2015-12-02 21:39:53 +02:00
|
|
|
/*
|
|
|
|
* CPlayerState.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
|
|
|
|
*
|
|
|
|
*/
|
2017-07-13 10:26:03 +02:00
|
|
|
#pragma once
|
2015-12-02 21:39:53 +02:00
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
#include <vcmi/Player.h>
|
|
|
|
#include <vcmi/Team.h>
|
|
|
|
|
2015-12-02 21:39:53 +02:00
|
|
|
#include "HeroBonus.h"
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
#include "ResourceSet.h"
|
2015-12-02 21:39:53 +02:00
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2015-12-02 21:39:53 +02:00
|
|
|
class CGHeroInstance;
|
|
|
|
class CGTownInstance;
|
|
|
|
class CGDwelling;
|
2022-06-11 17:45:34 +02:00
|
|
|
struct QuestInfo;
|
2015-12-02 21:39:53 +02:00
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
struct DLL_LINKAGE PlayerState : public CBonusSystemNode, public Player
|
2015-12-02 21:39:53 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
PlayerColor color;
|
|
|
|
bool human; //true if human controlled player, false for AI
|
|
|
|
TeamID team;
|
|
|
|
TResources resources;
|
|
|
|
std::set<ObjectInstanceID> visitedObjects; // as a std::set, since most accesses here will be from visited status checks
|
|
|
|
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
|
|
|
|
std::vector<QuestInfo> quests; //store info about all received quests
|
|
|
|
|
|
|
|
bool enteredWinningCheatCode, enteredLosingCheatCode; //if true, this player has entered cheat codes for loss / victory
|
|
|
|
EPlayerStatus::EStatus status;
|
|
|
|
boost::optional<ui8> daysWithoutCastle;
|
|
|
|
|
|
|
|
PlayerState();
|
2023-03-13 23:26:44 +02:00
|
|
|
PlayerState(PlayerState && other) noexcept;
|
2016-07-29 11:27:55 +02:00
|
|
|
|
2015-12-02 21:39:53 +02:00
|
|
|
std::string nodeName() const override;
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
|
2023-04-04 16:52:33 +02:00
|
|
|
PlayerColor getId() const override;
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
TeamID getTeam() const override;
|
|
|
|
bool isHuman() const override;
|
2023-04-05 02:26:29 +02:00
|
|
|
const IBonusBearer * getBonusBearer() const override;
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
int getResourceAmount(int type) const override;
|
2015-12-02 21:39:53 +02:00
|
|
|
|
2023-04-04 16:52:33 +02:00
|
|
|
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;
|
|
|
|
|
2022-01-25 13:19:48 +02:00
|
|
|
bool checkVanquished() const
|
|
|
|
{
|
|
|
|
return heroes.empty() && towns.empty();
|
|
|
|
}
|
|
|
|
|
2015-12-02 21:39:53 +02:00
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
2017-07-31 15:35:42 +02:00
|
|
|
h & color;
|
|
|
|
h & human;
|
|
|
|
h & team;
|
|
|
|
h & resources;
|
|
|
|
h & status;
|
|
|
|
h & heroes;
|
|
|
|
h & towns;
|
|
|
|
h & availableHeroes;
|
|
|
|
h & dwellings;
|
|
|
|
h & quests;
|
|
|
|
h & visitedObjects;
|
|
|
|
h & status;
|
|
|
|
h & daysWithoutCastle;
|
|
|
|
h & enteredLosingCheatCode;
|
|
|
|
h & enteredWinningCheatCode;
|
2015-12-02 21:39:53 +02:00
|
|
|
h & static_cast<CBonusSystemNode&>(*this);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DLL_LINKAGE TeamState : public CBonusSystemNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TeamID id; //position in gameState::teams
|
|
|
|
std::set<PlayerColor> players; // members of this team
|
2016-12-12 22:38:12 +02:00
|
|
|
//TODO: boost::array, bool if possible
|
2022-09-18 16:39:10 +02:00
|
|
|
std::shared_ptr<boost::multi_array<ui8, 3>> fogOfWarMap; //[z][x][y] true - visible, false - hidden
|
2015-12-02 21:39:53 +02:00
|
|
|
|
|
|
|
TeamState();
|
2023-03-13 23:26:44 +02:00
|
|
|
TeamState(TeamState && other) noexcept;
|
2015-12-02 21:39:53 +02:00
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
2017-07-31 15:35:42 +02:00
|
|
|
h & id;
|
|
|
|
h & players;
|
|
|
|
h & fogOfWarMap;
|
2015-12-02 21:39:53 +02:00
|
|
|
h & static_cast<CBonusSystemNode&>(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
2022-07-26 15:07:42 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|