25 lines
No EOL
648 B
GDScript
25 lines
No EOL
648 B
GDScript
extends "res://Systems/StateMachine/ChessGameState.gd"
|
|
|
|
func enter(_previous: String, data := {}) -> void:
|
|
print("ENTERING STATE ", Constants.ROUND_END)
|
|
if "endCondition" in data:
|
|
match data["endCondition"]:
|
|
"checkmate":
|
|
handleCheckmate()
|
|
"draw":
|
|
handleDraw()
|
|
|
|
# Reset state for next round
|
|
game.clearSelection();
|
|
game.resetBoard()
|
|
finished.emit(Constants.WHITE_TURN)
|
|
|
|
func handleCheckmate() -> void:
|
|
var winner = "White" if game.turn == 1 else "Black"
|
|
print("Checkmate! " + winner + " wins!")
|
|
|
|
func handleDraw() -> void:
|
|
print("Game ended in draw")
|
|
|
|
|
|
|