diff --git a/AI/BattleAI/AttackPossibility.cpp b/AI/BattleAI/AttackPossibility.cpp index 8098e4668..cd69c2a58 100644 --- a/AI/BattleAI/AttackPossibility.cpp +++ b/AI/BattleAI/AttackPossibility.cpp @@ -51,11 +51,11 @@ int64_t AttackPossibility::calculateDamageReduce( // FIXME: provide distance info for Jousting bonus auto enemyDamageBeforeAttack = cb.battleEstimateDamage(defender, attacker, 0); - auto enemiesKilled = damageDealt / defender->MaxHealth() + (damageDealt % defender->MaxHealth() >= defender->getFirstHPleft() ? 1 : 0); + auto enemiesKilled = damageDealt / defender->getMaxHealth() + (damageDealt % defender->getMaxHealth() >= defender->getFirstHPleft() ? 1 : 0); auto enemyDamage = averageDmg(enemyDamageBeforeAttack.damage); auto damagePerEnemy = enemyDamage / (double)defender->getCount(); - return (int64_t)(damagePerEnemy * (enemiesKilled * KILL_BOUNTY + damageDealt * HEALTH_BOUNTY / (double)defender->MaxHealth())); + return (int64_t)(damagePerEnemy * (enemiesKilled * KILL_BOUNTY + damageDealt * HEALTH_BOUNTY / (double)defender->getMaxHealth())); } int64_t AttackPossibility::evaluateBlockedShootersDmg(const BattleAttackInfo & attackInfo, BattleHex hex, const HypotheticBattle & state) diff --git a/AI/BattleAI/BattleAI.cpp b/AI/BattleAI/BattleAI.cpp index 2073b0a58..1b9930b02 100644 --- a/AI/BattleAI/BattleAI.cpp +++ b/AI/BattleAI/BattleAI.cpp @@ -109,7 +109,7 @@ BattleAction CBattleAI::activeStack( const CStack * stack ) auto healingTargets = cb->battleGetStacks(CBattleInfoEssentials::ONLY_MINE); std::map woundHpToStack; for(auto stack : healingTargets) - if(auto woundHp = stack->MaxHealth() - stack->getFirstHPleft()) + if(auto woundHp = stack->getMaxHealth() - stack->getFirstHPleft()) woundHpToStack[woundHp] = stack; if(woundHpToStack.empty()) return BattleAction::makeDefend(stack); diff --git a/AI/BattleAI/StackWithBonuses.h b/AI/BattleAI/StackWithBonuses.h index 8e46908fc..87743ba6b 100644 --- a/AI/BattleAI/StackWithBonuses.h +++ b/AI/BattleAI/StackWithBonuses.h @@ -14,7 +14,7 @@ #include #include -#include "../../lib/bonuses/HeroBonus.h" +#include "../../lib/bonuses/Bonus.h" #include "../../lib/battle/BattleProxy.h" #include "../../lib/battle/CUnitState.h" diff --git a/client/windows/CCastleInterface.cpp b/client/windows/CCastleInterface.cpp index cae21474f..2edc887d6 100644 --- a/client/windows/CCastleInterface.cpp +++ b/client/windows/CCastleInterface.cpp @@ -1703,7 +1703,7 @@ CFortScreen::RecruitArea::RecruitArea(int posX, int posY, const CGTownInstance * sizes.y+=21; values.push_back(std::make_shared(sizes, CGI->generaltexth->allTexts[199], CGI->generaltexth->fcommands[2], getMyCreature()->getMinDamage(false), getMyCreature()->getMaxDamage(false))); sizes.y+=20; - values.push_back(std::make_shared(sizes, CGI->generaltexth->allTexts[388], CGI->generaltexth->fcommands[3], getMyCreature()->MaxHealth())); + values.push_back(std::make_shared(sizes, CGI->generaltexth->allTexts[388], CGI->generaltexth->fcommands[3], getMyCreature()->getMaxHealth())); sizes.y+=21; values.push_back(std::make_shared(sizes, CGI->generaltexth->allTexts[193], CGI->generaltexth->fcommands[4], getMyCreature()->valOfBonuses(Bonus::STACKS_SPEED))); sizes.y+=20; diff --git a/client/windows/CCreatureWindow.cpp b/client/windows/CCreatureWindow.cpp index 4c15912d1..38f87aeb5 100644 --- a/client/windows/CCreatureWindow.cpp +++ b/client/windows/CCreatureWindow.cpp @@ -525,7 +525,7 @@ CStackWindow::MainSection::MainSection(CStackWindow * owner, int yOffset, bool s addStatLabel(EStat::ATTACK, parent->info->creature->getAttack(battleStack->isShooter()), battleStack->getAttack(battleStack->isShooter())); addStatLabel(EStat::DEFENCE, parent->info->creature->getDefense(battleStack->isShooter()), battleStack->getDefense(battleStack->isShooter())); addStatLabel(EStat::DAMAGE, parent->info->stackNode->getMinDamage(battleStack->isShooter()) * dmgMultiply, battleStack->getMaxDamage(battleStack->isShooter()) * dmgMultiply); - addStatLabel(EStat::HEALTH, parent->info->creature->MaxHealth(), battleStack->MaxHealth()); + addStatLabel(EStat::HEALTH, parent->info->creature->getMaxHealth(), battleStack->getMaxHealth()); addStatLabel(EStat::SPEED, parent->info->creature->Speed(), battleStack->Speed()); if(battleStack->isShooter()) @@ -545,7 +545,7 @@ CStackWindow::MainSection::MainSection(CStackWindow * owner, int yOffset, bool s addStatLabel(EStat::ATTACK, parent->info->creature->getAttack(shooter), parent->info->stackNode->getAttack(shooter)); addStatLabel(EStat::DEFENCE, parent->info->creature->getDefense(shooter), parent->info->stackNode->getDefense(shooter)); addStatLabel(EStat::DAMAGE, parent->info->stackNode->getMinDamage(shooter) * dmgMultiply, parent->info->stackNode->getMaxDamage(shooter) * dmgMultiply); - addStatLabel(EStat::HEALTH, parent->info->creature->MaxHealth(), parent->info->stackNode->MaxHealth()); + addStatLabel(EStat::HEALTH, parent->info->creature->getMaxHealth(), parent->info->stackNode->getMaxHealth()); addStatLabel(EStat::SPEED, parent->info->creature->Speed(), parent->info->stackNode->Speed()); if(shooter) diff --git a/client/windows/CCreatureWindow.h b/client/windows/CCreatureWindow.h index daf1a2911..114ba977e 100644 --- a/client/windows/CCreatureWindow.h +++ b/client/windows/CCreatureWindow.h @@ -9,7 +9,7 @@ */ #pragma once -#include "../../lib/bonuses/HeroBonus.h" +#include "../../lib/bonuses/Bonus.h" #include "../widgets/MiscWidgets.h" #include "CWindowObject.h" diff --git a/client/windows/CHeroWindow.h b/client/windows/CHeroWindow.h index fe91cc67d..704254317 100644 --- a/client/windows/CHeroWindow.h +++ b/client/windows/CHeroWindow.h @@ -11,7 +11,7 @@ #include -#include "../../lib/bonuses/HeroBonus.h" +#include "../../lib/bonuses/Bonus.h" #include "../../lib/bonuses/IBonusBearer.h" #include "../widgets/CWindowWithArtifacts.h" #include "../widgets/CGarrisonInt.h" diff --git a/client/windows/GUIClasses.cpp b/client/windows/GUIClasses.cpp index 659d6658e..2e9e31d68 100644 --- a/client/windows/GUIClasses.cpp +++ b/client/windows/GUIClasses.cpp @@ -61,7 +61,7 @@ #include "../lib/CStopWatch.h" #include "../lib/CTownHandler.h" #include "../lib/GameConstants.h" -#include "../lib/bonuses/HeroBonus.h" +#include "../lib/bonuses/Bonus.h" #include "../lib/mapping/CMap.h" #include "../lib/NetPacksBase.h" #include "../lib/StartInfo.h" diff --git a/cmake_modules/VCMI_lib.cmake b/cmake_modules/VCMI_lib.cmake index ada7791b4..1748df5e5 100644 --- a/cmake_modules/VCMI_lib.cmake +++ b/cmake_modules/VCMI_lib.cmake @@ -27,12 +27,12 @@ macro(add_main_lib TARGET_NAME LIBRARY_TYPE) ${MAIN_LIB_DIR}/battle/SiegeInfo.cpp ${MAIN_LIB_DIR}/battle/Unit.cpp + ${MAIN_LIB_DIR}/bonuses/Bonus.cpp ${MAIN_LIB_DIR}/bonuses/BonusList.cpp ${MAIN_LIB_DIR}/bonuses/BonusParams.cpp ${MAIN_LIB_DIR}/bonuses/BonusSelector.cpp ${MAIN_LIB_DIR}/bonuses/CBonusProxy.cpp ${MAIN_LIB_DIR}/bonuses/CBonusSystemNode.cpp - ${MAIN_LIB_DIR}/bonuses/HeroBonus.cpp ${MAIN_LIB_DIR}/bonuses/IBonusBearer.cpp ${MAIN_LIB_DIR}/bonuses/Limiters.cpp ${MAIN_LIB_DIR}/bonuses/Propagators.cpp @@ -310,12 +310,12 @@ macro(add_main_lib TARGET_NAME LIBRARY_TYPE) ${MAIN_LIB_DIR}/battle/SiegeInfo.h ${MAIN_LIB_DIR}/battle/Unit.h + ${MAIN_LIB_DIR}/bonuses/Bonus.h ${MAIN_LIB_DIR}/bonuses/BonusList.h ${MAIN_LIB_DIR}/bonuses/BonusParams.h ${MAIN_LIB_DIR}/bonuses/BonusSelector.h ${MAIN_LIB_DIR}/bonuses/CBonusProxy.h ${MAIN_LIB_DIR}/bonuses/CBonusSystemNode.h - ${MAIN_LIB_DIR}/bonuses/HeroBonus.h ${MAIN_LIB_DIR}/bonuses/IBonusBearer.h ${MAIN_LIB_DIR}/bonuses/Limiters.h ${MAIN_LIB_DIR}/bonuses/Propagators.h diff --git a/include/vcmi/Creature.h b/include/vcmi/Creature.h index 5074b459b..df77332ce 100644 --- a/include/vcmi/Creature.h +++ b/include/vcmi/Creature.h @@ -24,7 +24,7 @@ class DLL_LINKAGE ACreature: public AFactionMember public: bool isLiving() const; //non-undead, non-non living or alive ui32 Speed(int turn = 0, bool useBind = false) const; //get speed (in moving tiles) of creature with all modificators - ui32 MaxHealth() const; //get max HP of stack with all modifiers + virtual ui32 getMaxHealth() const; //get max HP of stack with all modifiers }; template @@ -46,8 +46,6 @@ public: virtual std::string getNamePluralTextID() const = 0; virtual std::string getNameSingularTextID() const = 0; - virtual uint32_t getMaxHealth() const = 0; - virtual int32_t getAdvMapAmountMin() const = 0; virtual int32_t getAdvMapAmountMax() const = 0; virtual int32_t getAIValue() const = 0; diff --git a/include/vcmi/FactionMember.h b/include/vcmi/FactionMember.h index 394641917..2a6d54da7 100644 --- a/include/vcmi/FactionMember.h +++ b/include/vcmi/FactionMember.h @@ -53,10 +53,15 @@ public: */ int getPrimSkillLevel(PrimarySkill::PrimarySkill id) const; /** - Returns morale or luck of creature or hero. + Returns morale of creature or hero. Taking absolute bonuses into account. + For now, uses range [-3, +3] */ - int MoraleVal() const; //range [-3, +3] - int LuckVal() const; //range [-3, +3] + int MoraleVal() const; + /** + Returns luck of creature or hero. Taking absolute bonuses into account. + For now, uses range [-3, +3] + */ + int LuckVal() const; /** Returns total value of all morale bonuses and sets bonusList as a pointer to the list of selected bonuses. @param bonusList is the out param it's list of all selected bonuses diff --git a/lib/BasicTypes.cpp b/lib/BasicTypes.cpp index 4a4215e0b..0e4f9cb6b 100644 --- a/lib/BasicTypes.cpp +++ b/lib/BasicTypes.cpp @@ -13,7 +13,7 @@ #include "VCMI_Lib.h" #include "GameConstants.h" #include "bonuses/BonusList.h" -#include "bonuses/HeroBonus.h" +#include "bonuses/Bonus.h" #include "bonuses/IBonusBearer.h" #include @@ -139,7 +139,7 @@ int AFactionMember::LuckVal() const return LuckValAndBonusList(tmp); } -ui32 ACreature::MaxHealth() const +ui32 ACreature::getMaxHealth() const { const std::string cachingStr = "type_STACK_HEALTH"; static const auto selector = Selector::type()(Bonus::STACK_HEALTH); diff --git a/lib/BattleFieldHandler.h b/lib/BattleFieldHandler.h index 6f4ae3855..a3e550485 100644 --- a/lib/BattleFieldHandler.h +++ b/lib/BattleFieldHandler.h @@ -11,7 +11,7 @@ #include #include -#include "bonuses/HeroBonus.h" +#include "bonuses/Bonus.h" #include "GameConstants.h" #include "IHandlerBase.h" #include "battle/BattleHex.h" diff --git a/lib/CArtHandler.h b/lib/CArtHandler.h index 3d5f26ea4..8edaee22d 100644 --- a/lib/CArtHandler.h +++ b/lib/CArtHandler.h @@ -12,7 +12,7 @@ #include #include -#include "bonuses/HeroBonus.h" +#include "bonuses/Bonus.h" #include "bonuses/CBonusSystemNode.h" #include "GameConstants.h" #include "IHandlerBase.h" diff --git a/lib/CBonusTypeHandler.h b/lib/CBonusTypeHandler.h index 68856d91b..6ef36eabe 100644 --- a/lib/CBonusTypeHandler.h +++ b/lib/CBonusTypeHandler.h @@ -12,7 +12,7 @@ #include "IBonusTypeHandler.h" #include "IHandlerBase.h" -#include "bonuses/HeroBonus.h" +#include "bonuses/Bonus.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/CCreatureHandler.cpp b/lib/CCreatureHandler.cpp index d9ca7df75..adcb440d9 100644 --- a/lib/CCreatureHandler.cpp +++ b/lib/CCreatureHandler.cpp @@ -71,11 +71,6 @@ const IBonusBearer * CCreature::getBonusBearer() const return this; } -uint32_t CCreature::getMaxHealth() const -{ - return MaxHealth(); -} - int32_t CCreature::getAdvMapAmountMin() const { return ammMin; diff --git a/lib/CCreatureHandler.h b/lib/CCreatureHandler.h index 5d285eda4..e503364a6 100644 --- a/lib/CCreatureHandler.h +++ b/lib/CCreatureHandler.h @@ -9,7 +9,7 @@ */ #pragma once -#include "bonuses/HeroBonus.h" +#include "bonuses/Bonus.h" #include "bonuses/CBonusSystemNode.h" #include "ConstTransitivePtr.h" #include "ResourceSet.h" @@ -169,7 +169,6 @@ public: void registerIcons(const IconRegistar & cb) const override; CreatureID getId() const override; virtual const IBonusBearer * getBonusBearer() const override; - uint32_t getMaxHealth() const override; int32_t getAdvMapAmountMin() const override; int32_t getAdvMapAmountMax() const override; diff --git a/lib/CCreatureSet.h b/lib/CCreatureSet.h index 75af51012..7f883282b 100644 --- a/lib/CCreatureSet.h +++ b/lib/CCreatureSet.h @@ -9,7 +9,7 @@ */ #pragma once -#include "bonuses/HeroBonus.h" +#include "bonuses/Bonus.h" #include "bonuses/CBonusSystemNode.h" #include "GameConstants.h" #include "CArtHandler.h" diff --git a/lib/CGameState.h b/lib/CGameState.h index 8dec18bbf..2e2adc317 100644 --- a/lib/CGameState.h +++ b/lib/CGameState.h @@ -12,7 +12,7 @@ #include "CCreatureHandler.h" #include "VCMI_Lib.h" -#include "bonuses/HeroBonus.h" +#include "bonuses/Bonus.h" #include "CCreatureSet.h" #include "ConstTransitivePtr.h" #include "IGameCallback.h" diff --git a/lib/CHeroHandler.h b/lib/CHeroHandler.h index 7d2712d2f..7ccdf224c 100644 --- a/lib/CHeroHandler.h +++ b/lib/CHeroHandler.h @@ -16,7 +16,7 @@ #include "../lib/ConstTransitivePtr.h" #include "GameConstants.h" -#include "bonuses/HeroBonus.h" +#include "bonuses/Bonus.h" #include "bonuses/BonusList.h" #include "IHandlerBase.h" diff --git a/lib/CPathfinder.h b/lib/CPathfinder.h index 03ab5a407..c31ddfa73 100644 --- a/lib/CPathfinder.h +++ b/lib/CPathfinder.h @@ -11,7 +11,7 @@ #include "VCMI_Lib.h" #include "IGameCallback.h" -#include "bonuses/HeroBonus.h" +#include "bonuses/Bonus.h" #include "int3.h" #include diff --git a/lib/CPlayerState.h b/lib/CPlayerState.h index b735bcc43..96cbbaa49 100644 --- a/lib/CPlayerState.h +++ b/lib/CPlayerState.h @@ -12,7 +12,7 @@ #include #include -#include "bonuses/HeroBonus.h" +#include "bonuses/Bonus.h" #include "bonuses/CBonusSystemNode.h" #include "ResourceSet.h" diff --git a/lib/CSkillHandler.h b/lib/CSkillHandler.h index 8c3e89d85..457707e42 100644 --- a/lib/CSkillHandler.h +++ b/lib/CSkillHandler.h @@ -12,7 +12,7 @@ #include #include -#include "../lib/bonuses/HeroBonus.h" +#include "../lib/bonuses/Bonus.h" #include "GameConstants.h" #include "IHandlerBase.h" diff --git a/lib/CStack.cpp b/lib/CStack.cpp index 98c3502d9..1c2f5fa30 100644 --- a/lib/CStack.cpp +++ b/lib/CStack.cpp @@ -230,7 +230,7 @@ void CStack::prepareAttacked(BattleStackAttacked & bsa, vstd::RNG & rand, const { customState->casts.use(); bsa.flags |= BattleStackAttacked::REBIRTH; - int64_t toHeal = customState->MaxHealth() * resurrectedCount; + int64_t toHeal = customState->getMaxHealth() * resurrectedCount; //TODO: add one-battle rebirth? customState->heal(toHeal, EHealLevel::RESURRECT, EHealPower::PERMANENT); customState->counterAttacks.use(customState->counterAttacks.available()); @@ -308,7 +308,7 @@ std::string CStack::getName() const bool CStack::canBeHealed() const { - return getFirstHPleft() < static_cast(MaxHealth()) && isValidTarget() && !hasBonusOfType(Bonus::SIEGE_WEAPON); + return getFirstHPleft() < static_cast(getMaxHealth()) && isValidTarget() && !hasBonusOfType(Bonus::SIEGE_WEAPON); } bool CStack::isOnNativeTerrain() const diff --git a/lib/CStack.h b/lib/CStack.h index 939d8191a..a2f944a8d 100644 --- a/lib/CStack.h +++ b/lib/CStack.h @@ -10,7 +10,7 @@ #pragma once #include "JsonNode.h" -#include "bonuses/HeroBonus.h" +#include "bonuses/Bonus.h" #include "bonuses/CBonusSystemNode.h" #include "CCreatureHandler.h" //todo: remove #include "battle/BattleHex.h" diff --git a/lib/CTownHandler.cpp b/lib/CTownHandler.cpp index 40c34c8ab..bf0934bf1 100644 --- a/lib/CTownHandler.cpp +++ b/lib/CTownHandler.cpp @@ -23,7 +23,7 @@ #include "filesystem/Filesystem.h" #include "mapObjects/CObjectClassesHandler.h" #include "mapObjects/CObjectHandler.h" -#include "bonuses/HeroBonus.h" +#include "bonuses/Bonus.h" #include "bonuses/Propagators.h" #include "ResourceSet.h" diff --git a/lib/CTownHandler.h b/lib/CTownHandler.h index 16c263419..09e2bce7d 100644 --- a/lib/CTownHandler.h +++ b/lib/CTownHandler.h @@ -19,7 +19,7 @@ #include "IHandlerBase.h" #include "LogicalExpression.h" #include "battle/BattleHex.h" -#include "bonuses/HeroBonus.h" +#include "bonuses/Bonus.h" #include "bonuses/BonusList.h" #include "Point.h" diff --git a/lib/JsonNode.cpp b/lib/JsonNode.cpp index 36f81dd89..ca1f01f05 100644 --- a/lib/JsonNode.cpp +++ b/lib/JsonNode.cpp @@ -14,7 +14,7 @@ #include "ScopeGuard.h" #include "bonuses/BonusParams.h" -#include "bonuses/HeroBonus.h" +#include "bonuses/Bonus.h" #include "bonuses/Limiters.h" #include "bonuses/Propagators.h" #include "bonuses/Updaters.h" diff --git a/lib/VCMI_lib.cbp b/lib/VCMI_lib.cbp index bb73fdb73..2195ab5c5 100644 --- a/lib/VCMI_lib.cbp +++ b/lib/VCMI_lib.cbp @@ -245,7 +245,7 @@ - + diff --git a/lib/VCMI_lib.vcxproj b/lib/VCMI_lib.vcxproj index 21c719f94..2598a5bc6 100644 --- a/lib/VCMI_lib.vcxproj +++ b/lib/VCMI_lib.vcxproj @@ -426,7 +426,7 @@ - + diff --git a/lib/VCMI_lib.vcxproj.filters b/lib/VCMI_lib.vcxproj.filters index fa768e169..a8541fe9d 100644 --- a/lib/VCMI_lib.vcxproj.filters +++ b/lib/VCMI_lib.vcxproj.filters @@ -407,7 +407,7 @@ Header Files - + Header Files diff --git a/lib/battle/BattleInfo.h b/lib/battle/BattleInfo.h index 4d3dcc08b..7d1361fee 100644 --- a/lib/battle/BattleInfo.h +++ b/lib/battle/BattleInfo.h @@ -9,7 +9,7 @@ */ #pragma once #include "../int3.h" -#include "../bonuses/HeroBonus.h" +#include "../bonuses/Bonus.h" #include "../bonuses/CBonusSystemNode.h" #include "CBattleInfoCallback.h" #include "IBattleState.h" diff --git a/lib/battle/CUnitState.cpp b/lib/battle/CUnitState.cpp index 52ac0c379..dc0873be5 100644 --- a/lib/battle/CUnitState.cpp +++ b/lib/battle/CUnitState.cpp @@ -179,7 +179,7 @@ void CHealth::init() { reset(); fullUnits = owner->unitBaseAmount() > 1 ? owner->unitBaseAmount() - 1 : 0; - firstHPleft = owner->unitBaseAmount() > 0 ? owner->MaxHealth() : 0; + firstHPleft = owner->unitBaseAmount() > 0 ? owner->getMaxHealth() : 0; } void CHealth::addResurrected(int32_t amount) @@ -190,12 +190,12 @@ void CHealth::addResurrected(int32_t amount) int64_t CHealth::available() const { - return static_cast(firstHPleft) + owner->MaxHealth() * fullUnits; + return static_cast(firstHPleft) + owner->getMaxHealth() * fullUnits; } int64_t CHealth::total() const { - return static_cast(owner->MaxHealth()) * owner->unitBaseAmount(); + return static_cast(owner->getMaxHealth()) * owner->unitBaseAmount(); } void CHealth::damage(int64_t & amount) @@ -230,7 +230,7 @@ void CHealth::damage(int64_t & amount) void CHealth::heal(int64_t & amount, EHealLevel level, EHealPower power) { - const int32_t unitHealth = owner->MaxHealth(); + const int32_t unitHealth = owner->getMaxHealth(); const int32_t oldCount = getCount(); int64_t maxHeal = std::numeric_limits::max(); @@ -267,7 +267,7 @@ void CHealth::heal(int64_t & amount, EHealLevel level, EHealPower power) void CHealth::setFromTotal(const int64_t totalHealth) { - const int32_t unitHealth = owner->MaxHealth(); + const int32_t unitHealth = owner->getMaxHealth(); firstHPleft = totalHealth % unitHealth; fullUnits = static_cast(totalHealth / unitHealth); @@ -306,7 +306,7 @@ void CHealth::takeResurrected() { int64_t totalHealth = available(); - totalHealth -= resurrected * owner->MaxHealth(); + totalHealth -= resurrected * owner->getMaxHealth(); vstd::amax(totalHealth, 0); setFromTotal(totalHealth); resurrected = 0; diff --git a/lib/battle/DamageCalculator.cpp b/lib/battle/DamageCalculator.cpp index f40ceb147..dd5957d56 100644 --- a/lib/battle/DamageCalculator.cpp +++ b/lib/battle/DamageCalculator.cpp @@ -13,7 +13,7 @@ #include "CBattleInfoCallback.h" #include "Unit.h" -#include "../bonuses/HeroBonus.h" +#include "../bonuses/Bonus.h" #include "../mapObjects/CGTownInstance.h" #include "../spells/CSpellHandler.h" #include "../GameSettings.h" @@ -464,7 +464,7 @@ int64_t DamageCalculator::getCasualties(int64_t damageDealt) const return 0; int64_t damageLeft = damageDealt - info.defender->getFirstHPleft(); - int64_t killsLeft = damageLeft / info.defender->MaxHealth(); + int64_t killsLeft = damageLeft / info.defender->getMaxHealth(); return 1 + killsLeft; } diff --git a/lib/battle/Unit.h b/lib/battle/Unit.h index c4e1cb785..2318f1214 100644 --- a/lib/battle/Unit.h +++ b/lib/battle/Unit.h @@ -13,7 +13,7 @@ #include #include -#include "../bonuses/HeroBonus.h" +#include "../bonuses/Bonus.h" #include "../bonuses/IBonusBearer.h" #include "IUnitInfo.h" diff --git a/lib/bonuses/HeroBonus.cpp b/lib/bonuses/Bonus.cpp similarity index 95% rename from lib/bonuses/HeroBonus.cpp rename to lib/bonuses/Bonus.cpp index 1dc3ed7e3..5786dcb15 100644 --- a/lib/bonuses/HeroBonus.cpp +++ b/lib/bonuses/Bonus.cpp @@ -1,5 +1,5 @@ /* - * HeroBonus.cpp, part of VCMI engine + * Bonus.cpp, part of VCMI engine * * Authors: listed in file AUTHORS in main folder * @@ -9,7 +9,7 @@ */ #include "StdInc.h" -#include "HeroBonus.h" +#include "Bonus.h" #include "CBonusSystemNode.h" #include "Limiters.h" #include "Updaters.h" @@ -86,7 +86,8 @@ const std::set deprecatedBonusSet = { "BLOCK_MORALE", "BLOCK_LUCK", "SELF_MORALE", - "SELF_LUCK" + "SELF_LUCK", + "DIRECT_DAMAGE_IMMUNITY" }; //This constructor should be placed here to avoid side effects diff --git a/lib/bonuses/HeroBonus.h b/lib/bonuses/Bonus.h similarity index 97% rename from lib/bonuses/HeroBonus.h rename to lib/bonuses/Bonus.h index 40198b07e..274a1db8d 100644 --- a/lib/bonuses/HeroBonus.h +++ b/lib/bonuses/Bonus.h @@ -1,5 +1,5 @@ /* - * HeroBonus.h, part of VCMI engine + * Bonus.h, part of VCMI engine * * Authors: listed in file AUTHORS in main folder * diff --git a/lib/bonuses/BonusList.h b/lib/bonuses/BonusList.h index 10073e9ee..d219e8a97 100644 --- a/lib/bonuses/BonusList.h +++ b/lib/bonuses/BonusList.h @@ -9,7 +9,7 @@ */ #pragma once -#include "HeroBonus.h" +#include "Bonus.h" #include "BonusSelector.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/bonuses/BonusParams.h b/lib/bonuses/BonusParams.h index aeb5cd150..93ec69a12 100644 --- a/lib/bonuses/BonusParams.h +++ b/lib/bonuses/BonusParams.h @@ -9,7 +9,7 @@ */ #pragma once -#include "HeroBonus.h" +#include "Bonus.h" #include "../GameConstants.h" #include "../JsonNode.h" diff --git a/lib/bonuses/BonusSelector.h b/lib/bonuses/BonusSelector.h index 7d01feddf..54507edfd 100644 --- a/lib/bonuses/BonusSelector.h +++ b/lib/bonuses/BonusSelector.h @@ -10,7 +10,7 @@ #pragma once -#include "HeroBonus.h" +#include "Bonus.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/bonuses/CBonusProxy.h b/lib/bonuses/CBonusProxy.h index 5bed7962e..bff9ace49 100644 --- a/lib/bonuses/CBonusProxy.h +++ b/lib/bonuses/CBonusProxy.h @@ -10,7 +10,7 @@ #pragma once -#include "HeroBonus.h" +#include "Bonus.h" #include "BonusSelector.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/bonuses/IBonusBearer.h b/lib/bonuses/IBonusBearer.h index 4253356e3..219bc1c49 100644 --- a/lib/bonuses/IBonusBearer.h +++ b/lib/bonuses/IBonusBearer.h @@ -1,6 +1,6 @@ /* - * CBonusSystemNode.h, part of VCMI engine + * IBonusBearer.h, part of VCMI engine * * Authors: listed in file AUTHORS in main folder * @@ -10,7 +10,7 @@ */ #pragma once -#include "HeroBonus.h" +#include "Bonus.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/bonuses/Limiters.h b/lib/bonuses/Limiters.h index 90232ec63..3f4190db6 100644 --- a/lib/bonuses/Limiters.h +++ b/lib/bonuses/Limiters.h @@ -8,7 +8,7 @@ * */ -#include "HeroBonus.h" +#include "Bonus.h" #include "battle/BattleHex.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/bonuses/Propagators.h b/lib/bonuses/Propagators.h index 8cf4757bb..833e6b73d 100644 --- a/lib/bonuses/Propagators.h +++ b/lib/bonuses/Propagators.h @@ -9,7 +9,7 @@ */ #pragma once -#include "HeroBonus.h" +#include "Bonus.h" #include "CBonusSystemNode.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/bonuses/Updaters.h b/lib/bonuses/Updaters.h index 10523951c..0df11382c 100644 --- a/lib/bonuses/Updaters.h +++ b/lib/bonuses/Updaters.h @@ -9,7 +9,7 @@ */ #pragma once -#include "HeroBonus.h" +#include "Bonus.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/mapObjects/CGHeroInstance.cpp b/lib/mapObjects/CGHeroInstance.cpp index 773a6842d..55e53a65d 100644 --- a/lib/mapObjects/CGHeroInstance.cpp +++ b/lib/mapObjects/CGHeroInstance.cpp @@ -849,12 +849,12 @@ CStackBasicDescriptor CGHeroInstance::calculateNecromancy (const BattleResult &b } } // calculate number of creatures raised - low level units contribute at 50% rate - const double raisedUnitHealth = VLC->creh->objects[creatureTypeRaised]->MaxHealth(); + const double raisedUnitHealth = VLC->creh->objects[creatureTypeRaised]->getMaxHealth(); double raisedUnits = 0; for(const auto & casualty : casualties) { const CCreature * c = VLC->creh->objects[casualty.first]; - double raisedFromCasualty = std::min(c->MaxHealth() / raisedUnitHealth, 1.0) * casualty.second * necromancySkill; + double raisedFromCasualty = std::min(c->getMaxHealth() / raisedUnitHealth, 1.0) * casualty.second * necromancySkill; if(c->getLevel() < requiredCasualtyLevel) raisedFromCasualty *= 0.5; raisedUnits += raisedFromCasualty; diff --git a/lib/mapObjects/CGTownInstance.cpp b/lib/mapObjects/CGTownInstance.cpp index 4d01c0cc6..0b7ea8aaf 100644 --- a/lib/mapObjects/CGTownInstance.cpp +++ b/lib/mapObjects/CGTownInstance.cpp @@ -12,7 +12,7 @@ #include "CGTownInstance.h" #include "CObjectClassesHandler.h" #include "../spells/CSpellHandler.h" -#include "../bonuses/HeroBonus.h" +#include "../bonuses/Bonus.h" #include "../battle/IBattleInfoCallback.h" #include "../NetPacks.h" #include "../CConfigHandler.h" diff --git a/lib/mapObjects/CObjectHandler.h b/lib/mapObjects/CObjectHandler.h index 32b8f0def..bd7abe374 100644 --- a/lib/mapObjects/CObjectHandler.h +++ b/lib/mapObjects/CObjectHandler.h @@ -15,7 +15,7 @@ #include "../NetPacksBase.h" #include "../ResourceSet.h" -#include "../bonuses/HeroBonus.h" +#include "../bonuses/Bonus.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/mapObjects/MiscObjects.cpp b/lib/mapObjects/MiscObjects.cpp index 13c656d88..fe9910252 100644 --- a/lib/mapObjects/MiscObjects.cpp +++ b/lib/mapObjects/MiscObjects.cpp @@ -1895,7 +1895,7 @@ void CGSirens::onHeroVisit( const CGHeroInstance * h ) const if(drown) { cb->changeStackCount(StackLocation(h, i->first), -drown); - xp += drown * i->second->type->MaxHealth(); + xp += drown * i->second->type->getMaxHealth(); } } diff --git a/lib/serializer/JsonUpdater.cpp b/lib/serializer/JsonUpdater.cpp index e7edc7d75..c0dce33a6 100644 --- a/lib/serializer/JsonUpdater.cpp +++ b/lib/serializer/JsonUpdater.cpp @@ -13,7 +13,7 @@ #include "../JsonNode.h" #include "../bonuses/CBonusSystemNode.h" -#include "../bonuses/HeroBonus.h" +#include "../bonuses/Bonus.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/spells/BonusCaster.cpp b/lib/spells/BonusCaster.cpp index 9bfe6e04b..76a84f0b7 100644 --- a/lib/spells/BonusCaster.cpp +++ b/lib/spells/BonusCaster.cpp @@ -15,7 +15,7 @@ #include "../NetPacksBase.h" #include "../battle/Unit.h" -#include "../bonuses/HeroBonus.h" +#include "../bonuses/Bonus.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/spells/CSpellHandler.h b/lib/spells/CSpellHandler.h index 166387972..347e81a35 100644 --- a/lib/spells/CSpellHandler.h +++ b/lib/spells/CSpellHandler.h @@ -19,7 +19,7 @@ #include "../int3.h" #include "../GameConstants.h" #include "../battle/BattleHex.h" -#include "../bonuses/HeroBonus.h" +#include "../bonuses/Bonus.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/spells/ISpellMechanics.cpp b/lib/spells/ISpellMechanics.cpp index dadbbaed3..46f91c916 100644 --- a/lib/spells/ISpellMechanics.cpp +++ b/lib/spells/ISpellMechanics.cpp @@ -14,7 +14,7 @@ #include "../CRandomGenerator.h" #include "../VCMI_Lib.h" -#include "../bonuses/HeroBonus.h" +#include "../bonuses/Bonus.h" #include "../battle/CBattleInfoCallback.h" #include "../battle/IBattleState.h" #include "../battle/Unit.h" diff --git a/lib/spells/ISpellMechanics.h b/lib/spells/ISpellMechanics.h index 0fc1dfe75..1ed959fc3 100644 --- a/lib/spells/ISpellMechanics.h +++ b/lib/spells/ISpellMechanics.h @@ -16,7 +16,7 @@ #include "../battle/Destination.h" #include "../int3.h" #include "../GameConstants.h" -#include "../bonuses/HeroBonus.h" +#include "../bonuses/Bonus.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/spells/effects/Damage.cpp b/lib/spells/effects/Damage.cpp index ccc727ec7..bc3650e04 100644 --- a/lib/spells/effects/Damage.cpp +++ b/lib/spells/effects/Damage.cpp @@ -107,11 +107,11 @@ int64_t Damage::damageForTarget(size_t targetIndex, const Mechanics * m, const b if(killByPercentage) { int64_t amountToKill = target->getCount() * m->getEffectValue() / 100; - baseDamage = amountToKill * target->MaxHealth(); + baseDamage = amountToKill * target->getMaxHealth(); } else if(killByCount) { - baseDamage = m->getEffectValue() * target->MaxHealth(); + baseDamage = m->getEffectValue() * target->getMaxHealth(); } else { diff --git a/lib/spells/effects/Heal.cpp b/lib/spells/effects/Heal.cpp index daeb9ff7d..13373f5d2 100644 --- a/lib/spells/effects/Heal.cpp +++ b/lib/spells/effects/Heal.cpp @@ -59,7 +59,7 @@ bool Heal::isValidTarget(const Mechanics * m, const battle::Unit * unit) const if(minFullUnits > 0) { auto hpGained = std::min(m->getEffectValue(), injuries); - if(hpGained < minFullUnits * unit->MaxHealth()) + if(hpGained < minFullUnits * unit->getMaxHealth()) return false; } diff --git a/lib/spells/effects/Sacrifice.cpp b/lib/spells/effects/Sacrifice.cpp index 1e6404434..7beb1a201 100644 --- a/lib/spells/effects/Sacrifice.cpp +++ b/lib/spells/effects/Sacrifice.cpp @@ -152,7 +152,7 @@ EffectTarget Sacrifice::transformTarget(const Mechanics * m, const Target & aimP int64_t Sacrifice::calculateHealEffectValue(const Mechanics * m, const battle::Unit * victim) { - return (m->getEffectPower() + victim->MaxHealth() + m->calculateRawEffectValue(0, 1)) * victim->getCount(); + return (m->getEffectPower() + victim->getMaxHealth() + m->calculateRawEffectValue(0, 1)) * victim->getCount(); } diff --git a/lib/spells/effects/Summon.cpp b/lib/spells/effects/Summon.cpp index f0c62e41e..d64740882 100644 --- a/lib/spells/effects/Summon.cpp +++ b/lib/spells/effects/Summon.cpp @@ -94,7 +94,7 @@ void Summon::apply(ServerCallback * server, const Mechanics * m, const EffectTar { const battle::Unit * summoned = dest.unitValue; std::shared_ptr state = summoned->acquire(); - int64_t healthValue = (summonByHealth ? valueWithBonus : (valueWithBonus * summoned->MaxHealth())); + int64_t healthValue = (summonByHealth ? valueWithBonus : (valueWithBonus * summoned->getMaxHealth())); state->heal(healthValue, EHealLevel::OVERHEAL, (permanent ? EHealPower::PERMANENT : EHealPower::ONE_BATTLE)); pack.changedStacks.emplace_back(summoned->unitId(), UnitChanges::EOperation::RESET_STATE); state->save(pack.changedStacks.back().data); diff --git a/scripting/lua/api/Artifact.cpp b/scripting/lua/api/Artifact.cpp index 12a7418c7..bc4d5d68d 100644 --- a/scripting/lua/api/Artifact.cpp +++ b/scripting/lua/api/Artifact.cpp @@ -15,7 +15,7 @@ #include "../LuaStack.h" #include "../LuaCallWrapper.h" -#include "../../../lib/bonuses/HeroBonus.h" +#include "../../../lib/bonuses/Bonus.h" #include "../../../lib/bonuses/IBonusBearer.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/scripting/lua/api/BonusSystem.cpp b/scripting/lua/api/BonusSystem.cpp index 5addfa063..611748a2b 100644 --- a/scripting/lua/api/BonusSystem.cpp +++ b/scripting/lua/api/BonusSystem.cpp @@ -12,7 +12,7 @@ #include "BonusSystem.h" #include "../../../lib/bonuses/BonusList.h" -#include "../../../lib/bonuses/HeroBonus.h" +#include "../../../lib/bonuses/Bonus.h" #include "../../../lib/bonuses/IBonusBearer.h" #include "Registry.h" diff --git a/scripting/lua/api/Creature.cpp b/scripting/lua/api/Creature.cpp index 6eca6a79a..64c13c38b 100644 --- a/scripting/lua/api/Creature.cpp +++ b/scripting/lua/api/Creature.cpp @@ -15,7 +15,7 @@ #include "../LuaStack.h" #include "../LuaCallWrapper.h" -#include "../../../lib/bonuses/HeroBonus.h" +#include "../../../lib/bonuses/Bonus.h" #include "../../../lib/bonuses/IBonusBearer.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 6b2fda983..63c5126c6 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -1158,7 +1158,7 @@ int64_t CGameHandler::applyBattleEffects(BattleAttack & bat, std::shared_ptrhasBonusOfType(Bonus::SOUL_STEAL, subtype)) { - int64_t toHeal = bsa.killedAmount * attackerState->valOfBonuses(Bonus::SOUL_STEAL, subtype) * attackerState->MaxHealth(); + int64_t toHeal = bsa.killedAmount * attackerState->valOfBonuses(Bonus::SOUL_STEAL, subtype) * attackerState->getMaxHealth(); attackerState->heal(toHeal, EHealLevel::OVERHEAL, ((subtype == 0) ? EHealPower::ONE_BATTLE : EHealPower::PERMANENT)); drainedLife += toHeal; break; @@ -6003,7 +6003,7 @@ void CGameHandler::handleAfterAttackCasting(bool ranged, const CStack * attacker resurrectInfo.type = attacker->creatureId(); if(attacker->hasBonusOfType((Bonus::TRANSMUTATION), 0)) - resurrectInfo.count = std::max((defender->getCount() * defender->MaxHealth()) / resurrectInfo.type.toCreature()->MaxHealth(), 1u); + resurrectInfo.count = std::max((defender->getCount() * defender->getMaxHealth()) / resurrectInfo.type.toCreature()->getMaxHealth(), 1u); else if (attacker->hasBonusOfType((Bonus::TRANSMUTATION), 1)) resurrectInfo.count = defender->getCount(); else @@ -6044,7 +6044,7 @@ void CGameHandler::handleAfterAttackCasting(bool ranged, const CStack * attacker BattleStackAttacked bsa; bsa.attackerID = -1; bsa.stackAttacked = defender->unitId(); - bsa.damageAmount = amountToDie * defender->MaxHealth(); + bsa.damageAmount = amountToDie * defender->getMaxHealth(); bsa.flags = BattleStackAttacked::SPELL_EFFECT; bsa.spellID = SpellID::SLAYER; defender->prepareAttacked(bsa, getRandomGenerator()); @@ -6488,7 +6488,7 @@ void CGameHandler::runBattle() bte.stackID = stack->unitId(); bte.effect = Bonus::HP_REGENERATION; - const int32_t lostHealth = stack->MaxHealth() - stack->getFirstHPleft(); + const int32_t lostHealth = stack->getMaxHealth() - stack->getFirstHPleft(); if(stack->hasBonusOfType(Bonus::HP_REGENERATION)) bte.val = std::min(lostHealth, stack->valOfBonuses(Bonus::HP_REGENERATION)); diff --git a/test/battle/CHealthTest.cpp b/test/battle/CHealthTest.cpp index f7168cf0f..25ca2ae9c 100644 --- a/test/battle/CHealthTest.cpp +++ b/test/battle/CHealthTest.cpp @@ -42,7 +42,7 @@ public: static void checkTotal(const CHealth & health, const UnitMock & mock) { - EXPECT_EQ(health.total(), mock.MaxHealth() * mock.unitBaseAmount()); + EXPECT_EQ(health.total(), mock.getMaxHealth() * mock.unitBaseAmount()); } static void checkEmptyHealth(const CHealth & health, const UnitMock & mock) @@ -58,9 +58,9 @@ static void checkFullHealth(const CHealth & health, const UnitMock & mock) { checkTotal(health, mock); EXPECT_EQ(health.getCount(), mock.unitBaseAmount()); - EXPECT_EQ(health.getFirstHPleft(), mock.MaxHealth()); + EXPECT_EQ(health.getFirstHPleft(), mock.getMaxHealth()); EXPECT_EQ(health.getResurrected(), 0); - EXPECT_EQ(health.available(), mock.MaxHealth() * mock.unitBaseAmount()); + EXPECT_EQ(health.available(), mock.getMaxHealth() * mock.unitBaseAmount()); } static void checkDamage(CHealth & health, const int64_t initialDamage, const int64_t expectedDamage) @@ -110,7 +110,7 @@ TEST_F(HealthTest, damage) checkNormalDamage(health, 0); checkFullHealth(health, mock); - checkNormalDamage(health, mock.MaxHealth() - 1); + checkNormalDamage(health, mock.getMaxHealth() - 1); EXPECT_EQ(health.getCount(), UNIT_AMOUNT); EXPECT_EQ(health.getFirstHPleft(), 1); EXPECT_EQ(health.getResurrected(), 0); diff --git a/test/game/CGameStateTest.cpp b/test/game/CGameStateTest.cpp index c377d9590..66479a8d6 100644 --- a/test/game/CGameStateTest.cpp +++ b/test/game/CGameStateTest.cpp @@ -374,7 +374,7 @@ TEST_F(CGameStateTest, battleResurrection) ASSERT_NE(unit, nullptr); - int64_t damage = unit->MaxHealth() + 1; + int64_t damage = unit->getMaxHealth() + 1; unit->damage(damage); diff --git a/test/mock/mock_BonusBearer.h b/test/mock/mock_BonusBearer.h index 340421e67..d7f314c8d 100644 --- a/test/mock/mock_BonusBearer.h +++ b/test/mock/mock_BonusBearer.h @@ -11,7 +11,7 @@ #pragma once #include "../../lib/bonuses/BonusList.h" -#include "../../lib/bonuses/HeroBonus.h" +#include "../../lib/bonuses/Bonus.h" #include "../../lib/bonuses/IBonusBearer.h" diff --git a/test/scripting/ScriptFixture.h b/test/scripting/ScriptFixture.h index e733f71ab..4d7b780bc 100644 --- a/test/scripting/ScriptFixture.h +++ b/test/scripting/ScriptFixture.h @@ -18,7 +18,7 @@ #include "../../lib/ScriptHandler.h" #include "../../lib/NetPacksBase.h" #include "../../lib/battle/CBattleInfoCallback.h" -#include "../../lib/bonuses/HeroBonus.h" +#include "../../lib/bonuses/Bonus.h" #include "../mock/mock_ServerCallback.h" #include "../mock/mock_IBattleInfoCallback.h"