BattleAction.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * BattleAction.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "BattleHex.h"
  12. #include "../GameConstants.h"
  13. class CStack;
  14. /// A struct which handles battle actions like defending, walking,... - represents a creature stack in a battle
  15. struct DLL_LINKAGE BattleAction
  16. {
  17. ui8 side; //who made this action: false - left, true - right player
  18. ui32 stackNumber; //stack ID, -1 left hero, -2 right hero,
  19. Battle::ActionType actionType; //use ActionType enum for values
  20. BattleHex destinationTile;
  21. si32 additionalInfo; // e.g. spell number if type is 1 || 10; tile to attack if type is 6
  22. si32 selectedStack; //spell subject for teleport / sacrifice
  23. template <typename Handler> void serialize(Handler &h, const int version)
  24. {
  25. h & side;
  26. h & stackNumber;
  27. h & actionType;
  28. h & destinationTile;
  29. h & additionalInfo;
  30. h & selectedStack;
  31. }
  32. BattleAction();
  33. static BattleAction makeHeal(const CStack * healer, const CStack * healed);
  34. static BattleAction makeDefend(const CStack * stack);
  35. static BattleAction makeWait(const CStack * stack);
  36. static BattleAction makeMeleeAttack(const CStack * stack, const CStack * attacked, BattleHex attackFrom = BattleHex::INVALID);
  37. static BattleAction makeShotAttack(const CStack * shooter, const CStack * target);
  38. static BattleAction makeMove(const CStack * stack, BattleHex dest);
  39. static BattleAction makeEndOFTacticPhase(ui8 side);
  40. std::string toString() const;
  41. };
  42. DLL_EXPORT std::ostream & operator<<(std::ostream & os, const BattleAction & ba); //todo: remove