mirror of
https://github.com/vcmi/vcmi.git
synced 2025-09-16 09:26:28 +02:00
CCeatureSet: add getArmyDescription for hover and InfoWindow texts
This commit is contained in:
@@ -225,14 +225,39 @@ ui64 CCreatureSet::getPower (SlotID slot) const
|
|||||||
return getStack(slot).getPower();
|
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));
|
int quantity = CCreature::getQuantityID(getStackCount(slot));
|
||||||
if (quantity)
|
if(quantity)
|
||||||
return VLC->generaltexth->arraytxt[174 + 3*CCreature::getQuantityID(getStackCount(slot))];
|
return VLC->generaltexth->arraytxt[(174 + mode) + 3*CCreature::getQuantityID(getStackCount(slot))];
|
||||||
return "";
|
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
|
int CCreatureSet::stacksCount() const
|
||||||
{
|
{
|
||||||
return stacks.size();
|
return stacks.size();
|
||||||
|
@@ -200,7 +200,8 @@ public:
|
|||||||
virtual bool needsLastStack() const; //true if last stack cannot be taken
|
virtual bool needsLastStack() const; //true if last stack cannot be taken
|
||||||
ui64 getArmyStrength() const; //sum of AI values of creatures
|
ui64 getArmyStrength() const; //sum of AI values of creatures
|
||||||
ui64 getPower (SlotID slot) const; //value of specific stack
|
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 hasStackAtSlot(SlotID slot) const;
|
||||||
|
|
||||||
bool contains(const CStackInstance *stack) const;
|
bool contains(const CStackInstance *stack) const;
|
||||||
|
Reference in New Issue
Block a user