Repository navigation
Shops
The Shop System allows players to buy and sell items, purchase upgrades, purchase pets, and access gambling rewards during the game.
The Shop is accessed through the Shop button in the top-right corner of the screen.
The Shop contains four tabs:
- Items – Buy items or sell items from the player's inventory.
- Upgrades – Purchase available upgrades.
- Pets – Purchase available pets.
- Gambling – Access Standard and Premium reward pools with fixed prices and weighted prizes.
Handles the shop's underlying data and transactions, including:
- Item catalog
- Upgrade catalog
- Pet catalog
- Standard and Premium gambling catalogs
- Buying and selling
- Gambling transactions and reward delivery
Handles the Shop UI and player interaction, including:
- Opening and closing the Shop
- Category tabs
- Product cards
- Buy/Sell buttons
- Gold display
- Selected item details
- Access to the Gambling tab
When a player selects a product, the detail panel displays its name and price.
The UI checks whether the player has enough gold before enabling the purchase button.
Transactions are handled by ShopComponent, while ShopDisplay refreshes the UI after the shop or inventory changes.
Item listings store the items returned by the shared weapon and consumable generators. The buy price is calculated from the generated item's sell price to match the 60% resale rule. Compatible purchased items can stack with the same generated items.
Purchased items retain their specific behaviour, including consumable effects and weapon stats. This allows purchased potions to be used and purchased swords to function as weapons.
A successful item purchase deducts only the listing price. If the player cannot afford the item or it does not fit in the inventory, gold and inventory remain unchanged, and the listing stays in the shop.
The Gambling tab provides access to Standard and Premium reward pools.
The hidden-box interaction is available in the Inventory. When the player presses a box and pays its fixed coin price, the gambling system selects a prize using the configured weights. The UI then plays the box opening animation and reveals the selected prize without performing another random roll.
Item prizes use the shared weapon and consumable generators. The displayed prize name comes from the generated item, and each item win creates a new item with its corresponding properties.
Upgrade prizes apply their effects through the existing upgrade level-up logic. Only the gambling price is charged, with no additional upgrade price. A transaction the player cannot afford leaves their gold and upgrades unchanged.
Link: https://github.com/UQcsse3200/2026-studio-1/wiki/Shop-Gambling
Open Shop
↓
Select Category
↓
Select Product
↓
View Price
↓
Buy / Sell
↓
ShopComponent processes transaction
↓
UI refreshes
The Shop requires both ShopComponent and ShopDisplay to be attached to the player entity.
The Shop also interacts with InventoryComponent to access the player's inventory and gold.
createPlayer creates one WeaponGenerator and one ConsumableGenerator and passes both into installDefaultCatalog. Item listings and both gambling catalogs use these generators to keep item definitions consistent across starting gear, shop stock, and prizes.
Gambling upgrade rewards use the existing UpgradeNode level-up logic used by the Upgrades tab.
The Shop was tested in-game to verify:
- Shop opens and closes correctly.
- Items, Upgrades, and Pets tabs work.
- Buy/Sell interactions work.
- Gold and inventory updates are reflected in the UI.
- Pet icons are displayed correctly.
Additional scenarios to verify the updated logic include:
- The Gambling tab is accessible.
- Purchased consumables retain their effects, and purchased weapons retain their stats.
- Compatible purchased items stack with the same generated items.
- Successful item purchases deduct only the listing price.
- Unaffordable purchases or purchases that do not fit leave gold, inventory, and shop listings unchanged.
- Gambling item prizes display the generated item's name and create a new item for each win.
- Upgrade prizes apply their effects without an additional upgrade charge.
- Unaffordable gambling transactions leave gold and upgrades unchanged.
- The hidden-box animation reveals the predetermined prize without another random roll.