#include "King.h" #include "Position.h" #include #include #include King::King(Position pos, char c) { position = pos; color = c; } std::pair King::get_moves() { Position* moves = new Position[8]; int moveCounts = 0; for(int i = -1; i < 2; i++) { for(int j = -1; j < 2; j++) { Position p; if (position.posSym+i == position.posSym and position.posNum+j == position.posNum) continue; // Position выдаст ошибку если указать невозможную позицию try { p = Position((char)(position.posSym+i), (char)(position.posNum+j)); } catch (const std::invalid_argument) { continue; } moves[moveCounts] = p; moveCounts++; } } return std::pair(8, moves); } const char* King::print() { const char* me; if (color == 'B') me = "♚"; else me = "♔"; return me; }