2023-04-30 16:35:15 +02:00
|
|
|
/*
|
|
|
|
* BonusParams.cpp, 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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "StdInc.h"
|
|
|
|
|
2023-08-19 19:27:55 +02:00
|
|
|
#include "BonusEnum.h"
|
2023-04-30 16:35:15 +02:00
|
|
|
#include "BonusParams.h"
|
2023-04-30 21:55:04 +02:00
|
|
|
#include "BonusSelector.h"
|
2023-04-30 16:35:15 +02:00
|
|
|
|
|
|
|
#include "../ResourceSet.h"
|
2023-10-14 17:13:59 +02:00
|
|
|
#include "../VCMI_Lib.h"
|
|
|
|
#include "../modding/IdentifierStorage.h"
|
|
|
|
#include "../modding/ModScope.h"
|
2023-04-30 16:35:15 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2023-05-05 16:56:04 +02:00
|
|
|
const std::set<std::string> deprecatedBonusSet = {
|
|
|
|
"SECONDARY_SKILL_PREMY",
|
|
|
|
"SECONDARY_SKILL_VAL2",
|
|
|
|
"MAXED_SPELL",
|
|
|
|
"LAND_MOVEMENT",
|
|
|
|
"SEA_MOVEMENT",
|
|
|
|
"SIGHT_RADIOUS",
|
|
|
|
"NO_TYPE",
|
|
|
|
"SPECIAL_SECONDARY_SKILL",
|
|
|
|
"FULL_HP_REGENERATION",
|
|
|
|
"KING1",
|
|
|
|
"KING2",
|
|
|
|
"KING3",
|
|
|
|
"BLOCK_MORALE",
|
|
|
|
"BLOCK_LUCK",
|
|
|
|
"SELF_MORALE",
|
|
|
|
"SELF_LUCK",
|
|
|
|
"DIRECT_DAMAGE_IMMUNITY",
|
|
|
|
"AIR_SPELL_DMG_PREMY",
|
|
|
|
"EARTH_SPELL_DMG_PREMY"
|
|
|
|
"FIRE_SPELL_DMG_PREMY"
|
|
|
|
"WATER_SPELL_DMG_PREMY",
|
|
|
|
"FIRE_SPELLS",
|
|
|
|
"AIR_SPELLS",
|
|
|
|
"WATER_SPELLS",
|
2023-08-19 19:27:55 +02:00
|
|
|
"EARTH_SPELLS",
|
|
|
|
"FIRE_IMMUNITY",
|
|
|
|
"AIR_IMMUNITY",
|
|
|
|
"WATER_IMMUNITY",
|
|
|
|
"EARTH_IMMUNITY"
|
2023-05-05 16:56:04 +02:00
|
|
|
};
|
|
|
|
|
2023-04-30 16:35:15 +02:00
|
|
|
BonusParams::BonusParams(std::string deprecatedTypeStr, std::string deprecatedSubtypeStr, int deprecatedSubtype):
|
|
|
|
isConverted(true)
|
|
|
|
{
|
|
|
|
if(deprecatedTypeStr == "SECONDARY_SKILL_PREMY" || deprecatedTypeStr == "SPECIAL_SECONDARY_SKILL")
|
|
|
|
{
|
|
|
|
if(deprecatedSubtype == SecondarySkill::PATHFINDING || deprecatedSubtypeStr == "skill.pathfinding")
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::ROUGH_TERRAIN_DISCOUNT;
|
2023-04-30 16:35:15 +02:00
|
|
|
else if(deprecatedSubtype == SecondarySkill::DIPLOMACY || deprecatedSubtypeStr == "skill.diplomacy")
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::WANDERING_CREATURES_JOIN_BONUS;
|
2023-04-30 16:35:15 +02:00
|
|
|
else if(deprecatedSubtype == SecondarySkill::WISDOM || deprecatedSubtypeStr == "skill.wisdom")
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::MAX_LEARNABLE_SPELL_LEVEL;
|
2023-04-30 16:35:15 +02:00
|
|
|
else if(deprecatedSubtype == SecondarySkill::MYSTICISM || deprecatedSubtypeStr == "skill.mysticism")
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::MANA_REGENERATION;
|
2023-04-30 16:35:15 +02:00
|
|
|
else if(deprecatedSubtype == SecondarySkill::NECROMANCY || deprecatedSubtypeStr == "skill.necromancy")
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::UNDEAD_RAISE_PERCENTAGE;
|
2023-04-30 16:35:15 +02:00
|
|
|
else if(deprecatedSubtype == SecondarySkill::LEARNING || deprecatedSubtypeStr == "skill.learning")
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::HERO_EXPERIENCE_GAIN_PERCENT;
|
2023-04-30 16:35:15 +02:00
|
|
|
else if(deprecatedSubtype == SecondarySkill::RESISTANCE || deprecatedSubtypeStr == "skill.resistance")
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::MAGIC_RESISTANCE;
|
2023-04-30 16:35:15 +02:00
|
|
|
else if(deprecatedSubtype == SecondarySkill::EAGLE_EYE || deprecatedSubtypeStr == "skill.eagleEye")
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::LEARN_BATTLE_SPELL_CHANCE;
|
2023-04-30 16:35:15 +02:00
|
|
|
else if(deprecatedSubtype == SecondarySkill::SCOUTING || deprecatedSubtypeStr == "skill.scouting")
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::SIGHT_RADIUS;
|
2023-04-30 16:35:15 +02:00
|
|
|
else if(deprecatedSubtype == SecondarySkill::INTELLIGENCE || deprecatedSubtypeStr == "skill.intelligence")
|
|
|
|
{
|
2024-03-23 20:57:56 +02:00
|
|
|
type = BonusType::MANA_PER_KNOWLEDGE_PERCENTAGE;
|
2023-05-01 00:20:01 +02:00
|
|
|
valueType = BonusValueType::PERCENT_TO_BASE;
|
2023-04-30 16:35:15 +02:00
|
|
|
}
|
|
|
|
else if(deprecatedSubtype == SecondarySkill::SORCERY || deprecatedSubtypeStr == "skill.sorcery")
|
2023-05-05 20:28:07 +02:00
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::SPELL_DAMAGE;
|
2023-10-21 13:50:42 +02:00
|
|
|
subtype = BonusSubtypeID(SpellSchool::ANY);
|
2023-05-05 20:28:07 +02:00
|
|
|
}
|
2023-04-30 16:35:15 +02:00
|
|
|
else if(deprecatedSubtype == SecondarySkill::SCHOLAR || deprecatedSubtypeStr == "skill.scholar")
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::LEARN_MEETING_SPELL_LIMIT;
|
2023-04-30 16:35:15 +02:00
|
|
|
else if(deprecatedSubtype == SecondarySkill::ARCHERY|| deprecatedSubtypeStr == "skill.archery")
|
|
|
|
{
|
2023-10-21 13:50:42 +02:00
|
|
|
subtype = BonusCustomSubtype::damageTypeRanged;
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::PERCENTAGE_DAMAGE_BOOST;
|
2023-04-30 16:35:15 +02:00
|
|
|
}
|
|
|
|
else if(deprecatedSubtype == SecondarySkill::OFFENCE || deprecatedSubtypeStr == "skill.offence")
|
|
|
|
{
|
2023-10-21 13:50:42 +02:00
|
|
|
subtype = BonusCustomSubtype::damageTypeMelee;
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::PERCENTAGE_DAMAGE_BOOST;
|
2023-04-30 16:35:15 +02:00
|
|
|
}
|
|
|
|
else if(deprecatedSubtype == SecondarySkill::ARMORER || deprecatedSubtypeStr == "skill.armorer")
|
|
|
|
{
|
2023-10-21 13:50:42 +02:00
|
|
|
subtype = BonusCustomSubtype::damageTypeAll;
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::GENERAL_DAMAGE_REDUCTION;
|
2023-04-30 16:35:15 +02:00
|
|
|
}
|
|
|
|
else if(deprecatedSubtype == SecondarySkill::NAVIGATION || deprecatedSubtypeStr == "skill.navigation")
|
|
|
|
{
|
2023-10-21 13:50:42 +02:00
|
|
|
subtype = BonusCustomSubtype::heroMovementSea;
|
2023-05-01 00:20:01 +02:00
|
|
|
valueType = BonusValueType::PERCENT_TO_BASE;
|
|
|
|
type = BonusType::MOVEMENT;
|
2023-04-30 16:35:15 +02:00
|
|
|
}
|
|
|
|
else if(deprecatedSubtype == SecondarySkill::LOGISTICS || deprecatedSubtypeStr == "skill.logistics")
|
|
|
|
{
|
2023-10-21 13:50:42 +02:00
|
|
|
subtype = BonusCustomSubtype::heroMovementLand;
|
2023-05-01 00:20:01 +02:00
|
|
|
valueType = BonusValueType::PERCENT_TO_BASE;
|
|
|
|
type = BonusType::MOVEMENT;
|
2023-04-30 16:35:15 +02:00
|
|
|
}
|
|
|
|
else if(deprecatedSubtype == SecondarySkill::ESTATES || deprecatedSubtypeStr == "skill.estates")
|
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::GENERATE_RESOURCE;
|
2023-10-21 13:50:42 +02:00
|
|
|
subtype = BonusSubtypeID(GameResID(EGameResID::GOLD));
|
2023-04-30 16:35:15 +02:00
|
|
|
}
|
|
|
|
else if(deprecatedSubtype == SecondarySkill::AIR_MAGIC || deprecatedSubtypeStr == "skill.airMagic")
|
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::MAGIC_SCHOOL_SKILL;
|
2023-10-21 13:50:42 +02:00
|
|
|
subtype = BonusSubtypeID(SpellSchool::AIR);
|
2023-04-30 16:35:15 +02:00
|
|
|
}
|
|
|
|
else if(deprecatedSubtype == SecondarySkill::WATER_MAGIC || deprecatedSubtypeStr == "skill.waterMagic")
|
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::MAGIC_SCHOOL_SKILL;
|
2023-10-21 13:50:42 +02:00
|
|
|
subtype = BonusSubtypeID(SpellSchool::WATER);
|
2023-04-30 16:35:15 +02:00
|
|
|
}
|
|
|
|
else if(deprecatedSubtype == SecondarySkill::FIRE_MAGIC || deprecatedSubtypeStr == "skill.fireMagic")
|
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::MAGIC_SCHOOL_SKILL;
|
2023-10-21 13:50:42 +02:00
|
|
|
subtype = BonusSubtypeID(SpellSchool::FIRE);
|
2023-04-30 16:35:15 +02:00
|
|
|
}
|
|
|
|
else if(deprecatedSubtype == SecondarySkill::EARTH_MAGIC || deprecatedSubtypeStr == "skill.earthMagic")
|
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::MAGIC_SCHOOL_SKILL;
|
2023-10-21 13:50:42 +02:00
|
|
|
subtype = BonusSubtypeID(SpellSchool::EARTH);
|
2023-04-30 16:35:15 +02:00
|
|
|
}
|
|
|
|
else if (deprecatedSubtype == SecondarySkill::ARTILLERY || deprecatedSubtypeStr == "skill.artillery")
|
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::BONUS_DAMAGE_CHANCE;
|
2023-10-21 13:50:42 +02:00
|
|
|
subtype = BonusSubtypeID(CreatureID(CreatureID::BALLISTA));
|
2023-04-30 16:35:15 +02:00
|
|
|
}
|
|
|
|
else if (deprecatedSubtype == SecondarySkill::FIRST_AID || deprecatedSubtypeStr == "skill.firstAid")
|
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::SPECIFIC_SPELL_POWER;
|
2023-10-14 17:13:59 +02:00
|
|
|
subtype = SpellID(*VLC->identifiers()->getIdentifier( ModScope::scopeGame(), "spell", "firstAid"));
|
2023-04-30 16:35:15 +02:00
|
|
|
}
|
|
|
|
else if (deprecatedSubtype == SecondarySkill::BALLISTICS || deprecatedSubtypeStr == "skill.ballistics")
|
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::CATAPULT_EXTRA_SHOTS;
|
2023-10-14 17:13:59 +02:00
|
|
|
subtype = SpellID(*VLC->identifiers()->getIdentifier( ModScope::scopeGame(), "spell", "catapultShot"));
|
2023-04-30 16:35:15 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
isConverted = false;
|
|
|
|
}
|
|
|
|
else if (deprecatedTypeStr == "SECONDARY_SKILL_VAL2")
|
|
|
|
{
|
|
|
|
if(deprecatedSubtype == SecondarySkill::EAGLE_EYE || deprecatedSubtypeStr == "skill.eagleEye")
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::LEARN_BATTLE_SPELL_LEVEL_LIMIT;
|
2023-04-30 16:35:15 +02:00
|
|
|
else if (deprecatedSubtype == SecondarySkill::ARTILLERY || deprecatedSubtypeStr == "skill.artillery")
|
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::HERO_GRANTS_ATTACKS;
|
2023-10-21 13:50:42 +02:00
|
|
|
subtype = BonusSubtypeID(CreatureID(CreatureID::BALLISTA));
|
2023-04-30 16:35:15 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
isConverted = false;
|
|
|
|
}
|
|
|
|
else if (deprecatedTypeStr == "SEA_MOVEMENT")
|
|
|
|
{
|
2023-10-21 13:50:42 +02:00
|
|
|
subtype = BonusCustomSubtype::heroMovementSea;
|
2023-05-01 00:20:01 +02:00
|
|
|
valueType = BonusValueType::ADDITIVE_VALUE;
|
|
|
|
type = BonusType::MOVEMENT;
|
2023-04-30 16:35:15 +02:00
|
|
|
}
|
|
|
|
else if (deprecatedTypeStr == "LAND_MOVEMENT")
|
|
|
|
{
|
2023-10-21 13:50:42 +02:00
|
|
|
subtype = BonusCustomSubtype::heroMovementLand;
|
2023-05-01 00:20:01 +02:00
|
|
|
valueType = BonusValueType::ADDITIVE_VALUE;
|
|
|
|
type = BonusType::MOVEMENT;
|
2023-04-30 16:35:15 +02:00
|
|
|
}
|
|
|
|
else if (deprecatedTypeStr == "MAXED_SPELL")
|
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::SPELL;
|
2023-10-14 17:13:59 +02:00
|
|
|
subtype = SpellID(*VLC->identifiers()->getIdentifier( ModScope::scopeGame(), "spell", deprecatedSubtypeStr));
|
2023-05-01 00:20:01 +02:00
|
|
|
valueType = BonusValueType::INDEPENDENT_MAX;
|
2023-04-30 16:35:15 +02:00
|
|
|
val = 3;
|
|
|
|
}
|
|
|
|
else if (deprecatedTypeStr == "FULL_HP_REGENERATION")
|
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::HP_REGENERATION;
|
2023-04-30 16:35:15 +02:00
|
|
|
val = 100000; //very high value to always chose stack health
|
|
|
|
}
|
|
|
|
else if (deprecatedTypeStr == "KING1")
|
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::KING;
|
2023-04-30 16:35:15 +02:00
|
|
|
val = 0;
|
|
|
|
}
|
|
|
|
else if (deprecatedTypeStr == "KING2")
|
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::KING;
|
2023-04-30 16:35:15 +02:00
|
|
|
val = 2;
|
|
|
|
}
|
|
|
|
else if (deprecatedTypeStr == "KING3")
|
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::KING;
|
2023-04-30 16:35:15 +02:00
|
|
|
val = 3;
|
|
|
|
}
|
|
|
|
else if (deprecatedTypeStr == "SIGHT_RADIOUS")
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::SIGHT_RADIUS;
|
2023-04-30 16:35:15 +02:00
|
|
|
else if (deprecatedTypeStr == "SELF_MORALE")
|
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::MORALE;
|
2023-04-30 16:35:15 +02:00
|
|
|
val = 1;
|
2023-05-01 00:20:01 +02:00
|
|
|
valueType = BonusValueType::INDEPENDENT_MAX;
|
2023-04-30 16:35:15 +02:00
|
|
|
}
|
|
|
|
else if (deprecatedTypeStr == "SELF_LUCK")
|
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
type = BonusType::LUCK;
|
2023-04-30 16:35:15 +02:00
|
|
|
val = 1;
|
2023-05-01 00:20:01 +02:00
|
|
|
valueType = BonusValueType::INDEPENDENT_MAX;
|
2023-04-30 16:35:15 +02:00
|
|
|
}
|
2023-04-10 17:41:25 +02:00
|
|
|
else if (deprecatedTypeStr == "DIRECT_DAMAGE_IMMUNITY")
|
|
|
|
{
|
|
|
|
type = BonusType::SPELL_DAMAGE_REDUCTION;
|
2023-10-21 13:50:42 +02:00
|
|
|
subtype = BonusSubtypeID(SpellSchool::ANY);
|
2023-04-10 17:41:25 +02:00
|
|
|
val = 100;
|
|
|
|
}
|
2023-05-05 16:56:04 +02:00
|
|
|
else if (deprecatedTypeStr == "AIR_SPELL_DMG_PREMY")
|
|
|
|
{
|
|
|
|
type = BonusType::SPELL_DAMAGE;
|
2023-10-21 13:50:42 +02:00
|
|
|
subtype = BonusSubtypeID(SpellSchool::AIR);
|
2023-05-05 16:56:04 +02:00
|
|
|
}
|
|
|
|
else if (deprecatedTypeStr == "FIRE_SPELL_DMG_PREMY")
|
|
|
|
{
|
|
|
|
type = BonusType::SPELL_DAMAGE;
|
2023-10-21 13:50:42 +02:00
|
|
|
subtype = BonusSubtypeID(SpellSchool::FIRE);
|
2023-05-05 16:56:04 +02:00
|
|
|
}
|
|
|
|
else if (deprecatedTypeStr == "WATER_SPELL_DMG_PREMY")
|
|
|
|
{
|
|
|
|
type = BonusType::SPELL_DAMAGE;
|
2023-10-21 13:50:42 +02:00
|
|
|
subtype = BonusSubtypeID(SpellSchool::WATER);
|
2023-05-05 16:56:04 +02:00
|
|
|
}
|
|
|
|
else if (deprecatedTypeStr == "EARTH_SPELL_DMG_PREMY")
|
|
|
|
{
|
|
|
|
type = BonusType::SPELL_DAMAGE;
|
2023-10-21 13:50:42 +02:00
|
|
|
subtype = BonusSubtypeID(SpellSchool::EARTH);
|
2023-05-05 16:56:04 +02:00
|
|
|
}
|
|
|
|
else if (deprecatedTypeStr == "AIR_SPELLS")
|
|
|
|
{
|
|
|
|
type = BonusType::SPELLS_OF_SCHOOL;
|
2023-10-21 13:50:42 +02:00
|
|
|
subtype = BonusSubtypeID(SpellSchool::AIR);
|
2023-05-05 16:56:04 +02:00
|
|
|
}
|
|
|
|
else if (deprecatedTypeStr == "FIRE_SPELLS")
|
|
|
|
{
|
|
|
|
type = BonusType::SPELLS_OF_SCHOOL;
|
2023-10-21 13:50:42 +02:00
|
|
|
subtype = BonusSubtypeID(SpellSchool::FIRE);
|
2023-05-05 16:56:04 +02:00
|
|
|
}
|
|
|
|
else if (deprecatedTypeStr == "WATER_SPELLS")
|
|
|
|
{
|
|
|
|
type = BonusType::SPELLS_OF_SCHOOL;
|
2023-10-21 13:50:42 +02:00
|
|
|
subtype = BonusSubtypeID(SpellSchool::WATER);
|
2023-05-05 16:56:04 +02:00
|
|
|
}
|
|
|
|
else if (deprecatedTypeStr == "EARTH_SPELLS")
|
|
|
|
{
|
|
|
|
type = BonusType::SPELLS_OF_SCHOOL;
|
2023-10-21 13:50:42 +02:00
|
|
|
subtype = BonusSubtypeID(SpellSchool::EARTH);
|
2023-05-05 16:56:04 +02:00
|
|
|
}
|
2023-08-19 19:27:55 +02:00
|
|
|
else if (deprecatedTypeStr == "AIR_IMMUNITY")
|
|
|
|
{
|
2023-10-21 13:50:42 +02:00
|
|
|
subtype = BonusSubtypeID(SpellSchool::AIR);
|
2023-08-19 19:27:55 +02:00
|
|
|
switch(deprecatedSubtype)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
type = BonusType::SPELL_SCHOOL_IMMUNITY;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
type = BonusType::NEGATIVE_EFFECTS_IMMUNITY;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
type = BonusType::SPELL_DAMAGE_REDUCTION;
|
|
|
|
val = 100;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (deprecatedTypeStr == "FIRE_IMMUNITY")
|
|
|
|
{
|
2023-10-21 13:50:42 +02:00
|
|
|
subtype = BonusSubtypeID(SpellSchool::FIRE);
|
2023-08-19 19:27:55 +02:00
|
|
|
switch(deprecatedSubtype)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
type = BonusType::SPELL_SCHOOL_IMMUNITY;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
type = BonusType::NEGATIVE_EFFECTS_IMMUNITY;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
type = BonusType::SPELL_DAMAGE_REDUCTION;
|
|
|
|
val = 100;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (deprecatedTypeStr == "WATER_IMMUNITY")
|
|
|
|
{
|
2023-10-21 13:50:42 +02:00
|
|
|
subtype = BonusSubtypeID(SpellSchool::WATER);
|
2023-08-19 19:27:55 +02:00
|
|
|
switch(deprecatedSubtype)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
type = BonusType::SPELL_SCHOOL_IMMUNITY;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
type = BonusType::NEGATIVE_EFFECTS_IMMUNITY;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
type = BonusType::SPELL_DAMAGE_REDUCTION;
|
|
|
|
val = 100;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (deprecatedTypeStr == "EARTH_IMMUNITY")
|
|
|
|
{
|
2023-10-21 13:50:42 +02:00
|
|
|
subtype = BonusSubtypeID(SpellSchool::EARTH);
|
2023-08-19 19:27:55 +02:00
|
|
|
switch(deprecatedSubtype)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
type = BonusType::SPELL_SCHOOL_IMMUNITY;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
type = BonusType::NEGATIVE_EFFECTS_IMMUNITY;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
type = BonusType::SPELL_DAMAGE_REDUCTION;
|
|
|
|
val = 100;
|
|
|
|
}
|
|
|
|
}
|
2023-04-30 16:35:15 +02:00
|
|
|
else
|
|
|
|
isConverted = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const JsonNode & BonusParams::toJson()
|
|
|
|
{
|
|
|
|
assert(isConverted);
|
|
|
|
if(ret.isNull())
|
|
|
|
{
|
|
|
|
ret["type"].String() = vstd::findKey(bonusNameMap, type);
|
2023-10-05 15:13:52 +02:00
|
|
|
if(subtype)
|
|
|
|
ret["subtype"].String() = subtype->toString();
|
2023-05-05 18:08:36 +02:00
|
|
|
if(valueType)
|
|
|
|
ret["valueType"].String() = vstd::findKey(bonusValueMap, *valueType);
|
|
|
|
if(val)
|
|
|
|
ret["val"].Float() = *val;
|
|
|
|
if(targetType)
|
|
|
|
ret["targetSourceType"].String() = vstd::findKey(bonusSourceMap, *targetType);
|
2023-04-30 16:35:15 +02:00
|
|
|
jsonCreated = true;
|
|
|
|
}
|
2024-02-13 14:34:16 +02:00
|
|
|
ret.setModScope(ModScope::scopeGame());
|
2023-04-30 16:35:15 +02:00
|
|
|
return ret;
|
|
|
|
};
|
|
|
|
|
|
|
|
CSelector BonusParams::toSelector()
|
|
|
|
{
|
|
|
|
assert(isConverted);
|
|
|
|
|
|
|
|
auto ret = Selector::type()(type);
|
2023-05-05 18:08:36 +02:00
|
|
|
if(subtype)
|
|
|
|
ret = ret.And(Selector::subtype()(*subtype));
|
|
|
|
if(valueType)
|
|
|
|
ret = ret.And(Selector::valueType(*valueType));
|
|
|
|
if(targetType)
|
|
|
|
ret = ret.And(Selector::targetSourceType()(*targetType));
|
2023-04-30 16:35:15 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2023-10-05 15:13:52 +02:00
|
|
|
VCMI_LIB_NAMESPACE_END
|