refactor(model): 모델 및 스토리지 정리

- GameState, GameStatistics, HallOfFame 개선
- MonsterGrade, HallOfFameStorage 정리
This commit is contained in:
JiWoong Sul
2026-01-12 16:17:06 +09:00
parent 95528786eb
commit 6f70c18d08
5 changed files with 61 additions and 42 deletions

View File

@@ -763,6 +763,7 @@ class ProgressState {
this.monstersKilled = 0,
this.deathCount = 0,
this.finalBossState = FinalBossState.notSpawned,
this.pendingActCompletion = false,
});
final ProgressBarState task;
@@ -795,6 +796,9 @@ class ProgressState {
/// 최종 보스 상태 (Act V)
final FinalBossState finalBossState;
/// Act Boss 처치 대기 중 여부 (처치 후 시네마틱 재생 트리거)
final bool pendingActCompletion;
factory ProgressState.empty() => ProgressState(
task: ProgressBarState.empty(),
quest: ProgressBarState.empty(),
@@ -826,6 +830,7 @@ class ProgressState {
int? monstersKilled,
int? deathCount,
FinalBossState? finalBossState,
bool? pendingActCompletion,
}) {
return ProgressState(
task: task ?? this.task,
@@ -843,6 +848,7 @@ class ProgressState {
monstersKilled: monstersKilled ?? this.monstersKilled,
deathCount: deathCount ?? this.deathCount,
finalBossState: finalBossState ?? this.finalBossState,
pendingActCompletion: pendingActCompletion ?? this.pendingActCompletion,
);
}
}

View File

@@ -2,10 +2,7 @@
///
/// 세션 및 누적 통계를 추적하는 모델
class GameStatistics {
const GameStatistics({
required this.session,
required this.cumulative,
});
const GameStatistics({required this.session, required this.cumulative});
/// 현재 세션 통계
final SessionStatistics session;
@@ -47,10 +44,7 @@ class GameStatistics {
/// JSON 직렬화
Map<String, dynamic> toJson() {
return {
'session': session.toJson(),
'cumulative': cumulative.toJson(),
};
return {'session': session.toJson(), 'cumulative': cumulative.toJson()};
}
/// JSON 역직렬화
@@ -212,8 +206,7 @@ class SessionStatistics {
/// 스킬 사용 기록
SessionStatistics recordSkillUse({required bool isCritical}) {
final newCriticalStreak =
isCritical ? currentCriticalStreak + 1 : 0;
final newCriticalStreak = isCritical ? currentCriticalStreak + 1 : 0;
final newMaxStreak = newCriticalStreak > maxCriticalStreak
? newCriticalStreak
: maxCriticalStreak;
@@ -227,10 +220,7 @@ class SessionStatistics {
}
/// 데미지 기록
SessionStatistics recordDamage({
int dealt = 0,
int taken = 0,
}) {
SessionStatistics recordDamage({int dealt = 0, int taken = 0}) {
return copyWith(
totalDamageDealt: totalDamageDealt + dealt,
totalDamageTaken: totalDamageTaken + taken,

View File

@@ -19,6 +19,7 @@ class HallOfFameEntry {
required this.monstersKilled,
required this.questsCompleted,
required this.clearedAt,
this.raceId = '',
this.finalStats,
this.finalEquipment,
this.finalSkills,
@@ -30,9 +31,12 @@ class HallOfFameEntry {
/// 캐릭터 이름
final String characterName;
/// 종족
/// 종족 (표시용 이름)
final String race;
/// 종족 ID (ASCII 캐릭터 프레임용)
final String raceId;
/// 클래스
final String klass;
@@ -87,6 +91,7 @@ class HallOfFameEntry {
String? id,
String? characterName,
String? race,
String? raceId,
String? klass,
int? level,
int? totalPlayTimeMs,
@@ -102,6 +107,7 @@ class HallOfFameEntry {
id: id ?? this.id,
characterName: characterName ?? this.characterName,
race: race ?? this.race,
raceId: raceId ?? this.raceId,
klass: klass ?? this.klass,
level: level ?? this.level,
totalPlayTimeMs: totalPlayTimeMs ?? this.totalPlayTimeMs,
@@ -126,6 +132,7 @@ class HallOfFameEntry {
id: DateTime.now().millisecondsSinceEpoch.toString(),
characterName: state.traits.name,
race: state.traits.race,
raceId: state.traits.raceId,
klass: state.traits.klass,
level: state.traits.level,
totalPlayTimeMs: state.skillSystem.elapsedMs,
@@ -147,6 +154,7 @@ class HallOfFameEntry {
'id': id,
'characterName': characterName,
'race': race,
'raceId': raceId,
'klass': klass,
'level': level,
'totalPlayTimeMs': totalPlayTimeMs,
@@ -166,6 +174,7 @@ class HallOfFameEntry {
id: json['id'] as String,
characterName: json['characterName'] as String,
race: json['race'] as String,
raceId: json['raceId'] as String? ?? '',
klass: json['klass'] as String,
level: json['level'] as int,
totalPlayTimeMs: json['totalPlayTimeMs'] as int,
@@ -232,6 +241,12 @@ class HallOfFame {
return HallOfFame(entries: newEntries);
}
/// 엔트리 삭제 (디버그용)
HallOfFame removeEntry(String id) {
final newEntries = entries.where((e) => e.id != id).toList();
return HallOfFame(entries: newEntries);
}
/// JSON으로 직렬화
Map<String, dynamic> toJson() {
return {'entries': entries.map((e) => e.toJson()).toList()};
@@ -258,7 +273,8 @@ extension HallOfFameArenaX on HallOfFame {
final levelScore = entry.level * 100;
// 2. 장비 점수 (전체 슬롯 합계)
final equipScore = entry.finalEquipment?.fold<int>(
final equipScore =
entry.finalEquipment?.fold<int>(
0,
(sum, item) => sum + ItemService.calculateEquipmentScore(item),
) ??

View File

@@ -64,6 +64,13 @@ class HallOfFameStorage {
return save(updated);
}
/// 엔트리 삭제 및 저장 (디버그용)
Future<bool> deleteEntry(String id) async {
final hallOfFame = await load();
final updated = hallOfFame.removeEntry(id);
return save(updated);
}
/// 명예의 전당 초기화 (테스트용)
Future<bool> clear() async {
try {