diff --git a/hch/CObjectHandler.cpp b/hch/CObjectHandler.cpp index ef896f5f6..49fb1b6f8 100644 --- a/hch/CObjectHandler.cpp +++ b/hch/CObjectHandler.cpp @@ -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 { diff --git a/hch/CObjectHandler.h b/hch/CObjectHandler.h index ebf95882d..d84506b09 100644 --- a/hch/CObjectHandler.h +++ b/hch/CObjectHandler.h @@ -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 void serialize(Handler &h, const int version) { diff --git a/int3.h b/int3.h index 6ec02b3a1..2c008e924 100644 --- a/int3.h +++ b/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::const_iterator i = slots.find(slot); + if (i != slots.end()) + return i->second.first; + else + return -1; + } + int getAmount (TSlot slot) const + { + std::map::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