From 136766e6768285b883639d56937a1f5f56ec88ac Mon Sep 17 00:00:00 2001 From: Wickedness Date: Thu, 2 Jul 2026 23:33:38 +0900 Subject: [PATCH] Clean up final unit command prompt --- src/game/scenes/BattleScene.ts | 54 ++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/src/game/scenes/BattleScene.ts b/src/game/scenes/BattleScene.ts index d71ecb2..0e7f806 100644 --- a/src/game/scenes/BattleScene.ts +++ b/src/game/scenes/BattleScene.ts @@ -3812,24 +3812,28 @@ export class BattleScene extends Phaser.Scene { if (!stayingInPlace) { this.moveUnitView(unit, x, y, view, 260, fromX, fromY); } - this.showCommandMenu(unit, pointer?.x ?? targetX, pointer?.y ?? targetY); + const commandX = pointer?.x ?? targetX; + const commandY = pointer?.y ?? targetY; const isFinalAlly = this.remainingAllyCount() === 1; - const finalAllyHint = isFinalAlly ? '\n마지막 미행동 장수입니다. 바로 턴 종료 확인을 선택할 수 있습니다.' : ''; - this.renderUnitDetail(unit, `공격, 책략, 도구, 대기 중 하나를 선택하세요.\n우클릭하면 이동을 취소합니다.${finalAllyHint}`); if (isFinalAlly) { - this.showPostMoveTurnEndPrompt(unit); + this.hideCommandMenu(); + this.renderUnitDetail(unit, '마지막 미행동 장수입니다.\n바로 턴을 종료하거나 명령을 선택할 수 있습니다.'); + this.showPostMoveTurnEndPrompt(unit, commandX, commandY); return; } + this.showCommandMenu(unit, commandX, commandY); + this.renderUnitDetail(unit, '공격, 책략, 도구, 대기 중 하나를 선택하세요.\n우클릭하면 이동을 취소합니다.'); this.hideTurnEndPrompt(); } - private showPostMoveTurnEndPrompt(unit: UnitData) { + private showPostMoveTurnEndPrompt(unit: UnitData, commandX = this.tileCenterX(unit.x), commandY = this.tileCenterY(unit.y)) { + this.hideCommandMenu(); this.showTurnEndPrompt(undefined, { mode: 'post-move', title: '마지막 장수 이동 완료', - body: '대기로 행동을 마치고 턴을 종료할까요?', + body: '대기로 턴을 끝낼까요?', primaryLabel: '대기 후 턴 종료', secondaryLabel: '명령 선택', primaryAction: () => { @@ -3843,7 +3847,18 @@ export class BattleScene extends Phaser.Scene { this.endAllyTurn(); } }, - secondaryAction: () => this.hideTurnEndPrompt() + secondaryAction: () => { + if (this.phase !== 'command' || this.selectedUnit?.id !== unit.id || this.actedUnitIds.has(unit.id)) { + this.hideTurnEndPrompt(); + return; + } + + this.suppressNextLeftClick = true; + this.hideTurnEndPrompt(); + this.showCommandMenu(unit, commandX, commandY); + this.renderUnitDetail(unit, '공격, 책략, 도구, 대기 중 하나를 선택하세요.\n우클릭하면 이동을 취소합니다.'); + soundDirector.playSelect(); + } }); } @@ -4244,14 +4259,29 @@ export class BattleScene extends Phaser.Scene { } private commandMenuPosition(pointerX: number, pointerY: number, width: number, height: number) { - const margin = 14; + const margin = 12; const offset = 18; - const preferredLeft = pointerX + offset + width > this.scale.width - margin ? pointerX - offset - width : pointerX + offset; - const preferredTop = pointerY + height > this.scale.height - margin ? this.scale.height - margin - height : pointerY; + const minLeft = this.layout.mapX + margin; + const maxLeft = this.layout.mapX + this.layout.mapWidth - margin - width; + const minTop = this.layout.mapY + margin; + const maxTop = this.layout.mapY + this.layout.mapHeight - margin - height; + + if (maxLeft < minLeft || maxTop < minTop) { + const preferredLeft = pointerX + offset + width > this.scale.width - margin ? pointerX - offset - width : pointerX + offset; + const preferredTop = pointerY + height > this.scale.height - margin ? this.scale.height - margin - height : pointerY; + + return { + left: Phaser.Math.Clamp(preferredLeft, margin, this.scale.width - margin - width), + top: Phaser.Math.Clamp(preferredTop, margin, this.scale.height - margin - height) + }; + } + + const preferredLeft = pointerX + offset + width <= maxLeft ? pointerX + offset : pointerX - offset - width; + const preferredTop = pointerY - height / 2; return { - left: Phaser.Math.Clamp(preferredLeft, margin, this.scale.width - margin - width), - top: Phaser.Math.Clamp(preferredTop, margin, this.scale.height - margin - height) + left: Phaser.Math.Clamp(preferredLeft, minLeft, maxLeft), + top: Phaser.Math.Clamp(preferredTop, minTop, maxTop) }; }