mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Additional functions to obtain precise info about stacks and armed instance for OnionKnight and general use.
This commit is contained in:
@@ -2035,6 +2035,14 @@ int CArmedInstance::getArmyStrength() const
|
||||
ret += VLC->creh->creatures[i->second.first].AIValue * i->second.second;
|
||||
return ret;
|
||||
}
|
||||
ui64 CArmedInstance::getPower (TSlot slot) const
|
||||
{
|
||||
return VLC->creh->creatures[army.getCreature(slot)].AIValue * army.getAmount(slot);
|
||||
}
|
||||
std::string CArmedInstance::getRoughAmount (TSlot slot) const
|
||||
{
|
||||
return VLC->generaltexth->arraytxt[174 + 3*CCreature::getQuantityID(army.getAmount(slot))];
|
||||
}
|
||||
|
||||
/*const std::string & CGCreature::getHoverText() const
|
||||
{
|
||||
|
@@ -195,6 +195,8 @@ public:
|
||||
CCreatureSet army; //army
|
||||
virtual bool needsLastStack() const; //true if last stack cannot be taken
|
||||
int getArmyStrength() const; //sum of AI values of creatures
|
||||
ui64 getPower (TSlot slot) const; //value of specific stack
|
||||
std::string getRoughAmount (TSlot slot) const; //rought size of specific stack
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
|
16
int3.h
16
int3.h
@@ -28,6 +28,22 @@ public:
|
||||
TSlots slots; //slots[slot_id]=> pair(creature_id,creature_quantity)
|
||||
ui8 formation; //false - wide, true - tight
|
||||
|
||||
int getCreature (TSlot slot) const //workaround of map issue
|
||||
{
|
||||
std::map<TSlot, TStack>::const_iterator i = slots.find(slot);
|
||||
if (i != slots.end())
|
||||
return i->second.first;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
int getAmount (TSlot slot) const
|
||||
{
|
||||
std::map<TSlot, TStack>::const_iterator i = slots.find(slot);
|
||||
if (i != slots.end())
|
||||
return i->second.second;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
bool setCreature (TSlot slot, TCreature type, TQuantity quantity) //slots 0 to 6
|
||||
{
|
||||
slots[slot] = TStack(type, quantity); //brutal force
|
||||
|
Reference in New Issue
Block a user