@@ -92,6 +92,7 @@ const CARD_POOL: Array[String] = [
9292@onready var gameover_label : Label = $ HUD/GameOverPanel/GameOverLabel
9393@onready var restart_button : Button = $ HUD/GameOverPanel/RestartButton
9494@onready var menu_button : Button = $ HUD/GameOverPanel/MenuButton
95+ @onready var forfeit_dialog : ConfirmationDialog = $ HUD/ForfeitDialog
9596@onready var left_wall : CollisionShape2D = $ Walls/LeftWall
9697@onready var right_wall : CollisionShape2D = $ Walls/RightWall
9798@onready var top_wall : CollisionShape2D = $ Walls/TopWall
@@ -148,6 +149,13 @@ var encounter_speed_boost: bool = false
148149var deck_return_panel : String = ""
149150var deck_return_info : String = ""
150151
152+ func _update_reserve_indicator () -> void :
153+ if paddle and paddle .has_method ("set_reserve_count" ):
154+ if state == GameState .PLANNING :
155+ paddle .set_reserve_count (volley_ball_bonus )
156+ else :
157+ paddle .set_reserve_count (volley_ball_reserve )
158+
151159func _ready () -> void :
152160 randomize ()
153161 if get_viewport ():
@@ -160,6 +168,8 @@ func _ready() -> void:
160168 restart_button .pressed .connect (_start_run )
161169 if menu_button :
162170 menu_button .pressed .connect (_go_to_menu )
171+ if forfeit_dialog :
172+ forfeit_dialog .confirmed .connect (_confirm_forfeit_volley )
163173 if deck_button :
164174 deck_button .pressed .connect (_show_deck_panel )
165175 if deck_close_button :
@@ -247,11 +257,21 @@ func _set_hud_tooltips() -> void:
247257func _unhandled_input (event : InputEvent ) -> void :
248258 if event .is_action_pressed ("ui_cancel" ):
249259 App .show_menu ()
260+ if event is InputEventKey and event .is_pressed () and not event .is_echo ():
261+ var key_event : InputEventKey = event
262+ if key_event .keycode in [KEY_ENTER , KEY_KP_ENTER ]:
263+ if state == GameState .VOLLEY and active_balls .is_empty () and volley_ball_reserve > 0 :
264+ _prompt_forfeit_volley ()
265+ return
250266 if state == GameState .PLANNING and event .is_action_pressed ("ui_accept" ):
251267 _launch_volley ()
252268 if state == GameState .VOLLEY and event .is_action_pressed ("ui_select" ) and active_balls .is_empty () and volley_ball_reserve > 0 :
253- _forfeit_volley ()
269+ _prompt_forfeit_volley ()
254270 if state == GameState .VOLLEY and event .is_action_pressed ("ui_accept" ) and reserve_launch_cooldown <= 0.0 :
271+ if event is InputEventKey :
272+ var launch_key : InputEventKey = event
273+ if launch_key .keycode in [KEY_ENTER , KEY_KP_ENTER ]:
274+ return
255275 _launch_reserve_ball ()
256276 if state == GameState .PLANNING and event .is_action_pressed ("ui_select" ):
257277 _end_turn ()
@@ -418,6 +438,7 @@ func _start_turn() -> void:
418438 volley_damage_bonus = 0
419439 volley_ball_bonus = 0
420440 volley_ball_reserve = 0
441+ _update_reserve_indicator ()
421442 volley_piercing = false
422443 volley_ball_speed_multiplier = 1.0
423444 _apply_paddle_buffs ()
@@ -444,6 +465,7 @@ func _launch_volley() -> void:
444465 state = GameState .VOLLEY
445466 var total_balls : int = 1 + volley_ball_bonus
446467 volley_ball_reserve = max (0 , total_balls - 1 )
468+ _update_reserve_indicator ()
447469 reserve_launch_cooldown = 0.1
448470 _spawn_volley_ball ()
449471 info_label .text = "Volley in motion."
@@ -454,6 +476,7 @@ func _launch_reserve_ball() -> void:
454476 if volley_ball_reserve <= 0 :
455477 return
456478 volley_ball_reserve -= 1
479+ _update_reserve_indicator ()
457480 _spawn_volley_ball ()
458481 info_label .text = "Extra ball launched."
459482
@@ -499,8 +522,18 @@ func _forfeit_volley() -> void:
499522 if volley_ball_reserve <= 0 :
500523 return
501524 volley_ball_reserve = 0
525+ _update_reserve_indicator ()
502526 _apply_volley_threat ()
503527
528+ func _prompt_forfeit_volley () -> void :
529+ if forfeit_dialog == null :
530+ _forfeit_volley ()
531+ return
532+ forfeit_dialog .popup_centered ()
533+
534+ func _confirm_forfeit_volley () -> void :
535+ _forfeit_volley ()
536+
504537func _apply_volley_threat () -> void :
505538 var threat : int = _calculate_threat ()
506539 hp -= threat
@@ -713,6 +746,7 @@ func _clear_active_balls() -> void:
713746 ball .queue_free ()
714747 active_balls .clear ()
715748 volley_ball_reserve = 0
749+ _update_reserve_indicator ()
716750
717751func _build_bricks (rows : int , cols : int , base_hp : int , pattern : String ) -> void :
718752 for child in bricks_root .get_children ():
@@ -886,6 +920,7 @@ func _play_card(card_id: String) -> void:
886920 discard_pile .append (card_id )
887921 hand .erase (card_id )
888922 _refresh_hand ()
923+ _update_reserve_indicator ()
889924 _update_labels ()
890925
891926func _apply_card_effect (card_id : String ) -> void :
0 commit comments