Code:
#include <iostream>
#include <iomanip>
#include <ctime>
#include <algorithm>
#include <cstdlib>
#include <cstring>
using namespace std;
int Dice_Ret(int numOfDie);
int Random_Range(int lowest_number, int highest_number);
int Rand_Test();
int menu();
void Game_Stage1();
int main()
{
cout<<"Welcome to Zonc Alpha\nDisplaying Main Menu..\n";
int exit = 0;
while(1){
switch(menu()){
case 1:
Rand_Test();
break;
case 2:
Game_Stage1();
break;
case 4:
cout<<"Exiting...\n";
exit = 1;
break;
case 5:
cout<<"Random Dice Generating: "<<Random_Range(1,6)<<"\n\n";
break;
default:
cout<<"Invalid Response, Please choose again.\n";
break;
}
if(exit == 0)
continue;
else
break;
}
cout<<"Exited.\n";
}
int Rand_Test()
{
int arreh[7];
arreh[1] = 0, arreh[2] = 0, arreh[3] = 0, arreh[4] = 0, arreh[5] = 0, arreh[6] = 0;
int c, r = 60000;
cout<<"Out of "<<r<<" rolls of one die, these are the numbers generated.\n";
for(int a = 0; a <= r; a++){
c = Random_Range(1,6);
arreh[c] = arreh[c]++;
}
for(int a = 1; a <= 6; a++){
cout<<a<<" Was Generated \""<<arreh[a]<<"\" Times.\n";
}
}
int Random_Range(int x, int y)
{
if(x > y){
swap(x,y);
}
int range = y - x + 1;
return x + int(range * rand()/(RAND_MAX + 1.0));
}
int Dice_Ret(int numofDie)
{
}
int menu()
{
cout<<"\n\n";
cout<<"]----------------------------[\n";
cout<<" 1: Displays the dice randomization test\n";
cout<<" 2: Enter Beta Zonc 1\n";
cout<<" 3: Display Menu Again\n";
cout<<" 4: Exit\n";
cout<<" 5: Roll Die\n";
cout<<"]----------------------------[\n";
int a;
cout<<"What do you choose: ";
cin>>a;
return a;
}
void Game_Stage1() {
int dice[1] = 0, dice[2] = 0, dice[3] = 0, dice[4] = 0, dice[5] = 0, dice[6] = 0;
unsigned int totalscore = 0, side = 0, totalcurrent = 0, input, zonc = 0;
cout<<"\n\nWelcome to Zonc Beta 1, This is a single player game.\n"
"The object of this is to test the coding of the game.\nIf you dont know how to play,\ninstructions should be in the main menu.\n"
"if not, well your out of luck then because Zeus hasent coded them yet.\n\n";
cout<<"Please choose a Gameplay Goal (the number you win if you reach, must be higher than 1k): ";
unsigned int goal;
cin>>goal;
while((goal <= 1000) || (goal > 50000)){
cout<<"\n\nError, Your Goal is too small, Please input a new Goal: ";
cin>>goal;
}
cout<<"\n\nCommands;\nQ - Type at anytime to exit.\nRoll - Rolls the dice, assuming you can by the rules.\n"
"Keep - Keeps a single die, use multiple times for multiple die.\nScore - Displays your total score (including your current roll and on the side).\n";
int continue = 1, roll = 1; // Roll checks if the user has put away atleast one die, allowing them to roll again. On be default.
while(continue){
//abandoned this type of tracking multiples of the same dice number. int zc-one = 0, zc-two = 0, zc-three = 0, zc-four = 0, zc-five = 0, zc-six = 0; //Zonc Check Variables, each one stands for a dice number, a loop checks for 3 of one number.
for(int a = 1; a <= 6; a++)
dice[a] = Random_Range(1,6);
cout<<"Rolling..\nDisplaying Roll Results..\n"
"Dice1: "<<dice[1]<<", Dice2: "<<dice[2]<<", Dice3: "<<dice[3]<<", Dice4: "<<dice[4]<<", Dice5: "<<dice[5]<<", Dice6: "<<dice[6]<<"\n";
for(int a = 1; a <= 6; a++){ //Check if the player Zonced
zonc = 1;
if((dice[a] == 1) || (dice[a] == 5))
zonc = 0;
}
}
}