rp-scrabble
Simple, terminal-based Scrabble game
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Game Class Reference

#include <game.h>

Collaboration diagram for Game:
Collaboration graph
[legend]

Public Member Functions

 Game ()
 
 ~Game ()
 
void run ()
 

Private Member Functions

void init ()
 
bool firstTurnCheck (std::string str, int r, int c, char dir)
 
void addPlayer (Player *p)
 
std::string getInput ()
 
void printHelp ()
 

Private Attributes

BoardgameBoard
 
BaggameBag
 
std::vector< Player * > players
 
std::vector< Play * > plays
 
std::string gameID
 
std::string logFilePath
 

Detailed Description

Implements the main game loop, logging and other functionalities

Definition at line 17 of file game.h.

Constructor & Destructor Documentation

◆ Game()

Game::Game ( )

Initialise all data required for a Game, including log-files, gameID

Definition at line 22 of file game.cc.

Here is the call graph for this function:

◆ ~Game()

Game::~Game ( )

Clean up game data

Definition at line 44 of file game.cc.

Member Function Documentation

◆ addPlayer()

void Game::addPlayer ( Player p)
private

Add a Player to the Game

Parameters
pPointer to the new Player

This function shall not throw exceptions.

Definition at line 68 of file game.cc.

◆ firstTurnCheck()

bool Game::firstTurnCheck ( std::string  str,
int  r,
int  c,
char  dir 
)
private

Check whether the first play is valid

Parameters
tileStrString of letters that represent the Tiles to be placed
rRow where the first Tile goes
cColumn where first tile goes
dirDirection of placement
Returns
true if valid, false otherwise

This function shall not throw exceptions.

Definition at line 168 of file game.cc.

◆ getInput()

string Game::getInput ( )
private

Used to take user input

Returns
User input as a std::string
Exceptions
std::invalid_argumentFor integer inputs
std::stringcontaining the error message for other inputs

Definition at line 196 of file game.cc.

Here is the call graph for this function:

◆ init()

void Game::init ( )
private

Initialise and set up the game

Definition at line 78 of file game.cc.

Here is the call graph for this function:

◆ printHelp()

void Game::printHelp ( )
private

Print help information

This function shall not throw exceptions.

Definition at line 317 of file game.cc.

Here is the call graph for this function:

◆ run()

void Game::run ( )

Main game logic. Contains main game loop

This function shall not throw exceptions.

Definition at line 363 of file game.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ gameBag

Bag* Game::gameBag
private

Definition at line 20 of file game.h.

◆ gameBoard

Board* Game::gameBoard
private

Definition at line 19 of file game.h.

◆ gameID

std::string Game::gameID
private

Definition at line 23 of file game.h.

◆ logFilePath

std::string Game::logFilePath
private

Definition at line 24 of file game.h.

◆ players

std::vector<Player*> Game::players
private

Definition at line 21 of file game.h.

◆ plays

std::vector<Play*> Game::plays
private

Definition at line 22 of file game.h.


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