BattleAction.h 1.6 KB

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