implement delivery ready indicator logic + off-color detection
This commit is contained in:
@@ -733,11 +733,56 @@ func _check_goal_completion():
|
||||
if not player.race_manager:
|
||||
return
|
||||
|
||||
# Check if the pattern matches
|
||||
if player.race_manager.check_pattern_match():
|
||||
var is_match = false
|
||||
var is_off_color = false
|
||||
var primary_color = -1
|
||||
|
||||
if LobbyManager.game_mode == "Candy Survival":
|
||||
# Custom Candy Survival blueprint check (can be off-color)
|
||||
var main = player.get_tree().get_root().get_node_or_null("Main")
|
||||
var gm = main.get_node_or_null("CandySurvivalManager") if main else null
|
||||
|
||||
# Find any 3x3 block that is completely filled with tiles (no -1)
|
||||
for start_row in range(3):
|
||||
for start_col in range(3):
|
||||
var filled = true
|
||||
var dominant_colors = {}
|
||||
|
||||
for i in range(3):
|
||||
for j in range(3):
|
||||
var val = player.playerboard[(start_row + i) * 5 + (start_col + j)]
|
||||
if val == -1:
|
||||
filled = false
|
||||
else:
|
||||
dominant_colors[val] = dominant_colors.get(val, 0) + 1
|
||||
|
||||
if filled:
|
||||
is_match = true
|
||||
# Find majority color
|
||||
var max_count = 0
|
||||
for c in dominant_colors:
|
||||
if dominant_colors[c] > max_count:
|
||||
max_count = dominant_colors[c]
|
||||
primary_color = c
|
||||
|
||||
is_off_color = (max_count < 9)
|
||||
if is_off_color and gm and gm.has_method("can_finish_with_off_color"):
|
||||
if not gm.can_finish_with_off_color(player.name.to_int(), primary_color):
|
||||
is_match = false # Reject if primary color is still available on grid
|
||||
|
||||
if is_match:
|
||||
break
|
||||
if is_match:
|
||||
break
|
||||
|
||||
if is_match and gm and gm.has_method("on_blueprint_completed"):
|
||||
gm.on_blueprint_completed(player.name.to_int(), primary_color, is_off_color)
|
||||
else:
|
||||
is_match = player.race_manager.check_pattern_match()
|
||||
|
||||
if is_match:
|
||||
print("[PlayerboardManager] Goal completed for player %s!" % player.name)
|
||||
|
||||
# Level up boost difficulty on goal completion
|
||||
var powerup_manager = player.get_node_or_null("PowerUpManager")
|
||||
if powerup_manager:
|
||||
powerup_manager.add_goal_completion_reward()
|
||||
|
||||
Reference in New Issue
Block a user