Pawn.cpp 475 B

123456789101112131415161718192021222324
  1. #include "Pawn.h"
  2. #include "Position.h"
  3. #include <utility>
  4. #include <stdexcept>
  5. #include <iostream>
  6. Pawn::Pawn(Position pos) {
  7. position = pos;
  8. }
  9. std::pair<int, Position*> Pawn::get_moves()
  10. {
  11. Position* moves = new Position[1];
  12. Position p;
  13. try {
  14. p = Position(position.posSym, (char)(position.posNum+1));
  15. }
  16. catch (const std::invalid_argument) {
  17. p = Position();
  18. }
  19. moves[0] = p;
  20. return std::pair<int, Position*>(1, moves);
  21. };