commit c1a6a06dd37e186f9ef0b7b49f85fbea889d85f5 Author: 2ManyProjects Date: Fri Jan 24 20:06:23 2025 -0600 MVP diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8ad74f7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Normalize EOL for all files that Git considers text files. +* text=auto eol=lf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0af181c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# Godot 4+ specific ignores +.godot/ +/android/ diff --git a/Chess.png b/Chess.png new file mode 100644 index 0000000..d7ad79e Binary files /dev/null and b/Chess.png differ diff --git a/Chess.png.import b/Chess.png.import new file mode 100644 index 0000000..648d333 --- /dev/null +++ b/Chess.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bphl4a8t8l0h7" +path="res://.godot/imported/Chess.png-5aa5e1cd7f41db7e12bcda3ac0b5924e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Chess.png" +dest_files=["res://.godot/imported/Chess.png-5aa5e1cd7f41db7e12bcda3ac0b5924e.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Diagrams/Game Machine.mmd b/Diagrams/Game Machine.mmd new file mode 100644 index 0000000..d358912 --- /dev/null +++ b/Diagrams/Game Machine.mmd @@ -0,0 +1,31 @@ +--- +config: + theme: forest +--- +stateDiagram + [*] --> GameSetup + GameSetup --> WhiteTurn + state TurnPhases { + WhiteTurn --> HandSetup + BlackTurn --> HandSetup + HandSetup --> ResolvePersistentEffects : Draw Cards + ResolvePersistentEffects --> ApplyTileEffects + ApplyTileEffects --> AttachCards + AttachCards --> ApplyCardEffects + ApplyCardEffects --> Movement + Movement --> EvaluatePosition + state EvaluatePosition { + [*] --> CheckStatus + CheckStatus --> Checkmate : In Checkmate + CheckStatus --> Draw : In Draw + CheckStatus --> ValidMove : Game Continues + ValidMove --> SpecialMoves + SpecialMoves --> [*] + } + EvaluatePosition --> WhiteTurn : White's Turn + EvaluatePosition --> BlackTurn : Black's Turn + EvaluatePosition --> RoundEnd : Game Over + } + RoundEnd --> ShopPhase + ShopPhase --> GameSetup : Next Round + RoundEnd --> [*] : End Game diff --git a/Game.gd b/Game.gd new file mode 100644 index 0000000..8642c2e --- /dev/null +++ b/Game.gd @@ -0,0 +1,214 @@ +extends Control + +const CardDisplay = preload("res://Systems/CardDisplay.gd") + + +var Selected_Node = "" +var Turn = 0 + +var Location_X = "" +var Location_Y = "" +var turn_indicator: ColorRect +var p1String: RichTextLabel +var p2String: RichTextLabel +var p1Points = 0 +var p2Points = 0 +var pos = Vector2(25, 25) +var Areas: PackedStringArray +# this is seperate the Areas for special circumstances, like castling. +var Special_Area: PackedStringArray +var light_style = StyleBoxFlat.new() +var dark_style = StyleBoxFlat.new() +var highlight_style = StyleBoxFlat.new() + +var deck_manager: DeckManager +var card_display: CardDisplay +var has_moved = false # Track if piece has moved this turn +var currently_moving_piece = null + + +func _ready(): + deck_manager = DeckManager.new() + card_display = CardDisplay.new() + add_child(deck_manager) + add_child(card_display) + card_display.update_hand(deck_manager.hand) + deck_manager.connect("hand_updated", func(hand): card_display.update_hand(hand)) + light_style.bg_color = Color(0.8, 0.8, 0.8, 1) + dark_style.bg_color = Color(0.2, 0.2, 0.2, 1) + highlight_style.bg_color = Color(0, 0.3, 0, 1) + # Get reference to the turn indicator + turn_indicator = $TurnIndicator + p1String = $Player1Points + p2String = $Player2Points + p1String.text = "0" + p2String.text = "0" + # Set initial color for white's turn + update_turn_indicator() + +func update_turn_indicator(): + if Turn == 0: # White's turn + turn_indicator.color = Color(1, 1, 1, 1) # White + else: # Black's turn + turn_indicator.color = Color(0, 0, 0, 1) # Black + + + +func reset_highlights(): + var Flow = get_node("Flow") + for button in Flow.get_children(): + var coord = button.name.split("-") + var isWhiteSquare = (int(coord[0]) + int(coord[1])) % 2 == 0 + if isWhiteSquare: + button.add_theme_stylebox_override("normal", light_style) + else: + button.add_theme_stylebox_override("normal", dark_style) + +func _on_flow_send_location(location: String): + if Selected_Node != "" && Selected_Node == location: + reset_highlights() + Selected_Node = "" + return + # variables for later + var number = 0 + Location_X = "" + var node = get_node("Flow/" + location) + # This is to try and grab the X and Y coordinates from the board + while location.substr(number, 1) != "-": + Location_X += location.substr(number, 1) + number += 1 + Location_Y = location.substr(number + 1) + + # Now... we need to figure out how to select the pieces. If there is a valid move, do stuff. + # If we re-select, just go to that other piece + if Selected_Node == "" && node.get_child_count() != 0 && node.get_child(0).Item_Color == Turn: + Selected_Node = location + Get_Moveable_Areas() + elif Selected_Node != "" && node.get_child_count() != 0 && node.get_child(0).Item_Color == Turn && node.get_child(0).name == "Rook": + # Castling + for i in Areas: + if i == node.name: + var king = get_node("Flow/" + Selected_Node).get_child(0) + var rook = node.get_child(0) + # Using a seperate array because Areas wouldn't be really consistant... + king.reparent(get_node("Flow/" + Special_Area[1])) + rook.reparent(get_node("Flow/" + Special_Area[0])) + king.position = pos + rook.position = pos + # We have to get the parent because it will break lmao. + Update_Game(king.get_parent()) + # En Passant + elif Selected_Node != "" && node.get_child_count() != 0 && node.get_child(0).Item_Color != Turn && node.get_child(0).name == "Pawn" && Special_Area.size() != 0 && Special_Area[0] == node.name && node.get_child(0).get("En_Passant") == true: + for i in Special_Area: + if i == node.name: + var pawn = get_node("Flow/" + Selected_Node).get_child(0) + node.get_child(0).free() + pawn.reparent(get_node("Flow/" + Special_Area[1])) + pawn.position = pos + Update_Game(pawn.get_parent()) + elif Selected_Node != "" && node.get_child_count() != 0 && node.get_child(0).Item_Color == Turn: + # Re-select + Selected_Node = location + Get_Moveable_Areas() + elif Selected_Node != "" && node.get_child_count() != 0 && node.get_child(0).Item_Color != Turn: + # Taking over a piece + for i in Areas: + if i == node.name: + var Piece = get_node("Flow/" + Selected_Node).get_child(0) + var captured_piece = node.get_child(0) + + # Add points to the capturing player + if Turn == 0: # White's turn + p1Points += captured_piece.Points + p1String.text = str(p1Points) + else: # Black's turn + p2Points += captured_piece.Points + p2String.text = str(p2Points) + + # Win conditions + if captured_piece.name == "King": + print("Damn, you win!") + node.get_child(0).free() + Piece.reparent(node) + Piece.position = pos + Update_Game(node) + elif Selected_Node != "" && node.get_child_count() == 0: + # Moving a piece + for i in Areas: + if i == node.name: + var Piece = get_node("Flow/" + Selected_Node).get_child(0) + Piece.reparent(node) + Piece.position = pos + Update_Game(node) + + + +func Update_Game(node): + Selected_Node = "" + if Turn == 0: + Turn = 1 + else: + Turn = 0 + update_turn_indicator() + reset_highlights(); + + deck_manager.update_card_durations() + has_moved = false + currently_moving_piece = null + + var Flow = get_node("Flow") + # get the en-passantable pieces and undo them + var things = Flow.get_children() + for i in things: + if i.get_child_count() != 0 && i.get_child(0).name == "Pawn" && i.get_child(0).Item_Color == Turn && i.get_child(0).En_Passant == true: + i.get_child(0).set("En_Passant", false) + + # Remove the abilities once they are either used or not used + if node.get_child(0).name == "Pawn": + if node.get_child(0).Double_Start == true: + node.get_child(0).En_Passant = true + node.get_child(0).Double_Start = false + if node.get_child(0).name == "King": + node.get_child(0).Castling = false + if node.get_child(0).name == "Rook": + node.get_child(0).Castling = false + +# Below is the movement that is used for the pieces +func Get_Moveable_Areas(): + var Flow = get_node("Flow") + + for button in Flow.get_children(): + var coord = button.name.split("-") + var isWhiteSquare = (int(coord[0]) + int(coord[1])) % 2 == 0 + if isWhiteSquare: + button.add_theme_stylebox_override("normal", light_style) + else: + button.add_theme_stylebox_override("normal", dark_style) + + # Clearing the arrays + Areas.clear() + Special_Area.clear() + var Piece = get_node("Flow/" + Selected_Node).get_child(0) + # For the selected piece that we have, we can get the movement that we need here. + + var moves = Piece.get_valid_moves(Flow, Selected_Node) + + Areas = moves.regular_moves + Special_Area = moves.special_moves + # Highlight valid moves + + for move in Areas: + var button = Flow.get_node(move) + var isWhiteSquare = (int(move.split("-")[0]) + int(move.split("-")[1])) % 2 == 0 + var baseStyle = dark_style + if isWhiteSquare: + baseStyle = light_style + var combinedStyle = StyleBoxFlat.new() + combinedStyle.bg_color = baseStyle.bg_color + highlight_style.bg_color + button.add_theme_stylebox_override("normal", combinedStyle) +# One function that shortens everything. Its also a pretty good way to see if we went off the board or not. +func Is_Null(Location): + if get_node_or_null("Flow/" + Location) == null: + return true + else: + return false diff --git a/Generator.gd b/Generator.gd new file mode 100644 index 0000000..62d53ac --- /dev/null +++ b/Generator.gd @@ -0,0 +1,106 @@ +extends FlowContainer + +@export var Board_X_Size = 8 +@export var Board_Y_Size = 8 + +@export var Tile_X_Size: int = 50 +@export var Tile_Y_Size: int = 50 + +signal send_location + +func _ready(): + # stop negative numbers from happening + if Board_X_Size < 0 || Board_Y_Size < 0: + return + var Number_X = 0 + var Number_Y = 0 + var is_white = true + var light_style = StyleBoxFlat.new() + light_style.bg_color = Color(0.8, 0.8, 0.8, 1) + + var dark_style = StyleBoxFlat.new() + dark_style.bg_color = Color(0.2, 0.2, 0.2, 1) + # Set up the board + while Number_Y != Board_Y_Size: + self.size.y += Tile_Y_Size + 5 + self.size.x += Tile_X_Size + 5 + while Number_X != Board_X_Size: + var temp = Button.new() + temp.set_custom_minimum_size(Vector2(Tile_X_Size, Tile_Y_Size)) + if is_white: + temp.add_theme_stylebox_override("normal", light_style) + else: + temp.add_theme_stylebox_override("normal", dark_style) + + is_white = !is_white + temp.connect("pressed", func(): + emit_signal("send_location", temp.name)) + temp.set_name(str(Number_X) + "-" + str(Number_Y)) + add_child(temp) + Number_X += 1 + is_white = !is_white + Number_Y += 1 + Number_X = 0 + Regular_Game() + +func Regular_Game(): + get_node("0-0").add_child(Summon("Rook", 1)) + get_node("1-0").add_child(Summon("Knight", 1)) + get_node("2-0").add_child(Summon("Bishop", 1)) + get_node("3-0").add_child(Summon("Queen", 1)) + get_node("4-0").add_child(Summon("King", 1)) + get_node("5-0").add_child(Summon("Bishop", 1)) + get_node("6-0").add_child(Summon("Knight", 1)) + get_node("7-0").add_child(Summon("Rook", 1)) + + get_node("0-1").add_child(Summon("Pawn", 1)) + get_node("1-1").add_child(Summon("Pawn", 1)) + get_node("2-1").add_child(Summon("Pawn", 1)) + get_node("3-1").add_child(Summon("Pawn", 1)) + get_node("4-1").add_child(Summon("Pawn", 1)) + get_node("5-1").add_child(Summon("Pawn", 1)) + get_node("6-1").add_child(Summon("Pawn", 1)) + get_node("7-1").add_child(Summon("Pawn", 1)) + + get_node("0-7").add_child(Summon("Rook", 0)) + get_node("1-7").add_child(Summon("Knight", 0)) + get_node("2-7").add_child(Summon("Bishop", 0)) + get_node("3-7").add_child(Summon("Queen", 0)) + get_node("4-7").add_child(Summon("King", 0)) + get_node("5-7").add_child(Summon("Bishop", 0)) + get_node("6-7").add_child(Summon("Knight", 0)) + get_node("7-7").add_child(Summon("Rook", 0)) + + get_node("0-6").add_child(Summon("Pawn", 0)) + get_node("1-6").add_child(Summon("Pawn", 0)) + get_node("2-6").add_child(Summon("Pawn", 0)) + get_node("3-6").add_child(Summon("Pawn", 0)) + get_node("4-6").add_child(Summon("Pawn", 0)) + get_node("5-6").add_child(Summon("Pawn", 0)) + get_node("6-6").add_child(Summon("Pawn", 0)) + get_node("7-6").add_child(Summon("Pawn", 0)) + +func Summon(Piece_Name: String, color: int): + var Piece + match Piece_Name: + "Pawn": + Piece = Pawn.new() + Piece.name = "Pawn" + "King": + Piece = King.new() + Piece.name = "King" + "Queen": + Piece = Queen.new() + Piece.name = "Queen" + "Knight": + Piece = Knight.new() + Piece.name = "Knight" + "Rook": + Piece = Rook.new() + Piece.name = "Rook" + "Bishop": + Piece = Bishop.new() + Piece.name = "Bishop" + Piece.Item_Color = color + Piece.position = Vector2(Tile_X_Size / 2, Tile_Y_Size / 2) + return Piece diff --git a/Systems/Card.gd b/Systems/Card.gd new file mode 100644 index 0000000..31d7040 --- /dev/null +++ b/Systems/Card.gd @@ -0,0 +1,58 @@ +extends Resource +class_name Card + +enum Rank {RANK_0, RANK_1, RANK_2, RANK_3} +enum EffectType { + MOVEMENT_MODIFIER, + BOARD_EFFECT, + PIECE_EFFECT, + SPECIAL_ACTION +} + +var card_name: String +var rank: Rank +var description: String +var duration: int = 0 +var attached_piece: Pawn = null +var burned: bool = false +var effect_type: EffectType +var remaining_turns: int = 0 +var unit_whitelist: Array[String] = [] # List of piece types this card can be attached to + +func _init(): + remaining_turns = duration + +func can_attach_to_piece(piece: Pawn) -> bool: + if unit_whitelist.is_empty(): + return true + return unit_whitelist.has(piece.name) + +func apply_effect(target_piece = null, board_flow = null, game_state = null): + if burned || (target_piece && !can_attach_to_piece(target_piece)): + return false + + remaining_turns = duration + attached_piece = target_piece + + match rank: + Rank.RANK_0: burned = true + Rank.RANK_1: burned = true + Rank.RANK_2: pass + Rank.RANK_3: pass + + return modify_moves() + +func update_duration(): + if remaining_turns > 0: + remaining_turns -= 1 + if remaining_turns <= 0: + remove_effect() + + +func modify_moves() -> Dictionary: + return {} + + +func remove_effect(): + if attached_piece: + pass diff --git a/Systems/CardDisplay.gd b/Systems/CardDisplay.gd new file mode 100644 index 0000000..1700a85 --- /dev/null +++ b/Systems/CardDisplay.gd @@ -0,0 +1,50 @@ +extends Control +class_name CardDisplay + +var card_displays = [] +const CARD_WIDTH = 100 +const CARD_HEIGHT = 150 +const CARD_MARGIN = 10 +var container: HBoxContainer + +func _ready(): + container = HBoxContainer.new() + container.name = "CardContainer" + container.set_position(Vector2(10, 500)) + add_child(container) + +func update_hand(hand: Array): + clear_cards() + for card in hand: + add_card_display(card) + +func add_card_display(card: Card): + var card_panel = PanelContainer.new() + card_panel.custom_minimum_size = Vector2(CARD_WIDTH, CARD_HEIGHT) + + var vbox = VBoxContainer.new() + card_panel.add_child(vbox) + + var name_label = Label.new() + name_label.text = card.card_name + name_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER + vbox.add_child(name_label) + + var rank_label = Label.new() + rank_label.text = "Rank " + str(card.rank) + rank_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER + vbox.add_child(rank_label) + + var desc_label = Label.new() + desc_label.text = card.description + desc_label.autowrap_mode = TextServer.AUTOWRAP_WORD + desc_label.custom_minimum_size = Vector2(CARD_WIDTH - 10, 0) + vbox.add_child(desc_label) + + card_displays.append(card_panel) + container.add_child(card_panel) + +func clear_cards(): + for display in card_displays: + display.queue_free() + card_displays.clear() diff --git a/Systems/Cards/Doubletime.gd b/Systems/Cards/Doubletime.gd new file mode 100644 index 0000000..d348c4d --- /dev/null +++ b/Systems/Cards/Doubletime.gd @@ -0,0 +1,22 @@ +class DoubleTimeCard extends Card: + func _init(): + super._init() + card_name = "Double Time" + rank = Rank.RANK_2 + effect_type = EffectType.MOVEMENT_MODIFIER + description = "Piece can move twice in one turn" + duration = 2 # Lasts for 2 turns + + func modify_moves() -> Dictionary: + return { + "extra_moves": 1, + "move_multiplier": 1 + } + + func apply_effect(target_piece = null, board_flow = null, game_state = null): + if !super.apply_effect(target_piece, board_flow, game_state): + return false + + # Logic to allow second move would be implemented in Game.gd + attached_piece = target_piece + return true diff --git a/Systems/Cards/Drunkdriving.gd b/Systems/Cards/Drunkdriving.gd new file mode 100644 index 0000000..d762b3c --- /dev/null +++ b/Systems/Cards/Drunkdriving.gd @@ -0,0 +1,19 @@ +class DrunkDrivingCard extends Card: + func _init(): + super._init() + card_name = "Drunk Driving" + rank = Rank.RANK_1 + effect_type = EffectType.SPECIAL_ACTION + description = "Force Rook to move to opposite end" + unit_whitelist = ["Rook"] # Can only be attached to Rooks + + func apply_effect(target_piece = null, board_flow = null, game_state = null): + if !super.apply_effect(target_piece, board_flow, game_state): + return false + + if target_piece: + var current_pos = target_piece.get_parent().name.split("-") + var target_x = current_pos[0] + var target_y = "0" if target_piece.Item_Color == 0 else "7" + return [target_x + "-" + target_y] + return false diff --git a/Systems/Cards/Supernova.gd b/Systems/Cards/Supernova.gd new file mode 100644 index 0000000..daede16 --- /dev/null +++ b/Systems/Cards/Supernova.gd @@ -0,0 +1,20 @@ +class SupernovaCard extends Card: + func _init(): + super._init() + card_name = "Supernova" + rank = Rank.RANK_0 + effect_type = EffectType.PIECE_EFFECT + description = "Remove all abilities from enemy pieces" + unit_whitelist = ["King"] # Can only be used by Kings + + func apply_effect(target_piece = null, board_flow = null, game_state = null): + if !super.apply_effect(target_piece, board_flow, game_state): + return false + + if board_flow: + for cell in board_flow.get_children(): + if cell.get_child_count() > 0: + var piece = cell.get_child(0) + if piece.Item_Color != target_piece.Item_Color: + pass + return true diff --git a/Systems/DeckManager.gd b/Systems/DeckManager.gd new file mode 100644 index 0000000..b3db90a --- /dev/null +++ b/Systems/DeckManager.gd @@ -0,0 +1,106 @@ +extends Node +class_name DeckManager + +var deck: Array = [] +var hand: Array = [] +var discard: Array = [] +var attached_cards: Dictionary = {} # piece_id: card +var hand_size: int = 5 + +# Card costs for shop +const CARD_BASE_COSTS = { + Card.Rank.RANK_0: 100, + Card.Rank.RANK_1: 75, + Card.Rank.RANK_2: 50, + Card.Rank.RANK_3: 25 +} + +func _init(): + initialize_starting_deck() + +func initialize_starting_deck(): + # Add basic Rank 3 and 4 cards as per design doc + for i in range(10): + deck.append(Card.new()) # Basic movement cards + shuffle_deck() + draw_starting_hand() + +func shuffle_deck(): + deck.shuffle() + +func draw_starting_hand(): + for i in range(min(hand_size, deck.size())): + draw_card() + +func draw_card(): + if deck.is_empty() && !discard.is_empty(): + deck = discard.duplicate() + discard.clear() + shuffle_deck() + + if !deck.is_empty() && hand.size() < hand_size: + hand.append(deck.pop_back()) + + +signal hand_updated + + + +func play_card(card: Card, target_piece: Pawn, board_flow = null, game_state = null): + if !hand.has(card): + return false + emit_signal("hand_updated", hand) + + if card.apply_effect(target_piece, board_flow, game_state): + hand.erase(card) + + match card.rank: + Card.Rank.RANK_0: + # Burned permanently + pass + Card.Rank.RANK_1: + # Burned until next match + pass + Card.Rank.RANK_2: + discard.append(card) + Card.Rank.RANK_3: + deck.append(card) + shuffle_deck() + + if card.duration > 0: + attached_cards[target_piece.get_instance_id()] = card + + return true + return false + +func update_card_durations(): + var expired_cards = [] + for piece_id in attached_cards: + var card = attached_cards[piece_id] + card.update_duration() + if card.remaining_turns <= 0: + expired_cards.append(piece_id) + + for piece_id in expired_cards: + attached_cards.erase(piece_id) + +# Shop functionality +func get_shop_cards(num_cards: int = 3) -> Array: + var shop_cards = [] + # Generate random shop selection + #for i in range(num_cards): + #var card = generate_random_card() + #shop_cards.append({ + #"card": card, + #"cost": calculate_card_cost(card) + #}) + return shop_cards + +func calculate_card_cost(card: Card) -> int: + var base_cost = CARD_BASE_COSTS[card.rank] + # Add modifiers based on card effects + return base_cost + +func upgrade_card(card: Card) -> bool: + # Implement card upgrading logic + return false diff --git a/addons/Chess/Chess.gd b/addons/Chess/Chess.gd new file mode 100644 index 0000000..75dbadf --- /dev/null +++ b/addons/Chess/Chess.gd @@ -0,0 +1,22 @@ +@tool +extends EditorPlugin + + +func _enter_tree(): + # Initialization of the plugin goes here. + add_custom_type("Pawn", "Sprite2D", preload("res://addons/Chess/Scripts/Pawn.gd"), preload("res://addons/Chess/Textures/WPawn.svg")) + add_custom_type("King", "Sprite2D", preload("res://addons/Chess/Scripts/King.gd"), preload("res://addons/Chess/Textures/WKing.svg")) + add_custom_type("Bishop", "Sprite2D", preload("res://addons/Chess/Scripts/Bishop.gd"), preload("res://addons/Chess/Textures/WBishop.svg")) + add_custom_type("Knight", "Sprite2D", preload("res://addons/Chess/Scripts/Knight.gd"), preload("res://addons/Chess/Textures/WKnight.svg")) + add_custom_type("Queen", "Sprite2D", preload("res://addons/Chess/Scripts/Queen.gd"), preload("res://addons/Chess/Textures/WQueen.svg")) + add_custom_type("Rook", "Sprite2D", preload("res://addons/Chess/Scripts/Rook.gd"), preload("res://addons/Chess/Textures/WRook.svg")) + + +func _exit_tree(): + # Clean-up of the plugin goes here. + remove_custom_type("Pawn") + remove_custom_type("King") + remove_custom_type("Bishop") + remove_custom_type("Knight") + remove_custom_type("Queen") + remove_custom_type("Rook") diff --git a/addons/Chess/Scripts/Bishop.gd b/addons/Chess/Scripts/Bishop.gd new file mode 100644 index 0000000..5140081 --- /dev/null +++ b/addons/Chess/Scripts/Bishop.gd @@ -0,0 +1,49 @@ +@tool +extends Pawn +class_name Bishop + +func _ready(): + self.texture = load("res://addons/Chess/Textures/WBishop.svg") + Points = 3 + +func _process(_delta): + if Item_Color != Temp_Color: + Temp_Color = Item_Color + if Item_Color == 0: + self.texture = load("res://addons/Chess/Textures/WBishop.svg") + elif Item_Color == 1: + self.texture = load("res://addons/Chess/Textures/BBishop.svg") + + +func get_valid_moves(board_flow, current_location: String) -> Dictionary: + var moves = { + "regular_moves": [], + "special_moves": [] + } + + var loc = current_location.split("-") + var x = int(loc[0]) + var y = int(loc[1]) + + # Bishop moves diagonally + var diagonal_dirs = [[1,1], [1,-1], [-1,1], [-1,-1]] + for dir in diagonal_dirs: + var curr_x = x + var curr_y = y + while true: + curr_x += dir[0] + curr_y += dir[1] + var new_loc = str(curr_x) + "-" + str(curr_y) + + if !is_valid_cell(board_flow, new_loc): + break + + if can_move_to_cell(board_flow, new_loc): + moves.regular_moves.append(new_loc) + elif can_move_to_cell(board_flow, new_loc, true): + moves.regular_moves.append(new_loc) + break + else: + break + + return moves diff --git a/addons/Chess/Scripts/King.gd b/addons/Chess/Scripts/King.gd new file mode 100644 index 0000000..99faf50 --- /dev/null +++ b/addons/Chess/Scripts/King.gd @@ -0,0 +1,94 @@ +@tool +extends Pawn +class_name King + +var Castling = true + +func _ready(): + self.texture = load("res://addons/Chess/Textures/WKing.svg") + Points = 10 + +func _process(_delta): + if Item_Color != Temp_Color: + Temp_Color = Item_Color + if Item_Color == 0: + self.texture = load("res://addons/Chess/Textures/WKing.svg") + elif Item_Color == 1: + self.texture = load("res://addons/Chess/Textures/BKing.svg") + +# King.gd +func get_valid_moves(board_flow, current_location: String) -> Dictionary: + var moves = { + "regular_moves": [], + "special_moves": [] + } + + var loc = current_location.split("-") + var x = int(loc[0]) + var y = int(loc[1]) + + # Regular king moves (unchanged) + var king_dirs = [[0,1], [0,-1], [1,0], [-1,0], [1,1], [1,-1], [-1,1], [-1,-1]] + for dir in king_dirs: + var new_loc = str(x + dir[0]) + "-" + str(y + dir[1]) + if is_valid_cell(board_flow, new_loc): + if can_move_to_cell(board_flow, new_loc) || can_move_to_cell(board_flow, new_loc, true): + moves.regular_moves.append(new_loc) + + # Castling logic + if Castling: + # Kingside castling (right side) + if check_kingside_castle(board_flow, x, y): + # Add rook's current position to regular moves + moves.regular_moves.append(str(x + 3) + "-" + str(y)) + # Add king and rook destinations to special moves as individual items + moves.special_moves.append(str(x + 1) + "-" + str(y)) # Rook's destination + moves.special_moves.append(str(x + 2) + "-" + str(y)) # King's destination + + # Queenside castling (left side) + if check_queenside_castle(board_flow, x, y): + # Add rook's current position to regular moves + moves.regular_moves.append(str(x - 4) + "-" + str(y)) + # Add king and rook destinations to special moves as individual items + moves.special_moves.append(str(x - 1) + "-" + str(y)) # Rook's destination + moves.special_moves.append(str(x - 2) + "-" + str(y)) # King's destination + + return moves + +func check_kingside_castle(board_flow, x: int, y: int) -> bool: + # Check if path is clear + for i in range(1, 3): + var check_pos = str(x + i) + "-" + str(y) + if !is_valid_cell(board_flow, check_pos) || !can_move_to_cell(board_flow, check_pos): + return false + + # Check if rook is in position and hasn't moved + var rook_pos = str(x + 3) + "-" + str(y) + if !is_valid_cell(board_flow, rook_pos): + return false + + var rook_node = board_flow.get_node(rook_pos) + if rook_node.get_child_count() != 1: + return false + + var rook = rook_node.get_child(0) + return rook.name == "Rook" && rook.Castling && rook.Item_Color == self.Item_Color + +func check_queenside_castle(board_flow, x: int, y: int) -> bool: + # Check if path is clear + for i in range(1, 4): + var check_pos = str(x - i) + "-" + str(y) + if !is_valid_cell(board_flow, check_pos) || !can_move_to_cell(board_flow, check_pos): + return false + + # Check if rook is in position and hasn't moved + var rook_pos = str(x - 4) + "-" + str(y) + if !is_valid_cell(board_flow, rook_pos): + return false + + var rook_node = board_flow.get_node(rook_pos) + if rook_node.get_child_count() != 1: + return false + + var rook = rook_node.get_child(0) + return rook.name == "Rook" && rook.Castling && rook.Item_Color == self.Item_Color diff --git a/addons/Chess/Scripts/Knight.gd b/addons/Chess/Scripts/Knight.gd new file mode 100644 index 0000000..2ba0bc7 --- /dev/null +++ b/addons/Chess/Scripts/Knight.gd @@ -0,0 +1,40 @@ +@tool +extends Pawn +class_name Knight + +func _ready(): + self.texture = load("res://addons/Chess/Textures/WKnight.svg") + Points = 3 + +func _process(_delta): + if Item_Color != Temp_Color: + Temp_Color = Item_Color + if Item_Color == 0: + self.texture = load("res://addons/Chess/Textures/WKnight.svg") + elif Item_Color == 1: + self.texture = load("res://addons/Chess/Textures/BKnight.svg") +func get_valid_moves(board_flow, current_location: String) -> Dictionary: + var moves = { + "regular_moves": [], + "special_moves": [] + } + + var loc = current_location.split("-") + var x = int(loc[0]) + var y = int(loc[1]) + + # All possible L-shaped moves + var knight_moves = [ + [-2, -1], [-2, 1], + [-1, -2], [-1, 2], + [1, -2], [1, 2], + [2, -1], [2, 1] + ] + + for move in knight_moves: + var new_loc = str(x + move[0]) + "-" + str(y + move[1]) + if is_valid_cell(board_flow, new_loc): + if can_move_to_cell(board_flow, new_loc) || can_move_to_cell(board_flow, new_loc, true): + moves.regular_moves.append(new_loc) + + return moves diff --git a/addons/Chess/Scripts/Pawn.gd b/addons/Chess/Scripts/Pawn.gd new file mode 100644 index 0000000..36d69ea --- /dev/null +++ b/addons/Chess/Scripts/Pawn.gd @@ -0,0 +1,82 @@ +@tool +extends Sprite2D +class_name Pawn + +@export var Current_X_Position = 0 +@export var Current_Y_Position = 0 + +# Item_Color = 0; White +# Item_Color = 1; Black +@export var Item_Color = 0 + +@export var Points = 1 + +var Temp_Color = 0 +var Double_Start = true +var En_Passant = false + +func _ready(): + self.texture = load("res://addons/Chess/Textures/WPawn.svg") + +func _process(_delta): + if Item_Color != Temp_Color: + Temp_Color = Item_Color + if Item_Color == 0: + self.texture = load("res://addons/Chess/Textures/WPawn.svg") + elif Item_Color == 1: + self.texture = load("res://addons/Chess/Textures/BPawn.svg") + + +# Movement interface method that all pieces will implement +# In Pawn.gd +func get_valid_moves(board_flow, current_location: String) -> Dictionary: + var moves = { + "regular_moves": [], + "special_moves": [] + } + + var loc = current_location.split("-") + var x = int(loc[0]) + var y = int(loc[1]) + + # Movement direction based on color + var direction = -1 if Item_Color == 0 else 1 + + # Forward movement + var forward = str(x) + "-" + str(y + direction) + if is_valid_cell(board_flow, forward) && can_move_to_cell(board_flow, forward): + moves.regular_moves.append(forward) + + # Double move on first turn + var double_forward = str(x) + "-" + str(y + (direction * 2)) + if Double_Start && is_valid_cell(board_flow, double_forward) && can_move_to_cell(board_flow, double_forward): + moves.regular_moves.append(double_forward) + + # Diagonal captures + for dx in [-1, 1]: + var capture = str(x + dx) + "-" + str(y + direction) + if is_valid_cell(board_flow, capture) && can_move_to_cell(board_flow, capture, true): + moves.regular_moves.append(capture) + + # En Passant + var adjacent = str(x + dx) + "-" + str(y) + if is_valid_cell(board_flow, adjacent) && is_valid_cell(board_flow, capture): + var adjacent_cell = board_flow.get_node(adjacent) + if adjacent_cell.get_child_count() == 1: + var adjacent_piece = adjacent_cell.get_child(0) + if adjacent_piece.name == "Pawn" && adjacent_piece.En_Passant && adjacent_piece.Item_Color != self.Item_Color: + moves.special_moves.append([adjacent, capture]) + + return moves + +# Helper method for all pieces +func is_valid_cell(board_flow, location: String) -> bool: + var node = board_flow.get_node_or_null(location) + return node != null + +# Helper for checking if cell is empty or contains enemy +func can_move_to_cell(board_flow, location: String, is_capture: bool = false) -> bool: + var node = board_flow.get_node(location) + if is_capture: + return node.get_child_count() == 1 && node.get_child(0).Item_Color != self.Item_Color + return node.get_child_count() == 0 diff --git a/addons/Chess/Scripts/Queen.gd b/addons/Chess/Scripts/Queen.gd new file mode 100644 index 0000000..67ab4b9 --- /dev/null +++ b/addons/Chess/Scripts/Queen.gd @@ -0,0 +1,69 @@ +@tool +extends Pawn +class_name Queen + +func _ready(): + self.texture = load("res://addons/Chess/Textures/WQueen.svg") + Points = 9 +func _process(_delta): + if Item_Color != Temp_Color: + Temp_Color = Item_Color + if Item_Color == 0: + self.texture = load("res://addons/Chess/Textures/WQueen.svg") + elif Item_Color == 1: + self.texture = load("res://addons/Chess/Textures/BQueen.svg") + +func get_valid_moves(board_flow, current_location: String) -> Dictionary: + var moves = { + "regular_moves": [], + "special_moves": [] + } + + var loc = current_location.split("-") + var x = int(loc[0]) + var y = int(loc[1]) + + # Queen combines rook (straight) and bishop (diagonal) movements + # Straight movements + var straight_dirs = [[0,1], [0,-1], [1,0], [-1,0]] + for dir in straight_dirs: + var curr_x = x + var curr_y = y + while true: + curr_x += dir[0] + curr_y += dir[1] + var new_loc = str(curr_x) + "-" + str(curr_y) + + if !is_valid_cell(board_flow, new_loc): + break + + if can_move_to_cell(board_flow, new_loc): + moves.regular_moves.append(new_loc) + elif can_move_to_cell(board_flow, new_loc, true): + moves.regular_moves.append(new_loc) + break + else: + break + + # Diagonal movements + var diagonal_dirs = [[1,1], [1,-1], [-1,1], [-1,-1]] + for dir in diagonal_dirs: + var curr_x = x + var curr_y = y + while true: + curr_x += dir[0] + curr_y += dir[1] + var new_loc = str(curr_x) + "-" + str(curr_y) + + if !is_valid_cell(board_flow, new_loc): + break + + if can_move_to_cell(board_flow, new_loc): + moves.regular_moves.append(new_loc) + elif can_move_to_cell(board_flow, new_loc, true): + moves.regular_moves.append(new_loc) + break + else: + break + + return moves diff --git a/addons/Chess/Scripts/Rook.gd b/addons/Chess/Scripts/Rook.gd new file mode 100644 index 0000000..3de7b49 --- /dev/null +++ b/addons/Chess/Scripts/Rook.gd @@ -0,0 +1,60 @@ +@tool +extends Pawn +class_name Rook + +var Castling = true + +func _ready(): + self.texture = load("res://addons/Chess/Textures/WRook.svg") + Points = 5 + +func _process(_delta): + if Item_Color != Temp_Color: + Temp_Color = Item_Color + if Item_Color == 0: + self.texture = load("res://addons/Chess/Textures/WRook.svg") + elif Item_Color == 1: + self.texture = load("res://addons/Chess/Textures/BRook.svg") + +func get_valid_moves(board_flow, current_location: String) -> Dictionary: + var moves = { + "regular_moves": [], + "special_moves": [] + } + + var loc = current_location.split("-") + var x = int(loc[0]) + var y = int(loc[1]) + + # Check all four directions + var directions = [[0,1], [0,-1], [1,0], [-1,0]] + + for dir in directions: + var curr_x = x + var curr_y = y + while true: + curr_x += dir[0] + curr_y += dir[1] + var new_loc = str(curr_x) + "-" + str(curr_y) + if !is_valid_cell(board_flow, new_loc): + break + if can_move_to_cell(board_flow, new_loc): + moves.regular_moves.append(new_loc) + elif can_move_to_cell(board_flow, new_loc, true): + moves.regular_moves.append(new_loc) + break + else: + break + + if Castling: + # Check if there's a king that can castle + for direction in [-4, 3]: # Check both sides for king + var king_pos = str(x + direction) + "-" + str(y) + if is_valid_cell(board_flow, king_pos): + var king_node = board_flow.get_node(king_pos) + if king_node.get_child_count() == 1: + var piece = king_node.get_child(0) + if piece.name == "King" && piece.Castling && piece.Item_Color == self.Item_Color: + moves.special_moves.append([king_pos, current_location]) + + return moves diff --git a/addons/Chess/Textures/BBishop.svg b/addons/Chess/Textures/BBishop.svg new file mode 100644 index 0000000..e88c406 --- /dev/null +++ b/addons/Chess/Textures/BBishop.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/addons/Chess/Textures/BBishop.svg.import b/addons/Chess/Textures/BBishop.svg.import new file mode 100644 index 0000000..deadc2f --- /dev/null +++ b/addons/Chess/Textures/BBishop.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ca8t2shoassp2" +path="res://.godot/imported/BBishop.svg-caa7e8161cebaa9725ca98da7728dcf3.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/Chess/Textures/BBishop.svg" +dest_files=["res://.godot/imported/BBishop.svg-caa7e8161cebaa9725ca98da7728dcf3.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/addons/Chess/Textures/BKing.svg b/addons/Chess/Textures/BKing.svg new file mode 100644 index 0000000..ba2ac9f --- /dev/null +++ b/addons/Chess/Textures/BKing.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/addons/Chess/Textures/BKing.svg.import b/addons/Chess/Textures/BKing.svg.import new file mode 100644 index 0000000..3443e51 --- /dev/null +++ b/addons/Chess/Textures/BKing.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b8e8353pyae4l" +path="res://.godot/imported/BKing.svg-5f2dae3f9e9fd99c551e2bbdcedcbe5f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/Chess/Textures/BKing.svg" +dest_files=["res://.godot/imported/BKing.svg-5f2dae3f9e9fd99c551e2bbdcedcbe5f.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/addons/Chess/Textures/BKnight.svg b/addons/Chess/Textures/BKnight.svg new file mode 100644 index 0000000..04541a8 --- /dev/null +++ b/addons/Chess/Textures/BKnight.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + diff --git a/addons/Chess/Textures/BKnight.svg.import b/addons/Chess/Textures/BKnight.svg.import new file mode 100644 index 0000000..140966d --- /dev/null +++ b/addons/Chess/Textures/BKnight.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bjneg3fh7mu2e" +path="res://.godot/imported/BKnight.svg-7f401d8bdc16da86b2c2004013a9bd52.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/Chess/Textures/BKnight.svg" +dest_files=["res://.godot/imported/BKnight.svg-7f401d8bdc16da86b2c2004013a9bd52.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/addons/Chess/Textures/BPawn.svg b/addons/Chess/Textures/BPawn.svg new file mode 100644 index 0000000..b534de8 --- /dev/null +++ b/addons/Chess/Textures/BPawn.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/addons/Chess/Textures/BPawn.svg.import b/addons/Chess/Textures/BPawn.svg.import new file mode 100644 index 0000000..124fb87 --- /dev/null +++ b/addons/Chess/Textures/BPawn.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://1sql4pmy32c8" +path="res://.godot/imported/BPawn.svg-69542c0e9157623a0a057f4d726baaa4.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/Chess/Textures/BPawn.svg" +dest_files=["res://.godot/imported/BPawn.svg-69542c0e9157623a0a057f4d726baaa4.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/addons/Chess/Textures/BQueen.svg b/addons/Chess/Textures/BQueen.svg new file mode 100644 index 0000000..e557734 --- /dev/null +++ b/addons/Chess/Textures/BQueen.svg @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/addons/Chess/Textures/BQueen.svg.import b/addons/Chess/Textures/BQueen.svg.import new file mode 100644 index 0000000..1c909ad --- /dev/null +++ b/addons/Chess/Textures/BQueen.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cla2mshxp0elx" +path="res://.godot/imported/BQueen.svg-43c2121313f7ae80039aa817f5e6e5ae.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/Chess/Textures/BQueen.svg" +dest_files=["res://.godot/imported/BQueen.svg-43c2121313f7ae80039aa817f5e6e5ae.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/addons/Chess/Textures/BRook.svg b/addons/Chess/Textures/BRook.svg new file mode 100644 index 0000000..4eec43c --- /dev/null +++ b/addons/Chess/Textures/BRook.svg @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + diff --git a/addons/Chess/Textures/BRook.svg.import b/addons/Chess/Textures/BRook.svg.import new file mode 100644 index 0000000..5ff7ce5 --- /dev/null +++ b/addons/Chess/Textures/BRook.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://2an2oqh0ks1y" +path="res://.godot/imported/BRook.svg-fcf0e0216572b051e0d829eef86c69c8.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/Chess/Textures/BRook.svg" +dest_files=["res://.godot/imported/BRook.svg-fcf0e0216572b051e0d829eef86c69c8.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/addons/Chess/Textures/WBishop.svg b/addons/Chess/Textures/WBishop.svg new file mode 100644 index 0000000..3a8eaa2 --- /dev/null +++ b/addons/Chess/Textures/WBishop.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/addons/Chess/Textures/WBishop.svg.import b/addons/Chess/Textures/WBishop.svg.import new file mode 100644 index 0000000..1584ef1 --- /dev/null +++ b/addons/Chess/Textures/WBishop.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bal1cx2x7hk7l" +path="res://.godot/imported/WBishop.svg-8d8d69e7026e6a8ebafe899e6c3db44a.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/Chess/Textures/WBishop.svg" +dest_files=["res://.godot/imported/WBishop.svg-8d8d69e7026e6a8ebafe899e6c3db44a.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/addons/Chess/Textures/WKing.svg b/addons/Chess/Textures/WKing.svg new file mode 100644 index 0000000..632ca1a --- /dev/null +++ b/addons/Chess/Textures/WKing.svg @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/addons/Chess/Textures/WKing.svg.import b/addons/Chess/Textures/WKing.svg.import new file mode 100644 index 0000000..4e635ce --- /dev/null +++ b/addons/Chess/Textures/WKing.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bgeifkewhw83q" +path="res://.godot/imported/WKing.svg-7fc9428910d7accc920c7dcbb55e9e89.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/Chess/Textures/WKing.svg" +dest_files=["res://.godot/imported/WKing.svg-7fc9428910d7accc920c7dcbb55e9e89.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/addons/Chess/Textures/WKnight.svg b/addons/Chess/Textures/WKnight.svg new file mode 100644 index 0000000..a5f31c6 --- /dev/null +++ b/addons/Chess/Textures/WKnight.svg @@ -0,0 +1,19 @@ + + + + + + + + + + diff --git a/addons/Chess/Textures/WKnight.svg.import b/addons/Chess/Textures/WKnight.svg.import new file mode 100644 index 0000000..48b47c8 --- /dev/null +++ b/addons/Chess/Textures/WKnight.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dnp45xyp0eesa" +path="res://.godot/imported/WKnight.svg-511cbd9440386db76ded28b418432666.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/Chess/Textures/WKnight.svg" +dest_files=["res://.godot/imported/WKnight.svg-511cbd9440386db76ded28b418432666.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/addons/Chess/Textures/WPawn.svg b/addons/Chess/Textures/WPawn.svg new file mode 100644 index 0000000..b265fe1 --- /dev/null +++ b/addons/Chess/Textures/WPawn.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/addons/Chess/Textures/WPawn.svg.import b/addons/Chess/Textures/WPawn.svg.import new file mode 100644 index 0000000..31e5741 --- /dev/null +++ b/addons/Chess/Textures/WPawn.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dl5dp47xg34sb" +path="res://.godot/imported/WPawn.svg-d6caa773d0f71f225bae31a4e926de85.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/Chess/Textures/WPawn.svg" +dest_files=["res://.godot/imported/WPawn.svg-d6caa773d0f71f225bae31a4e926de85.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/addons/Chess/Textures/WQueen.svg b/addons/Chess/Textures/WQueen.svg new file mode 100644 index 0000000..8df7c8f --- /dev/null +++ b/addons/Chess/Textures/WQueen.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/addons/Chess/Textures/WQueen.svg.import b/addons/Chess/Textures/WQueen.svg.import new file mode 100644 index 0000000..4e32e08 --- /dev/null +++ b/addons/Chess/Textures/WQueen.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cr1lku07l36wb" +path="res://.godot/imported/WQueen.svg-5b2a2821ab5f933be4cb9be7369ada28.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/Chess/Textures/WQueen.svg" +dest_files=["res://.godot/imported/WQueen.svg-5b2a2821ab5f933be4cb9be7369ada28.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/addons/Chess/Textures/WRook.svg b/addons/Chess/Textures/WRook.svg new file mode 100644 index 0000000..0574ca6 --- /dev/null +++ b/addons/Chess/Textures/WRook.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + diff --git a/addons/Chess/Textures/WRook.svg.import b/addons/Chess/Textures/WRook.svg.import new file mode 100644 index 0000000..766ca77 --- /dev/null +++ b/addons/Chess/Textures/WRook.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://qisaumos7b53" +path="res://.godot/imported/WRook.svg-ded88be9bedc570bb66d27120b68b78a.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/Chess/Textures/WRook.svg" +dest_files=["res://.godot/imported/WRook.svg-ded88be9bedc570bb66d27120b68b78a.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/addons/Chess/plugin.cfg b/addons/Chess/plugin.cfg new file mode 100644 index 0000000..d602997 --- /dev/null +++ b/addons/Chess/plugin.cfg @@ -0,0 +1,7 @@ +[plugin] + +name="Chess" +description="" +author="CatAClock" +version="1.0" +script="Chess.gd" diff --git a/board.tscn b/board.tscn new file mode 100644 index 0000000..bff49b8 --- /dev/null +++ b/board.tscn @@ -0,0 +1,75 @@ +[gd_scene load_steps=3 format=3 uid="uid://d0qyk6v20uief"] + +[ext_resource type="Script" path="res://Generator.gd" id="1_ckrtr"] +[ext_resource type="Script" path="res://Game.gd" id="1_f1l42"] + +[node name="Board" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_f1l42") + +[node name="Flow" type="FlowContainer" parent="."] +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -252.0 +offset_right = -252.0 +grow_horizontal = 2 +script = ExtResource("1_ckrtr") + +[node name="Player1Points" type="RichTextLabel" parent="."] +layout_mode = 1 +anchors_preset = 1 +anchor_left = 1.0 +anchor_right = 1.0 +offset_left = -50.0 +offset_top = 50.0 +offset_bottom = 89.0 +grow_horizontal = 0 + +[node name="Player2Points" type="RichTextLabel" parent="."] +layout_mode = 1 +anchors_preset = 1 +anchor_left = 1.0 +anchor_right = 1.0 +offset_left = -48.0 +offset_top = 100.0 +offset_bottom = 140.0 +grow_horizontal = 0 + +[node name="TurnIndicator" type="ColorRect" parent="."] +custom_minimum_size = Vector2(50, 50) +layout_mode = 1 +anchors_preset = 1 +anchor_left = 1.0 +anchor_right = 1.0 +offset_left = -50.0 +offset_bottom = 50.0 +grow_horizontal = 0 + +[node name="RichTextLabel" type="RichTextLabel" parent="."] +layout_mode = 0 +offset_left = 1062.0 +offset_top = 65.0 +offset_right = 1142.0 +offset_bottom = 104.0 + +[node name="HBoxContainer" type="HBoxContainer" parent="."] +layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = -20.0 +offset_top = -40.0 +offset_right = 20.0 +grow_horizontal = 2 +grow_vertical = 0 + +[connection signal="send_location" from="Flow" to="." method="_on_flow_send_location"] diff --git a/icon.svg b/icon.svg new file mode 100644 index 0000000..adc26df --- /dev/null +++ b/icon.svg @@ -0,0 +1 @@ + diff --git a/icon.svg.import b/icon.svg.import new file mode 100644 index 0000000..73c87a7 --- /dev/null +++ b/icon.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bfk751s2xwsn3" +path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.svg" +dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..aa59888 --- /dev/null +++ b/project.godot @@ -0,0 +1,28 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=5 + +[application] + +config/name="Godot Chess" +run/main_scene="res://board.tscn" +config/features=PackedStringArray("4.3", "Forward Plus") +config/icon="res://icon.svg" + +[editor_plugins] + +enabled=PackedStringArray() + +[filesystem] + +import/blender/enabled=false + +[rendering] + +renderer/rendering_method="gl_compatibility"