Skip to content

Commit

Permalink
Fix remaining tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Pawkkie committed Jan 18, 2025
1 parent 6a5ae80 commit 6ca405c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/battle_ai_switch_items.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ static bool32 ShouldSwitchIfHasBadOdds(u32 battler)
&& gBattleMons[battler].hp >= gBattleMons[battler].maxHP / 4)))
{
// 50% chance to stay in regardless
if (RandomPercentage(RNG_AI_SWITCH_HASBADODDS, 50) || AI_DATA->aiSwitchPredictionInProgress)
return TRUE;
if (RandomPercentage(RNG_AI_SWITCH_HASBADODDS, 50) && !AI_DATA->aiSwitchPredictionInProgress)
return FALSE;

// Switch mon out
return SetSwitchinAndSwitch(battler, PARTY_SIZE);
Expand All @@ -217,8 +217,8 @@ static bool32 ShouldSwitchIfHasBadOdds(u32 battler)
return FALSE;

// 50% chance to stay in regardless
if (RandomPercentage(RNG_AI_SWITCH_HASBADODDS, 50) || AI_DATA->aiSwitchPredictionInProgress)
return TRUE;
if (RandomPercentage(RNG_AI_SWITCH_HASBADODDS, 50) && !AI_DATA->aiSwitchPredictionInProgress)
return FALSE;

// Switch mon out
return SetSwitchinAndSwitch(battler, PARTY_SIZE);
Expand Down
1 change: 1 addition & 0 deletions test/battle/ai/ai_flag_predict_switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ AI_SINGLE_BATTLE_TEST("AI_FLAG_PREDICT_SWITCH: AI will score against predicted i

AI_SINGLE_BATTLE_TEST("AI_FLAG_PREDICT_SWITCH: AI would switch out in predicted-incoming-mon scenario")
{
PASSES_RANDOMLY(5, 10, RNG_AI_SWITCH_HASBADODDS);
GIVEN {
AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_TRY_TO_FAINT | AI_FLAG_CHECK_VIABILITY | AI_FLAG_OMNISCIENT | AI_FLAG_SMART_SWITCHING | AI_FLAG_SMART_MON_CHOICES);
PLAYER(SPECIES_TYRANITAR) { Moves(MOVE_CRUNCH, MOVE_SPORE); }
Expand Down
2 changes: 1 addition & 1 deletion test/battle/ai/ai_switching.c
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ AI_SINGLE_BATTLE_TEST("AI_FLAG_SMART_SWITCHING: AI will switch out if player's m
GIVEN {
ASSUME(GetMoveType(MOVE_SOLAR_BEAM) == TYPE_GRASS);
AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_CHECK_VIABILITY | AI_FLAG_TRY_TO_FAINT | AI_FLAG_SMART_SWITCHING);
PLAYER(SPECIES_BELLOSSOM) { Moves(MOVE_SOLAR_BEAM); }
PLAYER(SPECIES_BELLOSSOM) { Moves(MOVE_SOLAR_BEAM, MOVE_THUNDERBOLT); }
OPPONENT(SPECIES_ZIGZAGOON) { Moves(MOVE_TACKLE); }
OPPONENT(SPECIES_AZUMARILL) { Moves(MOVE_PLAY_ROUGH); Ability(ABILITY_SAP_SIPPER); }
} WHEN {
Expand Down

0 comments on commit 6ca405c

Please sign in to comment.