diff --git a/src/game/scenes/BattleScene.ts b/src/game/scenes/BattleScene.ts index a0b6aee..4310a9b 100644 --- a/src/game/scenes/BattleScene.ts +++ b/src/game/scenes/BattleScene.ts @@ -1124,7 +1124,7 @@ type MapMenuAction = 'endTurn' | 'threat' | 'save' | 'load' | 'roster' | 'bond' type EnemyAiBehavior = 'aggressive' | 'guard' | 'hold'; type BattleOutcome = 'victory' | 'defeat'; type SaveSlotMode = 'save' | 'load'; -type TurnPromptMode = 'turn-end' | 'post-move' | 'load-confirm'; +type TurnPromptMode = 'turn-end' | 'post-move' | 'load-confirm' | 'save-overwrite-confirm'; const battleSpeedStorageKey = 'heros-web:battle-speed'; const battleSpeedLabels: Record = { @@ -11204,8 +11204,7 @@ export class BattleScene extends Phaser.Scene { this.suppressNextLeftClick = true; soundDirector.playSelect(); if (mode === 'save') { - this.saveBattleState(slot); - this.hideSaveSlotPanel(); + this.showSaveBattleConfirm(slot); } else { this.showLoadBattleConfirm(slot); } @@ -11242,6 +11241,37 @@ export class BattleScene extends Phaser.Scene { this.saveSlotPanelObjects = []; } + private showSaveBattleConfirm(slot: number) { + const battleSave = this.readBattleSaveState(slot); + const campaignSlot = listCampaignSaveSlots().find((candidate) => candidate.slot === slot); + if (!battleSave && !campaignSlot?.exists) { + this.saveBattleState(slot); + this.hideSaveSlotPanel(); + return; + } + + const existingSummary = battleSave + ? `기존 전투: ${this.formatSavedAt(battleSave.savedAt)}` + : `기존 캠페인: ${campaignSlot?.progressTitle ?? campaignSlot?.battleTitle ?? '저장 데이터'}`; + + this.hideSaveSlotPanel(); + this.showTurnEndPrompt(undefined, { + mode: 'save-overwrite-confirm', + title: '전투 저장 확인', + body: `슬롯 ${slot}에 기존 저장이 있습니다.\n${existingSummary}\n덮어쓸까요?`, + primaryLabel: '덮어쓰기', + secondaryLabel: '취소', + primaryAction: () => { + this.hideTurnEndPrompt(); + this.saveBattleState(slot); + }, + secondaryAction: () => { + this.hideTurnEndPrompt(); + this.showSaveSlotPanel('save'); + } + }); + } + private showLoadBattleConfirm(slot: number) { const state = this.readBattleSaveState(slot); if (!state) {