CGameStateFwd.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. #pragma once
  2. /*
  3. * CGameStateFwd.h, part of VCMI engine
  4. *
  5. * Authors: listed in file AUTHORS in main folder
  6. *
  7. * License: GNU General Public License v2.0 or later
  8. * Full text of license available in license.txt file, in main folder
  9. *
  10. */
  11. #include "CCreatureSet.h"
  12. class CQuest;
  13. class CGObjectInstance;
  14. class CHeroClass;
  15. class CTown;
  16. //numbers of creatures are exact numbers if detailed else they are quantity ids (1 - a few, 2 - several and so on; additionally 0 - unknown)
  17. struct ArmyDescriptor : public std::map<SlotID, CStackBasicDescriptor>
  18. {
  19. bool isDetailed;
  20. DLL_LINKAGE ArmyDescriptor(const CArmedInstance *army, bool detailed); //not detailed -> quantity ids as count
  21. DLL_LINKAGE ArmyDescriptor();
  22. DLL_LINKAGE int getStrength() const;
  23. };
  24. struct DLL_LINKAGE InfoAboutArmy
  25. {
  26. PlayerColor owner;
  27. std::string name;
  28. ArmyDescriptor army;
  29. InfoAboutArmy();
  30. InfoAboutArmy(const CArmedInstance *Army, bool detailed);
  31. void initFromArmy(const CArmedInstance *Army, bool detailed);
  32. };
  33. struct DLL_LINKAGE InfoAboutHero : public InfoAboutArmy
  34. {
  35. private:
  36. void assign(const InfoAboutHero & iah);
  37. public:
  38. struct DLL_LINKAGE Details
  39. {
  40. std::vector<si32> primskills;
  41. si32 mana, manaLimit, luck, morale;
  42. } *details;
  43. const CHeroClass *hclass;
  44. int portrait;
  45. enum EInfoLevel
  46. {
  47. BASIC,
  48. DETAILED,
  49. INBATTLE
  50. };
  51. InfoAboutHero();
  52. InfoAboutHero(const InfoAboutHero & iah);
  53. InfoAboutHero(const CGHeroInstance *h, EInfoLevel infoLevel);
  54. ~InfoAboutHero();
  55. InfoAboutHero & operator=(const InfoAboutHero & iah);
  56. void initFromHero(const CGHeroInstance *h, EInfoLevel infoLevel);
  57. };
  58. /// Struct which holds a int information about a town
  59. struct DLL_LINKAGE InfoAboutTown : public InfoAboutArmy
  60. {
  61. struct DLL_LINKAGE Details
  62. {
  63. si32 hallLevel, goldIncome;
  64. bool customRes;
  65. bool garrisonedHero;
  66. } *details;
  67. const CTown *tType;
  68. si32 built;
  69. si32 fortLevel; //0 - none
  70. InfoAboutTown();
  71. InfoAboutTown(const CGTownInstance *t, bool detailed);
  72. ~InfoAboutTown();
  73. void initFromTown(const CGTownInstance *t, bool detailed);
  74. };
  75. class DLL_LINKAGE EVictoryLossCheckResult
  76. {
  77. public:
  78. static EVictoryLossCheckResult victory(std::string toSelf, std::string toOthers)
  79. {
  80. return EVictoryLossCheckResult(VICTORY, toSelf, toOthers);
  81. }
  82. static EVictoryLossCheckResult defeat(std::string toSelf, std::string toOthers)
  83. {
  84. return EVictoryLossCheckResult(DEFEAT, toSelf, toOthers);
  85. }
  86. EVictoryLossCheckResult():
  87. intValue(0)
  88. {
  89. }
  90. bool operator==(EVictoryLossCheckResult const & other) const
  91. {
  92. return intValue == other.intValue;
  93. }
  94. bool operator!=(EVictoryLossCheckResult const & other) const
  95. {
  96. return intValue != other.intValue;
  97. }
  98. bool victory() const
  99. {
  100. return intValue == VICTORY;
  101. }
  102. bool loss() const
  103. {
  104. return intValue == DEFEAT;
  105. }
  106. EVictoryLossCheckResult invert()
  107. {
  108. return EVictoryLossCheckResult(-intValue, messageToOthers, messageToSelf);
  109. }
  110. std::string messageToSelf;
  111. std::string messageToOthers;
  112. template <typename Handler> void serialize(Handler &h, const int version)
  113. {
  114. h & intValue & messageToSelf & messageToOthers;
  115. }
  116. private:
  117. enum EResult
  118. {
  119. DEFEAT = -1,
  120. INGAME = 0,
  121. VICTORY= +1
  122. };
  123. EVictoryLossCheckResult(si32 intValue, std::string toSelf, std::string toOthers):
  124. messageToSelf(toSelf),
  125. messageToOthers(toOthers),
  126. intValue(intValue)
  127. {
  128. }
  129. si32 intValue; // uses EResult
  130. };
  131. /*static std::ostream & operator<<(std::ostream & os, const EVictoryLossCheckResult & victoryLossCheckResult)
  132. {
  133. os << victoryLossCheckResult.messageToSelf;
  134. return os;
  135. }*/
  136. struct DLL_LINKAGE QuestInfo //universal interface for human and AI
  137. {
  138. const CQuest * quest;
  139. const CGObjectInstance * obj; //related object, most likely Seer Hut
  140. int3 tile;
  141. QuestInfo(){};
  142. QuestInfo (const CQuest * Quest, const CGObjectInstance * Obj, int3 Tile) :
  143. quest (Quest), obj (Obj), tile (Tile){};
  144. //FIXME: assignment operator should return QuestInfo &
  145. bool operator= (const QuestInfo &qi)
  146. {
  147. quest = qi.quest;
  148. obj = qi.obj;
  149. tile = qi.tile;
  150. return true;
  151. }
  152. bool operator== (const QuestInfo & qi) const
  153. {
  154. return (quest == qi.quest && obj == qi.obj);
  155. }
  156. //std::vector<std::string> > texts //allow additional info for quest log?
  157. template <typename Handler> void serialize(Handler &h, const int version)
  158. {
  159. h & quest & obj & tile;
  160. }
  161. };