This repository was archived by the owner on May 19, 2021. It is now read-only.
forked from ChicoState/PigsGame
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemp_main.cpp
More file actions
90 lines (86 loc) · 2.58 KB
/
temp_main.cpp
File metadata and controls
90 lines (86 loc) · 2.58 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
85
86
87
88
89
90
// Matt Edge
// Last Update: 09/15/15 11:30 Am
#include<iostream>
#include<string>
#include "dice.h"
#include <stdlib.h>
#include <stdio.h>
#include "player.h"
#include "menu.h"
#include "cpu.h"
using namespace std;
int main()
{
int win_total = 100;
string num_sides;
string name;
string choice;
Menu mainMenu;
mainMenu.printWelcome();
cout << "______________________________________________\n";
cout << "Insert player name.\n";
cin >> name;
cout << "______________________________________________\n";
cout << "Insert number of sides on dice.\n";
cin >> num_sides;
cout << "______________________________________________\n";
int sides = atoi(num_sides.c_str());
Dice dice(sides);
Player *curPlayer;
Player *player = new Player(sides);
CPU *computer = new CPU(sides);
curPlayer = player;
while(curPlayer->GetTotalScore() < 100)
{
if(curPlayer->is_player() == true)
{
cout << name << "'s turn.\n";
cout << "What do you want to do?\n";
cout << "(1) Roll\n (2) Hold\n";
cout << "______________________________________________\n";
cin >> choice;
while(choice == "1")
{
curPlayer->Roll();
if(curPlayer->GetTurnScore() == 0)
{
cout << "You rolled a 1!\n" << name << "'s turn ends\n";
cout << "______________________________________________\n";
choice = 2;
}
else
{
cout << "Your turn score is:\n" << curPlayer->GetTurnScore() << "\n";
cout << "______________________________________________\n";
cout << "What do you want to do?\n";
cout << "(1) Roll\n (2) Hold\n";
cout << "______________________________________________\n";
cin >> choice;
}
}
curPlayer->EndTurn();
cout << name << "'s total score is:\n Total Score: " << curPlayer->GetTotalScore() << "\n"
<< "______________________________________________\n";
curPlayer = computer;
}
else
{
curPlayer->Roll();
cout << "Computer's total score is:\n Total Score: " << curPlayer->GetTotalScore() << "\n"
<< "______________________________________________\n";
curPlayer = player;
}
}
if(player->GetTotalScore() >= 100)
{
cout << "Congradulations "<< name << "!!!\n You won.\n";
}
else
{
cout << "Sorry... You lose. \n";
}
cout << name << "'s final score is: " << player->GetTotalScore() << "\n"
<< "Computer's final score is: " << computer->GetTotalScore() << "\n"
<< "______________________________________________\n";
return 0;
}