Skip to content

Commit

Permalink
Merge branch 'mart_badges' of https://github.com/ghoulslash/pokeemerald
Browse files Browse the repository at this point in the history
… into develop
  • Loading branch information
laserXdolphin committed Jul 17, 2024
2 parents b902da2 + 56095f8 commit b5c241d
Showing 1 changed file with 196 additions and 2 deletions.
198 changes: 196 additions & 2 deletions src/shop.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -155,6 +156,179 @@ static void Task_HandleShopMenuSell(u8 taskId);
static void BuyMenuPrintItemDescriptionAndShowItemIcon(s32 item, bool8 onInit, struct ListMenu *list);
static void BuyMenuPrintPriceInList(u8 windowId, u32 itemId, u8 y);

//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_BURN_HEAL,
ITEM_ICE_HEAL,
ITEM_AWAKENING,
ITEM_PARALYZE_HEAL,
ITEM_REVIVE,
ITEM_NONE
};

static const u16 sShopInventory_TwoBadges[] = {
ITEM_POKE_BALL,
ITEM_GREAT_BALL,
ITEM_POTION,
ITEM_SUPER_POTION,
ITEM_ANTIDOTE,
ITEM_BURN_HEAL,
ITEM_ICE_HEAL,
ITEM_AWAKENING,
ITEM_PARALYZE_HEAL,
ITEM_REVIVE,
ITEM_POKE_DOLL,
ITEM_NONE
};

static const u16 sShopInventory_ThreeBadges[] = {
ITEM_POKE_BALL,
ITEM_GREAT_BALL,
ITEM_POTION,
ITEM_SUPER_POTION,
ITEM_ANTIDOTE,
ITEM_BURN_HEAL,
ITEM_ICE_HEAL,
ITEM_AWAKENING,
ITEM_PARALYZE_HEAL,
ITEM_REVIVE,
ITEM_REPEL,
ITEM_POKE_DOLL,
ITEM_NONE
};

static const u16 sShopInventory_FourBadges[] = {
ITEM_POKE_BALL,
ITEM_GREAT_BALL,
ITEM_POTION,
ITEM_SUPER_POTION,
ITEM_HYPER_POTION,
ITEM_ANTIDOTE,
ITEM_BURN_HEAL,
ITEM_ICE_HEAL,
ITEM_AWAKENING,
ITEM_PARALYZE_HEAL,
ITEM_REVIVE,
ITEM_REPEL,
ITEM_POKE_DOLL,
ITEM_NONE
};

static const u16 sShopInventory_FiveBadges[] = {
ITEM_POKE_BALL,
ITEM_GREAT_BALL,
ITEM_ULTRA_BALL,
ITEM_POTION,
ITEM_SUPER_POTION,
ITEM_HYPER_POTION,
ITEM_ANTIDOTE,
ITEM_BURN_HEAL,
ITEM_ICE_HEAL,
ITEM_AWAKENING,
ITEM_PARALYZE_HEAL,
ITEM_REVIVE,
ITEM_REPEL,
ITEM_SUPER_REPEL,
ITEM_POKE_DOLL,
ITEM_NONE
};

static const u16 sShopInventory_SixBadges[] = {
ITEM_POKE_BALL,
ITEM_GREAT_BALL,
ITEM_ULTRA_BALL,
ITEM_POTION,
ITEM_SUPER_POTION,
ITEM_HYPER_POTION,
ITEM_ANTIDOTE,
ITEM_BURN_HEAL,
ITEM_ICE_HEAL,
ITEM_AWAKENING,
ITEM_PARALYZE_HEAL,
ITEM_FULL_HEAL,
ITEM_REVIVE,
ITEM_REPEL,
ITEM_SUPER_REPEL,
ITEM_POKE_DOLL,
ITEM_NONE
};

static const u16 sShopInventory_SevenBadges[] = {
ITEM_POKE_BALL,
ITEM_GREAT_BALL,
ITEM_ULTRA_BALL,
ITEM_POTION,
ITEM_SUPER_POTION,
ITEM_HYPER_POTION,
ITEM_MAX_POTION,
ITEM_ANTIDOTE,
ITEM_BURN_HEAL,
ITEM_ICE_HEAL,
ITEM_AWAKENING,
ITEM_PARALYZE_HEAL,
ITEM_FULL_HEAL,
ITEM_REVIVE,
ITEM_REPEL,
ITEM_SUPER_REPEL,
ITEM_MAX_REPEL,
ITEM_POKE_DOLL,
ITEM_NONE
};

static const u16 sShopInventory_EightBadges[] = {
ITEM_POKE_BALL,
ITEM_GREAT_BALL,
ITEM_ULTRA_BALL,
ITEM_POTION,
ITEM_SUPER_POTION,
ITEM_HYPER_POTION,
ITEM_MAX_POTION,
ITEM_FULL_RESTORE,
ITEM_ANTIDOTE,
ITEM_BURN_HEAL,
ITEM_ICE_HEAL,
ITEM_AWAKENING,
ITEM_PARALYZE_HEAL,
ITEM_FULL_HEAL,
ITEM_REVIVE,
ITEM_REPEL,
ITEM_SUPER_REPEL,
ITEM_MAX_REPEL,
ITEM_POKE_DOLL,
ITEM_NONE
};

static const u16 *const sShopInventories[] =
{
sShopInventory_ZeroBadges,
sShopInventory_OneBadge,
sShopInventory_TwoBadges,
sShopInventory_ThreeBadges,
sShopInventory_FourBadges,
sShopInventory_FiveBadges,
sShopInventory_SixBadges,
sShopInventory_SevenBadges,
sShopInventory_EightBadges
};


static const struct YesNoFuncTable sShopPurchaseYesNoFuncs =
{
BuyMenuTryMakePurchase,
Expand Down Expand Up @@ -374,13 +548,31 @@ 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;

gMartInfo.itemCount = 0;
// Read items until ITEM_NONE / DECOR_NONE is reached
while (sMartInfo.itemList[i])
{
Expand Down Expand Up @@ -1298,3 +1490,5 @@ void CreateDecorationShop2Menu(const u16 *itemsForSale)
SetShopItemsForSale(itemsForSale);
SetShopMenuCallback(ScriptContext_Enable);
}


0 comments on commit b5c241d

Please sign in to comment.