#include <play.h>
|
| Play (Player *p) |
|
| ~Play () |
|
void | setPlayer (Player *p) |
|
bool | validate (std::string tileStr, Board *b, int r, int c, char dir) |
|
std::vector< std::vector< Tile * > > | getWords (std::vector< Tile * > tilesInStr, Board *b, int r, int c, char dir) |
|
std::vector< Tile * > | getConnectedWord (Tile *t, char dir) |
|
void | calculatePoints (std::vector< std::vector< Tile * >> words, std::vector< Tile * > tileStrVec) |
|
int | getPointsMade () |
|
bool | confirmPlay () |
|
void | reset () |
|
void | show () |
|
Definition at line 23 of file play.h.
◆ Play()
Construct a Play
- Parameters
-
This function shall note throw exceptions
Definition at line 19 of file play.cc.
◆ ~Play()
◆ calculatePoints()
void Play::calculatePoints |
( |
std::vector< std::vector< Tile * >> |
words, |
|
|
std::vector< Tile * > |
tileStrVec |
|
) |
| |
Calculate the points made when the play was made
- Parameters
-
words | The words to consider for calculation |
tileStrVec | Tiles that were placed in the Play |
This function shall not throw exceptions.
Definition at line 296 of file play.cc.
◆ confirmPlay()
bool Play::confirmPlay |
( |
| ) |
|
Ask whether the play should be confirmed or not
- Returns
- true if confirmed, false otherwise
This function shall not throw exceptions.
Definition at line 363 of file play.cc.
◆ getConnectedWord()
vector< Tile * > Play::getConnectedWord |
( |
Tile * |
t, |
|
|
char |
searchDir |
|
) |
| |
Get the word that a Tile is part of
- Parameters
-
t | Tile in question |
searchDir | Direction of search |
- Returns
- Vector of Tiles that make up the found "word"
- Exceptions
-
std::string | containing the error message |
Definition at line 254 of file play.cc.
◆ getPointsMade()
int Play::getPointsMade |
( |
| ) |
|
Getter for pointsMade data member
- Returns
- pointsMade
This function shall not throw exceptions.
Definition at line 351 of file play.cc.
◆ getWords()
vector< vector< Tile * > > Play::getWords |
( |
std::vector< Tile * > |
tilesInStr, |
|
|
Board * |
b, |
|
|
int |
r, |
|
|
int |
c, |
|
|
char |
dir |
|
) |
| |
Get all new words that were made as a result of successful play
- Parameters
-
tilesInStr | Vector of Tiles that were placed |
b | Pointer to the Board where the Tiles were placed |
r | Row where the first Tile goes |
c | Column where first tile goes |
dir | Direction of placement |
- Returns
- A 2D vector of Tiles containing all the words made as vectors of Tiles
- Exceptions
-
std::string | containing the error message |
Definition at line 175 of file play.cc.
◆ reset()
Reset the Play to initial conditions
This function shall not throw exceptions.
Definition at line 387 of file play.cc.
◆ setPlayer()
void Play::setPlayer |
( |
Player * |
p | ) |
|
Set the maker of the Play
- Parameters
-
This function shall not throw exceptions.
Definition at line 62 of file play.cc.
◆ show()
◆ validate()
bool Play::validate |
( |
std::string |
tileStr, |
|
|
Board * |
b, |
|
|
int |
r, |
|
|
int |
c, |
|
|
char |
dir |
|
) |
| |
Validates whether a requested play is possible or not. Rejection restores the game's condition as it was before the play was made.
Algorithm-
- Start from first placed Tile
- Check whether the Tile has any neighbours that were placed before the current Tile (ie. check if the play connects with a previously placed word)
- If so, play is valid, return true, otherwise, move to next Tile
- If all placed Tiles are exhausted, return false
- Parameters
-
tileStr | String of letters that represent the Tiles to be placed |
b | Pointer to the Board where the tiles are to be placed |
r | Row where the first Tile goes |
c | Column where first tile goes |
dir | Direction of placement |
- Returns
- true if valid, false otherwise
- Exceptions
-
std::string | containing the error message |
- Warning
- Cannot be used to validate the first play
Definition at line 90 of file play.cc.
◆ playMaker
◆ playStr
std::string Play::playStr |
|
private |
◆ pointsMade
◆ wordsInPlay
std::vector<std::vector<Tile*> > Play::wordsInPlay |
|
private |
The documentation for this class was generated from the following files: