This commit is contained in:
CatAClock 2025-06-09 13:38:06 -07:00
parent c7bf4a5334
commit a59412eb60

18
game.gd
View file

@ -120,6 +120,9 @@ func UpdateGame(cell):
if cell.get_child(0).name == "Rook": if cell.get_child(0).name == "Rook":
cell.get_child(0).Castling = false cell.get_child(0).Castling = false
# King checking.
CheckKing(things)
# Below is the movement that is used for the pieces # Below is the movement that is used for the pieces
func GetMovableAreas(): func GetMovableAreas():
# Clearing the arrays # Clearing the arrays
@ -378,4 +381,19 @@ func IsNull(Location):
if Flow.get_node_or_null(Location) == null: if Flow.get_node_or_null(Location) == null:
return true return true
else: else:
IsKing(Location)
return false return false
# Checking for a king.
func CheckKing(Children):
for i in Children:
if not IsNull(i.get_path()):
SelectedNode = str(i.name)
print(SelectedNode)
GetMovableAreas()
# Helper function
func IsKing(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":
print("Check!");