44 lines
1.4 KiB
C++
44 lines
1.4 KiB
C++
#ifndef GAMEBOARD_H_
|
|
#define GAMEBOARD_H_
|
|
#include <vector>
|
|
#include <ostream>
|
|
#include <cstring>
|
|
#include "tile_utils.h"
|
|
|
|
class GameBoard {
|
|
public:
|
|
struct Factory {
|
|
Factory() : tileCounts() {
|
|
memset(tileCounts, 0, azool::NUMCOLORS*sizeof(int));
|
|
}
|
|
int tileCounts[azool::NUMCOLORS];
|
|
}; // struct Factory
|
|
|
|
GameBoard();
|
|
GameBoard(int factories);
|
|
friend std::ostream& operator<<(std::ostream& out, const GameBoard& board);
|
|
bool validFactoryRequest(int factoryIdx, azool::TileColor color);
|
|
bool takeTilesFromFactory(int factoryIdx, azool::TileColor color, int& numTiles);
|
|
bool takeTilesFromPool(azool::TileColor color, int& numTiles, bool& poolPenalty);
|
|
void returnTilesToBag(int numTiles, azool::TileColor color);
|
|
void dealTiles();
|
|
int numFactories() { return tileFactories.size(); }
|
|
bool endOfRound() {
|
|
// round ends when the pool and tile factories are empty
|
|
for (int ii = 0; ii < azool::NUMCOLORS; ++ii) {
|
|
if (pool[ii] > 0) return false;
|
|
}
|
|
return tileFactories.empty();
|
|
}
|
|
private:
|
|
void resetBoard();
|
|
// - vector of factories?
|
|
std::vector<Factory> tileFactories;
|
|
int maxNumFactories;
|
|
int pool[azool::NUMCOLORS]; // stores the count of each color currently in the pool; initialize to 0s
|
|
bool whiteTileInPool; // initialize to true
|
|
std::vector<azool::TileColor> tileBag; // initialize to 20 of each color
|
|
bool lastRound; // initialize to false
|
|
};
|
|
#endif // GAMEBOARD_H_
|