diff --git a/game.gd b/game.gd index 6e4bf98..6e376f1 100644 --- a/game.gd +++ b/game.gd @@ -119,6 +119,9 @@ func UpdateGame(cell): cell.get_child(0).Castling = false if cell.get_child(0).name == "Rook": cell.get_child(0).Castling = false + + # King checking. + CheckKing(things) # Below is the movement that is used for the pieces func GetMovableAreas(): @@ -378,4 +381,19 @@ func IsNull(Location): if Flow.get_node_or_null(Location) == null: return true else: + IsKing(Location) 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!");