update
This commit is contained in:
+101
-10
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:game_test/game/model/item.dart';
|
||||
import 'package:game_test/game/model/stage.dart'; // Import StageModel
|
||||
import 'package:provider/provider.dart';
|
||||
import '../providers/battle_provider.dart';
|
||||
import '../game/model/entity.dart';
|
||||
@@ -19,7 +20,9 @@ class _BattleScreenState extends State<BattleScreen> {
|
||||
super.initState();
|
||||
// Scroll to the bottom of the log when new messages are added
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_scrollController.jumpTo(_scrollController.position.maxScrollExtent);
|
||||
if (_scrollController.hasClients) {
|
||||
_scrollController.jumpTo(_scrollController.position.maxScrollExtent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -120,8 +123,9 @@ class _BattleScreenState extends State<BattleScreen> {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Consumer<BattleProvider>(
|
||||
builder: (context, provider, child) =>
|
||||
Text("Colosseum's Choice - Stage ${provider.stage}"),
|
||||
builder: (context, provider, child) => Text(
|
||||
"Colosseum - Stage ${provider.stage} (${provider.currentStage.type.name.toUpperCase()})",
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
@@ -132,6 +136,49 @@ class _BattleScreenState extends State<BattleScreen> {
|
||||
),
|
||||
body: Consumer<BattleProvider>(
|
||||
builder: (context, battleProvider, child) {
|
||||
// UI Switching based on Stage Type
|
||||
if (battleProvider.currentStage.type == StageType.shop) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.store, size: 64, color: Colors.amber),
|
||||
const SizedBox(height: 16),
|
||||
const Text("Merchant Shop", style: TextStyle(fontSize: 24)),
|
||||
const SizedBox(height: 8),
|
||||
const Text("Buying/Selling feature coming soon!"),
|
||||
const SizedBox(height: 32),
|
||||
ElevatedButton(
|
||||
onPressed: () => battleProvider.proceedToNextStage(),
|
||||
child: const Text("Leave Shop"),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else if (battleProvider.currentStage.type == StageType.rest) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.local_hotel, size: 64, color: Colors.blue),
|
||||
const SizedBox(height: 16),
|
||||
const Text("Rest Area", style: TextStyle(fontSize: 24)),
|
||||
const SizedBox(height: 8),
|
||||
const Text("Take a breath and heal."),
|
||||
const SizedBox(height: 32),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
battleProvider.player.heal(20); // Simple heal
|
||||
battleProvider.proceedToNextStage();
|
||||
},
|
||||
child: const Text("Rest & Leave (+20 HP)"),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Default: Battle UI (for Battle and Elite)
|
||||
return Stack(
|
||||
children: [
|
||||
Column(
|
||||
@@ -251,14 +298,30 @@ class _BattleScreenState extends State<BattleScreen> {
|
||||
if (item.hpBonus > 0) stats.add("+${item.hpBonus} HP");
|
||||
if (item.armorBonus > 0) stats.add("+${item.armorBonus} DEF");
|
||||
|
||||
if (stats.isEmpty) return const SizedBox.shrink(); // Hide if no stats
|
||||
List<String> effectTexts = item.effects.map((e) => e.description).toList();
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 4.0, bottom: 4.0),
|
||||
child: Text(
|
||||
stats.join(", "),
|
||||
style: const TextStyle(fontSize: 12, color: Colors.blueAccent),
|
||||
),
|
||||
if (stats.isEmpty && effectTexts.isEmpty) return const SizedBox.shrink();
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (stats.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4.0, bottom: 4.0),
|
||||
child: Text(
|
||||
stats.join(", "),
|
||||
style: const TextStyle(fontSize: 12, color: Colors.blueAccent),
|
||||
),
|
||||
),
|
||||
if (effectTexts.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 4.0),
|
||||
child: Text(
|
||||
effectTexts.join(", "),
|
||||
style: const TextStyle(fontSize: 11, color: Colors.orangeAccent),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -282,6 +345,34 @@ class _BattleScreenState extends State<BattleScreen> {
|
||||
backgroundColor: Colors.grey,
|
||||
),
|
||||
),
|
||||
// Display Active Status Effects
|
||||
if (character.statusEffects.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4.0),
|
||||
child: Wrap(
|
||||
spacing: 4.0,
|
||||
children: character.statusEffects.map((effect) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 6,
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.deepOrange,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
"${effect.type.name.toUpperCase()} (${effect.duration})",
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
if (!isEnemy) ...[
|
||||
Text("Armor: ${character.armor}"),
|
||||
Text("ATK: ${character.totalAtk}"),
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../providers/battle_provider.dart';
|
||||
import 'main_wrapper.dart';
|
||||
|
||||
class CharacterSelectionScreen extends StatelessWidget {
|
||||
const CharacterSelectionScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text("Choose Your Hero"),
|
||||
centerTitle: true,
|
||||
),
|
||||
body: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
// Initialize Game
|
||||
context.read<BattleProvider>().initializeBattle();
|
||||
|
||||
// Navigate to Game Screen (MainWrapper)
|
||||
// Using pushReplacement to prevent going back to selection
|
||||
Navigator.pushAndRemoveUntil(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => const MainWrapper()),
|
||||
(route) => false,
|
||||
);
|
||||
},
|
||||
child: Card(
|
||||
color: Colors.blueGrey[800],
|
||||
elevation: 8,
|
||||
child: Container(
|
||||
width: 300,
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(Icons.shield, size: 80, color: Colors.blue),
|
||||
const SizedBox(height: 16),
|
||||
const Text(
|
||||
"Warrior",
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const Text(
|
||||
"A balanced fighter with a sword and shield. Great for beginners.",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: Colors.grey),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const Divider(),
|
||||
const SizedBox(height: 8),
|
||||
const Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Text("HP: 100", style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
Text("ATK: 10", style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
Text("DEF: 5", style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import 'package:provider/provider.dart';
|
||||
import '../providers/battle_provider.dart';
|
||||
import '../game/model/item.dart';
|
||||
import '../game/model/entity.dart';
|
||||
import '../game/model/stage.dart'; // Import StageModel
|
||||
|
||||
class InventoryScreen extends StatelessWidget {
|
||||
const InventoryScreen({super.key});
|
||||
@@ -40,7 +41,8 @@ class InventoryScreen extends StatelessWidget {
|
||||
),
|
||||
_buildStatItem("ATK", "${player.totalAtk}"),
|
||||
_buildStatItem("DEF", "${player.totalDefense}"),
|
||||
_buildStatItem("Shield", "${player.armor}"), // Temporary armor points
|
||||
_buildStatItem("Shield", "${player.armor}"),
|
||||
_buildStatItem("Gold", "${player.gold} G", color: Colors.amber),
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -154,12 +156,8 @@ class InventoryScreen extends StatelessWidget {
|
||||
final item = player.inventory[index];
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
// Show confirmation dialog before equipping
|
||||
_showEquipConfirmationDialog(
|
||||
context,
|
||||
battleProvider,
|
||||
item,
|
||||
);
|
||||
// Show Action Dialog instead of direct Equip
|
||||
_showItemActionDialog(context, battleProvider, item);
|
||||
},
|
||||
child: Card(
|
||||
color: Colors.blueGrey[700],
|
||||
@@ -216,18 +214,143 @@ class InventoryScreen extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildStatItem(String label, String value) {
|
||||
Widget _buildStatItem(String label, String value, {Color? color}) {
|
||||
return Column(
|
||||
children: [
|
||||
Text(label, style: const TextStyle(color: Colors.grey, fontSize: 12)),
|
||||
Text(
|
||||
value,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// Shows a menu with actions for the selected item (Equip, Discard, etc.)
|
||||
void _showItemActionDialog(
|
||||
BuildContext context, BattleProvider provider, Item item) {
|
||||
|
||||
bool isShop = provider.currentStage.type == StageType.shop;
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => SimpleDialog(
|
||||
title: Text("${item.name} Actions"),
|
||||
children: [
|
||||
SimpleDialogOption(
|
||||
onPressed: () {
|
||||
Navigator.pop(ctx);
|
||||
_showEquipConfirmationDialog(context, provider, item);
|
||||
},
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.shield, color: Colors.blue),
|
||||
SizedBox(width: 10),
|
||||
Text("Equip"),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
if (isShop)
|
||||
SimpleDialogOption(
|
||||
onPressed: () {
|
||||
Navigator.pop(ctx);
|
||||
_showSellConfirmationDialog(context, provider, item);
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.attach_money, color: Colors.amber),
|
||||
const SizedBox(width: 10),
|
||||
Text("Sell (${item.price} G)"),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SimpleDialogOption(
|
||||
onPressed: () {
|
||||
Navigator.pop(ctx);
|
||||
_showDiscardConfirmationDialog(context, provider, item);
|
||||
},
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.delete, color: Colors.red),
|
||||
SizedBox(width: 10),
|
||||
Text("Discard"),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showSellConfirmationDialog(
|
||||
BuildContext context,
|
||||
BattleProvider provider,
|
||||
Item item,
|
||||
) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: const Text("Sell Item"),
|
||||
content: Text("Sell ${item.name} for ${item.price} G?"),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx),
|
||||
child: const Text("Cancel"),
|
||||
),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(backgroundColor: Colors.amber),
|
||||
onPressed: () {
|
||||
provider.sellItem(item);
|
||||
Navigator.pop(ctx);
|
||||
},
|
||||
child: const Text("Sell", style: TextStyle(color: Colors.black)),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showDiscardConfirmationDialog(
|
||||
BuildContext context,
|
||||
BattleProvider provider,
|
||||
Item item,
|
||||
) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: const Text("Discard Item"),
|
||||
content: Text("Are you sure you want to discard ${item.name}?"),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx),
|
||||
child: const Text("Cancel"),
|
||||
),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(backgroundColor: Colors.red),
|
||||
onPressed: () {
|
||||
provider.discardItem(item);
|
||||
Navigator.pop(ctx);
|
||||
},
|
||||
child: const Text("Discard"),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showEquipConfirmationDialog(
|
||||
BuildContext context,
|
||||
BattleProvider provider,
|
||||
@@ -395,14 +518,32 @@ class InventoryScreen extends StatelessWidget {
|
||||
if (item.hpBonus > 0) stats.add("+${item.hpBonus} HP");
|
||||
if (item.armorBonus > 0) stats.add("+${item.armorBonus} DEF");
|
||||
|
||||
if (stats.isEmpty) return const SizedBox.shrink(); // Hide if no stats
|
||||
// Include effects
|
||||
List<String> effectTexts = item.effects.map((e) => e.description).toList();
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 2.0, bottom: 2.0),
|
||||
child: Text(
|
||||
stats.join(", "),
|
||||
style: const TextStyle(fontSize: 10, color: Colors.blueAccent),
|
||||
),
|
||||
if (stats.isEmpty && effectTexts.isEmpty) return const SizedBox.shrink();
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
if (stats.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 2.0, bottom: 2.0),
|
||||
child: Text(
|
||||
stats.join(", "),
|
||||
style: const TextStyle(fontSize: 10, color: Colors.blueAccent),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
if (effectTexts.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 2.0),
|
||||
child: Text(
|
||||
effectTexts.join("\n"),
|
||||
style: const TextStyle(fontSize: 9, color: Colors.orangeAccent),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'character_selection_screen.dart';
|
||||
|
||||
class MainMenuScreen extends StatelessWidget {
|
||||
const MainMenuScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [Colors.black, Colors.blueGrey[900]!],
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.gavel, size: 100, color: Colors.amber),
|
||||
const SizedBox(height: 20),
|
||||
const Text(
|
||||
"COLOSSEUM'S CHOICE",
|
||||
style: TextStyle(
|
||||
fontSize: 32,
|
||||
fontWeight: FontWeight.bold,
|
||||
letterSpacing: 2.0,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
const Text(
|
||||
"Rise as a Legend",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.grey,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 60),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const CharacterSelectionScreen(),
|
||||
),
|
||||
);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 50, vertical: 15),
|
||||
backgroundColor: Colors.amber[700],
|
||||
foregroundColor: Colors.black,
|
||||
textStyle:
|
||||
const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
child: const Text("START GAME"),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user