Roman Hergenreder 5 years ago
parent
commit
b3df6714a4

+ 3 - 1
Makefile

@@ -1,6 +1,6 @@
 CC=gcc
 CXX=g++
-CFLAGS := -c -Wall -Wextra -std=c++11
+CFLAGS := -g -c -Wall -Wextra -std=c++11
 SRC_DIR := ./src
 OBJ_DIR := ./obj
 INCLUDE := -I./src
@@ -8,6 +8,8 @@ MKDIR_P := mkdir -p
 SRC_FILES := $(shell find $(SRC_DIR) -name '*.cpp')
 OBJ_FILES := $(addprefix $(OBJ_DIR)/,$(SRC_FILES:$(SRC_DIR)/%.cpp=%.o))
 
+debug: $(CFLAGS) += -DDEBUG -g
+debug: all
 all: dir chess
 
 dir:

+ 101 - 47
src/Field.cpp

@@ -1,4 +1,5 @@
 #include "Field.h"
+#include "Piece.h"
 #include "pieces/Pawn.h"
 #include "pieces/King.h"
 #include "pieces/Queen.h"
@@ -7,45 +8,73 @@
 #include "pieces/Knight.h"
 
 CField::CField() {
+  for(int y = 0; y < 8; y++) {
+    for(int x = 0; x < 8; x++) {
+      fields[x][y] = nullptr;
+    }
+  }
+
   reset();
 }
 
