From 6758f6ebe755e6961d365ec2ecdfffea6f9c6f2f Mon Sep 17 00:00:00 2001 From: CallmeEchoo Date: Tue, 2 May 2023 16:16:58 +0200 Subject: [PATCH] add some snow related tests --- include/config/battle.h | 2 +- test/ability_snow_warning.c | 20 +++++ test/weather_snow.c | 159 ++++++++++++++++++++++++++++++++++++ 3 files changed, 180 insertions(+), 1 deletion(-) create mode 100644 test/ability_snow_warning.c create mode 100644 test/weather_snow.c diff --git a/include/config/battle.h b/include/config/battle.h index 4daeb59b4..6ba84409f 100644 --- a/include/config/battle.h +++ b/include/config/battle.h @@ -120,7 +120,7 @@ #define B_SYMBIOSIS_GEMS GEN_LATEST // In Gen7+, Symbiosis passes an item after a gem-boosted attack. Previously, items are passed before the gem-boosted attack hits, making the item effect apply. #define B_CHECK_IF_CHARGED_UP TRUE // If set to TRUE, certain abilities such as Electromorphosis WILL check if the STATUS3_CHARGED_UP status flag is applied. #define B_ABSORBING_ABILITY_STRING GEN_LATEST // In Gen5+, the abilities that absorb moves of a certain type use a generic string for stat increases and decreases. -#define B_SNOW_WARNING GEN_9 // In Gen9+, Snow Warning will summon snow instead of hail. +#define B_SNOW_WARNING GEN_LATEST // In Gen9+, Snow Warning will summon snow instead of hail. // Item settings #define B_HP_BERRIES GEN_LATEST // In Gen4+, berries which restore hp activate immediately after HP drops to half. In Gen3, the effect occurs at the end of the turn. diff --git a/test/ability_snow_warning.c b/test/ability_snow_warning.c new file mode 100644 index 000000000..6c0753ad3 --- /dev/null +++ b/test/ability_snow_warning.c @@ -0,0 +1,20 @@ +#include "global.h" +#include "test_battle.h" + +SINGLE_BATTLE_TEST("Snow Warning summons hail(snow)") +{ + GIVEN { + PLAYER(SPECIES_ABOMASNOW) { Ability(ABILITY_SNOW_WARNING); }; + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN {} + } SCENE { + #if B_SNOW_WARNING < GEN_9 + MESSAGE("It started to hail!"); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HAIL_CONTINUES); + #elif B_SNOW_WARNING >= GEN_9 + MESSAGE("It started to snow!"); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_SNOW_CONTINUES); + #endif + } +} diff --git a/test/weather_snow.c b/test/weather_snow.c new file mode 100644 index 000000000..07afa48d5 --- /dev/null +++ b/test/weather_snow.c @@ -0,0 +1,159 @@ +#include "global.h" +#include "test_battle.h" + +#define TEST_HP 1 +#define MAX_HP 400 + +ASSUMPTIONS +{ + ASSUME(gBattleMoves[MOVE_SNOWSCAPE].effect == EFFECT_SNOW); + ASSUME(gSpeciesInfo[SPECIES_WOBBUFFET].types[0] == TYPE_PSYCHIC); + ASSUME(gSpeciesInfo[SPECIES_WOBBUFFET].types[1] == TYPE_PSYCHIC); + ASSUME(gSpeciesInfo[SPECIES_GLALIE].types[0] == TYPE_ICE); + ASSUME(gSpeciesInfo[SPECIES_GLALIE].types[1] == TYPE_ICE); +} + +SINGLE_BATTLE_TEST("Snow increases the defense of Ice types by 50 %", s16 damage) +{ + u16 move; + PARAMETRIZE{ move = MOVE_SNOWSCAPE; } + PARAMETRIZE{ move = MOVE_CELEBRATE; } + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_GLALIE); + } WHEN { + TURN { MOVE(opponent, move); } + TURN { MOVE(player, MOVE_TACKLE); } + } SCENE { + HP_BAR(opponent, captureDamage: &results[i].damage); + } FINALLY { + EXPECT_MUL_EQ(results[0].damage, Q_4_12(1.5), results[1].damage); + } +} + +SINGLE_BATTLE_TEST("Snow turns Weather Ball to an Ice-type move and doubles its power", s16 damage) +{ + u16 move; + PARAMETRIZE{ move = MOVE_CELEBRATE; } + PARAMETRIZE{ move = MOVE_SNOWSCAPE; } + GIVEN { + ASSUME(gBattleMoves[MOVE_WEATHER_BALL].effect == EFFECT_WEATHER_BALL); + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_DRAGONAIR); + } WHEN { + TURN { MOVE(player, move); } + TURN { MOVE(player, MOVE_WEATHER_BALL); } + } SCENE { + HP_BAR(opponent, captureDamage: &results[i].damage); + } FINALLY { + EXPECT_MUL_EQ(results[0].damage, Q_4_12(4.0), results[1].damage); // double base power + type effectiveness. + } +} + +SINGLE_BATTLE_TEST("Snow allows Blizzard to bypass accuracy checks") +{ + PASSES_RANDOMLY(100, 100); + GIVEN { + ASSUME(gBattleMoves[MOVE_BLIZZARD].accuracy == 70); + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(opponent, MOVE_SNOWSCAPE); MOVE(player, MOVE_BLIZZARD); } + } SCENE { + NONE_OF { MESSAGE("Wobbuffet's attack missed!"); } + } +} + +SINGLE_BATTLE_TEST("Snow halves the power of Solar Beam", s16 damage) +{ + u16 move; + PARAMETRIZE{ move = MOVE_CELEBRATE; } + PARAMETRIZE{ move = MOVE_SNOWSCAPE; } + GIVEN { + ASSUME(gBattleMoves[MOVE_SOLAR_BEAM].effect == EFFECT_SOLAR_BEAM); + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(opponent, move); MOVE(player, MOVE_SOLAR_BEAM); } + TURN { SKIP_TURN(player); } + } SCENE { + HP_BAR(opponent, captureDamage: &results[i].damage); + } FINALLY { + EXPECT_MUL_EQ(results[0].damage, Q_4_12(0.5), results[1].damage); + } +} + +SINGLE_BATTLE_TEST("Snow halves the power of Solar Blade", s16 damage) +{ + u16 move; + KNOWN_FAILING; // fails bc the bp of solar blade gets rounded up which leads to slightly incorrect calcs down the line + PARAMETRIZE{ move = MOVE_CELEBRATE; } + PARAMETRIZE{ move = MOVE_SNOWSCAPE; } + GIVEN { + ASSUME(gBattleMoves[MOVE_SOLAR_BLADE].effect == EFFECT_SOLAR_BEAM); + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WYNAUT); + } WHEN { + TURN { MOVE(opponent, move); MOVE(player, MOVE_SOLAR_BLADE); } + TURN { SKIP_TURN(player); } + } SCENE { + HP_BAR(opponent, captureDamage: &results[i].damage); + } FINALLY { + EXPECT_MUL_EQ(results[0].damage, Q_4_12(0.5), results[1].damage); + } +} + +SINGLE_BATTLE_TEST("Snow causes Moonlight to recover 1/4 of the user's max HP") +{ + GIVEN { + ASSUME(gBattleMoves[MOVE_MOONLIGHT].effect == EFFECT_MOONLIGHT); + PLAYER(SPECIES_WOBBUFFET) { HP(TEST_HP); MaxHP(MAX_HP); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(opponent, MOVE_SNOWSCAPE); MOVE(player, MOVE_MOONLIGHT); } + } SCENE { + HP_BAR(player, hp: TEST_HP + (MAX_HP/4)); + } +} + +SINGLE_BATTLE_TEST("Snow causes Moonlight to recover 1/4 of the user's max HP") +{ + GIVEN { + ASSUME(gBattleMoves[MOVE_MOONLIGHT].effect == EFFECT_MOONLIGHT); + PLAYER(SPECIES_WOBBUFFET) { HP(TEST_HP); MaxHP(MAX_HP); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(opponent, MOVE_SNOWSCAPE); MOVE(player, MOVE_MOONLIGHT); } + } SCENE { + HP_BAR(player, hp: TEST_HP + (MAX_HP/4)); + } +} + +SINGLE_BATTLE_TEST("Snow causes Synthesis to recover 1/4 of the user's max HP") +{ + GIVEN { + ASSUME(gBattleMoves[MOVE_SYNTHESIS].effect == EFFECT_SYNTHESIS); + PLAYER(SPECIES_WOBBUFFET) { HP(TEST_HP); MaxHP(MAX_HP); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(opponent, MOVE_SNOWSCAPE); MOVE(player, MOVE_SYNTHESIS); } + } SCENE { + HP_BAR(player, hp: TEST_HP + (MAX_HP/4)); + } +} + +SINGLE_BATTLE_TEST("Snow causes Morning Sun to recover 1/4 of the user's max HP") +{ + GIVEN { + ASSUME(gBattleMoves[MOVE_MORNING_SUN].effect == EFFECT_MORNING_SUN); + PLAYER(SPECIES_WOBBUFFET) { HP(TEST_HP); MaxHP(MAX_HP); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(opponent, MOVE_SNOWSCAPE); MOVE(player, MOVE_MORNING_SUN); } + } SCENE { + HP_BAR(player, hp: TEST_HP + (MAX_HP/4)); + } +} + +#undef MAX_HP +#undef TEST_HP \ No newline at end of file