Skip to content
Permalink
master
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 "hamza.h"
using namespace std;
// const int playerID = 1; //making playerID a variable
void Speeches::CLS()
//function i made to clear the screen
{
system("clear");
}
//a class for error and unrecgonised input
void Speeches::wrong()
{
cout << "OOPS did not recognise that. \n Try typing again" << endl;
}
void Speeches::hint1()
{
cout << "HINT type 'pick up item name' to save item for later use" << endl;
}
void Speeches::hint2()
{
cout << " HINT type 'use item name' to use a previous stored item" << endl;
}
void Speeches::hint3()
{
cout << " to travel just type 'locationname'" << endl;
cout << "e.g. type 'brokenchapel' to travel there." << endl;
}
void Speeches::hint4()
{
cout << "To drink potion just type potion type." << endl;
cout << " e.g. type 'attack' for attack potion" << endl;
}
void Speeches::hint5()
{
cout << "To travel using a specific plan type 'plan+Num."<< endl;
cout << "e.g. 'plan3" << endl;
}
void Speeches::hint6(){
cout << "type 'yes' or 'no'" << endl;
}
//scenario text for diffrent parts eg ending text.
void Locations::startlocation() //my starting scenario
{
cout<<"Finally"<< endl;
sleep(1);
// i use sleep throughout my code.
// it freezes the screen for certain amount of time
Speeches::CLS();
cout<<"You're almost there"<< endl;
sleep(1);
Speeches::CLS();
cout<<"You can see the golden sand down below"<< endl;
sleep(1);
Speeches::CLS();
cout<<"BUT"<< endl;
sleep(1);
Speeches::CLS();
cout<<"You're on a edge of clif and beach is down below"<< endl;
sleep(1);
Speeches::CLS();
cout<<"You go to an old campsite you see"<< endl;
sleep(1);
Speeches::CLS();
cout<<"Lucky you"<< endl;
sleep(1);
Speeches::CLS();
cout<<"The people seem to have forgotten 3 potions in a box"<< endl;
sleep(3);
Speeches::CLS();
cout<<"There seems to be a attack, defense & health potion"<< endl;
cout<<"But you can only take one without the rest breaking "<< endl;
sleep(5);
cout<<"Choose wisely"<< endl;
sleep(5);
Speeches::CLS();
}
void Locations::finishlocation() // my ending scenario. once they finished
{
cout<<"HURRAH"<< endl;
sleep(1);
Speeches::CLS();
cout<<" you got the ship working \n"<< endl;
sleep(1);
cout<<"you get into the driver seat and press the start button"<<endl;
sleep(3);
Speeches::CLS();
cout<<"The flight deck powers up"<< endl;
sleep(1);
cout<<"everything is runing fine"<<endl;
sleep(1);
Speeches::CLS();
cout<<"THANK GOD"<<endl;
sleep(1);
Speeches::CLS();
cout<<"The destination cordinate have been preset \n"<<endl;
sleep(1);
cout<<" It reads the moon \n"<<endl;
sleep(1);
cout<<" look's like your going to the moon \n"<<endl;
sleep(3);
Speeches::CLS();
cout<<" You press the launch button"<<endl;
sleep(1);
cout<<" 5 \n"<<endl;
sleep(1);
cout<<" 4 \n"<<endl;
sleep(1);
cout<<" 3 \n"<<endl;
sleep(1);
cout<<" 2 \n"<<endl;
sleep(1);
cout<<" 1 \n"<<endl;
sleep(1);
cout<<" LIFT OFF \n"<<endl;
Speeches::CLS();
sleep(2);
cout<<"Its gonna be a while until you reach your \n"<<endl;
cout<<" destination \n"<<endl;
sleep(2);
cout<<" sit back and enjoy the view"<<endl;
Speeches::CLS();
sleep(3);
cout<<" 3 hours later \n"<<endl;
sleep(1);
cout<<" you land on the moon"<<endl;
}
void Locations::middle_event() //before battlesystem text
{
cout<<"Now that you're all patched up,"<< endl;
cout<<"you look around for a way down to the beach"<< endl;
sleep(5);
Speeches::CLS();
cout<<"you see worn down path to the bottom near by"<< endl;
cout<<"But, there is a huge problem"<<endl;
sleep(5);
Speeches::CLS();
cout<<"From the distance you can see an enemy,"<< endl;
cout<<" at the start of the path"<<endl;
cout<<" CRAP"<<endl;
sleep(5);
Speeches::CLS();
cout<<"You can't go back"<< endl;
sleep(1);
cout<<" Not this far in"<< endl;
sleep(10);
Speeches::CLS();
cout<<" You decide to continue"<< endl;
sleep(4);
cout<<"But, you have come with 3 plans to"<<endl;
cout<<" deal with this foe"<<endl;
sleep(5);
Speeches::CLS();
cout<<" Plan1"<< endl;
cout<<"Charge staright at him"<<endl;
sleep(3);
cout<<" Plan2"<< endl;
cout<<"Try to sneak past him"<<endl;
sleep(3);
cout<<" Plan3"<< endl;
cout<<"Hid in bush and wait"<<endl;
cout<<" for him to pass"<<endl;
sleep(8);
Speeches::CLS();
}
// the diffrent plans are three paths that lead to the fight
void Locations::middle_plan1()
{
cout << "your running straight at him" << endl;
}
void Locations::middle_plan2()
{
cout << "sneak past but got caught and he damaged you" << endl;
DataBase::modifyPlayerHealth(DataBase::playerID, -5);
//using other member sql function
}
void Locations::middle_plan3()
{
cout << "tried to hid but damaged by thrones and spikes in a bush" << endl;
cout<<" and were found out"<<endl;
DataBase::modifyPlayerHealth(DataBase::playerID, -5);
}
void Locations::afterbattle() //text which introduces you to the buildings
{
cout<<" That was close"<< endl;
sleep(1);
Speeches::CLS();
cout<<" BUT YOU DID IT"<<endl;
sleep(0.5);
cout<<" HURRAH"<<endl;
sleep(0.5);
cout<<" HURRAH"<<endl;
Speeches::CLS();
sleep(1);
cout<<" But there is no time to stop now"<<endl;
sleep(2);
Speeches::CLS();
cout<<" you make it to beach"<< endl;
sleep(1);
Speeches::CLS();
cout<<" warm golden sand at your feet"<< endl;
sleep(1);
cout<<" the telepathic sounds of the waves "<<endl;
sleep(0.5);
cout<<" there is alot of work to do"<<endl;
Speeches::CLS();
sleep(1);
cout<<" At the beach you can see 3 building structures & a spaceship \n"<< endl;
sleep(1);
cout<<" - lighthouse \n"<<endl;
sleep(0.5);
cout<<" - beachhouse \n"<<endl;
sleep(0.5);
cout<<" - brokenchapel \n"<<endl;
sleep(0.5);
cout<<" - spaceship \n"<<endl;
}
void Locations::lighthouse1()
{
}
void Locations::beachhouse1()
{
cout << "beach house 1 with thick vines blocking bedroom" << endl;
}
void Locations::beachhouse2()
{
cout << "beach house 2 bedroom contains key" << endl;
}
void Locations::brokenchapel1()
{
cout << "broken down chapel descriptionc with locked room" << endl;
}
void Locations::brokenchapel2()
{
cout << "open locked room and find engine chip" << endl;
}
void Locations::spaceship()
{
cout << "spaceship with missing engine chip" << endl;
}
void Locations::spaceship2()
{
cout << "fixed spaceship" << endl;
}
//all the different locations you can visit at the beach.
//different locations have sql for obtaining and using objects
int Beachlocations::lighthouse() //lighthouse location
{
Speeches::CLS();
cout << "You're at the lighthouse but it would be advantages to make it to the top"<< endl;
sleep(1);
cout<<" up the stairs you go \n"<<endl;
sleep(0.5);
cout<<" climbing \n"<<endl;
sleep(0.5);
cout<<" and \n"<<endl;
cout<<" climbing \n"<<endl;
sleep(0.5);
cout<<" and \n"<<endl;
cout<<" running \n"<<endl;
sleep(0.5);
cout<<" and \n"<<endl;
cout<<" hoping \n"<<endl;
sleep(0.5);
cout<<" and \n"<<endl;
cout<<" huffing \n"<<endl;
sleep(0.5);
cout<<" and \n"<<endl;
cout<<" puffing \n"<<endl;
Speeches::CLS();
sleep(0.5);
cout<<" you make it to the top \n"<<endl;
sleep(0.5);
cout<< " light work!"<<endl;
sleep(0.5);
Speeches::CLS();
cout<<" the view is beautiful at the top, the whole beach is so sharp and clear"<<endl;
cout<<" from this height"<<endl;
sleep(0.5);
cout<<" not much up here though, other than a sharp long machetein the middle "<<endl;
cout<<" of the room"<<endl;
sleep(0.5);
cout<<" what would you like to do"<<endl;
Beachlocations beachobject;
//giving the class an object to use later.
Speeches speobject;
//giving Speeches class an object
string lighthousechoice;
nextchoice:
/*nextchoice is point where users
* return to when a mistake is made*/
cin >> lighthousechoice;
//choices at the lighthouse
if (lighthousechoice == "pick up machete")
{
DataBase::assignMachete(DataBase::playerID);
//assigning machete to player as they picked it up.
cout << "picked up machete" << endl;
goto nextchoice;
}
else if(lighthousechoice == "beachhouse")
{
beachobject.bhouse();
}
else if(lighthousechoice == "brokenchapel")
{
beachobject.bchapel();
}
else if(lighthousechoice == "spaceship")
{
beachobject.sship();
}
else{
speobject.wrong();
speobject.hint3();
speobject.hint1();
speobject.hint2();
goto nextchoice;
}
}
int Beachlocations::bhouse()
{
Speeches::CLS();
Beachlocations beachobject;
Speeches speobject;
cout << " your at the beachhouse. It seems to quite damaged" << endl;
sleep(0.5);
cout << " the inside is quite empty, not much other than a few sofas" << endl;
cout << " looks like the previous owners are long gone \n" << endl;
sleep(0.5);
cout << " you search the house and found nothing useful" << endl;
cout << " but \n" << endl;
sleep(0.5);
cout << " 1 of the bedroom door is blocked by thick vines" << endl;
sleep(0.5);
cout << " looks like you need somthing sharp to cut the vines \n" << endl;
Speeches::CLS();
string beachhouseoption;
nextchoice1:
cin >> beachhouseoption;
if (beachhouseoption == "use machete")
{
if (DataBase::checkForMachete(DataBase::playerID))
//checking if playerID has machete assigned
{
cout << " you cut down the vines using the machete" << endl;
cout << " and gaines accsess to the bedroom \n" << endl;
sleep(0.5);
cout << " again not much inside" << endl;
cout << " but there are some keys on the night stand" << endl;
string beachhousekey;
rechoice:
cin >> beachhousekey;
if (beachhousekey == "pick up keys")
{
DataBase::assignKey(DataBase::playerID);
//assigning key to playerID
cout << "keys picked up" << endl;
cout << " whats next" << endl;
goto nextchoice1;
}
else {
speobject.wrong();
speobject.hint3();
speobject.hint1();
speobject.hint2();
goto rechoice;
}
}
else if(beachhouseoption == "lighthouse")
{
beachobject.lighthouse();
}
else if(beachhouseoption == "brokenchapel")
{
beachobject.bchapel();
}
else if(beachhouseoption == "spaceship")
{
beachobject.sship();
}
else {
speobject.wrong();
speobject.hint3();
speobject.hint1();
speobject.hint2();
goto nextchoice1;
}
}
}
int Beachlocations::bchapel()
{
Speeches::CLS();
cout << " your at the chapel. It seems very old" << endl;
sleep(0.5);
cout << " There is a locked room. Seems like you need keys" << endl;
Beachlocations beachobject;
Speeches speobject;
string brokenchapeloption;
nextchoice2:
cin >> brokenchapeloption;
if (brokenchapeloption == "use key")
{
if (DataBase::checkForKey(DataBase::playerID)) {
cout << " you gained accsess to the room using the key you found earlier" << endl;
cout << " looks like it was the priest living quaters \n" << endl;
sleep(0.5);
cout << " you search the room" << endl;
cout << " and see there is a chip whick looks like it would fit a spaceship" << endl;
string bchapelkey;
rechoice1:
cin >> bchapelkey;
if (bchapelkey == "pick up chip") {
DataBase::assignChip(DataBase::playerID);
//calling my sql function
// assigning the chip to player once they picked it up
cout << "chip picked up" << endl;
cout << " whats next" << endl;
goto nextchoice2;
}
else {
speobject.wrong();
speobject.hint3();
speobject.hint1();
speobject.hint2();
goto rechoice1;
}
}
}
else if(brokenchapeloption == "lighthouse") {
beachobject.lighthouse();
}
else if(brokenchapeloption == "beachhouse") {
beachobject.bhouse();
}
else if(brokenchapeloption == "spaceship") {
beachobject.sship();
}
else {
speobject.wrong();
speobject.hint3();
speobject.hint1();
speobject.hint2();
}
}
int Beachlocations::sship()
{
Speeches::CLS();
cout << " there is spaceship but it does not start" << endl;
cout << "it seems like it is missing a chip in the engine" << endl;
//ginving all of my other classes an object
Beachlocations beachobject;
Speeches speobject;
Locations locobject;
string sshipoption;
nextchoice3:
cin >> sshipoption;
if (sshipoption == "use chip")
{
if (DataBase::checkForChip(DataBase::playerID)){
//calling my sql function
//checking if chip is assigned to player
retry3:
cout << "spaceship fixed do you wan to use spacship" << endl;
string fixedsship;
cin >> fixedsship;
if (fixedsship == "yes"){
locobject.finishlocation();
// this is where my code ends
}
else if(fixedsship == "no"){
goto nextchoice3;
}
else{
speobject.wrong();
speobject.hint6();
goto retry3;
}
}
else {
cout<<" no chip found try looking in other locations"<<endl;
goto nextchoice3;
}
}
else if(sshipoption == "lighthouse"){
beachobject.lighthouse();
}
else if(sshipoption == "beachhouse"){
beachobject.bhouse();
}
else if(sshipoption == "spaceship"){
beachobject.sship();
}
else{
speobject.wrong();
speobject.hint3();
speobject.hint1();
speobject.hint2();
}
}