BattleEvaluator.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * BattleEvaluator.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/AI_Base.h"
  12. #include "../../lib/battle/ReachabilityInfo.h"
  13. #include "PossibleSpellcast.h"
  14. #include "PotentialTargets.h"
  15. #include "BattleExchangeVariant.h"
  16. VCMI_LIB_NAMESPACE_BEGIN
  17. class CSpell;
  18. VCMI_LIB_NAMESPACE_END
  19. class EnemyInfo;
  20. class BattleEvaluator
  21. {
  22. std::unique_ptr<PotentialTargets> targets;
  23. std::shared_ptr<HypotheticBattle> hb;
  24. BattleExchangeEvaluator scoreEvaluator;
  25. std::shared_ptr<CBattleCallback> cb;
  26. std::shared_ptr<Environment> env;
  27. bool activeActionMade = false;
  28. std::optional<AttackPossibility> cachedAttack;
  29. PlayerColor playerID;
  30. BattleID battleID;
  31. BattleSide side;
  32. float cachedScore;
  33. DamageCache damageCache;
  34. float strengthRatio;
  35. int simulationTurnsCount;
  36. public:
  37. BattleAction selectStackAction(const CStack * stack);
  38. bool attemptCastingSpell(const CStack * stack);
  39. bool canCastSpell();
  40. std::optional<PossibleSpellcast> findBestCreatureSpell(const CStack * stack);
  41. BattleAction goTowardsNearest(const CStack * stack, std::vector<BattleHex> hexes, const PotentialTargets & targets);
  42. std::vector<BattleHex> getBrokenWallMoatHexes() const;
  43. void evaluateCreatureSpellcast(const CStack * stack, PossibleSpellcast & ps); //for offensive damaging spells only
  44. void print(const std::string & text) const;
  45. BattleAction moveOrAttack(const CStack * stack, BattleHex hex, const PotentialTargets & targets);
  46. BattleEvaluator(
  47. std::shared_ptr<Environment> env,
  48. std::shared_ptr<CBattleCallback> cb,
  49. const battle::Unit * activeStack,
  50. PlayerColor playerID,
  51. BattleID battleID,
  52. BattleSide side,
  53. float strengthRatio,
  54. int simulationTurnsCount);
  55. BattleEvaluator(
  56. std::shared_ptr<Environment> env,
  57. std::shared_ptr<CBattleCallback> cb,
  58. std::shared_ptr<HypotheticBattle> hb,
  59. DamageCache & damageCache,
  60. const battle::Unit * activeStack,
  61. PlayerColor playerID,
  62. BattleID battleID,
  63. BattleSide side,
  64. float strengthRatio,
  65. int simulationTurnsCount);
  66. };