* 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.
45 lines
1.2 KiB
GDScript
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() -> String:
|
|
return super()
|