161 lines
5.4 KiB
Dart
161 lines
5.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import '../../game/model/entity.dart';
|
|
import '../../game/enums.dart';
|
|
import '../../providers/battle_provider.dart';
|
|
|
|
class CharacterStatusCard extends StatelessWidget {
|
|
final Character character;
|
|
final bool isPlayer;
|
|
final bool isTurn;
|
|
|
|
const CharacterStatusCard({
|
|
super.key,
|
|
required this.character,
|
|
this.isPlayer = false,
|
|
this.isTurn = false,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
children: [
|
|
FittedBox(
|
|
fit: BoxFit.scaleDown,
|
|
child: Text(
|
|
"Armor: ${character.armor}",
|
|
style: const TextStyle(color: Colors.white),
|
|
),
|
|
),
|
|
FittedBox(
|
|
fit: BoxFit.scaleDown,
|
|
child: Text(
|
|
"${character.name}: HP ${character.hp}/${character.totalMaxHp}",
|
|
style: TextStyle(
|
|
color: character.isDead ? Colors.red : Colors.white,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
width: 100,
|
|
child: LinearProgressIndicator(
|
|
value: character.totalMaxHp > 0
|
|
? character.hp / character.totalMaxHp
|
|
: 0,
|
|
color: !isPlayer ? Colors.red : Colors.green,
|
|
backgroundColor: Colors.grey,
|
|
),
|
|
),
|
|
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(),
|
|
),
|
|
),
|
|
Text("ATK: ${character.totalAtk}"),
|
|
Text("DEF: ${character.totalDefense}"),
|
|
// 캐릭터 아이콘/이미지 영역 추가
|
|
Container(
|
|
width: 100, // 임시 크기
|
|
height: 100, // 임시 크기
|
|
decoration: BoxDecoration(
|
|
color: isPlayer
|
|
? Colors.lightBlue
|
|
: Colors.deepOrange, // 플레이어/적 구분 색상
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: Center(
|
|
child: isPlayer
|
|
? const Icon(
|
|
Icons.person,
|
|
size: 60,
|
|
color: Colors.white,
|
|
) // 플레이어 아이콘
|
|
: const Icon(
|
|
Icons.psychology,
|
|
size: 60,
|
|
color: Colors.white,
|
|
), // 적 아이콘 (몬스터 대신)
|
|
),
|
|
),
|
|
const SizedBox(height: 8), // 아이콘과 정보 사이 간격
|
|
|
|
if (!isPlayer)
|
|
Consumer<BattleProvider>(
|
|
builder: (context, provider, child) {
|
|
if (provider.currentEnemyIntent != null && !character.isDead) {
|
|
final intent = provider.currentEnemyIntent!;
|
|
return Padding(
|
|
padding: const EdgeInsets.only(top: 8.0),
|
|
child: Container(
|
|
padding: const EdgeInsets.all(8.0),
|
|
decoration: BoxDecoration(
|
|
color: Colors.black54,
|
|
borderRadius: BorderRadius.circular(8),
|
|
border: Border.all(color: Colors.redAccent),
|
|
),
|
|
child: Column(
|
|
children: [
|
|
Text(
|
|
"INTENT",
|
|
style: TextStyle(
|
|
color: Colors.redAccent,
|
|
fontSize: 10,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(
|
|
intent.type == EnemyActionType.attack
|
|
? Icons.flash_on
|
|
: Icons.shield,
|
|
color: Colors.yellow,
|
|
size: 16,
|
|
),
|
|
const SizedBox(width: 4),
|
|
Text(
|
|
intent.description,
|
|
style: const TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 12,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
return const SizedBox.shrink();
|
|
},
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|