From 313f2e552672cae9506c6a647464c247b9b39928 Mon Sep 17 00:00:00 2001 From: Hedara Date: Sat, 18 May 2024 15:44:55 +0200 Subject: [PATCH] Fixed Elixirs not being able to be used unless the first move was missing PP --- src/item_use.c | 4 ++-- test/battle/item_effect/restore_pp.c | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/item_use.c b/src/item_use.c index e711f8cd22..824b308524 100644 --- a/src/item_use.c +++ b/src/item_use.c @@ -1254,11 +1254,11 @@ bool32 CannotUseItemsInBattle(u16 itemId, struct Pokemon *mon) cannotUse = TRUE; break; case EFFECT_ITEM_RESTORE_PP: - if (ItemId_GetEffect(itemId)[6] == ITEM4_HEAL_PP) + if (ItemId_GetEffect(itemId)[4] == ITEM4_HEAL_PP) { for (i = 0; i < MAX_MON_MOVES; i++) { - if (GetMonData(mon, MON_DATA_PP1 + i) < CalculatePPWithBonus(GetMonData(mon, MON_DATA_MOVE1 + i), GetMonData(mon, MON_DATA_PP_BONUSES), i)); + if (GetMonData(mon, MON_DATA_PP1 + i) < CalculatePPWithBonus(GetMonData(mon, MON_DATA_MOVE1 + i), GetMonData(mon, MON_DATA_PP_BONUSES), i)) break; } if (i == MAX_MON_MOVES) diff --git a/test/battle/item_effect/restore_pp.c b/test/battle/item_effect/restore_pp.c index 8691dcf1ed..72a772658a 100644 --- a/test/battle/item_effect/restore_pp.c +++ b/test/battle/item_effect/restore_pp.c @@ -66,3 +66,28 @@ SINGLE_BATTLE_TEST("Max Elixir restores the PP of all of a battler's moves fully } TO_DO_BATTLE_TEST("Ether won't work if the selected move has all its PP") + +SINGLE_BATTLE_TEST("Elixir can be used if at least one move is missing PP in any slot") // As it works right now, this test can't test what it's suppossed to, since the relevant check doesn't run in the testing system. +{ + u8 move1PP; + u8 move2PP; + u8 move3PP; + u8 move4PP; + PARAMETRIZE { move1PP = 30; move2PP = 30; move3PP = 20; move4PP = 10; } + PARAMETRIZE { move1PP = 40; move2PP = 20; move3PP = 20; move4PP = 10; } + PARAMETRIZE { move1PP = 40; move2PP = 30; move3PP = 10; move4PP = 10; } + PARAMETRIZE { move1PP = 40; move2PP = 30; move3PP = 20; move4PP = 0; } + GIVEN { + ASSUME(gItemsInfo[ITEM_ELIXIR].battleUsage == EFFECT_ITEM_RESTORE_PP); + ASSUME(gItemsInfo[ITEM_ELIXIR].type == ITEM_USE_PARTY_MENU); + PLAYER(SPECIES_WOBBUFFET) { MovesWithPP({MOVE_MEDITATE, move1PP}, {MOVE_AGILITY, move2PP}, {MOVE_PSYBEAM, move3PP}, {MOVE_TRICK, move4PP}); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { USE_ITEM(player, ITEM_ELIXIR, partyIndex: 0); } + } THEN { + EXPECT_EQ(player->pp[0], 40); + EXPECT_EQ(player->pp[1], 30); + EXPECT_EQ(player->pp[2], 20); + EXPECT_EQ(player->pp[3], 10); + } +}