2023-07-23 23:00:37 +02:00
|
|
|
/*
|
|
|
|
* BattleProcessor.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
|
|
|
|
|
2023-07-23 23:20:35 +02:00
|
|
|
#include "../../lib/GameConstants.h"
|
2023-07-23 23:00:37 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
2023-08-14 18:46:42 +02:00
|
|
|
class CGHeroInstance;
|
|
|
|
class CGTownInstance;
|
|
|
|
class CArmedInstance;
|
|
|
|
class BattleAction;
|
|
|
|
class int3;
|
2023-08-28 16:43:57 +02:00
|
|
|
class CBattleInfoCallback;
|
2023-08-14 18:46:42 +02:00
|
|
|
struct BattleResult;
|
2023-08-25 17:23:15 +02:00
|
|
|
class BattleID;
|
2023-07-23 23:00:37 +02:00
|
|
|
VCMI_LIB_NAMESPACE_END
|
|
|
|
|
2023-08-14 18:46:42 +02:00
|
|
|
class CGameHandler;
|
2023-07-23 23:00:37 +02:00
|
|
|
class CBattleQuery;
|
2023-08-14 18:46:42 +02:00
|
|
|
class BattleActionProcessor;
|
|
|
|
class BattleFlowProcessor;
|
|
|
|
class BattleResultProcessor;
|
2023-07-23 23:00:37 +02:00
|
|
|
|
2023-08-17 13:56:24 +02:00
|
|
|
/// Main class for battle handling. Contains all public interface for battles that is accessible from outside, e.g. for CGameHandler
|
2023-07-23 23:00:37 +02:00
|
|
|
class BattleProcessor : boost::noncopyable
|
|
|
|
{
|
2023-08-14 18:46:42 +02:00
|
|
|
friend class BattleActionProcessor;
|
|
|
|
friend class BattleFlowProcessor;
|
|
|
|
friend class BattleResultProcessor;
|
2023-07-23 23:00:37 +02:00
|
|
|
|
2023-08-14 18:46:42 +02:00
|
|
|
CGameHandler * gameHandler;
|
|
|
|
std::unique_ptr<BattleActionProcessor> actionsProcessor;
|
|
|
|
std::unique_ptr<BattleFlowProcessor> flowProcessor;
|
|
|
|
std::unique_ptr<BattleResultProcessor> resultProcessor;
|
2023-07-23 23:00:37 +02:00
|
|
|
|
2023-08-28 16:43:57 +02:00
|
|
|
void updateGateState(const CBattleInfoCallback & battle);
|
2023-08-17 13:56:24 +02:00
|
|
|
void engageIntoBattle(PlayerColor player);
|
2023-07-23 23:00:37 +02:00
|
|
|
|
2023-08-28 16:43:57 +02:00
|
|
|
bool checkBattleStateChanges(const CBattleInfoCallback & battle);
|
2023-08-25 17:23:15 +02:00
|
|
|
BattleID setupBattle(int3 tile, const CArmedInstance *armies[2], const CGHeroInstance *heroes[2], bool creatureBank, const CGTownInstance *town);
|
2023-07-23 23:00:37 +02:00
|
|
|
|
2023-08-28 16:43:57 +02:00
|
|
|
bool makeAutomaticBattleAction(const CBattleInfoCallback & battle, const BattleAction & ba);
|
2023-08-13 22:08:53 +02:00
|
|
|
|
2023-08-28 16:43:57 +02:00
|
|
|
void setBattleResult(const CBattleInfoCallback & battle, EBattleResult resultType, int victoriusSide);
|
2023-08-17 13:56:24 +02:00
|
|
|
|
2023-07-23 23:00:37 +02:00
|
|
|
public:
|
2023-08-14 18:46:42 +02:00
|
|
|
explicit BattleProcessor(CGameHandler * gameHandler);
|
2023-07-23 23:00:37 +02:00
|
|
|
BattleProcessor();
|
|
|
|
~BattleProcessor();
|
|
|
|
|
2023-08-14 18:46:42 +02:00
|
|
|
void setGameHandler(CGameHandler * gameHandler);
|
|
|
|
|
2023-08-17 13:56:24 +02:00
|
|
|
/// Starts battle with specified parameters
|
|
|
|
void startBattlePrimary(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool creatureBank = false, const CGTownInstance *town = nullptr);
|
|
|
|
/// Starts battle between two armies (which can also be heroes) at specified tile
|
|
|
|
void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, bool creatureBank = false);
|
|
|
|
/// Starts battle between two armies (which can also be heroes) at position of 2nd object
|
|
|
|
void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, bool creatureBank = false);
|
2023-09-05 16:22:11 +02:00
|
|
|
/// Restart ongoing battle and end previous battle
|
|
|
|
void restartBattlePrimary(const BattleID & battleID, const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool creatureBank = false, const CGTownInstance *town = nullptr);
|
2023-07-23 23:00:37 +02:00
|
|
|
|
2023-08-17 13:56:24 +02:00
|
|
|
/// Processing of incoming battle action netpack
|
2023-08-25 17:23:15 +02:00
|
|
|
bool makePlayerBattleAction(const BattleID & battleID, PlayerColor player, const BattleAction & ba);
|
2023-07-23 23:00:37 +02:00
|
|
|
|
2023-08-17 13:56:24 +02:00
|
|
|
/// Applies results of a battle once player agrees to them
|
2023-08-25 17:23:15 +02:00
|
|
|
void endBattleConfirm(const BattleID & battleID);
|
2023-08-17 13:56:24 +02:00
|
|
|
/// Applies results of a battle after potential levelup
|
2023-08-25 17:23:15 +02:00
|
|
|
void battleAfterLevelUp(const BattleID & battleID, const BattleResult & result);
|
2023-07-23 23:00:37 +02:00
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|