BattleAction.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #include "StdInc.h"
  2. #include "BattleAction.h"
  3. #include "BattleState.h"
  4. /*
  5. * BattleAction.h, part of VCMI engine
  6. *
  7. * Authors: listed in file AUTHORS in main folder
  8. *
  9. * License: GNU General Public License v2.0 or later
  10. * Full text of license available in license.txt file, in main folder
  11. *
  12. */
  13. using namespace Battle;
  14. BattleAction::BattleAction()
  15. {
  16. side = -1;
  17. stackNumber = -1;
  18. actionType = INVALID;
  19. destinationTile = -1;
  20. additionalInfo = -1;
  21. }
  22. BattleAction BattleAction::makeHeal(const CStack *healer, const CStack *healed)
  23. {
  24. BattleAction ba;
  25. ba.side = !healer->attackerOwned;
  26. ba.actionType = STACK_HEAL;
  27. ba.stackNumber = healer->ID;
  28. ba.destinationTile = healed->position;
  29. return ba;
  30. }
  31. BattleAction BattleAction::makeDefend(const CStack *stack)
  32. {
  33. BattleAction ba;
  34. ba.side = !stack->attackerOwned;
  35. ba.actionType = DEFEND;
  36. ba.stackNumber = stack->ID;
  37. return ba;
  38. }
  39. BattleAction BattleAction::makeMeleeAttack(const CStack *stack, const CStack * attacked, BattleHex attackFrom /*= BattleHex::INVALID*/)
  40. {
  41. BattleAction ba;
  42. ba.side = !stack->attackerOwned;
  43. ba.actionType = WALK_AND_ATTACK;
  44. ba.stackNumber = stack->ID;
  45. ba.destinationTile = attackFrom;
  46. ba.additionalInfo = attacked->position;
  47. return ba;
  48. }
  49. BattleAction BattleAction::makeWait(const CStack *stack)
  50. {
  51. BattleAction ba;
  52. ba.side = !stack->attackerOwned;
  53. ba.actionType = WAIT;
  54. ba.stackNumber = stack->ID;
  55. return ba;
  56. }
  57. BattleAction BattleAction::makeShotAttack(const CStack *shooter, const CStack *target)
  58. {
  59. BattleAction ba;
  60. ba.side = !shooter->attackerOwned;
  61. ba.actionType = SHOOT;
  62. ba.stackNumber = shooter->ID;
  63. ba.destinationTile = target->position;
  64. return ba;
  65. }
  66. BattleAction BattleAction::makeMove(const CStack *stack, BattleHex dest)
  67. {
  68. BattleAction ba;
  69. ba.side = !stack->attackerOwned;
  70. ba.actionType = WALK;
  71. ba.stackNumber = stack->ID;
  72. ba.destinationTile = dest;
  73. return ba;
  74. }
  75. BattleAction BattleAction::makeEndOFTacticPhase(ui8 side)
  76. {
  77. BattleAction ba;
  78. ba.side = side;
  79. ba.actionType = END_TACTIC_PHASE;
  80. return ba;
  81. }