Răsfoiți Sursa

Additional functions to obtain precise info about stacks and armed instance for OnionKnight and general use.

DjWarmonger 16 ani în urmă
părinte
comite
6d6b3ae1ea
3 a modificat fișierele cu 26 adăugiri și 0 ștergeri
  1. 8 0
      hch/CObjectHandler.cpp
  2. 2 0
      hch/CObjectHandler.h
  3. 16 0
      int3.h

+ 8 - 0
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
 {

+ 2 - 0
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 <typename Handler> void serialize(Handler &h, const int version)
 	{

+ 16 - 0
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