game/prompt/04_inventory_slots_request.md

67 lines
2.5 KiB
Markdown

# 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
1. **Character Model Update:**
- Maintain `equipment` list (Items currently providing stats).
- Add `inventory` list (Items in the bag, providing NO stats).
- Limit `inventory` size to **16 slots**.
- Add methods: `equipItem(item)`, `unequipItem(item)`.
2. **Battle Logic Update:**
- **Victory Reward:** When an item is selected, add it to `inventory` (not `equipment`).
- If inventory is full (16 items), show a "Inventory Full" message (Snack bar or Log) and discard the item (Simple logic for now).
3. **UI Update (Inventory Screen):**
- **Section 1: Equipment:** Show currently equipped items (List or Row). Tap to Unequip.
- **Section 2: Inventory (Bag):** Use `GridView` with **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 from `inventory` to `equipment`.
- Method `unequip(Item item)`: Moves item from `equipment` to `inventory` (check space first).
## 2. `lib/providers/battle_provider.dart` (Update)
**Changes:**
- `selectReward(Item item)`: Now calls `player.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.builder` with `itemCount: 16`.
- Loop 0 to 15.
- If index < `player.inventory.length`, render the Item Tile (Tap to `equipItem`).
- Else, render an Empty Slot (Grey container with border).
---
# Output Format
Please provide the complete code for the 3 modified files.