Skip to content
Permalink
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#include <iostream>
#include <string>
#include <random>
#include <ctime>
using namespace std;
string random_s()
{
int Army=50;
int Popularity=50;
int Religion=50;
int Wealth=50;
// our variables have been declared as integers and given 50 to store our starting values
default_random_engine randomGenerator(time(0));
uniform_int_distribution<int> scenarios(1 , 2);
//the 2 lines above are the random engine function which creates a random seed depending on the time on your computer
//when initialised therefore creating random numbers, we have uniform distribution so that every 'scenario' has
//a equal chance of showing and no statistical biased is involved
//inside scenrios would be the numbers 1, N amount of scenarios added in later versions of our game,
//which would give the game a random output line very time making for a different gameplay experience every time.
string answer;
// a variable called answer was declared as type string here.
if (scenarios(randomGenerator)==2)
//if statements have been added to happen when the random generator chooses a output scenario.
// so depending on the number you get will output a different if statement
{
label1:
//label has been made here for a goto that happens later in the code for when the player inputs a improper word that isn't yes or no,
//it will repeat the scenrio until they input a viable answer.
cout<<"Give me half your money otherwise I will attack\n";
cout<<"Yes:lose 50% wealth, gain popularity \n";
cout<<"No:lose army, gain popularity"<<endl;
//\n was used to create 3 lines of text below each other while using a cout instead of the whole std::... as we
//declared it near the top of the .h file
cin>> answer;
//the player would input their answer here which will lead to another if statement build depending on what they input
if (answer == "yes")
{
Wealth=Wealth-(0.5*Wealth);
Popularity=Popularity+130;
//quick maths calculations and re-stored with the new numbers we currently has popularity +130
//as it was what we would test if the 'you are dead', decided to keep it to show the testing process somewhat
cout<<"Army: "<<Army<<" Popularity: "<<Popularity<< " Religion: "<<Religion<<" Wealth: "<<Wealth<<endl;
//simple print showing categories and their current updated stats all on 1 line
}
else if (answer == "no")
{
Army=Army-(0.4*Army);
Popularity=Popularity+30;
cout<<"Army: "<<Army<<" Popularity: "<<Popularity<< " Religion: "<<Religion<<" Wealth: "<<Wealth<<endl;
}
else
{
cout<<"Please enter valid input"<<endl;
goto label1;
//goto label was made to take back to the top of this specific if statement sotaht they could repeat what they would input as if they didnt input yes
//or no it would be something wrong
}
}
if (Army<0)
{
cout<<"since your army was not strong enough, the neighbouring empire defeated you during an invasion"<<endl;
cout<<"GAME OVER, Thank you for playing"<<endl;
return 0;
//this is all the ending possibilities of the game where it does a check after running the if statement
//if it doesnt happen then it will leave the loop and go back out to the while loop, repaeting until eventually
//the conditions for this for loop is activated.
}
else if (Army>100)
{
cout<<"your army got too strong and overthrew you"<<endl;
cout<<"GAME OVER, Thank you for playing"<<endl;
return 0;
}
if (Popularity<0)
{
cout<<"Since your popularity was too low, you got crippling depression and decided to end your meaningless worthless pointless empty shell of a life"<<endl;
cout<<"GAME OVER, Thank you for playing"<<endl;
return 0;
}
else if (Popularity>100)
{
cout<<"Since your popularity was too high, ego gets the better of you and your lifestyle changes leads to civil unrest and protest which ultimately leads to your dethronement"<<endl;
cout<<"GAME OVER, Thank you for playing"<<endl;
return 0;
}
if (Religion<0)
{
cout<<"Since your religious beliefs was too low, the pope started a crusade against you ending in your public beheading"<<endl;
cout<<"GAME OVER, Thank you for playing"<<endl;
return 0;
}
else if (Religion>100)
{
cout<<"Since your religious beliefs was too high, you went on a pilgrimage to land far far away, and was never to be seen again"<<endl;
cout<<"GAME OVER, Thank you for playing"<<endl;
return 0;
}
if (Wealth<0)
{
cout<<"Since you were a broke ass man, people yeeted you off the castle"<<endl;
cout<<"GAME OVER, Thank you for playing"<<endl;
return 0;
}
else if (Wealth>100)
{
cout<<"Since you became too wealthy, a group of robbers invaded your castle and you were killed during invasion along with your family"<<endl;
cout<<"GAME OVER, Thank you for playing"<<endl;
return 0;
}
if (scenarios(randomGenerator)==1)
{
label2:
cout<<"Our army would like the money to enlist new recruits \n";
cout<<"Yes:gain army, lose wealth \n";
cout<<"No:gain wealth , lose reputation "<<endl;
cin>> answer;
if (answer == "yes")
{
Wealth=Wealth-15;
Army=Army+20;
cout<<"Army: "<<Army<<" Popularity: "<<Popularity<< " Religion: "<<Religion<<" Wealth: "<<Wealth<<endl;
}
else if (answer == "no")
{
Army=Army-10;
Wealth=Wealth+15;
cout<<"Army: "<<Army<<" Popularity: "<<Popularity<< " Religion: "<<Religion<<" Wealth: "<<Wealth<<endl;
}
else
{
cout<<"Please enter valid input"<<endl;
goto label2;
}
}
if (Army<0)
{
cout<<"since your army was not strong enough, the neighbouring empire defeated you during an invasion"<<endl;
cout<<"GAME OVER, Thank you for playing"<<endl;
return 0;
}
else if (Army>100)
{
cout<<"your army got too strong and overthrew you"<<endl;
cout<<"GAME OVER, Thank you for playing"<<endl;
return 0;
}
if (Popularity<0)
{
cout<<"Since your popularity was too low, you got crippling depression and decided to end your meaningless worthless pointless empty shell of a life"<<endl;
cout<<"GAME OVER, Thank you for playing"<<endl;
return 0;
}
else if (Popularity>100)
{
cout<<"Since your popularity was too high, ego gets the better of you and your lifestyle changes leads to civil unrest and protest which ultimately leads to your dethronement"<<endl;
cout<<"GAME OVER, Thank you for playing"<<endl;
return 0;
}
if (Religion<0)
{
cout<<"Since your religious beliefs was too low, the pope started a crusade against you ending in your public beheading"<<endl;
cout<<"GAME OVER, Thank you for playing"<<endl;
return 0;
}
else if (Religion>100)
{
cout<<"Since your religious beliefs was too high, you went on a pilgrimage to land far far away, and was never to be seen again"<<endl;
cout<<"GAME OVER, Thank you for playing"<<endl;
return 0;
}
if (Wealth<0)
{
cout<<"Since you were a broke ass man, people yeeted you off the castle"<<endl;
cout<<"GAME OVER, Thank you for playing"<<endl;
return 0;
}
else if (Wealth>100)
{
cout<<"Since you became too wealthy, a group of robbers invaded your castle and you were killed during invasion along with your family"<<endl;
cout<<"GAME OVER, Thank you for playing"<<endl;
return 0;
}
}