#include <CrossZeroGameField.h>
Public Member Functions | |
CrossZeroGameField () | |
~CrossZeroGameField () | |
CrossZeroGameField (int height, int width) | |
bool | addInput (const CrossZeroPoint< int > &point, const std::string &token) |
void | printGameField () const |
bool | hasPlayerWon (const std::string &strToken) |
bool | isPositionReserved (const CrossZeroPoint< int > &point) const |
CrossZeroPoint< int > | getLatestAddedPoint () const |
int | getFieldWidth () const |
int | getFieldHeight () const |
Private Member Functions | |
bool | isTokenOnPosition (const CrossZeroPoint< int > &point, const std::string &strToken) |
Private Attributes | |
int | _iFieldHeight |
int | _iFieldWidth |
std::vector< std::vector < std::string > > * | _pFieldData |
CrossZeroPoint< int > | _latestAddedPoint |
Definition at line 20 of file CrossZeroGameField.h.
CrossZeroGameField::CrossZeroGameField | ( | ) |
Class default constructor. On default creates 10x10 field. Note! What actually happens here is that we create matrix (which is game field) which rows are vectors. Those vectors (rows) contains vectors (columns) which again contains std::string-objects (difficult, yes)
Definition at line 13 of file CrossZeroGameField.cpp.
References _iFieldHeight, _iFieldWidth, and _pFieldData.
CrossZeroGameField::~CrossZeroGameField | ( | ) |
CrossZeroGameField::CrossZeroGameField | ( | int | height, | |
int | width | |||
) |
Class overloaded constructor.
height | is a value which defines vertical size of game field. | |
width | is a value which defines horizontal size of game field. |
Definition at line 33 of file CrossZeroGameField.cpp.
References _iFieldHeight, _iFieldWidth, and _pFieldData.
bool CrossZeroGameField::addInput | ( | const CrossZeroPoint< int > & | point, | |
const std::string & | token | |||
) |
Given point (from game field) is filled with token.
point | is 2D-coordinate (x,y). | |
token | is letter which will be draw into game field. |
Definition at line 67 of file CrossZeroGameField.cpp.
References _iFieldHeight, _iFieldWidth, _latestAddedPoint, _pFieldData, CrossZeroPoint< T >::x, and CrossZeroPoint< T >::y.
Referenced by CrossZeroEngine::start().
void CrossZeroGameField::printGameField | ( | ) | const |
Prints out game field on screen.
Definition at line 93 of file CrossZeroGameField.cpp.
References _iFieldHeight, and _iFieldWidth.
Referenced by CrossZeroHumanPlayer::getRespond(), and CrossZeroEngine::start().
bool CrossZeroGameField::hasPlayerWon | ( | const std::string & | strToken | ) |
Checks if player (token) won a game.
strToken | is string which contains player's token. |
Definition at line 112 of file CrossZeroGameField.cpp.
References _latestAddedPoint, isTokenOnPosition(), CrossZeroPoint< T >::x, and CrossZeroPoint< T >::y.
Referenced by CrossZeroEngine::start().
bool CrossZeroGameField::isPositionReserved | ( | const CrossZeroPoint< int > & | point | ) | const |
Checks if position already reserved (is there already a token).
point | which is 2D CrossZeroPoint . |
Definition at line 312 of file CrossZeroGameField.cpp.
References _iFieldHeight, _iFieldWidth, _pFieldData, CrossZeroPoint< T >::x, and CrossZeroPoint< T >::y.
Referenced by CrossZeroHumanPlayer::getRespond(), and CrossZeroAiPlayer::getRespond().
CrossZeroPoint<int> CrossZeroGameField::getLatestAddedPoint | ( | ) | const [inline] |
Get latest added point on game field (position where token was added the last time)
Definition at line 71 of file CrossZeroGameField.h.
References _latestAddedPoint.
Referenced by CrossZeroAiPlayer::getRespond().
int CrossZeroGameField::getFieldWidth | ( | ) | const [inline] |
Get current field width
Definition at line 77 of file CrossZeroGameField.h.
References _iFieldWidth.
int CrossZeroGameField::getFieldHeight | ( | ) | const [inline] |
Get current field height.
Definition at line 82 of file CrossZeroGameField.h.
References _iFieldHeight.
bool CrossZeroGameField::isTokenOnPosition | ( | const CrossZeroPoint< int > & | point, | |
const std::string & | strToken | |||
) | [private] |
Checks if there is a param token on given position.
point | which is 2D CrossZeroPoint | |
strToken | is string which contains player's token |
Definition at line 297 of file CrossZeroGameField.cpp.
References _iFieldHeight, _iFieldWidth, CrossZeroPoint< T >::x, and CrossZeroPoint< T >::y.
Referenced by hasPlayerWon().
int CrossZeroGameField::_iFieldHeight [private] |
Definition at line 94 of file CrossZeroGameField.h.
Referenced by addInput(), CrossZeroGameField(), getFieldHeight(), isPositionReserved(), isTokenOnPosition(), and printGameField().
int CrossZeroGameField::_iFieldWidth [private] |
Definition at line 95 of file CrossZeroGameField.h.
Referenced by addInput(), CrossZeroGameField(), getFieldWidth(), isPositionReserved(), isTokenOnPosition(), and printGameField().
std::vector<std::vector<std::string> >* CrossZeroGameField::_pFieldData [private] |
Definition at line 97 of file CrossZeroGameField.h.
Referenced by addInput(), CrossZeroGameField(), isPositionReserved(), and ~CrossZeroGameField().
CrossZeroPoint<int> CrossZeroGameField::_latestAddedPoint [private] |
Definition at line 98 of file CrossZeroGameField.h.
Referenced by addInput(), getLatestAddedPoint(), and hasPlayerWon().