2011-12-14 00:23:17 +03:00
# pragma once
2011-07-05 09:14:07 +03:00
# include "BattleAction.h"
# include "IGameEventsReceiver.h"
2014-09-21 16:42:08 +03:00
# include "CGameStateFwd.h"
2009-04-16 14:14:13 +03:00
2009-04-15 17:03:31 +03:00
/*
* CGameInterface . 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
*
2009-04-16 14:14:13 +03:00
*/
2013-11-07 15:48:41 +03:00
using boost : : logic : : tribool ;
2009-04-16 14:14:13 +03:00
class CCallback ;
2012-09-20 19:55:21 +03:00
class CBattleCallback ;
2009-04-16 14:14:13 +03:00
class ICallback ;
class CGlobalAI ;
2010-02-10 04:56:00 +02:00
struct Component ;
2009-04-16 14:14:13 +03:00
class CSelectableComponent ;
2009-07-03 22:57:14 +03:00
struct TryMoveHero ;
2009-04-16 14:14:13 +03:00
class CGHeroInstance ;
class CGTownInstance ;
class CGObjectInstance ;
2010-06-27 19:03:01 +03:00
class CGBlackMarket ;
2009-07-06 22:41:27 +03:00
class CGDwelling ;
2009-04-16 14:14:13 +03:00
class CCreatureSet ;
class CArmedInstance ;
2009-07-26 06:33:13 +03:00
class IShipyard ;
2010-05-18 10:01:54 +03:00
class IMarket ;
2009-04-16 14:14:13 +03:00
struct BattleResult ;
struct BattleAttack ;
struct BattleStackAttacked ;
2010-05-16 16:42:19 +03:00
struct BattleSpellCast ;
2009-04-16 14:14:13 +03:00
struct SetStackEffect ;
2010-05-02 21:20:26 +03:00
struct Bonus ;
2009-04-16 14:14:13 +03:00
struct PackageApplied ;
2009-07-30 15:49:45 +03:00
struct SetObjectProperty ;
2009-09-01 16:54:13 +03:00
struct CatapultAttack ;
2009-09-05 17:10:26 +03:00
struct BattleStacksRemoved ;
2010-12-14 23:55:23 +02:00
struct StackLocation ;
class CStackInstance ;
2012-05-16 20:29:05 +03:00
class CCommanderInstance ;
2010-12-23 22:18:10 +02:00
class CStack ;
2014-09-21 16:42:08 +03:00
class CPathsInfo ;
2010-12-14 23:55:23 +02:00
class CCreature ;
2009-04-16 14:14:13 +03:00
class CLoadFile ;
class CSaveFile ;
2014-12-21 16:27:50 +02:00
class CISer ;
class COSer ;
2011-01-06 22:00:19 +02:00
struct ArtifactLocation ;
2011-06-20 14:41:04 +03:00
class CScriptingModule ;
2009-04-16 14:14:13 +03:00
2013-05-09 14:09:23 +03:00
class DLL_LINKAGE CBattleGameInterface : public IBattleEventsReceiver
2009-04-16 14:14:13 +03:00
{
public :
bool human ;
2013-03-03 20:06:03 +03:00
PlayerColor playerID ;
2009-04-16 14:14:13 +03:00
std : : string dllName ;
2010-12-22 22:14:40 +02:00
virtual ~ CBattleGameInterface ( ) { } ;
2013-06-22 17:47:20 +03:00
virtual void init ( shared_ptr < CBattleCallback > CB ) { } ;
2010-12-22 22:14:40 +02:00
//battle call-ins
2010-12-23 22:18:10 +02:00
virtual BattleAction activeStack ( const CStack * stack ) = 0 ; //called when it's turn of that stack
2011-08-25 18:24:37 +03:00
virtual void yourTacticPhase ( int distance ) { } ; //called when interface has opportunity to use Tactics skill -> use cb->battleMakeTacticAction from this function
2013-05-09 14:09:23 +03:00
2014-12-21 16:27:50 +02:00
virtual void saveGame ( COSer & h , const int version ) ;
virtual void loadGame ( CISer & h , const int version ) ;
2013-05-09 14:09:23 +03:00
2010-12-22 22:14:40 +02:00
} ;
2011-02-22 13:52:36 +02:00
/// Central class for managing human player / AI interface logic
2014-09-21 16:42:08 +03:00
class DLL_LINKAGE CGameInterface : public CBattleGameInterface , public IGameEventsReceiver
2010-12-22 22:14:40 +02:00
{
public :
2013-06-22 17:47:20 +03:00
virtual void init ( shared_ptr < CCallback > CB ) { } ;
2011-07-17 21:49:05 +03:00
virtual void yourTurn ( ) { } ; //called AFTER playerStartsTurn(player)
2012-06-27 23:44:01 +03:00
//pskill is gained primary skill, interface has to choose one of given skills and call callback with selection id
2013-05-27 13:53:28 +03:00
virtual void heroGotLevel ( const CGHeroInstance * hero , PrimarySkill : : PrimarySkill pskill , std : : vector < SecondarySkill > & skills , QueryID queryID ) = 0 ;
virtual void commanderGotLevel ( const CCommanderInstance * commander , std : : vector < ui32 > skills , QueryID queryID ) = 0 ;
2012-06-27 23:44:01 +03:00
// Show a dialog, player must take decision. If selection then he has to choose between one of given components,
// if cancel he is allowed to not choose. After making choice, CCallback::selectionMade should be called
// with number of selected component (1 - n) or 0 for cancel (if allowed) and askID.
2013-05-27 13:53:28 +03:00
virtual void showBlockingDialog ( const std : : string & text , const std : : vector < Component > & components , QueryID askID , const int soundID , bool selection , bool cancel ) = 0 ;
2012-06-27 23:44:01 +03:00
// all stacks operations between these objects become allowed, interface has to call onEnd when done
2013-05-27 13:53:28 +03:00
virtual void showGarrisonDialog ( const CArmedInstance * up , const CGHeroInstance * down , bool removableUnits , QueryID queryID ) = 0 ;
2012-02-22 16:41:27 +03:00
virtual void finish ( ) { } ; //if for some reason we want to end
2009-04-16 14:14:13 +03:00
} ;
2010-12-22 22:14:40 +02:00
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CDynLibHandler
2009-04-16 14:14:13 +03:00
{
public :
2013-06-23 00:47:51 +03:00
static shared_ptr < CGlobalAI > getNewAI ( std : : string dllname ) ;
static shared_ptr < CBattleGameInterface > getNewBattleAI ( std : : string dllname ) ;
static shared_ptr < CScriptingModule > getNewScriptingModule ( std : : string dllname ) ;
2009-04-16 14:14:13 +03:00
} ;
2011-06-20 14:41:04 +03:00
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGlobalAI : public CGameInterface // AI class (to derivate)
2009-04-16 14:14:13 +03:00
{
public :
2011-07-05 09:14:07 +03:00
CGlobalAI ( ) ;
2013-06-26 14:18:27 +03:00
virtual BattleAction activeStack ( const CStack * stack ) override ;
2009-04-16 14:14:13 +03:00
} ;
2011-07-05 09:14:07 +03:00
//class to be inherited by adventure-only AIs, it cedes battle actions to given battle-AI
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CAdventureAI : public CGlobalAI
2011-07-05 09:14:07 +03:00
{
public :
2013-06-23 22:35:54 +03:00
CAdventureAI ( ) { } ;
2011-07-05 09:14:07 +03:00
2013-06-23 00:47:51 +03:00
shared_ptr < CBattleGameInterface > battleAI ;
2013-06-22 17:47:20 +03:00
shared_ptr < CBattleCallback > cbc ;
2011-07-05 09:14:07 +03:00
2012-09-29 13:59:43 +03:00
virtual std : : string getBattleAIName ( ) const = 0 ; //has to return name of the battle AI to be used
2011-07-05 09:14:07 +03:00
//battle interface
2011-07-05 22:05:41 +03:00
virtual BattleAction activeStack ( const CStack * stack ) ;
2011-08-25 18:24:37 +03:00
virtual void yourTacticPhase ( int distance ) ;
2011-07-05 09:14:07 +03:00
virtual void battleNewRound ( int round ) ;
virtual void battleCatapultAttacked ( const CatapultAttack & ca ) ;
virtual void battleStart ( const CCreatureSet * army1 , const CCreatureSet * army2 , int3 tile , const CGHeroInstance * hero1 , const CGHeroInstance * hero2 , bool side ) ;
virtual void battleStacksAttacked ( const std : : vector < BattleStackAttacked > & bsa ) ;
2013-05-09 14:09:23 +03:00
virtual void actionStarted ( const BattleAction & action ) ;
2011-07-05 09:14:07 +03:00
virtual void battleNewRoundFirst ( int round ) ;
2013-05-09 14:09:23 +03:00
virtual void actionFinished ( const BattleAction & action ) ;
2011-07-05 09:14:07 +03:00
virtual void battleStacksEffectsSet ( const SetStackEffect & sse ) ;
2011-10-08 16:02:58 +03:00
//virtual void battleTriggerEffect(const BattleTriggerEffect & bte);
2011-07-05 09:14:07 +03:00
virtual void battleStacksRemoved ( const BattleStacksRemoved & bsr ) ;
virtual void battleObstaclesRemoved ( const std : : set < si32 > & removedObstacles ) ;
virtual void battleNewStackAppeared ( const CStack * stack ) ;
2011-12-22 16:05:19 +03:00
virtual void battleStackMoved ( const CStack * stack , std : : vector < BattleHex > dest , int distance ) ;
2011-07-05 09:14:07 +03:00
virtual void battleAttack ( const BattleAttack * ba ) ;
virtual void battleSpellCast ( const BattleSpellCast * sc ) ;
virtual void battleEnd ( const BattleResult * br ) ;
virtual void battleStacksHealedRes ( const std : : vector < std : : pair < ui32 , ui32 > > & healedStacks , bool lifeDrain , bool tentHeal , si32 lifeDrainFrom ) ;
2013-05-09 14:09:23 +03:00
2014-12-21 16:27:50 +02:00
virtual void saveGame ( COSer & h , const int version ) ; //saving
virtual void loadGame ( CISer & h , const int version ) ; //loading
2011-07-05 09:14:07 +03:00
} ;