From 5a745020eefe7e2ae9e25fada11e92800ced4374 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 27 Feb 2023 16:27:58 +0100 Subject: [PATCH] add tests for stockpile swallow spit up --- src/battle_message.c | 8 +- test/move_effect_stockpile.c | 252 +++++++++++++++++++++++++++++++++++ test/test_battle.h | 2 +- 3 files changed, 257 insertions(+), 5 deletions(-) create mode 100644 test/move_effect_stockpile.c diff --git a/src/battle_message.c b/src/battle_message.c index 74423781e..997a6ae09 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -177,8 +177,8 @@ static const u8 sText_PkmnCausedUproar[] = _("{B_ATK_NAME_WITH_PREFIX} caused\na static const u8 sText_PkmnMakingUproar[] = _("{B_ATK_NAME_WITH_PREFIX} is making\nan UPROAR!"); static const u8 sText_PkmnCalmedDown[] = _("{B_ATK_NAME_WITH_PREFIX} calmed down."); static const u8 sText_PkmnCantSleepInUproar[] = _("But {B_DEF_NAME_WITH_PREFIX} can't\nsleep in an UPROAR!"); -static const u8 sText_PkmnStockpiled[] = _("{B_ATK_NAME_WITH_PREFIX} STOCKPILED\n{B_BUFF1}!"); -static const u8 sText_PkmnCantStockpile[] = _("{B_ATK_NAME_WITH_PREFIX} can't\nSTOCKPILE any more!"); +static const u8 sText_PkmnStockpiled[] = _("{B_ATK_NAME_WITH_PREFIX} stockpiled\n{B_BUFF1}!"); +static const u8 sText_PkmnCantStockpile[] = _("{B_ATK_NAME_WITH_PREFIX} can't\nstockpile any more!"); static const u8 sText_PkmnCantSleepInUproar2[] = _("But {B_DEF_NAME_WITH_PREFIX} can't\nsleep in an UPROAR!"); static const u8 sText_UproarKeptPkmnAwake[] = _("But the UPROAR kept\n{B_DEF_NAME_WITH_PREFIX} awake!"); static const u8 sText_PkmnStayedAwakeUsing[] = _("{B_DEF_NAME_WITH_PREFIX} stayed awake\nusing its {B_DEF_ABILITY}!"); @@ -360,8 +360,8 @@ static const u8 sText_SunlightFaded[] = _("The sunlight faded."); static const u8 sText_StartedHail[] = _("It started to hail!"); static const u8 sText_HailContinues[] = _("Hail continues to fall."); static const u8 sText_HailStopped[] = _("The hail stopped."); -static const u8 sText_FailedToSpitUp[] = _("But it failed to SPIT UP\na thing!"); -static const u8 sText_FailedToSwallow[] = _("But it failed to SWALLOW\na thing!"); +static const u8 sText_FailedToSpitUp[] = _("But it failed to spit up\na thing!"); +static const u8 sText_FailedToSwallow[] = _("But it failed to swallow\na thing!"); static const u8 sText_WindBecameHeatWave[] = _("The wind turned into a\nHEAT WAVE!"); static const u8 sText_StatChangesGone[] = _("All stat changes were\neliminated!"); static const u8 sText_CoinsScattered[] = _("Coins scattered everywhere!"); diff --git a/test/move_effect_stockpile.c b/test/move_effect_stockpile.c new file mode 100644 index 000000000..1e62f766d --- /dev/null +++ b/test/move_effect_stockpile.c @@ -0,0 +1,252 @@ +#include "global.h" +#include "test_battle.h" + +// These tests cover all 3 effects: Stockpile, Spit up and Swallow. +ASSUMPTIONS +{ + ASSUME(gBattleMoves[MOVE_STOCKPILE].effect == EFFECT_STOCKPILE); + ASSUME(gBattleMoves[MOVE_SWALLOW].effect == EFFECT_SWALLOW); + ASSUME(gBattleMoves[MOVE_SPIT_UP].effect == EFFECT_SPIT_UP); +} + +SINGLE_BATTLE_TEST("Stockpile's count can go up only to 3") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_STOCKPILE); } + TURN { MOVE(player, MOVE_STOCKPILE); } + TURN { MOVE(player, MOVE_STOCKPILE); } + TURN { MOVE(player, MOVE_STOCKPILE); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_STOCKPILE, player); + MESSAGE("Wobbuffet stockpiled 1!"); + + ANIMATION(ANIM_TYPE_MOVE, MOVE_STOCKPILE, player); + MESSAGE("Wobbuffet stockpiled 2!"); + + ANIMATION(ANIM_TYPE_MOVE, MOVE_STOCKPILE, player); + MESSAGE("Wobbuffet stockpiled 3!"); + + NOT ANIMATION(ANIM_TYPE_MOVE, MOVE_STOCKPILE, player); + MESSAGE("Wobbuffet can't stockpile any more!"); + } +} + +#define MAX_HP_TEST 400 +SINGLE_BATTLE_TEST("Spit Up and Swallow don't work if used without Stockpile") +{ + u32 move; + PARAMETRIZE {move = MOVE_SWALLOW ;} + PARAMETRIZE {move = MOVE_SPIT_UP ;} + GIVEN { + PLAYER(SPECIES_WOBBUFFET) {HP(10), MaxHP(MAX_HP_TEST) ;} + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, move); } + TURN { MOVE(player, MOVE_STOCKPILE); } + TURN { MOVE(player, move); } + } SCENE { + NOT ANIMATION(ANIM_TYPE_MOVE, move, player); + if (move == MOVE_SWALLOW) + MESSAGE("But it failed to swallow a thing!"); + else + MESSAGE("But it failed to spit up a thing!"); + + ANIMATION(ANIM_TYPE_MOVE, MOVE_STOCKPILE, player); + MESSAGE("Wobbuffet stockpiled 1!"); + + ANIMATION(ANIM_TYPE_MOVE, move, player); + if (move == MOVE_SPIT_UP) { + HP_BAR(opponent); + } + else { + HP_BAR(player); + } + } +} + +SINGLE_BATTLE_TEST("Spit Up's power raises depending on Stockpile's count", s16 damage) +{ + u8 count; + PARAMETRIZE { count = 1;} + PARAMETRIZE { count = 2;} + PARAMETRIZE { count = 3;} + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_STOCKPILE); } + if (count != 1){ + TURN { MOVE(player, MOVE_STOCKPILE); } + if (count == 3) { + TURN { MOVE(player, MOVE_STOCKPILE); } + } + } + TURN { MOVE(player, MOVE_SPIT_UP); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_STOCKPILE, player); + MESSAGE("Wobbuffet stockpiled 1!"); + if (count != 1) { + ANIMATION(ANIM_TYPE_MOVE, MOVE_STOCKPILE, player); + MESSAGE("Wobbuffet stockpiled 2!"); + if (count == 3) { + ANIMATION(ANIM_TYPE_MOVE, MOVE_STOCKPILE, player); + MESSAGE("Wobbuffet stockpiled 3!"); + } + } + ANIMATION(ANIM_TYPE_MOVE, MOVE_SPIT_UP, player); + HP_BAR(opponent, captureDamage: &results[i].damage); + } FINALLY { + EXPECT_MUL_EQ(results[0].damage, Q_4_12(2.0), results[1].damage); + EXPECT_MUL_EQ(results[0].damage, Q_4_12(3.0), results[2].damage); + } +} + +SINGLE_BATTLE_TEST("Swallow heals HP depending on Stockpile's count", s16 hpHeal) +{ + u8 count; + PARAMETRIZE { count = 1;} + PARAMETRIZE { count = 2;} + PARAMETRIZE { count = 3;} + GIVEN { + PLAYER(SPECIES_WOBBUFFET) {HP(1), MaxHP(MAX_HP_TEST); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_STOCKPILE); } + if (count != 1){ + TURN { MOVE(player, MOVE_STOCKPILE); } + if (count == 3) { + TURN { MOVE(player, MOVE_STOCKPILE); } + } + } + TURN { MOVE(player, MOVE_SWALLOW); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_STOCKPILE, player); + MESSAGE("Wobbuffet stockpiled 1!"); + if (count != 1) { + ANIMATION(ANIM_TYPE_MOVE, MOVE_STOCKPILE, player); + MESSAGE("Wobbuffet stockpiled 2!"); + if (count == 3) { + ANIMATION(ANIM_TYPE_MOVE, MOVE_STOCKPILE, player); + MESSAGE("Wobbuffet stockpiled 3!"); + } + } + ANIMATION(ANIM_TYPE_MOVE, MOVE_SWALLOW, player); + HP_BAR(player, captureDamage: &results[i].hpHeal); + } FINALLY { + EXPECT_EQ(results[0].hpHeal, -(MAX_HP_TEST / 4)); + EXPECT_EQ(results[1].hpHeal, -(MAX_HP_TEST / 2)); + EXPECT_EQ(results[2].hpHeal, -(MAX_HP_TEST - 1)); + } +} + +SINGLE_BATTLE_TEST("Stockpile temporarily raises Def and Sp.Def", s16 dmgPyhsical, s16 dmgSpecial) +{ + u16 move; + PARAMETRIZE {move = MOVE_STOCKPILE;} + PARAMETRIZE {move = MOVE_CELEBRATE;} + GIVEN { + ASSUME(gBattleMoves[MOVE_TACKLE].split == SPLIT_PHYSICAL); + ASSUME(gBattleMoves[MOVE_GUST].split == SPLIT_SPECIAL); + PLAYER(SPECIES_WOBBUFFET) {Speed(2); } + OPPONENT(SPECIES_WOBBUFFET) {Speed(1); } + } WHEN { + TURN { MOVE(player, move); MOVE(opponent, MOVE_TACKLE); } + TURN { MOVE(opponent, MOVE_GUST); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, move, player); + if (move == MOVE_STOCKPILE) { + MESSAGE("Wobbuffet stockpiled 1!"); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, player); + MESSAGE("Wobbuffet's defense rose!"); + MESSAGE("Wobbuffet's sp. defense rose!"); + } + + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponent); + HP_BAR(player, captureDamage: &results[i].dmgPyhsical); + + ANIMATION(ANIM_TYPE_MOVE, MOVE_GUST, opponent); + HP_BAR(player, captureDamage: &results[i].dmgSpecial); + } FINALLY { + EXPECT_MUL_EQ(results[0].dmgPyhsical, Q_4_12(1.5), results[1].dmgPyhsical); + EXPECT_MUL_EQ(results[0].dmgSpecial, Q_4_12(1.5), results[1].dmgSpecial); + } +} + +DOUBLE_BATTLE_TEST("Stockpile's Def and Sp.Def boost is lost after using Spit Up or Swallow", s16 dmgPyhsicalBefore, s16 dmgPhysicalAfter, s16 dmgSpecialBefore, s16 dmgSpecialAfter) +{ + u8 count; + u16 move; + PARAMETRIZE {count = 1, move = MOVE_SPIT_UP;} + PARAMETRIZE {count = 2, move = MOVE_SWALLOW;} + PARAMETRIZE {count = 3, move = MOVE_SPIT_UP;} + GIVEN { + ASSUME(gBattleMoves[MOVE_TACKLE].split == SPLIT_PHYSICAL); + ASSUME(gBattleMoves[MOVE_GUST].split == SPLIT_SPECIAL); + PLAYER(SPECIES_WOBBUFFET) {Speed(4); HP(MAX_HP_TEST - 1); MaxHP(MAX_HP_TEST); } + PLAYER(SPECIES_WOBBUFFET) {Speed(3); } + OPPONENT(SPECIES_WOBBUFFET) {Speed(2); } + OPPONENT(SPECIES_WOBBUFFET) {Speed(1); } + } WHEN { + TURN { MOVE(opponentLeft, MOVE_TACKLE, target:playerLeft, criticalHit:FALSE); MOVE(opponentRight, MOVE_GUST, criticalHit:FALSE, target:playerLeft);} + TURN { MOVE(playerLeft, MOVE_STOCKPILE);} + if (count != 1) { + TURN { MOVE(playerLeft, MOVE_STOCKPILE);} + if (count == 3) { + TURN { MOVE(playerLeft, MOVE_STOCKPILE);} + } + } + TURN { MOVE(playerLeft, move, target:opponentLeft); MOVE(opponentLeft, MOVE_TACKLE, target:playerLeft, criticalHit:FALSE); MOVE(opponentRight, MOVE_GUST, target:playerLeft, criticalHit:FALSE); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponentLeft); + HP_BAR(playerLeft, captureDamage: &results[i].dmgPyhsicalBefore); + ANIMATION(ANIM_TYPE_MOVE, MOVE_GUST, opponentRight); + HP_BAR(playerLeft, captureDamage: &results[i].dmgSpecialBefore); + + ANIMATION(ANIM_TYPE_MOVE, MOVE_STOCKPILE, playerLeft); + if (count != 1) { + ANIMATION(ANIM_TYPE_MOVE, MOVE_STOCKPILE, playerLeft); + if (count == 3) { + ANIMATION(ANIM_TYPE_MOVE, MOVE_STOCKPILE, playerLeft); + } + } + ANIMATION(ANIM_TYPE_MOVE, move, playerLeft); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, playerLeft); + if (count == 1) { + MESSAGE("Wobbuffet's defense fell!"); + } + else if (count == 2) { + MESSAGE("Wobbuffet's defense harshly fell!"); + } + else { + MESSAGE("Wobbuffet's defense severely fell!"); + } + + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, playerLeft); + if (count == 1) { + MESSAGE("Wobbuffet's sp. defense fell!"); + } + else if (count == 2) { + MESSAGE("Wobbuffet's sp. defense harshly fell!"); + } + else { + MESSAGE("Wobbuffet's sp. defense severely fell!"); + } + MESSAGE("Wobbuffet's stockpiled effect wore off!"); + + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponentLeft); + HP_BAR(playerLeft, captureDamage: &results[i].dmgPhysicalAfter); + ANIMATION(ANIM_TYPE_MOVE, MOVE_GUST, opponentRight); + HP_BAR(playerLeft, captureDamage: &results[i].dmgSpecialAfter); + } FINALLY { + EXPECT_MUL_EQ(results[0].dmgPyhsicalBefore, UQ_4_12(1.0), results[0].dmgPhysicalAfter); + EXPECT_MUL_EQ(results[0].dmgSpecialBefore, UQ_4_12(1.0), results[0].dmgSpecialAfter); + EXPECT_MUL_EQ(results[1].dmgPyhsicalBefore, UQ_4_12(1.0), results[1].dmgPhysicalAfter); + EXPECT_MUL_EQ(results[1].dmgSpecialBefore, UQ_4_12(1.0), results[1].dmgSpecialAfter); + EXPECT_MUL_EQ(results[2].dmgPyhsicalBefore, UQ_4_12(1.0), results[2].dmgPhysicalAfter); + EXPECT_MUL_EQ(results[2].dmgSpecialBefore, UQ_4_12(1.0), results[2].dmgSpecialAfter); + } +} + diff --git a/test/test_battle.h b/test/test_battle.h index 806e7947e..16918251b 100644 --- a/test/test_battle.h +++ b/test/test_battle.h @@ -433,7 +433,7 @@ // NOTE: If the stack is too small the test runner will probably crash // or loop. #define BATTLE_TEST_STACK_SIZE 1024 -#define MAX_QUEUED_EVENTS 16 +#define MAX_QUEUED_EVENTS 25 enum { BATTLE_TEST_SINGLES, BATTLE_TEST_DOUBLES };