00001 #ifndef BOARD2D_HPP 00002 #define BOARD2D_HPP 00003 00004 #include "Board.hpp" 00005 00006 #include "Game/Move.hpp" 00007 #include "Game/Piece.hpp" 00008 00009 #include <vector> 00010 00011 class Board2D : public Board<2> 00012 { 00013 public: 00014 typedef struct Coords 00015 { 00016 int column; 00017 int line; 00018 00019 Coords():column(-1),line(-1) {} 00020 Coords(int column, int line):column(column),line(line) { } 00021 Coords(const int indexes[2]) { column = indexes[0] ; line = indexes[1]; } 00022 const int* get()const { return &column; } 00023 00024 bool isValid()const { return column >= 0 && column < 8 && line >= 0 && line < 8; } 00025 00026 bool operator!=(const Coords& c) 00027 { 00028 return column != c.column || line != c.line; 00029 } 00030 }Coords; 00031 00032 static const Coords InvalidCoords; 00033 00034 protected: 00035 00036 std::vector < std::vector < Piece > > m_board; 00037 00038 public: 00039 Board2D(unsigned int columnNumber, unsigned int lineNumber); 00040 00041 void init(const std::vector<std::pair<Coords, Piece> >& startPieces); 00042 const Piece& get(const int indexes[2])const; 00043 const Piece& get(const Coords& coords)const; 00044 00045 const std::vector<std::pair<Coords, Piece> > getPieces()const; 00046 00050 virtual void move(const Move<Coords>& move)=0; 00051 }; 00052 00053 #endif