Fixed replacementattack not being complete.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-03-22 10:30:45 +01:00
parent a7b87ab4f8
commit 970ca8ddd5
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
3 changed files with 9 additions and 1 deletions

View File

@ -34,5 +34,7 @@ CreatureLib::Battling::MiscLibrary::ReplacementAttack(Creature* user, CreatureIn
auto sideTarget = 0; auto sideTarget = 0;
if (user->GetBattleSide()->GetSideIndex() == 0) if (user->GetBattleSide()->GetSideIndex() == 0)
sideTarget = 1; sideTarget = 1;
return new AttackTurnChoice(user, GetReplacementAttack(), target); auto side = user->GetBattle()->GetSides()[sideTarget];
auto random_mon = side->GetRandomCreatureIndex();
return new AttackTurnChoice(user, GetReplacementAttack(), CreatureIndex(side->GetSideIndex(), random_mon));
} }

View File

@ -68,3 +68,7 @@ void BattleSide::GetActiveScripts(std::vector<ScriptWrapper>& scripts) {
scripts.emplace_back(&_volatile); scripts.emplace_back(&_volatile);
_battle->GetActiveScripts(scripts); _battle->GetActiveScripts(scripts);
} }
uint8_t BattleSide::GetRandomCreatureIndex() {
// TODO: Consider adding parameter to only get index for available creatures.
return _battle->GetRandom()->Get(_creaturesPerSide);
}

View File

@ -79,6 +79,8 @@ namespace CreatureLib::Battling {
bool HasFled() { return _hasFled; } bool HasFled() { return _hasFled; }
void MarkAsFled() { _hasFled = true; } void MarkAsFled() { _hasFled = true; }
uint8_t GetRandomCreatureIndex();
}; };
} }