--- a/src/game.c Wed Aug 29 17:31:36 2018 +0200 +++ b/src/game.c Tue Sep 18 15:02:08 2018 +0200 @@ -71,7 +71,9 @@ return 0; } -static void draw_board(GameState *gamestate, uint8_t perspective) { +static void draw_board(GameState *gamestate, + uint8_t perspective, + _Bool unicode) { char fen[90]; compute_fen(fen, gamestate); mvaddstr(0, 0, fen); @@ -80,11 +82,18 @@ for (uint8_t x = 0 ; x < 8 ; x++) { uint8_t col = gamestate->board[y][x] & COLOR_MASK; uint8_t piece = gamestate->board[y][x] & PIECE_MASK; - char piecec; + unsigned char piecestr[5]; if (piece) { - piecec = piece == PAWN ? 'P' : getpiecechr(piece); + if (unicode) { + unsigned char* uc = getpieceunicode(piece); + strncpy(piecestr, uc, 5); + } else { + piecestr[0] = piece == PAWN ? 'P' : getpiecechr(piece); + piecestr[1] = '\0'; + } } else { - piecec = ' '; + piecestr[0] = ' '; + piecestr[1] = '\0'; } _Bool boardblack = (y&1)==(x&1); @@ -97,9 +106,7 @@ int cy = perspective == WHITE ? boardy-y : boardy-7+y; int cx = perspective == WHITE ? boardx+x*3 : boardx+21-x*3; - mvaddch(cy, cx, ' '); - mvaddch(cy, cx+1, piecec); - mvaddch(cy, cx+2, ' '); + mvprintw(cy, cx, " %s ", piecestr); } } @@ -460,9 +467,11 @@ } } -static void post_game(GameState *gamestate, GameInfo *gameinfo) { +static void post_game(Settings* settings, GameState *gamestate) { + GameInfo *gameinfo = &(settings->gameinfo); + move(0,0); - draw_board(gamestate, WHITE); + draw_board(gamestate, WHITE, settings->unicode); // TODO: network connection is still open here - think about it! @@ -520,13 +529,13 @@ _Bool running; do { clear(); - draw_board(&gamestate, curcol); + draw_board(&gamestate, curcol, settings->unicode); running = !domove_singlemachine(&gamestate, &(settings->gameinfo), curcol); curcol = opponent_color(curcol); } while (running); - post_game(&gamestate, &(settings->gameinfo)); + post_game(settings, &gamestate); } void game_continue(Settings *settings, int opponent, GameState *gamestate) { @@ -541,7 +550,7 @@ _Bool running; do { clear(); - draw_board(gamestate, mycolor); + draw_board(gamestate, mycolor, settings->unicode); if (myturn) { running = !sendmove(gamestate, &(settings->gameinfo), opponent, mycolor); @@ -551,7 +560,7 @@ myturn ^= TRUE; } while (running); - post_game(gamestate, &(settings->gameinfo)); + post_game(settings, gamestate); } void game_start(Settings *settings, int opponent) {