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 <string>
#include <vector>
#include <fstream>
#include <climits>
#include <locale>
#include <ctype.h>
#include <iostream>
#include <cstdlib>
#include <unistd.h> //sleepfunction
#include <math.h>
#include "libsqlite.hpp"
#include "database.cpp"
using namespace std;
int playerID; //character ID variable
void clrS() //clear screen funtion
{
system("clear");
}
class naratives //class created for error messages
{
public: //class is made public to be used outside clss
void wrong1()
{
cout << "Thats was an awful error. Please try again. "<< endl;
}
void hint_1()
{
cout << "HINT type ' pick up item name' to save item for later use" << endl;
}
void hint_2()
{
cout << " HINT type 'use item name' to use a previous stored item" << endl;
}
void hint_3()
{
cout << " Do you want to explore? if so type the name of the location" << endl;
cout << "e.g. type in 'kitchen' to travel the location kitchen." << endl;
}
void hint_4()
{
cout << "Poition type?" << endl;
cout << " e.g. type 'defence' for defence potion" << endl;
}
void hint_5()
{
cout << "There are 3 plans which are created available. \n"
<< "To travel using a specific plan type: \n"
cout << "e.g. 'plan2" << endl;
}
void hint_6()
{
cout << "typeIn 'yes' or 'no'" << endl;
}
};
class locations //different senario test for each locations.
{
public: //made public to access outside class
void start_location() //new funtion for location story begining
{
clrs();
cout << "________________________________________________________________" << endl;
cout << "<<<< Hello. >>>>>>> \n" << endl;
sleep(2);
cout<< "<<<< Welcome. >>>>>>> \n"
"<<<< To the GRAND____Castle. >>>>>>> \n" << endl;
sleep(2);
cout<<"<<<<< The weather here is a little... \n" << endl;
sleep(2);
cout<<"<<<<< ermmm......\n " << endl;
sleep(3);
cout<<"<<<<< unforgiving... >>>>>> \n" << endl;
sleep(2);
cout<<"<<<<< You don't want to be here at the Castle... \n" << endl;
sleep(3);
cout<<"<<<< espacially during the night.\n" << endl;
sleep(3);
clrs();
}
void ending_location()
{
clrs();
cout << "Wow you finaly got the spaceship working!!!\n " << endl;
sleep(2);
cout << "Wasn't that a crazy Journey!!!\n" << endl;
sleep(2);
cout << "one little heads up... \n"<< endl;
sleep(2);
cout << "This isn't actually the end... \n"<< endl;
sleep(2);
clrs();
cout << "You get into the spaceship... \n"<<endl;
cout << "The spaceship makes a loud sound\n"<< endl;
sleep(2);
cout << "**BLEEP**\n"<< endl;
sleep(1);
cout << "**BLEEP**\n"<< endl;
sleep(3);
cout << "**BLEEP**\n"<< endl;
sleep(1);
cout << "**BLEEP**\n"<< endl;
sleep(3);
cout << "The next destination is shown on the screen\n" << endl;
sleep(2);
cout << "Spaceship displays *** NEXT Destination is THE WOODS!!! *** \n"<< endl;
sleep(3);
cout << "Off & Awayyyy\n" << endl;
}
void middle_event()
{
clrs();
cout << "You are not afarid and want to check out this 'Grand Castle',\n" << endl;
sleep(2);
cout << "You hear a small sound of someone talking. \n" << endl;
sleep(2);
cout << "You walk closer to the sound.\n" << endl;
sleep(2);
cout << "It's 2 Soldiers Guarding the door!!!.\n" << endl;
sleep(2);
cout << "You want to get past the solidiers through to the door.\n" << endl;
sleep(2);
cout << "You come up with 3 plans... \n" << endl;
sleep(3);
clrs();
cout << "<<<<< PLAN 1 >>>>>\n" << endl;
sleep(2);
cout << "Go Directly towards the Soldiers. \n" << endl;
sleep(2);
clrs();
cout << "<<<<< PLAN 2 >>>>>\n" << endl;
sleep(2);
cout << "Try to Sneak Past the Soldiers.\n" << endl;
sleep(2);
clrs();
cout << "<<<<< PLAN 3 >>>>>\n" << endl;
sleep(1);
cout << "Hide behind the wall and wait until they leave to go through the door. \n" << endl;
sleep(6);
cout << "But... \n" << endl;
clrs();
cout << "You won't know if they will leave... \n" << endl;
sleep(2);
cout << "You might end up waiting for a very long time... \n" << endl;
sleep(2);
}
void middle_plan1()//
{
clrs();
cout << "You have decided to Go Directly to the Soildiers.\n"<< endl;
sleep(4);
cout << "You are walking towards the Soldiers"<< endl;
sleep(2);
}
void middle_plan2()
{
clrs();
cout << "You have decied to sneak your way into the castle... " << endl;
sleep(2);
cout << "Good Luck!! "<< endl;
sleep(1);
cout << "You'll need it.\n"<< endl;
sleep(2);
clrs();
cout << "You are trying to sneak past the Soldiers. \n"<< endl;
sleep(2);
clrs();
cout << "OH NO!!" << endl;
sleep(1);
cout << "Soildiers Caught YOU!!\n" << endl;
sleep(2);
//DataBase::modifyPlayerHealth(playerID, -5); //lost -5 on health
}
void middle_plan3()
{
clrs();
cout << "You have decided to Hide yourself and\n"
"wait untill the Soldiers have left." << endl;
sleep(2);
clrs();
cout << "You are hiding behind the wall. "<< endl;
sleep(3);
clrs();
cout << "You got caught by one of the soildiers. "<< endl;
sleep(2);
//DataBase::modifyPlayerHealth(playerID, -5);
}
void after_battle()//Room Introduction
{
clrs();
cout << "You got Inside!!..."<< endl;
cout << "Now the real adventure starts."<< endl;
}
void kitchen()
{
clrs();
cout << "The kitchem has has a Machete. \n"<< endl;
}
void livingroom1()
{
cout << "Living room has a lot of plants. \n" << endl;
}
void Livingroom2()
{
cout << "Living room contain some keys. \n" << endl;
}
void bedroom1()
{
cout << "Bedroom containing a wardrobe that is locked. \n" << endl;
}
void bedroom2()
{
cout << "Bedroom contains some keys. \n " << endl;
}
void spaceship1()
{
cout << "Spaceship not turning on, missing key. \n" << endl;
}
};
class location_castle // all the location that can be visited from the Castle location
{
public:
int kitchen()
{
location_castle castle_objt; //giving the class location_castle an object to use later
naratives n_objt.; //giving class naratives an object
string kitchen_choice; //variable kitchen_choice in datatype string
nextchoice:
/* nextchoice is used for when users
* need to return to a point they made a mistake */
cin >> kitchen_choice; //different choices in the kitchen
if (kitchen_choice == "pick up machete")
{
cout << DataBase::assignMachete()<< endl;
cout << "Picked up Machete "<< endl;
goto nextchoice;
}
else if(kitchen_choice == "livingroom")
{
castle_objt.living_room();
}
else if(kitchen_choice == "bedroom")
{
castle_objt.bed_room();
}
else if(kitchen_choice == "spaceship")
{
castle_objt.sship();
}
else
{
n_objt.wrong1();
n_objt.hint_3();
n_objt.hint_1();
n_objt.hint_2();
goto nextchoice;
}
}
int living_room()
{
location_castle castle_objt;
naratives n_objt;
cout << << endl;
string livingrm_choice;
nextchoice1:
cin >> livingrm_choice;
if (livingrm_choice == "use machete")
{
if (DataBase::checkForMachete(playerID))
{
cout << "using the Machete you cut throught the grown leave into the bedroom." << endl;
cout << "Found a set if Key\n" << endl;
cout << "bedroom contains a key" << endl;
string livingrmkey;
rechoice:
cin >> livingrmkey;
if(livingrmscrew == "take Keys")
{
DataBase::assignKey(playerID);
}
}
cout << "Keys taken" << endl;
goto nextchoice1;
}
else if (livingrm_choice == "kitchen")
{
castle_objt.kitchen();
}
else if(livingrm_choice == "bedroom")
{
castle_objt.bed_room();
}
else if(livingrm_choice == "spaceship")
{
castle_objt.sship();
}
else
{
n_objt.wrong1();
n_objt.hint_3();
n_objt.hint_1();
n_objt.hint_2();
}
}
}
int bed_room()
{
cout << "Bedroom with a locked wardrobe" << endl;
location_castle castle_objt;
naratives n_objt;
string bedroom_choice;
nextchoice2;
cin >> bedroom_choice;
if(bedroom_choice == "use Key")
{
DataBase::checkForKey(playerID);
cout << "Bedroom contains the key for locked wardrobe. " << endl;
string bedrm_warkey;
rechoice:
cin >> (bedrm_warkey == "pick up keys")
{
Database::assignKey(playerID);
}
cout << "picked up the keys" << endl;
goto nextchoice2;
}
else if (bedroom_choice == "livingroom")
{
castle_objt.living_room();
}
else if(bedroom_choice == "kitchen")
{
castle_objt.kitchen();
}
else if(bedroom_choice == "spaceship")
{
castle_objt.sship();
}
else
{
n_objt.wrong1();
n_objt.hint_3();
n_objt.hint_1();
n_objt.hint_2();
}
}
int sship()
{
cout << "A key is needed to make this spaceship work. " << endl;
location_castle castle_objt;
naratives n_objt;
locations l_objt;
string sshipchoice;
nextchoice3;
cin >> sshipchoice;
if(sshipchoice == "use Key")
{
cout << "checking for key in Database....\n" << endl;
sleep(4);
Database::checkForKey(playerID);
retry3:
cout << "spaceship is fixed //////// wan to use spaceship? \n" << endl;
string secureship;
cin >> securesship;
if (securesship == "yes")
{
l_objt.ending_location();
}
else if(securesship == "no")
{
goto nextchoice3;
}
else
{
n_objt.wrong1();
n_objt.hint_6();
goto retry3;
}
else if(sshipchoice == "kitchen")
{
castle_objt.kitchen();
}
else if(sshipchoice == "livingroom")
{
castle_objt.living_room();
}
else if(sshipchoice == "bedroom")
{
castle_objt.bed_room();
}
else
{
n_objt.wrong1();
n_objt.hint_3();
n_objt.hint_1();
n_objt.hint2();
}
}
};
int main()
{
int playerID;
location_castle castle_objt;
locations l_objt;
l_objt.start_location();
naratives n_objt;
n_objt.hint_4();
retry:
string choose_potion;
cin >> choose_potion:
if(choose_potion == "health")
{
DataBase::modifyPlayerHealth(charID, 50);
cout << "Health has been leveled up" << endl;
}
else if(choose_potion == "attack")
{
DataBase::modifyPlayerAttack(charID, 10);
cout << "Attack power has increased" << endl;
}
else if(choose_potion == "defence")
{
DataBase::modifyPlayerDefense(charID, 10)
cout << "Your defending power has incresed" << endl;
}
else
{
n_objt.wrong1();
n_objt,hint_4();
goto retry;
}
l_objt.middle_event();
n_objt.hint_5();
retry2:
string middle_event;
cin>> middle_event;
if(middle_event == "plan1")
{
l_objt.middle_plan1();
}
else if (middle_event == "plan2")
{
l_objt.middle_plan2();
DataBase::modifyPlayerHealth(charID, -20)
count << "Health has decreased by -20" << endl;
}
else if(middle_event == "plan3")
{
l_objt.middle_plan3();
DataBase::modifyPlayerHealth(charID, -10)
cout << "Health has decreased by -10" << endl;
}
else
{
n_objt.wrong1();
n_objt.hint_5();
goto retry2;
}
cout << "fighting options available here... " << endl;
l_objt.after_battle();
string select_location;
retry4:
cin >> select_location;
if (select_location == "kitchen")
{
castle_objt.kitchen();
}
else if(select_location == "livingroom")
{
castle_objt.living_room();
}
else if(select_location == "bedroom")
{
castle_objt.bed_room();
}
else if(select_location == "spaceship")
{
castle_objt.sship();
}
else
{
n_objt.wrong1();
n_objt.hint_3();
goto retry4;
}
return 0;
}