1
0
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:
Konstantin 2023-04-04 17:52:33 +03:00
parent 8968f0ef0e
commit ee489f18d2
3 changed files with 37 additions and 5 deletions

View File

@ -10,19 +10,18 @@
#pragma once
#include "Entity.h"
VCMI_LIB_NAMESPACE_BEGIN
class PlayerColor;
class TeamID;
class IBonusBearer;
class DLL_LINKAGE Player
class DLL_LINKAGE Player : public EntityWithBonuses<PlayerColor>
{
public:
virtual PlayerColor getColor() const = 0;
virtual TeamID getTeam() const = 0;
virtual bool isHuman() const = 0;
virtual const IBonusBearer * accessBonuses() const = 0;
virtual int getResourceAmount(int type) const = 0;
};

View File

@ -45,11 +45,37 @@ std::string PlayerState::nodeName() const
return "Player " + color.getStrCap(false);
}
PlayerColor PlayerState::getColor() const
PlayerColor PlayerState::getId() const
{
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
{
return team;

View File

@ -45,12 +45,19 @@ public:
std::string nodeName() const override;
PlayerColor getColor() const override;
PlayerColor getId() const override;
TeamID getTeam() const override;
bool isHuman() const override;
const IBonusBearer * accessBonuses() 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
{
return heroes.empty() && towns.empty();