centeraalized reference to gameboard size
This commit is contained in:
parent
6ed2dd5f75
commit
c4c7bfc06d
3 changed files with 4 additions and 34 deletions
|
|
@ -34,7 +34,7 @@ func apply_effect(target_piece = null, board_flow = null, game_state = null):
|
||||||
var target_x = piece_x + dx
|
var target_x = piece_x + dx
|
||||||
var target_y = piece_y + dy
|
var target_y = piece_y + dy
|
||||||
|
|
||||||
if target_x < 0 or target_x >= 8 or target_y < 0 or target_y >= 8:
|
if target_x < 0 or target_x >= game_state.boardXSize or target_y < 0 or target_y >= game_state.boardYSize:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if dx == 0 and dy == 0:
|
if dx == 0 and dy == 0:
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ func apply_effect(target_piece = null, board_flow = null, game_state = null):
|
||||||
var target_y = king_y + dy
|
var target_y = king_y + dy
|
||||||
|
|
||||||
# Skip if outside board bounds
|
# Skip if outside board bounds
|
||||||
if target_x < 0 or target_x >= 8 or target_y < 0 or target_y >= 8:
|
if target_x < 0 or target_x >= game_state.boardXSize or target_y < 0 or target_y >= game_state.boardYSize:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Skip king's own position
|
# Skip king's own position
|
||||||
|
|
@ -126,33 +126,3 @@ func remove_effect():
|
||||||
if game_state.is_connected("turn_changed", Callable(self, "on_turn_changed")):
|
if game_state.is_connected("turn_changed", Callable(self, "on_turn_changed")):
|
||||||
game_state.disconnect("turn_changed", Callable(self, "on_turn_changed"))
|
game_state.disconnect("turn_changed", Callable(self, "on_turn_changed"))
|
||||||
super.remove_effect()
|
super.remove_effect()
|
||||||
|
|
||||||
func update_visual_effect(king, board_flow):
|
|
||||||
# Could be extended with visual feedback like particles or highlighting
|
|
||||||
var radius_tiles = []
|
|
||||||
var king_pos = king.get_parent().name.split("-")
|
|
||||||
var king_x = int(king_pos[0])
|
|
||||||
var king_y = int(king_pos[1])
|
|
||||||
|
|
||||||
for x in range(max(0, king_x - CAPTURE_RADIUS), min(8, king_x + CAPTURE_RADIUS + 1)):
|
|
||||||
for y in range(max(0, king_y - CAPTURE_RADIUS), min(8, king_y + CAPTURE_RADIUS + 1)):
|
|
||||||
if abs(x - king_x) + abs(y - king_y) <= CAPTURE_RADIUS:
|
|
||||||
var tile_name = str(x) + "-" + str(y)
|
|
||||||
radius_tiles.append(board_flow.get_node(tile_name))
|
|
||||||
|
|
||||||
# Highlight affected tiles briefly
|
|
||||||
for tile in radius_tiles:
|
|
||||||
var style = StyleBoxFlat.new()
|
|
||||||
style.bg_color = Color(1, 0, 0, 0.3) # Red tint
|
|
||||||
tile.add_theme_stylebox_override("normal", style)
|
|
||||||
|
|
||||||
# Remove highlight after a short delay
|
|
||||||
var timer = Timer.new()
|
|
||||||
board_flow.add_child(timer)
|
|
||||||
timer.wait_time = 0.5
|
|
||||||
timer.one_shot = true
|
|
||||||
timer.timeout.connect(func():
|
|
||||||
tile.remove_theme_stylebox_override("normal")
|
|
||||||
timer.queue_free()
|
|
||||||
)
|
|
||||||
timer.start()
|
|
||||||
|
|
|
||||||
|
|
@ -85,8 +85,8 @@ func place_random_game_tiles(num_tiles: int = 6) -> void:
|
||||||
return
|
return
|
||||||
|
|
||||||
var available_positions = []
|
var available_positions = []
|
||||||
for x in range(8):
|
for x in range(game.boardXSize):
|
||||||
for y in range(8):
|
for y in range(game.boardYSize):
|
||||||
if y > 1 && y < 6: # Don't place on starting rows
|
if y > 1 && y < 6: # Don't place on starting rows
|
||||||
available_positions.append(str(x) + "-" + str(y))
|
available_positions.append(str(x) + "-" + str(y))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue