Added some point processing, cleanup
This commit is contained in:
@@ -21,11 +21,15 @@ func process_ball(ball: Node3D) -> void:
|
|||||||
func handle_switch_user() -> void:
|
func handle_switch_user() -> void:
|
||||||
push_warning("Balls reaped: ", balls_reaped.size() )
|
push_warning("Balls reaped: ", balls_reaped.size() )
|
||||||
push_warning("Balls sunk: ", balls_sunk.size() )
|
push_warning("Balls sunk: ", balls_sunk.size() )
|
||||||
|
var is_player_1: bool = "Player 1" == get_player()
|
||||||
var switch_player: bool = true
|
var switch_player: bool = true
|
||||||
|
|
||||||
if not balls_reaped.is_empty():
|
if not balls_reaped.is_empty():
|
||||||
for ball_name in balls_reaped:
|
for ball_name in balls_reaped:
|
||||||
ball_states[ball_name]["points"] = -ball_states[ball_name]["points"]
|
if is_player_1:
|
||||||
|
player_1_points -= ball_states[ball_name]["points"]
|
||||||
|
else:
|
||||||
|
player_2_points -= ball_states[ball_name]["points"]
|
||||||
|
|
||||||
balls_reaped.clear()
|
balls_reaped.clear()
|
||||||
|
|
||||||
@@ -43,8 +47,7 @@ func handle_switch_user() -> void:
|
|||||||
|
|
||||||
if switch_player:
|
if switch_player:
|
||||||
Globals.game_state.switch_active_player()
|
Globals.game_state.switch_active_player()
|
||||||
turn_count += 1
|
|
||||||
else:
|
|
||||||
turn_count += 1
|
turn_count += 1
|
||||||
|
|
||||||
func process_win_condition() -> void:
|
func process_win_condition() -> void:
|
||||||
|
|||||||
@@ -21,11 +21,15 @@ func process_ball(ball: Node3D) -> void:
|
|||||||
func handle_switch_user() -> void:
|
func handle_switch_user() -> void:
|
||||||
push_warning("Balls reaped: ", balls_reaped.size() )
|
push_warning("Balls reaped: ", balls_reaped.size() )
|
||||||
push_warning("Balls sunk: ", balls_sunk.size() )
|
push_warning("Balls sunk: ", balls_sunk.size() )
|
||||||
|
var is_player_1: bool = "Player 1" == get_player()
|
||||||
var switch_player: bool = true
|
var switch_player: bool = true
|
||||||
|
|
||||||
if not balls_reaped.is_empty():
|
if not balls_reaped.is_empty():
|
||||||
for ball_name in balls_reaped:
|
for ball_name in balls_reaped:
|
||||||
ball_states[ball_name]["points"] = -ball_states[ball_name]["points"]
|
if is_player_1:
|
||||||
|
player_1_points -= ball_states[ball_name]["points"]
|
||||||
|
else:
|
||||||
|
player_2_points -= ball_states[ball_name]["points"]
|
||||||
|
|
||||||
balls_reaped.clear()
|
balls_reaped.clear()
|
||||||
|
|
||||||
@@ -43,8 +47,7 @@ func handle_switch_user() -> void:
|
|||||||
|
|
||||||
if switch_player:
|
if switch_player:
|
||||||
Globals.game_state.switch_active_player()
|
Globals.game_state.switch_active_player()
|
||||||
turn_count += 1
|
|
||||||
else:
|
|
||||||
turn_count += 1
|
turn_count += 1
|
||||||
|
|
||||||
func process_win_condition() -> void:
|
func process_win_condition() -> void:
|
||||||
|
|||||||
@@ -13,16 +13,24 @@ func process_ball(ball: Node3D) -> void:
|
|||||||
func handle_switch_user() -> void:
|
func handle_switch_user() -> void:
|
||||||
push_warning("Balls reaped: ", balls_reaped.size() )
|
push_warning("Balls reaped: ", balls_reaped.size() )
|
||||||
push_warning("Balls sunk: ", balls_sunk.size() )
|
push_warning("Balls sunk: ", balls_sunk.size() )
|
||||||
|
var is_player_1: bool = "Player 1" == get_player()
|
||||||
var switch_player: bool = true
|
var switch_player: bool = true
|
||||||
|
|
||||||
if not balls_reaped.is_empty():
|
if not balls_reaped.is_empty():
|
||||||
for ball_name in balls_reaped:
|
for ball_name in balls_reaped:
|
||||||
ball_states[ball_name]["points"] = -ball_states[ball_name]["points"]
|
if is_player_1:
|
||||||
|
player_1_points -= ball_states[ball_name]["points"]
|
||||||
|
else:
|
||||||
|
player_2_points -= ball_states[ball_name]["points"]
|
||||||
|
|
||||||
balls_reaped.clear()
|
balls_reaped.clear()
|
||||||
|
|
||||||
if not balls_sunk.is_empty():
|
if not balls_sunk.is_empty():
|
||||||
# TODO: Handle points, etc
|
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"]
|
||||||
|
|
||||||
switch_player = false
|
switch_player = false
|
||||||
balls_sunk.clear()
|
balls_sunk.clear()
|
||||||
@@ -33,8 +41,7 @@ func handle_switch_user() -> void:
|
|||||||
|
|
||||||
if switch_player:
|
if switch_player:
|
||||||
Globals.game_state.switch_active_player()
|
Globals.game_state.switch_active_player()
|
||||||
turn_count += 1
|
|
||||||
else:
|
|
||||||
turn_count += 1
|
turn_count += 1
|
||||||
|
|
||||||
func process_win_condition() -> void:
|
func process_win_condition() -> void:
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ func generate_ball_states() -> Dictionary:
|
|||||||
var ball_name = COLORED_BALLS[i]
|
var ball_name = COLORED_BALLS[i]
|
||||||
var points = COLORED_BALLS_POINTS[i]
|
var points = COLORED_BALLS_POINTS[i]
|
||||||
|
|
||||||
state[ball_name] = ball_states.duplicate_deep()
|
state[ball_name] = BALL_STATE.duplicate_deep()
|
||||||
state[ball_name]["points"] = points
|
state[ball_name]["points"] = points
|
||||||
|
|
||||||
# NOTE: Red balls
|
# NOTE: Red balls
|
||||||
@@ -60,16 +60,25 @@ func process_ball(ball: Node3D) -> void:
|
|||||||
func handle_switch_user() -> void:
|
func handle_switch_user() -> void:
|
||||||
push_warning("Balls reaped: ", balls_reaped.size() )
|
push_warning("Balls reaped: ", balls_reaped.size() )
|
||||||
push_warning("Balls sunk: ", balls_sunk.size() )
|
push_warning("Balls sunk: ", balls_sunk.size() )
|
||||||
|
var is_player_1: bool = "Player 1" == get_player()
|
||||||
var switch_player: bool = true
|
var switch_player: bool = true
|
||||||
|
|
||||||
if not balls_reaped.is_empty():
|
if not balls_reaped.is_empty():
|
||||||
for ball_name in balls_reaped:
|
for ball_name in balls_reaped:
|
||||||
ball_states[ball_name]["points"] = -ball_states[ball_name]["points"]
|
if is_player_1:
|
||||||
|
player_1_points -= ball_states[ball_name]["points"]
|
||||||
|
else:
|
||||||
|
player_2_points -= ball_states[ball_name]["points"]
|
||||||
|
|
||||||
balls_reaped.clear()
|
balls_reaped.clear()
|
||||||
|
|
||||||
if not balls_sunk.is_empty():
|
if not balls_sunk.is_empty():
|
||||||
# TODO: Handle points, etc, insure color ball not sunk before red ball
|
# NOTE: Handle points, etc, insure color ball not sunk before red ball
|
||||||
|
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"]
|
||||||
|
|
||||||
switch_player = false
|
switch_player = false
|
||||||
balls_sunk.clear()
|
balls_sunk.clear()
|
||||||
@@ -80,8 +89,7 @@ func handle_switch_user() -> void:
|
|||||||
|
|
||||||
if switch_player:
|
if switch_player:
|
||||||
Globals.game_state.switch_active_player()
|
Globals.game_state.switch_active_player()
|
||||||
turn_count += 1
|
|
||||||
else:
|
|
||||||
turn_count += 1
|
turn_count += 1
|
||||||
|
|
||||||
func process_win_condition() -> void:
|
func process_win_condition() -> void:
|
||||||
|
|||||||
Reference in New Issue
Block a user