467 } |
467 } |
468 } |
468 } |
469 } |
469 } |
470 } |
470 } |
471 |
471 |
472 static void post_game(Settings* settings, GameState *gamestate) { |
472 void game_review(Settings* settings, GameState *gamestate) { |
473 GameInfo *gameinfo = &(settings->gameinfo); |
473 GameInfo *gameinfo = &(settings->gameinfo); |
474 |
474 |
475 move(0,0); |
475 move(0,0); |
476 draw_board(gamestate, WHITE, settings->unicode); |
476 draw_board(gamestate, WHITE, settings->unicode); |
477 |
|
478 // TODO: network connection is still open here - think about it! |
|
479 |
477 |
480 mvaddstr(getmaxy(stdscr)-1, 0, |
478 mvaddstr(getmaxy(stdscr)-1, 0, |
481 "Press 'q' to quit or 's' to save a PGN file..."); |
479 "Press 'q' to quit or 's' to save a PGN file..."); |
482 refresh(); |
480 refresh(); |
483 flushinp(); |
481 flushinp(); |
497 echo(); |
495 echo(); |
498 |
496 |
499 gamestate_cleanup(gamestate); |
497 gamestate_cleanup(gamestate); |
500 } |
498 } |
501 |
499 |
502 void game_start_singlemachine(Settings *settings) { |
500 void game_play_singlemachine(Settings *settings) { |
503 inputy = getmaxy(stdscr) - 6; |
501 inputy = getmaxy(stdscr) - 6; |
504 |
502 |
505 GameState gamestate; |
503 GameState gamestate; |
506 gamestate_init(&gamestate); |
504 gamestate_init(&gamestate); |
507 uint8_t curcol = WHITE; |
505 uint8_t curcol = WHITE; |
535 running = !domove_singlemachine(&gamestate, |
533 running = !domove_singlemachine(&gamestate, |
536 &(settings->gameinfo), curcol); |
534 &(settings->gameinfo), curcol); |
537 curcol = opponent_color(curcol); |
535 curcol = opponent_color(curcol); |
538 } while (running); |
536 } while (running); |
539 |
537 |
540 post_game(settings, &gamestate); |
538 game_review(settings, &gamestate); |
541 } |
539 } |
542 |
540 |
543 void game_continue(Settings *settings, int opponent, GameState *gamestate) { |
541 void game_play(Settings *settings, GameState *gamestate, int opponent) { |
544 inputy = getmaxy(stdscr) - 6; |
542 inputy = getmaxy(stdscr) - 6; |
545 |
543 |
546 uint8_t mycolor = is_server(settings) ? settings->gameinfo.servercolor : |
544 uint8_t mycolor = is_server(settings) ? settings->gameinfo.servercolor : |
547 opponent_color(settings->gameinfo.servercolor); |
545 opponent_color(settings->gameinfo.servercolor); |
548 |
546 |
559 } else { |
557 } else { |
560 running = !recvmove(gamestate, &(settings->gameinfo), opponent); |
558 running = !recvmove(gamestate, &(settings->gameinfo), opponent); |
561 } |
559 } |
562 myturn ^= true; |
560 myturn ^= true; |
563 } while (running); |
561 } while (running); |
564 |
|
565 post_game(settings, gamestate); |
|
566 } |
|
567 |
|
568 void game_start(Settings *settings, int opponent) { |
|
569 GameState gamestate; |
|
570 gamestate_init(&gamestate); |
|
571 |
|
572 game_continue(settings, opponent, &gamestate); |
|
573 } |
562 } |
574 |
563 |
575 void dump_gameinfo(GameInfo *gameinfo) { |
564 void dump_gameinfo(GameInfo *gameinfo) { |
576 int serverwhite = gameinfo->servercolor == WHITE; |
565 int serverwhite = gameinfo->servercolor == WHITE; |
577 attron(A_UNDERLINE); |
566 attron(A_UNDERLINE); |