320 bg = NamedColor::black;
321 fg = NamedColor::white;
322 symbol = NamedSymbol::none;
332 this->symbol = symbol;
400 std::string encoding =
"raw";
402 void initializeGrid() {
403 for (
int i = 0;
i < gridSize[0];
i++) {
404 for (
int j = 0;
j < gridSize[1];
j++) {
405 setBGColor(
i,
j, NamedColor::black);
406 setFGColor(
i,
j, NamedColor::black);
407 setSymbol(
i,
j, NamedSymbol::none);
420 (*this)[row][col].setBGColor(color);
424 return (*
this)[row][col].getBGColor();
428 return (*
this)[row][col].getFGColor();
432 return (*
this)[row][col].getSymbol();
442 (*this)[row][col].setFGColor(color);
452 (*this)[row][col].setSymbol(symbol);
463 setFGColor(row, col, color);
464 setSymbol(row, col, symbol);
488 string getRAWRepresentation()
const {
491 std::vector<unsigned char> bgbuf;
492 std::vector<unsigned char> fgbuf;
493 std::vector<unsigned char> symbolbuf;
495 for (
int i = 0;
i < gridSize[0];
i++) {
496 for (
int j = 0;
j < gridSize[1];
j++) {
497 bgbuf.push_back(
static_cast<unsigned char>(getBGColor(
i,
j)));
498 fgbuf.push_back(
static_cast<unsigned char>(getFGColor(
i,
j)));
499 symbolbuf.push_back(
static_cast<unsigned char>(getSymbol(
i,
j)));
505 std::string symbolstr =
base64::encode (&(symbolbuf[0]), symbolbuf.size());
523 std::string json_str;
531 json_str += getRAWRepresentation();
This is a class in BRIDGES for representing an (n x n) grid.
Definition: Grid.h:30
This class represents a single cell of the Game Grid.
Definition: GameGrid.h:312
NamedSymbol getSymbol() const
Get cell symbol.
Definition: GameGrid.h:379
GameCell(NamedColor bg, NamedColor fg, NamedSymbol symbol)
Definition: GameGrid.h:329
GameCell()
constructor
Definition: GameGrid.h:319
void setFGColor(NamedColor fg)
Set foreground color using NamedColor Enum argument.
Definition: GameGrid.h:347
void setSymbol(NamedSymbol s)
Set symbol using int argument.
Definition: GameGrid.h:355
NamedColor getBGColor() const
Get background color of cell.
Definition: GameGrid.h:363
void setBGColor(NamedColor bg)
Set background color using NamedColor Enum argument.
Definition: GameGrid.h:339
NamedColor getFGColor() const
Get foreground color of cell.
Definition: GameGrid.h:371
This is a class in BRIDGES for representing an (n x n)game grid.
Definition: GameGrid.h:398
GameGrid(int nbrow=10, int nbcol=10)
Definition: GameGrid.h:475
virtual const string getDStype() const override
Return the data structure type.
Definition: GameGrid.h:467
void setBGColor(int row, int col, NamedColor color)
Definition: GameGrid.h:419
void drawSymbol(int row, int col, NamedSymbol symbol, NamedColor color)
Definition: GameGrid.h:461
GameGrid(const GameGrid &)=delete
NamedColor getFGColor(int row, int col) const
Definition: GameGrid.h:427
virtual ~GameGrid()=default
NamedSymbol getSymbol(int row, int col) const
Definition: GameGrid.h:431
void setSymbol(int row, int col, NamedSymbol symbol)
Definition: GameGrid.h:451
void setFGColor(int row, int col, NamedColor color)
Definition: GameGrid.h:441
NamedColor getBGColor(int row, int col) const
Definition: GameGrid.h:423
virtual const string getDataStructureRepresentation() const override
Definition: GameGrid.h:522
std::string JSONencode(const T &d)
Definition: JSONutil.h:38
string encode(BYTE const *buf, unsigned int bufLen)
Definition: base64.h:56
NamedSymbol
Definition: GameGrid.h:164
NamedColor
Definition: GameGrid.h:14
Support for drawing Bar charts.
Definition: alltypes.h:4
const string COLON
Definition: DataStructure.h:52
const string OPEN_BOX
Definition: DataStructure.h:55
const string COMMA
Definition: DataStructure.h:51
const string CLOSE_BOX
Definition: DataStructure.h:56
const string CLOSE_CURLY
Definition: DataStructure.h:54
const string QUOTE
Definition: DataStructure.h:50