src/game.c

changeset 35
6c64b7a073af
parent 34
c4d4b8a8f902
child 37
bcf624518909
equal deleted inserted replaced
34:c4d4b8a8f902 35:6c64b7a073af
28 */ 28 */
29 29
30 #include "game.h" 30 #include "game.h"
31 #include "network.h" 31 #include "network.h"
32 #include "input.h" 32 #include "input.h"
33 #include "colors.h"
33 #include <ncurses.h> 34 #include <ncurses.h>
34 #include <string.h> 35 #include <string.h>
35 #include <inttypes.h> 36 #include <inttypes.h>
36 #include <sys/select.h> 37 #include <sys/select.h>
37 38
78 piecec = piece == PAWN ? 'P' : getpiecechr(piece); 79 piecec = piece == PAWN ? 'P' : getpiecechr(piece);
79 } else { 80 } else {
80 piecec = ' '; 81 piecec = ' ';
81 } 82 }
82 83
83 attrset((col == WHITE ? A_BOLD : A_DIM) | 84 _Bool boardblack = (y&1)==(x&1);
84 COLOR_PAIR((y&1)==(x&1) ? COL_WB : COL_BW)); 85 attrset((col==WHITE ? A_BOLD : A_DIM)|
86 COLOR_PAIR(col == WHITE ?
87 (boardblack ? COL_WB : COL_WW) :
88 (boardblack ? COL_BB : COL_BW)
89 )
90 );
85 91
86 int cy = gamestate->mycolor == WHITE ? boardy-y : boardy-7+y; 92 int cy = gamestate->mycolor == WHITE ? boardy-y : boardy-7+y;
87 int cx = gamestate->mycolor == WHITE ? boardx+x*3 : boardx+21-x*3; 93 int cx = gamestate->mycolor == WHITE ? boardx+x*3 : boardx+21-x*3;
88 mvaddch(cy, cx, ' '); 94 mvaddch(cy, cx, ' ');
89 mvaddch(cy, cx+1, piecec); 95 mvaddch(cy, cx+1, piecec);
431 gamestate_cleanup(&gamestate); 437 gamestate_cleanup(&gamestate);
432 438
433 mvaddstr(getmaxy(stdscr)-1, 0, 439 mvaddstr(getmaxy(stdscr)-1, 0,
434 "Game has ended. Press any key to leave..."); 440 "Game has ended. Press any key to leave...");
435 refresh(); 441 refresh();
442 cbreak();
443 flushinp();
436 getch(); 444 getch();
437 } 445 }
438 446
439 void game_start(Settings *settings, int opponent) { 447 void game_start(Settings *settings, int opponent) {
440 inputy = getmaxy(stdscr) - 6; 448 inputy = getmaxy(stdscr) - 6;

mercurial