From 73857333f872ec5a1d32dbd522d8a7d6f2625fac Mon Sep 17 00:00:00 2001
From: Raúl Benencia <rul@kalgan.cc>
Date: Tue, 31 Mar 2015 15:54:15 -0300
Subject: define game_is_checkmate(Board, Color)

---
 include/game.h |  5 +++++
 lib/game.c     | 11 ++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/include/game.h b/include/game.h
index 61239e7..5ab589b 100644
--- a/include/game.h
+++ b/include/game.h
@@ -8,4 +8,9 @@
  */
 Board game_loop(Board);
 
+/*
+ * Return 1 if the received player is checkmated. Returns 0 otherwise.
+ */
+int game_is_checkmate(Board board, Color color);
+
 #endif
diff --git a/lib/game.c b/lib/game.c
index 6fcc0c5..b3eb677 100644
--- a/lib/game.c
+++ b/lib/game.c
@@ -13,12 +13,19 @@ static Color _toggle_current_player(Color c) {
         return WHITE;
 }
 
+/*
+ * TODO
+ */
+int game_is_checkmate(Board board, Color color) {
+    return 0;
+}
+
 Board game_loop(Board board) {
     Board b = board;
     Color current_player = WHITE;
     Coord orig, dest;
 
-    while (1) {
+    while (!game_is_checkmate(b, current_player)) {
         print_board(b, current_player);
 
         putchar('\n');
@@ -33,4 +40,6 @@ Board game_loop(Board board) {
         b = board_make_move(b, move_init(orig, dest));
         current_player = _toggle_current_player(current_player);
     }
+
+    return 0;
 }
-- 
cgit v1.2.3