2.9 KiB
2.9 KiB
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:
- Item Model: Create items that boost stats (ATK, MaxHP).
- Inventory System: Player can equip items, and stats are calculated dynamically (Base + Item Bonus).
- 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: ReturnsbaseAtk+ sum of all equipped items'atkBonus.int get totalMaxHp: ReturnsbaseMaxHp+ sum of all equipped items'hpBonus.- Important: Use
totalAtkandtotalMaxHpfor battle logic instead of raw fields.
- Methods:
void equip(Item item): Add to equipment. IfhpBonus> 0, increase currenthpby 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)"). SetshowRewardPopup = true.selectReward(Item item): Equip item to player -> Increase Stage -> Spawn stronger Enemy (Scale Enemy stats by Stage) -> ResetshowRewardPopup.- Update
playerAction: Ensure it usesplayer.totalAtkfor 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 showcurrent / totalMaxHp. - Victory Handling:
- Use
Consumerto listen tobattleProvider. - If
provider.showRewardPopupis true, show aSimpleDialog(or similar) listing therewardOptions. - Clicking an option calls
provider.selectReward(item).
- Use
Output Format
Please provide the complete code for the modified/new files.