Skip to content

Instantly share code, notes, and snippets.

@Steve132
Last active November 3, 2015 20:32
Show Gist options
  • Save Steve132/18a5a67e00460106f8dc to your computer and use it in GitHub Desktop.
Save Steve132/18a5a67e00460106f8dc to your computer and use it in GitHub Desktop.
StandYourGround game
#include<iostream>
#include<string>
#include<vector>
#include<cstdlib> //rand
#include<ctime> //time
using namespace std;
int quizQuestion(const std::string& question,const std::vector<std::string>& options)
{
cout << question << endl;
for(int i=0;i<options.size();i++)
{
cout << "\t" << i+1 << ") " << options[i] << "\n";
}
int selection;
for(selection=0;selection < 1 || selection > options.size();cin >> selection)
{
cout << "Enter the number of your answer: ";
}
cout << "\n\n\n";
return selection;
}
int game_over()
{
cout << "\n\n\t\tEND\n";
return 0;
}
//information gleaned from http://www.gunlaws101.com/state/law/north-carolina/stand-your-ground
std::string get_states(int setting)
{
static const int syg_law_value[51]={
1,1,1,-1,0,0,-1,-1,1,1,-1,0,0,1,-1,1,1,1,-1,-1,-1,1,-1,1,-1,1,-1,1,-1,-1,-1,-1,1,-1,-1,1,0,-1,-1,1,0,1,1,1,-1,0,0,1,-1,0,-1,
};
static const std::string states[51]={"AL","AK","AZ","AR","CA","CO","CT","DE","FL","GA","HI","ID","IL","IN","IA","KS","KY","LA","ME","MT","NE","NV","NH","NJ","NM","NY","NC","ND","OH","OK","OR","MD","MA","MI","MN","MS","MO","PA","RI","SC","SD","TN","TX","UT","VT","VA","WA","WV","WI","WY","DC"};
std::string statelist="(";
for(int i=0;i<51;i++)
{
if(syg_law_value[i]==setting)
{
statelist+=states[i]+",";
}
}
*statelist.rbegin()=')';
return statelist;
}
int main()
{
int establishment=quizQuestion("A man you've never seen before comes up to you with a gun. He points it at you and demands you come with him to your car. Are you:",{"In your home.","In a public shopping mall"});
srand(time(0));
int actions=quizQuestion("You respond by",{"Attempting to shoot him with your legal concealed weapon.","Turning your back to him and running away.","Nothing"});
int clearlegal=0;
if(actions==2)
{
cout << "You always have the right to run away. You attempt to run away. " << endl;
if(establishment==1)
{
if(rand() % 5 == 0)
{
cout << "You duck out of the way, managing to slam the door in his face. He shoots but it doesn't work. He starts angrily kicking the door, but you're already long gone out the back door" << endl;
}
else
{
cout << "He shoots you once in the shoulder as you turn away from the door to run. He laughs as you fall down over a table. You can see him standing over you with a strange smile on his face.";
}
return game_over();
}
else
{
cout << "The open space gives you the ability to make a mad dash. ";
if(rand() % 10 == 0)
{
cout << "You start sprinting and weaving...jumping over a nearby hedge. He runs around the concrete block, but you've already gone around the other side. You're several blocks away by the time you hear sirens in the distance to nab him.\n";
}
else
{
cout << "He shoots you several times in the lower back and legs before security guards are able to chase him away. Paramedics arrive. You'll live but you need a wheelchair.";
}
return game_over();
}
}
if(actions==3)
{
cout << "He grabs your wrist and pulls you in close. You resist and manage to knock him off balance, but he pulls you to the ground. He drops the gun, but now there's a struggle. You're getting some hits, but he's stronger than you. You think you're probably going to be beaten to death.";
int fight_or_succumb=quizQuestion("What do you do?", {"Attempt to shoot him with your legal concealed weapon.","Nothing"});
if(fight_or_succumb==2)
{
cout << "You give up. He is enraged, possibly on drugs. He continues to beat you until the lights go out.";
return game_over();
}
else
{
cout << "You successfully shoot him. He slumps over dead. You're terrified. The police arrive from the gunfire and take your story. Because there were no witnesses, the police take you in for questioning. This leads to a trial, but your lawyer is confident. After a long trial some jury deliberation the jury declares that your life was in danger and your choice was between dying and shooting, so they declare the incident a justifiable homicide by reason of self-defense." << endl;
return game_over();
}
}
cout << "While he isn't looking, you draw your gun and shoot him in the stomach. Your quickdraw training at the range paid off this time. He drops the gun in shock. He slumps over dead. You're terrified.\n\tThe police arrive from the gunfire and take your story. Because there were no witnesses, the police take you in for questioning. This leads to a trial\n" << endl;
if(establishment==2)
{
clearlegal=quizQuestion("Which of these most accurately describes the code and/or caselaw of your state regarding justifiable homicide in public:",
{string("It explicitly states that you do NOT have a duty to retreat (AKA \"Stand your ground\")")+get_states(1),
string("It explicitly states that you DO have a duty to retreat.")+get_states(-1),
string("It says nothing about this.")+get_states(0)});
}
else
{
clearlegal=quizQuestion("Which of these most accurately describes the code and/or caselaw of your state regarding justifiable homicide in private:",
{"It explicitly states that you do NOT have a duty to retreat (AKA \"Castle doctrine\")(All others)",
"It explicitly states that you DO have a duty to retreat. (Washington, DC)",
"It says nothing about this. (Vermont)"});
}
bool guilty;
if(clearlegal == 1)
{
cout << "Your trial is quick, because you did not have any legal requirement to run away, and it's obvious from the investigation that you were not the instigator, you are not guilty of any crimes. The judge refuses to allow the prosecutor to continue and throws out the case fast. He admonishes the police chief for even pursing the matter.\n";
guilty=false;
}
else if(clearlegal == 2)
{
cout << "Your trial is quick, because you had a legal obligation to run away, and it's obvious from the investigation that you made no attempt to do so. Under the law, you are guilty of murder, because you killed a man and it is explicit in the law that killing cannot be justified if you don't make an attempt to run away first. The prosecutor paints a picture of you as a tough guy who wants to be a vigilante and clean up the city with your gun. \n\tThe jury deliberates for quite some time (because they are instinctively uncomfortable with the fact that the victim was a criminal), but the judge helpfully reminds them that whether or not the victim was a criminal is irrelevant, and it's not up to them to judge the law, but to judge whether or not you are guilty of breaking the law as written.\n.";
guilty=true;
}
else
{
cout << "Your trial is long and involved. The prosecution argues that you had a legal obligation to run away when the opportunity presented itself, but you did not. This supposedly demonstrates your malicious and violent intent. Only a madman would choose to harm another instead of fleeing, and your killing was unjustified. There is caselaw to support this. Your attorney argues that the right to self-defense is enshrined in the right to life and liberty as described in our founding documents, and that you had no other choice.\n";
cout << "The jury goes and deliberates.\n\n";
guilty=static_cast<bool>(rand() & 0x1);
}
if(guilty)
{
cout << "They find you guilty of homicide in the 3rd degree and discharging a weapon within city limits, and your sentence is 10-20 years.\n\nYour first day in prison is stressful, to say the least. At least you'll have some time to read good books.";
return game_over();
}
else
{
cout << "You are not guilty on any count. You walk free (although the family of the dead victim is angry and tells the media you are a wild gun)" << endl;
return game_over();
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment