From cfac676f1357293599695387d80a7a44ed34266f Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Mon, 25 May 2020 09:39:05 -0600 Subject: [PATCH 1/2] start --- src/shop.c | 191 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 191 insertions(+) diff --git a/src/shop.c b/src/shop.c index dac43c96d16e..80310e96c63c 100755 --- a/src/shop.c +++ b/src/shop.c @@ -93,6 +93,180 @@ static void Task_HandleShopMenuBuy(u8 taskId); static void Task_HandleShopMenuSell(u8 taskId); static void BuyMenuPrintItemDescriptionAndShowItemIcon(s32 item, bool8 onInit, struct ListMenu *list); static void BuyMenuPrintPriceInList(u8 windowId, s32 item, u8 y); +//mart badges +static u8 GetNumberOfBadges(void); + +// pokemart items by badge +static const u16 sShopInventory_ZeroBadges[] = { + ITEM_POKE_BALL, + ITEM_POTION, + ITEM_ANTIDOTE, + ITEM_PARALYZE_HEAL, + ITEM_NONE +}; + +static const u16 sShopInventory_OneBadge[] = { + ITEM_POKE_BALL, + ITEM_POTION, + ITEM_SUPER_POTION, + ITEM_ANTIDOTE, + ITEM_PARALYZE_HEAL, + ITEM_AWAKENING, + ITEM_BURNHEAL, + ITEM_ICEHEAL, + ITEM_ESCAPEROPE, + ITEM_REPEL, + ITEM_NONE +}; + +// two is same as one badge +static const u16 sShopInventory_TwoBadges[] = { + ITEM_POKE_BALL, + ITEM_POTION, + ITEM_SUPER_POTION, + ITEM_ANTIDOTE, + ITEM_PARALYZE_HEAL, + ITEM_AWAKENING, + ITEM_BURNHEAL, + ITEM_ICEHEAL, + ITEM_ESCAPEROPE, + ITEM_REPEL, + ITEM_NONE +}; + +static const u16 sShopInventory_ThreeBadges[] = { + ITEM_POKE_BALL, + ITEM_GREATBALL, + ITEM_POTION, + ITEM_SUPER_POTION, + ITEM_REVIVE, + ITEM_ANTIDOTE, + ITEM_PARALYZE_HEAL, + ITEM_AWAKENING, + ITEM_BURNHEAL, + ITEM_ICEHEAL, + ITEM_ESCAPEROPE, + ITEM_REPEL, + ITEM_SUPERREPEL, + ITEM_NONE +}; + +// four is same as three +static const u16 sShopInventory_FourBadges[] = { + ITEM_POKE_BALL, + ITEM_GREATBALL, + ITEM_POTION, + ITEM_SUPER_POTION, + ITEM_REVIVE, + ITEM_ANTIDOTE, + ITEM_PARALYZE_HEAL, + ITEM_AWAKENING, + ITEM_BURNHEAL, + ITEM_ICEHEAL, + ITEM_ESCAPEROPE, + ITEM_REPEL, + ITEM_SUPERREPEL, + ITEM_NONE +}; + +static const u16 sShopInventory_FiveBadges[] = { + ITEM_POKE_BALL, + ITEM_GREATBALL, + ITEM_ULTRABALL, + ITEM_POTION, + ITEM_SUPER_POTION, + ITEM_HYPERPOTION, + ITEM_REVIVE, + ITEM_ANTIDOTE, + ITEM_PARALYZE_HEAL, + ITEM_AWAKENING, + ITEM_BURNHEAL, + ITEM_ICEHEAL, + ITEM_FULLHEAL, + ITEM_ESCAPEROPE, + ITEM_REPEL, + ITEM_SUPERREPEL, + ITEM_NONE +}; + +// six is same as five +static const u16 sShopInventory_SixBadges[] = { + ITEM_POKE_BALL, + ITEM_GREATBALL, + ITEM_ULTRABALL, + ITEM_POTION, + ITEM_SUPER_POTION, + ITEM_HYPERPOTION, + ITEM_REVIVE, + ITEM_ANTIDOTE, + ITEM_PARALYZE_HEAL, + ITEM_AWAKENING, + ITEM_BURNHEAL, + ITEM_ICEHEAL, + ITEM_FULLHEAL, + ITEM_ESCAPEROPE, + ITEM_REPEL, + ITEM_SUPERREPEL, + ITEM_NONE +}; + +static const u16 sShopInventory_SevenBadges[] = { + ITEM_POKE_BALL, + ITEM_GREATBALL, + ITEM_ULTRABALL, + ITEM_POTION, + ITEM_SUPER_POTION, + ITEM_HYPERPOTION, + ITEM_MAXPOTION, + ITEM_REVIVE, + ITEM_ANTIDOTE, + ITEM_PARALYZE_HEAL, + ITEM_AWAKENING, + ITEM_BURNHEAL, + ITEM_ICEHEAL, + ITEM_FULLHEAL, + ITEM_ESCAPEROPE, + ITEM_REPEL, + ITEM_SUPERREPEL, + ITEM_MAXREPEL, + ITEM_NONE +}; + +static const u16 sShopInventory_EightBadges[] = { + ITEM_POKE_BALL, + ITEM_GREATBALL, + ITEM_ULTRABALL, + ITEM_POTION, + ITEM_SUPER_POTION, + ITEM_HYPERPOTION, + ITEM_MAXPOTION, + ITEM_FULLRESTORE, + ITEM_REVIVE, + ITEM_ANTIDOTE, + ITEM_PARALYZE_HEAL, + ITEM_AWAKENING, + ITEM_BURNHEAL, + ITEM_ICEHEAL, + ITEM_FULLHEAL, + ITEM_ESCAPEROPE, + ITEM_REPEL, + ITEM_SUPERREPEL, + ITEM_MAXREPEL, + ITEM_NONE +}; + +static const u16 *sShopInventories[] = +{ + sShopInventory_ZeroBadges, + sShopInventory_OneBadge, + sShopInventory_TwoBadges, + sShopInventory_ThreeBadges, + sShopInventory_FourBadges, + sShopInventory_FiveBadges, + sShopInventory_SixBadges, + sShopInventory_SevenBadges, + sShopInventory_EightBadges +}; static const struct YesNoFuncTable sShopPurchaseYesNoFuncs = { @@ -317,6 +491,7 @@ static void SetShopMenuCallback(void (* callback)(void)) static void SetShopItemsForSale(const u16 *items) { u16 i = 0; + u8 badgeCount = GetNumberOfBadges(); sMartInfo.itemList = items; sMartInfo.itemCount = 0; @@ -1227,3 +1402,19 @@ void CreateDecorationShop2Menu(const u16 *itemsForSale) SetShopItemsForSale(itemsForSale); SetShopMenuCallback(EnableBothScriptContexts); } + + + +static u8 GetNumberOfBadges(void) +{ + u16 badgeFlag; + u8 count = 0; + + for (badgeFlag = FLAG_BADGE01_GET; badgeFlag < FLAG_BADGE01_GET + NUM_BADGES; badgeFlag++) + { + if (FlagGet(badgeFlag)) + count++; + } + + return count; +} From 8078b7f0077a5c8ef47a3cc98831f79e51f75e40 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Sat, 20 Jun 2020 14:26:40 -0600 Subject: [PATCH 2/2] merge 3b2393a2d5b924e61050b370e4e4f4bd7a50fe7e --- src/shop.c | 189 +++++++++++++++++++++++++++-------------------------- 1 file changed, 96 insertions(+), 93 deletions(-) diff --git a/src/shop.c b/src/shop.c index 80310e96c63c..94453c25ab7c 100755 --- a/src/shop.c +++ b/src/shop.c @@ -4,6 +4,7 @@ #include "decompress.h" #include "decoration.h" #include "decoration_inventory.h" +#include "event_data.h" #include "event_object_movement.h" #include "field_player_avatar.h" #include "field_screen_effect.h" @@ -93,169 +94,167 @@ static void Task_HandleShopMenuBuy(u8 taskId); static void Task_HandleShopMenuSell(u8 taskId); static void BuyMenuPrintItemDescriptionAndShowItemIcon(s32 item, bool8 onInit, struct ListMenu *list); static void BuyMenuPrintPriceInList(u8 windowId, s32 item, u8 y); -//mart badges -static u8 GetNumberOfBadges(void); -// pokemart items by badge +//mart badges static const u16 sShopInventory_ZeroBadges[] = { ITEM_POKE_BALL, ITEM_POTION, ITEM_ANTIDOTE, + ITEM_BURN_HEAL, + ITEM_ICE_HEAL, + ITEM_AWAKENING, ITEM_PARALYZE_HEAL, + ITEM_REVIVE, ITEM_NONE }; static const u16 sShopInventory_OneBadge[] = { ITEM_POKE_BALL, + ITEM_GREAT_BALL, ITEM_POTION, ITEM_SUPER_POTION, ITEM_ANTIDOTE, - ITEM_PARALYZE_HEAL, + ITEM_BURN_HEAL, + ITEM_ICE_HEAL, ITEM_AWAKENING, - ITEM_BURNHEAL, - ITEM_ICEHEAL, - ITEM_ESCAPEROPE, - ITEM_REPEL, + ITEM_PARALYZE_HEAL, + ITEM_REVIVE, ITEM_NONE }; -// two is same as one badge static const u16 sShopInventory_TwoBadges[] = { ITEM_POKE_BALL, + ITEM_GREAT_BALL, ITEM_POTION, ITEM_SUPER_POTION, ITEM_ANTIDOTE, - ITEM_PARALYZE_HEAL, + ITEM_BURN_HEAL, + ITEM_ICE_HEAL, ITEM_AWAKENING, - ITEM_BURNHEAL, - ITEM_ICEHEAL, - ITEM_ESCAPEROPE, - ITEM_REPEL, + ITEM_PARALYZE_HEAL, + ITEM_REVIVE, + ITEM_POKE_DOLL, ITEM_NONE }; static const u16 sShopInventory_ThreeBadges[] = { ITEM_POKE_BALL, - ITEM_GREATBALL, + ITEM_GREAT_BALL, ITEM_POTION, ITEM_SUPER_POTION, - ITEM_REVIVE, ITEM_ANTIDOTE, - ITEM_PARALYZE_HEAL, + ITEM_BURN_HEAL, + ITEM_ICE_HEAL, ITEM_AWAKENING, - ITEM_BURNHEAL, - ITEM_ICEHEAL, - ITEM_ESCAPEROPE, + ITEM_PARALYZE_HEAL, + ITEM_REVIVE, ITEM_REPEL, - ITEM_SUPERREPEL, + ITEM_POKE_DOLL, ITEM_NONE }; -// four is same as three static const u16 sShopInventory_FourBadges[] = { ITEM_POKE_BALL, - ITEM_GREATBALL, + ITEM_GREAT_BALL, ITEM_POTION, ITEM_SUPER_POTION, - ITEM_REVIVE, + ITEM_HYPER_POTION, ITEM_ANTIDOTE, - ITEM_PARALYZE_HEAL, + ITEM_BURN_HEAL, + ITEM_ICE_HEAL, ITEM_AWAKENING, - ITEM_BURNHEAL, - ITEM_ICEHEAL, - ITEM_ESCAPEROPE, + ITEM_PARALYZE_HEAL, + ITEM_REVIVE, ITEM_REPEL, - ITEM_SUPERREPEL, + ITEM_POKE_DOLL, ITEM_NONE }; static const u16 sShopInventory_FiveBadges[] = { ITEM_POKE_BALL, - ITEM_GREATBALL, - ITEM_ULTRABALL, + ITEM_GREAT_BALL, + ITEM_ULTRA_BALL, ITEM_POTION, ITEM_SUPER_POTION, - ITEM_HYPERPOTION, - ITEM_REVIVE, + ITEM_HYPER_POTION, ITEM_ANTIDOTE, - ITEM_PARALYZE_HEAL, + ITEM_BURN_HEAL, + ITEM_ICE_HEAL, ITEM_AWAKENING, - ITEM_BURNHEAL, - ITEM_ICEHEAL, - ITEM_FULLHEAL, - ITEM_ESCAPEROPE, + ITEM_PARALYZE_HEAL, + ITEM_REVIVE, ITEM_REPEL, - ITEM_SUPERREPEL, + ITEM_SUPER_REPEL, + ITEM_POKE_DOLL, ITEM_NONE }; -// six is same as five static const u16 sShopInventory_SixBadges[] = { ITEM_POKE_BALL, - ITEM_GREATBALL, - ITEM_ULTRABALL, + ITEM_GREAT_BALL, + ITEM_ULTRA_BALL, ITEM_POTION, ITEM_SUPER_POTION, - ITEM_HYPERPOTION, - ITEM_REVIVE, + ITEM_HYPER_POTION, ITEM_ANTIDOTE, - ITEM_PARALYZE_HEAL, + ITEM_BURN_HEAL, + ITEM_ICE_HEAL, ITEM_AWAKENING, - ITEM_BURNHEAL, - ITEM_ICEHEAL, - ITEM_FULLHEAL, - ITEM_ESCAPEROPE, + ITEM_PARALYZE_HEAL, + ITEM_FULL_HEAL, + ITEM_REVIVE, ITEM_REPEL, - ITEM_SUPERREPEL, + ITEM_SUPER_REPEL, + ITEM_POKE_DOLL, ITEM_NONE }; static const u16 sShopInventory_SevenBadges[] = { ITEM_POKE_BALL, - ITEM_GREATBALL, - ITEM_ULTRABALL, + ITEM_GREAT_BALL, + ITEM_ULTRA_BALL, ITEM_POTION, ITEM_SUPER_POTION, - ITEM_HYPERPOTION, - ITEM_MAXPOTION, - ITEM_REVIVE, + ITEM_HYPER_POTION, + ITEM_MAX_POTION, ITEM_ANTIDOTE, - ITEM_PARALYZE_HEAL, + ITEM_BURN_HEAL, + ITEM_ICE_HEAL, ITEM_AWAKENING, - ITEM_BURNHEAL, - ITEM_ICEHEAL, - ITEM_FULLHEAL, - ITEM_ESCAPEROPE, + ITEM_PARALYZE_HEAL, + ITEM_FULL_HEAL, + ITEM_REVIVE, ITEM_REPEL, - ITEM_SUPERREPEL, - ITEM_MAXREPEL, + ITEM_SUPER_REPEL, + ITEM_MAX_REPEL, + ITEM_POKE_DOLL, ITEM_NONE }; static const u16 sShopInventory_EightBadges[] = { ITEM_POKE_BALL, - ITEM_GREATBALL, - ITEM_ULTRABALL, + ITEM_GREAT_BALL, + ITEM_ULTRA_BALL, ITEM_POTION, ITEM_SUPER_POTION, - ITEM_HYPERPOTION, - ITEM_MAXPOTION, - ITEM_FULLRESTORE, - ITEM_REVIVE, + ITEM_HYPER_POTION, + ITEM_MAX_POTION, + ITEM_FULL_RESTORE, ITEM_ANTIDOTE, - ITEM_PARALYZE_HEAL, + ITEM_BURN_HEAL, + ITEM_ICE_HEAL, ITEM_AWAKENING, - ITEM_BURNHEAL, - ITEM_ICEHEAL, - ITEM_FULLHEAL, - ITEM_ESCAPEROPE, + ITEM_PARALYZE_HEAL, + ITEM_FULL_HEAL, + ITEM_REVIVE, ITEM_REPEL, - ITEM_SUPERREPEL, - ITEM_MAXREPEL, + ITEM_SUPER_REPEL, + ITEM_MAX_REPEL, + ITEM_POKE_DOLL, ITEM_NONE }; -static const u16 *sShopInventories[] = +static const u16 *const sShopInventories[] = { sShopInventory_ZeroBadges, sShopInventory_OneBadge, @@ -268,6 +267,7 @@ static const u16 *sShopInventories[] = sShopInventory_EightBadges }; + static const struct YesNoFuncTable sShopPurchaseYesNoFuncs = { BuyMenuTryMakePurchase, @@ -488,15 +488,32 @@ static void SetShopMenuCallback(void (* callback)(void)) sMartInfo.callback = callback; } +static u8 GetNumberOfBadges(void) +{ + u16 badgeFlag; + u8 count = 0; + + for (badgeFlag = FLAG_BADGE01_GET; badgeFlag < FLAG_BADGE01_GET + NUM_BADGES; badgeFlag++) + { + if (FlagGet(badgeFlag)) + count++; + } + + return count; +} + static void SetShopItemsForSale(const u16 *items) { u16 i = 0; u8 badgeCount = GetNumberOfBadges(); - sMartInfo.itemList = items; - sMartInfo.itemCount = 0; + if (items == NULL) + gMartInfo.itemList = sShopInventories[badgeCount]; + else + gMartInfo.itemList = items; - while (sMartInfo.itemList[i]) + gMartInfo.itemCount = 0; + while (gMartInfo.itemList[i]) { sMartInfo.itemCount++; i++; @@ -1404,17 +1421,3 @@ void CreateDecorationShop2Menu(const u16 *itemsForSale) } - -static u8 GetNumberOfBadges(void) -{ - u16 badgeFlag; - u8 count = 0; - - for (badgeFlag = FLAG_BADGE01_GET; badgeFlag < FLAG_BADGE01_GET + NUM_BADGES; badgeFlag++) - { - if (FlagGet(badgeFlag)) - count++; - } - - return count; -}