@@ -137,14 +137,27 @@ export class UIManager {
137137 const confirmBtn = document . getElementById ( 'confirmBtn' ) ! ;
138138 confirmBtn . style . display = isMyTurn && phase === 'astrogation' ? 'inline-block' : 'none' ;
139139
140- const launchMineBtn = document . getElementById ( 'launchMineBtn' ) ! ;
141- const launchTorpedoBtn = document . getElementById ( 'launchTorpedoBtn' ) ! ;
142- const launchNukeBtn = document . getElementById ( 'launchNukeBtn' ) ! ;
140+ const launchMineBtn = document . getElementById ( 'launchMineBtn' ) ! as HTMLButtonElement ;
141+ const launchTorpedoBtn = document . getElementById ( 'launchTorpedoBtn' ) ! as HTMLButtonElement ;
142+ const launchNukeBtn = document . getElementById ( 'launchNukeBtn' ) ! as HTMLButtonElement ;
143143 const skipOrdnanceBtn = document . getElementById ( 'skipOrdnanceBtn' ) ! ;
144- launchMineBtn . style . display = isMyTurn && phase === 'ordnance' ? 'inline-block' : 'none' ;
145- launchTorpedoBtn . style . display = isMyTurn && phase === 'ordnance' ? 'inline-block' : 'none' ;
146- launchNukeBtn . style . display = isMyTurn && phase === 'ordnance' ? 'inline-block' : 'none' ;
147- skipOrdnanceBtn . style . display = isMyTurn && phase === 'ordnance' ? 'inline-block' : 'none' ;
144+ const showOrd = isMyTurn && phase === 'ordnance' ;
145+ launchMineBtn . style . display = showOrd ? 'inline-block' : 'none' ;
146+ launchTorpedoBtn . style . display = showOrd ? 'inline-block' : 'none' ;
147+ launchNukeBtn . style . display = showOrd ? 'inline-block' : 'none' ;
148+ skipOrdnanceBtn . style . display = showOrd ? 'inline-block' : 'none' ;
149+ // Disable buttons based on cargo capacity
150+ if ( showOrd ) {
151+ const canMine = cargoFree >= 10 ; // mine mass
152+ const canTorpedo = cargoFree >= 20 ; // torpedo mass
153+ const canNuke = cargoFree >= 20 ; // nuke mass
154+ launchMineBtn . disabled = ! canMine ;
155+ launchTorpedoBtn . disabled = ! canTorpedo ;
156+ launchNukeBtn . disabled = ! canNuke ;
157+ launchMineBtn . style . opacity = canMine ? '1' : '0.4' ;
158+ launchTorpedoBtn . style . opacity = canTorpedo ? '1' : '0.4' ;
159+ launchNukeBtn . style . opacity = canNuke ? '1' : '0.4' ;
160+ }
148161
149162 const skipCombatBtn = document . getElementById ( 'skipCombatBtn' ) ! ;
150163 skipCombatBtn . style . display = isMyTurn && phase === 'combat' ? 'inline-block' : 'none' ;
0 commit comments