BattleAction.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #pragma once
  2. #ifndef __BATTLEACTION_H__
  3. #define __BATTLEACTION_H__
  4. #include "../global.h"
  5. /*
  6. * BattleAction.h, part of VCMI engine
  7. *
  8. * Authors: listed in file AUTHORS in main folder
  9. *
  10. * License: GNU General Public License v2.0 or later
  11. * Full text of license available in license.txt file, in main folder
  12. *
  13. */
  14. /// A struct which handles battle actions like defending, walking,... - represents a creature stack in a battle
  15. class CStack;
  16. struct DLL_EXPORT BattleAction
  17. {
  18. ui8 side; //who made this action: false - left, true - right player
  19. ui32 stackNumber;//stack ID, -1 left hero, -2 right hero,
  20. enum ActionType
  21. {
  22. 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, STACK_HEAL
  23. };
  24. si8 actionType; //use ActionType enum for values
  25. //10 = Monster casts a spell (i.e. Faerie Dragons) 11 - Bad morale freeze 12 - stacks heals another stack
  26. THex destinationTile;
  27. si32 additionalInfo; // e.g. spell number if type is 1 || 10; tile to attack if type is 6
  28. template <typename Handler> void serialize(Handler &h, const int version)
  29. {
  30. h & side & stackNumber & actionType & destinationTile & additionalInfo;
  31. }
  32. BattleAction();
  33. static BattleAction makeDefend(const CStack *stack);
  34. static BattleAction makeWait(const CStack *stack);
  35. static BattleAction makeMeleeAttack(const CStack *stack, const CStack * attacked, THex attackFrom = THex::INVALID);
  36. static BattleAction makeShotAttack(const CStack *shooter, const CStack *target);
  37. static BattleAction makeMove(const CStack *stack, THex dest);
  38. static BattleAction makeEndOFTacticPhase(ui8 side);
  39. };
  40. #endif // __BATTLEACTION_H__