CGameStateFwd.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. class CQuest;
  12. class CGObjectInstance;
  13. class DLL_LINKAGE EVictoryLossCheckResult
  14. {
  15. public:
  16. static EVictoryLossCheckResult victory(std::string toSelf, std::string toOthers)
  17. {
  18. return EVictoryLossCheckResult(VICTORY, toSelf, toOthers);
  19. }
  20. static EVictoryLossCheckResult defeat(std::string toSelf, std::string toOthers)
  21. {
  22. return EVictoryLossCheckResult(DEFEAT, toSelf, toOthers);
  23. }
  24. EVictoryLossCheckResult():
  25. intValue(0)
  26. {
  27. }
  28. bool operator==(EVictoryLossCheckResult const & other) const
  29. {
  30. return intValue == other.intValue;
  31. }
  32. bool operator!=(EVictoryLossCheckResult const & other) const
  33. {
  34. return intValue != other.intValue;
  35. }
  36. bool victory() const
  37. {
  38. return intValue == VICTORY;
  39. }
  40. bool loss() const
  41. {
  42. return intValue == DEFEAT;
  43. }
  44. EVictoryLossCheckResult invert()
  45. {
  46. return EVictoryLossCheckResult(-intValue, messageToOthers, messageToSelf);
  47. }
  48. std::string messageToSelf;
  49. std::string messageToOthers;
  50. template <typename Handler> void serialize(Handler &h, const int version)
  51. {
  52. h & intValue & messageToSelf & messageToOthers;
  53. }
  54. private:
  55. enum EResult
  56. {
  57. DEFEAT = -1,
  58. INGAME = 0,
  59. VICTORY= +1
  60. };
  61. EVictoryLossCheckResult(si32 intValue, std::string toSelf, std::string toOthers):
  62. messageToSelf(toSelf),
  63. messageToOthers(toOthers),
  64. intValue(intValue)
  65. {
  66. }
  67. si32 intValue; // uses EResult
  68. };
  69. /*static std::ostream & operator<<(std::ostream & os, const EVictoryLossCheckResult & victoryLossCheckResult)
  70. {
  71. os << victoryLossCheckResult.messageToSelf;
  72. return os;
  73. }*/
  74. struct DLL_LINKAGE QuestInfo //universal interface for human and AI
  75. {
  76. const CQuest * quest;
  77. const CGObjectInstance * obj; //related object, most likely Seer Hut
  78. int3 tile;
  79. QuestInfo(){};
  80. QuestInfo (const CQuest * Quest, const CGObjectInstance * Obj, int3 Tile) :
  81. quest (Quest), obj (Obj), tile (Tile){};
  82. //FIXME: assignment operator should return QuestInfo &
  83. bool operator= (const QuestInfo &qi)
  84. {
  85. quest = qi.quest;
  86. obj = qi.obj;
  87. tile = qi.tile;
  88. return true;
  89. }
  90. bool operator== (const QuestInfo & qi) const
  91. {
  92. return (quest == qi.quest && obj == qi.obj);
  93. }
  94. //std::vector<std::string> > texts //allow additional info for quest log?
  95. template <typename Handler> void serialize(Handler &h, const int version)
  96. {
  97. h & quest & obj & tile;
  98. }
  99. };