src/game.c

changeset 78
ceb9197b3c6d
parent 69
c8f2c280cff7
equal deleted inserted replaced
77:808a7324b467 78:ceb9197b3c6d
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 "colors.h"
34 #include "chess/rules.h"
35 #include "chess/pgn.h"
34 #include <ncurses.h> 36 #include <ncurses.h>
35 #include <string.h> 37 #include <string.h>
36 #include <inttypes.h> 38 #include <inttypes.h>
37 #include <sys/select.h> 39 #include <sys/select.h>
38 #include <stdio.h> 40 #include <stdio.h>
567 GameState gamestate; 569 GameState gamestate;
568 gamestate_init(&gamestate); 570 gamestate_init(&gamestate);
569 571
570 game_continue(settings, opponent, &gamestate); 572 game_continue(settings, opponent, &gamestate);
571 } 573 }
574
575 void dump_gameinfo(GameInfo *gameinfo) {
576 int serverwhite = gameinfo->servercolor == WHITE;
577 attron(A_UNDERLINE);
578 printw("Game details\n");
579 attroff(A_UNDERLINE);
580 printw(" Server: %s\n Client: %s\n",
581 serverwhite?"White":"Black", serverwhite?"Black":"White"
582 );
583 if (gameinfo->timecontrol) {
584 if (gameinfo->time % 60) {
585 printw(" Time limit: %ds + %ds\n",
586 gameinfo->time, gameinfo->addtime);
587 } else {
588 printw(" Time limit: %dm + %ds\n",
589 gameinfo->time/60, gameinfo->addtime);
590 }
591 } else {
592 printw(" No time limit\n");
593 }
594 refresh();
595 }
596
597 void dump_moveinfo(GameState *gamestate) {
598 int i = 1;
599 for (MoveList *movelist = gamestate->movelist ;
600 movelist ; movelist = movelist->next) {
601 if (++i % 2 == 0) {
602 printw("%d. %s", i/2, movelist->move.string);
603 } else {
604 printw(" %s", movelist->move.string);
605 }
606 if (i % 20) {
607 addch(' ');
608 } else {
609 addch('\n');
610 }
611 }
612 refresh();
613 }

mercurial