1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

Spells configuration version 2 (effect-based)

* Indirect spell effects loading
* Json serializer improvements
* spell->canBeCastAt do not allow useless cast for any spell
* Added proxy caster class for spell-created obstacles
* Handle damage from spell-created obstacles inside mechanics
* Experimental GameState integration/regression tests
* Ignore mod settings and load only "vcmi" mod when running tests
* fixed https://bugs.vcmi.eu/view.php?id=2765 (with tests)
* Huge improvements of BattleAI regarding spell casts
* AI can cast almost any combat spell except TELEPORT, SACRIFICE and obstacle placement spells.
* Possible fix for https://bugs.vcmi.eu/view.php?id=1811
* CStack factored out to several classes
* [Battle] Allowed RETURN_AFTER_STRIKE effect on server side to be optional
* [Battle] Allowed BattleAction have multiple destinations
* [Spells] Converted limit|immunity to target condition
* [Spells] Use partial configuration reload for backward compatibility handling
* [Tests] Started tests for CUnitState
* Partial fixes of fire shield effect
* [Battle] Do HP calculations in 64 bits
* [BattleAI] Use threading for spell cast evaluation
* [BattleAI] Made AI be able to evaluate modified turn order (on hypothetical battle state)
* Implemented https://bugs.vcmi.eu/view.php?id=2811
* plug rare freeze when hypnotized unit shots vertically
* Correctly apply ONLY_MELEE_FIGHT / ONLY_DISTANCE_FIGHT for unit damage, attack & defense
* [BattleAI] Try to not waste a cast if battle is actually won already
* Extended JsonSerializeFormat API
* fixed https://bugs.vcmi.eu/view.php?id=2847
* Any unit effect can be now chained (not only damage like Chain Lightning)
** only damage effect for now actually uses "chainFactor"
* Possible quick fix for https://bugs.vcmi.eu/view.php?id=2860
This commit is contained in:
AlexVinS
2017-07-20 07:08:49 +03:00
parent ff2d01a03d
commit 0b70baa95e
256 changed files with 20904 additions and 7964 deletions

View File

@@ -12,15 +12,15 @@
#include "../JsonNode.h"
JsonDeserializer::JsonDeserializer(const IInstanceResolver * instanceResolver_, JsonNode & root_):
JsonSerializeFormat(instanceResolver_, root_, false)
JsonDeserializer::JsonDeserializer(const IInstanceResolver * instanceResolver_, const JsonNode & root_):
JsonTreeSerializer(instanceResolver_, &root_, false)
{
}
void JsonDeserializer::serializeInternal(const std::string & fieldName, boost::logic::tribool & value)
{
const JsonNode & data = current->operator[](fieldName);
const JsonNode & data = currentObject->operator[](fieldName);
if(data.getType() != JsonNode::JsonType::DATA_BOOL)
value = boost::logic::indeterminate;
else
@@ -44,7 +44,7 @@ void JsonDeserializer::serializeInternal(const std::string & fieldName, si32 & v
void JsonDeserializer::serializeInternal(const std::string & fieldName, std::vector<si32> & value, const TDecoder & decoder, const TEncoder & encoder)
{
const JsonVector & data = current->operator[](fieldName).Vector();
const JsonVector & data = currentObject->operator[](fieldName).Vector();
value.clear();
value.reserve(data.size());
@@ -60,7 +60,7 @@ void JsonDeserializer::serializeInternal(const std::string & fieldName, std::vec
void JsonDeserializer::serializeInternal(const std::string & fieldName, double & value, const boost::optional<double> & defaultValue)
{
const JsonNode & data = current->operator[](fieldName);
const JsonNode & data = currentObject->operator[](fieldName);
if(!data.isNumber())
value = defaultValue ? defaultValue.get() : 0;//todo: report error on not null?
@@ -70,7 +70,7 @@ void JsonDeserializer::serializeInternal(const std::string & fieldName, double &
void JsonDeserializer::serializeInternal(const std::string & fieldName, si64 & value, const boost::optional<si64> & defaultValue)
{
const JsonNode & data = current->operator[](fieldName);
const JsonNode & data = currentObject->operator[](fieldName);
if(!data.isNumber())
value = defaultValue ? defaultValue.get() : 0;//todo: report error on not null?
@@ -80,7 +80,7 @@ void JsonDeserializer::serializeInternal(const std::string & fieldName, si64 & v
void JsonDeserializer::serializeInternal(const std::string & fieldName, si32 & value, const boost::optional<si32> & defaultValue, const std::vector<std::string> & enumMap)
{
const std::string & valueName = current->operator[](fieldName).String();
const std::string & valueName = currentObject->operator[](fieldName).String();
const si32 actualOptional = defaultValue ? defaultValue.get() : 0;
@@ -91,9 +91,19 @@ void JsonDeserializer::serializeInternal(const std::string & fieldName, si32 & v
value = rawValue;
}
void JsonDeserializer::serializeInternal(std::string & value)
{
value = currentObject->String();
}
void JsonDeserializer::serializeInternal(int64_t & value)
{
value = currentObject->Integer();
}
void JsonDeserializer::serializeLIC(const std::string & fieldName, const TDecoder & decoder, const TEncoder & encoder, const std::vector<bool> & standard, std::vector<bool> & value)
{
const JsonNode & field = current->operator[](fieldName);
const JsonNode & field = currentObject->operator[](fieldName);
const JsonNode & anyOf = field["anyOf"];
const JsonNode & allOf = field["allOf"];
@@ -119,7 +129,7 @@ void JsonDeserializer::serializeLIC(const std::string & fieldName, const TDecode
void JsonDeserializer::serializeLIC(const std::string & fieldName, LIC & value)
{
const JsonNode & field = current->operator[](fieldName);
const JsonNode & field = currentObject->operator[](fieldName);
const JsonNode & anyOf = field["anyOf"];
const JsonNode & allOf = field["allOf"];
@@ -164,7 +174,7 @@ void JsonDeserializer::serializeLIC(const std::string & fieldName, LIC & value)
void JsonDeserializer::serializeLIC(const std::string & fieldName, LICSet & value)
{
const JsonNode & field = current->operator[](fieldName);
const JsonNode & field = currentObject->operator[](fieldName);
const JsonNode & anyOf = field["anyOf"];
const JsonNode & allOf = field["allOf"];
@@ -209,7 +219,23 @@ void JsonDeserializer::serializeLIC(const std::string & fieldName, LICSet & valu
void JsonDeserializer::serializeString(const std::string & fieldName, std::string & value)
{
value = current->operator[](fieldName).String();
value = currentObject->operator[](fieldName).String();
}
void JsonDeserializer::serializeRaw(const std::string & fieldName, JsonNode & value, const boost::optional<const JsonNode &> defaultValue)
{
const JsonNode & data = currentObject->operator[](fieldName);
if(data.getType() == JsonNode::JsonType::DATA_NULL)
{
if(defaultValue)
value = defaultValue.get();
else
value.clear();
}
else
{
value = data;
}
}
void JsonDeserializer::readLICPart(const JsonNode & part, const TDecoder & decoder, const bool val, std::vector<bool> & value)