From b20121cba4f3ea011556155223cb143c013b7e7d Mon Sep 17 00:00:00 2001 From: 2ManyProjects Date: Thu, 6 Feb 2025 21:05:46 -0600 Subject: [PATCH] minor coloring fixes and removed parent of a parent calls --- Systems/Card.gd | 4 ++++ Systems/Cards/Explosiveboots.gd | 11 ++++++----- Systems/Cards/FieryCape.gd | 4 ++-- Systems/Cards/Supernova.gd | 19 ++++++++++--------- Systems/Game/ChessGame.gd | 2 +- 5 files changed, 23 insertions(+), 17 deletions(-) diff --git a/Systems/Card.gd b/Systems/Card.gd index 40e78ab..d019287 100644 --- a/Systems/Card.gd +++ b/Systems/Card.gd @@ -19,6 +19,8 @@ var effectType: EffectType var remaining_turns: int = 0 var unitWhitelist: Array[String] = [] # List of piece types this card can be attached to var id: String = Utils.generate_guid() +var stored_board_flow = null +var stored_game_state = null func _init(): remaining_turns = duration @@ -37,6 +39,8 @@ func apply_effect(target_piece = null, board_flow = null, game_state = null): remaining_turns = duration attached_piece = target_piece + stored_board_flow = board_flow + stored_game_state = game_state match rank: Rank.RANK_0: burned = true diff --git a/Systems/Cards/Explosiveboots.gd b/Systems/Cards/Explosiveboots.gd index 5cb716c..3f73e5c 100644 --- a/Systems/Cards/Explosiveboots.gd +++ b/Systems/Cards/Explosiveboots.gd @@ -14,6 +14,8 @@ func _init(): func apply_effect(target_piece = null, board_flow = null, game_state = null): attached_piece = target_piece + stored_board_flow = board_flow + stored_game_state = game_state if !target_piece or !board_flow or !game_state: print(cardName, " missing input param ") return false @@ -105,11 +107,10 @@ func setup_persistent_effect(game_state): func on_turn_changed(): # print("TURN CHANGED ==================", attached_piece, " | ", remaining_turns, ) - if attached_piece.get_parent().get_parent().owner.isPlayerTurn() and attached_piece and remaining_turns > 0: - # print(attached_piece.get_parent().get_parent(), attached_piece.get_parent().get_parent().owner) + if attached_piece.stored_game_state.isPlayerTurn() and attached_piece and remaining_turns > 0: var piece = attached_piece - var flow = attached_piece.get_parent().get_parent() - var state = attached_piece.get_parent().get_parent().owner + var flow = stored_board_flow + var state = attached_piece.stored_game_state # print("Debug values:") # print("- Piece: ", piece, " is null? ", piece == null) @@ -122,7 +123,7 @@ func on_turn_changed(): func remove_effect(): if attached_piece: - var game_state = attached_piece.get_parent().get_parent().owner + var game_state = attached_piece.stored_game_state if game_state.is_connected("turn_changed", on_turn_changed): game_state.disconnect("turn_changed", on_turn_changed) super.remove_effect() diff --git a/Systems/Cards/FieryCape.gd b/Systems/Cards/FieryCape.gd index 83cc8a7..a7edf41 100644 --- a/Systems/Cards/FieryCape.gd +++ b/Systems/Cards/FieryCape.gd @@ -30,7 +30,7 @@ func on_turn_changed(): return var piece = attached_piece - var board_flow = piece.get_parent().get_parent() + var board_flow = stored_board_flow var current_pos = piece.get_parent().name # If the piece has moved, place fire tiles @@ -72,7 +72,7 @@ func on_turn_changed(): func remove_effect(): if attached_piece: - var game_state = attached_piece.get_parent().get_parent().owner + var game_state = stored_game_state if game_state.is_connected("turn_changed", on_turn_changed): game_state.disconnect("turn_changed", on_turn_changed) super.remove_effect() \ No newline at end of file diff --git a/Systems/Cards/Supernova.gd b/Systems/Cards/Supernova.gd index 47344e3..6e76587 100644 --- a/Systems/Cards/Supernova.gd +++ b/Systems/Cards/Supernova.gd @@ -15,6 +15,8 @@ func _init(): func apply_effect(target_piece = null, board_flow = null, game_state = null): attached_piece = target_piece + stored_board_flow = board_flow + stored_game_state = game_state if !target_piece or !board_flow or !game_state: print(cardName, " missing input param ") return false @@ -26,10 +28,10 @@ func apply_effect(target_piece = null, board_flow = null, game_state = null): var king_pos = target_piece.get_parent().name.split("-") var king_x = int(king_pos[0]) var king_y = int(king_pos[1]) - + # Collect all tiles within radius to check 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): @@ -79,7 +81,7 @@ func apply_effect(target_piece = null, board_flow = null, game_state = null): if piece != null and piece.Item_Color != target_piece.Item_Color: game_state.updatePoints(piece) container.remove_piece() - + # Setup timer to remove overlays var timer = Timer.new() board_flow.add_child(timer) @@ -94,7 +96,7 @@ func apply_effect(target_piece = null, board_flow = null, game_state = null): timer.queue_free() ) timer.start() - + return true @@ -105,11 +107,10 @@ func setup_persistent_effect(game_state): func on_turn_changed(): - if attached_piece.get_parent().get_parent().owner.isPlayerTurn() and attached_piece and remaining_turns > 0: - # print(attached_piece.get_parent().get_parent(), attached_piece.get_parent().get_parent().owner) + if attached_piece.stored_game_state.isPlayerTurn() and attached_piece and remaining_turns > 0: var piece = attached_piece - var flow = attached_piece.get_parent().get_parent() - var state = attached_piece.get_parent().get_parent().owner + var flow = attached_piece.stored_board_flow + var state = attached_piece.stored_game_state # print("Debug values:") # print("- Piece: ", piece, " is null? ", piece == null) @@ -122,7 +123,7 @@ func on_turn_changed(): func remove_effect(): if attached_piece: - var game_state = attached_piece.get_parent().get_parent().owner + var game_state = attached_piece.stored_game_state if game_state.is_connected("turn_changed", Callable(self, "on_turn_changed")): game_state.disconnect("turn_changed", Callable(self, "on_turn_changed")) super.remove_effect() diff --git a/Systems/Game/ChessGame.gd b/Systems/Game/ChessGame.gd index 56dcb54..3ace80b 100644 --- a/Systems/Game/ChessGame.gd +++ b/Systems/Game/ChessGame.gd @@ -177,7 +177,7 @@ func parseLocation(location: String) -> void: func setupStyles() -> void: lightStyle = StyleBoxFlat.new() - lightStyle.bg_color = Color(0.8, 0.8, 0.8, 1) + lightStyle.bg_color = Color(0.5, 0.5, 0.5, 1) darkStyle = StyleBoxFlat.new() darkStyle.bg_color = Color(0.2, 0.2, 0.2, 1)