| 379 printw("Move does not comply chess rules."); |
379 printw("Move does not comply chess rules."); |
| 380 break; |
380 break; |
| 381 case KING_MOVES_INTO_CHECK: |
381 case KING_MOVES_INTO_CHECK: |
| 382 printw("Can't move the king into a check position."); |
382 printw("Can't move the king into a check position."); |
| 383 break; |
383 break; |
| |
384 case MISSING_CHECK: |
| |
385 printw("Move does not indicate check."); |
| |
386 break; |
| |
387 case MISSING_CHECKMATE: |
| |
388 printw("Move does not indicate checkmate."); |
| |
389 break; |
| |
390 case INVALID_CHECK: |
| |
391 printw("Move incorrectly indicates check."); |
| |
392 break; |
| |
393 case INVALID_CHECKMATE: |
| |
394 printw("Move incorrectly indicates checkmate."); |
| |
395 break; |
| 384 default: |
396 default: |
| 385 printw("Unknown move parser error."); |
397 printw("Unknown move parser error."); |
| 386 } |
398 } |
| 387 } |
399 } |
| 388 |
400 |
| 459 save_pgn(gamestate); |
471 save_pgn(gamestate); |
| 460 } else if (movestr[0] == 0) { |
472 } else if (movestr[0] == 0) { |
| 461 /* ignore empty move strings and ask again */ |
473 /* ignore empty move strings and ask again */ |
| 462 } else { |
474 } else { |
| 463 Move move; |
475 Move move; |
| 464 int result = eval_move(gamestate, movestr, &move, curcolor); |
476 int result = eval_move_lazy(gamestate, |
| |
477 movestr, curcolor, &move); |
| 465 if (result == VALID_MOVE_SYNTAX) { |
478 if (result == VALID_MOVE_SYNTAX) { |
| 466 result = validate_move(gamestate, &move); |
479 result = validate_move(gamestate, &move); |
| 467 if (result == VALID_MOVE_SEMANTICS) { |
480 if (result == VALID_MOVE_SEMANTICS) { |
| 468 apply_move(gamestate, &move); |
481 apply_move(gamestate, &move); |
| 469 if (gamestate->checkmate) { |
482 if (gamestate->checkmate) { |
| 594 } |
607 } |
| 595 } else if (movestr[0] == 0) { |
608 } else if (movestr[0] == 0) { |
| 596 /* ignore empty move strings and ask again */ |
609 /* ignore empty move strings and ask again */ |
| 597 } else { |
610 } else { |
| 598 Move move; |
611 Move move; |
| 599 int eval_result = eval_move(gamestate, movestr, &move, mycolor); |
612 int eval_result = eval_move_lazy(gamestate, |
| |
613 movestr, mycolor, &move); |
| 600 switch (eval_result) { |
614 switch (eval_result) { |
| 601 case VALID_MOVE_SYNTAX: |
615 case VALID_MOVE_SYNTAX: |
| 602 net_send_data(opponent, NETCODE_MOVE, &move, sizeof(Move)); |
616 net_send_data(opponent, NETCODE_MOVE, &move, sizeof(Move)); |
| 603 code = net_recieve_code(opponent); |
617 code = net_recieve_code(opponent); |
| 604 move.check = code == NETCODE_CHECK || |
618 /* we could validate the move's check/checkmate flag with |
| 605 code == NETCODE_CHECKMATE; |
619 * the network response code, but we choose not to do it */ |
| 606 gamestate->checkmate = code == NETCODE_CHECKMATE; |
620 gamestate->checkmate = code == NETCODE_CHECKMATE; |
| 607 gamestate->stalemate = code == NETCODE_STALEMATE; |
621 gamestate->stalemate = code == NETCODE_STALEMATE; |
| 608 if (code == NETCODE_DECLINE) { |
622 if (code == NETCODE_DECLINE) { |
| 609 uint32_t reason; |
623 uint32_t reason; |
| 610 net_recieve_data(opponent, &reason, sizeof(uint32_t)); |
624 net_recieve_data(opponent, &reason, sizeof(uint32_t)); |