src/main.c

changeset 133
c58ae152733e
parent 132
5762f2b5f87a
equal deleted inserted replaced
132:5762f2b5f87a 133:c58ae152733e
277 277
278 return 0; 278 return 0;
279 } 279 }
280 280
281 static void draw_board(GameState *gamestate, uint8_t perspective) { 281 static void draw_board(GameState *gamestate, uint8_t perspective) {
282 char fen[90]; 282 char fen[FEN_MAX_LENGTH];
283 fen_compute(fen, gamestate); 283 fen_compute(fen, gamestate);
284 mvaddstr(0, 0, fen); 284 mvaddstr(0, 0, fen);
285 285
286 for (uint8_t y = 0 ; y < 8 ; y++) { 286 for (uint8_t y = 0 ; y < 8 ; y++) {
287 for (uint8_t x = 0 ; x < 8 ; x++) { 287 for (uint8_t x = 0 ; x < 8 ; x++) {
904 } 904 }
905 if (!is_game_running(&gamestate)) { 905 if (!is_game_running(&gamestate)) {
906 addstr("Game has ended. Use -S to analyze it.\n"); 906 addstr("Game has ended. Use -S to analyze it.\n");
907 return; 907 return;
908 } 908 }
909 curcol = opponent_color(last_move(&gamestate).piece&COLOR_MASK); 909 curcol = current_color(&gamestate);
910 } else { 910 } else {
911 printw("Can't read PGN file (%s)\n", strerror(errno)); 911 printw("Can't read PGN file (%s)\n", strerror(errno));
912 return; 912 return;
913 } 913 }
914 } 914 }
932 uint8_t mycolor = gamestate->info.servercolor; 932 uint8_t mycolor = gamestate->info.servercolor;
933 if (as_client) { 933 if (as_client) {
934 mycolor = opponent_color(mycolor); 934 mycolor = opponent_color(mycolor);
935 } 935 }
936 936
937 bool myturn = (gamestate->movecount > 0 ? 937 bool myturn = current_color(gamestate) == mycolor;
938 (last_move(gamestate).piece & COLOR_MASK) : BLACK) != mycolor;
939 938
940 bool running; 939 bool running;
941 do { 940 do {
942 clear(); 941 clear();
943 draw_board(gamestate, mycolor); 942 draw_board(gamestate, mycolor);

mercurial