1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

refactor logic to CBattleInfoCallback and leave UI in BattleFieldController, BattleActionsController

- move fromWhichHexAttack to CBattleInfoCallback
- add toWhichHexMove (unifying incoherent duplicates)
- add battleGetOccupiableHexes
- add battleCanAttackHex for spatial attack check
- add battleCanAttackUnit for non-spatial attack check
- add headDirection to Unit (removing destShiftDir from CStack)
- remove redundant game logic from selectAttackDirection
- remove redundant game logic from BattleFieldController and BattleActionsController
- fix no consideration for double-wide tail attack in BattleFlowProcessor
- fix #6302 wrong moat stopping condition
- throw exception on attacker nullptr in battleCanAttackHex, fromWhichHexAttack
- safer actionIsLegal on attack, move
- remove redundant canStackMoveHere from ui code
- throw exception on nullptr unit in battleGetOccupiableHexes
- ensure activeStack in redrawBackgroundWithHexes
- test point validity in selectAttackDirection
This commit is contained in:
Andrej Dudenhefner
2025-11-09 22:12:49 +01:00
parent 81db5c7cf4
commit e72dcce8ba
12 changed files with 251 additions and 328 deletions

View File

@@ -66,8 +66,6 @@ public:
static BattleHexArray meleeAttackHexes(const battle::Unit * attacker, const battle::Unit * defender, BattleHex attackerPos = BattleHex::INVALID, BattleHex defenderPos = BattleHex::INVALID);
static bool isMeleeAttackPossible(const battle::Unit * attacker, const battle::Unit * defender, BattleHex attackerPos = BattleHex::INVALID, BattleHex defenderPos = BattleHex::INVALID);
BattleHex::EDir destShiftDir() const;
void prepareAttacked(BattleStackAttacked & bsa, vstd::RNG & rand) const; //requires bsa.damageAmount filled
static void prepareAttacked(BattleStackAttacked & bsa,
vstd::RNG & rand,