mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
adf5c052f9
* updated changelog
54 lines
1.4 KiB
C++
54 lines
1.4 KiB
C++
#define VCMI_DLL
|
|
#include "IGameCallback.h"
|
|
#include "../CGameState.h"
|
|
#include "../map.h"
|
|
#include "../hch/CObjectHandler.h"
|
|
#include "../StartInfo.h"
|
|
|
|
const CGObjectInstance* IGameCallback::getObj(int objid)
|
|
{
|
|
return gs->map->objects[objid];
|
|
}
|
|
const CGHeroInstance* IGameCallback::getHero(int objid)
|
|
{
|
|
return dynamic_cast<const CGHeroInstance*>(gs->map->objects[objid]);
|
|
}
|
|
const CGTownInstance* IGameCallback::getTown(int objid)
|
|
{
|
|
return dynamic_cast<const CGTownInstance*>(gs->map->objects[objid]);
|
|
}
|
|
|
|
int IGameCallback::getOwner(int heroID)
|
|
{
|
|
return gs->map->objects[heroID]->tempOwner;
|
|
}
|
|
int IGameCallback::getResource(int player, int which)
|
|
{
|
|
return gs->players.find(player)->second.resources[which];
|
|
}
|
|
int IGameCallback::getDate(int mode)
|
|
{
|
|
return gs->getDate(mode);
|
|
}
|
|
|
|
const CGHeroInstance* IGameCallback::getSelectedHero( int player )
|
|
{
|
|
return getHero(gs->players.find(player)->second.currentSelection);
|
|
}
|
|
|
|
const PlayerSettings * IGameCallback::getPlayerSettings( int color )
|
|
{
|
|
return &gs->scenarioOps->getIthPlayersSettings(color);
|
|
}
|
|
|
|
int IGameCallback::getHeroCount( int player, bool includeGarrisoned )
|
|
{
|
|
int ret = 0;
|
|
if(includeGarrisoned)
|
|
return gs->players[player].heroes.size();
|
|
else
|
|
for(int i=0; i < gs->players[player].heroes.size(); i++)
|
|
if(!gs->players[player].heroes[i]->inTownGarrison)
|
|
ret++;
|
|
return ret;
|
|
} |