1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-21 00:19:29 +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.
This commit is contained in:
AlexVinS
2018-03-17 17:58:30 +03:00
committed by AlexVinS
parent 11bb46780a
commit ecaa9f5d0b
475 changed files with 22491 additions and 7123 deletions

View File

@ -433,8 +433,7 @@ void JsonUtils::parseTypedBonusShort(const JsonVector& source, std::shared_ptr<B
dest->turnsRemain = 0;
}
std::shared_ptr<Bonus> JsonUtils::parseBonus (const JsonVector &ability_vec) //TODO: merge with AddAbility, create universal parser for all bonus properties
std::shared_ptr<Bonus> JsonUtils::parseBonus(const JsonVector & ability_vec)
{
auto b = std::make_shared<Bonus>();
std::string type = ability_vec[0].String();
@ -449,8 +448,9 @@ std::shared_ptr<Bonus> JsonUtils::parseBonus (const JsonVector &ability_vec) //T
parseTypedBonusShort(ability_vec, b);
return b;
}
template <typename T>
const T & parseByMap(const std::map<std::string, T> & map, const JsonNode * val, std::string err)
const T parseByMap(const std::map<std::string, T> & map, const JsonNode * val, std::string err)
{
static T defaultValue = T();
if (!val->isNull())
@ -471,6 +471,15 @@ const T & parseByMap(const std::map<std::string, T> & map, const JsonNode * val,
return defaultValue;
}
template <typename T>
const T parseByMapN(const std::map<std::string, T> & map, const JsonNode * val, std::string err)
{
if(val->isNumber())
return static_cast<T>(val->Integer());
else
return parseByMap<T>(map, val, err);
}
void JsonUtils::resolveIdentifier(si32 &var, const JsonNode &node, std::string name)
{
const JsonNode &value = node[name];
@ -729,7 +738,7 @@ bool JsonUtils::parseBonus(const JsonNode &ability, Bonus *b)
value = &ability["valueType"];
if (!value->isNull())
b->valType = static_cast<Bonus::ValueType>(parseByMap(bonusValueMap, value, "value type "));
b->valType = static_cast<Bonus::ValueType>(parseByMapN(bonusValueMap, value, "value type "));
b->stacking = ability["stacking"].String();
@ -744,7 +753,7 @@ bool JsonUtils::parseBonus(const JsonNode &ability, Bonus *b)
value = &ability["effectRange"];
if (!value->isNull())
b->effectRange = static_cast<Bonus::LimitEffect>(parseByMap(bonusLimitEffect, value, "effect range "));
b->effectRange = static_cast<Bonus::LimitEffect>(parseByMapN(bonusLimitEffect, value, "effect range "));
value = &ability["duration"];
if (!value->isNull())
@ -759,7 +768,7 @@ bool JsonUtils::parseBonus(const JsonNode &ability, Bonus *b)
ui16 dur = 0;
for (const JsonNode & d : value->Vector())
{
dur |= parseByMap(bonusDurationMap, &d, "duration type ");
dur |= parseByMapN(bonusDurationMap, &d, "duration type ");
}
b->duration = (Bonus::BonusDuration)dur;
}