CrossZeroGameField Class Reference

#include <CrossZeroGameField.h>

Collaboration diagram for CrossZeroGameField:

Collaboration graph
[legend]

List of all members.

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


Detailed Description

CrossZeroGameField is a class which models game field. It constructs game field and holds all information of the game field state.

Definition at line 20 of file CrossZeroGameField.h.


Constructor & Destructor Documentation

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 (  ) 

Class destructor

Definition at line 52 of file CrossZeroGameField.cpp.

References _pFieldData.

CrossZeroGameField::CrossZeroGameField ( int  height,
int  width 
)

Class overloaded constructor.

Parameters:
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.


Member Function Documentation

bool CrossZeroGameField::addInput ( const CrossZeroPoint< int > &  point,
const std::string &  token 
)

Given point (from game field) is filled with token.

Parameters:
point is 2D-coordinate (x,y).
token is letter which will be draw into game field.
Returns:
true if input was added into game field, false if not

Definition at line 67 of file CrossZeroGameField.cpp.

References _iFieldHeight, _iFieldWidth, _latestAddedPoint, _pFieldData, CrossZeroPoint< T >::x, and CrossZeroPoint< T >::y.

Referenced by CrossZeroEngine::start().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

bool CrossZeroGameField::hasPlayerWon ( const std::string &  strToken  ) 

Checks if player (token) won a game.

Parameters:
strToken is string which contains player's token.
Returns:
true if player has won a game, false if not

Definition at line 112 of file CrossZeroGameField.cpp.

References _latestAddedPoint, isTokenOnPosition(), CrossZeroPoint< T >::x, and CrossZeroPoint< T >::y.

Referenced by CrossZeroEngine::start().

Here is the call graph for this function:

Here is the caller graph for this function:

bool CrossZeroGameField::isPositionReserved ( const CrossZeroPoint< int > &  point  )  const

Checks if position already reserved (is there already a token).

Parameters:
point which is 2D CrossZeroPoint .
Returns:
true if point is reserved, false if not.

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().

Here is the caller graph for this function:

CrossZeroPoint<int> CrossZeroGameField::getLatestAddedPoint (  )  const [inline]

Get latest added point on game field (position where token was added the last time)

Returns:
position of last added token.

Definition at line 71 of file CrossZeroGameField.h.

References _latestAddedPoint.

Referenced by CrossZeroAiPlayer::getRespond().

Here is the caller graph for this function:

int CrossZeroGameField::getFieldWidth (  )  const [inline]

Get current field width

Returns:
field width.

Definition at line 77 of file CrossZeroGameField.h.

References _iFieldWidth.

int CrossZeroGameField::getFieldHeight (  )  const [inline]

Get current field height.

Returns:
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.

Parameters:
point which is 2D CrossZeroPoint
strToken is string which contains player's token
Returns:
true if token is on given position, false if not

Definition at line 297 of file CrossZeroGameField.cpp.

References _iFieldHeight, _iFieldWidth, CrossZeroPoint< T >::x, and CrossZeroPoint< T >::y.

Referenced by hasPlayerWon().

Here is the caller graph for this function:


Member Data Documentation

std::vector<std::vector<std::string> >* CrossZeroGameField::_pFieldData [private]

Definition at line 98 of file CrossZeroGameField.h.

Referenced by addInput(), getLatestAddedPoint(), and hasPlayerWon().


The documentation for this class was generated from the following files:

Generated on Mon Feb 25 23:18:58 2008 for CrossZero by  doxygen 1.5.5