2011-12-14 00:23:17 +03:00
# pragma once
2011-07-05 09:14:07 +03:00
# include "BattleAction.h"
# include "IGameEventsReceiver.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
*/
using namespace boost : : logic ;
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 ;
2010-12-14 23:55:23 +02:00
class CCreature ;
2009-04-16 14:14:13 +03:00
class CLoadFile ;
class CSaveFile ;
template < typename Serializer > class CISer ;
template < typename Serializer > 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
2011-05-10 01:20:47 +03:00
class CBattleGameInterface : public IBattleEventsReceiver
2009-04-16 14:14:13 +03:00
{
public :
bool human ;
2010-08-03 14:36:52 +03:00
int playerID ;
2009-04-16 14:14:13 +03:00
std : : string dllName ;
2010-12-22 22:14:40 +02:00
virtual ~ CBattleGameInterface ( ) { } ;
2012-09-20 19:55:21 +03:00
virtual void init ( 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
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
2011-05-10 01:20:47 +03:00
class CGameInterface : public CBattleGameInterface , public IGameEventsReceiver
2010-12-22 22:14:40 +02:00
{
public :
2011-05-03 06:14:18 +03:00
virtual void init ( 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-02-04 22:43:16 +03:00
virtual void heroGotLevel ( const CGHeroInstance * hero , PrimarySkill : : PrimarySkill pskill , std : : vector < SecondarySkill : : SecondarySkill > & skills , int queryID ) = 0 ;
2012-07-15 18:34:00 +03:00
virtual void commanderGotLevel ( const CCommanderInstance * commander , std : : vector < ui32 > skills , int 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.
virtual void showBlockingDialog ( const std : : string & text , const std : : vector < Component > & components , ui32 askID , const int soundID , bool selection , bool cancel ) = 0 ;
// all stacks operations between these objects become allowed, interface has to call onEnd when done
2012-07-15 18:34:00 +03:00
virtual void showGarrisonDialog ( const CArmedInstance * up , const CGHeroInstance * down , bool removableUnits , int queryID ) = 0 ;
2009-04-16 14:14:13 +03:00
virtual void serialize ( COSer < CSaveFile > & h , const int version ) { } ; //saving
virtual void serialize ( CISer < CLoadFile > & h , const int version ) { } ; //loading
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 :
2011-02-23 05:57:45 +02:00
static CGlobalAI * getNewAI ( std : : string dllname ) ;
static CBattleGameInterface * getNewBattleAI ( std : : string dllname ) ;
2011-06-20 14:41:04 +03:00
static 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 ( ) ;
2010-12-23 22:18:10 +02: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 :
2011-07-05 22:05:41 +03:00
CAdventureAI ( ) : battleAI ( NULL ) , cbc ( NULL ) { } ;
2011-07-05 09:14:07 +03:00
CBattleGameInterface * battleAI ;
2012-09-20 19:55:21 +03:00
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 ) ;
virtual void actionStarted ( const BattleAction * action ) ;
virtual void battleNewRoundFirst ( int round ) ;
virtual void actionFinished ( const BattleAction * action ) ;
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 ) ;
} ;