1
0
mirror of https://github.com/tiyn/yeschess.git synced 2026-02-22 10:34:47 +01:00

structure: made a src folder and moved all source file into it

This commit is contained in:
TiynGER
2020-12-16 04:24:19 +01:00
parent 6ad11fde2a
commit 0ceb567048
3 changed files with 0 additions and 0 deletions

29
src/game.nim Normal file
View File

@@ -0,0 +1,29 @@
from strutils import parseInt
import rdstdin
import ./chess
proc runGame*(): void =
## Initializes and runs a game of chess.
var game = initGame()
var draw: string
game.echoBoard(game.toMove)
while not game.isCheckmate(game.toMove) and not game.isStalemate(game.toMove):
echo "Make a move"
echo game.toMove
var move = readLine(stdin)
while not game.checkedMove(notationToMove(move, game.toMove)):
move = readLine(stdin)
game.echoBoard(game.toMove)
if (game.isDrawClaimable):
echo "Do you want to claim a draw? (y/N)"
draw = readLine(stdin)
if (draw == "y"):
echo "Draw claimed"
break
if game.isCheckmate(game.toMove):
echo $game.toMove & " was checkmated"
if game.isStalemate(game.toMove):
echo "Stalemate"
runGame()