2008-12-27 03:01:59 +02:00
# ifndef __IGAMECALLBACK_H__
# define __IGAMECALLBACK_H__
# include "../global.h"
# include <vector>
# include <set>
# include "../client/FunctionList.h"
2010-05-02 21:20:26 +03:00
# include "CCreatureSet.h"
2008-12-27 03:01:59 +02:00
2009-04-15 17:03:31 +03:00
/*
* IGameCallback . 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-02-04 15:40:54 +02:00
struct SetMovePoints ;
struct GiveBonus ;
2008-12-27 03:01:59 +02:00
class CGObjectInstance ;
class CGTownInstance ;
class CGHeroInstance ;
2009-04-11 04:32:50 +03:00
struct BlockingDialog ;
2008-12-27 03:01:59 +02:00
struct InfoWindow ;
struct MetaString ;
struct ShowInInfobox ;
struct BattleResult ;
2009-09-21 12:00:33 +03:00
struct Component ;
2008-12-27 03:01:59 +02:00
class CGameState ;
2009-02-08 08:42:15 +02:00
struct PlayerSettings ;
2009-03-14 13:25:25 +02:00
struct CPackForClient ;
2009-04-16 03:28:54 +03:00
class CArtHandler ;
class CArtifact ;
2009-07-21 02:34:06 +03:00
class CArmedInstance ;
2009-07-26 06:33:13 +03:00
struct TerrainTile ;
2010-02-10 04:56:00 +02:00
struct PlayerState ;
2010-07-09 02:03:27 +03:00
class CTown ;
2010-11-27 03:46:19 +02:00
struct StackLocation ;
2010-12-26 16:34:11 +02:00
struct ArtifactLocation ;
class CArtifactInstance ;
2008-12-27 03:01:59 +02:00
class DLL_EXPORT IGameCallback
{
protected :
CGameState * gs ;
public :
virtual ~ IGameCallback ( ) { } ;
2009-08-19 09:56:53 +03:00
CGameState * const gameState ( ) ;
2008-12-27 03:01:59 +02:00
virtual int getOwner ( int heroID ) ;
virtual int getResource ( int player , int which ) ;
2009-05-25 02:21:55 +03:00
virtual int getDate ( int mode = 0 ) ; ////mode=0 - total days in game, mode=1 - day of week, mode=2 - current week, mode=3 - current month
2010-07-27 00:14:08 +03:00
virtual const CGObjectInstance * getObj ( int objid , bool verbose = true ) ;
2008-12-27 03:01:59 +02:00
virtual const CGHeroInstance * getHero ( int objid ) ;
virtual const CGTownInstance * getTown ( int objid ) ;
virtual const CGHeroInstance * getSelectedHero ( int player ) ; //NULL if no hero is selected
2011-02-11 14:27:38 +02:00
virtual const CGObjectInstance * getObjByQuestIdentifier ( int identifier ) ; //NULL if object has been removed (eg. killed)
2008-12-27 03:01:59 +02:00
virtual int getCurrentPlayer ( ) = 0 ;
2009-03-21 18:03:07 +02:00
virtual int getSelectedHero ( ) = 0 ;
2009-02-08 08:42:15 +02:00
virtual const PlayerSettings * getPlayerSettings ( int color ) ;
2009-02-14 21:12:40 +02:00
virtual int getHeroCount ( int player , bool includeGarrisoned ) ;
2011-01-20 19:25:15 +02:00
virtual void getTilesInRange ( boost : : unordered_set < int3 , ShashInt3 > & tiles , int3 pos , int radious , int player = - 1 , int mode = 0 ) ; //mode 1 - only unrevealed tiles; mode 0 - all, mode -1 - only unrevealed
virtual void getAllTiles ( boost : : unordered_set < int3 , ShashInt3 > & tiles , int player = - 1 , int level = - 1 , int surface = 0 ) ; //returns all tiles on given level (-1 - both levels, otherwise number of level); surface: 0 - land and water, 1 - only land, 2 - only water
2010-08-22 10:11:46 +03:00
virtual void getFreeTiles ( std : : vector < int3 > & tiles ) ; //used for random spawns
2010-07-20 17:08:13 +03:00
virtual bool isAllowed ( int type , int id ) ; //type: 0 - spell; 1- artifact; 2 - secondary skill
2009-10-24 22:21:32 +03:00
virtual ui16 getRandomArt ( int flags ) ;
2010-06-28 08:07:21 +03:00
virtual ui16 getArtSync ( ui32 rand , int flags ) ; //synchronic
2010-06-27 19:03:01 +03:00
virtual void pickAllowedArtsSet ( std : : vector < const CArtifact * > & out ) ; //gives 3 treasures, 3 minors, 1 major -> used by Black Market and Artifact Merchant
2010-06-28 08:07:21 +03:00
virtual void erasePickedArt ( si32 id ) ;
2009-09-24 20:54:02 +03:00
virtual void getAllowedSpells ( std : : vector < ui16 > & out , ui16 level ) ;
2009-08-24 13:35:11 +03:00
virtual int3 getMapSize ( ) ; //returns size of the map
2009-07-26 06:33:13 +03:00
virtual TerrainTile * getTile ( int3 pos ) ;
2010-02-10 04:56:00 +02:00
virtual const PlayerState * getPlayerState ( int color ) ;
2010-07-09 02:03:27 +03:00
virtual const CTown * getNativeTown ( int color ) ;
2008-12-27 03:01:59 +02:00
//do sth
virtual void changeSpells ( int hid , bool give , const std : : set < ui32 > & spells ) = 0 ;
2009-04-16 03:28:54 +03:00
virtual bool removeObject ( int objid ) = 0 ;
2008-12-27 03:01:59 +02:00
virtual void setBlockVis ( int objid , bool bv ) = 0 ;
virtual void setOwner ( int objid , ui8 owner ) = 0 ;
virtual void setHoverName ( int objid , MetaString * name ) = 0 ;
2009-08-17 13:02:29 +03:00
virtual void setObjProperty ( int objid , int prop , si64 val ) = 0 ;
2009-08-16 18:39:18 +03:00
virtual void changePrimSkill ( int ID , int which , si64 val , bool abs = false ) = 0 ;
2009-01-11 00:08:18 +02:00
virtual void changeSecSkill ( int ID , int which , int val , bool abs = false ) = 0 ;
2008-12-27 03:01:59 +02:00
virtual void showInfoDialog ( InfoWindow * iw ) = 0 ;
2009-04-11 04:32:50 +03:00
virtual void showBlockingDialog ( BlockingDialog * iw , const CFunctionList < void ( ui32 ) > & callback ) = 0 ;
2009-04-12 03:58:41 +03:00
virtual ui32 showBlockingDialog ( BlockingDialog * iw ) = 0 ; //synchronous version of above //TODO:
2009-09-09 20:49:03 +03:00
virtual void showGarrisonDialog ( int upobj , int hid , bool removableUnits , const boost : : function < void ( ) > & cb ) = 0 ; //cb will be called when player closes garrison window
2010-02-06 15:49:14 +02:00
virtual void showThievesGuildWindow ( int requestingObjId ) = 0 ;
2008-12-27 03:01:59 +02:00
virtual void giveResource ( int player , int which , int val ) = 0 ;
2010-12-26 16:34:11 +02:00
2010-12-13 01:44:16 +02:00
virtual void giveCreatures ( const CArmedInstance * objid , const CGHeroInstance * h , const CCreatureSet & creatures , bool remove ) = 0 ;
2010-11-22 02:34:46 +02:00
virtual void takeCreatures ( int objid , std : : vector < CStackBasicDescriptor > creatures ) = 0 ;
2010-11-27 22:17:28 +02:00
virtual bool changeStackCount ( const StackLocation & sl , TQuantity count , bool absoluteValue = false ) = 0 ;
virtual bool changeStackType ( const StackLocation & sl , CCreature * c ) = 0 ;
virtual bool insertNewStack ( const StackLocation & sl , const CCreature * c , TQuantity count = - 1 ) = 0 ; //count -1 => moves whole stack
2010-12-12 01:11:26 +02:00
virtual bool eraseStack ( const StackLocation & sl , bool forceRemoval = false ) = 0 ;
2010-11-27 22:17:28 +02:00
virtual bool swapStacks ( const StackLocation & sl1 , const StackLocation & sl2 ) = 0 ;
virtual bool addToSlot ( const StackLocation & sl , const CCreature * c , TQuantity count ) = 0 ; //makes new stack or increases count of already existing
2010-12-13 01:44:16 +02:00
virtual void tryJoiningArmy ( const CArmedInstance * src , const CArmedInstance * dst , bool removeObjWhenFinished , bool allowMerging ) = 0 ; //merges army from src do dst or opens a garrison window
2010-11-27 22:17:28 +02:00
virtual bool moveStack ( const StackLocation & src , const StackLocation & dst , TQuantity count ) = 0 ;
2010-12-26 16:34:11 +02:00
virtual void giveHeroNewArtifact ( const CGHeroInstance * h , const CArtifact * artType , int pos ) = 0 ;
virtual void giveHeroArtifact ( const CGHeroInstance * h , const CArtifactInstance * a , int pos ) = 0 ; //pos==-1 - first free slot in backpack=0; pos==-2 - default if available or backpack
virtual void putArtifact ( const ArtifactLocation & al , const CArtifactInstance * a ) = 0 ;
virtual void removeArtifact ( const ArtifactLocation & al ) = 0 ;
virtual void moveArtifact ( const ArtifactLocation & al1 , const ArtifactLocation & al2 ) = 0 ;
2008-12-27 03:01:59 +02:00
virtual void showCompInfo ( ShowInInfobox * comp ) = 0 ;
virtual void heroVisitCastle ( int obj , int heroID ) = 0 ;
virtual void stopHeroVisitCastle ( int obj , int heroID ) = 0 ;
2010-12-26 16:34:11 +02:00
//virtual void giveHeroArtifact(int artid, int hid, int position)=0; //pos==-1 - first free slot in backpack=0; pos==-2 - default if available or backpack
//virtual void giveNewArtifact(int hid, int position)=0;
2010-12-29 23:04:22 +02:00
//virtual bool removeArtifact(const CArtifact* art, int hid) = 0;
2009-09-13 01:17:23 +03:00
virtual void startBattleI ( const CArmedInstance * army1 , const CArmedInstance * army2 , int3 tile , const CGHeroInstance * hero1 , const CGHeroInstance * hero2 , bool creatureBank = false , boost : : function < void ( BattleResult * ) > cb = 0 , const CGTownInstance * town = NULL ) = 0 ; //use hero=NULL for no hero
virtual void startBattleI ( const CArmedInstance * army1 , const CArmedInstance * army2 , int3 tile , boost : : function < void ( BattleResult * ) > cb = 0 , bool creatureBank = false ) = 0 ; //if any of armies is hero, hero will be used
virtual void startBattleI ( const CArmedInstance * army1 , const CArmedInstance * army2 , boost : : function < void ( BattleResult * ) > cb = 0 , bool creatureBank = false ) = 0 ; //if any of armies is hero, hero will be used, visitable tile of second obj is place of battle
2009-07-21 02:34:06 +03:00
//virtual void startBattleI(int heroID, CCreatureSet army, int3 tile, boost::function<void(BattleResult*)> cb)=0; //for hero<=>neutral army
2008-12-27 03:01:59 +02:00
virtual void setAmount ( int objid , ui32 val ) = 0 ;
2009-04-16 03:28:54 +03:00
virtual bool moveHero ( si32 hid , int3 dst , ui8 instant , ui8 asker = 255 ) = 0 ;
2009-02-04 15:40:54 +02:00
virtual void giveHeroBonus ( GiveBonus * bonus ) = 0 ;
virtual void setMovePoints ( SetMovePoints * smp ) = 0 ;
2009-02-06 13:15:39 +02:00
virtual void setManaPoints ( int hid , int val ) = 0 ;
2009-02-14 21:12:40 +02:00
virtual void giveHero ( int id , int player ) = 0 ;
2009-02-20 12:36:15 +02:00
virtual void changeObjPos ( int objid , int3 newPos , ui8 flags ) = 0 ;
2009-03-14 13:25:25 +02:00
virtual void sendAndApply ( CPackForClient * info ) = 0 ;
2009-06-16 14:18:14 +03:00
virtual void heroExchange ( si32 hero1 , si32 hero2 ) = 0 ; //when two heroes meet on adventure map
2009-03-14 13:25:25 +02:00
2009-09-21 12:00:33 +03:00
friend struct CPack ;
2009-03-07 00:25:19 +02:00
friend struct CPackForClient ;
2009-03-09 12:37:49 +02:00
friend struct CPackForServer ;
2008-12-27 03:01:59 +02:00
} ;
# endif // __IGAMECALLBACK_H__