2014-06-25 17:11:07 +03:00
|
|
|
/*
|
|
|
|
* CGameStateFwd.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
|
2014-06-25 17:11:07 +03:00
|
|
|
|
2015-12-02 21:39:53 +02:00
|
|
|
#include "CCreatureSet.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 "int3.h"
|
2015-12-02 21:39:53 +02:00
|
|
|
|
2014-06-25 17:11:07 +03:00
|
|
|
class CQuest;
|
|
|
|
class CGObjectInstance;
|
2015-12-02 21:39:53 +02:00
|
|
|
class CHeroClass;
|
|
|
|
class CTown;
|
|
|
|
|
|
|
|
//numbers of creatures are exact numbers if detailed else they are quantity ids (1 - a few, 2 - several and so on; additionally 0 - unknown)
|
|
|
|
struct ArmyDescriptor : public std::map<SlotID, CStackBasicDescriptor>
|
|
|
|
{
|
|
|
|
bool isDetailed;
|
|
|
|
DLL_LINKAGE ArmyDescriptor(const CArmedInstance *army, bool detailed); //not detailed -> quantity ids as count
|
|
|
|
DLL_LINKAGE ArmyDescriptor();
|
|
|
|
|
|
|
|
DLL_LINKAGE int getStrength() const;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DLL_LINKAGE InfoAboutArmy
|
|
|
|
{
|
|
|
|
PlayerColor owner;
|
|
|
|
std::string name;
|
|
|
|
|
|
|
|
ArmyDescriptor army;
|
|
|
|
|
|
|
|
InfoAboutArmy();
|
|
|
|
InfoAboutArmy(const CArmedInstance *Army, bool detailed);
|
|
|
|
|
|
|
|
void initFromArmy(const CArmedInstance *Army, bool detailed);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DLL_LINKAGE InfoAboutHero : public InfoAboutArmy
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
void assign(const InfoAboutHero & iah);
|
2016-09-28 13:22:33 +02:00
|
|
|
|
2015-12-02 21:39:53 +02:00
|
|
|
public:
|
|
|
|
struct DLL_LINKAGE Details
|
|
|
|
{
|
|
|
|
std::vector<si32> primskills;
|
2016-09-27 13:48:04 +02:00
|
|
|
si32 mana, manaLimit, luck, morale;
|
2015-12-02 21:39:53 +02:00
|
|
|
} *details;
|
|
|
|
|
|
|
|
const CHeroClass *hclass;
|
|
|
|
int portrait;
|
|
|
|
|
2016-09-28 13:22:33 +02:00
|
|
|
enum EInfoLevel
|
|
|
|
{
|
|
|
|
BASIC,
|
|
|
|
DETAILED,
|
|
|
|
INBATTLE
|
|
|
|
};
|
|
|
|
|
2015-12-02 21:39:53 +02:00
|
|
|
InfoAboutHero();
|
|
|
|
InfoAboutHero(const InfoAboutHero & iah);
|
2016-09-28 13:22:33 +02:00
|
|
|
InfoAboutHero(const CGHeroInstance *h, EInfoLevel infoLevel);
|
2015-12-02 21:39:53 +02:00
|
|
|
~InfoAboutHero();
|
|
|
|
|
|
|
|
InfoAboutHero & operator=(const InfoAboutHero & iah);
|
|
|
|
|
2016-09-28 13:22:33 +02:00
|
|
|
void initFromHero(const CGHeroInstance *h, EInfoLevel infoLevel);
|
2015-12-02 21:39:53 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/// Struct which holds a int information about a town
|
|
|
|
struct DLL_LINKAGE InfoAboutTown : public InfoAboutArmy
|
|
|
|
{
|
|
|
|
struct DLL_LINKAGE Details
|
|
|
|
{
|
|
|
|
si32 hallLevel, goldIncome;
|
|
|
|
bool customRes;
|
|
|
|
bool garrisonedHero;
|
|
|
|
|
|
|
|
} *details;
|
|
|
|
|
|
|
|
const CTown *tType;
|
|
|
|
|
|
|
|
si32 built;
|
|
|
|
si32 fortLevel; //0 - none
|
|
|
|
|
|
|
|
InfoAboutTown();
|
|
|
|
InfoAboutTown(const CGTownInstance *t, bool detailed);
|
|
|
|
~InfoAboutTown();
|
|
|
|
void initFromTown(const CGTownInstance *t, bool detailed);
|
|
|
|
};
|
2014-06-25 17:11:07 +03:00
|
|
|
|
|
|
|
class DLL_LINKAGE EVictoryLossCheckResult
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static EVictoryLossCheckResult victory(std::string toSelf, std::string toOthers)
|
|
|
|
{
|
|
|
|
return EVictoryLossCheckResult(VICTORY, toSelf, toOthers);
|
|
|
|
}
|
|
|
|
|
|
|
|
static EVictoryLossCheckResult defeat(std::string toSelf, std::string toOthers)
|
|
|
|
{
|
|
|
|
return EVictoryLossCheckResult(DEFEAT, toSelf, toOthers);
|
|
|
|
}
|
|
|
|
|
|
|
|
EVictoryLossCheckResult():
|
|
|
|
intValue(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(EVictoryLossCheckResult const & other) const
|
|
|
|
{
|
|
|
|
return intValue == other.intValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(EVictoryLossCheckResult const & other) const
|
|
|
|
{
|
|
|
|
return intValue != other.intValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool victory() const
|
|
|
|
{
|
|
|
|
return intValue == VICTORY;
|
|
|
|
}
|
|
|
|
bool loss() const
|
|
|
|
{
|
|
|
|
return intValue == DEFEAT;
|
|
|
|
}
|
|
|
|
|
|
|
|
EVictoryLossCheckResult invert()
|
|
|
|
{
|
|
|
|
return EVictoryLossCheckResult(-intValue, messageToOthers, messageToSelf);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string messageToSelf;
|
|
|
|
std::string messageToOthers;
|
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
2017-07-31 15:35:42 +02:00
|
|
|
h & intValue;
|
|
|
|
h & messageToSelf;
|
|
|
|
h & messageToOthers;
|
2014-06-25 17:11:07 +03:00
|
|
|
}
|
|
|
|
private:
|
|
|
|
enum EResult
|
|
|
|
{
|
|
|
|
DEFEAT = -1,
|
|
|
|
INGAME = 0,
|
|
|
|
VICTORY= +1
|
|
|
|
};
|
|
|
|
|
|
|
|
EVictoryLossCheckResult(si32 intValue, std::string toSelf, std::string toOthers):
|
|
|
|
messageToSelf(toSelf),
|
|
|
|
messageToOthers(toOthers),
|
|
|
|
intValue(intValue)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
si32 intValue; // uses EResult
|
|
|
|
};
|
|
|
|
|
|
|
|
/*static std::ostream & operator<<(std::ostream & os, const EVictoryLossCheckResult & victoryLossCheckResult)
|
|
|
|
{
|
|
|
|
os << victoryLossCheckResult.messageToSelf;
|
|
|
|
return os;
|
|
|
|
}*/
|
|
|
|
|
|
|
|
struct DLL_LINKAGE QuestInfo //universal interface for human and AI
|
|
|
|
{
|
|
|
|
const CQuest * quest;
|
|
|
|
const CGObjectInstance * obj; //related object, most likely Seer Hut
|
|
|
|
int3 tile;
|
|
|
|
|
2016-11-27 21:07:01 +02:00
|
|
|
QuestInfo()
|
|
|
|
: quest(nullptr), obj(nullptr), tile(-1,-1,-1)
|
|
|
|
{};
|
2014-06-25 17:11:07 +03:00
|
|
|
QuestInfo (const CQuest * Quest, const CGObjectInstance * Obj, int3 Tile) :
|
|
|
|
quest (Quest), obj (Obj), tile (Tile){};
|
|
|
|
|
|
|
|
//FIXME: assignment operator should return QuestInfo &
|
|
|
|
bool operator= (const QuestInfo &qi)
|
|
|
|
{
|
|
|
|
quest = qi.quest;
|
|
|
|
obj = qi.obj;
|
|
|
|
tile = qi.tile;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator== (const QuestInfo & qi) const
|
|
|
|
{
|
|
|
|
return (quest == qi.quest && obj == qi.obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
//std::vector<std::string> > texts //allow additional info for quest log?
|
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
2017-07-31 15:35:42 +02:00
|
|
|
h & quest;
|
|
|
|
h & obj;
|
|
|
|
h & tile;
|
2014-06-25 17:11:07 +03:00
|
|
|
}
|
|
|
|
};
|