| 222 "%s to move: ", curcolorstr); |
222 "%s to move: ", curcolorstr); |
| 223 clrtoeol(); |
223 clrtoeol(); |
| 224 |
224 |
| 225 if (asyncgetnstr(movestr, &bufpos, MOVESTR_BUFLEN)) { |
225 if (asyncgetnstr(movestr, &bufpos, MOVESTR_BUFLEN)) { |
| 226 if (strncmp(movestr, "resign", MOVESTR_BUFLEN) == 0) { |
226 if (strncmp(movestr, "resign", MOVESTR_BUFLEN) == 0) { |
| 227 gamestate->resign = true; |
227 if (curcolor == WHITE) { |
| |
228 gamestate->wresign = true; |
| |
229 } else { |
| |
230 gamestate->bresign = true; |
| |
231 } |
| 228 return 1; |
232 return 1; |
| 229 } else if (strncmp(movestr, "remis", MOVESTR_BUFLEN) == 0) { |
233 } else if (strncmp(movestr, "remis", MOVESTR_BUFLEN) == 0) { |
| 230 gamestate->remis = true; |
234 gamestate->remis = true; |
| 231 return 1; |
235 return 1; |
| 232 } else if (strncmp(movestr, "savepgn", MOVESTR_BUFLEN) == 0) { |
236 } else if (strncmp(movestr, "savepgn", MOVESTR_BUFLEN) == 0) { |
| 330 /* read move */ |
338 /* read move */ |
| 331 if (use_premove || asyncgetnstr(movestr, &bufpos, MOVESTR_BUFLEN)) { |
339 if (use_premove || asyncgetnstr(movestr, &bufpos, MOVESTR_BUFLEN)) { |
| 332 bool was_premove = use_premove; |
340 bool was_premove = use_premove; |
| 333 use_premove = false; |
341 use_premove = false; |
| 334 if (strncmp(movestr, "resign", MOVESTR_BUFLEN) == 0) { |
342 if (strncmp(movestr, "resign", MOVESTR_BUFLEN) == 0) { |
| 335 gamestate->resign = true; |
343 if (mycolor == WHITE) { |
| |
344 gamestate->wresign = true; |
| |
345 } else { |
| |
346 gamestate->bresign = true; |
| |
347 } |
| 336 net_send_code(opponent, NETCODE_RESIGN); |
348 net_send_code(opponent, NETCODE_RESIGN); |
| 337 return 1; |
349 return 1; |
| 338 } else if (strncmp(movestr, "savepgn", MOVESTR_BUFLEN) == 0) { |
350 } else if (strncmp(movestr, "savepgn", MOVESTR_BUFLEN) == 0) { |
| 339 save_pgn(gamestate, gameinfo); |
351 save_pgn(gamestate, gameinfo); |
| 340 } else if (strncmp(movestr, "remis", MOVESTR_BUFLEN) == 0) { |
352 } else if (strncmp(movestr, "remis", MOVESTR_BUFLEN) == 0) { |
| 434 refresh(); |
446 refresh(); |
| 435 |
447 |
| 436 /* allow the player to prepare a move */ |
448 /* allow the player to prepare a move */ |
| 437 if (asyncgetnstr(movestr, &bufpos, MOVESTR_BUFLEN)) { |
449 if (asyncgetnstr(movestr, &bufpos, MOVESTR_BUFLEN)) { |
| 438 if (strncmp(movestr, "resign", MOVESTR_BUFLEN) == 0) { |
450 if (strncmp(movestr, "resign", MOVESTR_BUFLEN) == 0) { |
| 439 gamestate->resign = true; |
451 if (mycolor == WHITE) { |
| |
452 gamestate->wresign = true; |
| |
453 } else { |
| |
454 gamestate->bresign = true; |
| |
455 } |
| 440 net_send_code(opponent, NETCODE_RESIGN); |
456 net_send_code(opponent, NETCODE_RESIGN); |
| 441 return 1; |
457 return 1; |
| 442 } else if (strncmp(movestr, "taunt", MOVESTR_BUFLEN) == 0) { |
458 } else if (strncmp(movestr, "taunt", MOVESTR_BUFLEN) == 0) { |
| 443 resign_suggested = true; |
459 resign_suggested = true; |
| 444 net_send_code(opponent, NETCODE_TAUNT); |
460 net_send_code(opponent, NETCODE_TAUNT); |
| 468 case NETCODE_TIMEOVER: |
484 case NETCODE_TIMEOVER: |
| 469 /* redraw the time control */ |
485 /* redraw the time control */ |
| 470 timecontrol(gamestate, gameinfo); |
486 timecontrol(gamestate, gameinfo); |
| 471 return 1; |
487 return 1; |
| 472 case NETCODE_RESIGN: |
488 case NETCODE_RESIGN: |
| 473 gamestate->resign = true; |
489 if (mycolor == WHITE) { |
| |
490 gamestate->bresign = true; |
| |
491 } else { |
| |
492 gamestate->wresign = true; |
| |
493 } |
| 474 return 1; |
494 return 1; |
| 475 case NETCODE_CONNLOST: |
495 case NETCODE_CONNLOST: |
| 476 gamestate->ragequit = true; |
496 gamestate->ragequit = true; |
| 477 return 1; |
497 return 1; |
| 478 case NETCODE_REMIS: |
498 case NETCODE_REMIS: |
| 545 erase(); /* don't use clear() to avoid flickering */ |
565 erase(); /* don't use clear() to avoid flickering */ |
| 546 draw_board(&viewedstate, WHITE, settings->unicode); |
566 draw_board(&viewedstate, WHITE, settings->unicode); |
| 547 timecontrol(&viewedstate, gameinfo); |
567 timecontrol(&viewedstate, gameinfo); |
| 548 |
568 |
| 549 move(getmaxy(stdscr)-5, 0); |
569 move(getmaxy(stdscr)-5, 0); |
| 550 const char *curcolorstr = |
570 if (gamestate->wresign) { |
| 551 gamestate->movecount % 2 == 0 ? "White" : "Black"; |
571 addstr("White resigned.\n"); |
| 552 if (gamestate->resign) { |
572 } else if (gamestate->bresign) { |
| 553 printw("%s resigned.\n", curcolorstr); |
573 addstr("Black resigned.\n"); |
| 554 } else if (gamestate->remis) { |
574 } else if (gamestate->remis) { |
| 555 addstr("The game ended remis.\n"); |
575 addstr("The game ended remis.\n"); |
| 556 } else if (gamestate->stalemate) { |
576 } else if (gamestate->stalemate) { |
| 557 addstr("The game ended in a stalemate.\n"); |
577 addstr("The game ended in a stalemate.\n"); |
| 558 } else if (gamestate->checkmate) { |
578 } else if (gamestate->checkmate) { |
| 559 printw("%s has lost the game.\n", curcolorstr); |
579 printw("%s was checkmated.\n", |
| |
580 gamestate->movecount % 2 == 0 ? "White" : "Black"); |
| 560 } else if (gamestate->ragequit) { |
581 } else if (gamestate->ragequit) { |
| 561 printw("Your opponent disconnected.\n"); |
582 printw("Your opponent disconnected.\n"); |
| 562 } |
583 } |
| 563 addstr("\nPress 'q' to quit, 's' to save the position as PGN, or\n" |
584 addstr("\nPress 'q' to quit, 's' to save the position as PGN, or\n" |
| 564 "arrow keys, home/end, page up/down to review the game.\n"); |
585 "arrow keys, home/end, page up/down to review the game.\n"); |