mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
vcmi: PlayerState is now an Entity
This will reduce code duplication a little bit.
This commit is contained in:
parent
8968f0ef0e
commit
ee489f18d2
@ -10,19 +10,18 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "Entity.h"
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
class PlayerColor;
|
class PlayerColor;
|
||||||
class TeamID;
|
class TeamID;
|
||||||
class IBonusBearer;
|
class IBonusBearer;
|
||||||
|
|
||||||
class DLL_LINKAGE Player
|
class DLL_LINKAGE Player : public EntityWithBonuses<PlayerColor>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual PlayerColor getColor() const = 0;
|
|
||||||
virtual TeamID getTeam() const = 0;
|
virtual TeamID getTeam() const = 0;
|
||||||
virtual bool isHuman() const = 0;
|
virtual bool isHuman() const = 0;
|
||||||
virtual const IBonusBearer * accessBonuses() const = 0;
|
|
||||||
virtual int getResourceAmount(int type) const = 0;
|
virtual int getResourceAmount(int type) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -45,11 +45,37 @@ std::string PlayerState::nodeName() const
|
|||||||
return "Player " + color.getStrCap(false);
|
return "Player " + color.getStrCap(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerColor PlayerState::getColor() const
|
PlayerColor PlayerState::getId() const
|
||||||
{
|
{
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t PlayerState::getIndex() const
|
||||||
|
{
|
||||||
|
return color.getNum();
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t PlayerState::getIconIndex() const
|
||||||
|
{
|
||||||
|
return color.getNum();
|
||||||
|
}
|
||||||
|
std::string PlayerState::getJsonKey() const
|
||||||
|
{
|
||||||
|
return color.getStr(false);
|
||||||
|
}
|
||||||
|
std::string PlayerState::getNameTranslated() const
|
||||||
|
{
|
||||||
|
return color.getStr(true);
|
||||||
|
}
|
||||||
|
std::string PlayerState::getNameTextID() const
|
||||||
|
{
|
||||||
|
return color.getStr(false);
|
||||||
|
}
|
||||||
|
void PlayerState::registerIcons(const IconRegistar & cb) const
|
||||||
|
{
|
||||||
|
//We cannot register new icons for players
|
||||||
|
}
|
||||||
|
|
||||||
TeamID PlayerState::getTeam() const
|
TeamID PlayerState::getTeam() const
|
||||||
{
|
{
|
||||||
return team;
|
return team;
|
||||||
|
@ -45,12 +45,19 @@ public:
|
|||||||
|
|
||||||
std::string nodeName() const override;
|
std::string nodeName() const override;
|
||||||
|
|
||||||
PlayerColor getColor() const override;
|
PlayerColor getId() const override;
|
||||||
TeamID getTeam() const override;
|
TeamID getTeam() const override;
|
||||||
bool isHuman() const override;
|
bool isHuman() const override;
|
||||||
const IBonusBearer * accessBonuses() const override;
|
const IBonusBearer * accessBonuses() const override;
|
||||||
int getResourceAmount(int type) const override;
|
int getResourceAmount(int type) const override;
|
||||||
|
|
||||||
|
int32_t getIndex() const override;
|
||||||
|
int32_t getIconIndex() const override;
|
||||||
|
std::string getJsonKey() const override;
|
||||||
|
std::string getNameTranslated() const override;
|
||||||
|
std::string getNameTextID() const override;
|
||||||
|
void registerIcons(const IconRegistar & cb) const override;
|
||||||
|
|
||||||
bool checkVanquished() const
|
bool checkVanquished() const
|
||||||
{
|
{
|
||||||
return heroes.empty() && towns.empty();
|
return heroes.empty() && towns.empty();
|
||||||
|
Loading…
Reference in New Issue
Block a user