From 5700fb08a2960d3d29ca511f4dd26ca6211aec84 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sun, 14 Dec 2025 14:14:27 -0300 Subject: [PATCH] Expanded `B_SANDSTORM_SPDEF_BOOST` test (#8532) --- include/constants/generational_changes.h | 2 +- src/battle_util.c | 2 +- test/battle/weather/sandstorm.c | 13 ++++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/include/constants/generational_changes.h b/include/constants/generational_changes.h index 57627c79bb..1926c5b1f7 100644 --- a/include/constants/generational_changes.h +++ b/include/constants/generational_changes.h @@ -179,7 +179,7 @@ F(IRON_BALL, ironBall, (u32, GEN_COUNT - 1)) /* TODO: use in tests */ \ /* Weather settings */ \ F(ABILITY_WEATHER, abilityWeather, (u32, GEN_COUNT - 1)) \ - F(SANDSTORM_SPDEF_BOOST, sandstormSpDefBoost, (u32, GEN_COUNT - 1)) /* TODO: use in tests */ \ + F(SANDSTORM_SPDEF_BOOST, sandstormSpDefBoost, (u32, GEN_COUNT - 1)) \ F(OVERWORLD_FOG, overworldFog, (u32, GEN_COUNT - 1)) /* TODO: use in tests */ \ F(OVERWORLD_SNOW, overworldSnow, (u32, GEN_COUNT - 1)) /* TODO: use in tests */ \ F(SNOW_WARNING, snowWarning, (u32, GEN_COUNT - 1)) \ diff --git a/src/battle_util.c b/src/battle_util.c index 3b8bd261b7..f4393e2aaa 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -8046,7 +8046,7 @@ static inline u32 CalcDefenseStat(struct DamageContext *ctx) } // sandstorm sp.def boost for rock types - if (B_SANDSTORM_SPDEF_BOOST >= GEN_4 && IS_BATTLER_OF_TYPE(battlerDef, TYPE_ROCK) && IsBattlerWeatherAffected(battlerDef, B_WEATHER_SANDSTORM) && !usesDefStat) + if (GetConfig(CONFIG_SANDSTORM_SPDEF_BOOST) >= GEN_4 && IS_BATTLER_OF_TYPE(battlerDef, TYPE_ROCK) && IsBattlerWeatherAffected(battlerDef, B_WEATHER_SANDSTORM) && !usesDefStat) modifier = uq4_12_multiply_half_down(modifier, UQ_4_12(1.5)); // snow def boost for ice types if (IS_BATTLER_OF_TYPE(battlerDef, TYPE_ICE) && IsBattlerWeatherAffected(battlerDef, B_WEATHER_SNOW) && usesDefStat) diff --git a/test/battle/weather/sandstorm.c b/test/battle/weather/sandstorm.c index d01bd72ce4..78dc0ecdce 100644 --- a/test/battle/weather/sandstorm.c +++ b/test/battle/weather/sandstorm.c @@ -17,12 +17,14 @@ SINGLE_BATTLE_TEST("Sandstorm deals 1/16 damage per turn") } THEN { EXPECT_EQ(sandstormDamage, opponent->maxHP / 16); } } -SINGLE_BATTLE_TEST("Sandstorm multiplies the special defense of Rock-types by 1.5x", s16 damage) +SINGLE_BATTLE_TEST("Sandstorm multiplies the special defense of Rock-types by 1.5x (Gen4+)", s16 damage) { - u16 move; - PARAMETRIZE { move = MOVE_SANDSTORM; } - PARAMETRIZE { move = MOVE_CELEBRATE; } + u32 move, config; + PARAMETRIZE { move = MOVE_CELEBRATE; config = GEN_3; } + PARAMETRIZE { move = MOVE_SANDSTORM; config = GEN_3; } + PARAMETRIZE { move = MOVE_SANDSTORM; config = GEN_4; } GIVEN { + WITH_CONFIG(CONFIG_SANDSTORM_SPDEF_BOOST, config); ASSUME(GetMoveCategory(MOVE_SWIFT) == DAMAGE_CATEGORY_SPECIAL); PLAYER(SPECIES_WOBBUFFET) ; OPPONENT(SPECIES_NOSEPASS); @@ -32,7 +34,8 @@ SINGLE_BATTLE_TEST("Sandstorm multiplies the special defense of Rock-types by 1. } SCENE { HP_BAR(opponent, captureDamage: &results[i].damage); } FINALLY { - EXPECT_MUL_EQ(results[0].damage, Q_4_12(1.5), results[1].damage); + EXPECT_MUL_EQ(results[2].damage, Q_4_12(1.5), results[0].damage); + EXPECT_MUL_EQ(results[2].damage, Q_4_12(1.5), results[1].damage); } }