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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
|
#include <iostream>
#include <string>
#include <ctime>
#include <cstdlib>
using namespace std;
int chargedmoney = 5001;
int saldo; //saldo means "blanace"
int satsning; //satsning means "bet"
bool loop_satsning=true;
bool loop_redo1=true; //redo means "ready"
bool loop_omstart=true; //omstart = restart
bool loop_insattning=true;
string omstart;
int dice1, dice2, dice3, dice4;
int spelare=0, dator=0; //spelare = player, dator=computer
int main()
{
cout << "Hey and Welcome to SUPER-DICE-DELUXE!" <<endl<<endl;
cout << "Please insert your name" <<endl<<endl;
char name[20];
cin >> name;
cout << "Hi," << name << "! Please read the rules below!" <<endl<<endl<<endl;
cout << "RULES:" <<endl;
cout << "You need to bet either 100, 300 or 500 each time you play a new game." <<endl;
cout << "To be able to bet you obviously need to put some money in, all from 100-5000" <<endl;
cout << "After that you will choose the amount of money you want to bet and then you just have to roll the dice! The one to first roll highest two rounds out of three, will bring the money to his/her wallet! Have fun!" <<endl<<endl<<endl;
string answere;
cout << "Do you wish to play? yes or no!" <<endl<<endl;
cin >> answere;
if (answere == "yes"){
cout << "Good choice!" <<endl <<endl <<endl;
do {
cout << "Choose the amount of money you would like to store in you Game-wallet" << endl<<endl;
cin >> chargedmoney;
saldo+=chargedmoney;
if (chargedmoney==100-5000) {
loop_insattning=false;
}
else if (chargedmoney> 5000){
loop_insattning=true;
saldo=0;
cout << "You have entered a non-valid amount of money. Please try again" << endl;
} else if (chargedmoney < 100) {
cout << "You have entered a non-valid amount of money. Please try again" << endl << endl;
loop_insattning=true;
saldo=0;
}
do {
cout << "Your current balance is " << saldo << " kr." <<endl;
do {
cout << "Choose the amount of money you would like to bet this round! (100kr, 300kr or 500kr)" << endl;
cin >> satsning;
if ((satsning == 100) || (satsning == 300) || (satsning == 500)) {
loop_satsning = true;
cout << "Your choice was to bet " << satsning << " kr." << endl;
} else {
loop_satsning = false;
cout << "You have entered a non-valid amount of money. Please try again" << endl;
}
} while (loop_satsning == false);
string redo1;
do { //OMGÅNG 1
cout << "Are you ready for this round? yes or no!" << endl;
cin >> redo1;
if (redo1 == "yes") {
loop_redo1 = true;
cout << "Round has started!" << endl;
} else {
loop_redo1 = false;
}
} while (loop_redo1 == false);
while (true)
{
srand(time(0));
dice1=rand() % 6 + 1;
dice2=rand() % 6 + 1;
cout <<"you got "<<dice1+dice2<<endl;
dice3 = rand() % 6 + 1;
dice4 = rand() % 6 + 1;
cout <<"The computer got "<<dice3+dice4<<endl;
if (dice1+dice2 > dice3+dice4){
cout<<"Congratulations! You won this round! "<<endl;
spelare++;
}
else if (dice1+dice2 < dice3+dice4){
cout<<"Sorry, you lose! "<<endl;
dator++;
}
else{
cout<<"It's a tie! "<<endl;
}
if ((spelare==2)||(dator==2)){
break;
}
}
if (spelare==2){
cout<<"Well done! You won "<<(satsning*2)<<"kr"<<endl;
saldo+= satsning*2;
}
else{
cout<<"Unfortunatley, you lost "<<satsning<< " kr " <<endl <<endl;
saldo-=satsning; ;
}
string omstart;
cout<<"If you want to play again, please write yes!"<<endl; //avslutning
cin>>omstart;
if (omstart=="yes"){
loop_omstart=true;
}
else{
return 0;
}
}while (loop_omstart==true);
}
while (answere == "no");
cout << "Well, I guess this is goodbye then.... Bye bye!" <<endl<<endl;
}
}
|