feat(death): Phase 4 사망/부활 시스템 구현
- DeathInfo, DeathCause 클래스 정의 (game_state.dart) - 사망 원인, 상실 장비 수, 사망 시점 정보 기록 - ShopService 구현 (shop_service.dart) - 장비 가격 계산 (레벨 * 50 * 희귀도 배율) - 슬롯별 장비 생성 (프로그래밍 테마) - 자동 구매 (빈 슬롯에 Common 장비) - ResurrectionService 구현 (resurrection_service.dart) - 사망 처리: 모든 장비 상실, 기본 무기만 유지 - 부활 처리: HP/MP 회복, 자동 장비 구매 - progress_service.dart 사망 판정 로직 추가 - 전투 중 HP <= 0 시 사망 처리 - ProgressTickResult에 playerDied 플래그 추가 - progress_loop.dart 사망 시 루프 정지 - onPlayerDied 콜백 추가 - 사망 상태에서 틱 진행 방지 - DeathOverlay 위젯 구현 (death_overlay.dart) - ASCII 스컬 아트, 사망 원인, 상실 정보 표시 - 부활 버튼 - GameSessionController 사망/부활 상태 관리 - GameSessionStatus.dead 상태 추가 - resurrect() 메서드로 부활 처리
This commit is contained in:
@@ -10,6 +10,7 @@ class AutoSaveConfig {
|
||||
this.onQuestComplete = true,
|
||||
this.onActComplete = true,
|
||||
this.onStop = true,
|
||||
this.onDeath = true,
|
||||
});
|
||||
|
||||
final bool onLevelUp;
|
||||
@@ -17,10 +18,14 @@ class AutoSaveConfig {
|
||||
final bool onActComplete;
|
||||
final bool onStop;
|
||||
|
||||
/// 사망 시 자동 저장 (Phase 4)
|
||||
final bool onDeath;
|
||||
|
||||
bool shouldSave(ProgressTickResult result) {
|
||||
return (onLevelUp && result.leveledUp) ||
|
||||
(onQuestComplete && result.completedQuest) ||
|
||||
(onActComplete && result.completedAct);
|
||||
(onActComplete && result.completedAct) ||
|
||||
(onDeath && result.playerDied);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +39,7 @@ class ProgressLoop {
|
||||
AutoSaveConfig autoSaveConfig = const AutoSaveConfig(),
|
||||
DateTime Function()? now,
|
||||
this.cheatsEnabled = false,
|
||||
this.onPlayerDied,
|
||||
}) : _state = initialState,
|
||||
_tickInterval = tickInterval,
|
||||
_autoSaveConfig = autoSaveConfig,
|
||||
@@ -43,6 +49,9 @@ class ProgressLoop {
|
||||
final ProgressService progressService;
|
||||
final SaveManager? saveManager;
|
||||
final Duration _tickInterval;
|
||||
|
||||
/// 플레이어 사망 시 콜백 (Phase 4)
|
||||
final void Function()? onPlayerDied;
|
||||
final AutoSaveConfig _autoSaveConfig;
|
||||
final DateTime Function() _now;
|
||||
final StreamController<GameState> _stateController;
|
||||
@@ -88,6 +97,11 @@ class ProgressLoop {
|
||||
|
||||
/// Run one iteration of the loop (used by Timer or manual stepping).
|
||||
GameState tickOnce({int? deltaMillis}) {
|
||||
// 사망 상태면 틱 진행 안 함 (Phase 4)
|
||||
if (_state.isDead) {
|
||||
return _state;
|
||||
}
|
||||
|
||||
final baseDelta = deltaMillis ?? _computeDelta();
|
||||
final delta = baseDelta * _speedMultiplier;
|
||||
final result = progressService.tick(_state, delta);
|
||||
@@ -97,6 +111,14 @@ class ProgressLoop {
|
||||
if (saveManager != null && _autoSaveConfig.shouldSave(result)) {
|
||||
saveManager!.saveState(_state);
|
||||
}
|
||||
|
||||
// 사망 시 루프 정지 및 콜백 호출 (Phase 4)
|
||||
if (result.playerDied) {
|
||||
_timer?.cancel();
|
||||
_timer = null;
|
||||
onPlayerDied?.call();
|
||||
}
|
||||
|
||||
return _state;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user