diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-12-25 12:54:59 +0100 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-12-25 12:54:59 +0100 |
commit | fae209a9e93400c3a2072befda9c820634cf9278 (patch) | |
tree | 2d69e2c75fff0e08468c168f773abbc939a2ff03 /src/wall.cpp | |
parent | 94a1189d757f0269ac081ad2d750152e30564986 (diff) |
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; +} |