2026-08-10 21:22:52 -05:00
|
|
|
class_name FreeBall extends BaseMode
|
|
|
|
|
|
|
|
|
|
|
2026-08-11 23:59:30 -05:00
|
|
|
func _init() -> void:
|
|
|
|
|
pass
|
|
|
|
|
|
2026-08-10 21:22:52 -05:00
|
|
|
func reap_ball(ball: Node3D) -> void:
|
|
|
|
|
super(ball)
|
|
|
|
|
|
|
|
|
|
func process_ball(ball: Node3D) -> void:
|
|
|
|
|
super(ball)
|
|
|
|
|
|
|
|
|
|
func handle_switch_user() -> void:
|
|
|
|
|
push_warning("Balls reaped: ", balls_reaped.size() )
|
|
|
|
|
push_warning("Balls sunk: ", balls_sunk.size() )
|
2026-08-12 22:36:45 -05:00
|
|
|
var is_player_1: bool = "Player 1" == get_player()
|
2026-08-12 22:14:03 -05:00
|
|
|
var switch_player: bool = true
|
2026-08-10 21:22:52 -05:00
|
|
|
|
|
|
|
|
if not balls_reaped.is_empty():
|
2026-08-12 22:14:03 -05:00
|
|
|
for ball_name in balls_reaped:
|
2026-08-12 22:36:45 -05:00
|
|
|
if is_player_1:
|
|
|
|
|
player_1_points -= ball_states[ball_name]["points"]
|
|
|
|
|
else:
|
|
|
|
|
player_2_points -= ball_states[ball_name]["points"]
|
2026-08-12 22:14:03 -05:00
|
|
|
|
2026-08-10 21:22:52 -05:00
|
|
|
balls_reaped.clear()
|
|
|
|
|
|
2026-08-12 22:14:03 -05:00
|
|
|
if not balls_sunk.is_empty():
|
2026-08-12 22:36:45 -05:00
|
|
|
for ball_name in balls_sunk:
|
|
|
|
|
if is_player_1:
|
|
|
|
|
player_1_points += ball_states[ball_name]["points"]
|
|
|
|
|
else:
|
|
|
|
|
player_2_points += ball_states[ball_name]["points"]
|
2026-08-12 22:14:03 -05:00
|
|
|
|
|
|
|
|
switch_player = false
|
|
|
|
|
balls_sunk.clear()
|
|
|
|
|
|
|
|
|
|
if ball_states_finalized():
|
|
|
|
|
process_win_condition()
|
2026-08-10 21:22:52 -05:00
|
|
|
return
|
|
|
|
|
|
2026-08-12 22:14:03 -05:00
|
|
|
if switch_player:
|
|
|
|
|
Globals.game_state.switch_active_player()
|
2026-08-12 22:36:45 -05:00
|
|
|
|
|
|
|
|
turn_count += 1
|
2026-08-10 21:22:52 -05:00
|
|
|
|
2026-08-12 22:14:03 -05:00
|
|
|
func process_win_condition() -> void:
|
|
|
|
|
pass
|