summaryrefslogtreecommitdiff
path: root/src/wall.cpp
blob: 42df094ea96b03832f966fb593fe2bac15d05ecf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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;
}