74 lines
2.9 KiB
Markdown
74 lines
2.9 KiB
Markdown
# Role
|
|
|
|
You are a Senior Flutter Developer.
|
|
You are continuing the development of "Colosseum's Choice".
|
|
The basic battle prototype is already working.
|
|
Now, you need to implement the **Item & Progression System**.
|
|
|
|
# Goal
|
|
|
|
Modify the existing code to implement the following features:
|
|
|
|
1. **Item Model:** Create items that boost stats (ATK, MaxHP).
|
|
2. **Inventory System:** Player can equip items, and stats are calculated dynamically (Base + Item Bonus).
|
|
3. **Battle Loop:**
|
|
- **Victory:** When Enemy HP <= 0, show a dialog to choose 1 of 3 random items.
|
|
- **Progression:** After picking an item, the next battle starts immediately with a slightly stronger enemy.
|
|
- **HP Rule:** Player HP is NOT fully restored between battles (Roguelike element).
|
|
|
|
# Required Changes & Implementation Details
|
|
|
|
Please generate the updated code for the following files.
|
|
**IMPORTANT:** Preserve the existing "Risk vs Return" and "Armor Decay" logic.
|
|
|
|
---
|
|
|
|
## 1. `lib/models/item.dart` (New File)
|
|
|
|
**Description:**
|
|
|
|
- **Fields:** `String name`, `String description`, `int atkBonus`, `int hpBonus`.
|
|
- **Constructor:** Standard constructor.
|
|
|
|
## 2. `lib/models/character.dart` (Modify)
|
|
|
|
**Description:** Update to support equipment.
|
|
|
|
- **New Fields:** `List<Item> equipment`.
|
|
- **Stat Logic:**
|
|
- `int get totalAtk`: Returns `baseAtk` + sum of all equipped items' `atkBonus`.
|
|
- `int get totalMaxHp`: Returns `baseMaxHp` + sum of all equipped items' `hpBonus`.
|
|
- **Important:** Use `totalAtk` and `totalMaxHp` for battle logic instead of raw fields.
|
|
- **Methods:**
|
|
- `void equip(Item item)`: Add to equipment. If `hpBonus` > 0, increase current `hp` by that amount as well (optional heal).
|
|
|
|
## 3. `lib/providers/battle_provider.dart` (Modify)
|
|
|
|
**Description:** Handle Victory and Stage Progression.
|
|
|
|
- **New Properties:**
|
|
- `int stage`: Tracks current stage number (starts at 1).
|
|
- `List<Item> rewardOptions`: Stores the 3 random items generated upon victory.
|
|
- `bool showRewardPopup`: Flag to trigger UI dialog.
|
|
- **Methods:**
|
|
- `initializeBattle()`: Reset Player (Stage 1).
|
|
- `_onVictory()` (Internal): Called when Enemy dies. Generate 3 random items (e.g., "Rusty Sword (+2 ATK)", "Leather Vest (+10 HP)"). Set `showRewardPopup = true`.
|
|
- `selectReward(Item item)`: Equip item to player -> Increase Stage -> Spawn stronger Enemy (Scale Enemy stats by Stage) -> Reset `showRewardPopup`.
|
|
- **Update `playerAction`**: Ensure it uses `player.totalAtk` for damage calculation.
|
|
|
|
## 4. `lib/screens/battle_screen.dart` (Modify)
|
|
|
|
**Description:** Add UI for stats and rewards.
|
|
|
|
- **Top Area:** Display `Stage: X`. Update HP bars to show `current / totalMaxHp`.
|
|
- **Victory Handling:**
|
|
- Use `Consumer` to listen to `battleProvider`.
|
|
- If `provider.showRewardPopup` is true, show a `SimpleDialog` (or similar) listing the `rewardOptions`.
|
|
- Clicking an option calls `provider.selectReward(item)`.
|
|
|
|
---
|
|
|
|
# Output Format
|
|
|
|
Please provide the complete code for the modified/new files.
|