Bridges-C++  3.4.2
Bridges(C++ API)
Public Member Functions | List of all members
bridges::game::GameGrid Class Reference

#include <GameGrid.h>

Inheritance diagram for bridges::game::GameGrid:
bridges::datastructure::Grid< GameCell > bridges::datastructure::DataStructure

Detailed Description

This is a class in BRIDGES for representing an (n x n)game grid.

This class is part of the Bridges Game API

See also
See the detailed Bridges game tutorial for examples at https://bridgesuncc.github.io/tutorials/NonBlockingGame.html
Author
Erik Saule,
Date
2018, 2019, 12/28/20

Public Member Functions

void setBGColor (int row, int col, NamedColor color)
 
NamedColor getBGColor (int row, int col) const
 
NamedColor getFGColor (int row, int col) const
 
NamedSymbol getSymbol (int row, int col) const
 
void setFGColor (int row, int col, NamedColor color)
 
void setSymbol (int row, int col, NamedSymbol symbol)
 
void drawSymbol (int row, int col, NamedSymbol symbol, NamedColor color)
 
virtual const string getDStype () const override
 Return the data structure type. More...
 
 GameGrid (int nbrow=10, int nbcol=10)
 
 GameGrid (const GameGrid &)=delete
 
virtual ~GameGrid ()=default
 
virtual const string getDataStructureRepresentation () const override
 
- Public Member Functions inherited from bridges::datastructure::Grid< GameCell >
 Grid (int rows, int cols)
 Grid constructor. More...
 
 Grid ()
 
 Grid (int *size)
 Grid constructor given size. More...
 
 Grid (const Grid &g)
 Grid constructor given an input grid. More...
 
virtual ~Grid ()
 
Gridoperator= (const Grid &g)
 
void setDimensions (int rows, int cols)
 Construct the grid given the dimensions. More...
 
int const * getDimensions ()
 Get dimenions of the grid. More...
 
GameCell const & get (int row, int col) const
 Get the (row, col) element in the grid. More...
 
void set (int row, int col, GameCell val)
 Set the grid value for the (row, col) element. More...
 
BracketHelperConst operator[] (int row) const
 provides the necessary abstraction to do something = grid[x][y]; More...
 
BracketHelper operator[] (int row)
 provides the necessary abstraction to do grid[x][y] = something; More...
 
- Public Member Functions inherited from bridges::datastructure::DataStructure
virtual ~DataStructure ()=default
 

Additional Inherited Members

- Protected Attributes inherited from bridges::datastructure::Grid< GameCell >
GameCell ** grid
 
int gridSize [2]
 
int maxGridSize [2]
 

Constructor & Destructor Documentation

◆ GameGrid() [1/2]

bridges::game::GameGrid::GameGrid ( int  nbrow = 10,
int  nbcol = 10 
)
inline

GameGrid constructors

◆ GameGrid() [2/2]

bridges::game::GameGrid::GameGrid ( const GameGrid )
delete

◆ ~GameGrid()

virtual bridges::game::GameGrid::~GameGrid ( )
virtualdefault

Member Function Documentation

◆ drawSymbol()

void bridges::game::GameGrid::drawSymbol ( int  row,
int  col,
NamedSymbol  symbol,
NamedColor  color 
)
inline

Draw a symbol at the specified location

Parameters
row,col- integer indices specifying the position to modify
symbolSymbol to draw
colorColor to draw the symbol in

◆ getBGColor()

NamedColor bridges::game::GameGrid::getBGColor ( int  row,
int  col 
) const
inline

◆ getDataStructureRepresentation()

virtual const string bridges::game::GameGrid::getDataStructureRepresentation ( ) const
inlineoverridevirtual

get the JSON representation of the game grid

Returns
the JSON representation of the game grid

Implements bridges::datastructure::DataStructure.

◆ getDStype()

virtual const string bridges::game::GameGrid::getDStype ( ) const
inlineoverridevirtual

Return the data structure type.

Returns
grid type (string)

Reimplemented from bridges::datastructure::Grid< GameCell >.

◆ getFGColor()

NamedColor bridges::game::GameGrid::getFGColor ( int  row,
int  col 
) const
inline

◆ getSymbol()

NamedSymbol bridges::game::GameGrid::getSymbol ( int  row,
int  col 
) const
inline

◆ setBGColor()

void bridges::game::GameGrid::setBGColor ( int  row,
int  col,
NamedColor  color 
)
inline

Set background color of a cell using an enum argument

Parameters
row,col- integer indices specifying the position to modify
color- Named Color enum argument to set the background at the chosen position

◆ setFGColor()

void bridges::game::GameGrid::setFGColor ( int  row,
int  col,
NamedColor  color 
)
inline

Set foreground color of a cell using an enum argument

Parameters
row,col- integer indices specifying the position to modify
color- Named Color enum argument to set the foreground at the chosen position

◆ setSymbol()

void bridges::game::GameGrid::setSymbol ( int  row,
int  col,
NamedSymbol  symbol 
)
inline

Set the symbol of a cell using an enum argument

Parameters
row,col- integer indices specifying the position to modify
symbol- the symbol to set

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