From 0cbbd15a6021f46e4ec9f78cab39eac9e85c1e8b Mon Sep 17 00:00:00 2001 From: 2ManyProjects Date: Mon, 17 Mar 2025 17:16:30 -0500 Subject: [PATCH] created movement related cards --- Systems/Cards/HorseCostume.gd | 28 ++++++++++++++++++++++++++++ Systems/Cards/HorseCostume.gd.uid | 1 + Systems/Cards/KingsSquire.gd | 28 ++++++++++++++++++++++++++++ Systems/Cards/KingsSquire.gd.uid | 1 + Systems/Cards/QueensSquire.gd | 28 ++++++++++++++++++++++++++++ Systems/Cards/QueensSquire.gd.uid | 1 + Systems/Game/Map/MapGenerator.gd | 4 ++-- Utils/Utils.gd | 13 +------------ addons/Chess/Scripts/Pawn.gd | 11 ++++++----- 9 files changed, 96 insertions(+), 19 deletions(-) create mode 100644 Systems/Cards/HorseCostume.gd create mode 100644 Systems/Cards/HorseCostume.gd.uid create mode 100644 Systems/Cards/KingsSquire.gd create mode 100644 Systems/Cards/KingsSquire.gd.uid create mode 100644 Systems/Cards/QueensSquire.gd create mode 100644 Systems/Cards/QueensSquire.gd.uid diff --git a/Systems/Cards/HorseCostume.gd b/Systems/Cards/HorseCostume.gd new file mode 100644 index 0000000..18b1c2b --- /dev/null +++ b/Systems/Cards/HorseCostume.gd @@ -0,0 +1,28 @@ +class_name HorseCostumeCard extends Card + +func _init(): + super._init() + # id = Utils.generate_guid() + cardName = "Horse Costume" + rank = Rank.RANK_2 + effectType = EffectType.MOVEMENT_MODIFIER + description = "Attached Unit can move and capture in any direction" + duration = 3 + unitWhitelist = ["Pawn", "Bishop", "Queen", "Rook", "King"] + is_default = true + # current_movement_string = "mWmFcfF" + + +func apply_effect(target_piece = null, board_flow = null, game_state = null): + if !super.apply_effect(target_piece, board_flow, game_state): + return false + + attached_piece = target_piece + attached_piece.current_movement_string = "N" + return true + + +func reset(): + super.reset() + remaining_turns = duration + attached_piece.reset_current_movement_string() diff --git a/Systems/Cards/HorseCostume.gd.uid b/Systems/Cards/HorseCostume.gd.uid new file mode 100644 index 0000000..b3b9404 --- /dev/null +++ b/Systems/Cards/HorseCostume.gd.uid @@ -0,0 +1 @@ +uid://nw1oesh7pr48 diff --git a/Systems/Cards/KingsSquire.gd b/Systems/Cards/KingsSquire.gd new file mode 100644 index 0000000..6231129 --- /dev/null +++ b/Systems/Cards/KingsSquire.gd @@ -0,0 +1,28 @@ +class_name KingsSquireCard extends Card + +func _init(): + super._init() + # id = Utils.generate_guid() + cardName = "Kings' Squire" + rank = Rank.RANK_2 + effectType = EffectType.MOVEMENT_MODIFIER + description = "Attached Pawn can move and capture in any direction" + duration = 1 # Lasts for 2 turns + unitWhitelist = ["Pawn"] + is_default = false + # current_movement_string = "mWmFcfF" + + +func apply_effect(target_piece = null, board_flow = null, game_state = null): + if !super.apply_effect(target_piece, board_flow, game_state): + return false + + attached_piece = target_piece + attached_piece.current_movement_string = "WF" + return true + + +func reset(): + super.reset() + remaining_turns = duration + attached_piece.reset_current_movement_string() diff --git a/Systems/Cards/KingsSquire.gd.uid b/Systems/Cards/KingsSquire.gd.uid new file mode 100644 index 0000000..3bea221 --- /dev/null +++ b/Systems/Cards/KingsSquire.gd.uid @@ -0,0 +1 @@ +uid://ms7wi6dgoqnr diff --git a/Systems/Cards/QueensSquire.gd b/Systems/Cards/QueensSquire.gd new file mode 100644 index 0000000..9b53125 --- /dev/null +++ b/Systems/Cards/QueensSquire.gd @@ -0,0 +1,28 @@ +class_name QueensSquireCard extends Card + +func _init(): + super._init() + # id = Utils.generate_guid() + cardName = "Queens' Squire" + rank = Rank.RANK_3 + effectType = EffectType.MOVEMENT_MODIFIER + description = "Attached Pawn can move in any direction, can only capture diagonally forward" + duration = 1 # Lasts for 2 turns + unitWhitelist = ["Pawn"] + is_default = true + # current_movement_string = "mWmFcfF" + + +func apply_effect(target_piece = null, board_flow = null, game_state = null): + if !super.apply_effect(target_piece, board_flow, game_state): + return false + + attached_piece = target_piece + attached_piece.current_movement_string = "mWmFcfF" + return true + + +func reset(): + super.reset() + remaining_turns = duration + attached_piece.reset_current_movement_string() diff --git a/Systems/Cards/QueensSquire.gd.uid b/Systems/Cards/QueensSquire.gd.uid new file mode 100644 index 0000000..70eef2d --- /dev/null +++ b/Systems/Cards/QueensSquire.gd.uid @@ -0,0 +1 @@ +uid://8vpac2cx4e0u diff --git a/Systems/Game/Map/MapGenerator.gd b/Systems/Game/Map/MapGenerator.gd index 9384062..c72dfc1 100644 --- a/Systems/Game/Map/MapGenerator.gd +++ b/Systems/Game/Map/MapGenerator.gd @@ -552,8 +552,8 @@ func generate_chess_data(node, player): var unit_string = level_unit_distribution[index] var pawn_string = "" var height = 6; - unit_string = level_unit_distribution[level_unit_distribution.size() - 1] - height = 8 + # unit_string = level_unit_distribution[level_unit_distribution.size() - 1] + # height = 8 for x in unit_string.length(): pawn_string += "p" diff --git a/Utils/Utils.gd b/Utils/Utils.gd index 095e4c4..69d9af4 100644 --- a/Utils/Utils.gd +++ b/Utils/Utils.gd @@ -91,18 +91,7 @@ enum LossConditionType { UNIT_LOST, # Default: King loss TURN_NUMBER # Turn limit reached } - - -static var CardTypes = [ - HopscotchCard, - FieryCapeCard, - FieryTrailCard, - ExplosiveBootsCard, - DoubleTimeCard, - DrunkDrivingCard, - SupernovaCard -] - + static var CardPrices = { Card.Rank.RANK_0: 200, # Legendary (Rank 0) Card.Rank.RANK_1: 100, # Rare (Rank 1) diff --git a/addons/Chess/Scripts/Pawn.gd b/addons/Chess/Scripts/Pawn.gd index b702ab3..f19358f 100644 --- a/addons/Chess/Scripts/Pawn.gd +++ b/addons/Chess/Scripts/Pawn.gd @@ -148,8 +148,8 @@ func getValidMoves(board_flow, current_location: String) -> Dictionary: "N": # Knight processKnightMove(board_flow, moves, x, y, dir_vector, can_move, can_capture) - # Add special pawn moves if this is a pawn - if original_movement_string == "mfWcfF": + # Add special pawn moves if this is a pawn and no movement effects currently applied + if self.name == "Pawn" and self.original_movement_string == self.current_movement_string: addSpecialPawnMoves(board_flow, moves, x, y) return moves @@ -174,6 +174,9 @@ func can_move_to_cell(board_flow, location: String, is_capture: bool = false) -> func set_current_movement_string(mvmnt: String): current_movement_string = mvmnt +func reset_current_movement_string(): + original_movement_string = current_movement_string + func get_current_movement_string() -> String: return current_movement_string @@ -287,13 +290,11 @@ func getDirectionsForAtom(atom) -> Array: "N": # Knight - directions handled specially base_directions = ["f", "b", "l", "r"] - # Filter directions based on modifiers - NEW LOGIC HERE if direction_modifiers: var filtered_directions = [] for dir in base_directions: - # For each direction, check if it CONTAINS any of the modifiers - # (doesn't need to match all characters) + # For each direction, check if it has any of the modifiers var contains_modifier = false for mod in direction_modifiers: if dir.contains(mod):