2023-08-14 18:46:42 +02:00
|
|
|
/*
|
|
|
|
* BattleActionProcessor.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
struct BattleLogMessage;
|
|
|
|
struct BattleAttack;
|
|
|
|
class BattleAction;
|
|
|
|
struct BattleHex;
|
|
|
|
class CStack;
|
2023-08-17 18:18:14 +02:00
|
|
|
class PlayerColor;
|
2023-08-14 18:46:42 +02:00
|
|
|
enum class BonusType;
|
|
|
|
|
2023-08-17 13:56:24 +02:00
|
|
|
namespace battle
|
|
|
|
{
|
2023-08-14 18:46:42 +02:00
|
|
|
class Unit;
|
|
|
|
class CUnitState;
|
|
|
|
}
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|
|
|
|
|
|
|
|
class CGameHandler;
|
2023-08-16 23:51:50 +02:00
|
|
|
class BattleProcessor;
|
2023-08-14 18:46:42 +02:00
|
|
|
|
2023-08-17 13:56:24 +02:00
|
|
|
/// Processes incoming battle action queries and applies requested action(s)
|
2023-08-14 18:46:42 +02:00
|
|
|
class BattleActionProcessor : boost::noncopyable
|
|
|
|
{
|
|
|
|
using FireShieldInfo = std::vector<std::pair<const CStack *, int64_t>>;
|
|
|
|
|
|
|
|
BattleProcessor * owner;
|
|
|
|
CGameHandler * gameHandler;
|
|
|
|
|
|
|
|
int moveStack(int stack, BattleHex dest); //returned value - travelled distance
|
|
|
|
void makeAttack(const CStack * attacker, const CStack * defender, int distance, BattleHex targetHex, bool first, bool ranged, bool counter);
|
|
|
|
|
|
|
|
void handleAttackBeforeCasting(bool ranged, const CStack * attacker, const CStack * defender);
|
|
|
|
void handleAfterAttackCasting(bool ranged, const CStack * attacker, const CStack * defender);
|
|
|
|
void attackCasting(bool ranged, BonusType attackMode, const battle::Unit * attacker, const battle::Unit * defender);
|
|
|
|
|
|
|
|
// damage, drain life & fire shield; returns amount of drained life
|
|
|
|
int64_t applyBattleEffects(BattleAttack & bat, std::shared_ptr<battle::CUnitState> attackerState, FireShieldInfo & fireShield, const CStack * def, int distance, bool secondary);
|
|
|
|
|
|
|
|
void sendGenericKilledLog(const CStack * defender, int32_t killed, bool multiple);
|
|
|
|
void addGenericKilledLog(BattleLogMessage & blm, const CStack * defender, int32_t killed, bool multiple);
|
|
|
|
|
2023-08-16 23:51:50 +02:00
|
|
|
bool canStackAct(const CStack * stack);
|
|
|
|
|
|
|
|
bool doEmptyAction(const BattleAction & ba);
|
|
|
|
bool doEndTacticsAction(const BattleAction & ba);
|
|
|
|
bool doRetreatAction(const BattleAction & ba);
|
|
|
|
bool doSurrenderAction(const BattleAction & ba);
|
|
|
|
bool doHeroSpellAction(const BattleAction & ba);
|
|
|
|
bool doWalkAction(const BattleAction & ba);
|
|
|
|
bool doWaitAction(const BattleAction & ba);
|
|
|
|
bool doDefendAction(const BattleAction & ba);
|
|
|
|
bool doAttackAction(const BattleAction & ba);
|
|
|
|
bool doShootAction(const BattleAction & ba);
|
|
|
|
bool doCatapultAction(const BattleAction & ba);
|
|
|
|
bool doUnitSpellAction(const BattleAction & ba);
|
|
|
|
bool doHealAction(const BattleAction & ba);
|
|
|
|
|
|
|
|
bool dispatchBattleAction(const BattleAction & ba);
|
2023-08-17 18:18:14 +02:00
|
|
|
bool makeBattleActionImpl(const BattleAction & ba);
|
2023-08-16 23:51:50 +02:00
|
|
|
|
2023-08-14 18:46:42 +02:00
|
|
|
public:
|
2023-08-16 23:51:50 +02:00
|
|
|
explicit BattleActionProcessor(BattleProcessor * owner);
|
2023-08-14 18:46:42 +02:00
|
|
|
void setGameHandler(CGameHandler * newGameHandler);
|
|
|
|
|
2023-08-17 18:18:14 +02:00
|
|
|
bool makeAutomaticBattleAction(const BattleAction & ba);
|
|
|
|
bool makePlayerBattleAction(PlayerColor player, const BattleAction & ba);
|
2023-08-14 18:46:42 +02:00
|
|
|
};
|