update
This commit is contained in:
@@ -24,3 +24,5 @@ enum StageType {
|
||||
}
|
||||
|
||||
enum EquipmentSlot { weapon, armor, shield, accessory }
|
||||
|
||||
enum DamageType { normal, bleed, vulnerable }
|
||||
|
||||
@@ -1,15 +1,27 @@
|
||||
import 'package:flutter/material.dart'; // Color 사용을 위해 import
|
||||
import 'package:flutter/material.dart';
|
||||
import '../enums.dart';
|
||||
|
||||
enum DamageTarget { player, enemy }
|
||||
|
||||
class DamageEvent {
|
||||
final int damage;
|
||||
final DamageTarget target;
|
||||
final Color color; // 데미지 타입에 따른 색상 (예: 일반 공격, 치명타 등)
|
||||
final DamageType type;
|
||||
|
||||
DamageEvent({
|
||||
required this.damage,
|
||||
required this.target,
|
||||
this.color = Colors.red, // 기본 색상은 빨강
|
||||
this.type = DamageType.normal,
|
||||
});
|
||||
|
||||
Color get color {
|
||||
switch (type) {
|
||||
case DamageType.normal:
|
||||
return Colors.grey;
|
||||
case DamageType.bleed:
|
||||
return Colors.red;
|
||||
case DamageType.vulnerable:
|
||||
return Colors.orange;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+150
-115
@@ -18,12 +18,16 @@ class EnemyIntent {
|
||||
final int value;
|
||||
final RiskLevel risk;
|
||||
final String description;
|
||||
final bool isSuccess;
|
||||
final int finalValue;
|
||||
|
||||
EnemyIntent({
|
||||
required this.type,
|
||||
required this.value,
|
||||
required this.risk,
|
||||
required this.description,
|
||||
required this.isSuccess,
|
||||
required this.finalValue,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -38,9 +42,12 @@ class BattleProvider with ChangeNotifier {
|
||||
bool isPlayerTurn = true;
|
||||
|
||||
int stage = 1;
|
||||
int turnCount = 1;
|
||||
List<Item> rewardOptions = [];
|
||||
bool showRewardPopup = false;
|
||||
|
||||
List<String> get logs => battleLogs;
|
||||
|
||||
// Damage Event Stream
|
||||
final _damageEventController = StreamController<DamageEvent>.broadcast();
|
||||
Stream<DamageEvent> get damageStream => _damageEventController.stream;
|
||||
@@ -62,11 +69,12 @@ class BattleProvider with ChangeNotifier {
|
||||
|
||||
void initializeBattle() {
|
||||
stage = 1;
|
||||
turnCount = 1;
|
||||
player = Character(
|
||||
name: "Player",
|
||||
maxHp: 100,
|
||||
maxHp: 80,
|
||||
armor: 0,
|
||||
atk: 10,
|
||||
atk: 5,
|
||||
baseDefense: 5,
|
||||
);
|
||||
|
||||
@@ -213,6 +221,7 @@ class BattleProvider with ChangeNotifier {
|
||||
enemy: newEnemy,
|
||||
shopItems: shopItems,
|
||||
);
|
||||
turnCount = 1;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -267,61 +276,63 @@ class BattleProvider with ChangeNotifier {
|
||||
break;
|
||||
}
|
||||
|
||||
if (success) {
|
||||
if (success) {
|
||||
if (type == ActionType.attack) {
|
||||
int damage = (player.totalAtk * efficiency).toInt();
|
||||
|
||||
if (type == ActionType.attack) {
|
||||
_effectEventController.sink.add(
|
||||
EffectEvent(
|
||||
type: ActionType.attack,
|
||||
|
||||
int damage = (player.totalAtk * efficiency).toInt();
|
||||
risk: risk,
|
||||
|
||||
|
||||
|
||||
_effectEventController.sink.add(EffectEvent(
|
||||
|
||||
type: ActionType.attack,
|
||||
|
||||
risk: risk,
|
||||
|
||||
target: EffectTarget.enemy,
|
||||
|
||||
));
|
||||
|
||||
|
||||
|
||||
_applyDamage(enemy, damage, targetType: DamageTarget.enemy); // Add targetType
|
||||
|
||||
_addLog("Player dealt $damage damage to Enemy.");
|
||||
|
||||
|
||||
|
||||
// Try applying status effects from items
|
||||
|
||||
_tryApplyStatusEffects(player, enemy);
|
||||
target: EffectTarget.enemy,
|
||||
),
|
||||
);
|
||||
|
||||
int damageToHp = 0;
|
||||
if (enemy.armor > 0) {
|
||||
if (enemy.armor >= damage) {
|
||||
enemy.armor -= damage;
|
||||
damageToHp = 0;
|
||||
_addLog("Enemy's armor absorbed all $damage damage.");
|
||||
} else {
|
||||
|
||||
_effectEventController.sink.add(EffectEvent(
|
||||
|
||||
type: ActionType.defend,
|
||||
|
||||
risk: risk,
|
||||
|
||||
target: EffectTarget.player,
|
||||
|
||||
));
|
||||
|
||||
|
||||
|
||||
int armorGained = (player.totalDefense * efficiency).toInt();
|
||||
|
||||
player.armor += armorGained;
|
||||
|
||||
_addLog("Player gained $armorGained armor.");
|
||||
|
||||
damageToHp = damage - enemy.armor;
|
||||
_addLog("Enemy's armor absorbed ${enemy.armor} damage.");
|
||||
enemy.armor = 0;
|
||||
}
|
||||
|
||||
} else {
|
||||
damageToHp = damage;
|
||||
}
|
||||
|
||||
else {
|
||||
if (damageToHp > 0) {
|
||||
_applyDamage(enemy, damageToHp, targetType: DamageTarget.enemy);
|
||||
_addLog("Player dealt $damageToHp damage to Enemy.");
|
||||
} else {
|
||||
_addLog("Player's attack was fully blocked by armor.");
|
||||
}
|
||||
|
||||
// Try applying status effects from items
|
||||
|
||||
_tryApplyStatusEffects(player, enemy);
|
||||
} else {
|
||||
_effectEventController.sink.add(
|
||||
EffectEvent(
|
||||
type: ActionType.defend,
|
||||
|
||||
risk: risk,
|
||||
|
||||
target: EffectTarget.player,
|
||||
),
|
||||
);
|
||||
|
||||
int armorGained = (player.totalDefense * efficiency).toInt();
|
||||
|
||||
player.armor += armorGained;
|
||||
|
||||
_addLog("Player gained $armorGained armor.");
|
||||
}
|
||||
} else {
|
||||
_addLog("Player's action missed!");
|
||||
}
|
||||
|
||||
@@ -352,6 +363,13 @@ class BattleProvider with ChangeNotifier {
|
||||
_addLog("Enemy's turn...");
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
|
||||
// Enemy Turn Start Logic
|
||||
// Armor decay
|
||||
if (enemy.armor > 0) {
|
||||
enemy.armor = (enemy.armor * 0.5).toInt();
|
||||
_addLog("Enemy's armor decayed to ${enemy.armor}.");
|
||||
}
|
||||
|
||||
// 1. Process Start-of-Turn Effects for Enemy
|
||||
bool canAct = _processStartTurnEffects(enemy);
|
||||
|
||||
@@ -370,28 +388,16 @@ class BattleProvider with ChangeNotifier {
|
||||
_addLog("Enemy maintains defensive stance.");
|
||||
} else {
|
||||
// Attack Logic
|
||||
final random = Random();
|
||||
bool success = false;
|
||||
switch (intent.risk) {
|
||||
case RiskLevel.safe:
|
||||
success = random.nextDouble() < 1.0;
|
||||
break;
|
||||
case RiskLevel.normal:
|
||||
success = random.nextDouble() < 0.8;
|
||||
break;
|
||||
case RiskLevel.risky:
|
||||
success = random.nextDouble() < 0.4;
|
||||
break;
|
||||
}
|
||||
if (intent.isSuccess) {
|
||||
_effectEventController.sink.add(
|
||||
EffectEvent(
|
||||
type: ActionType.attack,
|
||||
risk: intent.risk,
|
||||
target: EffectTarget.player,
|
||||
),
|
||||
);
|
||||
|
||||
if (success) {
|
||||
_effectEventController.sink.add(EffectEvent(
|
||||
type: ActionType.attack,
|
||||
risk: intent.risk,
|
||||
target: EffectTarget.player,
|
||||
));
|
||||
|
||||
int incomingDamage = intent.value;
|
||||
int incomingDamage = intent.finalValue;
|
||||
int damageToHp = 0;
|
||||
|
||||
// Handle Player Armor
|
||||
@@ -440,6 +446,7 @@ class BattleProvider with ChangeNotifier {
|
||||
}
|
||||
|
||||
isPlayerTurn = true;
|
||||
turnCount++;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -461,17 +468,21 @@ class BattleProvider with ChangeNotifier {
|
||||
|
||||
// Emit DamageEvent for bleed
|
||||
if (character == player) {
|
||||
_damageEventController.sink.add(DamageEvent(
|
||||
damage: totalBleed,
|
||||
target: DamageTarget.player,
|
||||
color: Colors.purpleAccent, // Bleed damage color
|
||||
));
|
||||
_damageEventController.sink.add(
|
||||
DamageEvent(
|
||||
damage: totalBleed,
|
||||
target: DamageTarget.player,
|
||||
type: DamageType.bleed,
|
||||
),
|
||||
);
|
||||
} else if (character == enemy) {
|
||||
_damageEventController.sink.add(DamageEvent(
|
||||
damage: totalBleed,
|
||||
target: DamageTarget.enemy,
|
||||
color: Colors.purpleAccent, // Bleed damage color
|
||||
));
|
||||
_damageEventController.sink.add(
|
||||
DamageEvent(
|
||||
damage: totalBleed,
|
||||
target: DamageTarget.enemy,
|
||||
type: DamageType.bleed,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -505,22 +516,25 @@ class BattleProvider with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
void _applyDamage(Character target, int damage, {required DamageTarget targetType, Color color = Colors.red}) {
|
||||
void _applyDamage(
|
||||
Character target,
|
||||
int damage, {
|
||||
required DamageTarget targetType,
|
||||
DamageType type = DamageType.normal,
|
||||
}) {
|
||||
// Check Vulnerable
|
||||
if (target.hasStatus(StatusEffectType.vulnerable)) {
|
||||
damage = (damage * 1.5).toInt();
|
||||
_addLog("Vulnerable! Damage increased to $damage.");
|
||||
color = Colors.orange; // Vulnerable damage color
|
||||
type = DamageType.vulnerable;
|
||||
}
|
||||
|
||||
target.hp -= damage;
|
||||
if (target.hp < 0) target.hp = 0;
|
||||
|
||||
_damageEventController.sink.add(DamageEvent(
|
||||
damage: damage,
|
||||
target: targetType,
|
||||
color: color,
|
||||
));
|
||||
_damageEventController.sink.add(
|
||||
DamageEvent(damage: damage, target: targetType, type: type),
|
||||
);
|
||||
}
|
||||
|
||||
void _addLog(String message) {
|
||||
@@ -554,7 +568,7 @@ class BattleProvider with ChangeNotifier {
|
||||
}
|
||||
|
||||
// Heal player after selecting reward
|
||||
int healAmount = GameMath.floor(player.totalMaxHp * 0.5);
|
||||
int healAmount = GameMath.floor(player.totalMaxHp * 0.1);
|
||||
player.heal(healAmount);
|
||||
_addLog("Stage Cleared! Recovered $healAmount HP.");
|
||||
|
||||
@@ -653,27 +667,7 @@ class BattleProvider with ChangeNotifier {
|
||||
int damage = (enemy.totalAtk * efficiency * variance).toInt();
|
||||
if (damage < 1) damage = 1;
|
||||
|
||||
currentEnemyIntent = EnemyIntent(
|
||||
type: EnemyActionType.attack,
|
||||
value: damage,
|
||||
risk: risk,
|
||||
description: "Attacks for $damage (${risk.name})",
|
||||
);
|
||||
} else {
|
||||
// Defend Intent
|
||||
int baseDef = enemy.totalDefense;
|
||||
// Variance
|
||||
double variance = 0.8 + random.nextDouble() * 0.4;
|
||||
int armor = (baseDef * 2 * efficiency * variance).toInt();
|
||||
|
||||
currentEnemyIntent = EnemyIntent(
|
||||
type: EnemyActionType.defend,
|
||||
value: armor,
|
||||
risk: risk,
|
||||
description: "Defends for $armor (${risk.name})",
|
||||
);
|
||||
|
||||
// [Changed] Apply defense immediately for pre-emptive defense
|
||||
// Calculate success immediately
|
||||
bool success = false;
|
||||
switch (risk) {
|
||||
case RiskLevel.safe:
|
||||
@@ -687,18 +681,59 @@ class BattleProvider with ChangeNotifier {
|
||||
break;
|
||||
}
|
||||
|
||||
currentEnemyIntent = EnemyIntent(
|
||||
type: EnemyActionType.attack,
|
||||
value: damage,
|
||||
risk: risk,
|
||||
description: "Attacks for $damage (${risk.name})",
|
||||
isSuccess: success,
|
||||
finalValue: damage,
|
||||
);
|
||||
} else {
|
||||
// Defend Intent
|
||||
int baseDef = enemy.totalDefense;
|
||||
// Variance
|
||||
double variance = 0.8 + random.nextDouble() * 0.4;
|
||||
int armor = (baseDef * 2 * efficiency * variance).toInt();
|
||||
|
||||
// Calculate success immediately
|
||||
bool success = false;
|
||||
switch (risk) {
|
||||
case RiskLevel.safe:
|
||||
success = random.nextDouble() < 1.0;
|
||||
break;
|
||||
case RiskLevel.normal:
|
||||
success = random.nextDouble() < 0.8;
|
||||
break;
|
||||
case RiskLevel.risky:
|
||||
success = random.nextDouble() < 0.4;
|
||||
break;
|
||||
}
|
||||
|
||||
currentEnemyIntent = EnemyIntent(
|
||||
type: EnemyActionType.defend,
|
||||
value: armor,
|
||||
risk: risk,
|
||||
description: "Defends for $armor (${risk.name})",
|
||||
isSuccess: success,
|
||||
finalValue: armor,
|
||||
);
|
||||
|
||||
// Apply defense immediately if successful
|
||||
if (success) {
|
||||
enemy.armor += armor;
|
||||
_addLog("Enemy prepares defense! (+$armor Armor)");
|
||||
_effectEventController.sink.add(EffectEvent(
|
||||
type: ActionType.defend,
|
||||
risk: risk,
|
||||
target: EffectTarget.enemy,
|
||||
));
|
||||
_effectEventController.sink.add(
|
||||
EffectEvent(
|
||||
type: ActionType.defend,
|
||||
risk: risk,
|
||||
target: EffectTarget.enemy,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
_addLog("Enemy tried to defend but fumbled!");
|
||||
}
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+194
-150
@@ -1,13 +1,14 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:game_test/game/model/item.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../providers/battle_provider.dart';
|
||||
import '../game/model/entity.dart';
|
||||
import '../game/enums.dart';
|
||||
|
||||
import '../game/model/item.dart';
|
||||
import '../game/model/damage_event.dart';
|
||||
import '../game/model/effect_event.dart';
|
||||
import 'dart:async'; // StreamSubscription
|
||||
import 'dart:async';
|
||||
import '../widgets/responsive_container.dart';
|
||||
import '../utils/item_utils.dart';
|
||||
|
||||
class BattleScreen extends StatefulWidget {
|
||||
const BattleScreen({super.key});
|
||||
@@ -24,18 +25,17 @@ class _BattleScreenState extends State<BattleScreen> {
|
||||
StreamSubscription<EffectEvent>? _effectSubscription;
|
||||
final GlobalKey _playerKey = GlobalKey();
|
||||
final GlobalKey _enemyKey = GlobalKey();
|
||||
final GlobalKey _stackKey = GlobalKey();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// Scroll to the bottom of the log when new messages are added
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (_scrollController.hasClients) {
|
||||
_scrollController.jumpTo(_scrollController.position.maxScrollExtent);
|
||||
}
|
||||
});
|
||||
|
||||
// Subscribe to Damage Stream
|
||||
final battleProvider = context.read<BattleProvider>();
|
||||
_damageSubscription = battleProvider.damageStream.listen(
|
||||
_addFloatingDamageText,
|
||||
@@ -68,13 +68,13 @@ class _BattleScreenState extends State<BattleScreen> {
|
||||
|
||||
Offset position = renderBox.localToGlobal(Offset.zero);
|
||||
|
||||
RenderBox? stackRenderBox = context.findRenderObject() as RenderBox?;
|
||||
RenderBox? stackRenderBox =
|
||||
_stackKey.currentContext?.findRenderObject() as RenderBox?;
|
||||
if (stackRenderBox != null) {
|
||||
Offset stackOffset = stackRenderBox.localToGlobal(Offset.zero);
|
||||
position = position - stackOffset;
|
||||
}
|
||||
|
||||
// 중앙 정렬 보정 및 위쪽으로 이동
|
||||
position = position + Offset(renderBox.size.width / 2 - 20, -20);
|
||||
|
||||
final String id = UniqueKey().toString();
|
||||
@@ -119,13 +119,14 @@ class _BattleScreenState extends State<BattleScreen> {
|
||||
if (renderBox == null) return;
|
||||
|
||||
Offset position = renderBox.localToGlobal(Offset.zero);
|
||||
RenderBox? stackRenderBox = context.findRenderObject() as RenderBox?;
|
||||
|
||||
RenderBox? stackRenderBox =
|
||||
_stackKey.currentContext?.findRenderObject() as RenderBox?;
|
||||
if (stackRenderBox != null) {
|
||||
Offset stackOffset = stackRenderBox.localToGlobal(Offset.zero);
|
||||
position = position - stackOffset;
|
||||
}
|
||||
|
||||
// 중앙 정렬
|
||||
position =
|
||||
position +
|
||||
Offset(renderBox.size.width / 2 - 30, renderBox.size.height / 2 - 30);
|
||||
@@ -248,7 +249,6 @@ class _BattleScreenState extends State<BattleScreen> {
|
||||
onPressed: () {
|
||||
context.read<BattleProvider>().playerAction(actionType, risk);
|
||||
Navigator.pop(context);
|
||||
// Ensure the log scrolls to the bottom after action
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_scrollController.animateTo(
|
||||
_scrollController.position.maxScrollExtent,
|
||||
@@ -279,132 +279,135 @@ class _BattleScreenState extends State<BattleScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Consumer<BattleProvider>(
|
||||
builder: (context, provider, child) => Text(
|
||||
"Colosseum - Stage ${provider.stage} (${provider.currentStage.type.name.toUpperCase()})",
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.refresh),
|
||||
onPressed: () => context.read<BattleProvider>().initializeBattle(),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Consumer<BattleProvider>(
|
||||
return ResponsiveContainer(
|
||||
child: 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"),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
return _buildShopUI(context, battleProvider);
|
||||
} 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)"),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
return _buildRestUI(context, battleProvider);
|
||||
}
|
||||
|
||||
// Default: Battle UI (for Battle and Elite)
|
||||
return Stack(
|
||||
key: _stackKey,
|
||||
children: [
|
||||
Container(color: Colors.black87),
|
||||
Column(
|
||||
children: [
|
||||
// Top (Status Area)
|
||||
// Top Bar
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
_buildCharacterStatus(
|
||||
battleProvider.enemy,
|
||||
isEnemy: true,
|
||||
key: _enemyKey,
|
||||
Text(
|
||||
"Stage ${battleProvider.stage}",
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
_buildCharacterStatus(
|
||||
battleProvider.player,
|
||||
isEnemy: false,
|
||||
key: _playerKey,
|
||||
Text(
|
||||
"Turn ${battleProvider.turnCount}",
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// Middle (Log Area)
|
||||
|
||||
// Battle Area
|
||||
Expanded(
|
||||
child: Container(
|
||||
color: Colors.black87,
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: ListView.builder(
|
||||
controller: _scrollController,
|
||||
itemCount: battleProvider.battleLogs.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Text(
|
||||
battleProvider.battleLogs[index],
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontFamily: 'Monospace',
|
||||
fontSize: 12,
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Center(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
_buildCharacterStatus(
|
||||
battleProvider.player,
|
||||
isPlayer: true,
|
||||
isTurn: battleProvider.isPlayerTurn,
|
||||
key: _playerKey,
|
||||
),
|
||||
// const Text(
|
||||
// "VS",
|
||||
// style: TextStyle(
|
||||
// color: Colors.red,
|
||||
// fontSize: 24,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// ),
|
||||
// ),
|
||||
_buildCharacterStatus(
|
||||
battleProvider.enemy,
|
||||
isPlayer: false,
|
||||
isTurn: !battleProvider.isPlayerTurn,
|
||||
key: _enemyKey,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
// Bottom (Control Area)
|
||||
|
||||
// Action Buttons
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
_buildActionButton(
|
||||
context,
|
||||
"ATTACK",
|
||||
ActionType.attack,
|
||||
battleProvider.isPlayerTurn &&
|
||||
!battleProvider.player.isDead &&
|
||||
!battleProvider.enemy.isDead &&
|
||||
!battleProvider.showRewardPopup,
|
||||
),
|
||||
_buildActionButton(
|
||||
context,
|
||||
"DEFEND",
|
||||
ActionType.defend,
|
||||
battleProvider.isPlayerTurn &&
|
||||
!battleProvider.player.isDead &&
|
||||
!battleProvider.enemy.isDead &&
|
||||
!battleProvider.showRewardPopup,
|
||||
if (battleProvider.logs.isNotEmpty)
|
||||
Container(
|
||||
height: 60,
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black54,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: ListView.builder(
|
||||
reverse: true,
|
||||
itemCount: battleProvider.logs.length,
|
||||
itemBuilder: (context, index) {
|
||||
final logIndex =
|
||||
battleProvider.logs.length - 1 - index;
|
||||
return Text(
|
||||
battleProvider.logs[logIndex],
|
||||
style: const TextStyle(
|
||||
color: Colors.white70,
|
||||
fontSize: 12,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Card(
|
||||
color: Colors.grey[900],
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
_buildActionButton(
|
||||
context,
|
||||
"ATTACK",
|
||||
ActionType.attack,
|
||||
battleProvider.isPlayerTurn &&
|
||||
!battleProvider.player.isDead &&
|
||||
!battleProvider.enemy.isDead &&
|
||||
!battleProvider.showRewardPopup,
|
||||
),
|
||||
_buildActionButton(
|
||||
context,
|
||||
"DEFEND",
|
||||
ActionType.defend,
|
||||
battleProvider.isPlayerTurn &&
|
||||
!battleProvider.player.isDead &&
|
||||
!battleProvider.enemy.isDead &&
|
||||
!battleProvider.showRewardPopup,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -425,13 +428,32 @@ class _BattleScreenState extends State<BattleScreen> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.name,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(4),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.blueGrey[700],
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(color: Colors.grey),
|
||||
),
|
||||
child: Icon(
|
||||
ItemUtils.getIcon(item.slot),
|
||||
color: ItemUtils.getColor(item.slot),
|
||||
size: 24,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Text(
|
||||
item.name,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
_buildItemStatText(item), // Display stats here
|
||||
_buildItemStatText(item),
|
||||
Text(
|
||||
item.description,
|
||||
style: const TextStyle(
|
||||
@@ -455,6 +477,49 @@ class _BattleScreenState extends State<BattleScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildShopUI(BuildContext context, BattleProvider battleProvider) {
|
||||
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"),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildRestUI(BuildContext context, BattleProvider battleProvider) {
|
||||
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);
|
||||
battleProvider.proceedToNextStage();
|
||||
},
|
||||
child: const Text("Rest & Leave (+20 HP)"),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildItemStatText(Item item) {
|
||||
List<String> stats = [];
|
||||
if (item.atkBonus > 0) stats.add("+${item.atkBonus} ATK");
|
||||
@@ -490,12 +555,14 @@ class _BattleScreenState extends State<BattleScreen> {
|
||||
|
||||
Widget _buildCharacterStatus(
|
||||
Character character, {
|
||||
bool isEnemy = false,
|
||||
bool isPlayer = false,
|
||||
bool isTurn = false,
|
||||
Key? key,
|
||||
}) {
|
||||
return Column(
|
||||
key: key,
|
||||
children: [
|
||||
Text("Armor: ${character.armor}"),
|
||||
Text(
|
||||
"${character.name}: HP ${character.hp}/${character.totalMaxHp}",
|
||||
style: TextStyle(
|
||||
@@ -509,11 +576,10 @@ class _BattleScreenState extends State<BattleScreen> {
|
||||
value: character.totalMaxHp > 0
|
||||
? character.hp / character.totalMaxHp
|
||||
: 0,
|
||||
color: isEnemy ? Colors.red : Colors.green,
|
||||
color: !isPlayer ? Colors.red : Colors.green,
|
||||
backgroundColor: Colors.grey,
|
||||
),
|
||||
),
|
||||
// Display Active Status Effects
|
||||
if (character.statusEffects.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4.0),
|
||||
@@ -541,7 +607,10 @@ class _BattleScreenState extends State<BattleScreen> {
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
if (isEnemy)
|
||||
Text("ATK: ${character.totalAtk}"),
|
||||
Text("DEF: ${character.totalDefense}"),
|
||||
|
||||
if (!isPlayer)
|
||||
Consumer<BattleProvider>(
|
||||
builder: (context, provider, child) {
|
||||
if (provider.currentEnemyIntent != null && !character.isDead) {
|
||||
@@ -593,11 +662,6 @@ class _BattleScreenState extends State<BattleScreen> {
|
||||
return const SizedBox.shrink();
|
||||
},
|
||||
),
|
||||
if (!isEnemy) ...[
|
||||
Text("Armor: ${character.armor}"),
|
||||
Text("ATK: ${character.totalAtk}"),
|
||||
Text("DEF: ${character.totalDefense}"),
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -655,24 +719,19 @@ class __FloatingDamageTextState extends State<_FloatingDamageText>
|
||||
|
||||
_offsetAnimation = Tween<Offset>(
|
||||
begin: const Offset(0.0, 0.0),
|
||||
end: const Offset(0.0, -1.5), // 위로 띄울 높이
|
||||
end: const Offset(0.0, -1.5),
|
||||
).animate(CurvedAnimation(parent: _controller, curve: Curves.easeOut));
|
||||
|
||||
_opacityAnimation = Tween<double>(begin: 1.0, end: 0.0).animate(
|
||||
CurvedAnimation(
|
||||
parent: _controller,
|
||||
curve: const Interval(
|
||||
0.5,
|
||||
1.0,
|
||||
curve: Curves.easeOut,
|
||||
), // 절반 이후부터 투명도 감소
|
||||
curve: const Interval(0.5, 1.0, curve: Curves.easeOut),
|
||||
),
|
||||
);
|
||||
|
||||
_controller.forward().then((_) {
|
||||
if (mounted) {
|
||||
widget.onRemove(); // 애니메이션 완료 후 콜백 호출하여 위젯 제거 요청
|
||||
// _controller.dispose(); // 제거: dispose() 메서드에서 처리됨
|
||||
widget.onRemove();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -719,7 +778,6 @@ class __FloatingDamageTextState extends State<_FloatingDamageText>
|
||||
|
||||
class _DamageTextData {
|
||||
final String id;
|
||||
|
||||
final Widget widget;
|
||||
|
||||
_DamageTextData({required this.id, required this.widget});
|
||||
@@ -733,13 +791,9 @@ class _FloatingEffect extends StatefulWidget {
|
||||
|
||||
const _FloatingEffect({
|
||||
Key? key,
|
||||
|
||||
required this.icon,
|
||||
|
||||
required this.color,
|
||||
|
||||
required this.size,
|
||||
|
||||
required this.onRemove,
|
||||
}) : super(key: key);
|
||||
|
||||
@@ -750,18 +804,14 @@ class _FloatingEffect extends StatefulWidget {
|
||||
class __FloatingEffectState extends State<_FloatingEffect>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late AnimationController _controller;
|
||||
|
||||
late Animation<double> _scaleAnimation;
|
||||
|
||||
late Animation<double> _opacityAnimation;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_controller = AnimationController(
|
||||
duration: const Duration(milliseconds: 800),
|
||||
|
||||
vsync: this,
|
||||
);
|
||||
|
||||
@@ -773,7 +823,6 @@ class __FloatingEffectState extends State<_FloatingEffect>
|
||||
_opacityAnimation = Tween<double>(begin: 1.0, end: 0.0).animate(
|
||||
CurvedAnimation(
|
||||
parent: _controller,
|
||||
|
||||
curve: const Interval(0.5, 1.0, curve: Curves.easeOut),
|
||||
),
|
||||
);
|
||||
@@ -788,7 +837,6 @@ class __FloatingEffectState extends State<_FloatingEffect>
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -796,14 +844,11 @@ class __FloatingEffectState extends State<_FloatingEffect>
|
||||
Widget build(BuildContext context) {
|
||||
return AnimatedBuilder(
|
||||
animation: _controller,
|
||||
|
||||
builder: (context, child) {
|
||||
return Transform.scale(
|
||||
scale: _scaleAnimation.value,
|
||||
|
||||
child: Opacity(
|
||||
opacity: _opacityAnimation.value,
|
||||
|
||||
child: Icon(widget.icon, color: widget.color, size: widget.size),
|
||||
),
|
||||
);
|
||||
@@ -814,7 +859,6 @@ class __FloatingEffectState extends State<_FloatingEffect>
|
||||
|
||||
class _FloatingEffectData {
|
||||
final String id;
|
||||
|
||||
final Widget widget;
|
||||
|
||||
_FloatingEffectData({required this.id, required this.widget});
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../providers/battle_provider.dart';
|
||||
import 'main_wrapper.dart';
|
||||
import '../widgets/responsive_container.dart';
|
||||
|
||||
class CharacterSelectionScreen extends StatelessWidget {
|
||||
const CharacterSelectionScreen({super.key});
|
||||
@@ -9,63 +10,85 @@ class CharacterSelectionScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text("Choose Your Hero"),
|
||||
centerTitle: true,
|
||||
),
|
||||
backgroundColor: Colors.black, // Outer background
|
||||
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,
|
||||
child: ResponsiveContainer(
|
||||
child: 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: 80",
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
Text(
|
||||
"ATK: 5",
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
Text(
|
||||
"DEF: 5",
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
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/enums.dart';
|
||||
import '../utils/item_utils.dart';
|
||||
|
||||
class InventoryScreen extends StatelessWidget {
|
||||
const InventoryScreen({super.key});
|
||||
@@ -101,10 +102,10 @@ class InventoryScreen extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Icon(
|
||||
_getIconForSlot(slot),
|
||||
ItemUtils.getIcon(slot),
|
||||
size: 24,
|
||||
color: item != null
|
||||
? Colors.white
|
||||
? ItemUtils.getColor(slot)
|
||||
: Colors.grey,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
@@ -171,7 +172,11 @@ class InventoryScreen extends StatelessWidget {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.backpack, size: 32),
|
||||
Icon(
|
||||
ItemUtils.getIcon(item.slot),
|
||||
size: 32,
|
||||
color: ItemUtils.getColor(item.slot),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
child: Text(
|
||||
@@ -208,19 +213,6 @@ class InventoryScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
IconData _getIconForSlot(EquipmentSlot slot) {
|
||||
switch (slot) {
|
||||
case EquipmentSlot.weapon:
|
||||
return Icons.g_mobiledata; // Using a generic 'game' icon for weapon
|
||||
case EquipmentSlot.armor:
|
||||
return Icons.checkroom;
|
||||
case EquipmentSlot.shield:
|
||||
return Icons.shield;
|
||||
case EquipmentSlot.accessory:
|
||||
return Icons.diamond;
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildStatItem(String label, String value, {Color? color}) {
|
||||
return Column(
|
||||
children: [
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'character_selection_screen.dart';
|
||||
import '../widgets/responsive_container.dart';
|
||||
|
||||
class MainMenuScreen extends StatelessWidget {
|
||||
const MainMenuScreen({super.key});
|
||||
@@ -16,50 +17,56 @@ class MainMenuScreen extends StatelessWidget {
|
||||
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,
|
||||
child: ResponsiveContainer(
|
||||
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: 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(),
|
||||
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,
|
||||
),
|
||||
);
|
||||
},
|
||||
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),
|
||||
backgroundColor: Colors.amber[700],
|
||||
foregroundColor: Colors.black,
|
||||
textStyle: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
child: const Text("START GAME"),
|
||||
),
|
||||
child: const Text("START GAME"),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'battle_screen.dart';
|
||||
import 'inventory_screen.dart';
|
||||
import '../widgets/responsive_container.dart';
|
||||
|
||||
class MainWrapper extends StatefulWidget {
|
||||
const MainWrapper({super.key});
|
||||
@@ -12,35 +13,36 @@ class MainWrapper extends StatefulWidget {
|
||||
class _MainWrapperState extends State<MainWrapper> {
|
||||
int _currentIndex = 0;
|
||||
|
||||
final List<Widget> _screens = [
|
||||
const BattleScreen(),
|
||||
const InventoryScreen(),
|
||||
];
|
||||
final List<Widget> _screens = [const BattleScreen(), const InventoryScreen()];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: IndexedStack(
|
||||
index: _currentIndex,
|
||||
children: _screens,
|
||||
),
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
currentIndex: _currentIndex,
|
||||
onTap: (index) {
|
||||
setState(() {
|
||||
_currentIndex = index;
|
||||
});
|
||||
},
|
||||
items: const [
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.flash_on),
|
||||
label: 'Battle',
|
||||
backgroundColor: Colors.black, // Outer background for web
|
||||
body: Center(
|
||||
child: ResponsiveContainer(
|
||||
child: Scaffold(
|
||||
body: IndexedStack(index: _currentIndex, children: _screens),
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
currentIndex: _currentIndex,
|
||||
onTap: (index) {
|
||||
setState(() {
|
||||
_currentIndex = index;
|
||||
});
|
||||
},
|
||||
items: const [
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.flash_on),
|
||||
label: 'Battle',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.backpack),
|
||||
label: 'Inventory',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.backpack),
|
||||
label: 'Inventory',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../game/enums.dart';
|
||||
|
||||
class ItemUtils {
|
||||
static IconData getIcon(EquipmentSlot slot) {
|
||||
switch (slot) {
|
||||
case EquipmentSlot.weapon:
|
||||
return Icons.change_history; // Triangle
|
||||
case EquipmentSlot.shield:
|
||||
return Icons.shield;
|
||||
case EquipmentSlot.armor:
|
||||
return Icons.checkroom;
|
||||
case EquipmentSlot.accessory:
|
||||
return Icons.diamond;
|
||||
}
|
||||
}
|
||||
|
||||
static Color getColor(EquipmentSlot slot) {
|
||||
switch (slot) {
|
||||
case EquipmentSlot.weapon:
|
||||
return Colors.red;
|
||||
case EquipmentSlot.shield:
|
||||
return Colors.blue;
|
||||
case EquipmentSlot.armor:
|
||||
return Colors.blue;
|
||||
case EquipmentSlot.accessory:
|
||||
return Colors.orange;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ResponsiveContainer extends StatelessWidget {
|
||||
final Widget child;
|
||||
final double maxWidth;
|
||||
final double maxHeight;
|
||||
|
||||
const ResponsiveContainer({
|
||||
Key? key,
|
||||
required this.child,
|
||||
this.maxWidth = 600.0,
|
||||
this.maxHeight = 1000.0,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(maxWidth: maxWidth, maxHeight: maxHeight),
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user