1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

CCeatureSet: add getArmyDescription for hover and InfoWindow texts

This commit is contained in:
Arseniy Shestakov 2015-12-24 21:03:51 +03:00
parent a1f5a0a85c
commit 75ca020890
2 changed files with 30 additions and 4 deletions

View File

@ -225,14 +225,39 @@ ui64 CCreatureSet::getPower (SlotID slot) const
return getStack(slot).getPower();
}
std::string CCreatureSet::getRoughAmount (SlotID slot) const
std::string CCreatureSet::getRoughAmount(SlotID slot, int mode) const
{
/// Mode represent return string format
/// "Pack" - 0, "A pack of" - 1, "a pack of" - 2
int quantity = CCreature::getQuantityID(getStackCount(slot));
if (quantity)
return VLC->generaltexth->arraytxt[174 + 3*CCreature::getQuantityID(getStackCount(slot))];
if(quantity)
return VLC->generaltexth->arraytxt[(174 + mode) + 3*CCreature::getQuantityID(getStackCount(slot))];
return "";
}
std::string CCreatureSet::getArmyDescription() const
{
std::string text;
std::vector<std::string> guards;
for(auto & elem : stacks)
{
auto str = boost::str(boost::format("%s %s") % getRoughAmount(elem.first, 2) % getCreature(elem.first)->namePl);
guards.push_back(str);
}
if(guards.size())
{
for(int i = 0; i < guards.size(); i++)
{
text += guards[i];
if(i + 2 < guards.size())
text += ", ";
else if(i + 2 == guards.size())
text += VLC->generaltexth->allTexts[237];
}
}
return text;
}
int CCreatureSet::stacksCount() const
{
return stacks.size();

View File

@ -200,7 +200,8 @@ public:
virtual bool needsLastStack() const; //true if last stack cannot be taken
ui64 getArmyStrength() const; //sum of AI values of creatures
ui64 getPower (SlotID slot) const; //value of specific stack
std::string getRoughAmount (SlotID slot) const; //rough size of specific stack
std::string getRoughAmount(SlotID slot, int mode = 0) const; //rough size of specific stack
std::string getArmyDescription() const;
bool hasStackAtSlot(SlotID slot) const;
bool contains(const CStackInstance *stack) const;