From 66b550b9f00b6c8600fad60572de166982a024bd Mon Sep 17 00:00:00 2001 From: PhallenTree <168426989+PhallenTree@users.noreply.github.com> Date: Fri, 6 Mar 2026 19:47:19 +0000 Subject: [PATCH] Fixes Trump Card's power calculation using its own PP when called by another move (#9445) --- src/battle_util.c | 2 +- test/battle/move_effect/trump_card.c | 77 +++++++++++++++++++++++++++- 2 files changed, 77 insertions(+), 2 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index cf94c40a88..93941198ac 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -6357,7 +6357,7 @@ static inline u32 CalcMoveBasePower(struct BattleContext *ctx) basePower *= 2; break; case EFFECT_TRUMP_CARD: - i = GetMoveSlot(gBattleMons[battlerAtk].moves, move); + i = GetMoveSlot(gBattleMons[battlerAtk].moves, ctx->chosenMove); if (i != MAX_MON_MOVES) { if (gBattleMons[battlerAtk].pp[i] >= ARRAY_COUNT(sTrumpCardPowerTable)) diff --git a/test/battle/move_effect/trump_card.c b/test/battle/move_effect/trump_card.c index 21b5c48ca3..1fa9850a4c 100644 --- a/test/battle/move_effect/trump_card.c +++ b/test/battle/move_effect/trump_card.c @@ -1,4 +1,79 @@ #include "global.h" #include "test/battle.h" -TO_DO_BATTLE_TEST("TODO: Write Trump Card (Move Effect) test titles") +ASSUMPTIONS +{ + ASSUME(GetMoveEffect(MOVE_TRUMP_CARD) == EFFECT_TRUMP_CARD); +} + +SINGLE_BATTLE_TEST("Trump Card increases in power if its PP is low", s16 damage) +{ + // pp + 1 is assigned as the move's PP as it will be reduced before its base power is determined + u32 pp; + + PARAMETRIZE { pp = 4; } // 40 power + PARAMETRIZE { pp = 3; } // 50 power + PARAMETRIZE { pp = 2; } // 60 power + PARAMETRIZE { pp = 1; } // 80 power + PARAMETRIZE { pp = 0; } // 200 power + + GIVEN { + PLAYER(SPECIES_WOBBUFFET) { MovesWithPP({MOVE_TRUMP_CARD, pp + 1}); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_TRUMP_CARD); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_TRUMP_CARD, player); + HP_BAR(opponent, captureDamage: &results[i].damage); + } FINALLY { + EXPECT_MUL_EQ(results[0].damage, UQ_4_12(1.25), results[1].damage); + EXPECT_MUL_EQ(results[0].damage, UQ_4_12(1.5), results[2].damage); + EXPECT_MUL_EQ(results[0].damage, UQ_4_12(2.0), results[3].damage); + EXPECT_MUL_EQ(results[0].damage, UQ_4_12(5.0), results[4].damage); + } +} + +SINGLE_BATTLE_TEST("Trump Card doesn't increase in power if its PP is low when called by a different move", s16 damage) +{ + u32 pp; + + PARAMETRIZE { pp = 4; } // would be 40 power + PARAMETRIZE { pp = 0; } // would be 200 power + + GIVEN { + ASSUME(GetMoveEffect(MOVE_SLEEP_TALK) == EFFECT_SLEEP_TALK); + PLAYER(SPECIES_WOBBUFFET) { MovesWithPP({MOVE_TRUMP_CARD, pp}, {MOVE_SLEEP_TALK, 10}); Status1(STATUS1_SLEEP); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_SLEEP_TALK); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_SLEEP_TALK, player); + ANIMATION(ANIM_TYPE_MOVE, MOVE_TRUMP_CARD, player); + HP_BAR(opponent, captureDamage: &results[i].damage); + } FINALLY { + EXPECT_EQ(results[0].damage, results[1].damage); + } +} + +SINGLE_BATTLE_TEST("Trump Card increases in power if the move that called it has low PP", s16 damage) +{ + // pp + 1 is assigned as the move's PP as it will be reduced before its base power is determined + u32 pp; + + PARAMETRIZE { pp = 4; } // 40 power + PARAMETRIZE { pp = 0; } // 200 power + + GIVEN { + ASSUME(GetMoveEffect(MOVE_SLEEP_TALK) == EFFECT_SLEEP_TALK); + PLAYER(SPECIES_WOBBUFFET) { MovesWithPP({MOVE_TRUMP_CARD, 5}, {MOVE_SLEEP_TALK, pp + 1}); Status1(STATUS1_SLEEP); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_SLEEP_TALK); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_SLEEP_TALK, player); + ANIMATION(ANIM_TYPE_MOVE, MOVE_TRUMP_CARD, player); + HP_BAR(opponent, captureDamage: &results[i].damage); + } FINALLY { + EXPECT_MUL_EQ(results[0].damage, UQ_4_12(5.0), results[1].damage); + } +}