/*
FINALLLLLLLLLLLLYYYYYY!!! *.*
Okay, good to know stuff:
FIRST LETTER OF EACH VARIABLE:
small i = integer.
small c = character.
small f = float.
small p = pointer.
ex. piOnes = pointer to int Ones
I havn't comment so much, but it's more of a long code then an advanced one, so shouldn't be to hard :P
also, IM USING CODE::BLOCKS, IF YOU USE ANOTHER COMPILER YOU MIGHT HAVE TO #include "stdafx.h"
:P
*/
#include <iostream>
#include <ctime>
// Dice-generator function
void RollDice(int * a, int * b, int * c, int * d, int * e, int * f, int * g, int * h, int * i, int * j, int * k, int * l, int * m, int * n, int * o, float * a, float * b, float * c, float * d, float * e, float * f, float * g, float * h, float * i, float * j, float * k, float * l, float * m, float * n, float * o);
// Scoreboard function, input dice
void Scoreboard(int x1, int x2, int x3, int x4, int x5, int * a, int * b, int * c, int * d, int * e, int * f, int * g, int * h, int * i, int * j, int * k, int * l, int * m, int * n, int * o, float * a, float * b, float * c, float * d, float * e, float * f, float * g, float * h, float * i, float * j, float * k, float * l, float * m, float * n, float * o);
// Rules function, made it a function to keep main-function as clean as possible
void Rules();
using namespace std;
using std::cout;
using std::cin;
using std::rand;
using std::srand;
// Main function serves as a menu to hop between the other functions
int main()
{
// Variables that we will use to save the results
// Pointers for passing through scope and changing value
int iOnes = 0; int * piOnes = &iOnes;
int iTwos = 0; int * piTwos = &iTwos;
int iThrees = 0; int * piThrees = &iThrees;
int iFours = 0; int * piFours = &iFours;
int iFives = 0; int * piFives = &iFives;
int iSixes = 0; int * piSixes = &iSixes;
int iPair = 0; int * piPair = &iPair;
int iTwoPair = 0; int * piTwoPair = &iTwoPair;
int iThreeOfaKind = 0; int * piThreeOfaKind = &iThreeOfaKind;
int iFourOfaKind = 0; int * piFourOfaKind = &iFourOfaKind;
int iSmallStraight = 0; int * piSmallStraight = &iSmallStraight;
int iLargeStraight = 0; int * piLargeStraight = &iLargeStraight;
int iFullhouse = 0; int * piFullhouse = &iFullhouse;
int iChance = 0; int * piChance = &iChance;
int iYahtzee = 0; int * piYahtzee = &iYahtzee;
// Variables that we will use to check if the user have saved anything from before (even if it's a 0)
// Pointers for passing through scope and changing value
float fOnes = 0.5; float * pfOnes = &fOnes;
float fTwos = 0.5; float * pfTwos = &fTwos;
float fThrees = 0.5; float * pfThrees = & fThrees;
float fFours = 0.5; float * pfFours = &fFours;
float fFives = 0.5; float * pfFives = &fFives;
float fSixes = 0.5; float * pfSixes = &fSixes;
float fPair = 0.5; float * pfPair = &fPair;
float fTwoPair = 0.5; float * pfTwoPair = &fTwoPair;
float fThreeOfaKind = 0.5; float * pfThreeOfaKind = &fThreeOfaKind;
float fFourOfaKind = 0.5; float * pfFourOfaKind = &fFourOfaKind;
float fSmallStraight = 0.5; float * pfSmallStraight = &fSmallStraight;
float fLargeStraight = 0.5; float * pfLargeStraight = &fLargeStraight;
float fFullhouse = 0.5; float * pfFullhouse = &fFullhouse;
float fChance = 0.5; float * pfChance = & fChance;
float fYahtzee = 0.5; float * pfYahtzee = &fYahtzee;
int iX = 0;
int * piX = &iX;
// Variable for menu-loop
int iMenuChoice = 0;
do{
system("CLS");
cout << " '''' /''/ /''' |'''''''''''''| |'''''''| |'''''''| |'''''''| |''|" << endl;
cout << " ' '/ / / ' |____ ____| |___ / | | | | | |" << endl;
cout << " ' / / /' ' | | / / | ''''| | ''''| | |" << endl;
cout << " | | / /__' ' | | / / | | | | ''''" << endl;
cout << " | | / ______ ' | | / ''''| | '''''|| '''''| |''|" << endl;
cout << " |__| /__/ '__' |___| |_______| |________||________| |__|" << endl;
cout << endl << endl << endl;
cout << "Menu:" << endl << endl;
cout << "1. Roll dice" << endl;
cout << "2. Check Scoreboard" << endl;
cout << "3. Rules" << endl;
cout << "4. Exit" << endl;
cin >> iMenuChoice;
if(iMenuChoice == 1)
{
RollDice(piOnes, piTwos, piThrees, piFours, piFives, piSixes, piPair, piTwoPair, piThreeOfaKind, piFourOfaKind, piSmallStraight, piLargeStraight, piFullhouse, piChance, piYahtzee, pfOnes, pfTwos, pfThrees, pfFours, pfFives, pfSixes, pfPair, pfTwoPair, pfThreeOfaKind, pfFourOfaKind, pfSmallStraight, pfLargeStraight, pfFullhouse, pfChance, pfYahtzee);
++*piX; // counter inside Menuchoice -> roll dice, so it doesnt go up by lookin at the rules etc.
}
else if(iMenuChoice == 2)
{
cout << endl << "1 Ones: (" << *piOnes << ")";
if (*pfOnes != 0.5) cout << " saved";
cout << endl << "2 Twos: (" << *piTwos << ")";
if (*pfTwos != 0.5) cout << " saved";
cout << endl << "3 Threes: (" << *piThrees << ")";
if (*pfThrees != 0.5) cout << " saved";
cout << endl << "4 Fours: (" << *piFours << ")";
if (*pfFours != 0.5) cout << " saved";
cout << endl << "5 Fives: (" << *piFives << ")";
if (*pfFives != 0.5) cout << " saved";
cout << endl << "6 Sixes: (" << *piSixes << ")";
if (*pfSixes != 0.5) cout << " saved";
cout << endl << "7 Pair: (" << *piPair << ")";
if (*pfPair != 0.5) cout << " saved";
cout << endl << "8 TwoPair: (" << *piTwoPair << ")";
if (*pfTwoPair != 0.5) cout << " saved";
cout << endl << "9 Three of a Kind:(" << *piThreeOfaKind << ")";
if (*pfThreeOfaKind != 0.5) cout << " saved";
cout << endl << "10 Four of a Kind: (" << *piFourOfaKind << ")";
if (*pfFourOfaKind != 0.5) cout << " saved";
cout << endl << "11 Small Straight: (" << *piSmallStraight << ")";
if (*pfSmallStraight != 0.5) cout << " saved";
cout << endl << "12 Large Straight: (" << *piLargeStraight << ")";
if (*pfLargeStraight != 0.5) cout << " saved";
cout << endl << "13 Full House: (" << *piFullhouse << ")";
if (*pfFullhouse != 0.5) cout << " saved";
cout << endl << "14 Chance: (" << *piChance << ")";
if (*pfChance != 0.5) cout << " saved";
cout << endl << "15 Yahtzee: (" << *piYahtzee << ")";
if (*pfYahtzee != 0.5) cout << " saved";
cout << endl << endl << "Total: (" << *piOnes + *piTwos + *piThrees + *piFours + *piFives + *piSixes + *piPair + *piTwoPair + *piThreeOfaKind + *piFourOfaKind + *piSmallStraight + *piLargeStraight + *piFullhouse + *piChance +*piYahtzee << ")" << endl << endl;
system("PAUSE");
}
else if(iMenuChoice == 3)
{
Rules();
}
else if(iMenuChoice == 4){}
{
cout << endl << "BYE BYE!" << endl << endl;
}
if(*piX == 15)
{
system("CLS");
cout << "your total score is: " << *pfOnes+*pfTwos+*pfThrees+*pfFours+*pfFives+*pfSixes+*pfPair+*pfTwoPair+*pfThreeOfaKind+*pfFourOfaKind+*pfSmallStraight+*pfLargeStraight+*pfFullhouse+*pfChance+*pfYahtzee << endl;
cout << endl << "Bye bye.." << endl << endl;
system("PAUSE");
iMenuChoice = 4;
}
}while(iMenuChoice != 4);
return 0;
}
void RollDice(int * piOnes, int * piTwos, int * piThrees, int * piFours, int * piFives, int * piSixes, int * piPair, int * piTwoPair, int * piThreeOfaKind, int * piFourOfaKind, int * piSmallStraight, int * piLargeStraight, int * piFullhouse, int * piChance, int * piYahtzee, float * pfOnes, float * pfTwos, float * pfThrees, float * pfFours, float * pfFives, float * pfSixes, float * pfPair, float * pfTwoPair, float * pfThreeOfaKind, float * pfFourOfaKind, float * pfSmallStraight, float * pfLargeStraight, float * pfFullhouse, float * pfChance, float * pfYahtzee)
{
srand(time(NULL));
/* Varibles */
int x = 0; // For the do-while loop that simulates the three casts.
int tarning[5]; // The dices.
int save[5]; // saving-slots for the dices.
save[0] = 0, save[1] = 0, save[2] = 0, save[3] = 0, save[4] = 0;
char cYesNo; // For saving option.
int number;
/* Dice Loop, 5 * 3 casts */
do{
x++; // Max three casts (will check this at end of do-while loop)
system("CLS");
cout << save[0] << ", " << save[1] << ", " << save[2] << ", " << save[3] << ", " << save[4] << endl << endl;
cout << "Rolling..." << endl << endl;
for(int x = 0; x < 5; x++) // cast the 5 dices
{
if(tarning[x] != save[x])
{
tarning[x] = rand() % 6 + 1; // random generator inside the forloop and if-statement!
cout << tarning[x] << endl;
}
}
for(int x = 0; x < 5; x++) // Loop for saving the dices in its own slot
{
if(save[x] != tarning[x])
{
cout << "\n" << "Save dice " << x + 1 << "? y / n" << endl;
cin >> cYesNo;
if(cYesNo == 'y' || cYesNo == 'Y')
{
save[x] = tarning[x];
}
}
}
cout << endl << endl;
/* Checks to see so that you cast max 3 times (or less if you saved all dices) */
}while(x < 2 || (tarning[0] != save[0] && tarning[1] != save[1] && tarning[2] != save[2] && tarning[3] != save[3] && tarning[4] != save[4]));
// This is the third and last cast of the dices, and here all the remaining dices will be saved automaticly, so there won be any zeros!
if(tarning[0] != save[0] || tarning[1] != save[1] || tarning[2] != save[2] || tarning[3] != save[3] || tarning[4] != save[4])
{
system("CLS");
cout << save[0] << ", " << save[1] << ", " << save[2] << ", " << save[3] << ", " << save[4] << endl << endl;
cout << "This is your last roll!" << endl;
cout << "Remaining dices will be saved automaticly!" << endl << endl;;
cout << "Rolling..." << endl << endl;
for(int x = 0; x < 5; x++) // cast the 5 dices
{
if(tarning[x] != save[x])
{
tarning[x] = rand() % 6 + 1; // random generator inside the forloop and if-statement!
cout << tarning[x] << endl;
}
}
cout << endl << endl;
system("PAUSE");
for(int x = 0; x < 5; x++) // Loop for saving the dices in its own slot
{
if(save[x] != tarning[x])
{
save[x] = tarning[x];
}
}
cout << endl << endl;
}
/* re-save the dice in normal int's, instead of the array, cous i don't know how to send a array to another function :P */
int x1, x2, x3, x4, x5;
x1 = save[0];
x2 = save[1];
x3 = save[2];
x4 = save[3];
x5 = save[4];
/* sends the results to the scoreboard */
Scoreboard(x1, x2, x3, x4, x5, piOnes, piTwos, piThrees, piFours, piFives, piSixes, piPair, piTwoPair, piThreeOfaKind, piFourOfaKind, piSmallStraight, piLargeStraight, piFullhouse, piChance, piYahtzee, pfOnes, pfTwos, pfThrees, pfFours, pfFives, pfSixes, pfPair, pfTwoPair, pfThreeOfaKind, pfFourOfaKind, pfSmallStraight, pfLargeStraight, pfFullhouse, pfChance, pfYahtzee);
return;
}
/*
THIS NEXT FUNCTION TAKES CARE OF SAVING THE RESULTS, IT ALSO CHECKS TO
SEE IF THE DICES MEET THE RQUIREMENTS TO SAVE IN A SPESIFIC SLOT!
OBS! THERE IS ALOT OF IF STATEMENTS FOR CHECKING IF THE DICES MEET THE
REQUIREMENT BUT THEY ARE DEVIDED IN TO SECTIONS FOR EASIER USAGE.
I HAVE ALSO AVOIDED COMMENTING INSIDE THE FUNCTION!
*/
void Scoreboard(int x1,int x2,int x3,int x4,int x5, int * piOnes, int * piTwos, int * piThrees, int * piFours, int * piFives, int * piSixes, int * piPair, int * piTwoPair, int * piThreeOfaKind, int * piFourOfaKind, int * piSmallStraight, int * piLargeStraight, int * piFullhouse, int * piChance, int * piYahtzee, float * pfOnes, float * pfTwos, float * pfThrees, float * pfFours, float * pfFives, float * pfSixes, float * pfPair, float * pfTwoPair, float * pfThreeOfaKind, float * pfFourOfaKind, float * pfSmallStraight, float * pfLargeStraight, float * pfFullhouse, float * pfChance, float * pfYahtzee)
{
/* Variables from Roll-function are passed in. */
//Other Variables, for saving option etc
int iSave = 0;
char cProceed;
//Start of loop that will continue untill the user has entered something, and then return to main function
for(; ;)
{
system("CLS");
cout << x1 << ", " << x2 << ", " << x3 << ", " << x4 << ", " << x5 << endl << endl;
cout << "What do you want to save your result as?" << endl;
cout << "(enter the number and press enter)" << endl << endl;
cout << "1 Ones: (" << *piOnes << ")";
if (*pfOnes != 0.5) cout << " saved";
cout << endl << "2 Twos: (" << *piTwos << ")";
if (*pfTwos != 0.5) cout << " saved";
cout << endl << "3 Threes: (" << *piThrees << ")";
if (*pfThrees != 0.5) cout << " saved";
cout << endl << "4 Fours: (" << *piFours << ")";
if (*pfFours != 0.5) cout << " saved";
cout << endl << "5 Fives: (" << *piFives << ")";
if (*pfFives != 0.5) cout << " saved";
cout << endl << "6 Sixes: (" << *piSixes << ")";
if (*pfSixes != 0.5) cout << " saved";
cout << endl << "7 Pair: (" << *piPair << ")";
if (*pfPair != 0.5) cout << " saved";
cout << endl << "8 TwoPair: (" << *piTwoPair << ")";
if (*pfTwoPair != 0.5) cout << " saved";
cout << endl << "9 Three of a Kind:(" << *piThreeOfaKind << ")";
if (*pfThreeOfaKind != 0.5) cout << " saved";
cout << endl << "10 Four of a Kind: (" << *piFourOfaKind << ")";
if (*pfFourOfaKind != 0.5) cout << " saved";
cout << endl << "11 Small Straight: (" << *piSmallStraight << ")";
if (*pfSmallStraight != 0.5) cout << " saved";
cout << endl << "12 Large Straight: (" << *piLargeStraight << ")";
if (*pfLargeStraight != 0.5) cout << " saved";
cout << endl << "13 Full House: (" << *piFullhouse << ")";
if (*pfFullhouse != 0.5) cout << " saved";
cout << endl << "14 Chance: (" << *piChance << ")";
if (*pfChance != 0.5) cout << " saved";
cout << endl << "15 Yahtzee: (" << *piYahtzee << ")";
if (*pfYahtzee != 0.5) cout << " saved";
cout << endl << endl << "Total: (" << *piOnes + *piTwos + *piThrees + *piFours + *piFives + *piSixes + *piPair + *piTwoPair + *piThreeOfaKind + *piFourOfaKind + *piSmallStraight + *piLargeStraight + *piFullhouse + *piChance +*piYahtzee << ")" << endl << endl;
cin >> iSave;
/***********************************************************************************************************************/
/*ONES******************************************************************************************************************/
if(iSave == 1)
{
if(*pfOnes == 0.5)
{
if(x1 == 1) {*piOnes += x1;}
if(x2 == 1) {*piOnes += x2;}
if(x3 == 1) {*piOnes += x3;}
if(x4 == 1) {*piOnes += x4;}
if(x5 == 1) {*piOnes += x5;}
*pfOnes = *piOnes;
cout << "Your new score for ones are: " << *piOnes << endl;
system("PAUSE");
return;
}
else if(*pfOnes != 0.5) { cout << "Sorry, You already saved that slot." << endl; system("PAUSE"); }
} // end if(save == 1) iOnes
/***********************************************************************************************************************/
/*TWOS******************************************************************************************************************/
else if(iSave == 2)
{
if(*pfTwos == 0.5)
{
if(x1 == 2) {*piTwos += x1;}
if(x2 == 2) {*piTwos += x2;}
if(x3 == 2) {*piTwos += x3;}
if(x4 == 2) {*piTwos += x4;}
if(x5 == 2) {*piTwos += x5;}
*pfTwos = *piTwos;
cout << "Your new score for twos are: " << *piTwos << endl;
system("PAUSE");
return;
}
else if(*pfTwos != 0.5) { cout << "Sorry, You already saved that slot." << endl; system("PAUSE"); }
} // end if(save == 2) iTwos
/***********************************************************************************************************************/
/*THREES****************************************************************************************************************/
else if(iSave == 3)
{
if(*pfThrees == 0.5)
{
if(x1 == 3) {*piThrees += x1;}
if(x2 == 3) {*piThrees += x2;}
if(x3 == 3) {*piThrees += x3;}
if(x4 == 3) {*piThrees += x4;}
if(x5 == 3) {*piThrees += x5;}
*pfThrees = *piThrees;
cout << "Your new score for threes are: " << *piThrees << endl;
system("PAUSE");
return;
}
else if(*pfThrees != 0.5) { cout << "Sorry, You already saved that slot." << endl; system("PAUSE"); }
} // end if(save == 3) iThrees
/***********************************************************************************************************************/
/*FOURS*****************************************************************************************************************/
else if(iSave == 4)
{
if(*pfFours == 0.5)
{
if(x1 == 4) {*piFours += x1;}
if(x2 == 4) {*piFours += x2;}
if(x3 == 4) {*piFours += x3;}
if(x4 == 4) {*piFours += x4;}
if(x5 == 4) {*piFours += x5;}
*pfFours = *piFours;
cout << "Your new score for fours are: " << *piFours << endl;
system("PAUSE");
return;
}
else if(*pfFours != 0.5) { cout << "Sorry, You already saved that slot." << endl; system("PAUSE"); }
} // end if(save == 4) iFours
/***********************************************************************************************************************/
/*FIVES*****************************************************************************************************************/
else if(iSave == 5)
{
if(*pfFives == 0.5)
{
if(x1 == 5) {*piFives += x1;}
if(x2 == 5) {*piFives += x2;}
if(x3 == 5) {*piFives += x3;}
if(x4 == 5) {*piFives += x4;}
if(x5 == 5) {*piFives += x5;}
*pfFives = *piFives;
cout << "Your new score for fives are: " << *piFives << endl;
system("PAUSE");
return;
}
else if(*pfFives != 0.5) { cout << "Sorry, You already saved that slot." << endl; system("PAUSE"); }
} // end if(save == 5) iFives
/***********************************************************************************************************************/
/*SIXES*****************************************************************************************************************/
else if(iSave == 6)
{
if(*pfSixes == 0.5)
{
if(x1 == 6) {*piSixes += x1;}
if(x2 == 6) {*piSixes += x2;}
if(x3 == 6) {*piSixes += x3;}
if(x4 == 6) {*piSixes += x4;}
if(x5 == 6) {*piSixes += x5;}
*pfSixes = *piSixes;
cout << "Your new score for sixes are: " << *piSixes << endl;
system("PAUSE");
return;
}
else if(*pfSixes != 0.5) { cout << "Sorry, You already saved that slot." << endl; system("PAUSE"); }
} // end if(save == 6) iSixes
/***********************************************************************************************************************/
/*PAIR******************************************************************************************************************/
else if(iSave == 7)
{
if(*pfPair == 0.5)
{
if((x1 == x2) || (x1 == x3) || (x1 == x4) || (x1 ==x5))
{
*piPair = x1 += x1;
*pfPair = *piPair;
cout << "Your new score for pair is: " << *piPair << endl;
system("PAUSE");
return;
}
else if((x2 == x3) || (x2 == x4) || (x2 == x5))
{
*piPair = x2 += x2;
*pfPair = *piPair;
cout << "Your new score for pair is: " << *piPair << endl;
system("PAUSE");
return;
}
else if((x3 == x4) || (x3 == x5))
{
*piPair = x3 += x3;
*pfPair = *piPair;
cout << "Your new score for pair is: " << *piPair << endl;
system("PAUSE");
return;
}
else if((x4 == x5))
{
*piPair = x4 += x4;
*pfPair = *piPair;
cout << "Your new score for pair is: " << *piPair << endl;
system("PAUSE");
return;
}
else {cout << "Your new score for pair is: " << *piPair << endl; *pfPair = 0; system("PAUSE"); return; }
}
else if(*pfPair != 0.5) { cout << "Sorry, You already saved that slot." << endl; system("PAUSE"); }
} // End if(save == 7) iPair
/***********************************************************************************************************************/
/*TWO*PAIR**************************************************************************************************************/
else if(iSave == 8)
{
if(*pfTwoPair == 0.5)
{
if(x1 == x2 && (x3 == x4 || x3 == x5))
{
*piTwoPair = x1 + x1 + x3 + x3;
*pfTwoPair = *piTwoPair;
cout << "Your new score for two-pair is: " << *piTwoPair << endl;
system("PAUSE");
return;
}
else if(x1 == x2 && x4 == x5)
{
*piTwoPair = x1 + x1 + x4 + x4;
*pfTwoPair = *piTwoPair;
cout << "Your new score for two-pair is: " << *piTwoPair << endl;
system("PAUSE");
return;
}
else if(x1 == x3 && (x2 == x4 || x2 == x5))
{
*piTwoPair = x1 + x1 + x2 + x2;
*pfTwoPair = *piTwoPair;
cout << "Your new score for two-pair is: " << *piTwoPair << endl;
system("PAUSE");
return;
}
else if(x1 == x3 && x4 == x5)
{
*piTwoPair = x1 + x1 + x4 + x4;
*pfTwoPair = *piTwoPair;
cout << "Your new score for two-pair is: " << *piTwoPair << endl;
system("PAUSE");
return;
}
else if(x1 == x4 && (x2 == x3 || x2 == x5))
{
*piTwoPair = x1 + x1 + x2 + x2;
*pfTwoPair = *piTwoPair;
cout << "Your new score for two-pair is: " << *piTwoPair << endl;
system("PAUSE");
return;
}
else if(x1 == x4 && x3 == x5)
{
*piTwoPair = x1 + x1 + x3 + x3;
*pfTwoPair = *piTwoPair;
cout << "Your new score for two-pair is: " << *piTwoPair << endl;
system("PAUSE");
return;
}
else if(x1 == x5 && (x2 == x3 || x2 == x4))
{
*piTwoPair = x1 + x1 + x2 + x2;
*pfTwoPair = *piTwoPair;
cout << "Your new score for two-pair is: " << *piTwoPair << endl;
system("PAUSE");
return;
}
else if(x1 == x5 && x3 == x4)
{
*piTwoPair = x1 + x1 + x3 + x3;
*pfTwoPair = *piTwoPair;
cout << "Your new score for two-pair is: " << *piTwoPair << endl;
system("PAUSE");
return;
}
else if(x2 == x3 && x4 == x5)
{
*piTwoPair = x2 + x2 + x4 + x4;
*pfTwoPair = *piTwoPair;
cout << "Your new score for two-pair is: " << *piTwoPair << endl;
system("PAUSE");
return;
}
else if(x2 == x4 && x3 == x5)
{
*piTwoPair = x2 + x2 + x3 + x3;
*pfTwoPair = *piTwoPair;
cout << "Your new score for two-pair is: " << *piTwoPair << endl;
system("PAUSE");
return;
}
else if(x2 == x5 && x3 == x4)
{
*piTwoPair = x2 + x2 + x3 + x3;
*pfTwoPair = *piTwoPair;
cout << "Your new score for two-pair is: " << *piTwoPair << endl;
system("PAUSE");
return;
}
else { cout << "Your new score for two-pair is: " << *piTwoPair << endl; *pfTwoPair = 0; system("PAUSE"); return; }
}
else if(*pfTwoPair != 0.5) { cout << "Sorry, You already saved that slot." << endl; system("PAUSE"); }
} // End if(save == 8 ) iTwoPair
/***********************************************************************************************************************/
/*THREE*OF*A*KIND*******************************************************************************************************/
else if(iSave == 9)
{
if(*pfThreeOfaKind == 0.5)
{
if((x1 == x2) && (x1 == x3 || x1 == x4 || x1 == x5))
{
*piThreeOfaKind = x1 + x1 + x1;
*pfThreeOfaKind = *piThreeOfaKind;
cout << "Your new score for three of a kind is: " << *piThreeOfaKind << endl;
system("PAUSE");
return;
}
else if((x1 == x3) && (x1 == x4 || x1 == x5))
{
*piThreeOfaKind = x1 + x1 + x1;
*pfThreeOfaKind = *piThreeOfaKind;
cout << "Your new score for three of a kind is: " << *piThreeOfaKind << endl;
system("PAUSE");
return;
}
else if((x1 == x4) && (x1 == x5))
{
*piThreeOfaKind = x1 + x1 + x1;
*pfThreeOfaKind = *piThreeOfaKind;
cout << "Your new score for three of a kind is: " << *piThreeOfaKind << endl;
system("PAUSE");
return;
}
else if((x2 == x3) && (x2 == x4 || x2 == x5))
{
*piThreeOfaKind = x2 + x2 + x2;
*pfThreeOfaKind = *piThreeOfaKind;
cout << "Your new score for three of a kind is: " << *piThreeOfaKind << endl;
system("PAUSE");
return;
}
else if((x2 == x4) && (x2 == x5))
{
*piThreeOfaKind = x2 + x2 + x2;
*pfThreeOfaKind = *piThreeOfaKind;
cout << "Your new score for three of a kind is: " << *piThreeOfaKind << endl;
system("PAUSE");
return;
}
else if((x3 == x4) && (x3 == x5))
{
*piThreeOfaKind = x3 + x3 + x3;
*pfThreeOfaKind = *piThreeOfaKind;
cout << "Your new score for three of a kind is: " << *piThreeOfaKind << endl;
system("PAUSE");
return;
}
else { cout << "Your new score for three of a kind is: " << *piThreeOfaKind << endl; *pfThreeOfaKind = 0; system("PAUSE"); return; }
}
else if(*pfThreeOfaKind != 0.5) { cout << "Sorry, You already saved that slot." << endl; system("PAUSE"); }
} // end if(save == 9) iThreeOfaKind
/***********************************************************************************************************************/
/*FOUR*OF*A*KIND********************************************************************************************************/
else if(iSave == 10)
{
if(*pfFourOfaKind == 0.5)
{
if((x1 == x2) && (x1 == x3) && (x1 == x4 || x1 == x5))
{
*piFourOfaKind = x1 + x1 + x1 + x1;
*pfFourOfaKind = *piFourOfaKind;
cout << "Your new score for four of a kind is: " << *piFourOfaKind << endl;
system("PAUSE");
return;
}
else if((x1 == x2) && (x1 == x4) && (x1 == x3 || x1 == x5))
{
*piFourOfaKind = x1 + x1 + x1 + x1;
*pfFourOfaKind = *piFourOfaKind;
cout << "Your new score for four of a kind is: " << *piFourOfaKind << endl;
system("PAUSE");
return;
}
else if((x1 == x2) && (x1 == x5) && (x1 == x3 || x1 == x4))
{
*piFourOfaKind = x1 + x1 + x1 + x1;
*pfFourOfaKind = *piFourOfaKind;
cout << "Your new score for four of a kind is: " << *piFourOfaKind << endl;
system("PAUSE");
return;
}
else if((x1 == x3) && (x1 == x4) && (x1 == x2 || x1 == x5))
{
*piFourOfaKind = x1 + x1 + x1 + x1;
*pfFourOfaKind = *piFourOfaKind;
cout << "Your new score for four of a kind is: " << *piFourOfaKind << endl;
system("PAUSE");
return;
}
else if((x1 == x3) && (x1 == x5) && (x1 == x2 || x1 == x4))
{
*piFourOfaKind = x1 + x1 + x1 + x1;
*pfFourOfaKind = *piFourOfaKind;
cout << "Your new score for four of a kind is: " << *piFourOfaKind << endl;
system("PAUSE");
return;
}
else if((x1 == x4) && (x1 == x5) && (x1 == x2 || x1 == x3))
{
*piFourOfaKind = x1 + x1 + x1 + x1;
*pfFourOfaKind = *piFourOfaKind;
cout << "Your new score for four of a kind is: " << *piFourOfaKind << endl;
system("PAUSE");
return;
}
else if((x2 == x3) && (x2 == x4) && (x2 == x5))
{
*piFourOfaKind = x2 + x2 + x2 + x2;
*pfFourOfaKind = *piFourOfaKind;
cout << "Your new score for four of a kind is: " << *piFourOfaKind << endl;
system("PAUSE");
return;
}
else { cout << "Your new score for four of a kind is: " << *piFourOfaKind << endl; *pfFourOfaKind = 0; system("PAUSE"); return; }
}
else if(*pfFourOfaKind != 0.5) { cout << "Sorry, You already saved that slot." << endl; system("PAUSE"); }
} // End if(save == 10) iFourOfaKind
/***********************************************************************************************************************/
/*SMALL*STRAIGHT********************************************************************************************************/
else if(iSave == 11)
{
if(*pfSmallStraight == 0.5)
{
if(x1 != x2 && x1 != x3 && x1 != x4 && x1 != x5)
{
if(x2 != x3 && x2 != x4 && x2 != x5)
{
if(x3 != x4 && x3 != x5)
{
if(x4 != x5)
{
if(x1 != 6 && x2 != 6 && x3 != 6 && x4 != 6 && x5 != 6)
{
*piSmallStraight = x1 + x2 + x3 + x4 + x5;
*pfSmallStraight = *piSmallStraight;
cout << "Your new score for Small Straight is: " << *piSmallStraight << endl;
system("PAUSE");
return;
}
else { cout << "Your new score for Small Straight is: " << *piSmallStraight << endl; *pfSmallStraight = 0; system("PAUSE"); return; }
}
else { cout << "Your new score for Small Straight is: " << *piSmallStraight << endl; *pfSmallStraight = 0; system("PAUSE"); return; }
}
else { cout << "Your new score for Small Straight is: " << *piSmallStraight << endl; *pfSmallStraight = 0; system("PAUSE"); return; }
}
else { cout << "Your new score for Small Straight is: " << *piSmallStraight << endl; *pfSmallStraight = 0; system("PAUSE"); return; }
}
else { cout << "Your new score for Small Straight is: " << *piSmallStraight << endl; *pfSmallStraight = 0; system("PAUSE"); return; }
}
else if(*pfSmallStraight != 0.5) { cout << "Sorry, You already saved that slot." << endl; system("PAUSE"); }
} // End if(save == 11) iSmallStraight
/***********************************************************************************************************************/
/*LARGE*STRAIGHT********************************************************************************************************/
else if(iSave == 12)
{
if(*pfLargeStraight == 0.5)
{
if(x1 != x2 && x1 != x3 && x1 != x4 && x1 != x5)
{
if(x2 != x3 && x2 != x4 && x2 != x5)
{
if(x3 != x4 && x3 != x5)
{
if(x4 != x5)
{
if(x1 != 1 && x2 != 1 && x3 != 1 && x4 != 1 && x5 != 1)
{
*piLargeStraight = x1 + x2 + x3 + x4 + x5;
*pfLargeStraight = *piLargeStraight;
cout << "Your new score for Large Straight is: " << *piLargeStraight << endl;
system("PAUSE");
return;
}
else { cout << "Your new score for Large Straight is: " << *piLargeStraight << endl; *pfLargeStraight = 0; system("PAUSE"); return; }
}
else { cout << "Your new score for Large Straight is: " << *piLargeStraight << endl; *pfLargeStraight = 0; system("PAUSE"); return; }
}
else { cout << "Your new score for Large Straight is: " << *piLargeStraight << endl; *pfLargeStraight = 0; system("PAUSE"); return; }
}
else { cout << "Your new score for Large Straight is: " << *piLargeStraight << endl; *pfLargeStraight = 0; system("PAUSE"); return; }
}
else { cout << "Your new score for Large Straight is: " << *piLargeStraight << endl; *pfLargeStraight = 0; system("PAUSE"); return; }
}
else if(*pfLargeStraight != 0.5) { cout << "Sorry, You already saved that slot." << endl; system("PAUSE"); }
} // End if(save == 12) iLargeStraight
/***********************************************************************************************************************/
/*FULL*HOUSE************************************************************************************************************/
else if(iSave == 13)
{
if(*pfFullhouse == 0.5)
{
if((x1 == x2 && x1 == x3) && (x4 == x5))
{
*piFullhouse = x1 + x2 + x3 + x4 + x5;
*pfFullhouse = *piFullhouse;
cout << "Your new score for Full House is: " << *piFullhouse << endl;
system("PAUSE");
return;
}
else if((x1 == x2 && x1 == x4) && (x3 == x5))
{
*piFullhouse = x1 + x2 + x3 + x4 + x5;
*pfFullhouse = *piFullhouse;
cout << "Your new score for Full House is: " << *piFullhouse << endl;
system("PAUSE");
return;
}
else if((x1 == x2 && x1 == x5) && (x3 == x4))
{
*piFullhouse = x1 + x2 + x3 + x4 + x5;
*pfFullhouse = *piFullhouse;
cout << "Your new score for Full House is: " << *piFullhouse << endl;
system("PAUSE");
return;
}
else if((x1 == x3 && x1 == x4) && (x2 == x5))
{
*piFullhouse = x1 + x2 + x3 + x4 + x5;
*pfFullhouse = *piFullhouse;
cout << "Your new score for Full House is: " << *piFullhouse << endl;
system("PAUSE");
return;
}
else if((x1 == x3 && x1 == x5) && (x2 == x4))
{
*piFullhouse = x1 + x2 + x3 + x4 + x5;
*pfFullhouse = *piFullhouse;
cout << "Your new score for Full House is: " << *piFullhouse << endl;
system("PAUSE");
return;
}
else if((x1 == x4 && x1 == x5) && (x2 == x3))
{
*piFullhouse = x1 + x2 + x3 + x4 + x5;
*pfFullhouse = *piFullhouse;
cout << "Your new score for Full House is: " << *piFullhouse << endl;
system("PAUSE");
return;
}
else if((x2 == x3 && x2 == x4) && (x1 == x5))
{
*piFullhouse = x1 + x2 + x3 + x4 + x5;
*pfFullhouse = *piFullhouse;
cout << "Your new score for Full House is: " << *piFullhouse << endl;
system("PAUSE");
return;
}
else if((x2 == x3 && x2 == x5) && (x1 == x4))
{
*piFullhouse = x1 + x2 + x3 + x4 + x5;
*pfFullhouse = *piFullhouse;
cout << "Your new score for Full House is: " << *piFullhouse << endl;
system("PAUSE");
return;
}
else if((x2 == x4 && x2 == x5) && (x1 == x3))
{
*piFullhouse = x1 + x2 + x3 + x4 + x5;
*pfFullhouse = *piFullhouse;
cout << "Your new score for Full House is: " << *piFullhouse << endl;
system("PAUSE");
return;
}
else if((x3 == x4 && x3 == x5) && (x1 == x2))
{
*piFullhouse = x1 + x2 + x3 + x4 + x5;
*pfFullhouse = *piFullhouse;
cout << "Your new score for Full House is: " << *piFullhouse << endl;
system("PAUSE");
return;
}
else { cout << "Your new score for Full House is: " << *piFullhouse << endl; *pfFullhouse = 0; system("PAUSE"); return; }
}
else if(*pfFullhouse != 0.5) { cout << "Sorry, You already saved that slot." << endl; system("PAUSE"); }
} // End if(save == 13) iFullHouse
/***********************************************************************************************************************/
/*CHANCE****************************************************************************************************************/
else if(iSave == 14)
{
if(*pfChance == 0.5)
{
*piChance = x1 + x2 + x3 + x4 + x5;
*pfChance = *piChance;
cout << "Your new score for chance are: " << *piChance << endl;
system("PAUSE");
return;
}
else if(*pfChance != 0.5) { cout << "Sorry, You already saved that slot." << endl; system("PAUSE"); }
} //End if(save == 14) iChance
/***********************************************************************************************************************/
/*YAHTZEE***************************************************************************************************************/
else if(iSave == 15)
{
if(*pfYahtzee == 0.5)
{
if((x1 == x2) && (x1 == x3) && (x1 == x4) && (x1 == x5))
{
*piYahtzee = 50;
*pfYahtzee = *piYahtzee;
cout << "Your new score for chance are: " << *piYahtzee << endl;
system("PAUSE");
return;
}
else { cout << "Your new score for Yahtzee are: " << *piYahtzee << endl; *pfYahtzee = 0; system("PAUSE"); return; }
}
else if(*pfYahtzee != 0.5) { cout << "Sorry, You already saved that slot." << endl; system("PAUSE"); }
} // End if(save == 15) iYahtzee
/***********************************************************************************************************************/
} // End for-loop
return;
}
void Rules()
{
system("CLS");
cout << "RULES OF YAHTZEE (EUROPEAN VERSION)" << endl << endl << endl << endl;
cout << "Yahtzee is kind of a mix between a dice game and a regulare poker game." << endl << endl;
cout << "1. You roll 5 dice a maximum of 3 times" << endl << endl;;
cout << "2. After rolling the dice, you will be promted to save them in a slot." << endl << endl;
cout << "You get as many points as the sum of the dice you are saving." << endl;
cout << "The dice must meet the right requirements to give you any score (see below)." << endl;
cout << "You can save the dice even if they doesn't meet the requirements (for 0 score)!" << endl << endl;
cout << "3. Requirments:" << endl << endl;
cout << "Ones: Only dice with number 1 will give you points." << endl;
cout << "Twos: Only dice with number 2 will give you points." << endl;
cout << "Threes: Only dice with number 3 will give you points." << endl;
cout << "Fours: Only dice with number 4 will give you points." << endl;
cout << "Fives: Only dice with number 5 will give you points." << endl;
cout << "Sixes: Only dice with number 6 will give you points." << endl;
cout << "Pair: Only 2 dice of the same number give points." << endl;
cout << "Two Pair: Only 2 pairs will give you points (2, 2, 4, 4, 0)" << endl;
cout << "Three of a kind: Only 3 dice of same number give points." << endl;
cout << "Four of a kind: Only 4 dice of same number give points." << endl;
cout << "Small Straight: Only a straight from 1-5 give points." << endl;
cout << "Large Straight: Only a straight from 2-6 give points." << endl;
cout << "Full House: Only a pair + a three of a kind give points (1, 1, 1, 2, 2)." << endl;
cout << "Chance: You can save anything in the chance slot." << endl;
cout << "YAHTZEE: All dice must be of same number to give points." << endl;
cout << endl << endl;
system("PAUSE");
return;
}