mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-02 00:10:22 +02:00
Renamed new types for consistency with code style
This commit is contained in:
parent
31cf3442af
commit
ac925bb786
@ -71,7 +71,7 @@ float HeroManager::evaluateSecSkill(SecondarySkill skill, const CGHeroInstance *
|
||||
|
||||
float HeroManager::evaluateSpeciality(const CGHeroInstance * hero) const
|
||||
{
|
||||
auto heroSpecial = Selector::source(BonusSource::HERO_SPECIAL, TBonusSourceID(hero->type->getId()));
|
||||
auto heroSpecial = Selector::source(BonusSource::HERO_SPECIAL, BonusSourceID(hero->type->getId()));
|
||||
auto secondarySkillBonus = Selector::targetSourceType()(BonusSource::SECONDARY_SKILL);
|
||||
auto specialSecondarySkillBonuses = hero->getBonuses(heroSpecial.And(secondarySkillBonus));
|
||||
auto secondarySkillBonuses = hero->getBonuses(Selector::sourceTypeSel(BonusSource::SECONDARY_SKILL));
|
||||
|
@ -242,13 +242,13 @@ uint64_t evaluateArtifactArmyValue(CArtifactInstance * art)
|
||||
return 1500;
|
||||
|
||||
auto statsValue =
|
||||
10 * art->valOfBonuses(BonusType::MOVEMENT, BonusSubtypeID::heroMovementLand)
|
||||
10 * art->valOfBonuses(BonusType::MOVEMENT, BonusCustomSubtype::heroMovementLand)
|
||||
+ 1200 * art->valOfBonuses(BonusType::STACKS_SPEED)
|
||||
+ 700 * art->valOfBonuses(BonusType::MORALE)
|
||||
+ 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, TBonusSubtype(PrimarySkill::ATTACK))
|
||||
+ 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, TBonusSubtype(PrimarySkill::DEFENSE))
|
||||
+ 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, TBonusSubtype(PrimarySkill::KNOWLEDGE))
|
||||
+ 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, TBonusSubtype(PrimarySkill::SPELL_POWER))
|
||||
+ 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, BonusSubtypeID(PrimarySkill::ATTACK))
|
||||
+ 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, BonusSubtypeID(PrimarySkill::DEFENSE))
|
||||
+ 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, BonusSubtypeID(PrimarySkill::KNOWLEDGE))
|
||||
+ 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, BonusSubtypeID(PrimarySkill::SPELL_POWER))
|
||||
+ 500 * art->valOfBonuses(BonusType::LUCK);
|
||||
|
||||
auto classValue = 0;
|
||||
|
@ -534,7 +534,7 @@ void BattleStacksController::stackMoved(const CStack *stack, std::vector<BattleH
|
||||
addNewAnim(new MovementStartAnimation(owner, stack));
|
||||
});
|
||||
|
||||
if (!stack->hasBonus(Selector::typeSubtype(BonusType::FLYING, BonusSubtypeID::movementFlying)))
|
||||
if (!stack->hasBonus(Selector::typeSubtype(BonusType::FLYING, BonusCustomSubtype::movementFlying)))
|
||||
{
|
||||
owner.addToAnimationStage(EAnimationEvents::MOVEMENT, [&]()
|
||||
{
|
||||
@ -797,7 +797,7 @@ void BattleStacksController::removeExpiredColorFilters()
|
||||
{
|
||||
if (!filter.persistent)
|
||||
{
|
||||
if (filter.source && !filter.target->hasBonus(Selector::source(BonusSource::SPELL_EFFECT, TBonusSourceID(filter.source->id)), Selector::all))
|
||||
if (filter.source && !filter.target->hasBonus(Selector::source(BonusSource::SPELL_EFFECT, BonusSourceID(filter.source->id)), Selector::all))
|
||||
return true;
|
||||
if (filter.effect == ColorFilter::genEmptyShifter())
|
||||
return true;
|
||||
|
@ -224,7 +224,7 @@ CStackWindow::ActiveSpellsSection::ActiveSpellsSection(CStackWindow * owner, int
|
||||
spellText = CGI->generaltexth->allTexts[610]; //"%s, duration: %d rounds."
|
||||
boost::replace_first(spellText, "%s", spell->getNameTranslated());
|
||||
//FIXME: support permanent duration
|
||||
int duration = battleStack->getBonusLocalFirst(Selector::source(BonusSource::SPELL_EFFECT, TBonusSourceID(effect)))->turnsRemain;
|
||||
int duration = battleStack->getBonusLocalFirst(Selector::source(BonusSource::SPELL_EFFECT, BonusSourceID(effect)))->turnsRemain;
|
||||
boost::replace_first(spellText, "%d", std::to_string(duration));
|
||||
|
||||
spellIcons.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("SpellInt"), effect + 1, 0, firstPos.x + offset.x * printed, firstPos.y + offset.y * printed));
|
||||
|
@ -579,7 +579,7 @@ void CKingdomInterface::generateMinesList(const std::vector<const CGObjectInstan
|
||||
std::vector<const CGHeroInstance*> heroes = LOCPLINT->cb->getHeroesInfo(true);
|
||||
for(auto & heroe : heroes)
|
||||
{
|
||||
totalIncome += heroe->valOfBonuses(Selector::typeSubtype(BonusType::GENERATE_RESOURCE, TBonusSubtype(GameResID(EGameResID::GOLD))));
|
||||
totalIncome += heroe->valOfBonuses(Selector::typeSubtype(BonusType::GENERATE_RESOURCE, BonusSubtypeID(GameResID(EGameResID::GOLD))));
|
||||
}
|
||||
|
||||
//Add town income of all towns
|
||||
|
@ -31,7 +31,7 @@ macro(add_main_lib TARGET_NAME LIBRARY_TYPE)
|
||||
${MAIN_LIB_DIR}/bonuses/BonusList.cpp
|
||||
${MAIN_LIB_DIR}/bonuses/BonusParams.cpp
|
||||
${MAIN_LIB_DIR}/bonuses/BonusSelector.cpp
|
||||
${MAIN_LIB_DIR}/bonuses/BonusSubtypeID.cpp
|
||||
${MAIN_LIB_DIR}/bonuses/BonusCustomTypes.cpp
|
||||
${MAIN_LIB_DIR}/bonuses/CBonusProxy.cpp
|
||||
${MAIN_LIB_DIR}/bonuses/CBonusSystemNode.cpp
|
||||
${MAIN_LIB_DIR}/bonuses/IBonusBearer.cpp
|
||||
@ -358,7 +358,7 @@ macro(add_main_lib TARGET_NAME LIBRARY_TYPE)
|
||||
${MAIN_LIB_DIR}/bonuses/BonusList.h
|
||||
${MAIN_LIB_DIR}/bonuses/BonusParams.h
|
||||
${MAIN_LIB_DIR}/bonuses/BonusSelector.h
|
||||
${MAIN_LIB_DIR}/bonuses/BonusSubtypeID.h
|
||||
${MAIN_LIB_DIR}/bonuses/BonusCustomTypes.h
|
||||
${MAIN_LIB_DIR}/bonuses/CBonusProxy.h
|
||||
${MAIN_LIB_DIR}/bonuses/CBonusSystemNode.h
|
||||
${MAIN_LIB_DIR}/bonuses/IBonusBearer.h
|
||||
|
@ -145,7 +145,7 @@ DLL_LINKAGE CArtifactInstance * ArtifactUtils::createScroll(const SpellID & sid)
|
||||
{
|
||||
auto ret = new CArtifactInstance(VLC->arth->objects[ArtifactID::SPELL_SCROLL]);
|
||||
auto bonus = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::SPELL,
|
||||
BonusSource::ARTIFACT_INSTANCE, -1, TBonusSourceID(ArtifactID(ArtifactID::SPELL_SCROLL)), TBonusSubtype(sid));
|
||||
BonusSource::ARTIFACT_INSTANCE, -1, BonusSourceID(ArtifactID(ArtifactID::SPELL_SCROLL)), BonusSubtypeID(sid));
|
||||
ret->addNewBonus(bonus);
|
||||
return ret;
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ TerrainId AFactionMember::getNativeTerrain() const
|
||||
{
|
||||
constexpr auto any = TerrainId(ETerrainId::ANY_TERRAIN);
|
||||
const std::string cachingStringNoTerrainPenalty = "type_NO_TERRAIN_PENALTY_sANY";
|
||||
static const auto selectorNoTerrainPenalty = Selector::typeSubtype(BonusType::NO_TERRAIN_PENALTY, TBonusSubtype(any));
|
||||
static const auto selectorNoTerrainPenalty = Selector::typeSubtype(BonusType::NO_TERRAIN_PENALTY, BonusSubtypeID(any));
|
||||
|
||||
//this code is used in the CreatureTerrainLimiter::limit to setup battle bonuses
|
||||
//and in the CGHeroInstance::getNativeTerrain() to setup movement bonuses or/and penalties.
|
||||
@ -54,7 +54,7 @@ int AFactionMember::getAttack(bool ranged) const
|
||||
{
|
||||
const std::string cachingStr = "type_PRIMARY_SKILLs_ATTACK";
|
||||
|
||||
static const auto selector = Selector::typeSubtype(BonusType::PRIMARY_SKILL, TBonusSubtype(PrimarySkill::ATTACK));
|
||||
static const auto selector = Selector::typeSubtype(BonusType::PRIMARY_SKILL, BonusSubtypeID(PrimarySkill::ATTACK));
|
||||
|
||||
return getBonusBearer()->valOfBonuses(selector, cachingStr);
|
||||
}
|
||||
@ -63,7 +63,7 @@ int AFactionMember::getDefense(bool ranged) const
|
||||
{
|
||||
const std::string cachingStr = "type_PRIMARY_SKILLs_DEFENSE";
|
||||
|
||||
static const auto selector = Selector::typeSubtype(BonusType::PRIMARY_SKILL, TBonusSubtype(PrimarySkill::DEFENSE));
|
||||
static const auto selector = Selector::typeSubtype(BonusType::PRIMARY_SKILL, BonusSubtypeID(PrimarySkill::DEFENSE));
|
||||
|
||||
return getBonusBearer()->valOfBonuses(selector, cachingStr);
|
||||
}
|
||||
@ -71,14 +71,14 @@ int AFactionMember::getDefense(bool ranged) const
|
||||
int AFactionMember::getMinDamage(bool ranged) const
|
||||
{
|
||||
const std::string cachingStr = "type_CREATURE_DAMAGEs_0Otype_CREATURE_DAMAGEs_1";
|
||||
static const auto selector = Selector::typeSubtype(BonusType::CREATURE_DAMAGE, BonusSubtypeID::creatureDamageBoth).Or(Selector::typeSubtype(BonusType::CREATURE_DAMAGE, BonusSubtypeID::creatureDamageMin));
|
||||
static const auto selector = Selector::typeSubtype(BonusType::CREATURE_DAMAGE, BonusCustomSubtype::creatureDamageBoth).Or(Selector::typeSubtype(BonusType::CREATURE_DAMAGE, BonusCustomSubtype::creatureDamageMin));
|
||||
return getBonusBearer()->valOfBonuses(selector, cachingStr);
|
||||
}
|
||||
|
||||
int AFactionMember::getMaxDamage(bool ranged) const
|
||||
{
|
||||
const std::string cachingStr = "type_CREATURE_DAMAGEs_0Otype_CREATURE_DAMAGEs_2";
|
||||
static const auto selector = Selector::typeSubtype(BonusType::CREATURE_DAMAGE, BonusSubtypeID::creatureDamageBoth).Or(Selector::typeSubtype(BonusType::CREATURE_DAMAGE, BonusSubtypeID::creatureDamageMax));
|
||||
static const auto selector = Selector::typeSubtype(BonusType::CREATURE_DAMAGE, BonusCustomSubtype::creatureDamageBoth).Or(Selector::typeSubtype(BonusType::CREATURE_DAMAGE, BonusCustomSubtype::creatureDamageMax));
|
||||
return getBonusBearer()->valOfBonuses(selector, cachingStr);
|
||||
}
|
||||
|
||||
@ -87,7 +87,7 @@ int AFactionMember::getPrimSkillLevel(PrimarySkill id) const
|
||||
static const CSelector selectorAllSkills = Selector::type()(BonusType::PRIMARY_SKILL);
|
||||
static const std::string keyAllSkills = "type_PRIMARY_SKILL";
|
||||
auto allSkills = getBonusBearer()->getBonuses(selectorAllSkills, keyAllSkills);
|
||||
auto ret = allSkills->valOfBonuses(Selector::subtype()(TBonusSubtype(id)));
|
||||
auto ret = allSkills->valOfBonuses(Selector::subtype()(BonusSubtypeID(id)));
|
||||
auto minSkillValue = (id == PrimarySkill::SPELL_POWER || id == PrimarySkill::KNOWLEDGE) ? 1 : 0;
|
||||
return std::max(ret, minSkillValue); //otherwise, some artifacts may cause negative skill value effect, sp=0 works in old saves
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ BattleFieldInfo * BattleFieldHandler::loadFromJson(const std::string & scope, co
|
||||
auto bonus = JsonUtils::parseBonus(b);
|
||||
|
||||
bonus->source = BonusSource::TERRAIN_OVERLAY;
|
||||
bonus->sid = TBonusSourceID(info->getId());
|
||||
bonus->sid = BonusSourceID(info->getId());
|
||||
bonus->duration = BonusDuration::ONE_BATTLE;
|
||||
|
||||
info->bonuses.push_back(bonus);
|
||||
|
@ -751,7 +751,7 @@ void CArtHandler::afterLoadFinalization()
|
||||
{
|
||||
assert(art == objects[art->id]);
|
||||
assert(bonus->source == BonusSource::ARTIFACT);
|
||||
bonus->sid = TBonusSourceID(art->id);
|
||||
bonus->sid = BonusSourceID(art->id);
|
||||
}
|
||||
}
|
||||
CBonusSystemNode::treeHasChanged();
|
||||
|
@ -168,10 +168,10 @@ ImagePath CBonusTypeHandler::bonusToGraphics(const std::shared_ptr<Bonus> & bonu
|
||||
}
|
||||
case BonusType::GENERAL_DAMAGE_REDUCTION:
|
||||
{
|
||||
if (bonus->subtype == BonusSubtypeID::damageTypeMelee)
|
||||
if (bonus->subtype == BonusCustomSubtype::damageTypeMelee)
|
||||
fileName = "DamageReductionMelee.bmp";
|
||||
|
||||
if (bonus->subtype == BonusSubtypeID::damageTypeRanged)
|
||||
if (bonus->subtype == BonusCustomSubtype::damageTypeRanged)
|
||||
fileName = "DamageReductionRanged.bmp";
|
||||
|
||||
break;
|
||||
|
@ -113,25 +113,25 @@ FactionID CCreature::getFaction() const
|
||||
|
||||
int32_t CCreature::getBaseAttack() const
|
||||
{
|
||||
static const auto SELECTOR = Selector::typeSubtype(BonusType::PRIMARY_SKILL, TBonusSubtype(PrimarySkill::ATTACK)).And(Selector::sourceTypeSel(BonusSource::CREATURE_ABILITY));
|
||||
static const auto SELECTOR = Selector::typeSubtype(BonusType::PRIMARY_SKILL, BonusSubtypeID(PrimarySkill::ATTACK)).And(Selector::sourceTypeSel(BonusSource::CREATURE_ABILITY));
|
||||
return getExportedBonusList().valOfBonuses(SELECTOR);
|
||||
}
|
||||
|
||||
int32_t CCreature::getBaseDefense() const
|
||||
{
|
||||
static const auto SELECTOR = Selector::typeSubtype(BonusType::PRIMARY_SKILL, TBonusSubtype(PrimarySkill::DEFENSE)).And(Selector::sourceTypeSel(BonusSource::CREATURE_ABILITY));
|
||||
static const auto SELECTOR = Selector::typeSubtype(BonusType::PRIMARY_SKILL, BonusSubtypeID(PrimarySkill::DEFENSE)).And(Selector::sourceTypeSel(BonusSource::CREATURE_ABILITY));
|
||||
return getExportedBonusList().valOfBonuses(SELECTOR);
|
||||
}
|
||||
|
||||
int32_t CCreature::getBaseDamageMin() const
|
||||
{
|
||||
static const auto SELECTOR = Selector::typeSubtype(BonusType::CREATURE_DAMAGE, BonusSubtypeID::creatureDamageMin).And(Selector::sourceTypeSel(BonusSource::CREATURE_ABILITY));
|
||||
static const auto SELECTOR = Selector::typeSubtype(BonusType::CREATURE_DAMAGE, BonusCustomSubtype::creatureDamageMin).And(Selector::sourceTypeSel(BonusSource::CREATURE_ABILITY));
|
||||
return getExportedBonusList().valOfBonuses(SELECTOR);
|
||||
}
|
||||
|
||||
int32_t CCreature::getBaseDamageMax() const
|
||||
{
|
||||
static const auto SELECTOR = Selector::typeSubtype(BonusType::CREATURE_DAMAGE, BonusSubtypeID::creatureDamageMax).And(Selector::sourceTypeSel(BonusSource::CREATURE_ABILITY));
|
||||
static const auto SELECTOR = Selector::typeSubtype(BonusType::CREATURE_DAMAGE, BonusCustomSubtype::creatureDamageMax).And(Selector::sourceTypeSel(BonusSource::CREATURE_ABILITY));
|
||||
return getExportedBonusList().valOfBonuses(SELECTOR);
|
||||
}
|
||||
|
||||
@ -293,12 +293,12 @@ CCreature::CCreature()
|
||||
|
||||
void CCreature::addBonus(int val, BonusType type)
|
||||
{
|
||||
addBonus(val, type, TBonusSubtype());
|
||||
addBonus(val, type, BonusSubtypeID());
|
||||
}
|
||||
|
||||
void CCreature::addBonus(int val, BonusType type, TBonusSubtype subtype)
|
||||
void CCreature::addBonus(int val, BonusType type, BonusSubtypeID subtype)
|
||||
{
|
||||
auto selector = Selector::typeSubtype(type, subtype).And(Selector::source(BonusSource::CREATURE_ABILITY, TBonusSourceID(getId())));
|
||||
auto selector = Selector::typeSubtype(type, subtype).And(Selector::source(BonusSource::CREATURE_ABILITY, BonusSourceID(getId())));
|
||||
BonusList & exported = getExportedBonusList();
|
||||
|
||||
BonusList existing;
|
||||
@ -306,7 +306,7 @@ void CCreature::addBonus(int val, BonusType type, TBonusSubtype subtype)
|
||||
|
||||
if(existing.empty())
|
||||
{
|
||||
auto added = std::make_shared<Bonus>(BonusDuration::PERMANENT, type, BonusSource::CREATURE_ABILITY, val, TBonusSourceID(getId()), subtype, BonusValueType::BASE_NUMBER);
|
||||
auto added = std::make_shared<Bonus>(BonusDuration::PERMANENT, type, BonusSource::CREATURE_ABILITY, val, BonusSourceID(getId()), subtype, BonusValueType::BASE_NUMBER);
|
||||
addNewBonus(added);
|
||||
}
|
||||
else
|
||||
@ -350,16 +350,16 @@ void CCreature::updateFrom(const JsonNode & data)
|
||||
addBonus(configNode["speed"].Integer(), BonusType::STACKS_SPEED);
|
||||
|
||||
if(!configNode["attack"].isNull())
|
||||
addBonus(configNode["attack"].Integer(), BonusType::PRIMARY_SKILL, TBonusSubtype(PrimarySkill::ATTACK));
|
||||
addBonus(configNode["attack"].Integer(), BonusType::PRIMARY_SKILL, BonusSubtypeID(PrimarySkill::ATTACK));
|
||||
|
||||
if(!configNode["defense"].isNull())
|
||||
addBonus(configNode["defense"].Integer(), BonusType::PRIMARY_SKILL, TBonusSubtype(PrimarySkill::DEFENSE));
|
||||
addBonus(configNode["defense"].Integer(), BonusType::PRIMARY_SKILL, BonusSubtypeID(PrimarySkill::DEFENSE));
|
||||
|
||||
if(!configNode["damage"]["min"].isNull())
|
||||
addBonus(configNode["damage"]["min"].Integer(), BonusType::CREATURE_DAMAGE, BonusSubtypeID::creatureDamageMin);
|
||||
addBonus(configNode["damage"]["min"].Integer(), BonusType::CREATURE_DAMAGE, BonusCustomSubtype::creatureDamageMin);
|
||||
|
||||
if(!configNode["damage"]["max"].isNull())
|
||||
addBonus(configNode["damage"]["max"].Integer(), BonusType::CREATURE_DAMAGE, BonusSubtypeID::creatureDamageMax);
|
||||
addBonus(configNode["damage"]["max"].Integer(), BonusType::CREATURE_DAMAGE, BonusCustomSubtype::creatureDamageMax);
|
||||
|
||||
if(!configNode["shots"].isNull())
|
||||
addBonus(configNode["shots"].Integer(), BonusType::SHOTS);
|
||||
@ -609,11 +609,11 @@ CCreature * CCreatureHandler::loadFromJson(const std::string & scope, const Json
|
||||
|
||||
cre->addBonus(node["hitPoints"].Integer(), BonusType::STACK_HEALTH);
|
||||
cre->addBonus(node["speed"].Integer(), BonusType::STACKS_SPEED);
|
||||
cre->addBonus(node["attack"].Integer(), BonusType::PRIMARY_SKILL, TBonusSubtype(PrimarySkill::ATTACK));
|
||||
cre->addBonus(node["defense"].Integer(), BonusType::PRIMARY_SKILL, TBonusSubtype(PrimarySkill::DEFENSE));
|
||||
cre->addBonus(node["attack"].Integer(), BonusType::PRIMARY_SKILL, BonusSubtypeID(PrimarySkill::ATTACK));
|
||||
cre->addBonus(node["defense"].Integer(), BonusType::PRIMARY_SKILL, BonusSubtypeID(PrimarySkill::DEFENSE));
|
||||
|
||||
cre->addBonus(node["damage"]["min"].Integer(), BonusType::CREATURE_DAMAGE, BonusSubtypeID::creatureDamageMin);
|
||||
cre->addBonus(node["damage"]["max"].Integer(), BonusType::CREATURE_DAMAGE, BonusSubtypeID::creatureDamageMax);
|
||||
cre->addBonus(node["damage"]["min"].Integer(), BonusType::CREATURE_DAMAGE, BonusCustomSubtype::creatureDamageMin);
|
||||
cre->addBonus(node["damage"]["max"].Integer(), BonusType::CREATURE_DAMAGE, BonusCustomSubtype::creatureDamageMax);
|
||||
|
||||
assert(node["damage"]["min"].Integer() <= node["damage"]["max"].Integer());
|
||||
|
||||
@ -792,7 +792,7 @@ void CCreatureHandler::loadCrExpBon(CBonusSystemNode & globalEffects)
|
||||
{
|
||||
CreatureID sid = static_cast<ui32>(parser.readNumber()); //id = this particular creature ID
|
||||
|
||||
b.sid = TBonusSourceID(sid);
|
||||
b.sid = BonusSourceID(sid);
|
||||
bl.clear();
|
||||
loadStackExp(b, bl, parser);
|
||||
for(const auto & b : bl)
|
||||
@ -898,7 +898,7 @@ void CCreatureHandler::loadCreatureJson(CCreature * creature, const JsonNode & c
|
||||
{
|
||||
auto b = JsonUtils::parseBonus(ability.second);
|
||||
b->source = BonusSource::CREATURE_ABILITY;
|
||||
b->sid = TBonusSourceID(creature->getId());
|
||||
b->sid = BonusSourceID(creature->getId());
|
||||
b->duration = BonusDuration::PERMANENT;
|
||||
creature->addNewBonus(b);
|
||||
}
|
||||
@ -916,7 +916,7 @@ void CCreatureHandler::loadCreatureJson(CCreature * creature, const JsonNode & c
|
||||
{
|
||||
auto b = JsonUtils::parseBonus(ability);
|
||||
b->source = BonusSource::CREATURE_ABILITY;
|
||||
b->sid = TBonusSourceID(creature->getId());
|
||||
b->sid = BonusSourceID(creature->getId());
|
||||
b->duration = BonusDuration::PERMANENT;
|
||||
creature->addNewBonus(b);
|
||||
}
|
||||
@ -1030,19 +1030,19 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigPars
|
||||
break;
|
||||
case 'A':
|
||||
b.type = BonusType::PRIMARY_SKILL;
|
||||
b.subtype = TBonusSubtype(PrimarySkill::ATTACK);
|
||||
b.subtype = BonusSubtypeID(PrimarySkill::ATTACK);
|
||||
break;
|
||||
case 'D':
|
||||
b.type = BonusType::PRIMARY_SKILL;
|
||||
b.subtype = TBonusSubtype(PrimarySkill::DEFENSE);
|
||||
b.subtype = BonusSubtypeID(PrimarySkill::DEFENSE);
|
||||
break;
|
||||
case 'M': //Max damage
|
||||
b.type = BonusType::CREATURE_DAMAGE;
|
||||
b.subtype = BonusSubtypeID::creatureDamageMax;
|
||||
b.subtype = BonusCustomSubtype::creatureDamageMax;
|
||||
break;
|
||||
case 'm': //Min damage
|
||||
b.type = BonusType::CREATURE_DAMAGE;
|
||||
b.subtype = BonusSubtypeID::creatureDamageMin;
|
||||
b.subtype = BonusCustomSubtype::creatureDamageMin;
|
||||
break;
|
||||
case 'S':
|
||||
b.type = BonusType::STACKS_SPEED; break;
|
||||
@ -1059,13 +1059,13 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigPars
|
||||
break;
|
||||
case 'E':
|
||||
b.type = BonusType::DEATH_STARE;
|
||||
b.subtype = BonusSubtypeID::deathStareGorgon;
|
||||
b.subtype = BonusCustomSubtype::deathStareGorgon;
|
||||
break;
|
||||
case 'F':
|
||||
b.type = BonusType::FEAR; break;
|
||||
case 'g':
|
||||
b.type = BonusType::SPELL_DAMAGE_REDUCTION;
|
||||
b.subtype = TBonusSubtype(SpellSchool::ANY);
|
||||
b.subtype = BonusSubtypeID(SpellSchool::ANY);
|
||||
break;
|
||||
case 'P':
|
||||
b.type = BonusType::CASTS; break;
|
||||
@ -1106,7 +1106,7 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigPars
|
||||
b.type = BonusType::MIND_IMMUNITY; break;
|
||||
case 'r':
|
||||
b.type = BonusType::REBIRTH; //on/off? makes sense?
|
||||
b.subtype = BonusSubtypeID::rebirthRegular;
|
||||
b.subtype = BonusCustomSubtype::rebirthRegular;
|
||||
b.val = 20; //arbitrary value
|
||||
break;
|
||||
case 'R':
|
||||
@ -1129,42 +1129,42 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigPars
|
||||
{
|
||||
case 'B': //Blind
|
||||
b.type = BonusType::SPELL_IMMUNITY;
|
||||
b.subtype = TBonusSubtype(SpellID(SpellID::BLIND));
|
||||
b.subtype = BonusSubtypeID(SpellID(SpellID::BLIND));
|
||||
b.additionalInfo = 0;//normal immunity
|
||||
break;
|
||||
case 'H': //Hypnotize
|
||||
b.type = BonusType::SPELL_IMMUNITY;
|
||||
b.subtype = TBonusSubtype(SpellID(SpellID::HYPNOTIZE));
|
||||
b.subtype = BonusSubtypeID(SpellID(SpellID::HYPNOTIZE));
|
||||
b.additionalInfo = 0;//normal immunity
|
||||
break;
|
||||
case 'I': //Implosion
|
||||
b.type = BonusType::SPELL_IMMUNITY;
|
||||
b.subtype = TBonusSubtype(SpellID(SpellID::IMPLOSION));
|
||||
b.subtype = BonusSubtypeID(SpellID(SpellID::IMPLOSION));
|
||||
b.additionalInfo = 0;//normal immunity
|
||||
break;
|
||||
case 'K': //Berserk
|
||||
b.type = BonusType::SPELL_IMMUNITY;
|
||||
b.subtype = TBonusSubtype(SpellID(SpellID::BERSERK));
|
||||
b.subtype = BonusSubtypeID(SpellID(SpellID::BERSERK));
|
||||
b.additionalInfo = 0;//normal immunity
|
||||
break;
|
||||
case 'M': //Meteor Shower
|
||||
b.type = BonusType::SPELL_IMMUNITY;
|
||||
b.subtype = TBonusSubtype(SpellID(SpellID::METEOR_SHOWER));
|
||||
b.subtype = BonusSubtypeID(SpellID(SpellID::METEOR_SHOWER));
|
||||
b.additionalInfo = 0;//normal immunity
|
||||
break;
|
||||
case 'N': //dispell beneficial spells
|
||||
b.type = BonusType::SPELL_IMMUNITY;
|
||||
b.subtype = TBonusSubtype(SpellID(SpellID::DISPEL_HELPFUL_SPELLS));
|
||||
b.subtype = BonusSubtypeID(SpellID(SpellID::DISPEL_HELPFUL_SPELLS));
|
||||
b.additionalInfo = 0;//normal immunity
|
||||
break;
|
||||
case 'R': //Armageddon
|
||||
b.type = BonusType::SPELL_IMMUNITY;
|
||||
b.subtype = TBonusSubtype(SpellID(SpellID::ARMAGEDDON));
|
||||
b.subtype = BonusSubtypeID(SpellID(SpellID::ARMAGEDDON));
|
||||
b.additionalInfo = 0;//normal immunity
|
||||
break;
|
||||
case 'S': //Slow
|
||||
b.type = BonusType::SPELL_IMMUNITY;
|
||||
b.subtype = TBonusSubtype(SpellID(SpellID::SLOW));
|
||||
b.subtype = BonusSubtypeID(SpellID(SpellID::SLOW));
|
||||
b.additionalInfo = 0;//normal immunity
|
||||
break;
|
||||
case '6':
|
||||
@ -1180,51 +1180,51 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigPars
|
||||
break;
|
||||
case 'F':
|
||||
b.type = BonusType::NEGATIVE_EFFECTS_IMMUNITY;
|
||||
b.subtype = TBonusSubtype(SpellSchool::FIRE);
|
||||
b.subtype = BonusSubtypeID(SpellSchool::FIRE);
|
||||
break;
|
||||
case 'O':
|
||||
b.type = BonusType::SPELL_DAMAGE_REDUCTION;
|
||||
b.subtype = TBonusSubtype(SpellSchool::FIRE);
|
||||
b.subtype = BonusSubtypeID(SpellSchool::FIRE);
|
||||
b.val = 100; //Full damage immunity
|
||||
break;
|
||||
case 'f':
|
||||
b.type = BonusType::SPELL_SCHOOL_IMMUNITY;
|
||||
b.subtype = TBonusSubtype(SpellSchool::FIRE);
|
||||
b.subtype = BonusSubtypeID(SpellSchool::FIRE);
|
||||
break;
|
||||
case 'C':
|
||||
b.type = BonusType::NEGATIVE_EFFECTS_IMMUNITY;
|
||||
b.subtype = TBonusSubtype(SpellSchool::WATER);
|
||||
b.subtype = BonusSubtypeID(SpellSchool::WATER);
|
||||
break;
|
||||
case 'W':
|
||||
b.type = BonusType::SPELL_DAMAGE_REDUCTION;
|
||||
b.subtype = TBonusSubtype(SpellSchool::WATER);
|
||||
b.subtype = BonusSubtypeID(SpellSchool::WATER);
|
||||
b.val = 100; //Full damage immunity
|
||||
break;
|
||||
case 'w':
|
||||
b.type = BonusType::SPELL_SCHOOL_IMMUNITY;
|
||||
b.subtype = TBonusSubtype(SpellSchool::WATER);
|
||||
b.subtype = BonusSubtypeID(SpellSchool::WATER);
|
||||
break;
|
||||
case 'E':
|
||||
b.type = BonusType::SPELL_DAMAGE_REDUCTION;
|
||||
b.subtype = TBonusSubtype(SpellSchool::EARTH);
|
||||
b.subtype = BonusSubtypeID(SpellSchool::EARTH);
|
||||
b.val = 100; //Full damage immunity
|
||||
break;
|
||||
case 'e':
|
||||
b.type = BonusType::SPELL_SCHOOL_IMMUNITY;
|
||||
b.subtype = TBonusSubtype(SpellSchool::EARTH);
|
||||
b.subtype = BonusSubtypeID(SpellSchool::EARTH);
|
||||
break;
|
||||
case 'A':
|
||||
b.type = BonusType::SPELL_DAMAGE_REDUCTION;
|
||||
b.subtype = TBonusSubtype(SpellSchool::AIR);
|
||||
b.subtype = BonusSubtypeID(SpellSchool::AIR);
|
||||
b.val = 100; //Full damage immunity
|
||||
break;
|
||||
case 'a':
|
||||
b.type = BonusType::SPELL_SCHOOL_IMMUNITY;
|
||||
b.subtype = TBonusSubtype(SpellSchool::AIR);
|
||||
b.subtype = BonusSubtypeID(SpellSchool::AIR);
|
||||
break;
|
||||
case 'D':
|
||||
b.type = BonusType::SPELL_DAMAGE_REDUCTION;
|
||||
b.subtype = TBonusSubtype(SpellSchool::ANY);
|
||||
b.subtype = BonusSubtypeID(SpellSchool::ANY);
|
||||
b.val = 100; //Full damage immunity
|
||||
break;
|
||||
case '0':
|
||||
@ -1253,16 +1253,16 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigPars
|
||||
case 'K':
|
||||
case 'k':
|
||||
b.type = BonusType::SPELL_AFTER_ATTACK;
|
||||
b.subtype = TBonusSubtype(SpellID(stringToNumber(mod)));
|
||||
b.subtype = BonusSubtypeID(SpellID(stringToNumber(mod)));
|
||||
break;
|
||||
case 'h':
|
||||
b.type = BonusType::HATE;
|
||||
b.subtype = TBonusSubtype(CreatureID(stringToNumber(mod)));
|
||||
b.subtype = BonusSubtypeID(CreatureID(stringToNumber(mod)));
|
||||
break;
|
||||
case 'p':
|
||||
case 'J':
|
||||
b.type = BonusType::SPELL_BEFORE_ATTACK;
|
||||
b.subtype = TBonusSubtype(SpellID(stringToNumber(mod)));
|
||||
b.subtype = BonusSubtypeID(SpellID(stringToNumber(mod)));
|
||||
b.additionalInfo = 3; //always expert?
|
||||
break;
|
||||
case 'r':
|
||||
@ -1271,7 +1271,7 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigPars
|
||||
break;
|
||||
case 's':
|
||||
b.type = BonusType::ENCHANTED;
|
||||
b.subtype = TBonusSubtype(SpellID(stringToNumber(mod)));
|
||||
b.subtype = BonusSubtypeID(SpellID(stringToNumber(mod)));
|
||||
b.valType = BonusValueType::INDEPENDENT_MAX;
|
||||
break;
|
||||
default:
|
||||
|
@ -195,7 +195,7 @@ public:
|
||||
bool valid() const;
|
||||
|
||||
void addBonus(int val, BonusType type);
|
||||
void addBonus(int val, BonusType type, TBonusSubtype subtype);
|
||||
void addBonus(int val, BonusType type, BonusSubtypeID subtype);
|
||||
std::string nodeName() const override;
|
||||
|
||||
template<typename RanGen>
|
||||
|
@ -268,7 +268,7 @@ bool CGameInfoCallback::getTownInfo(const CGObjectInstance * town, InfoAboutTown
|
||||
{
|
||||
const auto * selectedHero = dynamic_cast<const CGHeroInstance *>(selectedObject);
|
||||
if(nullptr != selectedHero)
|
||||
detailed = selectedHero->hasVisions(town, BonusSubtypeID::visionsTowns);
|
||||
detailed = selectedHero->hasVisions(town, BonusCustomSubtype::visionsTowns);
|
||||
}
|
||||
|
||||
dest.initFromTown(dynamic_cast<const CGTownInstance *>(town), detailed);
|
||||
@ -322,7 +322,7 @@ bool CGameInfoCallback::getHeroInfo(const CGObjectInstance * hero, InfoAboutHero
|
||||
{
|
||||
const auto * selectedHero = dynamic_cast<const CGHeroInstance *>(selectedObject);
|
||||
if(nullptr != selectedHero)
|
||||
if(selectedHero->hasVisions(hero, BonusSubtypeID::visionsHeroes))
|
||||
if(selectedHero->hasVisions(hero, BonusCustomSubtype::visionsHeroes))
|
||||
infoLevel = InfoAboutHero::EInfoLevel::DETAILED;
|
||||
}
|
||||
|
||||
|
@ -547,7 +547,7 @@ static std::vector<std::shared_ptr<Bonus>> createCreatureSpecialty(CreatureID ba
|
||||
{
|
||||
std::shared_ptr<Bonus> bonus = std::make_shared<Bonus>();
|
||||
bonus->type = BonusType::PRIMARY_SKILL;
|
||||
bonus->subtype = TBonusSubtype(PrimarySkill::ATTACK);
|
||||
bonus->subtype = BonusSubtypeID(PrimarySkill::ATTACK);
|
||||
bonus->val = 0;
|
||||
bonus->limiter.reset(new CCreatureTypeLimiter(specCreature, false));
|
||||
bonus->updater.reset(new GrowsWithLevelUpdater(specCreature.getAttack(false), stepSize));
|
||||
@ -557,7 +557,7 @@ static std::vector<std::shared_ptr<Bonus>> createCreatureSpecialty(CreatureID ba
|
||||
{
|
||||
std::shared_ptr<Bonus> bonus = std::make_shared<Bonus>();
|
||||
bonus->type = BonusType::PRIMARY_SKILL;
|
||||
bonus->subtype = TBonusSubtype(PrimarySkill::DEFENSE);
|
||||
bonus->subtype = BonusSubtypeID(PrimarySkill::DEFENSE);
|
||||
bonus->val = 0;
|
||||
bonus->limiter.reset(new CCreatureTypeLimiter(specCreature, false));
|
||||
bonus->updater.reset(new GrowsWithLevelUpdater(specCreature.getDefense(false), stepSize));
|
||||
@ -605,7 +605,7 @@ void CHeroHandler::loadHeroSpecialty(CHero * hero, const JsonNode & node)
|
||||
{
|
||||
bonus->duration = BonusDuration::PERMANENT;
|
||||
bonus->source = BonusSource::HERO_SPECIAL;
|
||||
bonus->sid = TBonusSourceID(hero->getId());
|
||||
bonus->sid = BonusSourceID(hero->getId());
|
||||
return bonus;
|
||||
};
|
||||
|
||||
|
@ -93,7 +93,7 @@ SecondarySkill CSkill::getId() const
|
||||
void CSkill::addNewBonus(const std::shared_ptr<Bonus> & b, int level)
|
||||
{
|
||||
b->source = BonusSource::SECONDARY_SKILL;
|
||||
b->sid = TBonusSourceID(id);
|
||||
b->sid = BonusSourceID(id);
|
||||
b->duration = BonusDuration::PERMANENT;
|
||||
b->description = getNameTranslated();
|
||||
levels[level-1].effects.push_back(b);
|
||||
|
@ -220,7 +220,7 @@ void CStack::prepareAttacked(BattleStackAttacked & bsa, vstd::RNG & rand, const
|
||||
resurrectedCount += 1;
|
||||
}
|
||||
|
||||
if(customState->hasBonusOfType(BonusType::REBIRTH, BonusSubtypeID::rebirthSpecial))
|
||||
if(customState->hasBonusOfType(BonusType::REBIRTH, BonusCustomSubtype::rebirthSpecial))
|
||||
{
|
||||
// resurrect at least one Sacred Phoenix
|
||||
vstd::amax(resurrectedCount, 1);
|
||||
|
@ -551,16 +551,16 @@ void CTownHandler::addBonusesForVanilaBuilding(CBuilding * building) const
|
||||
b = createBonus(building, BonusType::LUCK, +2);
|
||||
break;
|
||||
case BuildingSubID::SPELL_POWER_GARRISON_BONUS:
|
||||
b = createBonus(building, BonusType::PRIMARY_SKILL, +2, TBonusSubtype(PrimarySkill::SPELL_POWER));
|
||||
b = createBonus(building, BonusType::PRIMARY_SKILL, +2, BonusSubtypeID(PrimarySkill::SPELL_POWER));
|
||||
break;
|
||||
case BuildingSubID::ATTACK_GARRISON_BONUS:
|
||||
b = createBonus(building, BonusType::PRIMARY_SKILL, +2, TBonusSubtype(PrimarySkill::ATTACK));
|
||||
b = createBonus(building, BonusType::PRIMARY_SKILL, +2, BonusSubtypeID(PrimarySkill::ATTACK));
|
||||
break;
|
||||
case BuildingSubID::DEFENSE_GARRISON_BONUS:
|
||||
b = createBonus(building, BonusType::PRIMARY_SKILL, +2, TBonusSubtype(PrimarySkill::DEFENSE));
|
||||
b = createBonus(building, BonusType::PRIMARY_SKILL, +2, BonusSubtypeID(PrimarySkill::DEFENSE));
|
||||
break;
|
||||
case BuildingSubID::LIGHTHOUSE:
|
||||
b = createBonus(building, BonusType::MOVEMENT, +500, BonusSubtypeID::heroMovementSea, playerPropagator);
|
||||
b = createBonus(building, BonusType::MOVEMENT, +500, BonusCustomSubtype::heroMovementSea, playerPropagator);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -570,15 +570,15 @@ void CTownHandler::addBonusesForVanilaBuilding(CBuilding * building) const
|
||||
|
||||
std::shared_ptr<Bonus> CTownHandler::createBonus(CBuilding * build, BonusType type, int val) const
|
||||
{
|
||||
return createBonus(build, type, val, TBonusSubtype(), emptyPropagator());
|
||||
return createBonus(build, type, val, BonusSubtypeID(), emptyPropagator());
|
||||
}
|
||||
|
||||
std::shared_ptr<Bonus> CTownHandler::createBonus(CBuilding * build, BonusType type, int val, TBonusSubtype subtype) const
|
||||
std::shared_ptr<Bonus> CTownHandler::createBonus(CBuilding * build, BonusType type, int val, BonusSubtypeID subtype) const
|
||||
{
|
||||
return createBonus(build, type, val, subtype, emptyPropagator());
|
||||
}
|
||||
|
||||
std::shared_ptr<Bonus> CTownHandler::createBonus(CBuilding * build, BonusType type, int val, TBonusSubtype subtype, TPropagatorPtr & prop) const
|
||||
std::shared_ptr<Bonus> CTownHandler::createBonus(CBuilding * build, BonusType type, int val, BonusSubtypeID subtype, TPropagatorPtr & prop) const
|
||||
{
|
||||
std::ostringstream descr;
|
||||
descr << build->getNameTranslated();
|
||||
@ -591,7 +591,7 @@ std::shared_ptr<Bonus> CTownHandler::createBonusImpl(const BuildingID & building
|
||||
int val,
|
||||
TPropagatorPtr & prop,
|
||||
const std::string & description,
|
||||
TBonusSubtype subtype) const
|
||||
BonusSubtypeID subtype) const
|
||||
{
|
||||
auto b = std::make_shared<Bonus>(BonusDuration::PERMANENT, type, BonusSource::TOWN_STRUCTURE, val, BuildingTypeUniqueID(faction, building), subtype, description);
|
||||
|
||||
@ -610,7 +610,7 @@ void CTownHandler::loadSpecialBuildingBonuses(const JsonNode & source, BonusList
|
||||
if(bonus == nullptr)
|
||||
continue;
|
||||
|
||||
bonus->sid = TBonusSourceID(building->getUniqueTypeID());
|
||||
bonus->sid = BonusSourceID(building->getUniqueTypeID());
|
||||
//JsonUtils::parseBuildingBonus produces UNKNOWN type propagator instead of empty.
|
||||
if(bonus->propagator != nullptr
|
||||
&& bonus->propagator->getPropagatorType() == CBonusSystemNode::ENodeTypes::UNKNOWN)
|
||||
@ -674,7 +674,7 @@ void CTownHandler::loadBuilding(CTown * town, const std::string & stringID, cons
|
||||
ret->subId = BuildingSubID::CUSTOM_VISITING_BONUS;
|
||||
|
||||
for(auto & bonus : ret->onVisitBonuses)
|
||||
bonus->sid = TBonusSourceID(ret->getUniqueTypeID());
|
||||
bonus->sid = BonusSourceID(ret->getUniqueTypeID());
|
||||
}
|
||||
|
||||
if(source["type"].String() == "configurable" && ret->subId == BuildingSubID::NONE)
|
||||
|
@ -392,15 +392,15 @@ class DLL_LINKAGE CTownHandler : public CHandlerBase<FactionID, Faction, CFactio
|
||||
void loadBuildings(CTown * town, const JsonNode & source);
|
||||
|
||||
std::shared_ptr<Bonus> createBonus(CBuilding * build, BonusType type, int val) const;
|
||||
std::shared_ptr<Bonus> createBonus(CBuilding * build, BonusType type, int val, TBonusSubtype subtype) const;
|
||||
std::shared_ptr<Bonus> createBonus(CBuilding * build, BonusType type, int val, TBonusSubtype subtype, TPropagatorPtr & prop) const;
|
||||
std::shared_ptr<Bonus> createBonus(CBuilding * build, BonusType type, int val, BonusSubtypeID subtype) const;
|
||||
std::shared_ptr<Bonus> createBonus(CBuilding * build, BonusType type, int val, BonusSubtypeID subtype, TPropagatorPtr & prop) const;
|
||||
std::shared_ptr<Bonus> createBonusImpl(const BuildingID & building,
|
||||
const FactionID & faction,
|
||||
BonusType type,
|
||||
int val,
|
||||
TPropagatorPtr & prop,
|
||||
const std::string & description,
|
||||
TBonusSubtype subtype) const;
|
||||
BonusSubtypeID subtype) const;
|
||||
|
||||
/// loads CStructure's into town
|
||||
void loadStructure(CTown & town, const std::string & stringID, const JsonNode & source) const;
|
||||
|
@ -417,25 +417,25 @@ std::string JsonNode::toJson(bool compact) const
|
||||
|
||||
///JsonUtils
|
||||
|
||||
static void loadBonusSubtype(TBonusSubtype & subtype, BonusType type, const JsonNode & node)
|
||||
static void loadBonusSubtype(BonusSubtypeID & subtype, BonusType type, const JsonNode & node)
|
||||
{
|
||||
if (node.isNull())
|
||||
{
|
||||
subtype = TBonusSubtype();
|
||||
subtype = BonusSubtypeID();
|
||||
return;
|
||||
}
|
||||
|
||||
if (node.isNumber()) // Compatibility code for 1.3 or older
|
||||
{
|
||||
logMod->warn("Bonus subtype must be string!");
|
||||
subtype = BonusSubtypeID(node.Integer());
|
||||
subtype = BonusCustomSubtype(node.Integer());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!node.isString())
|
||||
{
|
||||
logMod->warn("Bonus subtype must be string!");
|
||||
subtype = TBonusSubtype();
|
||||
subtype = BonusSubtypeID();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -538,7 +538,7 @@ static void loadBonusSubtype(TBonusSubtype & subtype, BonusType type, const Json
|
||||
{
|
||||
VLC->identifiers()->requestIdentifier( "bonusSubtype", node, [&subtype](int32_t identifier)
|
||||
{
|
||||
subtype = BonusSubtypeID(identifier);
|
||||
subtype = BonusCustomSubtype(identifier);
|
||||
});
|
||||
break;
|
||||
}
|
||||
@ -546,29 +546,29 @@ static void loadBonusSubtype(TBonusSubtype & subtype, BonusType type, const Json
|
||||
for(const auto & i : bonusNameMap)
|
||||
if(i.second == type)
|
||||
logMod->warn("Bonus type %s does not supports subtypes!", i.first );
|
||||
subtype = TBonusSubtype();
|
||||
subtype = BonusSubtypeID();
|
||||
}
|
||||
}
|
||||
|
||||
static void loadBonusSourceInstance(TBonusSourceID & sourceInstance, BonusSource sourceType, const JsonNode & node)
|
||||
static void loadBonusSourceInstance(BonusSourceID & sourceInstance, BonusSource sourceType, const JsonNode & node)
|
||||
{
|
||||
if (node.isNull())
|
||||
{
|
||||
sourceInstance = BonusSourceID();
|
||||
sourceInstance = BonusCustomSource();
|
||||
return;
|
||||
}
|
||||
|
||||
if (node.isNumber()) // Compatibility code for 1.3 or older
|
||||
{
|
||||
logMod->warn("Bonus source must be string!");
|
||||
sourceInstance = BonusSourceID(node.Integer());
|
||||
sourceInstance = BonusCustomSource(node.Integer());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!node.isString())
|
||||
{
|
||||
logMod->warn("Bonus source must be string!");
|
||||
sourceInstance = BonusSourceID();
|
||||
sourceInstance = BonusCustomSource();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -643,7 +643,7 @@ static void loadBonusSourceInstance(TBonusSourceID & sourceInstance, BonusSource
|
||||
case BonusSource::TERRAIN_NATIVE:
|
||||
case BonusSource::OTHER:
|
||||
default:
|
||||
sourceInstance = TBonusSourceID();
|
||||
sourceInstance = BonusSourceID();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1181,13 +1181,13 @@ CSelector JsonUtils::parseSelector(const JsonNode & ability)
|
||||
value = &ability["subtype"];
|
||||
if(!value->isNull() && type != BonusType::NONE)
|
||||
{
|
||||
TBonusSubtype subtype;
|
||||
BonusSubtypeID subtype;
|
||||
loadBonusSubtype(subtype, type, ability);
|
||||
ret = ret.And(Selector::subtype()(subtype));
|
||||
}
|
||||
value = &ability["sourceType"];
|
||||
std::optional<BonusSource> src = std::nullopt; //Fixes for GCC false maybe-uninitialized
|
||||
std::optional<TBonusSourceID> id = std::nullopt;
|
||||
std::optional<BonusSourceID> id = std::nullopt;
|
||||
if(value->isString())
|
||||
{
|
||||
auto it = bonusSourceMap.find(value->String());
|
||||
|
@ -497,7 +497,7 @@ struct DLL_LINKAGE RemoveBonus : public CPackForClient
|
||||
|
||||
//vars to identify bonus: its source
|
||||
BonusSource source;
|
||||
TBonusSourceID id; //source id
|
||||
BonusSourceID id; //source id
|
||||
|
||||
//used locally: copy of removed bonus
|
||||
Bonus bonus;
|
||||
|
@ -442,9 +442,9 @@ BattleInfo * BattleInfo::setupBattle(const int3 & tile, TerrainId terrain, const
|
||||
//native terrain bonuses
|
||||
static auto nativeTerrain = std::make_shared<CreatureTerrainLimiter>();
|
||||
|
||||
curB->addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::STACKS_SPEED, BonusSource::TERRAIN_NATIVE, 1, TBonusSourceID())->addLimiter(nativeTerrain));
|
||||
curB->addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::PRIMARY_SKILL, BonusSource::TERRAIN_NATIVE, 1, TBonusSourceID(), TBonusSubtype(PrimarySkill::ATTACK))->addLimiter(nativeTerrain));
|
||||
curB->addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::PRIMARY_SKILL, BonusSource::TERRAIN_NATIVE, 1, TBonusSourceID(), TBonusSubtype(PrimarySkill::DEFENSE))->addLimiter(nativeTerrain));
|
||||
curB->addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::STACKS_SPEED, BonusSource::TERRAIN_NATIVE, 1, BonusSourceID())->addLimiter(nativeTerrain));
|
||||
curB->addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::PRIMARY_SKILL, BonusSource::TERRAIN_NATIVE, 1, BonusSourceID(), BonusSubtypeID(PrimarySkill::ATTACK))->addLimiter(nativeTerrain));
|
||||
curB->addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::PRIMARY_SKILL, BonusSource::TERRAIN_NATIVE, 1, BonusSourceID(), BonusSubtypeID(PrimarySkill::DEFENSE))->addLimiter(nativeTerrain));
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//tactics
|
||||
|
@ -1658,7 +1658,7 @@ SpellID CBattleInfoCallback::getRandomBeneficialSpell(CRandomGenerator & rand, c
|
||||
std::stringstream cachingStr;
|
||||
cachingStr << "source_" << vstd::to_underlying(BonusSource::SPELL_EFFECT) << "id_" << spellID.num;
|
||||
|
||||
if(subject->hasBonus(Selector::source(BonusSource::SPELL_EFFECT, TBonusSourceID(spellID)), Selector::all, cachingStr.str())
|
||||
if(subject->hasBonus(Selector::source(BonusSource::SPELL_EFFECT, BonusSourceID(spellID)), Selector::all, cachingStr.str())
|
||||
//TODO: this ability has special limitations
|
||||
|| !(spellID.toSpell()->canBeCast(this, spells::Mode::CREATURE_ACTIVE, subject)))
|
||||
continue;
|
||||
|
@ -340,12 +340,12 @@ CUnitState::CUnitState():
|
||||
health(this),
|
||||
shots(this),
|
||||
totalAttacks(this, Selector::type()(BonusType::ADDITIONAL_ATTACK), 1),
|
||||
minDamage(this, Selector::typeSubtype(BonusType::CREATURE_DAMAGE, BonusSubtypeID::creatureDamageBoth).Or(Selector::typeSubtype(BonusType::CREATURE_DAMAGE, BonusSubtypeID::creatureDamageMin)), 0),
|
||||
maxDamage(this, Selector::typeSubtype(BonusType::CREATURE_DAMAGE, BonusSubtypeID::creatureDamageBoth).Or(Selector::typeSubtype(BonusType::CREATURE_DAMAGE, BonusSubtypeID::creatureDamageMax)), 0),
|
||||
attack(this, Selector::typeSubtype(BonusType::PRIMARY_SKILL, TBonusSubtype(PrimarySkill::ATTACK)), 0),
|
||||
defence(this, Selector::typeSubtype(BonusType::PRIMARY_SKILL, TBonusSubtype(PrimarySkill::DEFENSE)), 0),
|
||||
minDamage(this, Selector::typeSubtype(BonusType::CREATURE_DAMAGE, BonusCustomSubtype::creatureDamageBoth).Or(Selector::typeSubtype(BonusType::CREATURE_DAMAGE, BonusCustomSubtype::creatureDamageMin)), 0),
|
||||
maxDamage(this, Selector::typeSubtype(BonusType::CREATURE_DAMAGE, BonusCustomSubtype::creatureDamageBoth).Or(Selector::typeSubtype(BonusType::CREATURE_DAMAGE, BonusCustomSubtype::creatureDamageMax)), 0),
|
||||
attack(this, Selector::typeSubtype(BonusType::PRIMARY_SKILL, BonusSubtypeID(PrimarySkill::ATTACK)), 0),
|
||||
defence(this, Selector::typeSubtype(BonusType::PRIMARY_SKILL, BonusSubtypeID(PrimarySkill::DEFENSE)), 0),
|
||||
inFrenzy(this, Selector::type()(BonusType::IN_FRENZY)),
|
||||
cloneLifetimeMarker(this, Selector::type()(BonusType::NONE).And(Selector::source(BonusSource::SPELL_EFFECT, TBonusSourceID(SpellID(SpellID::CLONE))))),
|
||||
cloneLifetimeMarker(this, Selector::type()(BonusType::NONE).And(Selector::source(BonusSource::SPELL_EFFECT, BonusSourceID(SpellID(SpellID::CLONE))))),
|
||||
cloneID(-1)
|
||||
{
|
||||
|
||||
@ -430,7 +430,7 @@ const CGHeroInstance * CUnitState::getHeroCaster() const
|
||||
|
||||
int32_t CUnitState::getSpellSchoolLevel(const spells::Spell * spell, int32_t * outSelectedSchool) const
|
||||
{
|
||||
int32_t skill = valOfBonuses(Selector::typeSubtype(BonusType::SPELLCASTER, TBonusSubtype(spell->getId())));
|
||||
int32_t skill = valOfBonuses(Selector::typeSubtype(BonusType::SPELLCASTER, BonusSubtypeID(spell->getId())));
|
||||
vstd::abetween(skill, 0, 3);
|
||||
return skill;
|
||||
}
|
||||
@ -466,7 +466,7 @@ int32_t CUnitState::getEnchantPower(const spells::Spell * spell) const
|
||||
|
||||
int64_t CUnitState::getEffectValue(const spells::Spell * spell) const
|
||||
{
|
||||
return static_cast<int64_t>(getCount()) * valOfBonuses(BonusType::SPECIFIC_SPELL_POWER, TBonusSubtype(spell->getId()));
|
||||
return static_cast<int64_t>(getCount()) * valOfBonuses(BonusType::SPECIFIC_SPELL_POWER, BonusSubtypeID(spell->getId()));
|
||||
}
|
||||
|
||||
PlayerColor CUnitState::getCasterOwner() const
|
||||
@ -511,7 +511,7 @@ bool CUnitState::isGhost() const
|
||||
|
||||
bool CUnitState::isFrozen() const
|
||||
{
|
||||
return hasBonus(Selector::source(BonusSource::SPELL_EFFECT, TBonusSourceID(SpellID(SpellID::STONE_GAZE))), Selector::all);
|
||||
return hasBonus(Selector::source(BonusSource::SPELL_EFFECT, BonusSourceID(SpellID(SpellID::STONE_GAZE))), Selector::all);
|
||||
}
|
||||
|
||||
bool CUnitState::isValidTarget(bool allowDead) const
|
||||
|
@ -52,7 +52,7 @@ DamageRange DamageCalculator::getBaseDamageSingle() const
|
||||
{
|
||||
auto retrieveHeroPrimSkill = [&](PrimarySkill skill) -> int
|
||||
{
|
||||
std::shared_ptr<const Bonus> b = info.attacker->getBonus(Selector::sourceTypeSel(BonusSource::HERO_BASE_SKILL).And(Selector::typeSubtype(BonusType::PRIMARY_SKILL, TBonusSubtype(skill))));
|
||||
std::shared_ptr<const Bonus> b = info.attacker->getBonus(Selector::sourceTypeSel(BonusSource::HERO_BASE_SKILL).And(Selector::typeSubtype(BonusType::PRIMARY_SKILL, BonusSubtypeID(skill))));
|
||||
return b ? b->val : 0;
|
||||
};
|
||||
|
||||
@ -144,7 +144,7 @@ int DamageCalculator::getActorAttackSlayer() const
|
||||
{
|
||||
SpellID spell(SpellID::SLAYER);
|
||||
int attackBonus = spell.toSpell()->getLevelPower(spLevel);
|
||||
if(info.attacker->hasBonusOfType(BonusType::SPECIAL_PECULIAR_ENCHANT, TBonusSubtype(spell)))
|
||||
if(info.attacker->hasBonusOfType(BonusType::SPECIAL_PECULIAR_ENCHANT, BonusSubtypeID(spell)))
|
||||
{
|
||||
ui8 attackerTier = info.attacker->unitType()->getLevel();
|
||||
ui8 specialtyBonus = std::max(5 - attackerTier, 0);
|
||||
@ -206,11 +206,11 @@ double DamageCalculator::getAttackOffenseArcheryFactor() const
|
||||
if(info.shooting)
|
||||
{
|
||||
const std::string cachingStrArchery = "type_PERCENTAGE_DAMAGE_BOOSTs_1";
|
||||
static const auto selectorArchery = Selector::typeSubtype(BonusType::PERCENTAGE_DAMAGE_BOOST, BonusSubtypeID::damageTypeRanged);
|
||||
static const auto selectorArchery = Selector::typeSubtype(BonusType::PERCENTAGE_DAMAGE_BOOST, BonusCustomSubtype::damageTypeRanged);
|
||||
return info.attacker->valOfBonuses(selectorArchery, cachingStrArchery) / 100.0;
|
||||
}
|
||||
const std::string cachingStrOffence = "type_PERCENTAGE_DAMAGE_BOOSTs_0";
|
||||
static const auto selectorOffence = Selector::typeSubtype(BonusType::PERCENTAGE_DAMAGE_BOOST, BonusSubtypeID::damageTypeMelee);
|
||||
static const auto selectorOffence = Selector::typeSubtype(BonusType::PERCENTAGE_DAMAGE_BOOST, BonusCustomSubtype::damageTypeMelee);
|
||||
return info.attacker->valOfBonuses(selectorOffence, cachingStrOffence) / 100.0;
|
||||
}
|
||||
|
||||
@ -232,7 +232,7 @@ double DamageCalculator::getAttackDoubleDamageFactor() const
|
||||
{
|
||||
if(info.doubleDamage) {
|
||||
const auto cachingStr = "type_BONUS_DAMAGE_PERCENTAGEs_" + std::to_string(info.attacker->creatureIndex());
|
||||
const auto selector = Selector::typeSubtype(BonusType::BONUS_DAMAGE_PERCENTAGE, TBonusSubtype(info.attacker->creatureId()));
|
||||
const auto selector = Selector::typeSubtype(BonusType::BONUS_DAMAGE_PERCENTAGE, BonusSubtypeID(info.attacker->creatureId()));
|
||||
return info.attacker->valOfBonuses(selector, cachingStr) / 100.0;
|
||||
}
|
||||
return 0.0;
|
||||
@ -260,7 +260,7 @@ double DamageCalculator::getAttackHateFactor() const
|
||||
|
||||
auto allHateEffects = info.attacker->getBonuses(selectorHate, cachingStrHate);
|
||||
|
||||
return allHateEffects->valOfBonuses(Selector::subtype()(TBonusSubtype(info.defender->creatureId()))) / 100.0;
|
||||
return allHateEffects->valOfBonuses(Selector::subtype()(BonusSubtypeID(info.defender->creatureId()))) / 100.0;
|
||||
}
|
||||
|
||||
double DamageCalculator::getDefenseSkillFactor() const
|
||||
@ -282,7 +282,7 @@ double DamageCalculator::getDefenseSkillFactor() const
|
||||
double DamageCalculator::getDefenseArmorerFactor() const
|
||||
{
|
||||
const std::string cachingStrArmorer = "type_GENERAL_DAMAGE_REDUCTIONs_N1_NsrcSPELL_EFFECT";
|
||||
static const auto selectorArmorer = Selector::typeSubtype(BonusType::GENERAL_DAMAGE_REDUCTION, BonusSubtypeID::damageTypeAll).And(Selector::sourceTypeSel(BonusSource::SPELL_EFFECT).Not());
|
||||
static const auto selectorArmorer = Selector::typeSubtype(BonusType::GENERAL_DAMAGE_REDUCTION, BonusCustomSubtype::damageTypeAll).And(Selector::sourceTypeSel(BonusSource::SPELL_EFFECT).Not());
|
||||
return info.defender->valOfBonuses(selectorArmorer, cachingStrArmorer) / 100.0;
|
||||
|
||||
}
|
||||
@ -290,10 +290,10 @@ double DamageCalculator::getDefenseArmorerFactor() const
|
||||
double DamageCalculator::getDefenseMagicShieldFactor() const
|
||||
{
|
||||
const std::string cachingStrMeleeReduction = "type_GENERAL_DAMAGE_REDUCTIONs_0";
|
||||
static const auto selectorMeleeReduction = Selector::typeSubtype(BonusType::GENERAL_DAMAGE_REDUCTION, BonusSubtypeID::damageTypeMelee);
|
||||
static const auto selectorMeleeReduction = Selector::typeSubtype(BonusType::GENERAL_DAMAGE_REDUCTION, BonusCustomSubtype::damageTypeMelee);
|
||||
|
||||
const std::string cachingStrRangedReduction = "type_GENERAL_DAMAGE_REDUCTIONs_1";
|
||||
static const auto selectorRangedReduction = Selector::typeSubtype(BonusType::GENERAL_DAMAGE_REDUCTION, BonusSubtypeID::damageTypeRanged);
|
||||
static const auto selectorRangedReduction = Selector::typeSubtype(BonusType::GENERAL_DAMAGE_REDUCTION, BonusCustomSubtype::damageTypeRanged);
|
||||
|
||||
//handling spell effects - shield and air shield
|
||||
if(info.shooting)
|
||||
@ -313,7 +313,7 @@ double DamageCalculator::getDefenseRangePenaltiesFactor() const
|
||||
auto isAdvancedAirShield = [](const Bonus* bonus)
|
||||
{
|
||||
return bonus->source == BonusSource::SPELL_EFFECT
|
||||
&& bonus->sid == TBonusSourceID(SpellID(SpellID::AIR_SHIELD))
|
||||
&& bonus->sid == BonusSourceID(SpellID(SpellID::AIR_SHIELD))
|
||||
&& bonus->val >= MasteryLevel::ADVANCED;
|
||||
};
|
||||
|
||||
@ -387,7 +387,7 @@ double DamageCalculator::getDefensePetrificationFactor() const
|
||||
{
|
||||
// Creatures that are petrified by a Basilisk's Petrifying attack or a Medusa's Stone gaze take 50% damage (R8 = 0.50) from ranged and melee attacks. Taking damage also deactivates the effect.
|
||||
const std::string cachingStrAllReduction = "type_GENERAL_DAMAGE_REDUCTIONs_N1_srcSPELL_EFFECT";
|
||||
static const auto selectorAllReduction = Selector::typeSubtype(BonusType::GENERAL_DAMAGE_REDUCTION, BonusSubtypeID::damageTypeAll).And(Selector::sourceTypeSel(BonusSource::SPELL_EFFECT));
|
||||
static const auto selectorAllReduction = Selector::typeSubtype(BonusType::GENERAL_DAMAGE_REDUCTION, BonusCustomSubtype::damageTypeAll).And(Selector::sourceTypeSel(BonusSource::SPELL_EFFECT));
|
||||
|
||||
return info.defender->valOfBonuses(selectorAllReduction, cachingStrAllReduction) / 100.0;
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ JsonNode Bonus::toJsonNode() const
|
||||
JsonNode root(JsonNode::JsonType::DATA_STRUCT);
|
||||
// only add values that might reasonably be found in config files
|
||||
root["type"].String() = vstd::findKey(bonusNameMap, type);
|
||||
if(subtype != TBonusSubtype())
|
||||
if(subtype != BonusSubtypeID())
|
||||
root["subtype"].String() = subtype.toString();
|
||||
if(additionalInfo != CAddInfo::NONE)
|
||||
root["addInfo"] = additionalInfoToJson(type, additionalInfo);
|
||||
@ -158,7 +158,7 @@ JsonNode Bonus::toJsonNode() const
|
||||
root["sourceType"].String() = vstd::findKey(bonusSourceMap, source);
|
||||
if(targetSourceType != BonusSource::OTHER)
|
||||
root["targetSourceType"].String() = vstd::findKey(bonusSourceMap, targetSourceType);
|
||||
if(sid != TBonusSourceID())
|
||||
if(sid != BonusSourceID())
|
||||
root["sourceID"].String() = sid.toString();
|
||||
if(val != 0)
|
||||
root["val"].Integer() = val;
|
||||
@ -183,19 +183,19 @@ JsonNode Bonus::toJsonNode() const
|
||||
return root;
|
||||
}
|
||||
|
||||
Bonus::Bonus(BonusDuration::Type Duration, BonusType Type, BonusSource Src, si32 Val, TBonusSourceID ID)
|
||||
: Bonus(Duration, Type, Src, Val, ID, TBonusSubtype(), std::string())
|
||||
Bonus::Bonus(BonusDuration::Type Duration, BonusType Type, BonusSource Src, si32 Val, BonusSourceID ID)
|
||||
: Bonus(Duration, Type, Src, Val, ID, BonusSubtypeID(), std::string())
|
||||
{}
|
||||
|
||||
Bonus::Bonus(BonusDuration::Type Duration, BonusType Type, BonusSource Src, si32 Val, TBonusSourceID ID, std::string Desc)
|
||||
: Bonus(Duration, Type, Src, Val, ID, TBonusSubtype(), Desc)
|
||||
Bonus::Bonus(BonusDuration::Type Duration, BonusType Type, BonusSource Src, si32 Val, BonusSourceID ID, std::string Desc)
|
||||
: Bonus(Duration, Type, Src, Val, ID, BonusSubtypeID(), Desc)
|
||||
{}
|
||||
|
||||
Bonus::Bonus(BonusDuration::Type Duration, BonusType Type, BonusSource Src, si32 Val, TBonusSourceID ID, TBonusSubtype Subtype)
|
||||
Bonus::Bonus(BonusDuration::Type Duration, BonusType Type, BonusSource Src, si32 Val, BonusSourceID ID, BonusSubtypeID Subtype)
|
||||
: Bonus(Duration, Type, Src, Val, ID, Subtype, std::string())
|
||||
{}
|
||||
|
||||
Bonus::Bonus(BonusDuration::Type Duration, BonusType Type, BonusSource Src, si32 Val, TBonusSourceID ID, TBonusSubtype Subtype, std::string Desc):
|
||||
Bonus::Bonus(BonusDuration::Type Duration, BonusType Type, BonusSource Src, si32 Val, BonusSourceID ID, BonusSubtypeID Subtype, std::string Desc):
|
||||
duration(Duration),
|
||||
type(Type),
|
||||
subtype(Subtype),
|
||||
@ -208,7 +208,7 @@ Bonus::Bonus(BonusDuration::Type Duration, BonusType Type, BonusSource Src, si32
|
||||
targetSourceType = BonusSource::OTHER;
|
||||
}
|
||||
|
||||
Bonus::Bonus(BonusDuration::Type Duration, BonusType Type, BonusSource Src, si32 Val, TBonusSourceID ID, TBonusSubtype Subtype, BonusValueType ValType):
|
||||
Bonus::Bonus(BonusDuration::Type Duration, BonusType Type, BonusSource Src, si32 Val, BonusSourceID ID, BonusSubtypeID Subtype, BonusValueType ValType):
|
||||
duration(Duration),
|
||||
type(Type),
|
||||
subtype(Subtype),
|
||||
|
@ -10,7 +10,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "BonusEnum.h"
|
||||
#include "BonusSubtypeID.h"
|
||||
#include "BonusCustomTypes.h"
|
||||
#include "../constants/VariantIdentifier.h"
|
||||
#include "../constants/EntityIdentifiers.h"
|
||||
|
||||
@ -25,8 +25,8 @@ class IUpdater;
|
||||
class BonusList;
|
||||
class CSelector;
|
||||
|
||||
using TBonusSubtype = VariantIdentifier<BonusSubtypeID, SpellID, CreatureID, PrimarySkill, TerrainId, GameResID, SpellSchool>;
|
||||
using TBonusSourceID = VariantIdentifier<BonusSourceID, SpellID, CreatureID, ArtifactID, CampaignScenarioID, SecondarySkill, HeroTypeID, Obj, ObjectInstanceID, BuildingTypeUniqueID, BattleField>;
|
||||
using BonusSubtypeID = VariantIdentifier<BonusCustomSubtype, SpellID, CreatureID, PrimarySkill, TerrainId, GameResID, SpellSchool>;
|
||||
using BonusSourceID = VariantIdentifier<BonusCustomSource, SpellID, CreatureID, ArtifactID, CampaignScenarioID, SecondarySkill, HeroTypeID, Obj, ObjectInstanceID, BuildingTypeUniqueID, BattleField>;
|
||||
using TBonusListPtr = std::shared_ptr<BonusList>;
|
||||
using TConstBonusListPtr = std::shared_ptr<const BonusList>;
|
||||
using TLimiterPtr = std::shared_ptr<ILimiter>;
|
||||
@ -60,12 +60,12 @@ struct DLL_LINKAGE Bonus : public std::enable_shared_from_this<Bonus>
|
||||
si16 turnsRemain = 0; //used if duration is N_TURNS, N_DAYS or ONE_WEEK
|
||||
|
||||
BonusType type = BonusType::NONE; //uses BonusType values - says to what is this bonus - 1 byte
|
||||
TBonusSubtype subtype;
|
||||
BonusSubtypeID subtype;
|
||||
|
||||
BonusSource source = BonusSource::OTHER; //source type" uses BonusSource values - what gave that bonus
|
||||
BonusSource targetSourceType;//Bonuses of what origin this amplifies, uses BonusSource values. Needed for PERCENT_TO_TARGET_TYPE.
|
||||
si32 val = 0;
|
||||
TBonusSourceID sid; //source id: id of object/artifact/spell
|
||||
BonusSourceID sid; //source id: id of object/artifact/spell
|
||||
BonusValueType valType = BonusValueType::ADDITIVE_VALUE;
|
||||
std::string stacking; // bonuses with the same stacking value don't stack (e.g. Angel/Archangel morale bonus)
|
||||
|
||||
@ -79,11 +79,11 @@ struct DLL_LINKAGE Bonus : public std::enable_shared_from_this<Bonus>
|
||||
|
||||
std::string description;
|
||||
|
||||
Bonus(BonusDuration::Type Duration, BonusType Type, BonusSource Src, si32 Val, TBonusSourceID sourceID);
|
||||
Bonus(BonusDuration::Type Duration, BonusType Type, BonusSource Src, si32 Val, TBonusSourceID sourceID, std::string Desc);
|
||||
Bonus(BonusDuration::Type Duration, BonusType Type, BonusSource Src, si32 Val, TBonusSourceID sourceID, TBonusSubtype subtype);
|
||||
Bonus(BonusDuration::Type Duration, BonusType Type, BonusSource Src, si32 Val, TBonusSourceID sourceID, TBonusSubtype subtype, std::string Desc);
|
||||
Bonus(BonusDuration::Type Duration, BonusType Type, BonusSource Src, si32 Val, TBonusSourceID sourceID, TBonusSubtype subtype, BonusValueType ValType);
|
||||
Bonus(BonusDuration::Type Duration, BonusType Type, BonusSource Src, si32 Val, BonusSourceID sourceID);
|
||||
Bonus(BonusDuration::Type Duration, BonusType Type, BonusSource Src, si32 Val, BonusSourceID sourceID, std::string Desc);
|
||||
Bonus(BonusDuration::Type Duration, BonusType Type, BonusSource Src, si32 Val, BonusSourceID sourceID, BonusSubtypeID subtype);
|
||||
Bonus(BonusDuration::Type Duration, BonusType Type, BonusSource Src, si32 Val, BonusSourceID sourceID, BonusSubtypeID subtype, std::string Desc);
|
||||
Bonus(BonusDuration::Type Duration, BonusType Type, BonusSource Src, si32 Val, BonusSourceID sourceID, BonusSubtypeID subtype, BonusValueType ValType);
|
||||
Bonus() = default;
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
|
74
lib/bonuses/BonusCustomTypes.cpp
Normal file
74
lib/bonuses/BonusCustomTypes.cpp
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* BonusCustomTypes.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"
|
||||
#include "BonusCustomTypes.h"
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
const BonusCustomSubtype BonusCustomSubtype::creatureDamageBoth(0);
|
||||
const BonusCustomSubtype BonusCustomSubtype::creatureDamageMin(1);
|
||||
const BonusCustomSubtype BonusCustomSubtype::creatureDamageMax(2);
|
||||
const BonusCustomSubtype BonusCustomSubtype::damageTypeAll(-1);
|
||||
const BonusCustomSubtype BonusCustomSubtype::damageTypeMelee(0);
|
||||
const BonusCustomSubtype BonusCustomSubtype::damageTypeRanged(1);
|
||||
const BonusCustomSubtype BonusCustomSubtype::heroMovementLand(1);
|
||||
const BonusCustomSubtype BonusCustomSubtype::heroMovementSea(0);
|
||||
const BonusCustomSubtype BonusCustomSubtype::deathStareGorgon(0);
|
||||
const BonusCustomSubtype BonusCustomSubtype::deathStareCommander(1);
|
||||
const BonusCustomSubtype BonusCustomSubtype::rebirthRegular(0);
|
||||
const BonusCustomSubtype BonusCustomSubtype::rebirthSpecial(1);
|
||||
const BonusCustomSubtype BonusCustomSubtype::visionsMonsters(0);
|
||||
const BonusCustomSubtype BonusCustomSubtype::visionsHeroes(1);
|
||||
const BonusCustomSubtype BonusCustomSubtype::visionsTowns(2);
|
||||
const BonusCustomSubtype BonusCustomSubtype::immunityBattleWide(0);
|
||||
const BonusCustomSubtype BonusCustomSubtype::immunityEnemyHero(1);
|
||||
const BonusCustomSubtype BonusCustomSubtype::transmutationPerHealth(0);
|
||||
const BonusCustomSubtype BonusCustomSubtype::transmutationPerUnit(1);
|
||||
const BonusCustomSubtype BonusCustomSubtype::destructionKillPercentage(0);
|
||||
const BonusCustomSubtype BonusCustomSubtype::destructionKillAmount(1);
|
||||
const BonusCustomSubtype BonusCustomSubtype::soulStealPermanent(0);
|
||||
const BonusCustomSubtype BonusCustomSubtype::soulStealBattle(1);
|
||||
const BonusCustomSubtype BonusCustomSubtype::movementFlying(0);
|
||||
const BonusCustomSubtype BonusCustomSubtype::movementTeleporting(1);
|
||||
|
||||
const BonusCustomSource BonusCustomSource::undeadMoraleDebuff(-2);
|
||||
|
||||
BonusCustomSubtype BonusCustomSubtype::spellLevel(int level)
|
||||
{
|
||||
return BonusCustomSubtype(level);
|
||||
}
|
||||
|
||||
BonusCustomSubtype BonusCustomSubtype::creatureLevel(int level)
|
||||
{
|
||||
return BonusCustomSubtype(level);
|
||||
}
|
||||
|
||||
si32 BonusCustomSubtype::decode(const std::string & identifier)
|
||||
{
|
||||
return std::stoi(identifier);
|
||||
}
|
||||
|
||||
std::string BonusCustomSubtype::encode(const si32 index)
|
||||
{
|
||||
return std::to_string(index);
|
||||
}
|
||||
|
||||
si32 BonusCustomSource::decode(const std::string & identifier)
|
||||
{
|
||||
return std::stoi(identifier);
|
||||
}
|
||||
|
||||
std::string BonusCustomSource::encode(const si32 index)
|
||||
{
|
||||
return std::to_string(index);
|
||||
}
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
75
lib/bonuses/BonusCustomTypes.h
Normal file
75
lib/bonuses/BonusCustomTypes.h
Normal file
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* BonusCustomTypes.h, 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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "../constants/EntityIdentifiers.h"
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
class DLL_LINKAGE BonusCustomSource : public Identifier<BonusCustomSource>
|
||||
{
|
||||
public:
|
||||
using Identifier<BonusCustomSource>::Identifier;
|
||||
|
||||
static std::string encode(int32_t index);
|
||||
static si32 decode(const std::string & identifier);
|
||||
|
||||
static const BonusCustomSource undeadMoraleDebuff; // -2
|
||||
};
|
||||
|
||||
class DLL_LINKAGE BonusCustomSubtype : public Identifier<BonusCustomSubtype>
|
||||
{
|
||||
public:
|
||||
using Identifier<BonusCustomSubtype>::Identifier;
|
||||
|
||||
static std::string encode(int32_t index);
|
||||
static si32 decode(const std::string & identifier);
|
||||
|
||||
static const BonusCustomSubtype creatureDamageBoth; // 0
|
||||
static const BonusCustomSubtype creatureDamageMin; // 1
|
||||
static const BonusCustomSubtype creatureDamageMax; // 2
|
||||
|
||||
static const BonusCustomSubtype damageTypeAll; // -1
|
||||
static const BonusCustomSubtype damageTypeMelee; // 0
|
||||
static const BonusCustomSubtype damageTypeRanged; // 1
|
||||
|
||||
static const BonusCustomSubtype heroMovementLand; // 1
|
||||
static const BonusCustomSubtype heroMovementSea; // 0
|
||||
|
||||
static const BonusCustomSubtype deathStareGorgon; // 0
|
||||
static const BonusCustomSubtype deathStareCommander;
|
||||
|
||||
static const BonusCustomSubtype rebirthRegular; // 0
|
||||
static const BonusCustomSubtype rebirthSpecial; // 1
|
||||
|
||||
static const BonusCustomSubtype visionsMonsters; // 0
|
||||
static const BonusCustomSubtype visionsHeroes; // 1
|
||||
static const BonusCustomSubtype visionsTowns; // 2
|
||||
|
||||
static const BonusCustomSubtype immunityBattleWide; // 0
|
||||
static const BonusCustomSubtype immunityEnemyHero; // 1
|
||||
|
||||
static const BonusCustomSubtype transmutationPerHealth; // 0
|
||||
static const BonusCustomSubtype transmutationPerUnit; // 1
|
||||
|
||||
static const BonusCustomSubtype destructionKillPercentage; // 0
|
||||
static const BonusCustomSubtype destructionKillAmount; // 1
|
||||
|
||||
static const BonusCustomSubtype soulStealPermanent; // 0
|
||||
static const BonusCustomSubtype soulStealBattle; // 1
|
||||
|
||||
static const BonusCustomSubtype movementFlying; // 0
|
||||
static const BonusCustomSubtype movementTeleporting; // 1
|
||||
|
||||
static BonusCustomSubtype spellLevel(int level);
|
||||
static BonusCustomSubtype creatureLevel(int level);
|
||||
};
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
@ -84,66 +84,66 @@ BonusParams::BonusParams(std::string deprecatedTypeStr, std::string deprecatedSu
|
||||
else if(deprecatedSubtype == SecondarySkill::SORCERY || deprecatedSubtypeStr == "skill.sorcery")
|
||||
{
|
||||
type = BonusType::SPELL_DAMAGE;
|
||||
subtype = TBonusSubtype(SpellSchool::ANY);
|
||||
subtype = BonusSubtypeID(SpellSchool::ANY);
|
||||
}
|
||||
else if(deprecatedSubtype == SecondarySkill::SCHOLAR || deprecatedSubtypeStr == "skill.scholar")
|
||||
type = BonusType::LEARN_MEETING_SPELL_LIMIT;
|
||||
else if(deprecatedSubtype == SecondarySkill::ARCHERY|| deprecatedSubtypeStr == "skill.archery")
|
||||
{
|
||||
subtype = BonusSubtypeID::damageTypeRanged;
|
||||
subtype = BonusCustomSubtype::damageTypeRanged;
|
||||
type = BonusType::PERCENTAGE_DAMAGE_BOOST;
|
||||
}
|
||||
else if(deprecatedSubtype == SecondarySkill::OFFENCE || deprecatedSubtypeStr == "skill.offence")
|
||||
{
|
||||
subtype = BonusSubtypeID::damageTypeMelee;
|
||||
subtype = BonusCustomSubtype::damageTypeMelee;
|
||||
type = BonusType::PERCENTAGE_DAMAGE_BOOST;
|
||||
}
|
||||
else if(deprecatedSubtype == SecondarySkill::ARMORER || deprecatedSubtypeStr == "skill.armorer")
|
||||
{
|
||||
subtype = BonusSubtypeID::damageTypeAll;
|
||||
subtype = BonusCustomSubtype::damageTypeAll;
|
||||
type = BonusType::GENERAL_DAMAGE_REDUCTION;
|
||||
}
|
||||
else if(deprecatedSubtype == SecondarySkill::NAVIGATION || deprecatedSubtypeStr == "skill.navigation")
|
||||
{
|
||||
subtype = BonusSubtypeID::heroMovementSea;
|
||||
subtype = BonusCustomSubtype::heroMovementSea;
|
||||
valueType = BonusValueType::PERCENT_TO_BASE;
|
||||
type = BonusType::MOVEMENT;
|
||||
}
|
||||
else if(deprecatedSubtype == SecondarySkill::LOGISTICS || deprecatedSubtypeStr == "skill.logistics")
|
||||
{
|
||||
subtype = BonusSubtypeID::heroMovementLand;
|
||||
subtype = BonusCustomSubtype::heroMovementLand;
|
||||
valueType = BonusValueType::PERCENT_TO_BASE;
|
||||
type = BonusType::MOVEMENT;
|
||||
}
|
||||
else if(deprecatedSubtype == SecondarySkill::ESTATES || deprecatedSubtypeStr == "skill.estates")
|
||||
{
|
||||
type = BonusType::GENERATE_RESOURCE;
|
||||
subtype = TBonusSubtype(GameResID(EGameResID::GOLD));
|
||||
subtype = BonusSubtypeID(GameResID(EGameResID::GOLD));
|
||||
}
|
||||
else if(deprecatedSubtype == SecondarySkill::AIR_MAGIC || deprecatedSubtypeStr == "skill.airMagic")
|
||||
{
|
||||
type = BonusType::MAGIC_SCHOOL_SKILL;
|
||||
subtype = TBonusSubtype(SpellSchool::AIR);
|
||||
subtype = BonusSubtypeID(SpellSchool::AIR);
|
||||
}
|
||||
else if(deprecatedSubtype == SecondarySkill::WATER_MAGIC || deprecatedSubtypeStr == "skill.waterMagic")
|
||||
{
|
||||
type = BonusType::MAGIC_SCHOOL_SKILL;
|
||||
subtype = TBonusSubtype(SpellSchool::WATER);
|
||||
subtype = BonusSubtypeID(SpellSchool::WATER);
|
||||
}
|
||||
else if(deprecatedSubtype == SecondarySkill::FIRE_MAGIC || deprecatedSubtypeStr == "skill.fireMagic")
|
||||
{
|
||||
type = BonusType::MAGIC_SCHOOL_SKILL;
|
||||
subtype = TBonusSubtype(SpellSchool::FIRE);
|
||||
subtype = BonusSubtypeID(SpellSchool::FIRE);
|
||||
}
|
||||
else if(deprecatedSubtype == SecondarySkill::EARTH_MAGIC || deprecatedSubtypeStr == "skill.earthMagic")
|
||||
{
|
||||
type = BonusType::MAGIC_SCHOOL_SKILL;
|
||||
subtype = TBonusSubtype(SpellSchool::EARTH);
|
||||
subtype = BonusSubtypeID(SpellSchool::EARTH);
|
||||
}
|
||||
else if (deprecatedSubtype == SecondarySkill::ARTILLERY || deprecatedSubtypeStr == "skill.artillery")
|
||||
{
|
||||
type = BonusType::BONUS_DAMAGE_CHANCE;
|
||||
subtype = TBonusSubtype(CreatureID(CreatureID::BALLISTA));
|
||||
subtype = BonusSubtypeID(CreatureID(CreatureID::BALLISTA));
|
||||
}
|
||||
else if (deprecatedSubtype == SecondarySkill::FIRST_AID || deprecatedSubtypeStr == "skill.firstAid")
|
||||
{
|
||||
@ -165,20 +165,20 @@ BonusParams::BonusParams(std::string deprecatedTypeStr, std::string deprecatedSu
|
||||
else if (deprecatedSubtype == SecondarySkill::ARTILLERY || deprecatedSubtypeStr == "skill.artillery")
|
||||
{
|
||||
type = BonusType::HERO_GRANTS_ATTACKS;
|
||||
subtype = TBonusSubtype(CreatureID(CreatureID::BALLISTA));
|
||||
subtype = BonusSubtypeID(CreatureID(CreatureID::BALLISTA));
|
||||
}
|
||||
else
|
||||
isConverted = false;
|
||||
}
|
||||
else if (deprecatedTypeStr == "SEA_MOVEMENT")
|
||||
{
|
||||
subtype = BonusSubtypeID::heroMovementSea;
|
||||
subtype = BonusCustomSubtype::heroMovementSea;
|
||||
valueType = BonusValueType::ADDITIVE_VALUE;
|
||||
type = BonusType::MOVEMENT;
|
||||
}
|
||||
else if (deprecatedTypeStr == "LAND_MOVEMENT")
|
||||
{
|
||||
subtype = BonusSubtypeID::heroMovementLand;
|
||||
subtype = BonusCustomSubtype::heroMovementLand;
|
||||
valueType = BonusValueType::ADDITIVE_VALUE;
|
||||
type = BonusType::MOVEMENT;
|
||||
}
|
||||
@ -226,52 +226,52 @@ BonusParams::BonusParams(std::string deprecatedTypeStr, std::string deprecatedSu
|
||||
else if (deprecatedTypeStr == "DIRECT_DAMAGE_IMMUNITY")
|
||||
{
|
||||
type = BonusType::SPELL_DAMAGE_REDUCTION;
|
||||
subtype = TBonusSubtype(SpellSchool::ANY);
|
||||
subtype = BonusSubtypeID(SpellSchool::ANY);
|
||||
val = 100;
|
||||
}
|
||||
else if (deprecatedTypeStr == "AIR_SPELL_DMG_PREMY")
|
||||
{
|
||||
type = BonusType::SPELL_DAMAGE;
|
||||
subtype = TBonusSubtype(SpellSchool::AIR);
|
||||
subtype = BonusSubtypeID(SpellSchool::AIR);
|
||||
}
|
||||
else if (deprecatedTypeStr == "FIRE_SPELL_DMG_PREMY")
|
||||
{
|
||||
type = BonusType::SPELL_DAMAGE;
|
||||
subtype = TBonusSubtype(SpellSchool::FIRE);
|
||||
subtype = BonusSubtypeID(SpellSchool::FIRE);
|
||||
}
|
||||
else if (deprecatedTypeStr == "WATER_SPELL_DMG_PREMY")
|
||||
{
|
||||
type = BonusType::SPELL_DAMAGE;
|
||||
subtype = TBonusSubtype(SpellSchool::WATER);
|
||||
subtype = BonusSubtypeID(SpellSchool::WATER);
|
||||
}
|
||||
else if (deprecatedTypeStr == "EARTH_SPELL_DMG_PREMY")
|
||||
{
|
||||
type = BonusType::SPELL_DAMAGE;
|
||||
subtype = TBonusSubtype(SpellSchool::EARTH);
|
||||
subtype = BonusSubtypeID(SpellSchool::EARTH);
|
||||
}
|
||||
else if (deprecatedTypeStr == "AIR_SPELLS")
|
||||
{
|
||||
type = BonusType::SPELLS_OF_SCHOOL;
|
||||
subtype = TBonusSubtype(SpellSchool::AIR);
|
||||
subtype = BonusSubtypeID(SpellSchool::AIR);
|
||||
}
|
||||
else if (deprecatedTypeStr == "FIRE_SPELLS")
|
||||
{
|
||||
type = BonusType::SPELLS_OF_SCHOOL;
|
||||
subtype = TBonusSubtype(SpellSchool::FIRE);
|
||||
subtype = BonusSubtypeID(SpellSchool::FIRE);
|
||||
}
|
||||
else if (deprecatedTypeStr == "WATER_SPELLS")
|
||||
{
|
||||
type = BonusType::SPELLS_OF_SCHOOL;
|
||||
subtype = TBonusSubtype(SpellSchool::WATER);
|
||||
subtype = BonusSubtypeID(SpellSchool::WATER);
|
||||
}
|
||||
else if (deprecatedTypeStr == "EARTH_SPELLS")
|
||||
{
|
||||
type = BonusType::SPELLS_OF_SCHOOL;
|
||||
subtype = TBonusSubtype(SpellSchool::EARTH);
|
||||
subtype = BonusSubtypeID(SpellSchool::EARTH);
|
||||
}
|
||||
else if (deprecatedTypeStr == "AIR_IMMUNITY")
|
||||
{
|
||||
subtype = TBonusSubtype(SpellSchool::AIR);
|
||||
subtype = BonusSubtypeID(SpellSchool::AIR);
|
||||
switch(deprecatedSubtype)
|
||||
{
|
||||
case 0:
|
||||
@ -287,7 +287,7 @@ BonusParams::BonusParams(std::string deprecatedTypeStr, std::string deprecatedSu
|
||||
}
|
||||
else if (deprecatedTypeStr == "FIRE_IMMUNITY")
|
||||
{
|
||||
subtype = TBonusSubtype(SpellSchool::FIRE);
|
||||
subtype = BonusSubtypeID(SpellSchool::FIRE);
|
||||
switch(deprecatedSubtype)
|
||||
{
|
||||
case 0:
|
||||
@ -303,7 +303,7 @@ BonusParams::BonusParams(std::string deprecatedTypeStr, std::string deprecatedSu
|
||||
}
|
||||
else if (deprecatedTypeStr == "WATER_IMMUNITY")
|
||||
{
|
||||
subtype = TBonusSubtype(SpellSchool::WATER);
|
||||
subtype = BonusSubtypeID(SpellSchool::WATER);
|
||||
switch(deprecatedSubtype)
|
||||
{
|
||||
case 0:
|
||||
@ -319,7 +319,7 @@ BonusParams::BonusParams(std::string deprecatedTypeStr, std::string deprecatedSu
|
||||
}
|
||||
else if (deprecatedTypeStr == "EARTH_IMMUNITY")
|
||||
{
|
||||
subtype = TBonusSubtype(SpellSchool::EARTH);
|
||||
subtype = BonusSubtypeID(SpellSchool::EARTH);
|
||||
switch(deprecatedSubtype)
|
||||
{
|
||||
case 0:
|
||||
|
@ -19,7 +19,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
||||
struct DLL_LINKAGE BonusParams {
|
||||
bool isConverted;
|
||||
BonusType type = BonusType::NONE;
|
||||
std::optional<TBonusSubtype> subtype = std::nullopt;
|
||||
std::optional<BonusSubtypeID> subtype = std::nullopt;
|
||||
std::optional<BonusValueType> valueType = std::nullopt;
|
||||
std::optional<si32> val = std::nullopt;
|
||||
std::optional<BonusSource> targetType = std::nullopt;
|
||||
|
@ -21,9 +21,9 @@ namespace Selector
|
||||
return stype;
|
||||
}
|
||||
|
||||
DLL_LINKAGE CSelectFieldEqual<TBonusSubtype> & subtype()
|
||||
DLL_LINKAGE CSelectFieldEqual<BonusSubtypeID> & subtype()
|
||||
{
|
||||
static CSelectFieldEqual<TBonusSubtype> ssubtype(&Bonus::subtype);
|
||||
static CSelectFieldEqual<BonusSubtypeID> ssubtype(&Bonus::subtype);
|
||||
return ssubtype;
|
||||
}
|
||||
|
||||
@ -54,22 +54,22 @@ namespace Selector
|
||||
DLL_LINKAGE CWillLastTurns turns;
|
||||
DLL_LINKAGE CWillLastDays days;
|
||||
|
||||
CSelector DLL_LINKAGE typeSubtype(BonusType Type, TBonusSubtype Subtype)
|
||||
CSelector DLL_LINKAGE typeSubtype(BonusType Type, BonusSubtypeID Subtype)
|
||||
{
|
||||
return type()(Type).And(subtype()(Subtype));
|
||||
}
|
||||
|
||||
CSelector DLL_LINKAGE typeSubtypeInfo(BonusType type, TBonusSubtype subtype, const CAddInfo & info)
|
||||
CSelector DLL_LINKAGE typeSubtypeInfo(BonusType type, BonusSubtypeID subtype, const CAddInfo & info)
|
||||
{
|
||||
return CSelectFieldEqual<BonusType>(&Bonus::type)(type)
|
||||
.And(CSelectFieldEqual<TBonusSubtype>(&Bonus::subtype)(subtype))
|
||||
.And(CSelectFieldEqual<BonusSubtypeID>(&Bonus::subtype)(subtype))
|
||||
.And(CSelectFieldEqual<CAddInfo>(&Bonus::additionalInfo)(info));
|
||||
}
|
||||
|
||||
CSelector DLL_LINKAGE source(BonusSource source, TBonusSourceID sourceID)
|
||||
CSelector DLL_LINKAGE source(BonusSource source, BonusSourceID sourceID)
|
||||
{
|
||||
return CSelectFieldEqual<BonusSource>(&Bonus::source)(source)
|
||||
.And(CSelectFieldEqual<TBonusSourceID>(&Bonus::sid)(sourceID));
|
||||
.And(CSelectFieldEqual<BonusSourceID>(&Bonus::sid)(sourceID));
|
||||
}
|
||||
|
||||
CSelector DLL_LINKAGE sourceTypeSel(BonusSource source)
|
||||
|
@ -126,7 +126,7 @@ public:
|
||||
namespace Selector
|
||||
{
|
||||
extern DLL_LINKAGE CSelectFieldEqual<BonusType> & type();
|
||||
extern DLL_LINKAGE CSelectFieldEqual<TBonusSubtype> & subtype();
|
||||
extern DLL_LINKAGE CSelectFieldEqual<BonusSubtypeID> & subtype();
|
||||
extern DLL_LINKAGE CSelectFieldEqual<CAddInfo> & info();
|
||||
extern DLL_LINKAGE CSelectFieldEqual<BonusSource> & sourceType();
|
||||
extern DLL_LINKAGE CSelectFieldEqual<BonusSource> & targetSourceType();
|
||||
@ -134,9 +134,9 @@ namespace Selector
|
||||
extern DLL_LINKAGE CWillLastTurns turns;
|
||||
extern DLL_LINKAGE CWillLastDays days;
|
||||
|
||||
CSelector DLL_LINKAGE typeSubtype(BonusType Type, TBonusSubtype Subtype);
|
||||
CSelector DLL_LINKAGE typeSubtypeInfo(BonusType type, TBonusSubtype subtype, const CAddInfo & info);
|
||||
CSelector DLL_LINKAGE source(BonusSource source, TBonusSourceID sourceID);
|
||||
CSelector DLL_LINKAGE typeSubtype(BonusType Type, BonusSubtypeID Subtype);
|
||||
CSelector DLL_LINKAGE typeSubtypeInfo(BonusType type, BonusSubtypeID subtype, const CAddInfo & info);
|
||||
CSelector DLL_LINKAGE source(BonusSource source, BonusSourceID sourceID);
|
||||
CSelector DLL_LINKAGE sourceTypeSel(BonusSource source);
|
||||
CSelector DLL_LINKAGE valueType(BonusValueType valType);
|
||||
|
||||
|
@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Bonus.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"
|
||||
#include "BonusSubtypeID.h"
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
const BonusSubtypeID BonusSubtypeID::creatureDamageBoth(0);
|
||||
const BonusSubtypeID BonusSubtypeID::creatureDamageMin(1);
|
||||
const BonusSubtypeID BonusSubtypeID::creatureDamageMax(2);
|
||||
const BonusSubtypeID BonusSubtypeID::damageTypeAll(-1);
|
||||
const BonusSubtypeID BonusSubtypeID::damageTypeMelee(0);
|
||||
const BonusSubtypeID BonusSubtypeID::damageTypeRanged(1);
|
||||
const BonusSubtypeID BonusSubtypeID::heroMovementLand(1);
|
||||
const BonusSubtypeID BonusSubtypeID::heroMovementSea(0);
|
||||
const BonusSubtypeID BonusSubtypeID::deathStareGorgon(0);
|
||||
const BonusSubtypeID BonusSubtypeID::deathStareCommander(1);
|
||||
const BonusSubtypeID BonusSubtypeID::rebirthRegular(0);
|
||||
const BonusSubtypeID BonusSubtypeID::rebirthSpecial(1);
|
||||
const BonusSubtypeID BonusSubtypeID::visionsMonsters(0);
|
||||
const BonusSubtypeID BonusSubtypeID::visionsHeroes(1);
|
||||
const BonusSubtypeID BonusSubtypeID::visionsTowns(2);
|
||||
const BonusSubtypeID BonusSubtypeID::immunityBattleWide(0);
|
||||
const BonusSubtypeID BonusSubtypeID::immunityEnemyHero(1);
|
||||
const BonusSubtypeID BonusSubtypeID::transmutationPerHealth(0);
|
||||
const BonusSubtypeID BonusSubtypeID::transmutationPerUnit(1);
|
||||
const BonusSubtypeID BonusSubtypeID::destructionKillPercentage(0);
|
||||
const BonusSubtypeID BonusSubtypeID::destructionKillAmount(1);
|
||||
const BonusSubtypeID BonusSubtypeID::soulStealPermanent(0);
|
||||
const BonusSubtypeID BonusSubtypeID::soulStealBattle(1);
|
||||
const BonusSubtypeID BonusSubtypeID::movementFlying(0);
|
||||
const BonusSubtypeID BonusSubtypeID::movementTeleporting(1);
|
||||
|
||||
const BonusSourceID BonusSourceID::undeadMoraleDebuff(-2);
|
||||
|
||||
BonusSubtypeID BonusSubtypeID::spellLevel(int level)
|
||||
{
|
||||
return BonusSubtypeID(level);
|
||||
}
|
||||
|
||||
BonusSubtypeID BonusSubtypeID::creatureLevel(int level)
|
||||
{
|
||||
return BonusSubtypeID(level);
|
||||
}
|
||||
|
||||
si32 BonusSubtypeID::decode(const std::string & identifier)
|
||||
{
|
||||
return std::stoi(identifier);
|
||||
}
|
||||
|
||||
std::string BonusSubtypeID::encode(const si32 index)
|
||||
{
|
||||
return std::to_string(index);
|
||||
}
|
||||
|
||||
si32 BonusSourceID::decode(const std::string & identifier)
|
||||
{
|
||||
return std::stoi(identifier);
|
||||
}
|
||||
|
||||
std::string BonusSourceID::encode(const si32 index)
|
||||
{
|
||||
return std::to_string(index);
|
||||
}
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
@ -1,75 +0,0 @@
|
||||
/*
|
||||
* BonusSubtypeID.h, 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
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "../constants/EntityIdentifiers.h"
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
class DLL_LINKAGE BonusSourceID : public Identifier<BonusSourceID>
|
||||
{
|
||||
public:
|
||||
using Identifier<BonusSourceID>::Identifier;
|
||||
|
||||
static std::string encode(int32_t index);
|
||||
static si32 decode(const std::string & identifier);
|
||||
|
||||
static const BonusSourceID undeadMoraleDebuff; // -2
|
||||
};
|
||||
|
||||
class DLL_LINKAGE BonusSubtypeID : public Identifier<BonusSubtypeID>
|
||||
{
|
||||
public:
|
||||
using Identifier<BonusSubtypeID>::Identifier;
|
||||
|
||||
static std::string encode(int32_t index);
|
||||
static si32 decode(const std::string & identifier);
|
||||
|
||||
static const BonusSubtypeID creatureDamageBoth; // 0
|
||||
static const BonusSubtypeID creatureDamageMin; // 1
|
||||
static const BonusSubtypeID creatureDamageMax; // 2
|
||||
|
||||
static const BonusSubtypeID damageTypeAll; // -1
|
||||
static const BonusSubtypeID damageTypeMelee; // 0
|
||||
static const BonusSubtypeID damageTypeRanged; // 1
|
||||
|
||||
static const BonusSubtypeID heroMovementLand; // 1
|
||||
static const BonusSubtypeID heroMovementSea; // 0
|
||||
|
||||
static const BonusSubtypeID deathStareGorgon; // 0
|
||||
static const BonusSubtypeID deathStareCommander;
|
||||
|
||||
static const BonusSubtypeID rebirthRegular; // 0
|
||||
static const BonusSubtypeID rebirthSpecial; // 1
|
||||
|
||||
static const BonusSubtypeID visionsMonsters; // 0
|
||||
static const BonusSubtypeID visionsHeroes; // 1
|
||||
static const BonusSubtypeID visionsTowns; // 2
|
||||
|
||||
static const BonusSubtypeID immunityBattleWide; // 0
|
||||
static const BonusSubtypeID immunityEnemyHero; // 1
|
||||
|
||||
static const BonusSubtypeID transmutationPerHealth; // 0
|
||||
static const BonusSubtypeID transmutationPerUnit; // 1
|
||||
|
||||
static const BonusSubtypeID destructionKillPercentage; // 0
|
||||
static const BonusSubtypeID destructionKillAmount; // 1
|
||||
|
||||
static const BonusSubtypeID soulStealPermanent; // 0
|
||||
static const BonusSubtypeID soulStealBattle; // 1
|
||||
|
||||
static const BonusSubtypeID movementFlying; // 0
|
||||
static const BonusSubtypeID movementTeleporting; // 1
|
||||
|
||||
static BonusSubtypeID spellLevel(int level);
|
||||
static BonusSubtypeID creatureLevel(int level);
|
||||
};
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
@ -62,7 +62,7 @@ bool IBonusBearer::hasBonusOfType(BonusType type) const
|
||||
return hasBonus(s, cachingStr);
|
||||
}
|
||||
|
||||
int IBonusBearer::valOfBonuses(BonusType type, TBonusSubtype subtype) const
|
||||
int IBonusBearer::valOfBonuses(BonusType type, BonusSubtypeID subtype) const
|
||||
{
|
||||
//This part is performance-critical
|
||||
std::string cachingStr = "type_" + std::to_string(static_cast<int>(type)) + "_" + subtype.toString();
|
||||
@ -72,7 +72,7 @@ int IBonusBearer::valOfBonuses(BonusType type, TBonusSubtype subtype) const
|
||||
return valOfBonuses(s, cachingStr);
|
||||
}
|
||||
|
||||
bool IBonusBearer::hasBonusOfType(BonusType type, TBonusSubtype subtype) const
|
||||
bool IBonusBearer::hasBonusOfType(BonusType type, BonusSubtypeID subtype) const
|
||||
{
|
||||
//This part is performance-critical
|
||||
std::string cachingStr = "type_" + std::to_string(static_cast<int>(type)) + "_" + subtype.toString();
|
||||
@ -82,7 +82,7 @@ bool IBonusBearer::hasBonusOfType(BonusType type, TBonusSubtype subtype) const
|
||||
return hasBonus(s, cachingStr);
|
||||
}
|
||||
|
||||
bool IBonusBearer::hasBonusFrom(BonusSource source, TBonusSourceID sourceID) const
|
||||
bool IBonusBearer::hasBonusFrom(BonusSource source, BonusSourceID sourceID) const
|
||||
{
|
||||
boost::format fmt("source_%did_%s");
|
||||
fmt % static_cast<int>(source) % sourceID.toString();
|
||||
|
@ -35,9 +35,9 @@ public:
|
||||
//Optimized interface (with auto-caching)
|
||||
int valOfBonuses(BonusType type) const; //subtype -> subtype of bonus;
|
||||
bool hasBonusOfType(BonusType type) const;//determines if hero has a bonus of given type (and optionally subtype)
|
||||
int valOfBonuses(BonusType type, TBonusSubtype subtype) const; //subtype -> subtype of bonus;
|
||||
bool hasBonusOfType(BonusType type, TBonusSubtype subtype) const;//determines if hero has a bonus of given type (and optionally subtype)
|
||||
bool hasBonusFrom(BonusSource source, TBonusSourceID sourceID) const;
|
||||
int valOfBonuses(BonusType type, BonusSubtypeID subtype) const; //subtype -> subtype of bonus;
|
||||
bool hasBonusOfType(BonusType type, BonusSubtypeID subtype) const;//determines if hero has a bonus of given type (and optionally subtype)
|
||||
bool hasBonusFrom(BonusSource source, BonusSourceID sourceID) const;
|
||||
|
||||
virtual int64_t getTreeVersion() const = 0;
|
||||
};
|
||||
|
@ -140,7 +140,7 @@ HasAnotherBonusLimiter::HasAnotherBonusLimiter( BonusType bonus )
|
||||
{
|
||||
}
|
||||
|
||||
HasAnotherBonusLimiter::HasAnotherBonusLimiter( BonusType bonus, TBonusSubtype _subtype )
|
||||
HasAnotherBonusLimiter::HasAnotherBonusLimiter( BonusType bonus, BonusSubtypeID _subtype )
|
||||
: type(bonus), subtype(_subtype), isSubtypeRelevant(true), isSourceRelevant(false), isSourceIDRelevant(false)
|
||||
{
|
||||
}
|
||||
@ -150,7 +150,7 @@ HasAnotherBonusLimiter::HasAnotherBonusLimiter(BonusType bonus, BonusSource src)
|
||||
{
|
||||
}
|
||||
|
||||
HasAnotherBonusLimiter::HasAnotherBonusLimiter(BonusType bonus, TBonusSubtype _subtype, BonusSource src)
|
||||
HasAnotherBonusLimiter::HasAnotherBonusLimiter(BonusType bonus, BonusSubtypeID _subtype, BonusSource src)
|
||||
: type(bonus), subtype(_subtype), isSubtypeRelevant(true), source(src), isSourceRelevant(true), isSourceIDRelevant(false)
|
||||
{
|
||||
}
|
||||
|
@ -116,17 +116,17 @@ class DLL_LINKAGE HasAnotherBonusLimiter : public ILimiter //applies only to nod
|
||||
{
|
||||
public:
|
||||
BonusType type;
|
||||
TBonusSubtype subtype;
|
||||
BonusSubtypeID subtype;
|
||||
BonusSource source;
|
||||
TBonusSourceID sid;
|
||||
BonusSourceID sid;
|
||||
bool isSubtypeRelevant; //check for subtype only if this is true
|
||||
bool isSourceRelevant; //check for bonus source only if this is true
|
||||
bool isSourceIDRelevant; //check for bonus source only if this is true
|
||||
|
||||
HasAnotherBonusLimiter(BonusType bonus = BonusType::NONE);
|
||||
HasAnotherBonusLimiter(BonusType bonus, TBonusSubtype _subtype);
|
||||
HasAnotherBonusLimiter(BonusType bonus, BonusSubtypeID _subtype);
|
||||
HasAnotherBonusLimiter(BonusType bonus, BonusSource src);
|
||||
HasAnotherBonusLimiter(BonusType bonus, TBonusSubtype _subtype, BonusSource src);
|
||||
HasAnotherBonusLimiter(BonusType bonus, BonusSubtypeID _subtype, BonusSource src);
|
||||
|
||||
EDecision limit(const BonusLimitationContext &context) const override;
|
||||
std::string toString() const override;
|
||||
|
@ -11,8 +11,6 @@
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
#include "../constants/EntityIdentifiers.h"
|
||||
|
||||
enum class CampaignVersion : uint8_t
|
||||
{
|
||||
NONE = 0,
|
||||
|
@ -655,7 +655,7 @@ void CGameState::initGlobalBonuses()
|
||||
{
|
||||
auto bonus = JsonUtils::parseBonus(b.second);
|
||||
bonus->source = BonusSource::GLOBAL;//for all
|
||||
bonus->sid = TBonusSourceID(); //there is one global object
|
||||
bonus->sid = BonusSourceID(); //there is one global object
|
||||
globalEffects.addNewBonus(bonus);
|
||||
}
|
||||
VLC->creh->loadCrExpBon(globalEffects);
|
||||
@ -1871,7 +1871,7 @@ struct statsHLP
|
||||
//Heroes can produce gold as well - skill, specialty or arts
|
||||
for(const auto & h : ps->heroes)
|
||||
{
|
||||
totalIncome += h->valOfBonuses(Selector::typeSubtype(BonusType::GENERATE_RESOURCE, TBonusSubtype(GameResID(GameResID::GOLD))));
|
||||
totalIncome += h->valOfBonuses(Selector::typeSubtype(BonusType::GENERATE_RESOURCE, BonusSubtypeID(GameResID(GameResID::GOLD))));
|
||||
|
||||
if(!heroOrTown)
|
||||
heroOrTown = h;
|
||||
|
@ -87,7 +87,7 @@ void CGameStateCampaign::trimCrossoverHeroesParameters(std::vector<CampaignHeroR
|
||||
for(auto g = PrimarySkill::BEGIN; g < PrimarySkill::END; ++g)
|
||||
{
|
||||
auto sel = Selector::type()(BonusType::PRIMARY_SKILL)
|
||||
.And(Selector::subtype()(TBonusSubtype(g)))
|
||||
.And(Selector::subtype()(BonusSubtypeID(g)))
|
||||
.And(Selector::sourceType()(BonusSource::HERO_BASE_SKILL));
|
||||
|
||||
cgh->getBonusLocalFirst(sel)->val = cgh->type->heroClass->primarySkillInitial[g];
|
||||
@ -315,7 +315,7 @@ void CGameStateCampaign::giveCampaignBonusToHero(CGHeroInstance * hero)
|
||||
continue;
|
||||
|
||||
auto currentScenario = *gameState->scenarioOps->campState->currentScenario();
|
||||
auto bb = std::make_shared<Bonus>( BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::CAMPAIGN_BONUS, val, TBonusSourceID(currentScenario), TBonusSubtype(g) );
|
||||
auto bb = std::make_shared<Bonus>( BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::CAMPAIGN_BONUS, val, BonusSourceID(currentScenario), BonusSubtypeID(g) );
|
||||
hero->addNewBonus(bb);
|
||||
}
|
||||
break;
|
||||
|
@ -50,7 +50,7 @@ void CRewardableConstructor::configureObject(CGObjectInstance * object, CRandomG
|
||||
for (auto & bonus : rewardInfo.reward.bonuses)
|
||||
{
|
||||
bonus.source = BonusSource::OBJECT;
|
||||
bonus.sid = TBonusSourceID(rewardableObject->ID);
|
||||
bonus.sid = BonusSourceID(rewardableObject->ID);
|
||||
}
|
||||
}
|
||||
assert(!rewardableObject->configuration.info.empty());
|
||||
|
@ -59,7 +59,7 @@ void CArmedInstance::updateMoraleBonusFromArmy()
|
||||
auto b = getExportedBonusList().getFirst(Selector::sourceType()(BonusSource::ARMY).And(Selector::type()(BonusType::MORALE)));
|
||||
if(!b)
|
||||
{
|
||||
b = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::MORALE, BonusSource::ARMY, 0, TBonusSourceID());
|
||||
b = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::MORALE, BonusSource::ARMY, 0, BonusSourceID());
|
||||
addNewBonus(b);
|
||||
}
|
||||
|
||||
@ -120,12 +120,12 @@ void CArmedInstance::updateMoraleBonusFromArmy()
|
||||
CBonusSystemNode::treeHasChanged();
|
||||
|
||||
//-1 modifier for any Undead unit in army
|
||||
auto undeadModifier = getExportedBonusList().getFirst(Selector::source(BonusSource::ARMY, BonusSourceID::undeadMoraleDebuff));
|
||||
auto undeadModifier = getExportedBonusList().getFirst(Selector::source(BonusSource::ARMY, BonusCustomSource::undeadMoraleDebuff));
|
||||
if(hasUndead)
|
||||
{
|
||||
if(!undeadModifier)
|
||||
{
|
||||
undeadModifier = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::MORALE, BonusSource::ARMY, -1, BonusSourceID::undeadMoraleDebuff, VLC->generaltexth->arraytxt[116]);
|
||||
undeadModifier = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::MORALE, BonusSource::ARMY, -1, BonusCustomSource::undeadMoraleDebuff, VLC->generaltexth->arraytxt[116]);
|
||||
undeadModifier->description = undeadModifier->description.substr(0, undeadModifier->description.size()-2);//trim value
|
||||
addNewBonus(undeadModifier);
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ void CBank::doVisit(const CGHeroInstance * hero) const
|
||||
gbonus.id = hero->id.getNum();
|
||||
gbonus.bonus.duration = BonusDuration::ONE_BATTLE;
|
||||
gbonus.bonus.source = BonusSource::OBJECT;
|
||||
gbonus.bonus.sid = TBonusSourceID(ID);
|
||||
gbonus.bonus.sid = BonusSourceID(ID);
|
||||
gbonus.bonus.type = BonusType::MORALE;
|
||||
gbonus.bonus.val = -1;
|
||||
switch (ID)
|
||||
@ -239,7 +239,7 @@ void CBank::doVisit(const CGHeroInstance * hero) const
|
||||
case Obj::PYRAMID:
|
||||
{
|
||||
GiveBonus gb;
|
||||
gb.bonus = Bonus(BonusDuration::ONE_BATTLE, BonusType::LUCK, BonusSource::OBJECT, -2, TBonusSourceID(id), VLC->generaltexth->arraytxt[70]);
|
||||
gb.bonus = Bonus(BonusDuration::ONE_BATTLE, BonusType::LUCK, BonusSource::OBJECT, -2, BonusSourceID(id), VLC->generaltexth->arraytxt[70]);
|
||||
gb.id = hero->id.getNum();
|
||||
cb->giveHeroBonus(&gb);
|
||||
textID = 107;
|
||||
|
@ -46,7 +46,7 @@ std::string CGCreature::getHoverText(PlayerColor player) const
|
||||
std::string CGCreature::getHoverText(const CGHeroInstance * hero) const
|
||||
{
|
||||
std::string hoverName;
|
||||
if(hero->hasVisions(this, BonusSubtypeID::visionsMonsters))
|
||||
if(hero->hasVisions(this, BonusCustomSubtype::visionsMonsters))
|
||||
{
|
||||
MetaString ms;
|
||||
ms.appendNumber(stacks.begin()->second->count);
|
||||
|
@ -95,7 +95,7 @@ ui32 CGHeroInstance::getTileMovementCost(const TerrainTile & dest, const Terrain
|
||||
}
|
||||
else if(ti->nativeTerrain != from.terType->getId() &&//the terrain is not native
|
||||
ti->nativeTerrain != ETerrainId::ANY_TERRAIN && //no special creature bonus
|
||||
!ti->hasBonusOfType(BonusType::NO_TERRAIN_PENALTY, TBonusSubtype(from.terType->getId()))) //no special movement bonus
|
||||
!ti->hasBonusOfType(BonusType::NO_TERRAIN_PENALTY, BonusSubtypeID(from.terType->getId()))) //no special movement bonus
|
||||
{
|
||||
|
||||
ret = VLC->terrainTypeHandler->getById(from.terType->getId())->moveCost;
|
||||
@ -249,14 +249,14 @@ void CGHeroInstance::updateArmyMovementBonus(bool onLand, const TurnInfo * ti) c
|
||||
lowestCreatureSpeed = realLowestSpeed;
|
||||
//Let updaters run again
|
||||
treeHasChanged();
|
||||
ti->updateHeroBonuses(BonusType::MOVEMENT, Selector::subtype()(onLand ? BonusSubtypeID::heroMovementLand : BonusSubtypeID::heroMovementSea));
|
||||
ti->updateHeroBonuses(BonusType::MOVEMENT, Selector::subtype()(onLand ? BonusCustomSubtype::heroMovementLand : BonusCustomSubtype::heroMovementSea));
|
||||
}
|
||||
}
|
||||
|
||||
int CGHeroInstance::movementPointsLimitCached(bool onLand, const TurnInfo * ti) const
|
||||
{
|
||||
updateArmyMovementBonus(onLand, ti);
|
||||
return ti->valOfBonuses(BonusType::MOVEMENT, onLand ? BonusSubtypeID::heroMovementLand : BonusSubtypeID::heroMovementSea);
|
||||
return ti->valOfBonuses(BonusType::MOVEMENT, onLand ? BonusCustomSubtype::heroMovementLand : BonusCustomSubtype::heroMovementSea);
|
||||
}
|
||||
|
||||
CGHeroInstance::CGHeroInstance():
|
||||
@ -369,7 +369,7 @@ void CGHeroInstance::initHero(CRandomGenerator & rand)
|
||||
{
|
||||
auto bonus = JsonUtils::parseBonus(b.second);
|
||||
bonus->source = BonusSource::HERO_BASE_SKILL;
|
||||
bonus->sid = TBonusSourceID(id);
|
||||
bonus->sid = BonusSourceID(id);
|
||||
bonus->duration = BonusDuration::PERMANENT;
|
||||
addNewBonus(bonus);
|
||||
}
|
||||
@ -589,7 +589,7 @@ void CGHeroInstance::recreateSecondarySkillsBonuses()
|
||||
|
||||
void CGHeroInstance::updateSkillBonus(const SecondarySkill & which, int val)
|
||||
{
|
||||
removeBonuses(Selector::source(BonusSource::SECONDARY_SKILL, TBonusSourceID(which)));
|
||||
removeBonuses(Selector::source(BonusSource::SECONDARY_SKILL, BonusSourceID(which)));
|
||||
auto skillBonus = (*VLC->skillh)[which]->at(val).effects;
|
||||
for(const auto & b : skillBonus)
|
||||
addNewBonus(std::make_shared<Bonus>(*b));
|
||||
@ -638,7 +638,7 @@ int32_t CGHeroInstance::getSpellSchoolLevel(const spells::Spell * spell, int32_t
|
||||
|
||||
spell->forEachSchool([&, this](const SpellSchool & cnf, bool & stop)
|
||||
{
|
||||
int32_t thisSchool = valOfBonuses(BonusType::MAGIC_SCHOOL_SKILL, TBonusSubtype(cnf)); //FIXME: Bonus shouldn't be additive (Witchking Artifacts : Crown of Skies)
|
||||
int32_t thisSchool = valOfBonuses(BonusType::MAGIC_SCHOOL_SKILL, BonusSubtypeID(cnf)); //FIXME: Bonus shouldn't be additive (Witchking Artifacts : Crown of Skies)
|
||||
if(thisSchool > skill)
|
||||
{
|
||||
skill = thisSchool;
|
||||
@ -647,8 +647,8 @@ int32_t CGHeroInstance::getSpellSchoolLevel(const spells::Spell * spell, int32_t
|
||||
}
|
||||
});
|
||||
|
||||
vstd::amax(skill, valOfBonuses(BonusType::MAGIC_SCHOOL_SKILL, TBonusSubtype(SpellSchool::ANY))); //any school bonus
|
||||
vstd::amax(skill, valOfBonuses(BonusType::SPELL, TBonusSubtype(spell->getId()))); //given by artifact or other effect
|
||||
vstd::amax(skill, valOfBonuses(BonusType::MAGIC_SCHOOL_SKILL, BonusSubtypeID(SpellSchool::ANY))); //any school bonus
|
||||
vstd::amax(skill, valOfBonuses(BonusType::SPELL, BonusSubtypeID(spell->getId()))); //given by artifact or other effect
|
||||
|
||||
vstd::amax(skill, 0); //in case we don't know any school
|
||||
vstd::amin(skill, 3);
|
||||
@ -660,28 +660,28 @@ int64_t CGHeroInstance::getSpellBonus(const spells::Spell * spell, int64_t base,
|
||||
//applying sorcery secondary skill
|
||||
|
||||
if(spell->isMagical())
|
||||
base = static_cast<int64_t>(base * (valOfBonuses(BonusType::SPELL_DAMAGE, TBonusSubtype(SpellSchool::ANY))) / 100.0);
|
||||
base = static_cast<int64_t>(base * (valOfBonuses(BonusType::SPELL_DAMAGE, BonusSubtypeID(SpellSchool::ANY))) / 100.0);
|
||||
|
||||
base = static_cast<int64_t>(base * (100 + valOfBonuses(BonusType::SPECIFIC_SPELL_DAMAGE, TBonusSubtype(spell->getId()))) / 100.0);
|
||||
base = static_cast<int64_t>(base * (100 + valOfBonuses(BonusType::SPECIFIC_SPELL_DAMAGE, BonusSubtypeID(spell->getId()))) / 100.0);
|
||||
|
||||
int maxSchoolBonus = 0;
|
||||
|
||||
spell->forEachSchool([&maxSchoolBonus, this](const SpellSchool & cnf, bool & stop)
|
||||
{
|
||||
vstd::amax(maxSchoolBonus, valOfBonuses(BonusType::SPELL_DAMAGE, TBonusSubtype(cnf)));
|
||||
vstd::amax(maxSchoolBonus, valOfBonuses(BonusType::SPELL_DAMAGE, BonusSubtypeID(cnf)));
|
||||
});
|
||||
|
||||
base = static_cast<int64_t>(base * (100 + maxSchoolBonus) / 100.0);
|
||||
|
||||
if(affectedStack && affectedStack->creatureLevel() > 0) //Hero specials like Solmyr, Deemer
|
||||
base = static_cast<int64_t>(base * static_cast<double>(100 + valOfBonuses(BonusType::SPECIAL_SPELL_LEV, TBonusSubtype(spell->getId())) / affectedStack->creatureLevel()) / 100.0);
|
||||
base = static_cast<int64_t>(base * static_cast<double>(100 + valOfBonuses(BonusType::SPECIAL_SPELL_LEV, BonusSubtypeID(spell->getId())) / affectedStack->creatureLevel()) / 100.0);
|
||||
|
||||
return base;
|
||||
}
|
||||
|
||||
int64_t CGHeroInstance::getSpecificSpellBonus(const spells::Spell * spell, int64_t base) const
|
||||
{
|
||||
base = static_cast<int64_t>(base * (100 + valOfBonuses(BonusType::SPECIFIC_SPELL_DAMAGE, TBonusSubtype(spell->getId()))) / 100.0);
|
||||
base = static_cast<int64_t>(base * (100 + valOfBonuses(BonusType::SPECIFIC_SPELL_DAMAGE, BonusSubtypeID(spell->getId()))) / 100.0);
|
||||
return base;
|
||||
}
|
||||
|
||||
@ -751,19 +751,19 @@ bool CGHeroInstance::canCastThisSpell(const spells::Spell * spell) const
|
||||
const bool isAllowed = IObjectInterface::cb->isAllowed(0, spell->getIndex());
|
||||
|
||||
const bool inSpellBook = vstd::contains(spells, spell->getId()) && hasSpellbook();
|
||||
const bool specificBonus = hasBonusOfType(BonusType::SPELL, TBonusSubtype(spell->getId()));
|
||||
const bool specificBonus = hasBonusOfType(BonusType::SPELL, BonusSubtypeID(spell->getId()));
|
||||
|
||||
bool schoolBonus = false;
|
||||
|
||||
spell->forEachSchool([this, &schoolBonus](const SpellSchool & cnf, bool & stop)
|
||||
{
|
||||
if(hasBonusOfType(BonusType::SPELLS_OF_SCHOOL, TBonusSubtype(cnf)))
|
||||
if(hasBonusOfType(BonusType::SPELLS_OF_SCHOOL, BonusSubtypeID(cnf)))
|
||||
{
|
||||
schoolBonus = stop = true;
|
||||
}
|
||||
});
|
||||
|
||||
const bool levelBonus = hasBonusOfType(BonusType::SPELLS_OF_LEVEL, BonusSubtypeID::spellLevel(spell->getLevel()));
|
||||
const bool levelBonus = hasBonusOfType(BonusType::SPELLS_OF_LEVEL, BonusCustomSubtype::spellLevel(spell->getLevel()));
|
||||
|
||||
if(spell->isSpecial())
|
||||
{
|
||||
@ -1008,12 +1008,12 @@ int32_t CGHeroInstance::getSpellCost(const spells::Spell * sp) const
|
||||
|
||||
void CGHeroInstance::pushPrimSkill( PrimarySkill which, int val )
|
||||
{
|
||||
auto sel = Selector::typeSubtype(BonusType::PRIMARY_SKILL, TBonusSubtype(which))
|
||||
auto sel = Selector::typeSubtype(BonusType::PRIMARY_SKILL, BonusSubtypeID(which))
|
||||
.And(Selector::sourceType()(BonusSource::HERO_BASE_SKILL));
|
||||
if(hasBonus(sel))
|
||||
removeBonuses(sel);
|
||||
|
||||
addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::HERO_BASE_SKILL, val, TBonusSourceID(id), TBonusSubtype(which)));
|
||||
addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::HERO_BASE_SKILL, val, BonusSourceID(id), BonusSubtypeID(which)));
|
||||
}
|
||||
|
||||
EAlignment CGHeroInstance::getAlignment() const
|
||||
@ -1396,7 +1396,7 @@ void CGHeroInstance::setPrimarySkill(PrimarySkill primarySkill, si64 value, ui8
|
||||
if(primarySkill < PrimarySkill::EXPERIENCE)
|
||||
{
|
||||
auto skill = getBonusLocalFirst(Selector::type()(BonusType::PRIMARY_SKILL)
|
||||
.And(Selector::subtype()(TBonusSubtype(primarySkill)))
|
||||
.And(Selector::subtype()(BonusSubtypeID(primarySkill)))
|
||||
.And(Selector::sourceType()(BonusSource::HERO_BASE_SKILL)));
|
||||
assert(skill);
|
||||
|
||||
@ -1467,7 +1467,7 @@ void CGHeroInstance::levelUpAutomatically(CRandomGenerator & rand)
|
||||
}
|
||||
}
|
||||
|
||||
bool CGHeroInstance::hasVisions(const CGObjectInstance * target, TBonusSubtype subtype) const
|
||||
bool CGHeroInstance::hasVisions(const CGObjectInstance * target, BonusSubtypeID subtype) const
|
||||
{
|
||||
//VISIONS spell support
|
||||
const int visionsMultiplier = valOfBonuses(BonusType::VISIONS, subtype);
|
||||
@ -1559,7 +1559,7 @@ void CGHeroInstance::serializeCommonOptions(JsonSerializeFormat & handler)
|
||||
|
||||
for(auto i = PrimarySkill::BEGIN; i < PrimarySkill::END; ++i)
|
||||
{
|
||||
int value = valOfBonuses(Selector::typeSubtype(BonusType::PRIMARY_SKILL, TBonusSubtype(i)).And(Selector::sourceType()(BonusSource::HERO_BASE_SKILL)));
|
||||
int value = valOfBonuses(Selector::typeSubtype(BonusType::PRIMARY_SKILL, BonusSubtypeID(i)).And(Selector::sourceType()(BonusSource::HERO_BASE_SKILL)));
|
||||
|
||||
handler.serializeInt(NPrimarySkill::names[i.getNum()], value, 0);
|
||||
}
|
||||
@ -1752,7 +1752,7 @@ bool CGHeroInstance::isMissionCritical() const
|
||||
|
||||
void CGHeroInstance::fillUpgradeInfo(UpgradeInfo & info, const CStackInstance &stack) const
|
||||
{
|
||||
TConstBonusListPtr lista = getBonuses(Selector::typeSubtype(BonusType::SPECIAL_UPGRADE, TBonusSubtype(stack.type->getId())));
|
||||
TConstBonusListPtr lista = getBonuses(Selector::typeSubtype(BonusType::SPECIAL_UPGRADE, BonusSubtypeID(stack.type->getId())));
|
||||
for(const auto & it : *lista)
|
||||
{
|
||||
auto nid = CreatureID(it->additionalInfo[0]);
|
||||
|
@ -248,7 +248,7 @@ public:
|
||||
|
||||
void fillUpgradeInfo(UpgradeInfo & info, const CStackInstance &stack) const override;
|
||||
|
||||
bool hasVisions(const CGObjectInstance * target, TBonusSubtype masteryLevel) const;
|
||||
bool hasVisions(const CGObjectInstance * target, BonusSubtypeID masteryLevel) const;
|
||||
/// If this hero perishes, the scenario is failed
|
||||
bool isMissionCritical() const;
|
||||
|
||||
|
@ -222,7 +222,7 @@ void CGObjectInstance::giveDummyBonus(const ObjectInstanceID & heroID, BonusDura
|
||||
gbonus.id = heroID.getNum();
|
||||
gbonus.bonus.duration = duration;
|
||||
gbonus.bonus.source = BonusSource::OBJECT;
|
||||
gbonus.bonus.sid = TBonusSourceID(ID);
|
||||
gbonus.bonus.sid = BonusSourceID(ID);
|
||||
cb->giveHeroBonus(&gbonus);
|
||||
}
|
||||
|
||||
|
@ -227,11 +227,11 @@ void CGPandoraBox::serializeJsonOptions(JsonSerializeFormat & handler)
|
||||
int val;
|
||||
handler.serializeInt("morale", val, 0);
|
||||
if(val)
|
||||
vinfo.reward.bonuses.emplace_back(BonusDuration::ONE_BATTLE, BonusType::MORALE, BonusSource::OBJECT, val, TBonusSourceID(id));
|
||||
vinfo.reward.bonuses.emplace_back(BonusDuration::ONE_BATTLE, BonusType::MORALE, BonusSource::OBJECT, val, BonusSourceID(id));
|
||||
|
||||
handler.serializeInt("luck", val, 0);
|
||||
if(val)
|
||||
vinfo.reward.bonuses.emplace_back(BonusDuration::ONE_BATTLE, BonusType::LUCK, BonusSource::OBJECT, val, TBonusSourceID(id));
|
||||
vinfo.reward.bonuses.emplace_back(BonusDuration::ONE_BATTLE, BonusType::LUCK, BonusSource::OBJECT, val, BonusSourceID(id));
|
||||
|
||||
vinfo.reward.resources.serializeJson(handler, "resources");
|
||||
{
|
||||
|
@ -143,10 +143,10 @@ void COPWBonus::onHeroVisit (const CGHeroInstance * h) const
|
||||
switch (this->bType)
|
||||
{
|
||||
case BuildingSubID::STABLES:
|
||||
if(!h->hasBonusFrom(BonusSource::OBJECT, TBonusSourceID(Obj(Obj::STABLES)))) //does not stack with advMap Stables
|
||||
if(!h->hasBonusFrom(BonusSource::OBJECT, BonusSourceID(Obj(Obj::STABLES)))) //does not stack with advMap Stables
|
||||
{
|
||||
GiveBonus gb;
|
||||
gb.bonus = Bonus(BonusDuration::ONE_WEEK, BonusType::MOVEMENT, BonusSource::OBJECT, 600, TBonusSourceID(Obj(Obj::STABLES)), BonusSubtypeID::heroMovementLand, VLC->generaltexth->arraytxt[100]);
|
||||
gb.bonus = Bonus(BonusDuration::ONE_WEEK, BonusType::MOVEMENT, BonusSource::OBJECT, 600, BonusSourceID(Obj(Obj::STABLES)), BonusCustomSubtype::heroMovementLand, VLC->generaltexth->arraytxt[100]);
|
||||
gb.id = heroID.getNum();
|
||||
cb->giveHeroBonus(&gb);
|
||||
|
||||
@ -235,7 +235,7 @@ void CTownBonus::onHeroVisit (const CGHeroInstance * h) const
|
||||
|
||||
case BuildingSubID::CUSTOM_VISITING_BONUS:
|
||||
const auto building = town->getTown()->buildings.at(bID);
|
||||
if(!h->hasBonusFrom(BonusSource::TOWN_STRUCTURE, TBonusSourceID(building->getUniqueTypeID())))
|
||||
if(!h->hasBonusFrom(BonusSource::TOWN_STRUCTURE, BonusSourceID(building->getUniqueTypeID())))
|
||||
{
|
||||
const auto & bonuses = building->onVisitBonuses;
|
||||
applyBonuses(const_cast<CGHeroInstance *>(h), bonuses);
|
||||
@ -306,7 +306,7 @@ void CTownRewardableBuilding::initObj(CRandomGenerator & rand)
|
||||
for (auto & bonus : rewardInfo.reward.bonuses)
|
||||
{
|
||||
bonus.source = BonusSource::TOWN_STRUCTURE;
|
||||
bonus.sid = TBonusSourceID(building->getUniqueTypeID());
|
||||
bonus.sid = BonusSourceID(building->getUniqueTypeID());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -395,7 +395,7 @@ bool CTownRewardableBuilding::wasVisitedBefore(const CGHeroInstance * contextHer
|
||||
case Rewardable::VISIT_BONUS:
|
||||
{
|
||||
const auto building = town->getTown()->buildings.at(bID);
|
||||
return contextHero->hasBonusFrom(BonusSource::TOWN_STRUCTURE, TBonusSourceID(building->getUniqueTypeID()));
|
||||
return contextHero->hasBonusFrom(BonusSource::TOWN_STRUCTURE, BonusSourceID(building->getUniqueTypeID()));
|
||||
}
|
||||
case Rewardable::VISIT_HERO:
|
||||
return visitors.find(contextHero->id) != visitors.end();
|
||||
|
@ -160,7 +160,7 @@ GrowthInfo CGTownInstance::getGrowthInfo(int level) const
|
||||
}
|
||||
|
||||
//other *-of-legion-like bonuses (%d to growth cumulative with grail)
|
||||
TConstBonusListPtr bonuses = getBonuses(Selector::typeSubtype(BonusType::CREATURE_GROWTH, BonusSubtypeID::creatureLevel(level)));
|
||||
TConstBonusListPtr bonuses = getBonuses(Selector::typeSubtype(BonusType::CREATURE_GROWTH, BonusCustomSubtype::creatureLevel(level)));
|
||||
for(const auto & b : *bonuses)
|
||||
ret.entries.emplace_back(b->val, b->Description());
|
||||
|
||||
@ -787,7 +787,7 @@ void CGTownInstance::updateMoraleBonusFromArmy()
|
||||
auto b = getExportedBonusList().getFirst(Selector::sourceType()(BonusSource::ARMY).And(Selector::type()(BonusType::MORALE)));
|
||||
if(!b)
|
||||
{
|
||||
b = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::MORALE, BonusSource::ARMY, 0, TBonusSourceID());
|
||||
b = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::MORALE, BonusSource::ARMY, 0, BonusSourceID());
|
||||
addNewBonus(b);
|
||||
}
|
||||
|
||||
|
@ -676,9 +676,9 @@ void CGSeerHut::serializeJsonOptions(JsonSerializeFormat & handler)
|
||||
if(metaTypeName == "mana")
|
||||
reward.manaDiff = val;
|
||||
if(metaTypeName == "morale")
|
||||
reward.bonuses.emplace_back(BonusDuration::ONE_BATTLE, BonusType::MORALE, BonusSource::OBJECT, val, TBonusSourceID(id));
|
||||
reward.bonuses.emplace_back(BonusDuration::ONE_BATTLE, BonusType::MORALE, BonusSource::OBJECT, val, BonusSourceID(id));
|
||||
if(metaTypeName == "luck")
|
||||
reward.bonuses.emplace_back(BonusDuration::ONE_BATTLE, BonusType::LUCK, BonusSource::OBJECT, val, TBonusSourceID(id));
|
||||
reward.bonuses.emplace_back(BonusDuration::ONE_BATTLE, BonusType::LUCK, BonusSource::OBJECT, val, BonusSourceID(id));
|
||||
if(metaTypeName == "resource")
|
||||
{
|
||||
auto rawId = *VLC->identifiers()->getIdentifier(ModScope::scopeMap(), fullIdentifier, false);
|
||||
|
@ -197,7 +197,7 @@ bool CRewardableObject::wasVisitedBefore(const CGHeroInstance * contextHero) con
|
||||
case Rewardable::VISIT_PLAYER:
|
||||
return vstd::contains(cb->getPlayerState(contextHero->getOwner())->visitedObjects, ObjectInstanceID(id));
|
||||
case Rewardable::VISIT_BONUS:
|
||||
return contextHero->hasBonusFrom(BonusSource::OBJECT, TBonusSourceID(ID));
|
||||
return contextHero->hasBonusFrom(BonusSource::OBJECT, BonusSourceID(ID));
|
||||
case Rewardable::VISIT_HERO:
|
||||
return contextHero->visitedObjects.count(ObjectInstanceID(id));
|
||||
case Rewardable::VISIT_LIMITER:
|
||||
@ -234,7 +234,7 @@ bool CRewardableObject::wasVisited(const CGHeroInstance * h) const
|
||||
switch (configuration.visitMode)
|
||||
{
|
||||
case Rewardable::VISIT_BONUS:
|
||||
return h->hasBonusFrom(BonusSource::OBJECT, TBonusSourceID(ID));
|
||||
return h->hasBonusFrom(BonusSource::OBJECT, BonusSourceID(ID));
|
||||
case Rewardable::VISIT_HERO:
|
||||
return h->visitedObjects.count(ObjectInstanceID(id));
|
||||
case Rewardable::VISIT_LIMITER:
|
||||
|
@ -987,14 +987,14 @@ void CGSirens::initObj(CRandomGenerator & rand)
|
||||
|
||||
std::string CGSirens::getHoverText(const CGHeroInstance * hero) const
|
||||
{
|
||||
return getObjectName() + " " + visitedTxt(hero->hasBonusFrom(BonusSource::OBJECT, TBonusSourceID(ID)));
|
||||
return getObjectName() + " " + visitedTxt(hero->hasBonusFrom(BonusSource::OBJECT, BonusSourceID(ID)));
|
||||
}
|
||||
|
||||
void CGSirens::onHeroVisit( const CGHeroInstance * h ) const
|
||||
{
|
||||
InfoWindow iw;
|
||||
iw.player = h->tempOwner;
|
||||
if(h->hasBonusFrom(BonusSource::OBJECT, TBonusSourceID(ID))) //has already visited Sirens
|
||||
if(h->hasBonusFrom(BonusSource::OBJECT, BonusSourceID(ID))) //has already visited Sirens
|
||||
{
|
||||
iw.type = EInfoWindowMode::AUTO;
|
||||
iw.text.appendLocalString(EMetaText::ADVOB_TXT,133);
|
||||
@ -1180,7 +1180,7 @@ void CGLighthouse::onHeroVisit( const CGHeroInstance * h ) const
|
||||
RemoveBonus rb(GiveBonus::ETarget::PLAYER);
|
||||
rb.whoID = oldOwner.getNum();
|
||||
rb.source = BonusSource::OBJECT;
|
||||
rb.id = TBonusSourceID(id);
|
||||
rb.id = BonusSourceID(id);
|
||||
cb->sendAndApply(&rb);
|
||||
}
|
||||
}
|
||||
@ -1203,8 +1203,8 @@ void CGLighthouse::giveBonusTo(const PlayerColor & player, bool onInit) const
|
||||
gb.id = player.getNum();
|
||||
gb.bonus.duration = BonusDuration::PERMANENT;
|
||||
gb.bonus.source = BonusSource::OBJECT;
|
||||
gb.bonus.sid = TBonusSourceID(id);
|
||||
gb.bonus.subtype = BonusSubtypeID::heroMovementSea;
|
||||
gb.bonus.sid = BonusSourceID(id);
|
||||
gb.bonus.subtype = BonusCustomSubtype::heroMovementSea;
|
||||
|
||||
// FIXME: This is really dirty hack
|
||||
// Proper fix would be to make CGLighthouse into bonus system node
|
||||
|
@ -1040,9 +1040,9 @@ void CMapLoaderH3M::readBoxContent(CGPandoraBox * object, const int3 & mapPositi
|
||||
reward.heroExperience = reader->readUInt32();
|
||||
reward.manaDiff = reader->readInt32();
|
||||
if(auto val = reader->readUInt8())
|
||||
reward.bonuses.emplace_back(BonusDuration::ONE_BATTLE, BonusType::MORALE, BonusSource::OBJECT, val, TBonusSourceID(idToBeGiven));
|
||||
reward.bonuses.emplace_back(BonusDuration::ONE_BATTLE, BonusType::MORALE, BonusSource::OBJECT, val, BonusSourceID(idToBeGiven));
|
||||
if(auto val = reader->readUInt8())
|
||||
reward.bonuses.emplace_back(BonusDuration::ONE_BATTLE, BonusType::LUCK, BonusSource::OBJECT, val, TBonusSourceID(idToBeGiven));
|
||||
reward.bonuses.emplace_back(BonusDuration::ONE_BATTLE, BonusType::LUCK, BonusSource::OBJECT, val, BonusSourceID(idToBeGiven));
|
||||
|
||||
reader->readResourses(reward.resources);
|
||||
for(int x = 0; x < GameConstants::PRIMARY_SKILLS; ++x)
|
||||
@ -2008,12 +2008,12 @@ void CMapLoaderH3M::readSeerHutQuest(CGSeerHut * hut, const int3 & position, con
|
||||
}
|
||||
case ESeerHutRewardType::MORALE:
|
||||
{
|
||||
reward.bonuses.emplace_back(BonusDuration::ONE_BATTLE, BonusType::MORALE, BonusSource::OBJECT, reader->readUInt8(), TBonusSourceID(idToBeGiven));
|
||||
reward.bonuses.emplace_back(BonusDuration::ONE_BATTLE, BonusType::MORALE, BonusSource::OBJECT, reader->readUInt8(), BonusSourceID(idToBeGiven));
|
||||
break;
|
||||
}
|
||||
case ESeerHutRewardType::LUCK:
|
||||
{
|
||||
reward.bonuses.emplace_back(BonusDuration::ONE_BATTLE, BonusType::LUCK, BonusSource::OBJECT, reader->readUInt8(), TBonusSourceID(idToBeGiven));
|
||||
reward.bonuses.emplace_back(BonusDuration::ONE_BATTLE, BonusType::LUCK, BonusSource::OBJECT, reader->readUInt8(), BonusSourceID(idToBeGiven));
|
||||
break;
|
||||
}
|
||||
case ESeerHutRewardType::RESOURCES:
|
||||
|
@ -23,7 +23,7 @@ TurnInfo::BonusCache::BonusCache(const TConstBonusListPtr & bl)
|
||||
for(const auto & terrain : VLC->terrainTypeHandler->objects)
|
||||
{
|
||||
noTerrainPenalty.push_back(static_cast<bool>(
|
||||
bl->getFirst(Selector::type()(BonusType::NO_TERRAIN_PENALTY).And(Selector::subtype()(TBonusSubtype(terrain->getId()))))));
|
||||
bl->getFirst(Selector::type()(BonusType::NO_TERRAIN_PENALTY).And(Selector::subtype()(BonusSubtypeID(terrain->getId()))))));
|
||||
}
|
||||
|
||||
freeShipBoarding = static_cast<bool>(bl->getFirst(Selector::type()(BonusType::FREE_SHIP_BOARDING)));
|
||||
@ -73,10 +73,10 @@ bool TurnInfo::isLayerAvailable(const EPathfindingLayer & layer) const
|
||||
|
||||
bool TurnInfo::hasBonusOfType(BonusType type) const
|
||||
{
|
||||
return hasBonusOfType(type, TBonusSubtype());
|
||||
return hasBonusOfType(type, BonusSubtypeID());
|
||||
}
|
||||
|
||||
bool TurnInfo::hasBonusOfType(BonusType type, TBonusSubtype subtype) const
|
||||
bool TurnInfo::hasBonusOfType(BonusType type, BonusSubtypeID subtype) const
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
@ -96,10 +96,10 @@ bool TurnInfo::hasBonusOfType(BonusType type, TBonusSubtype subtype) const
|
||||
|
||||
int TurnInfo::valOfBonuses(BonusType type) const
|
||||
{
|
||||
return valOfBonuses(type, TBonusSubtype());
|
||||
return valOfBonuses(type, BonusSubtypeID());
|
||||
}
|
||||
|
||||
int TurnInfo::valOfBonuses(BonusType type, TBonusSubtype subtype) const
|
||||
int TurnInfo::valOfBonuses(BonusType type, BonusSubtypeID subtype) const
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
|
@ -43,9 +43,9 @@ struct DLL_LINKAGE TurnInfo
|
||||
TurnInfo(const CGHeroInstance * Hero, const int Turn = 0);
|
||||
bool isLayerAvailable(const EPathfindingLayer & layer) const;
|
||||
bool hasBonusOfType(const BonusType type) const;
|
||||
bool hasBonusOfType(const BonusType type, const TBonusSubtype subtype) const;
|
||||
bool hasBonusOfType(const BonusType type, const BonusSubtypeID subtype) const;
|
||||
int valOfBonuses(const BonusType type) const;
|
||||
int valOfBonuses(const BonusType type, const TBonusSubtype subtype) const;
|
||||
int valOfBonuses(const BonusType type, const BonusSubtypeID subtype) const;
|
||||
void updateHeroBonuses(BonusType type, const CSelector& sel) const;
|
||||
int getMaxMovePoints(const EPathfindingLayer & layer) const;
|
||||
};
|
||||
|
@ -35,7 +35,7 @@ int32_t AbilityCaster::getSpellSchoolLevel(const Spell * spell, int32_t * outSel
|
||||
|
||||
if(spell->getLevel() > 0)
|
||||
{
|
||||
vstd::amax(skill, unit->valOfBonuses(BonusType::MAGIC_SCHOOL_SKILL, TBonusSubtype(SpellSchool::ANY)));
|
||||
vstd::amax(skill, unit->valOfBonuses(BonusType::MAGIC_SCHOOL_SKILL, BonusSubtypeID(SpellSchool::ANY)));
|
||||
}
|
||||
|
||||
vstd::amax(skill, 0);
|
||||
|
@ -312,7 +312,7 @@ ESpellCastResult DimensionDoorMechanics::applyAdventureEffects(SpellCastEnvironm
|
||||
std::stringstream cachingStr;
|
||||
cachingStr << "source_" << vstd::to_underlying(BonusSource::SPELL_EFFECT) << "id_" << owner->id.num;
|
||||
|
||||
if(parameters.caster->getHeroCaster()->getBonuses(Selector::source(BonusSource::SPELL_EFFECT, TBonusSourceID(owner->id)), Selector::all, cachingStr.str())->size() >= owner->getLevelPower(schoolLevel)) //limit casts per turn
|
||||
if(parameters.caster->getHeroCaster()->getBonuses(Selector::source(BonusSource::SPELL_EFFECT, BonusSourceID(owner->id)), Selector::all, cachingStr.str())->size() >= owner->getLevelPower(schoolLevel)) //limit casts per turn
|
||||
{
|
||||
InfoWindow iw;
|
||||
iw.player = parameters.caster->getCasterOwner();
|
||||
@ -324,7 +324,7 @@ ESpellCastResult DimensionDoorMechanics::applyAdventureEffects(SpellCastEnvironm
|
||||
|
||||
GiveBonus gb;
|
||||
gb.id = parameters.caster->getCasterUnitId();
|
||||
gb.bonus = Bonus(BonusDuration::ONE_DAY, BonusType::NONE, BonusSource::SPELL_EFFECT, 0, TBonusSourceID(owner->id));
|
||||
gb.bonus = Bonus(BonusDuration::ONE_DAY, BonusType::NONE, BonusSource::SPELL_EFFECT, 0, BonusSourceID(owner->id));
|
||||
env->apply(&gb);
|
||||
|
||||
if(!dest->isClear(curr)) //wrong dest tile
|
||||
|
@ -383,15 +383,15 @@ int64_t CSpell::adjustRawDamage(const spells::Caster * caster, const battle::Uni
|
||||
//applying protections - when spell has more then one elements, only one protection should be applied (I think)
|
||||
forEachSchool([&](const SpellSchool & cnf, bool & stop)
|
||||
{
|
||||
if(bearer->hasBonusOfType(BonusType::SPELL_DAMAGE_REDUCTION, TBonusSubtype(cnf)))
|
||||
if(bearer->hasBonusOfType(BonusType::SPELL_DAMAGE_REDUCTION, BonusSubtypeID(cnf)))
|
||||
{
|
||||
ret *= 100 - bearer->valOfBonuses(BonusType::SPELL_DAMAGE_REDUCTION, TBonusSubtype(cnf));
|
||||
ret *= 100 - bearer->valOfBonuses(BonusType::SPELL_DAMAGE_REDUCTION, BonusSubtypeID(cnf));
|
||||
ret /= 100;
|
||||
stop = true; //only bonus from one school is used
|
||||
}
|
||||
});
|
||||
|
||||
CSelector selector = Selector::typeSubtype(BonusType::SPELL_DAMAGE_REDUCTION, TBonusSubtype(SpellSchool::ANY));
|
||||
CSelector selector = Selector::typeSubtype(BonusType::SPELL_DAMAGE_REDUCTION, BonusSubtypeID(SpellSchool::ANY));
|
||||
auto cachingStr = "type_SPELL_DAMAGE_REDUCTION_s_ANY";
|
||||
|
||||
//general spell dmg reduction, works only on magical effects
|
||||
@ -402,9 +402,9 @@ int64_t CSpell::adjustRawDamage(const spells::Caster * caster, const battle::Uni
|
||||
}
|
||||
|
||||
//dmg increasing
|
||||
if(bearer->hasBonusOfType(BonusType::MORE_DAMAGE_FROM_SPELL, TBonusSubtype(id)))
|
||||
if(bearer->hasBonusOfType(BonusType::MORE_DAMAGE_FROM_SPELL, BonusSubtypeID(id)))
|
||||
{
|
||||
ret *= 100 + bearer->valOfBonuses(BonusType::MORE_DAMAGE_FROM_SPELL, TBonusSubtype(id));
|
||||
ret *= 100 + bearer->valOfBonuses(BonusType::MORE_DAMAGE_FROM_SPELL, BonusSubtypeID(id));
|
||||
ret /= 100;
|
||||
}
|
||||
}
|
||||
@ -925,7 +925,7 @@ CSpell * CSpellHandler::loadFromJson(const std::string & scope, const JsonNode &
|
||||
auto b = JsonUtils::parseBonus(bonusNode);
|
||||
const bool usePowerAsValue = bonusNode["val"].isNull();
|
||||
|
||||
b->sid = TBonusSourceID(spell->id); //for all
|
||||
b->sid = BonusSourceID(spell->id); //for all
|
||||
b->source = BonusSource::SPELL_EFFECT;//for all
|
||||
|
||||
if(usePowerAsValue)
|
||||
@ -940,7 +940,7 @@ CSpell * CSpellHandler::loadFromJson(const std::string & scope, const JsonNode &
|
||||
auto b = JsonUtils::parseBonus(bonusNode);
|
||||
const bool usePowerAsValue = bonusNode["val"].isNull();
|
||||
|
||||
b->sid = TBonusSourceID(spell->id); //for all
|
||||
b->sid = BonusSourceID(spell->id); //for all
|
||||
b->source = BonusSource::SPELL_EFFECT;//for all
|
||||
|
||||
if(usePowerAsValue)
|
||||
|
@ -157,7 +157,7 @@ protected:
|
||||
{
|
||||
std::stringstream cachingStr;
|
||||
cachingStr << "type_" << vstd::to_underlying(BonusType::SPELL_IMMUNITY) << "subtype_" << m->getSpellIndex() << "addInfo_1";
|
||||
return !target->hasBonus(Selector::typeSubtypeInfo(BonusType::SPELL_IMMUNITY, TBonusSubtype(m->getSpellId()), 1), cachingStr.str());
|
||||
return !target->hasBonus(Selector::typeSubtypeInfo(BonusType::SPELL_IMMUNITY, BonusSubtypeID(m->getSpellId()), 1), cachingStr.str());
|
||||
}
|
||||
};
|
||||
|
||||
@ -179,14 +179,14 @@ protected:
|
||||
|
||||
m->getSpell()->forEachSchool([&](const SpellSchool & cnf, bool & stop)
|
||||
{
|
||||
if (bearer->hasBonusOfType(BonusType::SPELL_SCHOOL_IMMUNITY, TBonusSubtype(cnf)))
|
||||
if (bearer->hasBonusOfType(BonusType::SPELL_SCHOOL_IMMUNITY, BonusSubtypeID(cnf)))
|
||||
{
|
||||
elementalImmune = true;
|
||||
stop = true; //only bonus from one school is used
|
||||
}
|
||||
else if(!m->isPositiveSpell()) //negative or indifferent
|
||||
{
|
||||
if (bearer->hasBonusOfType(BonusType::NEGATIVE_EFFECTS_IMMUNITY, TBonusSubtype(cnf)))
|
||||
if (bearer->hasBonusOfType(BonusType::NEGATIVE_EFFECTS_IMMUNITY, BonusSubtypeID(cnf)))
|
||||
{
|
||||
elementalImmune = true;
|
||||
stop = true; //only bonus from one school is used
|
||||
@ -231,7 +231,7 @@ public:
|
||||
protected:
|
||||
bool check(const Mechanics * m, const battle::Unit * target) const override
|
||||
{
|
||||
return !target->hasBonusOfType(BonusType::SPELL_IMMUNITY, TBonusSubtype(m->getSpellId()));
|
||||
return !target->hasBonusOfType(BonusType::SPELL_IMMUNITY, BonusSubtypeID(m->getSpellId()));
|
||||
}
|
||||
};
|
||||
|
||||
@ -259,7 +259,7 @@ public:
|
||||
builder << "source_" << vstd::to_underlying(BonusSource::SPELL_EFFECT) << "id_" << spellID.num;
|
||||
cachingString = builder.str();
|
||||
|
||||
selector = Selector::source(BonusSource::SPELL_EFFECT, TBonusSourceID(spellID));
|
||||
selector = Selector::source(BonusSource::SPELL_EFFECT, BonusSourceID(spellID));
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -292,8 +292,8 @@ class ImmunityNegationCondition : public TargetConditionItemBase
|
||||
protected:
|
||||
bool check(const Mechanics * m, const battle::Unit * target) const override
|
||||
{
|
||||
const bool battleWideNegation = target->hasBonusOfType(BonusType::NEGATE_ALL_NATURAL_IMMUNITIES, BonusSubtypeID::immunityBattleWide);
|
||||
const bool heroNegation = target->hasBonusOfType(BonusType::NEGATE_ALL_NATURAL_IMMUNITIES, BonusSubtypeID::immunityEnemyHero);
|
||||
const bool battleWideNegation = target->hasBonusOfType(BonusType::NEGATE_ALL_NATURAL_IMMUNITIES, BonusCustomSubtype::immunityBattleWide);
|
||||
const bool heroNegation = target->hasBonusOfType(BonusType::NEGATE_ALL_NATURAL_IMMUNITIES, BonusCustomSubtype::immunityEnemyHero);
|
||||
//Non-magical effects is not affected by orb of vulnerability
|
||||
if(!m->isMagicalEffect())
|
||||
return false;
|
||||
|
@ -94,7 +94,7 @@ void Clone::apply(ServerCallback * server, const Mechanics * m, const EffectTarg
|
||||
SetStackEffect sse;
|
||||
sse.battleID = m->battle()->getBattle()->getBattleID();
|
||||
|
||||
Bonus lifeTimeMarker(BonusDuration::N_TURNS, BonusType::NONE, BonusSource::SPELL_EFFECT, 0, TBonusSourceID(SpellID(SpellID::CLONE))); //TODO: use special bonus type
|
||||
Bonus lifeTimeMarker(BonusDuration::N_TURNS, BonusType::NONE, BonusSource::SPELL_EFFECT, 0, BonusSourceID(SpellID(SpellID::CLONE))); //TODO: use special bonus type
|
||||
lifeTimeMarker.turnsRemain = m->getEffectDuration();
|
||||
std::vector<Bonus> buffer;
|
||||
buffer.push_back(lifeTimeMarker);
|
||||
|
@ -89,11 +89,11 @@ bool Damage::isReceptive(const Mechanics * m, const battle::Unit * unit) const
|
||||
if(!UnitEffect::isReceptive(m, unit))
|
||||
return false;
|
||||
|
||||
bool isImmune = m->getSpell()->isMagical() && (unit->getBonusBearer()->valOfBonuses(BonusType::SPELL_DAMAGE_REDUCTION, TBonusSubtype(SpellSchool::ANY)) >= 100); //General spell damage immunity
|
||||
bool isImmune = m->getSpell()->isMagical() && (unit->getBonusBearer()->valOfBonuses(BonusType::SPELL_DAMAGE_REDUCTION, BonusSubtypeID(SpellSchool::ANY)) >= 100); //General spell damage immunity
|
||||
//elemental immunity for damage
|
||||
m->getSpell()->forEachSchool([&](const SpellSchool & cnf, bool & stop)
|
||||
{
|
||||
isImmune |= (unit->getBonusBearer()->valOfBonuses(BonusType::SPELL_DAMAGE_REDUCTION, TBonusSubtype(cnf)) >= 100); //100% reduction is immunity
|
||||
isImmune |= (unit->getBonusBearer()->valOfBonuses(BonusType::SPELL_DAMAGE_REDUCTION, BonusSubtypeID(cnf)) >= 100); //100% reduction is immunity
|
||||
});
|
||||
|
||||
return !isImmune;
|
||||
|
@ -84,12 +84,12 @@ void Moat::convertBonus(const Mechanics * m, std::vector<Bonus> & converted) con
|
||||
|
||||
if(m->battle()->battleGetDefendedTown() && m->battle()->battleGetSiegeLevel() >= CGTownInstance::CITADEL)
|
||||
{
|
||||
nb.sid = TBonusSourceID(m->battle()->battleGetDefendedTown()->town->buildings.at(BuildingID::CITADEL)->getUniqueTypeID());
|
||||
nb.sid = BonusSourceID(m->battle()->battleGetDefendedTown()->town->buildings.at(BuildingID::CITADEL)->getUniqueTypeID());
|
||||
nb.source = BonusSource::TOWN_STRUCTURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
nb.sid = TBonusSourceID(m->getSpellId()); //for all
|
||||
nb.sid = BonusSourceID(m->getSpellId()); //for all
|
||||
nb.source = BonusSource::SPELL_EFFECT;//for all
|
||||
}
|
||||
std::set<BattleHex> flatMoatHexes;
|
||||
|
@ -109,9 +109,9 @@ void Timed::apply(ServerCallback * server, const Mechanics * m, const EffectTarg
|
||||
const auto *casterHero = dynamic_cast<const CGHeroInstance *>(m->caster);
|
||||
if(casterHero)
|
||||
{
|
||||
peculiarBonus = casterHero->getBonusLocalFirst(Selector::typeSubtype(BonusType::SPECIAL_PECULIAR_ENCHANT, TBonusSubtype(m->getSpellId())));
|
||||
addedValueBonus = casterHero->getBonusLocalFirst(Selector::typeSubtype(BonusType::SPECIAL_ADD_VALUE_ENCHANT, TBonusSubtype(m->getSpellId())));
|
||||
fixedValueBonus = casterHero->getBonusLocalFirst(Selector::typeSubtype(BonusType::SPECIAL_FIXED_VALUE_ENCHANT, TBonusSubtype(m->getSpellId())));
|
||||
peculiarBonus = casterHero->getBonusLocalFirst(Selector::typeSubtype(BonusType::SPECIAL_PECULIAR_ENCHANT, BonusSubtypeID(m->getSpellId())));
|
||||
addedValueBonus = casterHero->getBonusLocalFirst(Selector::typeSubtype(BonusType::SPECIAL_ADD_VALUE_ENCHANT, BonusSubtypeID(m->getSpellId())));
|
||||
fixedValueBonus = casterHero->getBonusLocalFirst(Selector::typeSubtype(BonusType::SPECIAL_FIXED_VALUE_ENCHANT, BonusSubtypeID(m->getSpellId())));
|
||||
}
|
||||
//TODO: does hero specialty should affects his stack casting spells?
|
||||
|
||||
@ -222,7 +222,7 @@ void Timed::convertBonus(const Mechanics * m, int32_t & duration, std::vector<Bo
|
||||
nb.turnsRemain = duration;
|
||||
vstd::amax(maxDuration, nb.turnsRemain);
|
||||
|
||||
nb.sid = TBonusSourceID(m->getSpellId()); //for all
|
||||
nb.sid = BonusSourceID(m->getSpellId()); //for all
|
||||
nb.source = BonusSource::SPELL_EFFECT;//for all
|
||||
|
||||
//fix to original config: shield should display damage reduction
|
||||
|
@ -253,7 +253,7 @@ bool UnitEffect::isReceptive(const Mechanics * m, const battle::Unit * unit) con
|
||||
//SPELL_IMMUNITY absolute case
|
||||
std::stringstream cachingStr;
|
||||
cachingStr << "type_" << vstd::to_underlying(BonusType::SPELL_IMMUNITY) << "subtype_" << m->getSpellIndex() << "addInfo_1";
|
||||
return !unit->hasBonus(Selector::typeSubtypeInfo(BonusType::SPELL_IMMUNITY, TBonusSubtype(m->getSpellId()), 1), cachingStr.str());
|
||||
return !unit->hasBonus(Selector::typeSubtypeInfo(BonusType::SPELL_IMMUNITY, BonusSubtypeID(m->getSpellId()), 1), cachingStr.str());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -333,7 +333,7 @@ void RewardsWidget::saveCurrentVisitInfo(int index)
|
||||
auto dur = bonusDurationMap.at(ui->bonuses->item(i, 0)->text().toStdString());
|
||||
auto typ = bonusNameMap.at(ui->bonuses->item(i, 1)->text().toStdString());
|
||||
auto val = ui->bonuses->item(i, 2)->data(Qt::UserRole).toInt();
|
||||
vinfo.reward.bonuses.emplace_back(dur, typ, BonusSource::OBJECT, val, TBonusSourceID(object.id));
|
||||
vinfo.reward.bonuses.emplace_back(dur, typ, BonusSource::OBJECT, val, BonusSourceID(object.id));
|
||||
}
|
||||
|
||||
vinfo.limiter.dayOfWeek = ui->lDayOfWeek->currentIndex();
|
||||
|
@ -248,11 +248,11 @@ void CGameHandler::levelUpCommander (const CCommanderInstance * c, int skill)
|
||||
{
|
||||
case ECommander::ATTACK:
|
||||
scp.accumulatedBonus.type = BonusType::PRIMARY_SKILL;
|
||||
scp.accumulatedBonus.subtype = TBonusSubtype(PrimarySkill::ATTACK);
|
||||
scp.accumulatedBonus.subtype = BonusSubtypeID(PrimarySkill::ATTACK);
|
||||
break;
|
||||
case ECommander::DEFENSE:
|
||||
scp.accumulatedBonus.type = BonusType::PRIMARY_SKILL;
|
||||
scp.accumulatedBonus.subtype = TBonusSubtype(PrimarySkill::DEFENSE);
|
||||
scp.accumulatedBonus.subtype = BonusSubtypeID(PrimarySkill::DEFENSE);
|
||||
break;
|
||||
case ECommander::HEALTH:
|
||||
scp.accumulatedBonus.type = BonusType::STACK_HEALTH;
|
||||
@ -788,7 +788,7 @@ void CGameHandler::onNewTurn()
|
||||
{
|
||||
for (GameResID k = GameResID::WOOD; k < GameResID::COUNT; k++)
|
||||
{
|
||||
n.res[elem.first][k] += h->valOfBonuses(BonusType::GENERATE_RESOURCE, TBonusSubtype(k));
|
||||
n.res[elem.first][k] += h->valOfBonuses(BonusType::GENERATE_RESOURCE, BonusSubtypeID(k));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -162,11 +162,11 @@ bool BattleActionProcessor::doDefendAction(const CBattleInfoCallback & battle, c
|
||||
SetStackEffect sse;
|
||||
sse.battleID = battle.getBattle()->getBattleID();
|
||||
|
||||
Bonus defenseBonusToAdd(BonusDuration::STACK_GETS_TURN, BonusType::PRIMARY_SKILL, BonusSource::OTHER, 20, TBonusSourceID(), TBonusSubtype(PrimarySkill::DEFENSE), BonusValueType::PERCENT_TO_ALL);
|
||||
Bonus bonus2(BonusDuration::STACK_GETS_TURN, BonusType::PRIMARY_SKILL, BonusSource::OTHER, stack->valOfBonuses(BonusType::DEFENSIVE_STANCE), TBonusSourceID(), TBonusSubtype(PrimarySkill::DEFENSE), BonusValueType::ADDITIVE_VALUE);
|
||||
Bonus alternativeWeakCreatureBonus(BonusDuration::STACK_GETS_TURN, BonusType::PRIMARY_SKILL, BonusSource::OTHER, 1, TBonusSourceID(), TBonusSubtype(PrimarySkill::DEFENSE), BonusValueType::ADDITIVE_VALUE);
|
||||
Bonus defenseBonusToAdd(BonusDuration::STACK_GETS_TURN, BonusType::PRIMARY_SKILL, BonusSource::OTHER, 20, BonusSourceID(), BonusSubtypeID(PrimarySkill::DEFENSE), BonusValueType::PERCENT_TO_ALL);
|
||||
Bonus bonus2(BonusDuration::STACK_GETS_TURN, BonusType::PRIMARY_SKILL, BonusSource::OTHER, stack->valOfBonuses(BonusType::DEFENSIVE_STANCE), BonusSourceID(), BonusSubtypeID(PrimarySkill::DEFENSE), BonusValueType::ADDITIVE_VALUE);
|
||||
Bonus alternativeWeakCreatureBonus(BonusDuration::STACK_GETS_TURN, BonusType::PRIMARY_SKILL, BonusSource::OTHER, 1, BonusSourceID(), BonusSubtypeID(PrimarySkill::DEFENSE), BonusValueType::ADDITIVE_VALUE);
|
||||
|
||||
BonusList defence = *stack->getBonuses(Selector::typeSubtype(BonusType::PRIMARY_SKILL, TBonusSubtype(PrimarySkill::DEFENSE)));
|
||||
BonusList defence = *stack->getBonuses(Selector::typeSubtype(BonusType::PRIMARY_SKILL, BonusSubtypeID(PrimarySkill::DEFENSE)));
|
||||
int oldDefenceValue = defence.totalValue();
|
||||
|
||||
defence.push_back(std::make_shared<Bonus>(defenseBonusToAdd));
|
||||
@ -263,7 +263,7 @@ bool BattleActionProcessor::doAttackAction(const CBattleInfoCallback & battle, c
|
||||
const auto * attackingHero = battle.battleGetFightingHero(ba.side);
|
||||
if(attackingHero)
|
||||
{
|
||||
totalAttacks += attackingHero->valOfBonuses(BonusType::HERO_GRANTS_ATTACKS, TBonusSubtype(stack->creatureId()));
|
||||
totalAttacks += attackingHero->valOfBonuses(BonusType::HERO_GRANTS_ATTACKS, BonusSubtypeID(stack->creatureId()));
|
||||
}
|
||||
|
||||
const bool firstStrike = destinationStack->hasBonusOfType(BonusType::FIRST_STRIKE);
|
||||
@ -355,7 +355,7 @@ bool BattleActionProcessor::doShootAction(const CBattleInfoCallback & battle, co
|
||||
const auto * attackingHero = battle.battleGetFightingHero(ba.side);
|
||||
if(attackingHero)
|
||||
{
|
||||
totalRangedAttacks += attackingHero->valOfBonuses(BonusType::HERO_GRANTS_ATTACKS, TBonusSubtype(stack->creatureId()));
|
||||
totalRangedAttacks += attackingHero->valOfBonuses(BonusType::HERO_GRANTS_ATTACKS, BonusSubtypeID(stack->creatureId()));
|
||||
}
|
||||
|
||||
for(int i = 1; i < totalRangedAttacks; ++i)
|
||||
@ -382,7 +382,7 @@ bool BattleActionProcessor::doCatapultAction(const CBattleInfoCallback & battle,
|
||||
return false;
|
||||
|
||||
std::shared_ptr<const Bonus> catapultAbility = stack->getBonusLocalFirst(Selector::type()(BonusType::CATAPULT));
|
||||
if(!catapultAbility || catapultAbility->subtype == TBonusSubtype())
|
||||
if(!catapultAbility || catapultAbility->subtype == BonusSubtypeID())
|
||||
{
|
||||
gameHandler->complain("We do not know how to shoot :P");
|
||||
}
|
||||
@ -407,7 +407,7 @@ bool BattleActionProcessor::doUnitSpellAction(const CBattleInfoCallback & battle
|
||||
return false;
|
||||
|
||||
std::shared_ptr<const Bonus> randSpellcaster = stack->getBonus(Selector::type()(BonusType::RANDOM_SPELLCASTER));
|
||||
std::shared_ptr<const Bonus> spellcaster = stack->getBonus(Selector::typeSubtype(BonusType::SPELLCASTER, TBonusSubtype(spellID)));
|
||||
std::shared_ptr<const Bonus> spellcaster = stack->getBonus(Selector::typeSubtype(BonusType::SPELLCASTER, BonusSubtypeID(spellID)));
|
||||
|
||||
//TODO special bonus for genies ability
|
||||
if (randSpellcaster && battle.battleGetRandomStackSpell(gameHandler->getRandomGenerator(), stack, CBattleInfoCallback::RANDOM_AIMED) == SpellID::NONE)
|
||||
@ -452,7 +452,7 @@ bool BattleActionProcessor::doHealAction(const CBattleInfoCallback & battle, con
|
||||
else
|
||||
destStack = battle.battleGetUnitByPos(target.at(0).hexValue);
|
||||
|
||||
if(stack == nullptr || destStack == nullptr || !healerAbility || healerAbility->subtype == TBonusSubtype())
|
||||
if(stack == nullptr || destStack == nullptr || !healerAbility || healerAbility->subtype == BonusSubtypeID())
|
||||
{
|
||||
gameHandler->complain("There is either no healer, no destination, or healer cannot heal :P");
|
||||
}
|
||||
@ -907,7 +907,7 @@ void BattleActionProcessor::makeAttack(const CBattleInfoCallback & battle, const
|
||||
const auto * owner = battle.battleGetFightingHero(attacker->unitSide());
|
||||
if(owner)
|
||||
{
|
||||
int chance = owner->valOfBonuses(BonusType::BONUS_DAMAGE_CHANCE, TBonusSubtype(attacker->creatureId()));
|
||||
int chance = owner->valOfBonuses(BonusType::BONUS_DAMAGE_CHANCE, BonusSubtypeID(attacker->creatureId()));
|
||||
if (chance > gameHandler->getRandomGenerator().nextInt(99))
|
||||
bat.flags |= BattleAttack::BALLISTA_DOUBLE_DMG;
|
||||
}
|
||||
@ -1095,7 +1095,7 @@ void BattleActionProcessor::attackCasting(const CBattleInfoCallback & battle, bo
|
||||
return;
|
||||
}
|
||||
int32_t spellLevel = 0;
|
||||
TConstBonusListPtr spellsByType = attacker->getBonuses(Selector::typeSubtype(attackMode, TBonusSubtype(spellID)));
|
||||
TConstBonusListPtr spellsByType = attacker->getBonuses(Selector::typeSubtype(attackMode, BonusSubtypeID(spellID)));
|
||||
for(const auto & sf : *spellsByType)
|
||||
{
|
||||
int meleeRanged;
|
||||
@ -1113,7 +1113,7 @@ void BattleActionProcessor::attackCasting(const CBattleInfoCallback & battle, bo
|
||||
if (meleeRanged == 0 || (meleeRanged == 1 && ranged) || (meleeRanged == 2 && !ranged))
|
||||
castMe = true;
|
||||
}
|
||||
int chance = attacker->valOfBonuses((Selector::typeSubtype(attackMode, TBonusSubtype(spellID))));
|
||||
int chance = attacker->valOfBonuses((Selector::typeSubtype(attackMode, BonusSubtypeID(spellID))));
|
||||
vstd::amin(chance, 100);
|
||||
|
||||
const CSpell * spell = SpellID(spellID).toSpell();
|
||||
@ -1168,7 +1168,7 @@ void BattleActionProcessor::handleAfterAttackCasting(const CBattleInfoCallback &
|
||||
// each gorgon have 10% chance to kill (counted separately in H3) -> binomial distribution
|
||||
//original formula x = min(x, (gorgons_count + 9)/10);
|
||||
|
||||
double chanceToKill = attacker->valOfBonuses(BonusType::DEATH_STARE, BonusSubtypeID::deathStareGorgon) / 100.0f;
|
||||
double chanceToKill = attacker->valOfBonuses(BonusType::DEATH_STARE, BonusCustomSubtype::deathStareGorgon) / 100.0f;
|
||||
vstd::amin(chanceToKill, 1); //cap at 100%
|
||||
|
||||
std::binomial_distribution<> distribution(attacker->getCount(), chanceToKill);
|
||||
@ -1179,7 +1179,7 @@ void BattleActionProcessor::handleAfterAttackCasting(const CBattleInfoCallback &
|
||||
int maxToKill = static_cast<int>((attacker->getCount() + cap - 1) / cap); //not much more than chance * count
|
||||
vstd::amin(staredCreatures, maxToKill);
|
||||
|
||||
staredCreatures += (attacker->level() * attacker->valOfBonuses(BonusType::DEATH_STARE, BonusSubtypeID::deathStareCommander)) / defender->level();
|
||||
staredCreatures += (attacker->level() * attacker->valOfBonuses(BonusType::DEATH_STARE, BonusCustomSubtype::deathStareCommander)) / defender->level();
|
||||
if(staredCreatures)
|
||||
{
|
||||
//TODO: death stare was not originally available for multiple-hex attacks, but...
|
||||
@ -1249,9 +1249,9 @@ void BattleActionProcessor::handleAfterAttackCasting(const CBattleInfoCallback &
|
||||
else
|
||||
resurrectInfo.type = attacker->creatureId();
|
||||
|
||||
if(attacker->hasBonusOfType((BonusType::TRANSMUTATION), BonusSubtypeID::transmutationPerHealth))
|
||||
if(attacker->hasBonusOfType((BonusType::TRANSMUTATION), BonusCustomSubtype::transmutationPerHealth))
|
||||
resurrectInfo.count = std::max((defender->getCount() * defender->getMaxHealth()) / resurrectInfo.type.toCreature()->getMaxHealth(), 1u);
|
||||
else if (attacker->hasBonusOfType((BonusType::TRANSMUTATION), BonusSubtypeID::transmutationPerUnit))
|
||||
else if (attacker->hasBonusOfType((BonusType::TRANSMUTATION), BonusCustomSubtype::transmutationPerUnit))
|
||||
resurrectInfo.count = defender->getCount();
|
||||
else
|
||||
return; //wrong subtype
|
||||
@ -1273,21 +1273,21 @@ void BattleActionProcessor::handleAfterAttackCasting(const CBattleInfoCallback &
|
||||
gameHandler->sendAndApply(&fakeEvent);
|
||||
}
|
||||
|
||||
if(attacker->hasBonusOfType(BonusType::DESTRUCTION, BonusSubtypeID::destructionKillPercentage) || attacker->hasBonusOfType(BonusType::DESTRUCTION, BonusSubtypeID::destructionKillAmount))
|
||||
if(attacker->hasBonusOfType(BonusType::DESTRUCTION, BonusCustomSubtype::destructionKillPercentage) || attacker->hasBonusOfType(BonusType::DESTRUCTION, BonusCustomSubtype::destructionKillAmount))
|
||||
{
|
||||
double chanceToTrigger = 0;
|
||||
int amountToDie = 0;
|
||||
|
||||
if(attacker->hasBonusOfType(BonusType::DESTRUCTION, BonusSubtypeID::destructionKillPercentage)) //killing by percentage
|
||||
if(attacker->hasBonusOfType(BonusType::DESTRUCTION, BonusCustomSubtype::destructionKillPercentage)) //killing by percentage
|
||||
{
|
||||
chanceToTrigger = attacker->valOfBonuses(BonusType::DESTRUCTION, BonusSubtypeID::destructionKillPercentage) / 100.0f;
|
||||
int percentageToDie = attacker->getBonus(Selector::type()(BonusType::DESTRUCTION).And(Selector::subtype()(BonusSubtypeID::destructionKillPercentage)))->additionalInfo[0];
|
||||
chanceToTrigger = attacker->valOfBonuses(BonusType::DESTRUCTION, BonusCustomSubtype::destructionKillPercentage) / 100.0f;
|
||||
int percentageToDie = attacker->getBonus(Selector::type()(BonusType::DESTRUCTION).And(Selector::subtype()(BonusCustomSubtype::destructionKillPercentage)))->additionalInfo[0];
|
||||
amountToDie = static_cast<int>(defender->getCount() * percentageToDie * 0.01f);
|
||||
}
|
||||
else if(attacker->hasBonusOfType(BonusType::DESTRUCTION, BonusSubtypeID::destructionKillAmount)) //killing by count
|
||||
else if(attacker->hasBonusOfType(BonusType::DESTRUCTION, BonusCustomSubtype::destructionKillAmount)) //killing by count
|
||||
{
|
||||
chanceToTrigger = attacker->valOfBonuses(BonusType::DESTRUCTION, BonusSubtypeID::destructionKillAmount) / 100.0f;
|
||||
amountToDie = attacker->getBonus(Selector::type()(BonusType::DESTRUCTION).And(Selector::subtype()(BonusSubtypeID::destructionKillAmount)))->additionalInfo[0];
|
||||
chanceToTrigger = attacker->valOfBonuses(BonusType::DESTRUCTION, BonusCustomSubtype::destructionKillAmount) / 100.0f;
|
||||
amountToDie = attacker->getBonus(Selector::type()(BonusType::DESTRUCTION).And(Selector::subtype()(BonusCustomSubtype::destructionKillAmount)))->additionalInfo[0];
|
||||
}
|
||||
|
||||
vstd::amin(chanceToTrigger, 1); //cap trigger chance at 100%
|
||||
@ -1348,12 +1348,12 @@ int64_t BattleActionProcessor::applyBattleEffects(const CBattleInfoCallback & ba
|
||||
{
|
||||
//we can have two bonuses - one with subtype 0 and another with subtype 1
|
||||
//try to use permanent first, use only one of two
|
||||
for(const auto & subtype : { BonusSubtypeID::soulStealBattle, BonusSubtypeID::soulStealPermanent})
|
||||
for(const auto & subtype : { BonusCustomSubtype::soulStealBattle, BonusCustomSubtype::soulStealPermanent})
|
||||
{
|
||||
if(attackerState->hasBonusOfType(BonusType::SOUL_STEAL, subtype))
|
||||
{
|
||||
int64_t toHeal = bsa.killedAmount * attackerState->valOfBonuses(BonusType::SOUL_STEAL, subtype) * attackerState->getMaxHealth();
|
||||
bool permanent = subtype == BonusSubtypeID::soulStealPermanent;
|
||||
bool permanent = subtype == BonusCustomSubtype::soulStealPermanent;
|
||||
attackerState->heal(toHeal, EHealLevel::OVERHEAL, (permanent ? EHealPower::PERMANENT : EHealPower::ONE_BATTLE));
|
||||
drainedLife += toHeal;
|
||||
break;
|
||||
@ -1366,9 +1366,9 @@ int64_t BattleActionProcessor::applyBattleEffects(const CBattleInfoCallback & ba
|
||||
if(!bat.shot() &&
|
||||
!def->isClone() &&
|
||||
def->hasBonusOfType(BonusType::FIRE_SHIELD) &&
|
||||
!attackerState->hasBonusOfType(BonusType::SPELL_SCHOOL_IMMUNITY, TBonusSubtype(SpellSchool::FIRE)) &&
|
||||
!attackerState->hasBonusOfType(BonusType::NEGATIVE_EFFECTS_IMMUNITY, TBonusSubtype(SpellSchool::FIRE)) &&
|
||||
attackerState->valOfBonuses(BonusType::SPELL_DAMAGE_REDUCTION, TBonusSubtype(SpellSchool::FIRE)) < 100 &&
|
||||
!attackerState->hasBonusOfType(BonusType::SPELL_SCHOOL_IMMUNITY, BonusSubtypeID(SpellSchool::FIRE)) &&
|
||||
!attackerState->hasBonusOfType(BonusType::NEGATIVE_EFFECTS_IMMUNITY, BonusSubtypeID(SpellSchool::FIRE)) &&
|
||||
attackerState->valOfBonuses(BonusType::SPELL_DAMAGE_REDUCTION, BonusSubtypeID(SpellSchool::FIRE)) < 100 &&
|
||||
CStack::isMeleeAttackPossible(attackerState.get(), def) // attacked needs to be adjacent to defender for fire shield to trigger (e.g. Dragon Breath attack)
|
||||
)
|
||||
{
|
||||
|
@ -383,7 +383,7 @@ bool BattleFlowProcessor::tryMakeAutomaticAction(const CBattleInfoCallback & bat
|
||||
const CreatureID stackCreatureId = next->unitType()->getId();
|
||||
|
||||
if ((stackCreatureId == CreatureID::ARROW_TOWERS || stackCreatureId == CreatureID::BALLISTA)
|
||||
&& (!curOwner || gameHandler->getRandomGenerator().nextInt(99) >= curOwner->valOfBonuses(BonusType::MANUAL_CONTROL, TBonusSubtype(stackCreatureId))))
|
||||
&& (!curOwner || gameHandler->getRandomGenerator().nextInt(99) >= curOwner->valOfBonuses(BonusType::MANUAL_CONTROL, BonusSubtypeID(stackCreatureId))))
|
||||
{
|
||||
BattleAction attack;
|
||||
attack.actionType = EActionType::SHOOT;
|
||||
@ -428,7 +428,7 @@ bool BattleFlowProcessor::tryMakeAutomaticAction(const CBattleInfoCallback & bat
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!curOwner || gameHandler->getRandomGenerator().nextInt(99) >= curOwner->valOfBonuses(BonusType::MANUAL_CONTROL, TBonusSubtype(CreatureID(CreatureID::CATAPULT))))
|
||||
if (!curOwner || gameHandler->getRandomGenerator().nextInt(99) >= curOwner->valOfBonuses(BonusType::MANUAL_CONTROL, BonusSubtypeID(CreatureID(CreatureID::CATAPULT))))
|
||||
{
|
||||
BattleAction attack;
|
||||
attack.actionType = EActionType::CATAPULT;
|
||||
@ -453,7 +453,7 @@ bool BattleFlowProcessor::tryMakeAutomaticAction(const CBattleInfoCallback & bat
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!curOwner || gameHandler->getRandomGenerator().nextInt(99) >= curOwner->valOfBonuses(BonusType::MANUAL_CONTROL, TBonusSubtype(CreatureID(CreatureID::FIRST_AID_TENT))))
|
||||
if (!curOwner || gameHandler->getRandomGenerator().nextInt(99) >= curOwner->valOfBonuses(BonusType::MANUAL_CONTROL, BonusSubtypeID(CreatureID(CreatureID::FIRST_AID_TENT))))
|
||||
{
|
||||
RandomGeneratorUtil::randomShuffle(possibleStacks, gameHandler->getRandomGenerator());
|
||||
const CStack * toBeHealed = possibleStacks.front();
|
||||
@ -663,7 +663,7 @@ void BattleFlowProcessor::stackTurnTrigger(const CBattleInfoCallback & battle, c
|
||||
|
||||
if (st->hasBonusOfType(BonusType::POISON))
|
||||
{
|
||||
std::shared_ptr<const Bonus> b = st->getBonusLocalFirst(Selector::source(BonusSource::SPELL_EFFECT, TBonusSourceID(SpellID(SpellID::POISON))).And(Selector::type()(BonusType::STACK_HEALTH)));
|
||||
std::shared_ptr<const Bonus> b = st->getBonusLocalFirst(Selector::source(BonusSource::SPELL_EFFECT, BonusSourceID(SpellID(SpellID::POISON))).And(Selector::type()(BonusType::STACK_HEALTH)));
|
||||
if (b) //TODO: what if not?...
|
||||
{
|
||||
bte.val = std::max (b->val - 10, -(st->valOfBonuses(BonusType::POISON)));
|
||||
|
@ -140,11 +140,11 @@ void PlayerMessageProcessor::cheatGiveSpells(PlayerColor player, const CGHeroIns
|
||||
///Give all spells with bonus (to allow banned spells)
|
||||
GiveBonus giveBonus(GiveBonus::ETarget::HERO);
|
||||
giveBonus.id = hero->id.getNum();
|
||||
giveBonus.bonus = Bonus(BonusDuration::PERMANENT, BonusType::SPELLS_OF_LEVEL, BonusSource::OTHER, 0, TBonusSourceID());
|
||||
giveBonus.bonus = Bonus(BonusDuration::PERMANENT, BonusType::SPELLS_OF_LEVEL, BonusSource::OTHER, 0, BonusSourceID());
|
||||
//start with level 0 to skip abilities
|
||||
for (int level = 1; level <= GameConstants::SPELL_LEVELS; level++)
|
||||
{
|
||||
giveBonus.bonus.subtype = BonusSubtypeID::spellLevel(level);
|
||||
giveBonus.bonus.subtype = BonusCustomSubtype::spellLevel(level);
|
||||
gameHandler->sendAndApply(&giveBonus);
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
|
||||
void makeWarMachine()
|
||||
{
|
||||
addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::SIEGE_WEAPON, BonusSource::CREATURE_ABILITY, 1, TBonusSourceID()));
|
||||
addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::SIEGE_WEAPON, BonusSource::CREATURE_ABILITY, 1, BonusSourceID()));
|
||||
}
|
||||
|
||||
void redirectBonusesToFake()
|
||||
@ -331,7 +331,7 @@ TEST_F(BattleMatchOwnerTest, hypnotizedToSelf)
|
||||
{
|
||||
UnitFake & unit1 = unitsFake.add(BattleSide::ATTACKER);
|
||||
EXPECT_CALL(unit1, unitId()).WillRepeatedly(Return(42));
|
||||
unit1.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::HYPNOTIZED, BonusSource::CREATURE_ABILITY, 0, TBonusSourceID()));
|
||||
unit1.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::HYPNOTIZED, BonusSource::CREATURE_ABILITY, 0, BonusSourceID()));
|
||||
|
||||
setDefaultExpectations();
|
||||
|
||||
@ -362,7 +362,7 @@ TEST_F(BattleMatchOwnerTest, hypnotizedToNormalAlly)
|
||||
{
|
||||
UnitFake & unit1 = unitsFake.add(BattleSide::ATTACKER);
|
||||
EXPECT_CALL(unit1, unitId()).WillRepeatedly(Return(42));
|
||||
unit1.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::HYPNOTIZED, BonusSource::CREATURE_ABILITY, 0, TBonusSourceID()));
|
||||
unit1.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::HYPNOTIZED, BonusSource::CREATURE_ABILITY, 0, BonusSourceID()));
|
||||
|
||||
UnitFake & unit2 = unitsFake.add(BattleSide::ATTACKER);
|
||||
EXPECT_CALL(unit2, unitId()).WillRepeatedly(Return(4242));
|
||||
@ -382,7 +382,7 @@ TEST_F(BattleMatchOwnerTest, normalToHypnotizedAlly)
|
||||
EXPECT_CALL(unit1, unitId()).WillRepeatedly(Return(42));
|
||||
UnitFake & unit2 = unitsFake.add(BattleSide::ATTACKER);
|
||||
EXPECT_CALL(unit2, unitId()).WillRepeatedly(Return(4242));
|
||||
unit2.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::HYPNOTIZED, BonusSource::CREATURE_ABILITY, 0, TBonusSourceID()));
|
||||
unit2.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::HYPNOTIZED, BonusSource::CREATURE_ABILITY, 0, BonusSourceID()));
|
||||
|
||||
setDefaultExpectations();
|
||||
|
||||
@ -397,11 +397,11 @@ TEST_F(BattleMatchOwnerTest, hypnotizedToHypnotizedAlly)
|
||||
{
|
||||
UnitFake & unit1 = unitsFake.add(BattleSide::ATTACKER);
|
||||
EXPECT_CALL(unit1, unitId()).WillRepeatedly(Return(42));
|
||||
unit1.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::HYPNOTIZED, BonusSource::CREATURE_ABILITY, 0, TBonusSourceID()));
|
||||
unit1.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::HYPNOTIZED, BonusSource::CREATURE_ABILITY, 0, BonusSourceID()));
|
||||
|
||||
UnitFake & unit2 = unitsFake.add(BattleSide::ATTACKER);
|
||||
EXPECT_CALL(unit2, unitId()).WillRepeatedly(Return(4242));
|
||||
unit2.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::HYPNOTIZED, BonusSource::CREATURE_ABILITY, 0, TBonusSourceID()));
|
||||
unit2.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::HYPNOTIZED, BonusSource::CREATURE_ABILITY, 0, BonusSourceID()));
|
||||
|
||||
setDefaultExpectations();
|
||||
|
||||
@ -433,7 +433,7 @@ TEST_F(BattleMatchOwnerTest, hypnotizedToNormalEnemy)
|
||||
{
|
||||
UnitFake & unit1 = unitsFake.add(BattleSide::ATTACKER);
|
||||
EXPECT_CALL(unit1, unitId()).WillRepeatedly(Return(42));
|
||||
unit1.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::HYPNOTIZED, BonusSource::CREATURE_ABILITY, 0, TBonusSourceID()));
|
||||
unit1.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::HYPNOTIZED, BonusSource::CREATURE_ABILITY, 0, BonusSourceID()));
|
||||
|
||||
UnitFake & unit2 = unitsFake.add(BattleSide::DEFENDER);
|
||||
EXPECT_CALL(unit2, unitId()).WillRepeatedly(Return(4242));
|
||||
@ -453,7 +453,7 @@ TEST_F(BattleMatchOwnerTest, normalToHypnotizedEnemy)
|
||||
EXPECT_CALL(unit1, unitId()).WillRepeatedly(Return(42));
|
||||
UnitFake & unit2 = unitsFake.add(BattleSide::DEFENDER);
|
||||
EXPECT_CALL(unit2, unitId()).WillRepeatedly(Return(4242));
|
||||
unit2.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::HYPNOTIZED, BonusSource::CREATURE_ABILITY, 0, TBonusSourceID()));
|
||||
unit2.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::HYPNOTIZED, BonusSource::CREATURE_ABILITY, 0, BonusSourceID()));
|
||||
|
||||
setDefaultExpectations();
|
||||
|
||||
@ -468,11 +468,11 @@ TEST_F(BattleMatchOwnerTest, hypnotizedToHypnotizedEnemy)
|
||||
{
|
||||
UnitFake & unit1 = unitsFake.add(BattleSide::ATTACKER);
|
||||
EXPECT_CALL(unit1, unitId()).WillRepeatedly(Return(42));
|
||||
unit1.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::HYPNOTIZED, BonusSource::CREATURE_ABILITY, 0, TBonusSourceID()));
|
||||
unit1.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::HYPNOTIZED, BonusSource::CREATURE_ABILITY, 0, BonusSourceID()));
|
||||
|
||||
UnitFake & unit2 = unitsFake.add(BattleSide::DEFENDER);
|
||||
EXPECT_CALL(unit2, unitId()).WillRepeatedly(Return(4242));
|
||||
unit2.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::HYPNOTIZED, BonusSource::CREATURE_ABILITY, 0, TBonusSourceID()));
|
||||
unit2.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::HYPNOTIZED, BonusSource::CREATURE_ABILITY, 0, BonusSourceID()));
|
||||
|
||||
setDefaultExpectations();
|
||||
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
EXPECT_CALL(mock, getAllBonuses(_, _, _, _)).WillRepeatedly(Invoke(&bonusMock, &BonusBearerMock::getAllBonuses));
|
||||
EXPECT_CALL(mock, getTreeVersion()).WillRepeatedly(Return(1));
|
||||
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, UNIT_HEALTH, TBonusSourceID()));
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, UNIT_HEALTH, BonusSourceID()));
|
||||
|
||||
EXPECT_CALL(mock, unitBaseAmount()).WillRepeatedly(Return(UNIT_AMOUNT));
|
||||
}
|
||||
@ -239,7 +239,7 @@ TEST_F(HealthTest, singleUnitStack)
|
||||
EXPECT_CALL(mock, getAllBonuses(_, _, _, _)).WillRepeatedly(Invoke(&bonusMock, &BonusBearerMock::getAllBonuses));
|
||||
EXPECT_CALL(mock, getTreeVersion()).WillRepeatedly(Return(1));
|
||||
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, 300, TBonusSourceID()));
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, 300, BonusSourceID()));
|
||||
|
||||
EXPECT_CALL(mock, unitBaseAmount()).WillRepeatedly(Return(1));
|
||||
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
|
||||
void makeNormalCaster()
|
||||
{
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::SPELLCASTER, BonusSource::CREATURE_ABILITY, DEFAULT_SCHOOL_LEVEL, TBonusSourceID(), TBonusSubtype(SpellID(DEFAULT_SPELL_INDEX))));
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::SPELLCASTER, BonusSource::CREATURE_ABILITY, DEFAULT_SCHOOL_LEVEL, BonusSourceID(), BonusSubtypeID(SpellID(DEFAULT_SPELL_INDEX))));
|
||||
}
|
||||
};
|
||||
|
||||
@ -63,7 +63,7 @@ TEST_F(UnitStateMagicTest, initialNormal)
|
||||
{
|
||||
setDefaultExpectations();
|
||||
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::CASTS, BonusSource::CREATURE_ABILITY, 567, TBonusSourceID()));
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::CASTS, BonusSource::CREATURE_ABILITY, 567, BonusSourceID()));
|
||||
|
||||
initUnit();
|
||||
|
||||
@ -125,7 +125,7 @@ TEST_F(UnitStateMagicTest, effectPower)
|
||||
|
||||
const int32_t EFFECT_POWER = 12 * 100;
|
||||
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::CREATURE_SPELL_POWER, BonusSource::CREATURE_ABILITY, EFFECT_POWER, TBonusSourceID()));
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::CREATURE_SPELL_POWER, BonusSource::CREATURE_ABILITY, EFFECT_POWER, BonusSourceID()));
|
||||
|
||||
makeNormalCaster();
|
||||
EXPECT_EQ(subject.getEffectPower(&spellMock), 12 * DEFAULT_AMOUNT);
|
||||
@ -148,7 +148,7 @@ TEST_F(UnitStateMagicTest, enchantPower)
|
||||
|
||||
const int32_t ENCHANT_POWER = 42;
|
||||
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::CREATURE_ENCHANT_POWER, BonusSource::CREATURE_ABILITY, ENCHANT_POWER, TBonusSourceID()));
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::CREATURE_ENCHANT_POWER, BonusSource::CREATURE_ABILITY, ENCHANT_POWER, BonusSourceID()));
|
||||
|
||||
makeNormalCaster();
|
||||
|
||||
@ -171,7 +171,7 @@ TEST_F(UnitStateMagicTest, effectValue)
|
||||
|
||||
const int32_t EFFECT_VALUE = 456;
|
||||
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::SPECIFIC_SPELL_POWER, BonusSource::CREATURE_ABILITY, EFFECT_VALUE, TBonusSourceID(), TBonusSubtype(SpellID(DEFAULT_SPELL_INDEX))));
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::SPECIFIC_SPELL_POWER, BonusSource::CREATURE_ABILITY, EFFECT_VALUE, BonusSourceID(), BonusSubtypeID(SpellID(DEFAULT_SPELL_INDEX))));
|
||||
|
||||
makeNormalCaster();
|
||||
EXPECT_EQ(subject.getEffectValue(&spellMock), EFFECT_VALUE * DEFAULT_AMOUNT);
|
||||
@ -201,7 +201,7 @@ TEST_F(UnitStateMagicTest, spendMana)
|
||||
{
|
||||
setDefaultExpectations();
|
||||
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::CASTS, BonusSource::CREATURE_ABILITY, 1, TBonusSourceID()));
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::CASTS, BonusSource::CREATURE_ABILITY, 1, BonusSourceID()));
|
||||
|
||||
initUnit();
|
||||
|
||||
|
@ -51,12 +51,12 @@ public:
|
||||
|
||||
void setDefaultExpectations()
|
||||
{
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACKS_SPEED, BonusSource::CREATURE_ABILITY, DEFAULT_SPEED, TBonusSourceID()));
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACKS_SPEED, BonusSource::CREATURE_ABILITY, DEFAULT_SPEED, BonusSourceID()));
|
||||
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::CREATURE_ABILITY, DEFAULT_ATTACK, TBonusSourceID(), TBonusSubtype(PrimarySkill::ATTACK)));
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::CREATURE_ABILITY, DEFAULT_DEFENCE, TBonusSourceID(), TBonusSubtype(PrimarySkill::DEFENSE)));
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::CREATURE_ABILITY, DEFAULT_ATTACK, BonusSourceID(), BonusSubtypeID(PrimarySkill::ATTACK)));
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::CREATURE_ABILITY, DEFAULT_DEFENCE, BonusSourceID(), BonusSubtypeID(PrimarySkill::DEFENSE)));
|
||||
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, DEFAULT_HP, TBonusSourceID()));
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, DEFAULT_HP, BonusSourceID()));
|
||||
|
||||
EXPECT_CALL(infoMock, unitBaseAmount()).WillRepeatedly(Return(DEFAULT_AMOUNT));
|
||||
EXPECT_CALL(infoMock, unitType()).WillRepeatedly(Return(pikeman));
|
||||
@ -66,8 +66,8 @@ public:
|
||||
|
||||
void makeShooter(int32_t ammo)
|
||||
{
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::SHOOTER, BonusSource::CREATURE_ABILITY, 1, TBonusSourceID()));
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::SHOTS, BonusSource::CREATURE_ABILITY, ammo, TBonusSourceID()));
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::SHOOTER, BonusSource::CREATURE_ABILITY, 1, BonusSourceID()));
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::SHOTS, BonusSource::CREATURE_ABILITY, ammo, BonusSourceID()));
|
||||
}
|
||||
|
||||
void initUnit()
|
||||
@ -179,7 +179,7 @@ TEST_F(UnitStateTest, attackWithFrenzy)
|
||||
{
|
||||
setDefaultExpectations();
|
||||
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::IN_FRENZY, BonusSource::SPELL_EFFECT, 50, TBonusSourceID()));
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::IN_FRENZY, BonusSource::SPELL_EFFECT, 50, BonusSourceID()));
|
||||
|
||||
int expectedAttack = static_cast<int>(DEFAULT_ATTACK + 0.5 * DEFAULT_DEFENCE);
|
||||
|
||||
@ -191,7 +191,7 @@ TEST_F(UnitStateTest, defenceWithFrenzy)
|
||||
{
|
||||
setDefaultExpectations();
|
||||
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::IN_FRENZY, BonusSource::SPELL_EFFECT, 50, TBonusSourceID()));
|
||||
bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::IN_FRENZY, BonusSource::SPELL_EFFECT, 50, BonusSourceID()));
|
||||
|
||||
int expectedDefence = 0;
|
||||
|
||||
@ -204,7 +204,7 @@ TEST_F(UnitStateTest, additionalAttack)
|
||||
setDefaultExpectations();
|
||||
|
||||
{
|
||||
auto bonus = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::ADDITIONAL_ATTACK, BonusSource::SPELL_EFFECT, 41, TBonusSourceID());
|
||||
auto bonus = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::ADDITIONAL_ATTACK, BonusSource::SPELL_EFFECT, 41, BonusSourceID());
|
||||
|
||||
bonusMock.addNewBonus(bonus);
|
||||
}
|
||||
@ -218,7 +218,7 @@ TEST_F(UnitStateTest, additionalMeleeAttack)
|
||||
setDefaultExpectations();
|
||||
|
||||
{
|
||||
auto bonus = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::ADDITIONAL_ATTACK, BonusSource::SPELL_EFFECT, 41, TBonusSourceID());
|
||||
auto bonus = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::ADDITIONAL_ATTACK, BonusSource::SPELL_EFFECT, 41, BonusSourceID());
|
||||
bonus->effectRange = BonusLimitEffect::ONLY_MELEE_FIGHT;
|
||||
|
||||
bonusMock.addNewBonus(bonus);
|
||||
@ -233,7 +233,7 @@ TEST_F(UnitStateTest, additionalRangedAttack)
|
||||
setDefaultExpectations();
|
||||
|
||||
{
|
||||
auto bonus = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::ADDITIONAL_ATTACK, BonusSource::SPELL_EFFECT, 41, TBonusSourceID());
|
||||
auto bonus = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::ADDITIONAL_ATTACK, BonusSource::SPELL_EFFECT, 41, BonusSourceID());
|
||||
bonus->effectRange = BonusLimitEffect::ONLY_DISTANCE_FIGHT;
|
||||
|
||||
bonusMock.addNewBonus(bonus);
|
||||
@ -248,10 +248,10 @@ TEST_F(UnitStateTest, getMinDamage)
|
||||
setDefaultExpectations();
|
||||
|
||||
{
|
||||
auto bonus = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::CREATURE_DAMAGE, BonusSource::SPELL_EFFECT, 30, TBonusSourceID(), BonusSubtypeID::creatureDamageBoth);
|
||||
auto bonus = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::CREATURE_DAMAGE, BonusSource::SPELL_EFFECT, 30, BonusSourceID(), BonusCustomSubtype::creatureDamageBoth);
|
||||
bonusMock.addNewBonus(bonus);
|
||||
|
||||
bonus = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::CREATURE_DAMAGE, BonusSource::SPELL_EFFECT, -20, TBonusSourceID(), BonusSubtypeID::creatureDamageMin);
|
||||
bonus = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::CREATURE_DAMAGE, BonusSource::SPELL_EFFECT, -20, BonusSourceID(), BonusCustomSubtype::creatureDamageMin);
|
||||
bonusMock.addNewBonus(bonus);
|
||||
}
|
||||
|
||||
@ -264,10 +264,10 @@ TEST_F(UnitStateTest, getMaxDamage)
|
||||
setDefaultExpectations();
|
||||
|
||||
{
|
||||
auto bonus = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::CREATURE_DAMAGE, BonusSource::SPELL_EFFECT, 30, TBonusSourceID(), BonusSubtypeID::creatureDamageBoth);
|
||||
auto bonus = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::CREATURE_DAMAGE, BonusSource::SPELL_EFFECT, 30, BonusSourceID(), BonusCustomSubtype::creatureDamageBoth);
|
||||
bonusMock.addNewBonus(bonus);
|
||||
|
||||
bonus = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::CREATURE_DAMAGE, BonusSource::SPELL_EFFECT, -20, TBonusSourceID(), BonusSubtypeID::creatureDamageMax);
|
||||
bonus = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::CREATURE_DAMAGE, BonusSource::SPELL_EFFECT, -20, BonusSourceID(), BonusCustomSubtype::creatureDamageMax);
|
||||
bonusMock.addNewBonus(bonus);
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ TEST_F(CCreatureTest, JsonAddBonus)
|
||||
{
|
||||
JsonNode data(JsonNode::JsonType::DATA_STRUCT);
|
||||
|
||||
std::shared_ptr<Bonus> b = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::BLOCKS_RETALIATION, BonusSource::CREATURE_ABILITY, 17, TBonusSourceID(CreatureID(42)), TBonusSubtype(CreatureID(43)), BonusValueType::BASE_NUMBER);
|
||||
std::shared_ptr<Bonus> b = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::BLOCKS_RETALIATION, BonusSource::CREATURE_ABILITY, 17, BonusSourceID(CreatureID(42)), BonusSubtypeID(CreatureID(43)), BonusValueType::BASE_NUMBER);
|
||||
|
||||
JsonNode & toAdd = data["bonuses"]["toAdd"];
|
||||
|
||||
@ -133,10 +133,10 @@ TEST_F(CCreatureTest, JsonRemoveBonus)
|
||||
{
|
||||
JsonNode data(JsonNode::JsonType::DATA_STRUCT);
|
||||
|
||||
std::shared_ptr<Bonus> b1 = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::BLOCKS_RETALIATION, BonusSource::CREATURE_ABILITY, 17, TBonusSourceID(CreatureID(42)), TBonusSubtype(CreatureID(43)), BonusValueType::BASE_NUMBER);
|
||||
std::shared_ptr<Bonus> b1 = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::BLOCKS_RETALIATION, BonusSource::CREATURE_ABILITY, 17, BonusSourceID(CreatureID(42)), BonusSubtypeID(CreatureID(43)), BonusValueType::BASE_NUMBER);
|
||||
subject->addNewBonus(b1);
|
||||
|
||||
std::shared_ptr<Bonus> b2 = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::BLOCKS_RETALIATION, BonusSource::CREATURE_ABILITY, 18, TBonusSourceID(CreatureID(42)), TBonusSubtype(CreatureID(43)), BonusValueType::BASE_NUMBER);
|
||||
std::shared_ptr<Bonus> b2 = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::BLOCKS_RETALIATION, BonusSource::CREATURE_ABILITY, 18, BonusSourceID(CreatureID(42)), BonusSubtypeID(CreatureID(43)), BonusValueType::BASE_NUMBER);
|
||||
subject->addNewBonus(b2);
|
||||
|
||||
|
||||
|
@ -56,7 +56,7 @@ TEST_F(AbilityCasterTest, MagicAbilityAffectedByGenericBonus)
|
||||
{
|
||||
EXPECT_CALL(spellMock, getLevel()).WillRepeatedly(Return(1));
|
||||
|
||||
casterBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::MAGIC_SCHOOL_SKILL, BonusSource::OTHER, 2, TBonusSourceID(), TBonusSubtype(SpellSchool::ANY)));
|
||||
casterBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::MAGIC_SCHOOL_SKILL, BonusSource::OTHER, 2, BonusSourceID(), BonusSubtypeID(SpellSchool::ANY)));
|
||||
|
||||
EXPECT_CALL(actualCaster, getAllBonuses(_, _, _, _)).Times(AtLeast(1));
|
||||
EXPECT_CALL(actualCaster, getTreeVersion()).Times(AtLeast(0));
|
||||
@ -70,7 +70,7 @@ TEST_F(AbilityCasterTest, MagicAbilityIngoresSchoolBonus)
|
||||
{
|
||||
EXPECT_CALL(spellMock, getLevel()).WillRepeatedly(Return(1));
|
||||
|
||||
casterBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::MAGIC_SCHOOL_SKILL, BonusSource::OTHER, 2, TBonusSourceID(), TBonusSubtype(SpellSchool::AIR)));
|
||||
casterBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::MAGIC_SCHOOL_SKILL, BonusSource::OTHER, 2, BonusSourceID(), BonusSubtypeID(SpellSchool::AIR)));
|
||||
|
||||
EXPECT_CALL(actualCaster, getAllBonuses(_, _, _, _)).Times(AtLeast(1));
|
||||
EXPECT_CALL(actualCaster, getTreeVersion()).Times(AtLeast(0));
|
||||
|
@ -138,7 +138,7 @@ public:
|
||||
EXPECT_EQ(marker.duration, BonusDuration::N_TURNS);
|
||||
EXPECT_EQ(marker.turnsRemain, effectDuration);
|
||||
EXPECT_EQ(marker.source, BonusSource::SPELL_EFFECT);
|
||||
EXPECT_EQ(marker.sid, TBonusSourceID(SpellID(SpellID::CLONE)));
|
||||
EXPECT_EQ(marker.sid, BonusSourceID(SpellID(SpellID::CLONE)));
|
||||
}
|
||||
|
||||
void setDefaultExpectations()
|
||||
|
@ -95,7 +95,7 @@ TEST_F(DamageApplyTest, DoesDamageToAliveUnit)
|
||||
const uint32_t unitId = 42;
|
||||
auto & targetUnit = unitsFake.add(BattleSide::ATTACKER);
|
||||
|
||||
targetUnit.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, unitHP, TBonusSourceID()));
|
||||
targetUnit.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, unitHP, BonusSourceID()));
|
||||
EXPECT_CALL(targetUnit, unitId()).WillRepeatedly(Return(unitId));
|
||||
EXPECT_CALL(targetUnit, unitBaseAmount()).WillRepeatedly(Return(unitAmount));
|
||||
EXPECT_CALL(targetUnit, alive()).WillRepeatedly(Return(true));
|
||||
@ -157,7 +157,7 @@ TEST_F(DamageApplyTest, DoesDamageByPercent)
|
||||
const uint32_t unitId = 42;
|
||||
auto & targetUnit = unitsFake.add(BattleSide::ATTACKER);
|
||||
|
||||
targetUnit.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, unitHP, TBonusSourceID()));
|
||||
targetUnit.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, unitHP, BonusSourceID()));
|
||||
EXPECT_CALL(targetUnit, unitId()).WillRepeatedly(Return(unitId));
|
||||
EXPECT_CALL(targetUnit, unitBaseAmount()).WillRepeatedly(Return(unitAmount));
|
||||
EXPECT_CALL(targetUnit, getCount()).WillOnce(Return(unitAmount));
|
||||
@ -202,7 +202,7 @@ TEST_F(DamageApplyTest, DoesDamageByCount)
|
||||
const uint32_t unitId = 42;
|
||||
auto & targetUnit = unitsFake.add(BattleSide::ATTACKER);
|
||||
|
||||
targetUnit.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, unitHP, TBonusSourceID()));
|
||||
targetUnit.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, unitHP, BonusSourceID()));
|
||||
EXPECT_CALL(targetUnit, unitId()).WillRepeatedly(Return(unitId));
|
||||
EXPECT_CALL(targetUnit, unitBaseAmount()).WillRepeatedly(Return(unitAmount));
|
||||
EXPECT_CALL(targetUnit, alive()).WillRepeatedly(Return(true));
|
||||
|
@ -74,7 +74,7 @@ TEST_F(DispelTest, ApplicableToAliveUnitWithTimedEffect)
|
||||
|
||||
auto & unit = unitsFake.add(BattleSide::ATTACKER);
|
||||
|
||||
unit.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::SPELL_EFFECT, 1, TBonusSourceID(SpellID(negativeID))));
|
||||
unit.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::SPELL_EFFECT, 1, BonusSourceID(SpellID(negativeID))));
|
||||
|
||||
EXPECT_CALL(unit, isValidTarget(Eq(false))).WillOnce(Return(true));
|
||||
|
||||
@ -101,7 +101,7 @@ TEST_F(DispelTest, IgnoresOwnEffects)
|
||||
}
|
||||
auto & unit = unitsFake.add(BattleSide::ATTACKER);
|
||||
|
||||
unit.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::SPELL_EFFECT, 1, TBonusSourceID(SpellID(neutralID))));
|
||||
unit.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::SPELL_EFFECT, 1, BonusSourceID(SpellID(neutralID))));
|
||||
|
||||
EXPECT_CALL(unit, isValidTarget(Eq(false))).Times(AtMost(1)).WillRepeatedly(Return(true));
|
||||
|
||||
@ -182,23 +182,23 @@ TEST_F(DispelApplyTest, RemovesEffects)
|
||||
EXPECT_CALL(unit1, unitId()).Times(AtLeast(1)).WillRepeatedly(Return(unitIds[1]));
|
||||
|
||||
{
|
||||
auto bonus = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::SPELL_EFFECT, 1, TBonusSourceID(negativeID));
|
||||
auto bonus = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::SPELL_EFFECT, 1, BonusSourceID(negativeID));
|
||||
expectedBonus[0].emplace_back(*bonus);
|
||||
unit0.addNewBonus(bonus);
|
||||
|
||||
bonus = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::SPELL_EFFECT, 1, TBonusSourceID(negativeID));
|
||||
bonus = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::SPELL_EFFECT, 1, BonusSourceID(negativeID));
|
||||
expectedBonus[0].emplace_back(*bonus);
|
||||
unit0.addNewBonus(bonus);
|
||||
|
||||
bonus = std::make_shared<Bonus>(BonusDuration::N_TURNS, BonusType::GENERAL_ATTACK_REDUCTION, BonusSource::SPELL_EFFECT, 3, TBonusSourceID(negativeID));
|
||||
bonus = std::make_shared<Bonus>(BonusDuration::N_TURNS, BonusType::GENERAL_ATTACK_REDUCTION, BonusSource::SPELL_EFFECT, 3, BonusSourceID(negativeID));
|
||||
expectedBonus[0].emplace_back(*bonus);
|
||||
unit0.addNewBonus(bonus);
|
||||
|
||||
bonus = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::SPELL_EFFECT, 5, TBonusSourceID(positiveID));
|
||||
bonus = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::SPELL_EFFECT, 5, BonusSourceID(positiveID));
|
||||
expectedBonus[1].emplace_back(*bonus);
|
||||
unit1.addNewBonus(bonus);
|
||||
|
||||
bonus = std::make_shared<Bonus>(BonusDuration::N_TURNS, BonusType::GENERAL_ATTACK_REDUCTION, BonusSource::SPELL_EFFECT, 3, TBonusSourceID(positiveID));
|
||||
bonus = std::make_shared<Bonus>(BonusDuration::N_TURNS, BonusType::GENERAL_ATTACK_REDUCTION, BonusSource::SPELL_EFFECT, 3, BonusSourceID(positiveID));
|
||||
expectedBonus[1].emplace_back(*bonus);
|
||||
unit1.addNewBonus(bonus);
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ TEST_F(HealTest, ApplicableIfActuallyResurrects)
|
||||
EXPECT_CALL(mechanicsMock, getEffectValue()).Times(AtLeast(1)).WillRepeatedly(Return(1000));
|
||||
EXPECT_CALL(mechanicsMock, isSmart()).WillOnce(Return(false));
|
||||
|
||||
unit.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, 200, TBonusSourceID()));
|
||||
unit.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, 200, BonusSourceID()));
|
||||
unitsFake.setDefaultBonusExpectations();
|
||||
|
||||
EffectTarget target;
|
||||
@ -117,7 +117,7 @@ TEST_F(HealTest, NotApplicableIfNotEnoughCasualties)
|
||||
EXPECT_CALL(mechanicsMock, getEffectValue()).Times(AtLeast(1)).WillRepeatedly(Return(999));
|
||||
EXPECT_CALL(mechanicsMock, isSmart()).WillRepeatedly(Return(false));
|
||||
|
||||
unit.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, 200, TBonusSourceID()));
|
||||
unit.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, 200, BonusSourceID()));
|
||||
unitsFake.setDefaultBonusExpectations();
|
||||
|
||||
EffectTarget target;
|
||||
@ -143,7 +143,7 @@ TEST_F(HealTest, NotApplicableIfResurrectsLessThanRequired)
|
||||
EXPECT_CALL(mechanicsMock, getEffectValue()).Times(AtLeast(1)).WillRepeatedly(Return(999));
|
||||
EXPECT_CALL(mechanicsMock, isSmart()).WillRepeatedly(Return(false));
|
||||
|
||||
unit.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, 200, TBonusSourceID()));
|
||||
unit.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, 200, BonusSourceID()));
|
||||
unitsFake.setDefaultBonusExpectations();
|
||||
|
||||
EffectTarget target;
|
||||
@ -271,7 +271,7 @@ TEST_F(HealTest, NotApplicableIfEffectValueTooLow)
|
||||
EXPECT_CALL(unit, getTotalHealth()).WillOnce(Return(200));
|
||||
EXPECT_CALL(unit, getAvailableHealth()).WillOnce(Return(100));
|
||||
|
||||
unit.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, 200, TBonusSourceID()));
|
||||
unit.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, 200, BonusSourceID()));
|
||||
|
||||
EXPECT_CALL(mechanicsMock, getEffectValue()).Times(AtLeast(1)).WillRepeatedly(Return(199));
|
||||
|
||||
@ -348,7 +348,7 @@ TEST_P(HealApplyTest, Heals)
|
||||
EXPECT_CALL(targetUnit, unitId()).WillRepeatedly(Return(unitId));
|
||||
EXPECT_CALL(targetUnit, unitType()).WillRepeatedly(Return(pikeman));
|
||||
|
||||
targetUnit.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, unitHP, TBonusSourceID()));
|
||||
targetUnit.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, unitHP, BonusSourceID()));
|
||||
|
||||
unitsFake.setDefaultBonusExpectations();
|
||||
|
||||
|
@ -179,13 +179,13 @@ TEST_F(SacrificeApplyTest, ResurrectsTarget)
|
||||
EXPECT_CALL(mechanicsMock, applySpellBonus(_, Eq(&targetUnit))).WillOnce(ReturnArg<0>());
|
||||
EXPECT_CALL(mechanicsMock, calculateRawEffectValue(_,_)).WillOnce(Return(effectValue));
|
||||
|
||||
targetUnit.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, unitHP, TBonusSourceID()));
|
||||
targetUnit.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, unitHP, BonusSourceID()));
|
||||
|
||||
auto & victim = unitsFake.add(BattleSide::ATTACKER);
|
||||
EXPECT_CALL(victim, unitId()).Times(AtLeast(1)).WillRepeatedly(Return(victimId));
|
||||
EXPECT_CALL(victim, getCount()).Times(AtLeast(1)).WillRepeatedly(Return(victimCount));
|
||||
|
||||
victim.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, victimUnitHP, TBonusSourceID()));
|
||||
victim.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, victimUnitHP, BonusSourceID()));
|
||||
|
||||
EXPECT_CALL(*battleFake, setUnitState(Eq(unitId), _, Eq(expectedHealValue))).Times(1);
|
||||
|
||||
|
@ -244,12 +244,12 @@ TEST_P(SummonApplyTest, UpdatesOldUnit)
|
||||
setDefaultExpectaions();
|
||||
|
||||
acquired = std::make_shared<battle::UnitFake>();
|
||||
acquired->addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, unitHealth, TBonusSourceID()));
|
||||
acquired->addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, unitHealth, BonusSourceID()));
|
||||
acquired->redirectBonusesToFake();
|
||||
acquired->expectAnyBonusSystemCall();
|
||||
|
||||
auto & unit = unitsFake.add(BattleSide::ATTACKER);
|
||||
unit.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, unitHealth, TBonusSourceID()));
|
||||
unit.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, unitHealth, BonusSourceID()));
|
||||
|
||||
{
|
||||
EXPECT_CALL(unit, acquire()).WillOnce(Return(acquired));
|
||||
|
@ -71,9 +71,9 @@ protected:
|
||||
|
||||
TEST_P(TimedApplyTest, ChangesBonuses)
|
||||
{
|
||||
Bonus testBonus1(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::OTHER, 3, TBonusSourceID(), TBonusSubtype(PrimarySkill::KNOWLEDGE));
|
||||
Bonus testBonus1(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::OTHER, 3, BonusSourceID(), BonusSubtypeID(PrimarySkill::KNOWLEDGE));
|
||||
|
||||
Bonus testBonus2(BonusDuration::N_TURNS, BonusType::PRIMARY_SKILL, BonusSource::OTHER, 3, TBonusSourceID(), TBonusSubtype(PrimarySkill::KNOWLEDGE));
|
||||
Bonus testBonus2(BonusDuration::N_TURNS, BonusType::PRIMARY_SKILL, BonusSource::OTHER, 3, BonusSourceID(), BonusSubtypeID(PrimarySkill::KNOWLEDGE));
|
||||
testBonus2.turnsRemain = 4;
|
||||
|
||||
JsonNode options(JsonNode::JsonType::DATA_STRUCT);
|
||||
@ -103,7 +103,7 @@ TEST_P(TimedApplyTest, ChangesBonuses)
|
||||
for(auto & bonus : expectedBonus)
|
||||
{
|
||||
bonus.source = BonusSource::SPELL_EFFECT;
|
||||
bonus.sid = TBonusSourceID(SpellID(spellIndex));
|
||||
bonus.sid = BonusSourceID(SpellID(spellIndex));
|
||||
}
|
||||
|
||||
if(cumulative)
|
||||
|
@ -54,7 +54,7 @@ TEST_F(AbsoluteLevelConditionTest, ReceptiveNormalSpell)
|
||||
{
|
||||
setDefaultExpectations();
|
||||
|
||||
auto bonus = std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::LEVEL_SPELL_IMMUNITY, BonusSource::OTHER, 3, TBonusSourceID());
|
||||
auto bonus = std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::LEVEL_SPELL_IMMUNITY, BonusSource::OTHER, 3, BonusSourceID());
|
||||
bonus->additionalInfo = 1;
|
||||
unitBonuses.addNewBonus(bonus);
|
||||
|
||||
@ -67,7 +67,7 @@ TEST_F(AbsoluteLevelConditionTest, ReceptiveAbility)
|
||||
{
|
||||
setDefaultExpectations();
|
||||
|
||||
auto bonus = std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::LEVEL_SPELL_IMMUNITY, BonusSource::OTHER, 5, TBonusSourceID());
|
||||
auto bonus = std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::LEVEL_SPELL_IMMUNITY, BonusSource::OTHER, 5, BonusSourceID());
|
||||
bonus->additionalInfo = 1;
|
||||
unitBonuses.addNewBonus(bonus);
|
||||
|
||||
@ -79,7 +79,7 @@ TEST_F(AbsoluteLevelConditionTest, ImmuneNormalSpell)
|
||||
{
|
||||
setDefaultExpectations();
|
||||
|
||||
auto bonus = std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::LEVEL_SPELL_IMMUNITY, BonusSource::OTHER, 4, TBonusSourceID());
|
||||
auto bonus = std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::LEVEL_SPELL_IMMUNITY, BonusSource::OTHER, 4, BonusSourceID());
|
||||
bonus->additionalInfo = 1;
|
||||
unitBonuses.addNewBonus(bonus);
|
||||
|
||||
@ -90,7 +90,7 @@ TEST_F(AbsoluteLevelConditionTest, ImmuneNormalSpell)
|
||||
TEST_F(AbsoluteLevelConditionTest, IgnoresNormalCase)
|
||||
{
|
||||
setDefaultExpectations();
|
||||
auto bonus = std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::LEVEL_SPELL_IMMUNITY, BonusSource::OTHER, 4, TBonusSourceID());
|
||||
auto bonus = std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::LEVEL_SPELL_IMMUNITY, BonusSource::OTHER, 4, BonusSourceID());
|
||||
unitBonuses.addNewBonus(bonus);
|
||||
EXPECT_TRUE(subject->isReceptive(&mechanicsMock, &unitMock));
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
TEST_P(AbsoluteSpellConditionTest, ChecksAbsoluteCase)
|
||||
{
|
||||
setDefaultExpectations();
|
||||
auto bonus = std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::SPELL_IMMUNITY, BonusSource::OTHER, 4, TBonusSourceID(), TBonusSubtype(SpellID(immuneSpell)));
|
||||
auto bonus = std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::SPELL_IMMUNITY, BonusSource::OTHER, 4, BonusSourceID(), BonusSubtypeID(SpellID(immuneSpell)));
|
||||
bonus->additionalInfo = 1;
|
||||
|
||||
unitBonuses.addNewBonus(bonus);
|
||||
@ -57,7 +57,7 @@ TEST_P(AbsoluteSpellConditionTest, ChecksAbsoluteCase)
|
||||
TEST_P(AbsoluteSpellConditionTest, IgnoresNormalCase)
|
||||
{
|
||||
setDefaultExpectations();
|
||||
auto bonus = std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::SPELL_IMMUNITY, BonusSource::OTHER, 4, TBonusSourceID(), TBonusSubtype(SpellID(immuneSpell)));
|
||||
auto bonus = std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::SPELL_IMMUNITY, BonusSource::OTHER, 4, BonusSourceID(), BonusSubtypeID(SpellID(immuneSpell)));
|
||||
unitBonuses.addNewBonus(bonus);
|
||||
EXPECT_TRUE(subject->isReceptive(&mechanicsMock, &unitMock));
|
||||
}
|
||||
|
@ -42,14 +42,14 @@ TEST_F(BonusConditionTest, ImmuneByDefault)
|
||||
TEST_F(BonusConditionTest, ReceptiveIfMatchesType)
|
||||
{
|
||||
setDefaultExpectations();
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::SPELL_DAMAGE_REDUCTION, BonusSource::OTHER, 100, TBonusSourceID()));
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::SPELL_DAMAGE_REDUCTION, BonusSource::OTHER, 100, BonusSourceID()));
|
||||
EXPECT_TRUE(subject->isReceptive(&mechanicsMock, &unitMock));
|
||||
}
|
||||
|
||||
TEST_F(BonusConditionTest, ImmuneIfTypeMismatch)
|
||||
{
|
||||
setDefaultExpectations();
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::SPELL_SCHOOL_IMMUNITY, BonusSource::OTHER, 0, TBonusSourceID(), TBonusSubtype(SpellSchool::FIRE)));
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::SPELL_SCHOOL_IMMUNITY, BonusSource::OTHER, 0, BonusSourceID(), BonusSubtypeID(SpellSchool::FIRE)));
|
||||
EXPECT_FALSE(subject->isReceptive(&mechanicsMock, &unitMock));
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ TEST_P(ElementalConditionTest, ReceptiveIfNoBonus)
|
||||
TEST_P(ElementalConditionTest, ImmuneIfBonusMatches)
|
||||
{
|
||||
setDefaultExpectations();
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::SPELL_SCHOOL_IMMUNITY, BonusSource::SPELL_EFFECT, 0, TBonusSourceID(), TBonusSubtype(SpellSchool::AIR)));
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::SPELL_SCHOOL_IMMUNITY, BonusSource::SPELL_EFFECT, 0, BonusSourceID(), BonusSubtypeID(SpellSchool::AIR)));
|
||||
|
||||
EXPECT_FALSE(subject->isReceptive(&mechanicsMock, &unitMock));
|
||||
}
|
||||
@ -64,7 +64,7 @@ TEST_P(ElementalConditionTest, ImmuneIfBonusMatches)
|
||||
TEST_P(ElementalConditionTest, NotImmuneIfBonusMismatches)
|
||||
{
|
||||
setDefaultExpectations();
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::SPELL_SCHOOL_IMMUNITY, BonusSource::SPELL_EFFECT, 0, TBonusSourceID(), TBonusSubtype(SpellSchool::WATER)));
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::SPELL_SCHOOL_IMMUNITY, BonusSource::SPELL_EFFECT, 0, BonusSourceID(), BonusSubtypeID(SpellSchool::WATER)));
|
||||
|
||||
EXPECT_TRUE(subject->isReceptive(&mechanicsMock, &unitMock));
|
||||
}
|
||||
@ -72,7 +72,7 @@ TEST_P(ElementalConditionTest, NotImmuneIfBonusMismatches)
|
||||
TEST_P(ElementalConditionTest, DependsOnPositivness)
|
||||
{
|
||||
setDefaultExpectations();
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::NEGATIVE_EFFECTS_IMMUNITY, BonusSource::SPELL_EFFECT, 0, TBonusSourceID(), TBonusSubtype(SpellSchool::AIR)));
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::NEGATIVE_EFFECTS_IMMUNITY, BonusSource::SPELL_EFFECT, 0, BonusSourceID(), BonusSubtypeID(SpellSchool::AIR)));
|
||||
|
||||
EXPECT_EQ(isPositive, subject->isReceptive(&mechanicsMock, &unitMock));
|
||||
}
|
||||
@ -80,8 +80,8 @@ TEST_P(ElementalConditionTest, DependsOnPositivness)
|
||||
TEST_P(ElementalConditionTest, ImmuneIfBothBonusesPresent)
|
||||
{
|
||||
setDefaultExpectations();
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::SPELL_SCHOOL_IMMUNITY, BonusSource::SPELL_EFFECT, 0, TBonusSourceID(), TBonusSubtype(SpellSchool::AIR)));
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::NEGATIVE_EFFECTS_IMMUNITY, BonusSource::SPELL_EFFECT, 0, TBonusSourceID(), TBonusSubtype(SpellSchool::AIR)));
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::SPELL_SCHOOL_IMMUNITY, BonusSource::SPELL_EFFECT, 0, BonusSourceID(), BonusSubtypeID(SpellSchool::AIR)));
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::NEGATIVE_EFFECTS_IMMUNITY, BonusSource::SPELL_EFFECT, 0, BonusSourceID(), BonusSubtypeID(SpellSchool::AIR)));
|
||||
|
||||
EXPECT_FALSE(subject->isReceptive(&mechanicsMock, &unitMock));
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ TEST_P(ImmunityNegationConditionTest, WithHeroNegation)
|
||||
{
|
||||
setDefaultExpectations();
|
||||
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::NEGATE_ALL_NATURAL_IMMUNITIES, BonusSource::OTHER, 0, TBonusSourceID(), BonusSubtypeID::immunityEnemyHero));
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::NEGATE_ALL_NATURAL_IMMUNITIES, BonusSource::OTHER, 0, BonusSourceID(), BonusCustomSubtype::immunityEnemyHero));
|
||||
|
||||
EXPECT_EQ(isMagicalEffect, subject->isReceptive(&mechanicsMock, &unitMock));
|
||||
}
|
||||
@ -66,7 +66,7 @@ TEST_P(ImmunityNegationConditionTest, WithBattleWideNegation)
|
||||
{
|
||||
setDefaultExpectations();
|
||||
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::NEGATE_ALL_NATURAL_IMMUNITIES, BonusSource::OTHER, 0, TBonusSourceID(), BonusSubtypeID::immunityBattleWide));
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::NEGATE_ALL_NATURAL_IMMUNITIES, BonusSource::OTHER, 0, BonusSourceID(), BonusCustomSubtype::immunityBattleWide));
|
||||
|
||||
//This should return if ownerMatches, because anyone should cast onto owner's stacks, but not on enemyStacks
|
||||
EXPECT_EQ(ownerMatches && isMagicalEffect, subject->isReceptive(&mechanicsMock, &unitMock));
|
||||
|
@ -56,7 +56,7 @@ TEST_P(NormalLevelConditionTest, DefaultForNormal)
|
||||
TEST_P(NormalLevelConditionTest, ReceptiveNormal)
|
||||
{
|
||||
setDefaultExpectations();
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::LEVEL_SPELL_IMMUNITY, BonusSource::OTHER, 3, TBonusSourceID()));
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::LEVEL_SPELL_IMMUNITY, BonusSource::OTHER, 3, BonusSourceID()));
|
||||
if(isMagicalEffect)
|
||||
EXPECT_CALL(mechanicsMock, getSpellLevel()).Times(AtLeast(1)).WillRepeatedly(Return(4));
|
||||
EXPECT_TRUE(subject->isReceptive(&mechanicsMock, &unitMock));
|
||||
@ -66,7 +66,7 @@ TEST_P(NormalLevelConditionTest, ReceptiveNormal)
|
||||
TEST_P(NormalLevelConditionTest, ReceptiveAbility)
|
||||
{
|
||||
setDefaultExpectations();
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::LEVEL_SPELL_IMMUNITY, BonusSource::OTHER, 5, TBonusSourceID()));
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::LEVEL_SPELL_IMMUNITY, BonusSource::OTHER, 5, BonusSourceID()));
|
||||
if(isMagicalEffect)
|
||||
EXPECT_CALL(mechanicsMock, getSpellLevel()).Times(AtLeast(1)).WillRepeatedly(Return(0));
|
||||
EXPECT_TRUE(subject->isReceptive(&mechanicsMock, &unitMock));
|
||||
@ -75,7 +75,7 @@ TEST_P(NormalLevelConditionTest, ReceptiveAbility)
|
||||
TEST_P(NormalLevelConditionTest, ImmuneNormal)
|
||||
{
|
||||
setDefaultExpectations();
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::LEVEL_SPELL_IMMUNITY, BonusSource::OTHER, 4, TBonusSourceID()));
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::LEVEL_SPELL_IMMUNITY, BonusSource::OTHER, 4, BonusSourceID()));
|
||||
if(isMagicalEffect)
|
||||
EXPECT_CALL(mechanicsMock, getSpellLevel()).Times(AtLeast(1)).WillRepeatedly(Return(2));
|
||||
EXPECT_EQ(!isMagicalEffect, subject->isReceptive(&mechanicsMock, &unitMock));
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
TEST_P(NormalSpellConditionTest, ChecksAbsoluteCase)
|
||||
{
|
||||
setDefaultExpectations();
|
||||
auto bonus = std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::SPELL_IMMUNITY, BonusSource::OTHER, 4, TBonusSourceID(), TBonusSubtype(SpellID(immuneSpell)));
|
||||
auto bonus = std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::SPELL_IMMUNITY, BonusSource::OTHER, 4, BonusSourceID(), BonusSubtypeID(SpellID(immuneSpell)));
|
||||
bonus->additionalInfo = 1;
|
||||
|
||||
unitBonuses.addNewBonus(bonus);
|
||||
@ -57,7 +57,7 @@ TEST_P(NormalSpellConditionTest, ChecksAbsoluteCase)
|
||||
TEST_P(NormalSpellConditionTest, ChecksNormalCase)
|
||||
{
|
||||
setDefaultExpectations();
|
||||
auto bonus = std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::SPELL_IMMUNITY, BonusSource::OTHER, 4, TBonusSourceID(), TBonusSubtype(SpellID(immuneSpell)));
|
||||
auto bonus = std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::SPELL_IMMUNITY, BonusSource::OTHER, 4, BonusSourceID(), BonusSubtypeID(SpellID(immuneSpell)));
|
||||
unitBonuses.addNewBonus(bonus);
|
||||
if(immuneSpell == castSpell)
|
||||
EXPECT_FALSE(subject->isReceptive(&mechanicsMock, &unitMock));
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
EXPECT_CALL(unitMock, getTreeVersion()).Times(AtLeast(0));
|
||||
EXPECT_CALL(mechanicsMock, isPositiveSpell()).WillRepeatedly(Return(isPositive));
|
||||
if(hasBonus)
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::RECEPTIVE, BonusSource::OTHER, 0, TBonusSourceID()));
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::RECEPTIVE, BonusSource::OTHER, 0, BonusSourceID()));
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -45,7 +45,7 @@ TEST_F(SpellEffectConditionTest, ImmuneByDefault)
|
||||
TEST_F(SpellEffectConditionTest, ReceptiveIfHasEffectFromDesiredSpell)
|
||||
{
|
||||
setDefaultExpectations();
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::STACK_HEALTH, BonusSource::SPELL_EFFECT, 3, TBonusSourceID(SpellID(SpellID::AGE))));
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::STACK_HEALTH, BonusSource::SPELL_EFFECT, 3, BonusSourceID(SpellID(SpellID::AGE))));
|
||||
|
||||
EXPECT_TRUE(subject->isReceptive(&mechanicsMock, &unitMock));
|
||||
}
|
||||
@ -53,14 +53,14 @@ TEST_F(SpellEffectConditionTest, ReceptiveIfHasEffectFromDesiredSpell)
|
||||
TEST_F(SpellEffectConditionTest, ImmuneIfHasEffectFromOtherSpell)
|
||||
{
|
||||
setDefaultExpectations();
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::STACK_HEALTH, BonusSource::SPELL_EFFECT, 3, TBonusSourceID(SpellID(SpellID::AIR_SHIELD))));
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::STACK_HEALTH, BonusSource::SPELL_EFFECT, 3, BonusSourceID(SpellID(SpellID::AIR_SHIELD))));
|
||||
EXPECT_FALSE(subject->isReceptive(&mechanicsMock, &unitMock));
|
||||
}
|
||||
|
||||
TEST_F(SpellEffectConditionTest, ImmuneIfHasNoSpellEffects)
|
||||
{
|
||||
setDefaultExpectations();
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, 3, TBonusSourceID()));
|
||||
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, 3, BonusSourceID()));
|
||||
EXPECT_FALSE(subject->isReceptive(&mechanicsMock, &unitMock));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user