+CField::~CField() {
+  // reset previous pieces
+  for(int y = 0; y < 8; y++) {
+    for(int x = 0; x < 8; x++) {
+      if(fields[x][y]) {
+        delete fields[x][y];
+      }
+    }
+  }
+}
+
 void CField::reset() {
 
+  // reset previous pieces
+  for(int y = 0; y < 8; y++) {
+    for(int x = 0; x < 8; x++) {
+      if(fields[x][y]) {
+        delete fields[x][y];
+      }
+      fields[x][y] = 0;
+    }
+  }
+
+
   // White
-  pieces[0][0] = new CRook(Color::WHITE);
-  pieces[7][0] = new CRook(Color::WHITE);
+  fields[0][0] = new CRook(0, 0, Color::WHITE);
+  fields[7][0] = new CRook(7, 0, Color::WHITE);
 
-  pieces[1][0] = new CKnight(Color::WHITE);
-  pieces[6][0] = new CKnight(Color::WHITE);
+  fields[1][0] = new CKnight(1, 0, Color::WHITE);
+  fields[6][0] = new CKnight(6, 0, Color::WHITE);
 
-  pieces[2][0] = new CBishop(Color::WHITE);
-  pieces[5][0] = new CBishop(Color::WHITE);
+  fields[2][0] = new CBishop(2, 0, Color::WHITE);
+  fields[5][0] = new CBishop(5, 0, Color::WHITE);
 
-  pieces[3][0] = new CQueen(Color::WHITE);
-  pieces[4][0] = (m_pKingWhite = new CKing(Color::WHITE));
+  fields[3][0] = new CQueen(3, 0, Color::WHITE);
+  fields[4][0] = (m_pKingWhite = new CKing(4, 0, Color::WHITE));
   for(unsigned int x = 0; x < 8; x++)
-    pieces[x][1] = new CPawn(Color::WHITE);
+    fields[x][1] = new CPawn(x, 1, Color::WHITE);
 
   // Empty Space
   for(unsigned x = 0; x < 8; x++)
     for(unsigned y = 2; y < 6; y++)
-      pieces[x][y] = nullptr;
+      fields[x][y] = nullptr;
 
   // Black
-  pieces[0][7] = new CRook(Color::BLACK);
-  pieces[7][7] = new CRook(Color::BLACK);
+  fields[0][7] = new CRook(0, 7, Color::BLACK);
+  fields[7][7] = new CRook(7, 7, Color::BLACK);
 
-  pieces[1][7] = new CKnight(Color::BLACK);
-  pieces[6][7] = new CKnight(Color::BLACK);
+  fields[1][7] = new CKnight(1, 7, Color::BLACK);
+  fields[6][7] = new CKnight(6, 7, Color::BLACK);
 
-  pieces[2][7] = new CBishop(Color::BLACK);
-  pieces[5][7] = new CBishop(Color::BLACK);
+  fields[2][7] = new CBishop(2, 7, Color::BLACK);
+  fields[5][7] = new CBishop(5, 7, Color::BLACK);
 
-  pieces[3][7] = new CQueen(Color::BLACK);
-  pieces[4][7] = (m_pKingBlack = new CKing(Color::BLACK));
+  fields[3][7] = new CQueen(3, 7, Color::BLACK);
+  fields[4][7] = (m_pKingBlack = new CKing(4, 7, Color::BLACK));
   for(unsigned int x = 0; x < 8; x++)
-    pieces[x][6] = new CPawn(Color::BLACK);
+    fields[x][6] = new CPawn(x, 6, Color::BLACK);
 }
 
 ostream& operator<<(ostream &os, const CField &field) {
@@ -58,8 +87,8 @@ ostream& operator<<(ostream &os, const CField &field) {
     os << " " << y + 1;
     for(int x = 0; x < 8; x++) {
       os << "  ";
-      if(field.pieces[x][y] != nullptr)
-        os << *field.pieces[x][y];
+      if(field.fields[x][y] != nullptr)
+        os << *field.fields[x][y];
       else
         os << " ";
     }
@@ -73,30 +102,32 @@ bool CField::checkBounds(int x, int y) {
   return (x >= 0 && y >= 0 && x < 8 && y < 8);
 }
 
-bool CField::isAttacked(int x, int y, int color) {
-  if(!checkBounds(x, y))
+bool CField::isAttacked(int tarX, int tarY, int color) {
+  if(!checkBounds(tarX, tarY))
     return false;
 
-  // TODO: CField::isAttacked(int,int,int)
-  return false;
-}
+  for(int x = 0; x < 8; x++) {
+    for(int y = 0; y < 8; y++) {
 
-void CField::swapPieces(int x0, int y0, int x1, int y1) {
-  if(!checkBounds(x0, y0) || !checkBounds(x1, y1))
-    return;
+      if((x != tarX || y != tarY) &&
+         fields[x][y] != nullptr &&
+         fields[x][y]->getColor() == color &&
+         fields[x][y]->canMove(this, tarX, tarY))
+         return true;
+    }
+  }
 
-  CPiece *piece0 = getPiece(x0, y0);
-  CPiece *piece1 = getPiece(x1, y1);
-  pieces[x0][y0] = piece1;
-  pieces[x1][y1] = piece0;
+  return false;
 }
 
 bool CField::move(int fromX, int fromY, int toX, int toY) {
   if(!checkBounds(fromX, fromY) || !checkBounds(fromX, fromY))
     return false;
 
-  if(fromX == toX && fromY == toY)
+  if(fromX == toX && fromY == toY) {
+    cout << "Source and Target positions are the same" << endl;
     return false;
+  }
 
   CPiece *movingPiece = getPiece(fromX, fromY);
   if(movingPiece == nullptr)
@@ -104,23 +135,46 @@ bool CField::move(int fromX, int fromY, int toX, int toY) {
 
   CPiece *targetPiece = getPiece(toX, toY);
   if(targetPiece != nullptr) {
-    if(targetPiece->getType() == CPiece::Type::KING)
+    if(targetPiece->getType() == CPiece::Type::KING) {
+      cout << "You cannot attack the king" << endl;
       return false;
-    else if(targetPiece->getColor() == movingPiece->getColor())
+    }
+    else if(targetPiece->getColor() == movingPiece->getColor()) {
+      cout << "You cannot attack your own pieces" << endl;
       return false;
+    }
   }
 
-  if(movingPiece->canMove(this, fromX, fromY, toX, toY)) {
-    if(targetPiece != nullptr) {
-      delete targetPiece;
-    }
-    pieces[toX][toY] = movingPiece;
-    pieces[fromX][fromY] = nullptr;
-    movingPiece->m_HasMoved = true;
-    return true;
-  } else {
+  if(!movingPiece->moveTo(this, toX, toY)) {
+    cout << "This piece cannot move there." << endl;
+    return false;
+  }
+
+  int activeColor = movingPiece->getColor();
+  CKing *pOwnKing = (activeColor == Color::WHITE ? m_pKingWhite : m_pKingBlack);
+  if(isAttacked(pOwnKing->m_X, pOwnKing->m_Y, 1 - activeColor)) {
+    // we cannot move as our king is attacked, reset this move!
+    cout << "You king is still attacked." << endl;
+    setPiece(fromX, fromY, movingPiece);
+    setPiece(toX, toY, targetPiece);
     return false;
   }
+
+  movingPiece->m_HasMoved = true;
+  if(targetPiece != nullptr)
+    delete targetPiece;
+
+  return true;
+}
+
+void CField::setPiece(int x, int y, CPiece *pPiece) {
+  if(checkBounds(x, y)) {
+    fields[x][y] = pPiece;
+    if(pPiece) {
+      pPiece->m_X = x;
+      pPiece->m_Y = y;
+    }
+  }
 }
 
 int CField::normalalize(int i) {
@@ -152,9 +206,9 @@ bool CField::intersect(int fromX, int fromY, int toX, int toY, bool includeTarge
   int y = fromY + dirY;
 
   for(; !(x == toX && y == toY); x += dirX, y += dirY) {
-    if(pieces[x][y] != nullptr)
+    if(fields[x][y] != nullptr)
       return true;
   }
 
-  return (includeTarget ? pieces[toX][toY] != nullptr : false);
+  return (includeTarget ? fields[toX][toY] != nullptr : false);
 }

+ 6 - 5
src/Field.h

@@ -2,10 +2,11 @@
 #define FIELD_H
 
 #include <iostream>
+#include <vector>
 
 class CField {
 
-  class CPiece *pieces[8][8];
+  class CPiece *fields[8][8];
   class CKing *m_pKingWhite, *m_pKingBlack;
 
   static inline int normalalize(int i);
@@ -13,21 +14,21 @@ class CField {
 public:
 
   CField();
-  ~CField() { }
+  ~CField();
 
   void reset();
 
   friend std::ostream& operator<<(std::ostream &os, const CField &field);
 
   bool isAttacked(int x, int y, int color);
-  void swapPieces(int x0, int y0, int x1, int y1);
+  void setPiece(int x, int y, class CPiece *pPiece);
   bool move(int fromX, int fromY, int toX, int toY);
-  bool intersect(int fromX, int fromY, int toX, int toY, bool includeTarget=false);
+  bool intersect(int fromX, int fromY, int toX, int toY, bool includeTarget = false);
   bool checkBounds(int x, int y);
 
   class CKing *getKingBlack() const { return m_pKingBlack; }
   class CKing *getKingWhite() const { return m_pKingWhite; }
-  class CPiece *getPiece(int x, int y) { return pieces[x][y]; }
+  class CPiece *getPiece(int x, int y) { return fields[x][y]; }
 };
 
 #endif

+ 16 - 3
src/Game.cpp

@@ -64,9 +64,17 @@ bool CGame::processInput(string line) {
       int fromX, fromY, toX, toY;
       if(parsePosition(match[1].str(), &fromX, &fromY) && parsePosition(match[2].str(), &toX, &toY)) {
         CPiece *piece = m_pField->getPiece(fromX, fromY);
-        if(piece != nullptr && piece->getColor() == m_CurrentPlayer && m_pField->move(fromX, fromY, toX, toY)) {
-          return true;
+        if(piece == nullptr) {
+          cout << "There is no piece on the source field" << endl;
+          return false;
         }
+
+        if(piece->getColor() != m_CurrentPlayer) {
+          cout << "You can only move your own pieces" << endl;
+          return false;
+        }
+
+        return (m_pField->move(fromX, fromY, toX, toY));
       }
     }
   }
@@ -82,6 +90,11 @@ void CGame::start() {
   string line;
 
   while(!m_IsOver) {
+
+    CKing *activeKing = getActiveKing();
+    if(m_pField->isAttacked(activeKing->m_X, activeKing->m_Y, 1 - m_CurrentPlayer))
+      cout << "Check!" << endl;
+
     cout << endl << *m_pField << endl;
 
     do {
@@ -89,7 +102,7 @@ void CGame::start() {
       cin >> line;
     } while(!processInput(line));
 
-    // check win condition
+    // TODO: check win condition
     {
       m_CurrentPlayer = 1 - m_CurrentPlayer;
     }

+ 12 - 0
src/Piece.cpp

@@ -1 +1,13 @@
 #include "Piece.h"
+#include "Field.h"
+
+bool CPiece::moveTo(CField *pField, int destX, int destY) {
+
+  if(canMove(pField, destX, destY)) {
+    pField->setPiece(m_X, m_Y, nullptr);
+    pField->setPiece(destX, destY, this);
+    return true;
+  }
+
+  return false;
+}

+ 9 - 6
src/Piece.h

@@ -27,14 +27,17 @@ private:
 
 public:
 
-  CPiece(Type type, string icon, int color) :
+  bool m_HasMoved;
+  int m_X, m_Y;
+
+  CPiece(Type type, string icon, int x, int y, int color) :
     m_Type(type), m_Icon(icon), m_Color(color) {
     m_HasMoved = false;
+    m_X = x;
+    m_Y = y;
   }
 
-  ~CPiece() { }
-
-  bool m_HasMoved;
+  virtual ~CPiece() { }
 
   friend std::ostream& operator<<(std::ostream &os, const CPiece &piece) {
     return os << piece.m_Icon;
@@ -42,10 +45,10 @@ public:
 
   Type getType() const { return m_Type; }
   int getColor() const { return m_Color; }
-  bool hasMoved() const { return m_HasMoved; }
+  bool moveTo(class CField *pField, int destX, int destY);
 
   // Virtual methods
-  virtual bool canMove(class CField *pField, int fromX, int fromY, int destX, int destY) = 0;
+  virtual bool canMove(class CField *pField, int destX, int destY)  = 0;
 };
 
 #endif

+ 6 - 6
src/pieces/Bishop.cpp

@@ -1,21 +1,21 @@
 #include "Bishop.h"
 #include "../Field.h"
 
-CBishop::CBishop(int color)
-  : CPiece(Type::BISHOP, (color == Color::WHITE ? "♗" : "♝"), color) {
+CBishop::CBishop(int x, int y, int color)
+  : CPiece(Type::BISHOP, (color == Color::WHITE ? "♗" : "♝"), x, y, color) {
 }
 
-bool CBishop::canMove(CField *pField, int fromX, int fromY, int destX, int destY) {
+bool CBishop::canMove(CField *pField, int destX, int destY) {
 
 
-  int dirX = destX - fromX;
-  int dirY = destY - fromY;
+  int dirX = destX - m_X;
+  int dirY = destY - m_Y;
 
   if(abs(dirX) != abs(dirY))
     return false;
 
   // check intersection
-  if(pField->intersect(fromX, fromY, destX, destY))
+  if(pField->intersect(m_X, m_Y, destX, destY))
     return false;
 
   return true;

+ 2 - 2
src/pieces/Bishop.h

@@ -7,10 +7,10 @@ class CBishop : public CPiece {
 
 public:
 
-  CBishop(int color);
+  CBishop(int x, int y, int color);
   ~CBishop() { }
 
-  virtual bool canMove(class CField *pField, int fromX, int fromY, int destX, int destY);
+  virtual bool canMove(class CField *pField, int destX, int destY) ;
 };
 
 #endif

+ 22 - 16
src/pieces/King.cpp

@@ -1,8 +1,8 @@
 #include "King.h"
 #include "../Field.h"
 
-CKing::CKing(int color)
-  : CPiece(Type::KING, (color == Color::WHITE ? "♔" : "♚"), color) {
+CKing::CKing(int x, int y, int color)
+  : CPiece(Type::KING, (color == Color::WHITE ? "♔" : "♚"), x, y, color) {
 }
 
 bool CKing::performCasteling(CField *pField, int rookPos) {
@@ -11,42 +11,48 @@ bool CKing::performCasteling(CField *pField, int rookPos) {
   if(m_HasMoved)
     return false;
 
-  int kingPos = 4;
-  int baseRow = getColor() == Color::WHITE ? 0 : 7;
-
   // 2. Rook may not have been moved yet
-  CPiece *piece = pField->getPiece(rookPos, baseRow);
-  if(piece == nullptr || piece->getType() != Type::ROOK || piece->hasMoved())
+  CPiece *piece = pField->getPiece(rookPos, m_Y);
+  if(piece == nullptr || piece->getType() != Type::ROOK || piece->m_HasMoved)
     return false;
 
 
-  for(int x = kingPos; (rookPos == 0 ? x >= 0 : x <= 7); (rookPos == 0 ? x-- : x++)) {
+  for(int x = m_X; (rookPos == 0 ? x >= 0 : x <= 7); (rookPos == 0 ? x-- : x++)) {
 
     // 3. Empty fields between king and rook
-    if(x != rookPos && x != kingPos) {
-      if(pField->getPiece(x, baseRow) != nullptr) {
+    if(x != rookPos && x != m_X) {
+      if(pField->getPiece(x, m_Y) != nullptr) {
         return false;
       }
     }
 
     // 4. No fields are attacked
-    if(pField->isAttacked(x, baseRow, 1 - getColor())) {
+    if(pField->isAttacked(x, m_Y, 1 - getColor())) {
       return false;
     }
   }
 
   // Swap!
-  pField->swapPieces(kingPos, baseRow, rookPos, baseRow);
+  pField->setPiece(m_X, m_Y, piece);
+  pField->setPiece(rookPos, m_Y, piece);
   m_HasMoved = true;
   piece->m_HasMoved = true;
   return true;
 }
 
-bool CKing::canMove(CField *pField, int fromX, int fromY, int destX, int destY) {
+bool CKing::canMove(CField *pField, int destX, int destY) {
+
+  int dirX = destX - m_X;
+  int dirY = destY - m_Y;
+
+  if(dirY == 0 && (destX == 0 || destX == 7))
+    return performCasteling(pField, destX);
 
-  int dirX = destX - fromX;
-  int dirY = destY - fromY;
+  if(abs(dirX) > 1 || abs(dirY) > 1)
+    return false;
 
-  return abs(dirX) <= 1 && abs(dirY) <= 1;
+  if(pField->isAttacked(destX, destY, 1 - getColor()))
+    return false;
 
+  return true;
 }

+ 2 - 2
src/pieces/King.h

@@ -9,13 +9,13 @@ class CKing : public CPiece {
 
 public:
 
-  CKing(int color);
+  CKing(int x, int y, int color);
   ~CKing() { }
 
   bool performKingsideCasteling(class CField *pField) { return performCasteling(pField, 7); };
   bool performQueensideCasteling(class CField *pField) { return performCasteling(pField, 0); };
 
-  virtual bool canMove(class CField *pField, int fromX, int fromY, int destX, int destY);
+  virtual bool canMove(class CField *pField, int destX, int destY) ;
 };
 
 #endif

+ 5 - 5
src/pieces/Knight.cpp

@@ -1,13 +1,13 @@
 #include "Knight.h"
 
-CKnight::CKnight(int color)
-  : CPiece(Type::KNIGHT, (color == Color::WHITE ? "♘" : "♞"), color) {
+CKnight::CKnight(int x, int y, int color)
+  : CPiece(Type::KNIGHT, (color == Color::WHITE ? "♘" : "♞"), x, y, color) {
 }
 
-bool CKnight::canMove(CField *pField, int fromX, int fromY, int destX, int destY) {
+bool CKnight::canMove(CField *pField, int destX, int destY) {
 
-  int dirX = destX - fromX;
-  int dirY = destY - fromY;
+  int dirX = destX - m_X;
+  int dirY = destY - m_Y;
 
   // 1 step in first direction, 2 steps in second direction
   return ((abs(dirX) == 2 && abs(dirY) == 1) || (abs(dirX) == 1 && abs(dirY) == 2));

+ 2 - 2
src/pieces/Knight.h

@@ -7,10 +7,10 @@ class CKnight : public CPiece {
 
 public:
 
-  CKnight(int color);
+  CKnight(int x, int y, int color);
   ~CKnight() { }
 
-  virtual bool canMove(class CField *pField, int fromX, int fromY, int destX, int destY);
+  virtual bool canMove(class CField *pField, int destX, int destY) ;
 };
 
 #endif

+ 7 - 7
src/pieces/Pawn.cpp

@@ -1,15 +1,15 @@
 #include "Pawn.h"
 #include "../Field.h"
 
-CPawn::CPawn(int color)
-  : CPiece(Type::PAWN, (color == Color::WHITE ? "♙" : "♟"), color) {
+CPawn::CPawn(int x, int y, int color)
+  : CPiece(Type::PAWN, (color == Color::WHITE ? "♙" : "♟"), x, y, color) {
 }
 
-bool CPawn::canMove(CField *pField, int fromX, int fromY, int destX, int destY) {
+bool CPawn::canMove(CField *pField, int destX, int destY) {
 
   // check for valid movement
-  int dirY = destY - fromY;
-  int dirX = destX - fromX;
+  int dirY = destY - m_Y;
+  int dirX = destX - m_X;
 
   // dirY = { -2, -1, 1, 2 }
   // dirX = { -1, 0, 1     }
@@ -31,7 +31,7 @@ bool CPawn::canMove(CField *pField, int fromX, int fromY, int destX, int destY)
 
   // Case 2: 1 Step crosswise
   } else if(abs(dirY) == 1 && dirX != 0) {
-      CPiece *targetPiece = pField->getPiece(fromX + dirX, fromY + dirY);
+      CPiece *targetPiece = pField->getPiece(m_X + dirX, m_Y + dirY);
       if(targetPiece == nullptr)
         return false;
 
@@ -41,5 +41,5 @@ bool CPawn::canMove(CField *pField, int fromX, int fromY, int destX, int destY)
 
   // Todo: check for base line of opponent
 
-  return !pField->intersect(fromX, fromY, destX, destY, dirX == 0);
+  return !pField->intersect(m_X, m_Y, destX, destY, dirX == 0);
 }

+ 2 - 2
src/pieces/Pawn.h

@@ -7,10 +7,10 @@ class CPawn : public CPiece {
 
 public:
 
-  CPawn(int color);
+  CPawn(int x, int y, int color);
   ~CPawn() { }
 
-  virtual bool canMove(class CField *pField, int fromX, int fromY, int destX, int destY);
+  virtual bool canMove(class CField *pField, int destX, int destY) ;
 };
 
 #endif

+ 7 - 7
src/pieces/Queen.cpp

@@ -1,17 +1,17 @@
 #include "Queen.h"
 #include "../Field.h"
 
-CQueen::CQueen(int color)
-  : CPiece(Type::QUEEN, (color == Color::WHITE ? "♕" : "♛"), color) {
+CQueen::CQueen(int x, int y, int color)
+  : CPiece(Type::QUEEN, (color == Color::WHITE ? "♕" : "♛"), x, y, color) {
 }
 
-bool CQueen::canMove(CField *pField, int fromX, int fromY, int destX, int destY) {
+bool CQueen::canMove(CField *pField, int destX, int destY) {
 
-  int dirX = destX - fromX;
-  int dirY = destY - fromY;
+  int dirX = destX - m_X;
+  int dirY = destY - m_Y;
 
-  if(abs(dirX) == abs(dirY) || ((fromX == destX) != (fromY == destY)))
-    return !pField->intersect(fromX, fromY, destX, destY);
+  if(abs(dirX) == abs(dirY) || ((m_X == destX) != (m_Y == destY)))
+    return !pField->intersect(m_X, m_Y, destX, destY);
 
   return false;
 }

+ 2 - 2
src/pieces/Queen.h

@@ -7,10 +7,10 @@ class CQueen : public CPiece {
 
 public:
 
-  CQueen(int color);
+  CQueen(int x, int y, int color);
   ~CQueen() { }
 
-  virtual bool canMove(class CField *pField, int fromX, int fromY, int destX, int destY);
+  virtual bool canMove(class CField *pField, int destX, int destY) ;
 };
 
 #endif

+ 5 - 5
src/pieces/Rook.cpp

@@ -1,18 +1,18 @@
 #include "Rook.h"
 #include "../Field.h"
 
-CRook::CRook(int color)
-  : CPiece(Type::ROOK, (color == Color::WHITE ? "♖" : "♜"), color) {
+CRook::CRook(int x, int y, int color)
+  : CPiece(Type::ROOK, (color == Color::WHITE ? "♖" : "♜"), x, y, color) {
 }
 
-bool CRook::canMove(CField *pField, int fromX, int fromY, int destX, int destY) {
+bool CRook::canMove(CField *pField, int destX, int destY) {
 
   // different x or different y but not both different/equal
-  if((fromX == destX) == (fromY == destY))
+  if((m_X == destX) == (m_Y == destY))
     return false;
 
   // check intersection
-  if(pField->intersect(fromX, fromY, destX, destY))
+  if(pField->intersect(m_X, m_Y, destX, destY))
     return false;
 
   return true;

+ 2 - 2
src/pieces/Rook.h

@@ -7,10 +7,10 @@ class CRook : public CPiece {
 
 public:
 
-  CRook(int color);
+  CRook(int x, int y, int color);
   ~CRook() { }
 
-  virtual bool canMove(class CField *pField, int fromX, int fromY, int destX, int destY);
+  virtual bool canMove(class CField *pField, int destX, int destY) ;
 };
 
 #endif