From fae209a9e93400c3a2072befda9c820634cf9278 Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Sat, 25 Dec 2010 12:54:59 +0100 Subject: Restructured repository. --- src/wall.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/wall.cpp (limited to 'src/wall.cpp') 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 +#include +#include + +#include + +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 > die(rand_gen, range); + + int num = die(); + + Tile to_return = wall[num]; + wall.erase(wall.begin() + num); + + return to_return; +} -- cgit v1.2.3