CGameStateFwd.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. InfoAboutHero();
  46. InfoAboutHero(const InfoAboutHero & iah);
  47. InfoAboutHero(const CGHeroInstance *h, bool detailed);
  48. ~InfoAboutHero();
  49. InfoAboutHero & operator=(const InfoAboutHero & iah);
  50. void initFromHero(const CGHeroInstance *h, bool detailed);
  51. };
  52. /// Struct which holds a int information about a town
  53. struct DLL_LINKAGE InfoAboutTown : public InfoAboutArmy
  54. {
  55. struct DLL_LINKAGE Details
  56. {
  57. si32 hallLevel, goldIncome;
  58. bool customRes;
  59. bool garrisonedHero;
  60. } *details;
  61. const CTown *tType;
  62. si32 built;
  63. si32 fortLevel; //0 - none
  64. InfoAboutTown();
  65. InfoAboutTown(const CGTownInstance *t, bool detailed);
  66. ~InfoAboutTown();
  67. void initFromTown(const CGTownInstance *t, bool detailed);
  68. };
  69. class DLL_LINKAGE EVictoryLossCheckResult
  70. {
  71. public:
  72. static EVictoryLossCheckResult victory(std::string toSelf, std::string toOthers)
  73. {
  74. return EVictoryLossCheckResult(VICTORY, toSelf, toOthers);
  75. }
  76. static EVictoryLossCheckResult defeat(std::string toSelf, std::string toOthers)
  77. {
  78. return EVictoryLossCheckResult(DEFEAT, toSelf, toOthers);
  79. }
  80. EVictoryLossCheckResult():
  81. intValue(0)
  82. {
  83. }
  84. bool operator==(EVictoryLossCheckResult const & other) const
  85. {
  86. return intValue == other.intValue;
  87. }
  88. bool operator!=(EVictoryLossCheckResult const & other) const
  89. {
  90. return intValue != other.intValue;
  91. }
  92. bool victory() const
  93. {
  94. return intValue == VICTORY;
  95. }
  96. bool loss() const
  97. {
  98. return intValue == DEFEAT;
  99. }
  100. EVictoryLossCheckResult invert()
  101. {
  102. return EVictoryLossCheckResult(-intValue, messageToOthers, messageToSelf);
  103. }
  104. std::string messageToSelf;
  105. std::string messageToOthers;
  106. template <typename Handler> void serialize(Handler &h, const int version)
  107. {
  108. h & intValue & messageToSelf & messageToOthers;
  109. }
  110. private:
  111. enum EResult
  112. {
  113. DEFEAT = -1,
  114. INGAME = 0,
  115. VICTORY= +1
  116. };
  117. EVictoryLossCheckResult(si32 intValue, std::string toSelf, std::string toOthers):
  118. messageToSelf(toSelf),
  119. messageToOthers(toOthers),
  120. intValue(intValue)
  121. {
  122. }
  123. si32 intValue; // uses EResult
  124. };
  125. /*static std::ostream & operator<<(std::ostream & os, const EVictoryLossCheckResult & victoryLossCheckResult)
  126. {
  127. os << victoryLossCheckResult.messageToSelf;
  128. return os;
  129. }*/
  130. struct DLL_LINKAGE QuestInfo //universal interface for human and AI
  131. {
  132. const CQuest * quest;
  133. const CGObjectInstance * obj; //related object, most likely Seer Hut
  134. int3 tile;
  135. QuestInfo(){};
  136. QuestInfo (const CQuest * Quest, const CGObjectInstance * Obj, int3 Tile) :
  137. quest (Quest), obj (Obj), tile (Tile){};
  138. //FIXME: assignment operator should return QuestInfo &
  139. bool operator= (const QuestInfo &qi)
  140. {
  141. quest = qi.quest;
  142. obj = qi.obj;
  143. tile = qi.tile;
  144. return true;
  145. }
  146. bool operator== (const QuestInfo & qi) const
  147. {
  148. return (quest == qi.quest && obj == qi.obj);
  149. }
  150. //std::vector<std::string> > texts //allow additional info for quest log?
  151. template <typename Handler> void serialize(Handler &h, const int version)
  152. {
  153. h & quest & obj & tile;
  154. }
  155. };