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()
|
||||
1
scenes/ui_controls/game/data.gd.uid
Normal file
1
scenes/ui_controls/game/data.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://br6jmlm4poh62
|
||||
54
scenes/ui_controls/game/data.tscn
Normal file
54
scenes/ui_controls/game/data.tscn
Normal file
@@ -0,0 +1,54 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://l3bve6miq8od"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://br6jmlm4poh62" path="res://scenes/ui_controls/game/data.gd" id="1_s7215"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_o1hjn"]
|
||||
font_color = Color(0, 1, 0.14117648, 1)
|
||||
|
||||
[node name="data" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 10
|
||||
anchor_right = 1.0
|
||||
grow_horizontal = 2
|
||||
script = ExtResource("1_s7215")
|
||||
|
||||
[node name="vbox" type="VBoxContainer" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 10.0
|
||||
offset_top = 5.0
|
||||
offset_right = 1142.0
|
||||
offset_bottom = 69.0
|
||||
|
||||
[node name="hbox" type="HBoxContainer" parent="vbox"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="hbox" type="HBoxContainer" parent="vbox/hbox"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="player_lbl" type="Label" parent="vbox/hbox/hbox"]
|
||||
layout_mode = 2
|
||||
text = "Player 1"
|
||||
|
||||
[node name="active_lbl" type="Label" parent="vbox/hbox/hbox"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
text = "Active"
|
||||
label_settings = SubResource("LabelSettings_o1hjn")
|
||||
uppercase = true
|
||||
|
||||
[node name="hbox2" type="HBoxContainer" parent="vbox/hbox"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 8
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="reset_bttn" type="Button" parent="vbox/hbox/hbox2"]
|
||||
layout_mode = 2
|
||||
focus_mode = 0
|
||||
mouse_default_cursor_shape = 2
|
||||
text = "Reset"
|
||||
flat = true
|
||||
alignment = 0
|
||||
|
||||
[connection signal="pressed" from="vbox/hbox/hbox2/reset_bttn" to="." method="_on_reset_bttn_pressed"]
|
||||
Reference in New Issue
Block a user