feat: Implement initial game structure with core logic, various managers, player scene, and project configuration.
This commit is contained in:
@@ -52,12 +52,13 @@ func grab_item(grid_position: Vector2i) -> bool:
|
||||
# Apply changes locally first, server will validate/sync
|
||||
enhanced_gridmap.set_cell_item(cell, -1) # Remove item visually immediately
|
||||
|
||||
# Check if grabbed item is a holo tile (11-14) and trigger special effect
|
||||
# Check if grabbed item is a holo tile (11-14) - add to powerup instead of triggering effect
|
||||
var is_holo = item >= 11 and item <= 14
|
||||
if is_holo:
|
||||
var special_tiles_manager = player.get_node_or_null("SpecialTilesManager")
|
||||
if special_tiles_manager:
|
||||
special_tiles_manager.trigger_random_effect()
|
||||
# Add holo pickup to power-up manager (4 pickups = 1 bar)
|
||||
var powerup_manager = player.get_node_or_null("PowerUpManager")
|
||||
if powerup_manager:
|
||||
powerup_manager.add_holo_pickup()
|
||||
# Convert holo tile to normal tile (11->7, 12->8, 13->9, 14->10)
|
||||
item = item - 4
|
||||
|
||||
@@ -67,6 +68,9 @@ func grab_item(grid_position: Vector2i) -> bool:
|
||||
var main = player.get_tree().get_root().get_node_or_null("Main")
|
||||
if main and main.ui_manager:
|
||||
main.ui_manager.update_playerboard_ui()
|
||||
|
||||
# Check if goal is completed after grabbing
|
||||
_check_goal_completion()
|
||||
|
||||
# === Server Sync ===
|
||||
if multiplayer.is_server():
|
||||
@@ -151,17 +155,18 @@ func bot_try_grab_item() -> bool:
|
||||
var empty_slot = player.playerboard.find(-1)
|
||||
if empty_slot != -1:
|
||||
if player.is_multiplayer_authority():
|
||||
# Check if grabbed item is a holo tile (11-14)
|
||||
# Check if grabbed item is a holo tile (11-14) - add to powerup
|
||||
if item >= 11 and item <= 14:
|
||||
var special_tiles_manager = player.get_node_or_null("SpecialTilesManager")
|
||||
if special_tiles_manager:
|
||||
special_tiles_manager.trigger_random_effect()
|
||||
var powerup_manager = player.get_node_or_null("PowerUpManager")
|
||||
if powerup_manager:
|
||||
powerup_manager.add_holo_pickup()
|
||||
item = item - 4 # Convert to normal tile
|
||||
player.playerboard[empty_slot] = item
|
||||
player.rpc("sync_grid_item", current_cell.x, current_cell.y, current_cell.z, -1)
|
||||
player.rpc("sync_playerboard", player.playerboard)
|
||||
player.has_performed_action = true
|
||||
player.action_points -= 1
|
||||
_check_goal_completion()
|
||||
return true
|
||||
|
||||
# Check adjacent cells if nothing at current position
|
||||
@@ -590,3 +595,52 @@ func _highlight_adjacent_playerboard_slots():
|
||||
var slot = main.playerboard_ui.get_child(adj_slot)
|
||||
if slot.get_child_count() > 2:
|
||||
slot.get_child(2).show()
|
||||
|
||||
# =============================================================================
|
||||
# Goal Completion Check
|
||||
# =============================================================================
|
||||
|
||||
func _check_goal_completion():
|
||||
"""Check if playerboard matches goals and trigger completion rewards."""
|
||||
if not player.race_manager:
|
||||
return
|
||||
|
||||
# Check if the pattern matches
|
||||
if player.race_manager.check_pattern_match():
|
||||
print("[PlayerboardManager] Goal completed for player %s!" % player.name)
|
||||
|
||||
# Award power-up bar for goal completion
|
||||
var powerup_manager = player.get_node_or_null("PowerUpManager")
|
||||
if powerup_manager:
|
||||
powerup_manager.add_goal_completion_reward()
|
||||
|
||||
# Notify GoalsCycleManager for scoring
|
||||
var main = player.get_tree().get_root().get_node_or_null("Main")
|
||||
if main:
|
||||
var goals_cycle_manager = main.get_node_or_null("GoalsCycleManager")
|
||||
if goals_cycle_manager:
|
||||
goals_cycle_manager.on_goal_completed(player, goals_cycle_manager.get_time_remaining())
|
||||
else:
|
||||
# Fallback if manager not initialized yet
|
||||
player.rpc("display_message", "Goal completed!")
|
||||
|
||||
func clear_and_convert_to_score() -> int:
|
||||
"""Clear playerboard and return score for matching tiles."""
|
||||
var matching_score = 0
|
||||
var goals = player.goals
|
||||
var playerboard = player.playerboard
|
||||
|
||||
# Check center 3x3 of playerboard against goals
|
||||
for i in range(3):
|
||||
for j in range(3):
|
||||
var goal_idx = i * 3 + j
|
||||
var board_idx = (i + 1) * 5 + (j + 1) # Center 3x3 in 5x5 board
|
||||
|
||||
if goal_idx < goals.size() and board_idx < playerboard.size():
|
||||
if goals[goal_idx] != -1 and playerboard[board_idx] == goals[goal_idx]:
|
||||
matching_score += 10 # 10 points per matching tile
|
||||
|
||||
# Clear playerboard
|
||||
player.playerboard.fill(-1)
|
||||
|
||||
return matching_score
|
||||
|
||||
Reference in New Issue
Block a user