Files
Billiards/controllers/game/modes/snooker.gd
itdominator 409680b94a major refactor(game-modes): centralize scoring and turn handling
* Move common ball recording, scoring, and turn-switching logic into `BaseMode`
* Add hooks for mode-specific ball handling and turn behavior
* Simplify 8-ball and 9-ball modes to use `LastBallMode`
* Update Snooker to use the new ball-processing hooks
* Remove duplicated scoring and turn-management code
2026-08-13 00:16:09 -05:00

45 lines
1.2 KiB
GDScript

class_name Snooker extends BaseMode
# NOTE: The game is sometimes played with fewer red balls- commonly 6 or 10.
# Normally, 15 red balls (1 point) and 6 balls of different colors:
# yellow (2 points), green (3), brown (4), blue (5), pink (6), black (7).
const COLORED_BALLS := {
"yellow_ball": 2, "green_ball": 3, "brown_ball": 4,
"blue_ball": 5, "pink_ball": 6, "black_ball": 7,
}
func _init() -> void:
pass
func generate_ball_states() -> Dictionary:
var state: Dictionary = {}
for ball_name in COLORED_BALLS:
state[ball_name] = BALL_STATE.duplicate_deep()
state[ball_name]["points"] = COLORED_BALLS[ball_name]
for i: int in range(1, 16):
var ball_name := "%02d_ball" % i
state[ball_name] = BALL_STATE.duplicate_deep()
state[ball_name]["points"] = 1
return state
func on_ball_reaped(ball: Node3D) -> void:
if ball.name in COLORED_BALLS:
ball_states[ball.name]["is_foul"] = true
func on_ball_sunk(ball: Node3D) -> void:
if ball.name in COLORED_BALLS:
# TODO: Check whether a red ball has been sunk first.
ball_states[ball.name]["is_foul"] = true
func score_sunk_balls() -> bool:
return true
func process_win_condition() -> void:
pass