Refactor game mode scoring and win conditions
* Add overridable hooks for sunk/reaped ball handling and turn behavior. * Implement default scoring and game-over messaging across game modes. * Add pretty game mode names for win-condition messages. * Update Free Ball, Last Ball, and Snooker modes to return win-condition messages. * Move the reset button lookup to the scene root for multiplayer setup. * Move camera controller scene to shared base UI. Move parts of it to new game_data UI node. * Add commented test state generation for end-state testing.
This commit is contained in:
33
scenes/ui_controls/game/data.gd
Normal file
33
scenes/ui_controls/game/data.gd
Normal file
@@ -0,0 +1,33 @@
|
||||
extends Control
|
||||
|
||||
|
||||
@onready var player_lbl: Label = $vbox/hbox/hbox/player_lbl
|
||||
@onready var active_lbl: Label = $vbox/hbox/hbox/active_lbl
|
||||
@onready var reset_bttn: Button = $vbox/hbox/hbox2/reset_bttn
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
setup_signals()
|
||||
setup_multiplayer()
|
||||
|
||||
MessageBus.emit_local("update_active_lbl", null)
|
||||
|
||||
|
||||
func setup_signals() -> void:
|
||||
MessageBus.subscribe("update_active_lbl", _on_update_active_lbl)
|
||||
|
||||
func setup_multiplayer() -> void:
|
||||
player_lbl.text = Globals.game_data.player_id
|
||||
|
||||
if not Globals.multiplayer_data.is_multiplayer_active: return
|
||||
|
||||
reset_bttn.pressed.disconnect(_on_reset_bttn_pressed)
|
||||
reset_bttn.visible = false
|
||||
|
||||
|
||||
func _on_update_active_lbl() -> void:
|
||||
active_lbl.visible = \
|
||||
Globals.multiplayer_data.current_turn_player_id == multiplayer.get_unique_id()
|
||||
|
||||
func _on_reset_bttn_pressed() -> void:
|
||||
Globals.game_state.reload_scene.emit()
|
||||
Reference in New Issue
Block a user