mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-21 00:19:29 +02:00
Make bonus stacking configurable + fix duplicate propagation/inheritance (#433)
Addresses several related problems: * Propagation / unpropagation of duplicate bonuses is inconsistent, causing bugs * Duplicate bonuses never stack, which is not always intended behaviour (e.g. multiple copies of resource generating artifacts) * Different bonuses always stack, which is not always intended behaviour (e.g. Angel + Archangel morale bonuses) This is addressed as follows: * Duplicate bonuses are never eliminated during propagation/inheritance. * Unpropagation eliminates only a single copy of duplicated bonus * Bonus receives a new field stacking that determines stacking behaviour: * * empty string = no stacking with duplicates (default) * * "ALWAYS" = stacks with duplicates & everything else * * some other value = no stacking with bonuses with same stacking value Also Morale/Luck window now hides non-stacking bonuses.
This commit is contained in:
committed by
ArseniyShestakov
parent
2b64bf29ed
commit
02b5a5e830
@ -598,6 +598,8 @@ bool JsonUtils::parseBonus(const JsonNode &ability, Bonus *b)
|
||||
if (!value->isNull())
|
||||
b->valType = static_cast<Bonus::ValueType>(parseByMap(bonusValueMap, value, "value type "));
|
||||
|
||||
b->stacking = ability["stacking"].String();
|
||||
|
||||
resolveAddInfo(b->additionalInfo, ability);
|
||||
|
||||
b->turnsRemain = ability["turns"].Float();
|
||||
@ -742,29 +744,6 @@ Key reverseMapFirst(const Val & val, const std::map<Key, Val> & map)
|
||||
return "";
|
||||
}
|
||||
|
||||
void JsonUtils::unparseBonus( JsonNode &node, const std::shared_ptr<Bonus>& bonus )
|
||||
{
|
||||
node["type"].String() = reverseMapFirst<std::string, Bonus::BonusType>(bonus->type, bonusNameMap);
|
||||
node["subtype"].Float() = bonus->subtype;
|
||||
node["val"].Float() = bonus->val;
|
||||
node["valueType"].String() = reverseMapFirst<std::string, Bonus::ValueType>(bonus->valType, bonusValueMap);
|
||||
node["additionalInfo"] = bonus->additionalInfo.toJsonNode();
|
||||
node["turns"].Float() = bonus->turnsRemain;
|
||||
node["sourceID"].Float() = bonus->source;
|
||||
node["description"].String() = bonus->description;
|
||||
node["effectRange"].String() = reverseMapFirst<std::string, Bonus::LimitEffect>(bonus->effectRange, bonusLimitEffect);
|
||||
node["duration"].String() = reverseMapFirst<std::string, ui16>(bonus->duration, bonusDurationMap);
|
||||
node["source"].String() = reverseMapFirst<std::string, Bonus::BonusSource>(bonus->source, bonusSourceMap);
|
||||
if(bonus->limiter)
|
||||
{
|
||||
node["limiter"].String() = reverseMapFirst<std::string, TLimiterPtr>(bonus->limiter, bonusLimiterMap);
|
||||
}
|
||||
if(bonus->propagator)
|
||||
{
|
||||
node["propagator"].String() = reverseMapFirst<std::string, TPropagatorPtr>(bonus->propagator, bonusPropagatorMap);
|
||||
}
|
||||
}
|
||||
|
||||
void minimizeNode(JsonNode & node, const JsonNode & schema)
|
||||
{
|
||||
if (schema["type"].String() == "object")
|
||||
|
Reference in New Issue
Block a user