#include <stdio.h>

#include "board.h"
#include "game.h"
#include "input.h"
#include "move.h"
#include "print.h"

static Color _toggle_current_player(Color c) {
    if (c == WHITE)
        return BLACK;
    else
        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 (!game_is_checkmate(b, current_player)) {
        print_board(b, current_player);

        putchar('\n');
        if (current_player == WHITE)
            printf("White's turn. \n");
        else
            printf("Black's turn. \n");

        orig = input_orig_coord();
        dest = input_dest_coord();

        b = board_make_move(b, move_init(orig, dest));
        current_player = _toggle_current_player(current_player);
    }

    return 0;
}