@@ -15,6 +15,9 @@ import {
1515import { buildHUDView } from './ui-hud' ;
1616import { deriveHudLayoutOffsets } from './ui-layout' ;
1717import {
18+ buildGameOverView ,
19+ buildReconnectView ,
20+ buildRematchPendingView ,
1821 buildScreenVisibility ,
1922 buildWaitingScreenCopy ,
2023 toggleLogVisible ,
@@ -508,32 +511,32 @@ export class UIManager {
508511 }
509512
510513 showGameOver ( won : boolean , reason : string , stats ?: { turns : number ; myShipsAlive : number ; myShipsTotal : number ; enemyShipsAlive : number ; enemyShipsTotal : number } ) {
514+ const view = buildGameOverView ( won , reason , stats ) ;
511515 this . gameOverEl . style . display = 'flex' ;
512- document . getElementById ( 'gameOverText' ) ! . textContent = won ? 'VICTORY' : 'DEFEAT' ;
513- let reasonText = reason ;
514- if ( stats ) {
515- reasonText += `\n\nTurns: ${ stats . turns } ` ;
516- reasonText += ` | Your ships: ${ stats . myShipsAlive } /${ stats . myShipsTotal } ` ;
517- reasonText += ` | Enemy: ${ stats . enemyShipsAlive } /${ stats . enemyShipsTotal } ` ;
518- }
516+ document . getElementById ( 'gameOverText' ) ! . textContent = view . titleText ;
519517 const reasonEl = document . getElementById ( 'gameOverReason' ) ! ;
520- reasonEl . textContent = reasonText ;
518+ reasonEl . textContent = view . reasonText ;
521519 reasonEl . style . whiteSpace = 'pre-line' ;
522- document . getElementById ( 'rematchBtn' ) ! . textContent = 'Rematch' ;
523- document . getElementById ( 'rematchBtn' ) ! . removeAttribute ( 'disabled' ) ;
520+ const rematchBtn = document . getElementById ( 'rematchBtn' ) ! ;
521+ rematchBtn . textContent = view . rematchText ;
522+ rematchBtn . removeAttribute ( 'disabled' ) ;
524523 }
525524
526525 showRematchPending ( ) {
526+ const view = buildRematchPendingView ( ) ;
527527 const btn = document . getElementById ( 'rematchBtn' ) ! ;
528- btn . textContent = 'Waiting...' ;
529- btn . setAttribute ( 'disabled' , 'true' ) ;
528+ btn . textContent = view . rematchText ;
529+ if ( view . rematchDisabled ) {
530+ btn . setAttribute ( 'disabled' , 'true' ) ;
531+ }
530532 }
531533
532534 showReconnecting ( attempt : number , maxAttempts : number , onCancel : ( ) => void ) {
535+ const view = buildReconnectView ( attempt , maxAttempts ) ;
533536 const overlay = document . getElementById ( 'reconnectOverlay' ) ! ;
534537 overlay . style . display = 'flex' ;
535- document . getElementById ( 'reconnectText' ) ! . textContent = 'Connection lost' ;
536- document . getElementById ( 'reconnectAttempt' ) ! . textContent = `Attempt ${ attempt } of ${ maxAttempts } ` ;
538+ document . getElementById ( 'reconnectText' ) ! . textContent = view . reconnectText ;
539+ document . getElementById ( 'reconnectAttempt' ) ! . textContent = view . attemptText ;
537540 const cancelBtn = document . getElementById ( 'reconnectCancelBtn' ) ! ;
538541 cancelBtn . onclick = ( ) => {
539542 this . hideReconnecting ( ) ;
0 commit comments