RealPlayer.cpp 646 B

1234567891011121314151617181920
  1. #include "RealPlayer.h"
  2. #include "Position.h"
  3. #include <iostream>
  4. #include <utility>
  5. #include <stdexcept>
  6. std::pair<Position, Position> RealPlayer::get_move(Chessboard board, char color)
  7. {
  8. char pos1[2];
  9. char pos2[2];
  10. std::cout << "Please enter your move: ";
  11. std::cin >> pos1;
  12. std::cin >> pos2;
  13. if (board.get_cell(Position(pos1[0], pos1[1])).get_figure() == nullptr or board.get_cell(Position(pos1[0], pos1[1])).get_figure()->get_color() != color )
  14. throw std::invalid_argument("Player Plays Against the Rules");
  15. return std::pair<Position, Position>(Position(pos1[0], pos1[1]), Position(pos1[2], pos1[3]));
  16. }