fixed portal pairing

This commit is contained in:
2ManyProjects 2025-02-09 01:41:13 -06:00
parent a412ab90e6
commit b4a7cf00d6

View file

@ -76,7 +76,7 @@ func clear_tiles() -> void:
remove_tile(location) remove_tile(location)
# Function to place random game tiles at the start of each match # Function to place random game tiles at the start of each match
func place_random_game_tiles(num_tiles: int = 6) -> void: func place_random_game_tiles(num_tiles: int = 8) -> void:
if !board_flow: if !board_flow:
push_error("TileManager not initialized with board_flow") push_error("TileManager not initialized with board_flow")
return return
@ -89,8 +89,11 @@ func place_random_game_tiles(num_tiles: int = 6) -> void:
available_positions.shuffle() available_positions.shuffle()
var skipNext = false;
for i in range(min(num_tiles, available_positions.size())): for i in range(min(num_tiles, available_positions.size())):
if skipNext:
skipNext = false
continue
var pos = available_positions[i] var pos = available_positions[i]
var container = board_flow.get_node(pos) as PieceContainer var container = board_flow.get_node(pos) as PieceContainer
if !container: if !container:
@ -119,50 +122,47 @@ func place_random_game_tiles(num_tiles: int = 6) -> void:
var next_pos = available_positions[i + 1] var next_pos = available_positions[i + 1]
var next_container = board_flow.get_node(next_pos) as PieceContainer var next_container = board_flow.get_node(next_pos) as PieceContainer
if next_container: if next_container:
var next_is_white = (int(next_pos.split("-")[0]) + int(next_pos.split("-")[1])) % 2 == 0 # var next_is_white = (int(next_pos.split("-")[0]) + int(next_pos.split("-")[1])) % 2 == 0
# Create portal pair with alternating blue/orange colors # # Create portal pair with alternating blue/orange colors
# var portal_color = Color.ORANGE if (i % 2 == 0) else Color.BLUE # # var portal_color = Color.ORANGE if (i % 2 == 0) else Color.BLUE
var portals = PortalTile.create_portal_pair( # var portals = PortalTile.create_portal_pair(
container, is_white, # container, is_white,
next_container, next_is_white, # next_container, next_is_white,
-1, # permanent duration # -1, # permanent duration
i, # pair id # i, # pair id
Color.ORANGE, # Color.ORANGE,
Color.BLUE # Color.BLUE
) # )
# Add both portals
add_tile(pos, portals[0])
add_tile(next_pos, portals[1])
# # Add both portals
# add_tile(pos, portals[0])
# add_tile(next_pos, portals[1])
place_portal_pair(pos, i, available_positions, container, is_white)
# Skip the next position since we used it for the portal pair # Skip the next position since we used it for the portal pair
i += 1 skipNext = true
else: else:
# If we can't make a pair, fall back to a wall tile # If we can't make a pair, fall back to a wall tile
tile = WallTile.new(container, is_white, -1) tile = WallTile.new(container, is_white, -1)
add_tile(pos, tile) add_tile(pos, tile)
# func place_portal_pair(location1: String, location2: String, duration: int = -1) -> void: func place_portal_pair(pos: String = "", i: int = 0, available_positions: Array = [], container: PieceContainer = null, is_white: bool = false) -> void:
# var container1 = board_flow.get_node(location1) as PieceContainer var next_pos = available_positions[i + 1]
# var container2 = board_flow.get_node(location2) as PieceContainer var next_container = board_flow.get_node(next_pos) as PieceContainer
if next_container:
var next_is_white = (int(next_pos.split("-")[0]) + int(next_pos.split("-")[1])) % 2 == 0
# if container1 && container2: # Create portal pair with alternating blue/orange colors
# var is_white1 = (int(location1.split("-")[0]) + int(location1.split("-")[1])) % 2 == 0 # var portal_color = Color.ORANGE if (i % 2 == 0) else Color.BLUE
# var is_white2 = (int(location2.split("-")[0]) + int(location2.split("-")[1])) % 2 == 0 var portals = PortalTile.create_portal_pair(
container, is_white,
next_container, next_is_white,
-1, # permanent duration
i, # pair id
Color.ORANGE,
Color.BLUE
)
# # Generate a unique color for this pair # Add both portals
# var portal_color = Color(randf(), randf(), 1.0) # Blue-ish random color add_tile(pos, portals[0])
add_tile(next_pos, portals[1])
# # Create portal pair
# var portals = PortalTile.create_portal_pair(
# container1, is_white1,
# container2, is_white2,
# duration,
# active_tiles.size(), # Use current size as unique pair ID
# portal_color
# )
# # Add both portals to active tiles
# add_tile(location1, portals[0])
# add_tile(location2, portals[1])