feat: fix some bug
This commit is contained in:
+10
-6
@@ -109,6 +109,7 @@ var admin_panel_instance: Control
|
||||
var current_match_id: String = ""
|
||||
|
||||
var leaderboard_panel_instance: Control
|
||||
var shop_panel_instance: Control
|
||||
|
||||
# Bot name tracking keyed by slot index to avoid re-generating on each update
|
||||
var _bot_names: Dictionary = {}
|
||||
@@ -787,13 +788,16 @@ func _on_shop_pressed() -> void:
|
||||
connection_status.text = "Must be logged in"
|
||||
return
|
||||
|
||||
var shop_scene = load("res://scenes/ui/shop_panel.tscn")
|
||||
if shop_scene:
|
||||
var shop = shop_scene.instantiate()
|
||||
add_child(shop)
|
||||
if not shop_panel_instance:
|
||||
var shop_scene = load("res://scenes/ui/shop_panel.tscn")
|
||||
if shop_scene:
|
||||
shop_panel_instance = shop_scene.instantiate()
|
||||
add_child(shop_panel_instance)
|
||||
shop_panel_instance.closed.connect(func(): if main_menu_panel: main_menu_panel.show())
|
||||
|
||||
if shop_panel_instance:
|
||||
if main_menu_panel: main_menu_panel.hide()
|
||||
shop.closed.connect(func(): if main_menu_panel: main_menu_panel.show())
|
||||
shop.show_panel()
|
||||
shop_panel_instance.show_panel()
|
||||
|
||||
func _on_banner1_pressed() -> void:
|
||||
var gacha_scene = load("res://scenes/ui/gacha_panel.tscn")
|
||||
|
||||
+19
-10
@@ -985,10 +985,10 @@ func _assign_stop_n_go_spawn_positions(all_players: Array):
|
||||
|
||||
# Collect valid walkable spawn positions from the leftmost columns
|
||||
var valid_spawns: Array[Vector2i] = []
|
||||
for col in range(0, min(5, enhanced_gridmap.columns)): # Check first 5 columns
|
||||
for col in range(0, min(5, enhanced_gridmap.columns)): # Check first 5 columns
|
||||
for row in range(enhanced_gridmap.rows):
|
||||
var tile = enhanced_gridmap.get_cell_item(Vector3i(col, 0, row))
|
||||
if tile == 0 or tile == 3: # Walkable or Start
|
||||
if tile == 0 or tile == 3: # Walkable or Start
|
||||
valid_spawns.append(Vector2i(col, row))
|
||||
if valid_spawns.size() >= all_players.size():
|
||||
break
|
||||
@@ -1036,7 +1036,7 @@ func _assign_portal_mode_spawn_positions(all_players: Array):
|
||||
for dx in range(-radius, radius + 1):
|
||||
for dz in range(-radius, radius + 1):
|
||||
# Only check the "ring" at the current radius
|
||||
if abs(dx) != radius and abs(dz) != radius and radius > 0:
|
||||
if abs(dx) != radius and abs(dz) != radius and radius > 0:
|
||||
continue
|
||||
|
||||
var test_pos = center_pos + Vector2i(dx, dz)
|
||||
@@ -1056,7 +1056,7 @@ func _assign_portal_mode_spawn_positions(all_players: Array):
|
||||
if abs(test_pos.x - reserved.x) <= 2 and abs(test_pos.y - reserved.y) <= 2:
|
||||
is_reserved = true
|
||||
break
|
||||
if is_reserved:
|
||||
if is_reserved:
|
||||
continue
|
||||
|
||||
# 4. Check if occupied by another already-assigned player
|
||||
@@ -1408,6 +1408,7 @@ func add_newly_connected_player_character(new_peer_id: int):
|
||||
|
||||
func _on_peer_disconnected(peer_id: int):
|
||||
if not is_inside_tree(): return
|
||||
if not multiplayer.has_multiplayer_peer(): return
|
||||
if multiplayer.is_server():
|
||||
print("[Main] Peer %d disconnected. Checking for bot replacement..." % peer_id)
|
||||
|
||||
@@ -1506,7 +1507,6 @@ func set_current_turn(player_id: int):
|
||||
player.is_my_turn = is_current_turn
|
||||
|
||||
if is_current_turn and not (player.is_bot or player.is_in_group("Bots")):
|
||||
player.action_points = 2
|
||||
player.has_moved_this_turn = false
|
||||
player.has_performed_action = false
|
||||
player.start_turn()
|
||||
@@ -1585,6 +1585,20 @@ func sync_playerboard(player_id: int, new_playerboard: Array):
|
||||
if player_id == multiplayer.get_unique_id() and GameStateManager.local_player_character:
|
||||
ui_manager.update_playerboard_ui()
|
||||
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func sync_playerboard_slot(player_id: int, slot_index: int, item_id: int):
|
||||
"""Patch a single playerboard slot without touching other slots.
|
||||
Used by _execute_grab on grab confirmation to avoid overwriting concurrent
|
||||
in-flight optimistic grab updates on high-latency clients."""
|
||||
var player = get_node_or_null(str(player_id))
|
||||
if player and slot_index >= 0 and slot_index < player.playerboard.size():
|
||||
player.playerboard[slot_index] = item_id
|
||||
|
||||
# Update UI for local player only
|
||||
if player_id == multiplayer.get_unique_id() and GameStateManager.local_player_character:
|
||||
ui_manager.update_playerboard_ui()
|
||||
|
||||
|
||||
# =============================================================================
|
||||
|
||||
|
||||
@@ -2076,11 +2090,6 @@ func _on_match_ended():
|
||||
is_match_ended = true
|
||||
print("[Main] Match ended! Showing game over screen...")
|
||||
|
||||
# Disable player controls
|
||||
var local_player = GameStateManager.local_player_character
|
||||
if local_player:
|
||||
local_player.action_points = 0
|
||||
|
||||
# Signal Global Game End (Stops Bot ticks and logic)
|
||||
GameStateManager.end_game()
|
||||
|
||||
|
||||
+5
-9
@@ -123,7 +123,7 @@ var _is_processing_action: bool = false
|
||||
var selected_gridmap_position = Vector2i(-1, -1)
|
||||
var selected_playerboard_slot = -1
|
||||
var targeted_playerboard_slot = -1
|
||||
var action_points: int = 2
|
||||
#var has_performed_action: bool = false
|
||||
|
||||
# Modifier for player models
|
||||
var rotation_speed: float = 10.0
|
||||
@@ -1784,7 +1784,6 @@ func grid_to_world(grid_position: Vector2i) -> Vector3:
|
||||
return world_position
|
||||
|
||||
func start_turn():
|
||||
action_points = 2
|
||||
has_moved_this_turn = false
|
||||
has_performed_action = false
|
||||
is_my_turn = true
|
||||
@@ -1996,7 +1995,7 @@ func _execute_grab(grid_pos: Vector2i, cell: Vector3i, item_id: int):
|
||||
# This function runs on the server when requested by a client
|
||||
# -----------------------------------------------------------------
|
||||
@rpc("any_peer", "reliable")
|
||||
func request_server_grab(grid_pos: Vector2i, x: int, y: int, z: int, item_id: int):
|
||||
func request_server_grab(grid_pos: Vector2i, x: int, y: int, z: int, item_id: int, expected_slot: int = -1):
|
||||
# 1. Only the server (peer 1) should process this
|
||||
if not multiplayer.is_server():
|
||||
return
|
||||
@@ -2006,8 +2005,9 @@ func request_server_grab(grid_pos: Vector2i, x: int, y: int, z: int, item_id: in
|
||||
push_error("Security: Non-authority tried to grab item!")
|
||||
return
|
||||
|
||||
# 3. Call the execution logic
|
||||
playerboard_manager._execute_grab(grid_pos, Vector3i(x, y, z), item_id)
|
||||
# 3. Call the execution logic (pass expected_slot for deterministic placement)
|
||||
playerboard_manager._execute_grab(grid_pos, Vector3i(x, y, z), item_id, expected_slot)
|
||||
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Auto-put: no manual selection needed
|
||||
@@ -2074,7 +2074,6 @@ func request_server_put(grid_position: Vector2i, slot_index: int, x: int, y: int
|
||||
|
||||
# Update player state
|
||||
has_performed_action = true
|
||||
action_points -= 1
|
||||
selected_playerboard_slot = -1
|
||||
|
||||
# Notify about action completion
|
||||
@@ -2161,9 +2160,6 @@ func highlight_adjacent_cells():
|
||||
func highlight_empty_adjacent_cells():
|
||||
action_manager.highlight_empty_adjacent_cells()
|
||||
|
||||
@rpc("any_peer", "call_local")
|
||||
func sync_action_points(points: int):
|
||||
action_manager.sync_action_points(points)
|
||||
|
||||
func highlight_random_valid_cells():
|
||||
action_manager.highlight_random_valid_cells()
|
||||
|
||||
Reference in New Issue
Block a user