mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-26 22:57:00 +02:00
improved/fixed specialty json encoding
This commit is contained in:
parent
05838b3827
commit
26862b4c51
@ -549,7 +549,7 @@ void CHeroHandler::loadHeroSpecialty(CHero * hero, const JsonNode & node)
|
|||||||
if (!specialties.isNull())
|
if (!specialties.isNull())
|
||||||
{
|
{
|
||||||
logMod->warn("Hero %s has deprecated specialties format. New format:", hero->identifier);
|
logMod->warn("Hero %s has deprecated specialties format. New format:", hero->identifier);
|
||||||
JsonNode specVec(JsonNode::DATA_VECTOR);
|
JsonNode specVec(JsonNode::JsonType::DATA_VECTOR);
|
||||||
for(const JsonNode &specialty : node["specialties"].Vector())
|
for(const JsonNode &specialty : node["specialties"].Vector())
|
||||||
{
|
{
|
||||||
SSpecialtyInfo spec;
|
SSpecialtyInfo spec;
|
||||||
|
@ -1166,31 +1166,48 @@ std::string Bonus::Description() const
|
|||||||
|
|
||||||
JsonNode subtypeToJson(Bonus::BonusType type, int subtype)
|
JsonNode subtypeToJson(Bonus::BonusType type, int subtype)
|
||||||
{
|
{
|
||||||
JsonNode node;
|
|
||||||
|
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case Bonus::PRIMARY_SKILL:
|
case Bonus::PRIMARY_SKILL:
|
||||||
node.String() = PrimarySkill::names[subtype];
|
return JsonUtils::stringNode(PrimarySkill::names[subtype]);
|
||||||
break;
|
|
||||||
case Bonus::SECONDARY_SKILL_PREMY:
|
case Bonus::SECONDARY_SKILL_PREMY:
|
||||||
node.String() = NSecondarySkill::names[subtype];
|
return JsonUtils::stringNode(NSecondarySkill::names[subtype]);
|
||||||
break;
|
case Bonus::SPECIAL_SPELL_LEV:
|
||||||
|
case Bonus::SPECIFIC_SPELL_DAMAGE:
|
||||||
|
case Bonus::SPECIAL_BLESS_DAMAGE:
|
||||||
|
case Bonus::MAXED_SPELL:
|
||||||
|
case Bonus::SPECIAL_PECULIAR_ENCHANT:
|
||||||
|
//return JsonUtils::stringNode((*VLC->spellh)[SpellID::ESpellID(subtype)]->identifier);
|
||||||
|
return JsonUtils::intNode(subtype); //Issue 2790
|
||||||
|
case Bonus::SPECIAL_UPGRADE:
|
||||||
|
return JsonUtils::stringNode(CreatureID::encode(subtype));
|
||||||
|
case Bonus::GENERATE_RESOURCE:
|
||||||
|
return JsonUtils::stringNode(GameConstants::RESOURCE_NAMES[subtype]);
|
||||||
default:
|
default:
|
||||||
node.Integer() = subtype;
|
return JsonUtils::intNode(subtype);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return node;
|
JsonNode additionalInfoToJson(Bonus::BonusType type, int addInfo)
|
||||||
|
{
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
case Bonus::SPECIAL_UPGRADE:
|
||||||
|
return JsonUtils::stringNode(CreatureID::encode(addInfo));
|
||||||
|
default:
|
||||||
|
return JsonUtils::intNode(addInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonNode Bonus::toJsonNode() const
|
JsonNode Bonus::toJsonNode() const
|
||||||
{
|
{
|
||||||
JsonNode root(JsonNode::DATA_STRUCT);
|
JsonNode root(JsonNode::JsonType::DATA_STRUCT);
|
||||||
|
|
||||||
root["type"].String() = vstd::findKey(bonusNameMap, type);
|
root["type"].String() = vstd::findKey(bonusNameMap, type);
|
||||||
if(subtype != -1)
|
if(subtype != -1)
|
||||||
root["subtype"] = subtypeToJson(type, subtype);
|
root["subtype"] = subtypeToJson(type, subtype);
|
||||||
|
if(additionalInfo != -1)
|
||||||
|
root["addInfo"] = additionalInfoToJson(type, additionalInfo);
|
||||||
if(val != 0)
|
if(val != 0)
|
||||||
root["val"].Integer() = val;
|
root["val"].Integer() = val;
|
||||||
if(valType != ADDITIVE_VALUE)
|
if(valType != ADDITIVE_VALUE)
|
||||||
@ -1413,7 +1430,7 @@ std::string ILimiter::toString() const
|
|||||||
|
|
||||||
JsonNode ILimiter::toJsonNode() const
|
JsonNode ILimiter::toJsonNode() const
|
||||||
{
|
{
|
||||||
JsonNode root(JsonNode::DATA_STRUCT);
|
JsonNode root(JsonNode::JsonType::DATA_STRUCT);
|
||||||
root["type"].String() = toString();
|
root["type"].String() = toString();
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
@ -1454,7 +1471,7 @@ std::string CCreatureTypeLimiter::toString() const
|
|||||||
|
|
||||||
JsonNode CCreatureTypeLimiter::toJsonNode() const
|
JsonNode CCreatureTypeLimiter::toJsonNode() const
|
||||||
{
|
{
|
||||||
JsonNode root(JsonNode::DATA_STRUCT);
|
JsonNode root(JsonNode::JsonType::DATA_STRUCT);
|
||||||
|
|
||||||
root["type"].String() = "CREATURE_TYPE_LIMITER";
|
root["type"].String() = "CREATURE_TYPE_LIMITER";
|
||||||
root["parameters"].Vector().push_back(JsonUtils::stringNode(creature->identifier));
|
root["parameters"].Vector().push_back(JsonUtils::stringNode(creature->identifier));
|
||||||
@ -1692,7 +1709,7 @@ std::string ScalingUpdater::toString() const
|
|||||||
|
|
||||||
JsonNode ScalingUpdater::toJsonNode() const
|
JsonNode ScalingUpdater::toJsonNode() const
|
||||||
{
|
{
|
||||||
JsonNode root(JsonNode::DATA_STRUCT);
|
JsonNode root(JsonNode::JsonType::DATA_STRUCT);
|
||||||
|
|
||||||
root["type"].String() = "GROWS_WITH_LEVEL";
|
root["type"].String() = "GROWS_WITH_LEVEL";
|
||||||
root["parameters"].Vector().push_back(JsonUtils::intNode(valPer20));
|
root["parameters"].Vector().push_back(JsonUtils::intNode(valPer20));
|
||||||
|
@ -214,7 +214,7 @@ private:
|
|||||||
BONUS_NAME(SPECIAL_BLESS_DAMAGE) /*val = spell (bless), additionalInfo = value per level in percent*/\
|
BONUS_NAME(SPECIAL_BLESS_DAMAGE) /*val = spell (bless), additionalInfo = value per level in percent*/\
|
||||||
BONUS_NAME(MAXED_SPELL) /*val = id*/\
|
BONUS_NAME(MAXED_SPELL) /*val = id*/\
|
||||||
BONUS_NAME(SPECIAL_PECULIAR_ENCHANT) /*blesses and curses with id = val dependent on unit's level, subtype = 0 or 1 for Coronius*/\
|
BONUS_NAME(SPECIAL_PECULIAR_ENCHANT) /*blesses and curses with id = val dependent on unit's level, subtype = 0 or 1 for Coronius*/\
|
||||||
BONUS_NAME(SPECIAL_UPGRADE) /*val = base, additionalInfo = target */\
|
BONUS_NAME(SPECIAL_UPGRADE) /*subtype = base, additionalInfo = target */\
|
||||||
BONUS_NAME(DRAGON_NATURE) \
|
BONUS_NAME(DRAGON_NATURE) \
|
||||||
BONUS_NAME(CREATURE_DAMAGE)/*subtype 0 = both, 1 = min, 2 = max*/\
|
BONUS_NAME(CREATURE_DAMAGE)/*subtype 0 = both, 1 = min, 2 = max*/\
|
||||||
BONUS_NAME(EXP_MULTIPLIER)/* val - percent of additional exp gained by stack/commander (base value 100)*/\
|
BONUS_NAME(EXP_MULTIPLIER)/* val - percent of additional exp gained by stack/commander (base value 100)*/\
|
||||||
|
Loading…
Reference in New Issue
Block a user