Access & Check

This commit is contained in:
CatAClock 2025-06-09 19:29:07 -07:00
parent a59412eb60
commit ec7b2cbd12
2 changed files with 31 additions and 12 deletions

View file

@ -1,16 +1,18 @@
[gd_scene load_steps=10 format=3 uid="uid://d0qyk6v20uief"] [gd_scene load_steps=10 format=3 uid="uid://d0qyk6v20uief"]
[ext_resource type="Script" path="res://generator.gd" id="1_ckrtr"] [ext_resource type="Script" uid="uid://dyqw4lpfqhgmb" path="res://generator.gd" id="1_ckrtr"]
[ext_resource type="Script" path="res://game.gd" id="1_f1l42"] [ext_resource type="Script" uid="uid://dysg515hr11cc" path="res://game.gd" id="1_f1l42"]
[ext_resource type="PackedScene" uid="uid://dl8ctpb4nx5b4" path="res://ChessScenes/pawn.tscn" id="3_871tv"] [ext_resource type="PackedScene" uid="uid://dl8ctpb4nx5b4" path="res://ChessScenes/pawn.tscn" id="3_871tv"]
[ext_resource type="PackedScene" uid="uid://cu208w2aj6qnh" path="res://ChessScenes/bishop.tscn" id="4_f2vpi"] [ext_resource type="PackedScene" uid="uid://cu208w2aj6qnh" path="res://ChessScenes/bishop.tscn" id="4_f2vpi"]
[ext_resource type="PackedScene" uid="uid://cl7imfd1umhvu" path="res://ChessScenes/rook.tscn" id="5_lwy4i"] [ext_resource type="PackedScene" uid="uid://cl7imfd1umhvu" path="res://ChessScenes/rook.tscn" id="5_lwy4i"]
[ext_resource type="PackedScene" uid="uid://bgd6ldfcm8hie" path="res://ChessScenes/knight.tscn" id="6_ta68t"] [ext_resource type="PackedScene" uid="uid://bgd6ldfcm8hie" path="res://ChessScenes/knight.tscn" id="6_ta68t"]
[ext_resource type="PackedScene" uid="uid://1sle88win6dm" path="res://ChessScenes/queen.tscn" id="7_7creb"] [ext_resource type="PackedScene" uid="uid://1sle88win6dm" path="res://ChessScenes/queen.tscn" id="7_7creb"]
[ext_resource type="PackedScene" uid="uid://yqfgmt234xui" path="res://ChessScenes/king.tscn" id="8_vvr6q"] [ext_resource type="PackedScene" uid="uid://yqfgmt234xui" path="res://ChessScenes/king.tscn" id="8_vvr6q"]
[ext_resource type="Script" path="res://game_win.gd" id="9_ww6wk"] [ext_resource type="Script" uid="uid://bombmbttl3o7n" path="res://game_win.gd" id="9_ww6wk"]
[node name="Board" type="Control"] [node name="Board" type="Control"]
accessibility_name = "Root"
accessibility_description = "The node that houses everything."
layout_mode = 3 layout_mode = 3
anchors_preset = 0 anchors_preset = 0
offset_right = 40.0 offset_right = 40.0
@ -19,6 +21,8 @@ script = ExtResource("1_f1l42")
BoardPath = NodePath("Flow") BoardPath = NodePath("Flow")
[node name="Flow" type="FlowContainer" parent="."] [node name="Flow" type="FlowContainer" parent="."]
accessibility_name = "Flow"
accessibility_description = "The game board"
layout_mode = 0 layout_mode = 0
script = ExtResource("1_ckrtr") script = ExtResource("1_ckrtr")
Pawn = ExtResource("3_871tv") Pawn = ExtResource("3_871tv")
@ -29,12 +33,16 @@ Queen = ExtResource("7_7creb")
King = ExtResource("8_vvr6q") King = ExtResource("8_vvr6q")
[node name="GameWin" type="Control" parent="."] [node name="GameWin" type="Control" parent="."]
accessibility_name = "Win"
accessibility_description = "Node that houses a script."
anchors_preset = 0 anchors_preset = 0
offset_right = 40.0 offset_right = 40.0
offset_bottom = 40.0 offset_bottom = 40.0
script = ExtResource("9_ww6wk") script = ExtResource("9_ww6wk")
[node name="Promotion" type="Panel" parent="."] [node name="Promotion" type="Panel" parent="."]
accessibility_name = "Promotion"
accessibility_description = "A panel that houses buttons for promoting."
visible = false visible = false
layout_mode = 0 layout_mode = 0
offset_left = 531.0 offset_left = 531.0
@ -43,6 +51,8 @@ offset_right = 731.0
offset_bottom = 330.0 offset_bottom = 330.0
[node name="Rook" type="Button" parent="Promotion"] [node name="Rook" type="Button" parent="Promotion"]
accessibility_name = "Rook"
accessibility_description = "Promote a pawn to a rook."
layout_mode = 0 layout_mode = 0
offset_left = 8.0 offset_left = 8.0
offset_top = 10.0 offset_top = 10.0
@ -51,6 +61,8 @@ offset_bottom = 41.0
text = "Rook" text = "Rook"
[node name="Bishop" type="Button" parent="Promotion"] [node name="Bishop" type="Button" parent="Promotion"]
accessibility_name = "Bishop"
accessibility_description = "Promote a pawn to a bishop."
layout_mode = 0 layout_mode = 0
offset_left = 68.0 offset_left = 68.0
offset_top = 10.0 offset_top = 10.0
@ -59,6 +71,8 @@ offset_bottom = 41.0
text = "Bishop" text = "Bishop"
[node name="Knight" type="Button" parent="Promotion"] [node name="Knight" type="Button" parent="Promotion"]
accessibility_name = "Knight"
accessibility_description = "Promote a pawn to a knight."
layout_mode = 0 layout_mode = 0
offset_left = 9.0 offset_left = 9.0
offset_top = 50.0 offset_top = 50.0
@ -67,6 +81,8 @@ offset_bottom = 81.0
text = "Knight" text = "Knight"
[node name="Queen" type="Button" parent="Promotion"] [node name="Queen" type="Button" parent="Promotion"]
accessibility_name = "Queen"
accessibility_description = "Promote a pawn to a queen."
layout_mode = 0 layout_mode = 0
offset_left = 79.0 offset_left = 79.0
offset_top = 52.0 offset_top = 52.0

