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. enum ActionType
  19. {
  20. END_TACTIC_PHASE = -2, INVALID = -1, NO_ACTION = 0, HERO_SPELL, WALK, DEFEND, RETREAT, SURRENDER, WALK_AND_ATTACK, SHOOT, WAIT, CATAPULT, MONSTER_SPELL, BAD_MORALE,
  21. STACK_HEAL, DAEMON_SUMMONING
  22. };
  23. si8 actionType; //use ActionType enum for values
  24. BattleHex destinationTile;
  25. si32 additionalInfo; // e.g. spell number if type is 1 || 10; tile to attack if type is 6
  26. template <typename Handler> void serialize(Handler &h, const int version)
  27. {
  28. h & side & stackNumber & actionType & destinationTile & additionalInfo;
  29. }
  30. BattleAction();
  31. static BattleAction makeDefend(const CStack *stack);
  32. static BattleAction makeWait(const CStack *stack);
  33. static BattleAction makeMeleeAttack(const CStack *stack, const CStack * attacked, BattleHex attackFrom = BattleHex::INVALID);
  34. static BattleAction makeShotAttack(const CStack *shooter, const CStack *target);
  35. static BattleAction makeMove(const CStack *stack, BattleHex dest);
  36. static BattleAction makeEndOFTacticPhase(ui8 side);
  37. };