-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQwintoPlayer.cpp
More file actions
84 lines (61 loc) · 1.76 KB
/
QwintoPlayer.cpp
File metadata and controls
84 lines (61 loc) · 1.76 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include "QwintoPlayer.h"
QwintoPlayer::QwintoPlayer(const std::string _name) : Player(new QwintoScoreSheet(_name)) {}
QwintoPlayer::~QwintoPlayer() {delete d_ScoreSheet;}
RollOfDice QwintoPlayer::inputBeforeRoll(RollOfDice& _roll)
{
d_active = true;
std::cout << "Which dice would you like to roll?" << std::endl;
std::cout << "(Seperate each dice by a space ex: red blue): " <<std::endl;
std::vector<Color> dice_colors = get_color_index_vect(std::cin);
RollOfDice rd;
for(auto color : dice_colors)
rd.push_back(_roll[convert_to_index(color)]);
return rd;
}
void QwintoPlayer::inputAfterRoll(const RollOfDice& _roll)
{
std::cout << _roll;
std::cout << *d_ScoreSheet;
if(!d_active)
{
char answer;
std::cout << "Would you like to score this roll? [y/n] ";
std::cin >> answer;
std::cin.ignore(256, '\n');
if(answer == 'n')
return;
}
for (int i = 0; i < 2; ++i)
{
Color color;
int index;
std::cout << "What row would you like to score the roll in? (enter color) ";
color = get_color_index_vect(std::cin)[0];
std::cout << "What column (index) do you want to score in?" << std::endl;
std::cout << "(count from beginning of the chosen row) ";
std::cin >> index;
std::cin.ignore(256, '\n');
if(d_ScoreSheet->score(_roll, color, index-1))
return;
else
{
std::cout << "That is not a valid location please try another" << std::endl;
if(d_active)
std::cout << "(last try before being marked as failed throw)" << std::endl;
}
}
if(d_active)
d_ScoreSheet->addFailedThrow();
d_active = false;
}
int QwintoPlayer::convert_to_index(const Color _color) const
{
if(_color == Color::RED)
return 0;
else if(_color == Color::YELLOW)
return 1;
else if(_color == Color::BLUE)
return 2;
else
return 0;
}