Fixes Opportunist accumulating stat changes (#4168)

* Fixes Opportunist accumulating stat changes

* move memset to TurnValuesCleanUp

* Update test/battle/ability/opportunist.c

---------

Co-authored-by: Bassoonian <iasperbassoonian@gmail.com>
This commit is contained in:
Alex 2024-02-10 18:18:29 +01:00 committed by GitHub
parent 8b871b7eb4
commit b7d77099b5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 0 deletions

View file

@ -4914,6 +4914,7 @@ static void TurnValuesCleanUp(bool8 var0)
else
{
memset(&gProtectStructs[i], 0, sizeof(struct ProtectStruct));
memset(&gQueuedStatBoosts[i], 0, sizeof(gQueuedStatBoosts));
if (gDisableStructs[i].isFirstTurn)
gDisableStructs[i].isFirstTurn--;

View file

@ -101,6 +101,24 @@ DOUBLE_BATTLE_TEST("Opportunist raises Attack only once when partner has Intimid
}
}
SINGLE_BATTLE_TEST("Opportunist does not accumulate opposing mon's stat changes")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_ESPATHRA) { Ability(ABILITY_OPPORTUNIST); }
} WHEN {
TURN { MOVE(player, MOVE_SWORDS_DANCE); }
TURN { MOVE(player, MOVE_SWORDS_DANCE); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_SWORDS_DANCE, player);
ABILITY_POPUP(opponent, ABILITY_OPPORTUNIST);
ANIMATION(ANIM_TYPE_MOVE, MOVE_SWORDS_DANCE, player);
ABILITY_POPUP(opponent, ABILITY_OPPORTUNIST);
} THEN {
EXPECT_EQ(opponent->statStages[STAT_ATK], DEFAULT_STAT_STAGE + 4);
}
}
TO_DO_BATTLE_TEST("Opportunist doesn't copy ally stat increases");
TO_DO_BATTLE_TEST("Opportunist doesn't copy foe stat increases gained via Opportunist");
TO_DO_BATTLE_TEST("Opportunist copies foe stat increased gained via Swagger and Flatter");