diff options
Diffstat (limited to 'src/wall.cpp')
-rw-r--r-- | src/wall.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/wall.cpp b/src/wall.cpp new file mode 100644 index 0000000..42df094 --- /dev/null +++ b/src/wall.cpp @@ -0,0 +1,42 @@ +#include "wall.h" + +#include <boost/random/uniform_int.hpp> +#include <boost/random/variate_generator.hpp> +#include <ctime> + +#include <iostream> + +Wall::Wall() : rand_gen(std::time(0)) { + +} + +void Wall::build() { + // Clear any previous wall. + wall.clear(); + + for(Tile tile = Tile::Man_1; tile.type <= Tile::Hatsu; tile++) { + wall.push_back(Tile(tile.type, tile.get_num() == 5)); // Insert a copy of the current tile, and make it red if it is 5. + wall.push_back(tile); + wall.push_back(tile); + wall.push_back(tile); + } +} + +int Wall::remaining() { + return wall.size(); +} + +Tile Wall::take_one() { + //return wall.front(); + + boost::uniform_int<> range(0, wall.size() - 1); + + boost::variate_generator<boost::mt19937&, boost::uniform_int<> > die(rand_gen, range); + + int num = die(); + + Tile to_return = wall[num]; + wall.erase(wall.begin() + num); + + return to_return; +} |