refactor(game): 앱 및 게임 세션 개선

- App 초기화 로직 정리
- GamePlayScreen 개선
- GameSessionController 확장
This commit is contained in:
JiWoong Sul
2026-01-08 16:05:14 +09:00
parent 606d052e2c
commit cfc1537af2
3 changed files with 26 additions and 16 deletions

View File

@@ -528,8 +528,8 @@ class _GamePlayScreenState extends State<GamePlayScreen>
/// 모바일 재진입 시 전체 화면 재로드
Future<void> _reloadGameScreen() async {
// 세이브 파일에서 다시 로드
await widget.controller.loadAndStart(cheatsEnabled: widget.controller.cheatsEnabled);
// 세이브 파일에서 다시 로드 (치트 모드는 저장된 상태에서 복원)
await widget.controller.loadAndStart();
if (!mounted) return;
@@ -550,7 +550,10 @@ class _GamePlayScreenState extends State<GamePlayScreen>
final currentState = widget.controller.state;
if (currentState == null || !widget.controller.isRunning) return;
await widget.controller.saveManager.saveState(currentState);
await widget.controller.saveManager.saveState(
currentState,
cheatsEnabled: widget.controller.cheatsEnabled,
);
}
/// 뒤로가기 시 저장 확인 다이얼로그

View File

@@ -225,13 +225,13 @@ class GameSessionController extends ChangeNotifier {
Future<void> loadAndStart({
String? fileName,
bool cheatsEnabled = false,
}) async {
_status = GameSessionStatus.loading;
_error = null;
notifyListeners();
final (outcome, loaded) = await saveManager.loadState(fileName: fileName);
final (outcome, loaded, savedCheatsEnabled) =
await saveManager.loadState(fileName: fileName);
if (!outcome.success || loaded == null) {
_status = GameSessionStatus.error;
_error = outcome.error ?? 'Unknown error';
@@ -239,7 +239,8 @@ class GameSessionController extends ChangeNotifier {
return;
}
await startNew(loaded, cheatsEnabled: cheatsEnabled, isNewGame: false);
// 저장된 치트 모드 상태 복원
await startNew(loaded, cheatsEnabled: savedCheatsEnabled, isNewGame: false);
}
Future<void> pause({bool saveOnStop = false}) async {
@@ -382,8 +383,11 @@ class GameSessionController extends ChangeNotifier {
_state = resurrectedState;
_status = GameSessionStatus.idle; // 사망 상태 해제
// 저장
await saveManager.saveState(resurrectedState);
// 저장 (치트 모드 상태 유지)
await saveManager.saveState(
resurrectedState,
cheatsEnabled: _cheatsEnabled,
);
notifyListeners();
}