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 "desert_story_alicja.h"
#include "database.h"
#include "hamza.h"
#include "shuvas.h"
#include "miles.h"
#include "libsqlite.hpp"
#include <iostream>
#include <string>
#include <unistd.h> //included for sleep function
#include <stdlib.h> /* srand, rand */
#include <ctime>
#include "character.h"
#include <climits>
using namespace std;
void CLS() {
system("clear");
}
int main() {
//start of Miles' code
string PlayerN;
string Enemy;
string Enemy02;
string Boss;
string YN; // Sigh...
int pouch;
system("clear");
cout << " \n";
cout << " ==========================================" << endl;
cout << " " << endl;
cout << " SECOND BRAVES: THE WAR BELL TOLLS " << endl;
cout << " " << endl;
cout << " ==========================================\n";
Miles::pausing();
string name;
cout << "Enter the name of your character: ";
cin >> name;
Character user(name);
PlayerN = user.getName();
DataBase::registerPlayer(name);
//database
CLS();
Miles::interlude();
sleep(2);
Miles::story1(PlayerN);
//Right so the section below may look intimidating, but let me explain
//The Do-While Switch Loop is to increment two loops,
//The main loop is the first you see, while has the option to choose the weapons,
//The second is more about whether you want said-weapon.
//The second loop will break when you respond Yes or No.
//Saying Yes will break both loops as I have instructed,
//Saying No will sent the user back to the main loop (with the "goto" command).
//The Cin.fail doesn't seem to work as I wanted to, but it does the important bit,
//which is to prevent the loop from going beserk if the user is stupid enough to not follow basic instructions
//Weapon choice
do
{
again:
int weapon;
cout << "\nChoose your weapon: " << endl;
cout << "************" << endl;
cout << "* *" << endl;
cout << "* 1. Sword *" << endl;
cout << "* 2. Axe *" << endl;
cout << "* 3. Lance *" << endl;
cout << "* *" << endl;
cout << "************" << endl;
cin >> weapon;
while (cin.fail()) //Meant to catch the wrong type and ignore it
{
cin.ignore(INT_MAX, 0);
cin.clear();
cin.get();
}
switch(weapon)
{
case 1:
{
cout << "\nThis is the Crafted Sword," << endl;
cout << "Very high on Attack, but low on Defense!\n";
cout << "Do you want to choose this weapon? (Y/N)" << endl;
cin >> YN;
if (YN == "Y")
{
int A = 3;
int D = 1;
user.setBonus(A,D);
cout << "\nYou chose the Crafted Sword!" << endl;
CLS();
break;
}
else
{
CLS();
goto again;
}
}
case 2:
{
cout << "\nThis is the Crafted Axe," << endl;
cout << "It has balanced Attack and Defense!\n";
cout << "Do you want to choose this weapon? (Y/N)" << endl;
cin >> YN;
if (YN == "Y")
{
int A = 2;
int D = 2;
user.setBonus(A,D);
cout << "\nYou chose the Crafted Axe!" << endl;
break;
}
else
{
goto again;
}
}
case 3:
{
cout << "\nThis is the Crafted Lance," << endl;
cout << "Very high Defense, but low on Attack!\n";
cout << "Do you want to choose this weapon? (Y/N)" << endl;
cin >> YN;
if (YN == "Y")
{
int A = 2;
int D = 2;
user.setBonus(A,D);
cout << "\nYou chose the Hero Lance!" << endl;
break;
}
else
{
goto again;
}
}
default:
{
cout << "\nChoose a weapon, BASED ON THE NUMBERS AVAILABLE!" << endl;
goto again;
}
}
} while (YN != "Y");
//story and event
Miles::story2(PlayerN);
//battle
string N1;
int EA1;
int ED1;
N1 = "Shadow Armour";
ED1 = 1;
EA1 = 0;
Character Enemy1 (N1);
Enemy = Enemy1.getName();
Enemy1.levelMatch(user.getLevel() + 2);
Enemy1.setBonus(EA1, ED1);
sleep(2);
checkpoint1:
cout << "A wild " << Enemy1.getName() << " is challenging you to battle!" << endl;
sleep(2);
//battle system
do
{
back:
CLS();
int choice;
cout << "\nWhat do you want to do?" << endl;
cout << "* 1. Attack *" << endl;
cout << "* 2. Guard *" << endl;
cout << "* 3. Brave *" << endl;
cout << "* 4. Potions x"<< user.getItem() << " *" << endl;
cout << "***********************" << endl;
cout << "* " << PlayerN << ": " << user.getHealth() << "/" << user.getHPThres() << " HP" << endl;
cout << "***********************" << endl;
cout << "* " << Enemy << ": " << Enemy1.getHealth() << "/" << Enemy1.getHPThres() << " HP" << endl;
cout << "***********************" << endl;
cin >> choice;
while (cin.fail()) //Meant to catch the wrong type and ignore it
{
cin.clear();
cin.ignore(INT_MAX, 1);
cin.get();
}
switch (choice)
{
//BASE ATTACK!!
case 1:{
int BattleDamage;
int EnemyDamage;
int RNG;
//Damage calculator && damage function for HP display!
BattleDamage = round(user.getAttack() - Enemy1.getDefense()); //Fire Emblem, saving lives ever since 1996
Enemy1.damage(BattleDamage);
cout << "You attacked the foe! You did " << BattleDamage << " of damage!" << endl;
sleep(1);
//If the enemy died in that hit
if (Enemy1.getHealth() <= 0)
{
int lvl = rand() % 100+50;
int mny = (user.getHealth() + Enemy1.getLevel() + Enemy1.getAttack() + Enemy1.getDefense()) * 10;
user.levelUp(lvl);
user.MoneyGain(mny);
cout << "Great! You defeated the " << Enemy1.getName() << "!" << endl;
cout << "You earned " << lvl << " of EXP!" << endl;
cout << "Your munny pouch now has ¥" << user.getMoney() << "!"<< endl;
sleep(1);
break;
}
//If the enemy did not died in that hit
else
{
RNG = rand() % 10+1;
if (RNG <= 9){
EnemyDamage = round(Enemy1.getAttack() - user.getDefense());
user.damage(EnemyDamage);
//Capped the damage to one, so there's always a successful hit
if (EnemyDamage <= 0){
cout << "The foe attacked back! The foe did " << 1 << " of damage!" << endl;
}
else{
cout << "The foe attacked back! The foe did " << EnemyDamage << " of damage!" << endl;
}
//If you died during the enemy's attack
if (user.getHealth() <= 0){
string Continue;
cout << "You fainted..!" << endl;
cout << "Do you wish to continue? (Y/N)" << endl;
cin >> Continue;
if (Continue == "Y"){
cout << "You chose to continue!" << endl;
sleep(1);
user.HealthRestore(user.getHPThres());
Enemy1.HealthRestore(Enemy1.getHPThres());
goto checkpoint1;
}
else if (Continue == "N"){
cout << " - GAME OVER -";
return 0;
}
else{
cout << "Since you failed to answer Y/N\n - GAME OVER - " << endl;
return 0;
}
}
}
else{
EnemyDamage = round(user.getAttack() - Enemy1.getDefense()) * 3;
user.damage(EnemyDamage);
cout << "The foe did a critical hit! You lost " << EnemyDamage << " of Hit Points." << endl;
//If you died during the enemy's attack
if (user.getHealth() <= 0){
string Continue;
cout << "You fainted..!" << endl;
cout << "Do you wish to continue? (Y/N)" << endl;
cin >> Continue;
if (Continue == "Y"){
cout << "You chose to continue!" << endl;
sleep(1);
goto checkpoint1;
}
else if (Continue == "N"){
cout << " - GAME OVER -";
return 0;
}
else{
cout << "Since you failed to answer Y/N\n - GAME OVER - " << endl;
return 0;
}
}
}
}
sleep(1);
break;
}
//GUARD SYSTEM!
case 2:{
int EnemyDamage;
int RNG;
cout << "You used Guard" << endl;
sleep(1);
cout << "The foe couldn't break through!"<< endl;
sleep(1);
break;
}
//BRAVE SYSTEM!
case 3:{
int BattleDamage;
int EnemyDamage;
int RNG;
cout << "You embrace for a hit!" << endl;
sleep(1);
RNG = rand() % 10+1;
if (RNG <= 9){
EnemyDamage = round(Enemy1.getAttack() - user.getDefense());
user.damage(EnemyDamage);
//Capped the damage to one, so there's always a successful hit
if (EnemyDamage <= 0){
cout << "The foe attacked! The foe did " << 1 << " of damage!" << endl;
}
else{
cout << "The foe attacked! The foe did " << EnemyDamage << " of damage!" << endl;
}
}
else{
EnemyDamage = round(user.getAttack() - Enemy1.getDefense()) * 3;
user.damage(EnemyDamage);
cout << "The foe did a critical hit! You lost " << EnemyDamage << " of Hit Points." << endl;
}
sleep(1);
//Damage calculator && damage function for HP display!
BattleDamage = round(user.getAttack() - Enemy1.getDefense()) * 3;
Enemy1.damage(BattleDamage);
cout << "You unleashed a Brave attack, doing a whooping " << BattleDamage << " of damage!" << endl;
sleep(1);
if (Enemy1.getHealth() <= 0){
int lvl = rand() % 100+50;
int mny = (Enemy1.getHealth() + Enemy1.getLevel() + Enemy1.getAttack() + Enemy1.getDefense()) * 13;
user.levelUp(lvl);
user.MoneyGain(mny);
cout << " " << endl;
cout << "Great! You defeated the " << Enemy1.getName() << "!" << endl;
cout << "You earned " << lvl << " of EXP!" << endl;
cout << "Your munny pouch now has ¥" << user.getMoney() << "!"<< endl;
sleep(1);
break;
}
else{
RNG = rand() % 10+1;
if (RNG <= 9){
EnemyDamage = round(Enemy1.getAttack() - user.getDefense());
user.damage(EnemyDamage);
//Capped the damage to one, so there's always a successful hit
if (EnemyDamage <= 0){
cout << "The foe attacked! The foe did " << 1 << " of damage!" << endl;
}
else{
cout << "The foe attacked! The foe did " << EnemyDamage << " of damage!" << endl;
}
//If the player died during the enemy's attack
if (user.getHealth() <= 0){
string Continue;
cout << "You fainted..!" << endl;
cout << "Do you wish to continue? (Y/N)" << endl;
cin >> Continue;
if (Continue == "Y"){
cout << "You chose to continue!" << endl;
sleep(1);
user.HealthRestore(user.getHPThres());
Enemy1.HealthRestore(Enemy1.getHPThres());
goto checkpoint1;
}
else if (Continue == "N"){
cout << " - GAME OVER -";
return 0;
}
else{
cout << "Since you failed to answer Y/N\n - GAME OVER - " << endl;
return 0;
}
}
}
else{
EnemyDamage = round(user.getAttack() - Enemy1.getDefense()) * 3;
user.damage(EnemyDamage);
cout << "The foe did a critical hit! You lost " << EnemyDamage << " of Hit Points." << endl;
//If you died during the enemy's attack
if (user.getHealth() <= 0){
string Continue;
cout << "You fainted..!" << endl;
cout << "Do you wish to continue? (Y/N)" << endl;
cin >> Continue;
if (Continue == "Y"){
cout << "You chose to continue!" << endl;
user.HealthRestore(user.getHPThres());
Enemy1.HealthRestore(Enemy1.getHPThres());
sleep(1);
goto checkpoint1;
}
else if (Continue == "N"){
cout << " - GAME OVER -";
return 0;
}
else{
cout << "Since you failed to answer Y/N\n - GAME OVER - " << endl;
return 0;
}
}
}
sleep(1);
}
break;
}
//ITEM SYSTEM!!
case 4:{
int RNG;
int EnemyDamage;
cout << "You don't have any items" << endl;
sleep(1);
RNG = rand() % 10+1;
if (RNG <= 9){
EnemyDamage = round(Enemy1.getAttack() - user.getDefense());
user.damage(EnemyDamage);
//Capped the damage to one, so there's always a successful hit
if (EnemyDamage <= 0){
cout << "The foe attacked back! The foe did " << 1 << " of damage!" << endl;
sleep(1);
}
else{
cout << "The foe attacked back! The foe did " << EnemyDamage << " of damage!" << endl;
sleep(1);
}
//If you died during the enemy's attack
if (user.getHealth() <= 0){
string Continue;
cout << "You fainted..!" << endl;
sleep(1);
cout << "Do you wish to continue? (Y/N)" << endl;
cin >> Continue;
if (Continue == "Y"){
cout << "You chose to continue!" << endl;
sleep(1);
user.HealthRestore(user.getHPThres());
Enemy1.HealthRestore(Enemy1.getHPThres());
goto checkpoint1;
}
else if (Continue == "N"){
cout << " - GAME OVER -";
return 0;
}
else{
cout << "Since you failed to answer Y/N\n - GAME OVER - " << endl;
return 0;
}
}
}
else
{
EnemyDamage = round(user.getAttack() - Enemy1.getDefense()) * 3;
user.damage(EnemyDamage);
cout << "The foe did a critical hit! You lost " << EnemyDamage << " of Hit Points." << endl;
//If you died during the enemy's attack
if (user.getHealth() <= 0){
string Continue;
cout << "You fainted..!" << endl;
cout << "Do you wish to continue? (Y/N)" << endl;
cin >> Continue;
if (Continue == "Y"){
cout << "You chose to continue!" << endl;
user.HealthRestore(user.getHPThres());
Enemy1.HealthRestore(Enemy1.getHPThres());
sleep(1);
goto checkpoint1;
}
else if (Continue == "N"){
cout << " - GAME OVER -";
return 0;
}
else{
cout << "Since you failed to answer Y/N\n - GAME OVER -\n " << endl;
return 0;
}
}
break;
}
}
//Ignorance is Bliss
default:{
cout << "\nChoose an option, BASED ON THE NUMBERS AVAILABLE!" << endl;
goto back;
}
}
} while (Enemy1.getHealth() > 1);
//more story
//choices
//battle
string N2;
int EA2;
int ED2;
N2 = "Lance Shadow";
ED1 = 1;
EA1 = 2;
Character Enemy2 (N2);
Enemy02 = Enemy2.getName();
Enemy2.levelMatch(user.getLevel() + 2);
Enemy2.setBonus(EA1, ED1);
checkpoint2:
cout << "A wild " << Enemy02 << " is challenging you to battle!" << endl;
sleep(1);
//battle system
do
{
back2:
CLS();
int choice;
bool gSystem;
sleep(1);
cout << "\nWhat do you want to do?" << endl;
cout << "* 1. Attack *" << endl;
cout << "* 2. Guard *" << endl;
cout << "* 3. Brave *" << endl;
cout << "* 4. Potions x"<< user.getItem() << " *" << endl;
cout << "***********************" << endl;
cout << "* " << PlayerN << ": " << user.getHealth() << "/" << user.getHPThres() << " HP" << endl;
cout << "***********************" << endl;
cout << "* " << Enemy02 << ": " << Enemy2.getHealth() << "/" << Enemy2.getHPThres() << " HP" << endl;
cout << "***********************" << endl;
cin >> choice;
while (cin.fail()) //Meant to catch the wrong type and ignore it
{
cin.clear();
cin.ignore(INT_MAX, 1);
cin.get();
}
switch (choice)
{
//BASE ATTACK!!
case 1:{
int BattleDamage;
int EnemyDamage;
int RNG;
//Damage calculator && damage function for HP display!
BattleDamage = round(user.getAttack() - Enemy2.getDefense()); //Fire Emblem, saving lives ever since 1996
Enemy2.damage(BattleDamage);
cout << "You attacked the foe! You did " << BattleDamage << " of damage!" << endl;
sleep(1);
//If the enemy died in that hit
if (Enemy2.getHealth() <= 0)
{
int lvl = rand() % 100+50;
int mny = (user.getHealth() + Enemy2.getLevel() + Enemy2.getAttack() + Enemy2.getDefense()) * 10;
user.levelUp(lvl);
user.MoneyGain(mny);
cout << "Great! You defeated the " << Enemy02 << "!" << endl;
cout << "You earned " << lvl << " of EXP!" << endl;
cout << "Your munny pouch now has ¥" << user.getMoney() << "!"<< endl;
break;
}
//If the enemy did not die in that hit
else
{
RNG = rand() % 10+1;
if (RNG <= 9){
EnemyDamage = round(Enemy2.getAttack() - user.getDefense());
user.damage(EnemyDamage);
//Capped the damage to one, so there's always a successful hit
if (EnemyDamage <= 0){
cout << "The foe attacked back! The foe did " << 1 << " of damage!" << endl;
}
else{
cout << "The foe attacked back! The foe did " << EnemyDamage << " of damage!" << endl;
}
//If you died during the enemy's attack
if (user.getHealth() <= 0){
string Continue;
cout << "You fainted..!" << endl;
cout << "Do you wish to continue? (Y/N)" << endl;
cin >> Continue;
if (Continue == "Y"){
cout << "You chose to continue!" << endl;
sleep(1);
user.HealthRestore(user.getHPThres());
Enemy2.HealthRestore(Enemy2.getHPThres());
goto checkpoint1;
}
else if (Continue == "N"){
cout << " - GAME OVER -";
return 0;
}
else{
cout << "Since you failed to answer Y/N\n - GAME OVER - " << endl;
return 0;
}
}
}
else
{
EnemyDamage = round(user.getAttack() - Enemy2.getDefense()) * 3;
user.damage(EnemyDamage);
cout << "The foe did a critical hit! You lost " << EnemyDamage << " of Hit Points." << endl;
//If you died during the enemy's attack
if (user.getHealth() <= 0){
string Continue;
cout << "You fainted..!" << endl;
cout << "Do you wish to continue? (Y/N)" << endl;
cin >> Continue;
if (Continue == "Y"){
cout << "You chose to continue!" << endl;
sleep(1);
goto checkpoint1;
}
else if (Continue == "N"){
cout << " - GAME OVER -";
return 0;
}
else{
cout << "Since you failed to answer Y/N\n - GAME OVER - " << endl;
return 0;
}
}
}
}
sleep(1);
break;
}
//GUARD SYSTEM!
case 2:{
int EnemyDamage;
int RNG;
cout << "You used Guard" << endl;
sleep(1);
cout << "The foe couldn't break through!"<< endl;
sleep(1);
break;
}
//BRAVE SYSTEM!
case 3:{
int BattleDamage;
int EnemyDamage;
int RNG;
cout << "You embrace for a hit!" << endl;
sleep(1);
RNG = rand() % 10+1;
if (RNG <= 9){
EnemyDamage = round(Enemy2.getAttack() - user.getDefense());
user.damage(EnemyDamage);
//Capped the damage to one, so there's always a successful hit
if (EnemyDamage <= 0){
cout << "The foe attacked! The foe did " << 1 << " of damage!" << endl;
}
else{
cout << "The foe attacked! The foe did " << EnemyDamage << " of damage!" << endl;
}
}
else{
EnemyDamage = round(user.getAttack() - Enemy2.getDefense()) * 3;
user.damage(EnemyDamage);
cout << "The foe did a critical hit! You lost " << EnemyDamage << " of Hit Points." << endl;
}
sleep(1);
//Damage calculator && damage function for HP display!
BattleDamage = round(user.getAttack() - Enemy2.getDefense()) * 3;
Enemy2.damage(BattleDamage);
cout << "You unleashed a Brave attack, doing a whooping " << BattleDamage << " of damage!" << endl;
sleep(1);
if (Enemy2.getHealth() <= 0){
int lvl = rand() % 100+50;
int mny = (Enemy1.getHealth() + Enemy2.getLevel() + Enemy2.getAttack() + Enemy2.getDefense()) * 13;
user.levelUp(lvl);
user.MoneyGain(mny);
cout << " " << endl;
cout << "Great! You defeated the " << Enemy2.getName() << "!" << endl;
cout << "You earned " << lvl << " of EXP!" << endl;
cout << "Your munny pouch now has ¥" << user.getMoney() << "!"<< endl;
sleep(1);
break;
}
else{
RNG = rand() % 10+1;
if (RNG <= 9){
EnemyDamage = round(Enemy2.getAttack() - user.getDefense());
user.damage(EnemyDamage);
//Capped the damage to one, so there's always a successful hit
if (EnemyDamage <= 0){
cout << "The foe attacked! The foe did " << 1 << " of damage!" << endl;
}
else{
cout << "The foe attacked! The foe did " << EnemyDamage << " of damage!" << endl;
}
//If the player died during the enemy's attack
if (user.getHealth() <= 0){
string Continue;
cout << "You fainted..!" << endl;
cout << "Do you wish to continue? (Y/N)" << endl;
cin >> Continue;
if (Continue == "Y"){
cout << "You chose to continue!" << endl;
sleep(1);
user.HealthRestore(user.getHPThres());
Enemy2.HealthRestore(Enemy2.getHPThres());
goto checkpoint1;
}
else if (Continue == "N"){
cout << " - GAME OVER -";
return 0;
}
else{
cout << "Since you failed to answer Y/N\n - GAME OVER - " << endl;
return 0;
}
}
}
else{
EnemyDamage = round(user.getAttack() - Enemy2.getDefense()) * 3;
user.damage(EnemyDamage);
cout << "The foe did a critical hit! You lost " << EnemyDamage << " of Hit Points." << endl;
//If you died during the enemy's attack
if (user.getHealth() <= 0){
string Continue;
cout << "You fainted..!" << endl;
cout << "Do you wish to continue? (Y/N)" << endl;
cin >> Continue;
if (Continue == "Y"){
cout << "You chose to continue!" << endl;
user.HealthRestore(user.getHPThres());
Enemy1.HealthRestore(Enemy2.getHPThres());
sleep(1);
goto checkpoint2;
}
else if (Continue == "N"){
cout << " - GAME OVER -";
return 0;
}
else{
cout << "Since you failed to answer Y/N\n - GAME OVER - " << endl;
return 0;
}
}
}
sleep(1);
}
break;
}
//ITEM SYSTEM!!
case 4:{
int RNG;
int EnemyDamage;
cout << "You don't have any items" << endl;
sleep(1);
RNG = rand() % 10+1;
if (RNG <= 9){
EnemyDamage = round(Enemy2.getAttack() - user.getDefense());
user.damage(EnemyDamage);
//Capped the damage to one, so there's always a successful hit
if (EnemyDamage <= 0){
cout << "The foe attacked back! The foe did " << 1 << " of damage!" << endl;
sleep(1);
}
else{
cout << "The foe attacked back! The foe did " << EnemyDamage << " of damage!" << endl;
sleep(1);
}
//If you died during the enemy's attack
if (user.getHealth() <= 0){
string Continue;
cout << "You fainted..!" << endl;
sleep(1);
cout << "Do you wish to continue? (Y/N)" << endl;
cin >> Continue;
if (Continue == "Y"){
cout << "You chose to continue!" << endl;
sleep(1);
user.HealthRestore(user.getHPThres());
Enemy1.HealthRestore(Enemy2.getHPThres());
goto checkpoint1;
}
else if (Continue == "N"){
cout << " - GAME OVER -";
return 0;
}
else{
cout << "Since you failed to answer Y/N\n - GAME OVER - " << endl;
return 0;
}
}
}
else
{
EnemyDamage = round(user.getAttack() - Enemy2.getDefense()) * 3;
user.damage(EnemyDamage);
cout << "The foe did a critical hit! You lost " << EnemyDamage << " of Hit Points." << endl;
//If you died during the enemy's attack
if (user.getHealth() <= 0){
string Continue;
cout << "You fainted..!" << endl;
cout << "Do you wish to continue? (Y/N)" << endl;
cin >> Continue;
if (Continue == "Y"){
cout << "You chose to continue!" << endl;
user.HealthRestore(user.getHPThres());
Enemy1.HealthRestore(Enemy2.getHPThres());
sleep(1);
goto checkpoint1;
}
else if (Continue == "N"){
cout << " - GAME OVER -";
return 0;
}
else{
cout << "Since you failed to answer Y/N\n - GAME OVER -\n " << endl;
return 0;
}
}
break;
}
default:
{
cout << "\nChoose an option, BASED ON THE NUMBERS AVAILABLE!" << endl;
goto back2;
}
}
if(user.getHealth() <= 0 || Enemy2.getHealth() <= 0)
{
break;
}
}
} while (Enemy2.getHealth() > 1);
//end of Miles' code
//start of Alicja's code
DesertStory::draw("desert");
DesertStory::desert();
cout << string(50, '\n');
cout << "You realise that if you don't want to die here you have to move." << endl;
cout << "Choose one of the numbers: " << endl;
cout << " 1. You follow footsteps on the sand you just noticed. " << endl;
cout << " 2. You go another way." << endl;
cout << " 3. You feel too weak and you decide to stay where you are. " << endl;
sleep(4);
int choice_1;
cin >> choice_1;
cin.ignore();
while (cin.fail())// handles invalid inputs
{
cin.clear();
cin.ignore();
cin.get();
cout << "Choose one of: 1, 2, 3, please." << endl;
cin >> choice_1;
}
if(choice_1 > 3 || choice_1 < 1)
{
cout << " Please enter 1, 2 or 3" << endl;
cin >> choice_1;
}
else if(choice_1 == 1)
{
DesertStory::desert_way1();
}
else if(choice_1 == 2)
{
DesertStory::desert_way2();
sleep(6);
cout << "Choose 1 or 2:" << endl;
cout << " 1. You decide to run away.\n" << endl;
cout << " 2. You feel like you are able to fight with him.\n" << endl;
sleep(3);
int choice_2;
cin >> choice_2;
while (cin.fail())
{
cin.clear();
cin.ignore();
cin.get();
cout << "Choose one of: 1, 2 please." << endl;
cin >> choice_2;
}
if(choice_2 > 2 || choice_2 < 1 )
{
cout << "Please enter: 1 or 2." << endl;
cin >> choice_2;
}
else if(choice_2 == 1)
{
cout << "You felt down after few steps and man hits you in the back.\n"<< endl;
cout << "The fight begins." << endl;
}//battle
else if(choice_2 == 2)
{
cout << "You take your out weapon and the fight begins." << endl;
}//battle
}
else if(choice_1 == 3)
{
DesertStory::desert_way3();
}
DesertStory::when_you_win();
srand(time(NULL)); //creates random number between 1 and 3
int dSecret;
dSecret = rand() % 3 +1;
if(dSecret == 1)
{
cout << "After few miles of walking you noticed trees at horizon.\n"
"You are in woods.\n" <<endl;
}
else if(dSecret == 2)
{
cout << "You found pocket knife on your way this will increase your attack." << endl;
DataBase::modifyPlayerAttack(DataBase::playerID, 10);//adds 10 points to player's attack
}
else if(dSecret == 3)
cout << "You stepped on poisonous snake he and he bit you. This will lower your health" << endl;
DataBase::modifyPlayerHealth(DataBase::playerID, -10);//takes 10 points out of player's health
//end in woods
//end of Alicja's code
//start of Shuvas' code
string choiceOne_Path, choiceTwo_Path, helpChoice;
choiceOne_Path = "";
GameClass introObject;
introObject.introFun();
do
{
sleep(1);
cout << "There is a pathway already, there are footsteps..." << endl;
sleep(2);
cout << "It looks like the pathway has been used recently..." << endl;
sleep(3);
cls();
cout << "\t >> Enter '1' to follow the pathway!";
cout << "\t >> or Enter '2' to make your own path through the forest!" << endl;
cout << "\nEnter your choice: ";
cin >> choiceOne_Path;
if(choiceOne_Path == "1")
{
//pathway
GameClass choice1Object; //stating the class, creating an object and assigning the object to the class
choice1Object.choice1pathway(); //specifying the function from the class
}
else if(choiceOne_Path == "2")
{
//forest
GameClass choice2Object;
choice2Object.choice2forest();
}
else
{
GameClass wrongObject;
wrongObject.wrongFun();
}
} while (choiceOne_Path != "1" && choiceOne_Path != "2"); //wil keep looping if user input isn't equal to the required condition
//end of Shuvas' code
//start of Hamza's code
Beachlocations beachobject;
//giving Beachlocations an object
Locations locobject;
//giving Locations an object
locobject.startlocation();
Speeches speobject;
//giving Speeches an object
speobject.hint4();
retry:
string potion_choice;
cin >> potion_choice ;
if(potion_choice == "health")
{
DataBase::modifyPlayerHealth(DataBase::playerID, 50);
// sql function of another member
cout << "health was increased " << endl;
}
else if(potion_choice == "attack")
{
DataBase::modifyPlayerAttack(DataBase::playerID, 10);
// sql function of another member
cout << "your attack is much higher" << endl;
}
else if(potion_choice == "defense")
{
DataBase::modifyPlayerDefense(DataBase::playerID, 10);
//sql function of another member
cout << "your defending is much stronger" << endl;
}
else
{
speobject.wrong();
speobject.hint4();
goto retry;
}
locobject.middle_event();
speobject.hint5();
retry2:
string mevent;
cin >> mevent;
if(mevent == "plan1")
{
locobject.middle_plan1();
}
else if(mevent == "plan2")
{
locobject.middle_plan2();
}
else if(mevent == "plan3")
{
locobject.middle_plan3();
}
else
{
speobject.wrong();
speobject.hint5();
goto retry2;
}
cout << "fight system goes here"<< endl;
locobject.afterbattle();
string locationchoice;
retry4:
cin >> locationchoice;
if (locationchoice == "beachhouse"){
beachobject.bhouse();
}
else if(locationchoice == "brokenchapel"){
beachobject.bchapel();
}
else if(locationchoice == "lighthouse"){
beachobject.lighthouse();
}
else if(locationchoice == "spaceship"){
beachobject.sship();
}
else {
speobject.wrong();
speobject.hint3();
goto retry4;
}
//end of Hamza's code
return 0;
}