lint/style changes
This commit is contained in:
parent
4404eb21e9
commit
8736aee27c
@ -22,7 +22,9 @@ public:
|
|||||||
bool takeTilesFromPool(azool::TileColor color, int& numTiles, bool& poolPenalty);
|
bool takeTilesFromPool(azool::TileColor color, int& numTiles, bool& poolPenalty);
|
||||||
void returnTilesToBag(int numTiles, azool::TileColor color);
|
void returnTilesToBag(int numTiles, azool::TileColor color);
|
||||||
void dealTiles();
|
void dealTiles();
|
||||||
int numFactories() { return tileFactories.size(); }
|
int numFactories() {
|
||||||
|
return tileFactories.size();
|
||||||
|
}
|
||||||
bool endOfRound() {
|
bool endOfRound() {
|
||||||
// round ends when the pool and tile factories are empty
|
// round ends when the pool and tile factories are empty
|
||||||
for (int ii = 0; ii < azool::NUMCOLORS; ++ii) {
|
for (int ii = 0; ii < azool::NUMCOLORS; ++ii) {
|
||||||
|
@ -15,10 +15,16 @@ public:
|
|||||||
void placeTiles(int rowIdx, azool::TileColor color, int numTiles);
|
void placeTiles(int rowIdx, azool::TileColor color, int numTiles);
|
||||||
void endRound(bool& fullRow);
|
void endRound(bool& fullRow);
|
||||||
void finalizeScore();
|
void finalizeScore();
|
||||||
int getScore() const { return myScore; }
|
int getScore() const {
|
||||||
|
return myScore;
|
||||||
|
}
|
||||||
std::string printMyBoard() const;
|
std::string printMyBoard() const;
|
||||||
bool tookPenalty() const { return myTookPoolPenaltyThisRound; }
|
bool tookPenalty() const {
|
||||||
const std::string getPlayerName() const { return myName; }
|
return myTookPoolPenaltyThisRound;
|
||||||
|
}
|
||||||
|
const std::string getPlayerName() const {
|
||||||
|
return myName;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Player(const Player&) = delete;
|
Player(const Player&) = delete;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef TILE_UTILS_H_
|
#ifndef TILE_UTILS_H_
|
||||||
#define TILE_UTILS_H_
|
#define TILE_UTILS_H_
|
||||||
namespace azool {
|
namespace azool {
|
||||||
enum TileColor {
|
enum TileColor {
|
||||||
NONE = -1,
|
NONE = -1,
|
||||||
RED = 0,
|
RED = 0,
|
||||||
BLUE,
|
BLUE,
|
||||||
@ -9,15 +9,15 @@ namespace azool {
|
|||||||
YELLOW,
|
YELLOW,
|
||||||
BLACK,
|
BLACK,
|
||||||
NUMCOLORS
|
NUMCOLORS
|
||||||
};
|
};
|
||||||
const std::string TileColorStrings[NUMCOLORS] = {
|
const std::string TileColorStrings[NUMCOLORS] = {
|
||||||
"red",
|
"red",
|
||||||
"blue",
|
"blue",
|
||||||
"green",
|
"green",
|
||||||
"yellow",
|
"yellow",
|
||||||
"black"
|
"black"
|
||||||
};
|
};
|
||||||
|
|
||||||
const char TileColorSyms[NUMCOLORS] = { 'r', 'b', 'g', 'y', 'k' };
|
const char TileColorSyms[NUMCOLORS] = { 'r', 'b', 'g', 'y', 'k' };
|
||||||
}
|
}
|
||||||
#endif // TILE_UTILS_H_
|
#endif // TILE_UTILS_H_
|
||||||
|
@ -12,7 +12,7 @@ GameBoard::GameBoard(int numPlayers) :
|
|||||||
rng(std::default_random_engine(
|
rng(std::default_random_engine(
|
||||||
std::chrono::system_clock::now().time_since_epoch().count())) {
|
std::chrono::system_clock::now().time_since_epoch().count())) {
|
||||||
resetBoard();
|
resetBoard();
|
||||||
} // GameBoard::GameBoard
|
} // GameBoard::GameBoard
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& out, const GameBoard& board) {
|
std::ostream& operator<<(std::ostream& out, const GameBoard& board) {
|
||||||
// user will input 1-indexed value, even though we 0-index internally
|
// user will input 1-indexed value, even though we 0-index internally
|
||||||
|
@ -17,7 +17,7 @@ Player::Player(GameBoard* const board, std::string name) :
|
|||||||
myRows[ii].first = 0;
|
myRows[ii].first = 0;
|
||||||
myRows[ii].second = azool::NONE;
|
myRows[ii].second = azool::NONE;
|
||||||
} // initialize rows
|
} // initialize rows
|
||||||
} // Player::Player
|
} // Player::Player
|
||||||
|
|
||||||
bool Player::checkValidMove(azool::TileColor color, int rowIdx) const {
|
bool Player::checkValidMove(azool::TileColor color, int rowIdx) const {
|
||||||
// check if valid move
|
// check if valid move
|
||||||
@ -296,7 +296,7 @@ bool Player::discardFromPool(azool::TileColor color) {
|
|||||||
} // Player::discardFromPool
|
} // Player::discardFromPool
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
int promptForFactoryIdx(int maxNumFactories) {
|
int promptForFactoryIdx(int maxNumFactories) {
|
||||||
static const char* promptFactoryIdxDraw = "Which factory? enter index\n";
|
static const char* promptFactoryIdxDraw = "Which factory? enter index\n";
|
||||||
char factInput; // TODO can we safely say there will never be more than 9 possible?
|
char factInput; // TODO can we safely say there will never be more than 9 possible?
|
||||||
std::cout << promptFactoryIdxDraw << std::flush;
|
std::cout << promptFactoryIdxDraw << std::flush;
|
||||||
@ -306,8 +306,8 @@ namespace {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return factIdx;
|
return factIdx;
|
||||||
}
|
}
|
||||||
azool::TileColor promptForColor() {
|
azool::TileColor promptForColor() {
|
||||||
static const char* promptColorDraw = "Which color? [r|b|g|y|k]\n";
|
static const char* promptColorDraw = "Which color? [r|b|g|y|k]\n";
|
||||||
char colorInput = '\0';
|
char colorInput = '\0';
|
||||||
std::cout << promptColorDraw << std::flush;
|
std::cout << promptColorDraw << std::flush;
|
||||||
@ -332,8 +332,8 @@ namespace {
|
|||||||
return azool::NONE;
|
return azool::NONE;
|
||||||
} // end switch
|
} // end switch
|
||||||
return azool::NONE;
|
return azool::NONE;
|
||||||
}
|
}
|
||||||
int promptForRow() {
|
int promptForRow() {
|
||||||
static const char* promptRowPlacement = "Place on which row? enter number [1-5]\n";
|
static const char* promptRowPlacement = "Place on which row? enter number [1-5]\n";
|
||||||
char rowInput;
|
char rowInput;
|
||||||
std::cout << promptRowPlacement << std::flush;
|
std::cout << promptRowPlacement << std::flush;
|
||||||
@ -343,7 +343,7 @@ namespace {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return rowIdx;
|
return rowIdx;
|
||||||
}
|
}
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
void Player::takeTurn() {
|
void Player::takeTurn() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user