2.5 KiB
2.5 KiB
Role
You are a Senior Flutter Developer working on "Colosseum's Choice". You need to upgrade the Inventory System to a Grid-based Slot System.
Goal
Separate "Equipped Items" from "Inventory Items" and create a fixed 16-slot inventory interface.
Key Requirements
- Character Model Update:
- Maintain
equipmentlist (Items currently providing stats). - Add
inventorylist (Items in the bag, providing NO stats). - Limit
inventorysize to 16 slots. - Add methods:
equipItem(item),unequipItem(item).
- Maintain
- Battle Logic Update:
- Victory Reward: When an item is selected, add it to
inventory(notequipment). - If inventory is full (16 items), show a "Inventory Full" message (Snack bar or Log) and discard the item (Simple logic for now).
- Victory Reward: When an item is selected, add it to
- UI Update (Inventory Screen):
- Section 1: Equipment: Show currently equipped items (List or Row). Tap to Unequip.
- Section 2: Inventory (Bag): Use
GridViewwith fixed 16 slots (4x4 grid).- If a slot has an item: Show Icon & Name. Tap to Equip.
- If a slot is empty: Show an empty box container.
Required Files
Please generate the updated code for the following files.
1. lib/models/character.dart (Update)
Changes:
- Add
List<Item> inventory = [];. - Add
int maxInventorySize = 16;. - Method
addToInventory(Item item): Adds to inventory if length < 16. Returns success boolean. - Method
equip(Item item): Moves item frominventorytoequipment. - Method
unequip(Item item): Moves item fromequipmenttoinventory(check space first).
2. lib/providers/battle_provider.dart (Update)
Changes:
selectReward(Item item): Now callsplayer.addToInventory(item).- If false (full), add a log "Inventory is full! Item discarded.".
- Add
equipItem(Item item): Calls player logic and notifies listeners. - Add
unequipItem(Item item): Calls player logic and notifies listeners.
3. lib/screens/inventory_screen.dart (Update)
Layout:
- Top (Stats): Keep existing stat display.
- Middle (Equipped): "Currently Equipped" Label ->
ListView(horizontal or vertical, compact). OnTap ->provider.unequipItem. - Bottom (Inventory): "Bag (X/16)" Label ->
GridView.builderwithitemCount: 16.- Loop 0 to 15.
- If index <
player.inventory.length, render the Item Tile (Tap toequipItem). - Else, render an Empty Slot (Grey container with border).
Output Format
Please provide the complete code for the 3 modified files.