From 19e75c60f94f7744e8a802bdbd9ac851ff90d3c3 Mon Sep 17 00:00:00 2001 From: 2ManyProjects Date: Sat, 1 Feb 2025 10:43:12 -0600 Subject: [PATCH] fixed supernova UI --- Systems/Card.gd | 11 ++++- Systems/Cards/Supernova.gd | 86 +++++++++++++++----------------------- 2 files changed, 43 insertions(+), 54 deletions(-) diff --git a/Systems/Card.gd b/Systems/Card.gd index 39ba3e1..40e78ab 100644 --- a/Systems/Card.gd +++ b/Systems/Card.gd @@ -51,8 +51,17 @@ func update_duration(): remaining_turns -= 1 if remaining_turns <= 0: remove_effect() + burn_or() + - +func burn_or(): + + match rank: + Rank.RANK_0: burned = true + Rank.RANK_1: burned = true + Rank.RANK_2: pass + Rank.RANK_3: pass + return true func modify_moves() -> Dictionary: return {} diff --git a/Systems/Cards/Supernova.gd b/Systems/Cards/Supernova.gd index af30d21..c8977ff 100644 --- a/Systems/Cards/Supernova.gd +++ b/Systems/Cards/Supernova.gd @@ -1,23 +1,19 @@ class_name SupernovaCard extends Card -const CAPTURE_RADIUS = 4 - +const CAPTURE_RADIUS = 3 +var started = false; func _init(): duration = 5 super._init() cardName = "Supernova" rank = Rank.RANK_0 effectType = EffectType.PIECE_EFFECT - description = "All enemy units within 4 radius are captured" + description = "All enemy units within 3 radius are captured" unitWhitelist = ["King"] + remaining_turns = duration func apply_effect(target_piece = null, board_flow = null, game_state = null): print(cardName, " APPLY EFFECT ") - # if !super.apply_effect(target_piece, board_flow, game_state): - # print(cardName, " super apply false ") - # return false - - remaining_turns = duration attached_piece = target_piece if !target_piece or !board_flow or !game_state: print(cardName, " missing input param ") @@ -28,82 +24,71 @@ func apply_effect(target_piece = null, board_flow = null, game_state = null): var king_x = int(king_pos[0]) var king_y = int(king_pos[1]) - # Collect all tiles within radius to check + # Calculate tiles as before... var tiles_to_check = [] - - # Check in all directions (up, down, left, right and diagonals) for dx in range(-CAPTURE_RADIUS, CAPTURE_RADIUS + 1): for dy in range(-CAPTURE_RADIUS, CAPTURE_RADIUS + 1): - # Skip if outside Manhattan distance if abs(dx) + abs(dy) > CAPTURE_RADIUS: continue - # Calculate target coordinates var target_x = king_x + dx var target_y = king_y + dy - # Skip if outside board bounds if target_x < 0 or target_x >= 8 or target_y < 0 or target_y >= 8: continue - # Skip king's own position if dx == 0 and dy == 0: continue - # Add tile to check list tiles_to_check.append(str(target_x) + "-" + str(target_y)) - print(tiles_to_check) - # reset_tile_styles(board_flow, tiles_to_check) - # Process each tile and capture pieces + # Process tiles and add overlay for tile_name in tiles_to_check: var tile = board_flow.get_node(tile_name) - var style = StyleBoxFlat.new() - style.bg_color = Color(1, 0, 0, 0.3) # Red tint - tile.remove_theme_stylebox_override("normal") - tile.add_theme_stylebox_override("normal", style) - if tile.get_child_count() > 0: - var piece = tile.get_child(0) - # print("Process", piece.name, " | ", piece.Item_Color, " | ", target_piece.Item_Color) - if piece.Item_Color != target_piece.Item_Color: # Only capture enemy pieces + # Remove any existing overlay + var existing_overlay = tile.get_node_or_null("SupernovaOverlay") + if existing_overlay: + existing_overlay.queue_free() + + # Create new overlay + var overlay = ColorRect.new() + overlay.name = "SupernovaOverlay" + overlay.color = Color(1, 0, 0, 0.3) + overlay.size = tile.size + overlay.mouse_filter = Control.MOUSE_FILTER_IGNORE # Make sure overlay doesn't block input + tile.add_child(overlay) + overlay.show() + + # Handle piece capture + if tile.get_child_count() > 1: # > 1 because we just added the overlay + var piece = tile.get_child(0) # Piece should still be first child + if piece.Item_Color != target_piece.Item_Color: game_state.updatePoints(piece) piece.queue_free() + # Setup timer to remove overlays var timer = Timer.new() board_flow.add_child(timer) timer.wait_time = 0.5 timer.one_shot = true timer.timeout.connect(func(): - reset_tile_styles(board_flow, tiles_to_check) + for tile_name in tiles_to_check: + var tile = board_flow.get_node(tile_name) + var overlay = tile.get_node_or_null("SupernovaOverlay") + if overlay: + overlay.queue_free() timer.queue_free() ) timer.start() - # Visual feedback - # for tile_name in tiles_to_check: - # var tile = board_flow.get_node(tile_name) - # var style = StyleBoxFlat.new() - # style.bg_color = Color(1, 0, 0, 0.3) # Red tint - # tile.add_theme_stylebox_override("normal", style) - - # 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() - setup_persistent_effect(game_state); - # game_state.stateMachine.transitionToNextState(Constants.POST_MOVE) + + setup_persistent_effect(game_state) return true - + func reset_tile_styles(board_flow, tiles_to_check): for tile_name in tiles_to_check: var tile = board_flow.get_node(tile_name) if !tile: - print("continue") continue # Reset to original chess board pattern @@ -135,11 +120,6 @@ func on_turn_changed(): # Now try apply_effect with these values apply_effect(piece, flow, state) - remaining_turns -= 1 - if remaining_turns <= 0: - remove_effect() - else: - burned = true func remove_effect(): if attached_piece: