2011-12-14 00:23:17 +03:00
# pragma once
2010-05-02 21:20:26 +03:00
2012-11-07 23:14:31 +03:00
//#ifndef _MSC_VER
2010-12-20 23:22:53 +02:00
# include "CCreatureHandler.h"
2009-05-20 13:08:56 +03:00
# include "VCMI_Lib.h"
2013-04-07 13:48:07 +03:00
# include "mapping/CMap.h"
2012-11-07 23:14:31 +03:00
//#endif
2010-05-02 21:20:26 +03:00
2010-02-10 04:56:00 +02:00
# include "HeroBonus.h"
2010-05-02 21:20:26 +03:00
# include "CCreatureSet.h"
2010-12-20 15:04:24 +02:00
# include "ConstTransitivePtr.h"
2011-05-10 01:20:47 +03:00
# include "IGameCallback.h"
2011-07-05 09:14:07 +03:00
# include "ResourceSet.h"
2011-12-14 00:23:17 +03:00
# include "int3.h"
2012-07-07 11:45:45 +03:00
# include "CObjectHandler.h"
2013-02-02 01:04:25 +03:00
# include "IGameCallback.h"
2010-12-20 15:04:24 +02:00
2010-05-02 21:20:26 +03:00
2009-04-15 17:03:31 +03:00
/*
* CGameState . 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
*
*/
2008-12-27 03:01:59 +02:00
class CTown ;
class CScriptCallback ;
class CCallback ;
2010-06-07 08:28:12 +03:00
class IGameCallback ;
2008-12-27 03:01:59 +02:00
class CLuaCallback ;
class CCPPObjectScript ;
class CCreatureSet ;
class CStack ;
2012-05-16 20:29:05 +03:00
class CQuest ;
2008-12-27 03:01:59 +02:00
class CGHeroInstance ;
class CGTownInstance ;
class CArmedInstance ;
2009-10-24 22:21:32 +03:00
class CGDwelling ;
2008-12-27 03:01:59 +02:00
class CObjectScript ;
class CGObjectInstance ;
class CCreature ;
2012-11-03 22:31:16 +03:00
class CMap ;
2008-12-27 03:01:59 +02:00
struct StartInfo ;
struct SDL_Surface ;
class CMapHandler ;
class CPathfinder ;
struct SetObjectProperty ;
struct MetaString ;
2009-03-07 00:25:19 +02:00
struct CPack ;
2009-05-07 18:19:52 +03:00
class CSpell ;
2009-08-30 15:47:40 +03:00
struct TerrainTile ;
2010-02-07 17:06:14 +02:00
class CHeroClass ;
2010-05-08 21:56:38 +03:00
class CCampaign ;
2010-08-04 14:18:13 +03:00
class CCampaignState ;
2010-11-10 02:06:25 +02:00
class IModableArt ;
2011-05-03 06:14:18 +03:00
class CGGarrison ;
2011-12-14 00:23:17 +03:00
class CGameInfo ;
2012-05-16 20:29:05 +03:00
struct QuestInfo ;
2012-07-07 11:45:45 +03:00
class CQuest ;
2008-12-27 03:01:59 +02:00
namespace boost
{
class shared_mutex ;
}
2011-09-24 04:15:36 +03:00
//numbers of creatures are exact numbers if detailed else they are quantity ids (0 - a few, 1 - several and so on; additionally -1 - unknown)
2013-02-16 17:03:47 +03:00
struct ArmyDescriptor : public std : : map < SlotID , CStackBasicDescriptor >
2010-12-06 01:10:02 +02:00
{
2012-11-03 22:31:16 +03:00
bool isDetailed ;
2011-12-14 00:23:17 +03:00
DLL_LINKAGE ArmyDescriptor ( const CArmedInstance * army , bool detailed ) ; //not detailed -> quantity ids as count
DLL_LINKAGE ArmyDescriptor ( ) ;
2011-08-25 18:24:37 +03:00
2011-12-14 00:23:17 +03:00
DLL_LINKAGE int getStrength ( ) const ;
2010-12-06 01:10:02 +02:00
} ;
2012-06-13 16:04:06 +03:00
struct DLL_LINKAGE InfoAboutArmy
{
2013-03-03 20:06:03 +03:00
PlayerColor owner ;
2012-06-13 16:04:06 +03:00
std : : string name ;
ArmyDescriptor army ;
InfoAboutArmy ( ) ;
InfoAboutArmy ( const CArmedInstance * Army , bool detailed ) ;
void initFromArmy ( const CArmedInstance * Army , bool detailed ) ;
} ;
struct DLL_LINKAGE InfoAboutHero : public InfoAboutArmy
2010-02-07 17:06:14 +02:00
{
2010-02-07 19:56:06 +02:00
private :
void assign ( const InfoAboutHero & iah ) ;
public :
2011-12-14 00:23:17 +03:00
struct DLL_LINKAGE Details
2010-02-07 17:06:14 +02:00
{
2012-06-13 16:04:06 +03:00
std : : vector < si32 > primskills ;
si32 mana , luck , morale ;
2010-02-07 17:06:14 +02:00
} * details ;
const CHeroClass * hclass ;
int portrait ;
2010-12-06 01:10:02 +02:00
2010-02-07 17:06:14 +02:00
InfoAboutHero ( ) ;
2010-02-07 19:56:06 +02:00
InfoAboutHero ( const InfoAboutHero & iah ) ;
2012-06-13 16:04:06 +03:00
InfoAboutHero ( const CGHeroInstance * h , bool detailed ) ;
2010-02-07 17:06:14 +02:00
~ InfoAboutHero ( ) ;
2012-06-13 16:04:06 +03:00
InfoAboutHero & operator = ( const InfoAboutHero & iah ) ;
2010-02-07 17:06:14 +02:00
void initFromHero ( const CGHeroInstance * h , bool detailed ) ;
} ;
2011-12-14 00:23:17 +03:00
/// Struct which holds a int information about a town
2012-06-13 16:04:06 +03:00
struct DLL_LINKAGE InfoAboutTown : public InfoAboutArmy
2011-05-03 06:14:18 +03:00
{
2012-06-13 16:04:06 +03:00
struct DLL_LINKAGE Details
2011-05-03 06:14:18 +03:00
{
2012-06-13 16:04:06 +03:00
si32 hallLevel , goldIncome ;
2011-05-03 06:14:18 +03:00
bool customRes ;
bool garrisonedHero ;
} * details ;
CTown * tType ;
2012-06-13 16:04:06 +03:00
si32 built ;
si32 fortLevel ; //0 - none
2011-05-03 06:14:18 +03:00
InfoAboutTown ( ) ;
2012-06-13 16:04:06 +03:00
InfoAboutTown ( const CGTownInstance * t , bool detailed ) ;
2011-05-03 06:14:18 +03:00
~ InfoAboutTown ( ) ;
void initFromTown ( const CGTownInstance * t , bool detailed ) ;
} ;
2010-07-15 06:04:57 +03:00
// typedef si32 TResourceUnit;
// typedef std::vector<si32> TResourceVector;
// typedef std::set<si32> TResourceSet;
2010-02-07 17:06:14 +02:00
2011-12-14 00:23:17 +03:00
struct DLL_LINKAGE SThievesGuildInfo
2010-02-01 19:51:33 +02:00
{
2013-03-03 20:06:03 +03:00
std : : vector < PlayerColor > playerColors ; //colors of players that are in-game
2010-02-01 19:51:33 +02:00
2013-03-03 20:06:03 +03:00
std : : vector < std : : vector < PlayerColor > > numOfTowns , numOfHeroes , gold , woodOre , mercSulfCrystGems , obelisks , artifacts , army , income ; // [place] -> [colours of players]
2010-02-01 19:51:33 +02:00
2013-03-03 20:06:03 +03:00
std : : map < PlayerColor , InfoAboutHero > colorToBestHero ; //maps player's color to his best heros'
2010-02-01 19:51:33 +02:00
2013-03-03 20:06:03 +03:00
std : : map < PlayerColor , EAiTactic : : EAiTactic > personality ; // color to personality // ai tactic
std : : map < PlayerColor , si32 > bestCreature ; // color to ID // id or -1 if not known
2010-02-06 15:49:14 +02:00
2010-02-07 17:06:14 +02:00
// template <typename Handler> void serialize(Handler &h, const int version)
// {
// h & playerColors & numOfTowns & numOfHeroes & gold & woodOre & mercSulfCrystGems & obelisks & artifacts & army & income;
// h & colorToBestHero & personality & bestCreature;
// }
2010-02-01 19:51:33 +02:00
} ;
2011-12-14 00:23:17 +03:00
struct DLL_LINKAGE PlayerState : public CBonusSystemNode
2008-12-27 03:01:59 +02:00
{
public :
2013-03-03 20:06:03 +03:00
PlayerColor color ;
2013-02-09 15:56:35 +03:00
bool human ; //true if human controlled player, false for AI
2013-02-14 02:55:42 +03:00
ObjectInstanceID currentSelection ; //id of hero/town, 0xffffffff if none
2013-03-03 20:06:03 +03:00
TeamID team ;
2011-07-05 09:14:07 +03:00
TResources resources ;
2010-12-20 15:04:24 +02:00
std : : vector < ConstTransitivePtr < CGHeroInstance > > heroes ;
std : : vector < ConstTransitivePtr < CGTownInstance > > towns ;
std : : vector < ConstTransitivePtr < CGHeroInstance > > availableHeroes ; //heroes available in taverns
std : : vector < ConstTransitivePtr < CGDwelling > > dwellings ; //used for town growth
2012-05-16 20:29:05 +03:00
std : : vector < QuestInfo > quests ; //store info about all received quests
2009-09-07 05:29:44 +03:00
2013-02-09 15:56:35 +03:00
bool enteredWinningCheatCode , enteredLosingCheatCode ; //if true, this player has entered cheat codes for loss / victory
EPlayerStatus : : EStatus status ;
2010-01-29 22:52:45 +02:00
ui8 daysWithoutCastle ;
2009-09-07 05:29:44 +03:00
PlayerState ( ) ;
2013-06-26 14:18:27 +03:00
std : : string nodeName ( ) const override ;
2010-05-14 05:18:37 +03:00
2008-12-27 03:01:59 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
2010-08-03 15:34:06 +03:00
h & color & human & currentSelection & team & resources & status ;
2012-03-31 18:10:16 +03:00
h & heroes & towns & availableHeroes & dwellings ;
2012-11-03 22:31:16 +03:00
h & getBonusList ( ) ; //FIXME FIXME FIXME
2010-11-10 02:06:25 +02:00
h & status & daysWithoutCastle ;
2010-07-30 14:29:42 +03:00
h & enteredLosingCheatCode & enteredWinningCheatCode ;
2010-05-02 21:20:26 +03:00
h & static_cast < CBonusSystemNode & > ( * this ) ;
2008-12-27 03:01:59 +02:00
}
} ;
2011-12-14 00:23:17 +03:00
struct DLL_LINKAGE TeamState : public CBonusSystemNode
2010-08-03 15:34:06 +03:00
{
public :
2013-03-03 20:06:03 +03:00
TeamID id ; //position in gameState::teams
std : : set < PlayerColor > players ; // members of this team
2010-08-03 15:34:06 +03:00
std : : vector < std : : vector < std : : vector < ui8 > > > fogOfWarMap ; //true - visible, false - hidden
2012-11-03 22:31:16 +03:00
2011-02-21 06:13:00 +02:00
TeamState ( ) ;
2012-11-03 22:31:16 +03:00
2010-08-03 15:34:06 +03:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
2010-12-22 22:14:40 +02:00
h & id & players & fogOfWarMap ;
2010-08-03 15:34:06 +03:00
h & static_cast < CBonusSystemNode & > ( * this ) ;
}
} ;
2008-12-27 03:01:59 +02:00
struct UpgradeInfo
{
2013-02-11 02:24:57 +03:00
CreatureID oldID ; //creature to be upgraded
std : : vector < CreatureID > newID ; //possible upgrades
2011-07-05 09:14:07 +03:00
std : : vector < TResources > cost ; // cost[upgrade_serial] -> set of pairs<resource_ID,resource_amount>; cost is for single unit (not entire stack)
2013-02-07 20:34:50 +03:00
UpgradeInfo ( ) { oldID = CreatureID : : NONE ; } ;
2008-12-27 03:01:59 +02:00
} ;
2012-01-03 04:55:26 +03:00
struct DLL_LINKAGE CGPathNode
2009-08-28 12:03:58 +03:00
{
2011-09-19 23:50:25 +03:00
enum EAccessibility
2009-12-20 19:14:14 +02:00
{
2013-02-06 02:16:13 +03:00
NOT_SET = 0 ,
ACCESSIBLE = 1 , //tile can be entered and passed
2009-12-20 19:14:14 +02:00
VISITABLE , //tile can be entered as the last tile in path
BLOCKVIS , //visitable from neighbouring tile but not passable
2011-09-19 23:50:25 +03:00
BLOCKED //tile can't be entered nor visited
2009-12-20 19:14:14 +02:00
} ;
2013-02-06 02:16:13 +03:00
EAccessibility accessible ;
2009-08-30 15:47:40 +03:00
ui8 land ;
2009-08-28 12:03:58 +03:00
ui8 turns ;
ui32 moveRemains ;
2009-08-30 15:47:40 +03:00
CGPathNode * theNodeBefore ;
int3 coord ; //coordinates
2012-01-03 04:55:26 +03:00
2009-08-28 12:03:58 +03:00
CGPathNode ( ) ;
2012-01-03 04:55:26 +03:00
bool reachable ( ) const ;
2009-08-28 12:03:58 +03:00
} ;
2011-12-14 00:23:17 +03:00
struct DLL_LINKAGE CGPath
2009-08-30 15:47:40 +03:00
{
std : : vector < CGPathNode > nodes ; //just get node by node
int3 startPos ( ) const ; // start point
int3 endPos ( ) const ; //destination point
void convert ( ui8 mode ) ; //mode=0 -> from 'manifest' to 'object'
} ;
2011-12-14 00:23:17 +03:00
struct DLL_LINKAGE CPathsInfo
2009-08-28 12:03:58 +03:00
{
2011-09-03 05:54:33 +03:00
bool isValid ;
2009-09-07 05:29:44 +03:00
const CGHeroInstance * hero ;
int3 hpos ;
2009-08-28 12:03:58 +03:00
int3 sizes ;
CGPathNode * * * nodes ; //[w][h][level]
2009-08-30 15:47:40 +03:00
bool getPath ( const int3 & dst , CGPath & out ) ;
CPathsInfo ( const int3 & Sizes ) ;
2009-08-28 12:03:58 +03:00
~ CPathsInfo ( ) ;
} ;
2012-07-26 03:48:44 +03:00
struct DLL_EXPORT DuelParameters
2011-01-21 04:36:30 +02:00
{
2013-02-13 01:24:48 +03:00
ETerrainType terType ;
BFieldType bfieldType ;
2012-07-26 03:48:44 +03:00
struct DLL_EXPORT SideSettings
2011-01-21 04:36:30 +02:00
{
2012-07-26 03:48:44 +03:00
struct DLL_EXPORT StackSettings
2011-01-21 04:36:30 +02:00
{
2013-02-11 02:24:57 +03:00
CreatureID type ;
2011-01-21 04:36:30 +02:00
si32 count ;
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & type & count ;
}
StackSettings ( ) ;
2013-02-11 02:24:57 +03:00
StackSettings ( CreatureID Type , si32 Count ) ;
2012-07-26 03:48:44 +03:00
} stacks [ GameConstants : : ARMY_SIZE ] ;
2011-01-21 04:36:30 +02:00
si32 heroId ; //-1 if none
2012-07-26 03:48:44 +03:00
std : : vector < si32 > heroPrimSkills ; //may be empty
std : : map < si32 , CArtifactInstance * > artifacts ;
std : : vector < std : : pair < si32 , si8 > > heroSecSkills ; //may be empty; pairs <id, level>, level [0-3]
2013-02-11 02:24:57 +03:00
std : : set < SpellID > spells ;
2011-01-21 04:36:30 +02:00
SideSettings ( ) ;
template < typename Handler > void serialize ( Handler & h , const int version )
{
2012-07-26 03:48:44 +03:00
h & stacks & heroId & heroPrimSkills & artifacts & heroSecSkills & spells ;
2011-01-21 04:36:30 +02:00
}
} sides [ 2 ] ;
2012-07-26 03:48:44 +03:00
std : : vector < shared_ptr < CObstacleInstance > > obstacles ;
static DuelParameters fromJSON ( const std : : string & fname ) ;
struct CusomCreature
{
int id ;
int attack , defense , dmg , HP , speed , shoots ;
2012-11-03 22:31:16 +03:00
CusomCreature ( )
2012-07-26 03:48:44 +03:00
{
id = attack = defense = dmg = HP = speed = shoots = - 1 ;
}
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & id & attack & defense & dmg & HP & speed & shoots ;
}
} ;
std : : vector < CusomCreature > creatures ;
2011-01-21 04:36:30 +02:00
DuelParameters ( ) ;
template < typename Handler > void serialize ( Handler & h , const int version )
{
2012-07-26 03:48:44 +03:00
h & terType & bfieldType & sides & obstacles & creatures ;
2011-01-21 04:36:30 +02:00
}
} ;
2011-09-19 23:50:25 +03:00
class CPathfinder : private CGameInfoCallback
{
2012-01-03 04:55:26 +03:00
private :
2011-09-19 23:50:25 +03:00
bool useSubterraneanGates ;
bool allowEmbarkAndDisembark ;
CPathsInfo & out ;
const CGHeroInstance * hero ;
const std : : vector < std : : vector < std : : vector < ui8 > > > & FoW ;
std : : list < CGPathNode * > mq ; //BFS queue -> nodes to be checked
int3 curPos ;
CGPathNode * cp ; //current (source) path node -> we took it from the queue
CGPathNode * dp ; //destination node -> it's a neighbour of cp that we consider
const TerrainTile * ct , * dt ; //tile info for both nodes
ui8 useEmbarkCost ; //0 - usual movement; 1 - embark; 2 - disembark
int destTopVisObjID ;
CGPathNode * getNode ( const int3 & coord ) ;
void initializeGraph ( ) ;
2012-01-03 04:55:26 +03:00
bool goodForLandSeaTransition ( ) ; //checks if current move will be between sea<->land. If so, checks it legality (returns false if movement is not possible) and sets useEmbarkCost
2011-09-19 23:50:25 +03:00
2012-01-03 04:55:26 +03:00
CGPathNode : : EAccessibility evaluateAccessibility ( const TerrainTile * tinfo ) const ;
2011-09-19 23:50:25 +03:00
bool canMoveBetween ( const int3 & a , const int3 & b ) const ; //checks only for visitable objects that may make moving between tiles impossible, not other conditions (like tiles itself accessibility)
2012-01-03 04:55:26 +03:00
public :
CPathfinder ( CPathsInfo & _out , CGameState * _gs , const CGHeroInstance * _hero ) ;
2013-06-26 14:18:27 +03:00
void calculatePaths ( int3 src = int3 ( - 1 , - 1 , - 1 ) , int movement = - 1 ) ; //calculates possible paths for hero, by default uses current hero position and movement left; returns pointer to newly allocated CPath or nullptr if path does not exists
2011-09-19 23:50:25 +03:00
} ;
2011-01-21 04:36:30 +02:00
2011-05-04 05:38:58 +03:00
struct BattleInfo ;
2010-12-25 21:23:30 +02:00
2011-12-14 00:23:17 +03:00
class DLL_LINKAGE CGameState : public CNonConstInfoCallback
2008-12-27 03:01:59 +02:00
{
2009-03-07 00:11:17 +02:00
public :
2010-12-20 15:04:24 +02:00
ConstTransitivePtr < StartInfo > scenarioOps , initialOpts ; //second one is a copy of settings received from pregame (not randomized)
2013-03-03 20:06:03 +03:00
PlayerColor currentPlayer ; //ID of player currently having turn
2010-12-20 23:22:53 +02:00
ConstTransitivePtr < BattleInfo > curB ; //current battle
2008-12-27 03:01:59 +02:00
ui32 day ; //total number of days in game
2012-10-26 20:51:05 +03:00
ConstTransitivePtr < CMap > map ;
2013-03-03 20:06:03 +03:00
bmap < PlayerColor , PlayerState > players ;
bmap < TeamID , TeamState > teams ;
2010-05-02 21:20:26 +03:00
CBonusSystemNode globalEffects ;
2008-12-27 03:01:59 +02:00
2011-12-14 00:23:17 +03:00
struct DLL_LINKAGE HeroesPool
2008-12-27 03:01:59 +02:00
{
2013-06-26 14:18:27 +03:00
bmap < ui32 , ConstTransitivePtr < CGHeroInstance > > heroesPool ; //[subID] - heroes available to buy; nullptr if not available
2010-12-20 15:04:24 +02:00
bmap < ui32 , ui8 > pavailable ; // [subid] -> which players can recruit hero (binary flags)
2008-12-27 03:01:59 +02:00
2013-06-26 14:18:27 +03:00
CGHeroInstance * pickHeroFor ( bool native , PlayerColor player , const CTown * town , bmap < ui32 , ConstTransitivePtr < CGHeroInstance > > & available , const CHeroClass * bannedClass = nullptr ) const ;
2009-01-06 20:42:20 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & heroesPool & pavailable ;
}
2008-12-27 03:01:59 +02:00
} hpool ; //we have here all heroes available on this map that are not hired
boost : : shared_mutex * mx ;
2011-05-10 01:20:47 +03:00
2012-04-14 05:20:22 +03:00
void init ( StartInfo * si ) ;
2012-07-26 03:48:44 +03:00
2013-05-29 01:47:15 +03:00
bool isUsedHero ( HeroTypeID hid ) const ; //looks in heroes and prisons
void placeCampaignHeroes ( const std : : vector < std : : pair < CGHeroInstance * , ObjectInstanceID > > & campHeroReplacements ) ;
std : : vector < std : : pair < CGHeroInstance * , ObjectInstanceID > > campaignHeroesToReplace ( ) ; //returns heroes and placeholders in where heroes will be put; may remove some placeholders
std : : set < HeroTypeID > getUnusedAllowedHeroes ( bool alsoIncludeNotAllowed = false ) const ;
2012-07-26 03:48:44 +03:00
void initDuel ( ) ;
2008-12-27 03:01:59 +02:00
void randomizeObject ( CGObjectInstance * cur ) ;
2013-02-11 02:24:57 +03:00
std : : pair < Obj , int > pickObject ( CGObjectInstance * obj ) ; //chooses type of object to be randomized, returns <type, subtype>
2013-03-03 20:06:03 +03:00
int pickHero ( PlayerColor owner ) ;
2013-02-19 01:37:22 +03:00
void giveHeroArtifact ( CGHeroInstance * h , ArtifactID aid ) ;
2012-02-17 22:30:40 +03:00
2009-03-07 00:25:19 +02:00
void apply ( CPack * pack ) ;
2013-02-13 01:24:48 +03:00
BFieldType battleGetBattlefieldType ( int3 tile ) const ;
2010-07-15 06:04:57 +03:00
UpgradeInfo getUpgradeInfo ( const CStackInstance & stack ) ;
2013-03-03 20:06:03 +03:00
PlayerRelations : : PlayerRelations getPlayerRelations ( PlayerColor color1 , PlayerColor color2 ) ;
2009-08-30 15:47:40 +03:00
bool checkForVisitableDir ( const int3 & src , const int3 & dst ) const ; //check if src tile is visitable from dst tile
bool checkForVisitableDir ( const int3 & src , const TerrainTile * pom , const int3 & dst ) const ; //check if src tile is visitable from dst tile
2013-06-26 14:18:27 +03:00
void calculatePaths ( const CGHeroInstance * hero , CPathsInfo & out , int3 src = int3 ( - 1 , - 1 , - 1 ) , int movement = - 1 ) ; //calculates possible paths for hero, by default uses current hero position and movement left; returns pointer to newly allocated CPath or nullptr if path does not exists
2010-05-06 15:13:31 +03:00
int3 guardingCreaturePosition ( int3 pos ) const ;
2012-11-15 00:19:32 +03:00
std : : vector < CGObjectInstance * > guardingCreatures ( int3 pos ) const ;
2013-03-03 20:06:03 +03:00
int victoryCheck ( PlayerColor player ) const ; //checks if given player is winner; -1 if std victory, 1 if special victory, 0 else
int lossCheck ( PlayerColor player ) const ; //checks if given player is loser; -1 if std loss, 1 if special, 0 else
PlayerColor checkForStandardWin ( ) const ; //returns color of player that accomplished standard victory conditions or 255 (NEUTRAL) if no winner
bool checkForStandardLoss ( PlayerColor player ) const ; //checks if given player lost the game
2010-02-01 19:51:33 +02:00
void obtainPlayersStats ( SThievesGuildInfo & tgi , int level ) ; //fills tgi with info about other players that is available at given level of thieves' guild
2010-12-20 15:04:24 +02:00
bmap < ui32 , ConstTransitivePtr < CGHeroInstance > > unusedHeroesFromPool ( ) ; //heroes pool without heroes that are available in taverns
2010-12-22 22:14:40 +02:00
BattleInfo * setupBattle ( int3 tile , const CArmedInstance * armies [ 2 ] , const CGHeroInstance * heroes [ 2 ] , bool creatureBank , const CGTownInstance * town ) ;
2011-02-04 16:58:14 +02:00
void buildBonusSystemTree ( ) ;
2011-02-22 11:47:25 +02:00
void attachArmedObjects ( ) ;
void buildGlobalTeamPlayerTree ( ) ;
void deserializationFix ( ) ;
2009-03-07 00:11:17 +02:00
2013-03-03 20:06:03 +03:00
bool isVisible ( int3 pos , PlayerColor player ) ;
bool isVisible ( const CGObjectInstance * obj , boost : : optional < PlayerColor > player ) ;
2009-07-30 15:49:45 +03:00
2009-05-07 20:20:41 +03:00
CGameState ( ) ; //c-tor
2012-04-08 13:34:23 +03:00
virtual ~ CGameState ( ) ; //d-tor
2010-07-10 05:15:49 +03:00
void getNeighbours ( const TerrainTile & srct , int3 tile , std : : vector < int3 > & vec , const boost : : logic : : tribool & onLand , bool limitCoastSailing ) ;
2009-08-30 15:47:40 +03:00
int getMovementCost ( const CGHeroInstance * h , const int3 & src , const int3 & dest , int remainingMovePoints = - 1 , bool checkLast = true ) ;
2013-02-02 11:29:57 +03:00
int getDate ( Date : : EDateType mode = Date : : DAY ) const ; //mode=0 - total days in game, mode=1 - day of week, mode=2 - current week, mode=3 - current month
2008-12-27 03:01:59 +02:00
template < typename Handler > void serialize ( Handler & h , const int version )
{
2012-09-21 20:59:54 +03:00
h & scenarioOps & initialOpts & currentPlayer & day & map & players & teams & hpool & globalEffects ;
2011-02-23 05:57:45 +02:00
BONUS_TREE_DESERIALIZATION_FIX
2008-12-27 03:01:59 +02:00
}
friend class CCallback ;
friend class CLuaCallback ;
friend class CClient ;
2012-10-26 20:51:05 +03:00
friend void initGameState ( CMap * map , CGameInfo * cgi ) ;
2008-12-27 03:01:59 +02:00
friend class IGameCallback ;
friend class CMapHandler ;
friend class CGameHandler ;
} ;
2012-11-03 22:31:16 +03:00
2012-05-16 20:29:05 +03:00
struct DLL_LINKAGE QuestInfo //universal interface for human and AI
{
2012-10-03 17:49:29 +03:00
const CQuest * quest ;
2012-07-06 22:12:04 +03:00
const CGObjectInstance * obj ; //related object, most likely Seer Hut
2012-05-16 20:29:05 +03:00
int3 tile ;
2012-07-06 22:12:04 +03:00
QuestInfo ( ) { } ;
2012-07-08 11:42:03 +03:00
QuestInfo ( const CQuest * Quest , const CGObjectInstance * Obj , int3 Tile ) :
2012-10-03 17:49:29 +03:00
quest ( Quest ) , obj ( Obj ) , tile ( Tile ) { } ;
2012-09-28 18:46:09 +03:00
bool operator = ( const QuestInfo & qi )
{
quest = qi . quest ;
obj = qi . obj ;
tile = qi . tile ;
return true ;
}
2012-07-06 22:12:04 +03:00
2012-09-26 16:13:39 +03:00
bool operator = = ( const QuestInfo & qi ) const
2012-07-08 19:36:20 +03:00
{
return ( quest = = qi . quest & & obj = = qi . obj ) ;
}
2012-05-16 20:29:05 +03:00
//std::vector<std::string> > texts //allow additional info for quest log?
template < typename Handler > void serialize ( Handler & h , const int version )
{
h & quest & obj & tile ;
}
2012-11-03 22:31:16 +03:00
} ;