src/game.c

changeset 100
685af47592b5
parent 98
9cb41383540f
equal deleted inserted replaced
99:231a79d93c0c 100:685af47592b5
33 #include "colors.h" 33 #include "colors.h"
34 #include "chess/rules.h" 34 #include "chess/rules.h"
35 #include "chess/pgn.h" 35 #include "chess/pgn.h"
36 #include <ncurses.h> 36 #include <ncurses.h>
37 #include <string.h> 37 #include <string.h>
38 #include <inttypes.h>
39 #include <sys/select.h> 38 #include <sys/select.h>
40 #include <stdio.h> 39 #include <stdio.h>
41 #include <errno.h> 40 #include <errno.h>
42 41
43 static const uint8_t boardx = 4, boardy = 10; 42 static const uint8_t boardx = 4, boardy = 10;
45 44
46 static int timecontrol(GameState *gamestate, GameInfo *gameinfo) { 45 static int timecontrol(GameState *gamestate, GameInfo *gameinfo) {
47 if (gameinfo->timecontrol) { 46 if (gameinfo->timecontrol) {
48 uint16_t white = remaining_movetime(gameinfo, gamestate, WHITE); 47 uint16_t white = remaining_movetime(gameinfo, gamestate, WHITE);
49 uint16_t black = remaining_movetime(gameinfo, gamestate, BLACK); 48 uint16_t black = remaining_movetime(gameinfo, gamestate, BLACK);
50 mvprintw(boardy+4, boardx-1, 49 char clkstr[16];
51 "White time: %4" PRIu16 ":%02" PRIu16, 50 bool always_hours = gameinfo->time >= 3600;
52 white / 60, white % 60); 51 print_clk(white, clkstr, always_hours);
53 mvprintw(boardy+5, boardx-1, 52 mvprintw(boardy+4, boardx-1, "White time: %s", clkstr);
54 "Black time: %4" PRIu16 ":%02" PRIu16, 53 print_clk(black, clkstr, always_hours);
55 black / 60, black % 60); 54 mvprintw(boardy+5, boardx-1, "Black time: %s", clkstr);
56 55
57 if (white == 0) { 56 if (white == 0) {
58 move(inputy, 0); 57 move(inputy, 0);
59 printw("Time is over - Black wins!"); 58 printw("Time is over - Black wins!");
60 clrtobot(); 59 clrtobot();

mercurial