21
game.gd
View file

@ -98,16 +98,14 @@ func _on_flow_send_location(Location: String):
func UpdateGame(cell): func UpdateGame(cell):
SelectedNode = "" SelectedNode = ""
if Turn == 0:
Turn = 1
else:
Turn = 0
# get the en-passantable pieces and undo them
var things = Flow.get_children() var things = Flow.get_children()
# get the en-passantable pieces and undo them
for i in things: for i in things:
if i.get_child_count() != 0 && i.get_child(0).name == "Pawn" && i.get_child(0).PieceColor == Turn && i.get_child(0).EnPassant == true: if i.get_child_count() != 0 && i.get_child(0).name == "Pawn" && i.get_child(0).PieceColor == Turn && i.get_child(0).EnPassant == true:
i.get_child(0).EnPassant = false i.get_child(0).EnPassant = false
# This changes the color to regular white. For kings.
elif i.get_child_count() != 0:
i.get_child(0).modulate = Color(1, 1, 1, 1)
# Remove and add the abilities once they are either used or not used # Remove and add the abilities once they are either used or not used
if cell.get_child(0).name == "Pawn": if cell.get_child(0).name == "Pawn":
@ -122,6 +120,12 @@ func UpdateGame(cell):
# King checking. # King checking.
CheckKing(things) CheckKing(things)
SelectedNode = ""
if Turn == 0:
Turn = 1
else:
Turn = 0
# Below is the movement that is used for the pieces # Below is the movement that is used for the pieces
func GetMovableAreas(): func GetMovableAreas():
@ -387,13 +391,12 @@ func IsNull(Location):
# Checking for a king. # Checking for a king.
func CheckKing(Children): func CheckKing(Children):
for i in Children: for i in Children:
if not IsNull(i.get_path()): if i.get_child_count() != 0:
SelectedNode = str(i.name) SelectedNode = str(i.name)
print(SelectedNode)
GetMovableAreas() GetMovableAreas()
# Helper function # Helper function
func IsKing(Location): func IsKing(Location):
var TheNode = Flow.get_node_or_null(Location) var TheNode = Flow.get_node_or_null(Location)
if TheNode != null && TheNode.get_child_count() != 0 && TheNode.get_child(0).PieceColor != Turn && TheNode.get_child(0).name == "King": if TheNode != null && TheNode.get_child_count() != 0 && TheNode.get_child(0).PieceColor != Turn && TheNode.get_child(0).name == "King":
print("Check!"); TheNode.get_child(0).modulate = Color(1, 0, 0, 1)