forked from itsJonnyJyo/Chicken-Feet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathyard.cpp
More file actions
57 lines (53 loc) · 1 KB
/
yard.cpp
File metadata and controls
57 lines (53 loc) · 1 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "yard.h"
#include <iostream>
#include <vector>
#include <algorithm> //std::shuffle
#include <random> //default_random_engine
#include <chrono> //chrono::system_clock
using namespace std;
Yard::Yard(int players):
playerCount(players)
{
Bone * currBone;
for (int i = 0; i <= 9; ++i){
for (int j = i; j <= 9; ++j){
currBone = new Bone(i, j);
if(i==j)
currBone->setIsDouble(true);
deck.push_back(currBone);
}
}
}
Yard::~Yard()
{
for (auto it = deck.begin(); it != deck.end(); it++)
{
delete *it;
}
}
bool Yard::deal(Bone* &aBone)
{
if (deck.size() == 0)
return false;
aBone = deck.back();
deck.pop_back();
return true;
}
void Yard::shuffleDeck()
{
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
shuffle(deck.begin(), deck.end(), std::default_random_engine(seed));
}
void Yard::print() const
{
for (auto it = deck.begin(); it != deck.end(); it++)
{
(*it)->print();
}
}
bool Yard::isEmpty(){
if(deck.empty()){
return true;
}
return false;
}