AttackPossibility.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * AttackPossibility.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 "../../lib/battle/CUnitState.h"
  12. #include "../../CCallback.h"
  13. #include "common.h"
  14. #include "StackWithBonuses.h"
  15. #define BATTLE_TRACE_LEVEL 0
  16. /// <summary>
  17. /// Evaluate attack value of one particular attack taking into account various effects like
  18. /// retaliation, 2-hex breath, collateral damage, shooters blocked damage
  19. /// </summary>
  20. class AttackPossibility
  21. {
  22. public:
  23. BattleHex from; //tile from which we attack
  24. BattleHex dest; //tile which we attack
  25. BattleAttackInfo attack;
  26. std::shared_ptr<battle::CUnitState> attackerState;
  27. std::vector<std::shared_ptr<battle::CUnitState>> affectedUnits;
  28. int64_t defenderDamageReduce = 0;
  29. int64_t attackerDamageReduce = 0; //usually by counter-attack
  30. int64_t collateralDamageReduce = 0; // friendly fire (usually by two-hex attacks)
  31. int64_t shootersBlockedDmg = 0;
  32. AttackPossibility(BattleHex from, BattleHex dest, const BattleAttackInfo & attack_);
  33. int64_t damageDiff() const;
  34. int64_t attackValue() const;
  35. static AttackPossibility evaluate(const BattleAttackInfo & attackInfo, BattleHex hex, const HypotheticBattle & state);
  36. static int64_t calculateDamageReduce(
  37. const battle::Unit * attacker,
  38. const battle::Unit * defender,
  39. uint64_t damageDealt,
  40. const CBattleInfoCallback & cb);
  41. private:
  42. static int64_t evaluateBlockedShootersDmg(const BattleAttackInfo & attackInfo, BattleHex hex, const HypotheticBattle & state);
  43. };