Files
Billiards/controllers/game/modes/9_ball.gd
itdominator b931ef5a01 feat(game): improve mode state handling and active player UI
* Rename and consolidate ball state tracking across game modes
* Add ball finalization and win-condition hooks
* Track foul points by negating reaped ball points
* Update turn switching and ball processing flow
* Add active-player indicator to the camera controller UI
* Refresh active-player label when the turn changes
2026-08-12 21:38:49 -05:00

53 lines
1.2 KiB
GDScript

class_name Ball9 extends BaseMode
func _init() -> void:
pass
func reap_ball(ball: Node3D) -> void:
super(ball)
if ball.name == "09_ball":
# TODO: 9 ball must not be be destroyed. Handle rule...
ball_states[ball.name]["valid_end"] = false
pass
func process_ball(ball: Node3D) -> void:
super(ball)
if ball.name == "09_ball":
# TODO: 9 ball must be sunk last. Handle rule...
ball_states[ball.name]["valid_end"] = false
pass
func handle_switch_user() -> void:
push_warning("Balls reaped: ", balls_reaped.size() )
push_warning("Balls sunk: ", balls_sunk.size() )
var switch_player: bool = true
if not balls_reaped.is_empty():
for ball_name in balls_reaped:
ball_states[ball_name]["points"] = -ball_states[ball_name]["points"]
balls_reaped.clear()
if not balls_sunk.is_empty():
# TODO: Handle points, etc, insure 9-ball not sunk unless last
# Insure we process stripped vs solid ball and apropriate points accordingly
switch_player = true
balls_sunk.clear()
if ball_states_finalized():
process_win_condition()
return
if switch_player:
Globals.game_state.switch_active_player()
turn_count += 1
else:
turn_count += 1
func process_win_condition() -> void:
pass