1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

Merge pull request #4437 from IvanSavenko/battle_sides

Unified handling of battle sides ID's
This commit is contained in:
Ivan Savenko
2024-08-14 18:37:05 +03:00
committed by GitHub
95 changed files with 601 additions and 568 deletions

View File

@@ -2114,7 +2114,7 @@ void BattleResultAccepted::applyGs(CGameState * gs) const
res.hero->removeBonusesRecursive(Bonus::OneBattle);
}
if(winnerSide != 2)
if(winnerSide != BattleSide::NONE)
{
// Grow up growing artifacts
const auto hero = heroResult[winnerSide].hero;
@@ -2135,10 +2135,10 @@ void BattleResultAccepted::applyGs(CGameState * gs) const
if(VLC->settings()->getBoolean(EGameSettings::MODULE_STACK_EXPERIENCE))
{
if(heroResult[0].army)
heroResult[0].army->giveStackExp(heroResult[0].exp);
if(heroResult[1].army)
heroResult[1].army->giveStackExp(heroResult[1].exp);
if(heroResult[BattleSide::ATTACKER].army)
heroResult[BattleSide::ATTACKER].army->giveStackExp(heroResult[BattleSide::ATTACKER].exp);
if(heroResult[BattleSide::DEFENDER].army)
heroResult[BattleSide::DEFENDER].army->giveStackExp(heroResult[BattleSide::DEFENDER].exp);
CBonusSystemNode::treeHasChanged();
}
@@ -2242,19 +2242,14 @@ void StartAction::applyGs(CGameState *gs)
else
{
if(ba.actionType == EActionType::HERO_SPELL)
gs->getBattle(battleID)->sides[ba.side].usedSpellsHistory.push_back(ba.spell);
gs->getBattle(battleID)->getSide(ba.side).usedSpellsHistory.push_back(ba.spell);
}
}
void BattleSpellCast::applyGs(CGameState * gs) const
{
if(castByHero)
{
if(side < 2)
{
gs->getBattle(battleID)->sides[side].castSpellsCount++;
}
}
if(castByHero && side != BattleSide::NONE)
gs->getBattle(battleID)->getSide(side).castSpellsCount++;
}
void SetStackEffect::applyGs(CGameState *gs)
@@ -2388,7 +2383,7 @@ void BattleSetStackProperty::applyGs(CGameState * gs) const
}
case ENCHANTER_COUNTER:
{
auto & counter = gs->getBattle(battleID)->sides[gs->getBattle(battleID)->whatSide(stack->unitOwner())].enchanterCounter;
auto & counter = gs->getBattle(battleID)->getSide(gs->getBattle(battleID)->whatSide(stack->unitOwner())).enchanterCounter;
if(absolute)
counter = val;
else