diff --git a/character.cpp b/character.cpp new file mode 100644 index 0000000..cd30c20 --- /dev/null +++ b/character.cpp @@ -0,0 +1,43 @@ +#include "character.h" +#include + +//comment +using namespace std; + +Character::Character() +{ + +} + +Character::Character(const string name){ + this->_name = name; + + this->_level = 1; + this->_health = _level+10; + this->_hpThres = _level+10; + this->_exp = (this->_level*100)-50; + this->_expThres = (this->_level*100)-50; + this->_attack = (this->_level+3); + this->_defense = _level + 1; + this->_damageMin = this->_attack-2; + this->_damageMax = this->_attack+2; + this->_money = 0; + this->_item = 00; + + } + +Character::~Character() +{ + +} + + + + +//Functions +//void Character::init(const string name){ } + +string Character::getAsString() + { + + } diff --git a/character.h b/character.h new file mode 100644 index 0000000..7ae8c1a --- /dev/null +++ b/character.h @@ -0,0 +1,136 @@ +#ifndef CHARACTER_H +#define CHARACTER_H +#include +#include +#include +#include +#include +#include +#include + + +unsigned int sleep(unsigned int seconds); + +using namespace std; + + + +class Character +{ + +private: + /* + * The UNDERSCORE is mainly so you know it's private! + */ + string _name; + + int _level; + int _health; + int _hpThres; + int _exp; + int _expThres; + int _bonusDEF; // UNUSED + int _bonusATK; // UNUSED + int _totalATK; // UNUSED + int _attack; + int _damageMin; + int _damageMax; + int _defense; + int _money; + int _item; + +public: + Character(); + Character(const string name); + virtual ~Character(); + + //Functions + + void init (const string name); + string getAsString(); + + + void setBonus(int n, int m){ + this->_attack = _attack + n; + this->_defense = _defense + m; + } + + void levelUp(int exp){ + while (this->_exp >= this->_expThres) + { + this->_exp -= this->_expThres; + + if (_level < 40){ + this->_level++; + this->_expThres = (_level*100) - 50; + cout << "Congratulations!! You leveled up!!" << endl; + } + } + } + + void levelMatch(int lvl){ + this->_level = _level + lvl; + this->_health = _level + _health; + this->_hpThres = _level + _hpThres; + } + + void damage(int dmg){ + if (dmg <= 0) + { + dmg = 1; + } + + this->_health = _health - dmg; + } + + void CanGuard(bool check){ + + if(check == true) + { + cout << "Guard failed!"; + } + + } + + void MoneyGain(int munny){ + this->_money = _money += munny; + } + + void HealthRestore(int hp){ + + this->_health = pow(_health, 0); + + this->_health = _health + (hp-1); + + } + + void ItemCount(int num){ + + this->_item = _item + num; + + } + + + + + //Accessors + inline const string& getName() const {return this->_name;} + inline const int& getLevel() const {return this->_level;} + inline const int& getHealth() const {return this->_health;} + inline const int& getHPThres() const {return this->_hpThres;} + inline const int& getEXP() const {return this->_exp;} + inline const int& getEXPThres() const {return this->_expThres;} + inline const int& getAttack() const {return this->_attack;} + inline const int& getDamageMin() const {return this->_damageMin;} + inline const int& getDamageMax() const {return this->_damageMax;} + inline const int& getDefense() const {return this->_defense;} + inline const int& getMoney() const {return this->_money;} + inline const int& getItem() const {return this->_item;} + + + //Modifiers + + +}; + +#endif \ No newline at end of file diff --git a/characters.cpp b/characters.cpp new file mode 100644 index 0000000..5f04608 --- /dev/null +++ b/characters.cpp @@ -0,0 +1,17 @@ +class Characters { + Characters(); +} +class Player : Characters { + Player(); +} +class Enemy : Characters { + +} +class Warlock : Enemy { + +} +class Dwarf : Enemy { + +} + +void Battlesystem::fightEm(Player player, Enemy enemy) {...} \ No newline at end of file diff --git a/database b/database new file mode 100755 index 0000000..5bc4def Binary files /dev/null and b/database differ diff --git a/database.cpp b/database.cpp new file mode 100644 index 0000000..3a09713 --- /dev/null +++ b/database.cpp @@ -0,0 +1,474 @@ +#include "database.h" + +int DataBase::playerID = 0; +const std::string DataBase::sqliteFile = "osg"; +int DataBase::tryDatabase() { + try { + sqlite::sqlite db(DataBase::sqliteFile); + auto cur = db.get_statement(); + cur->set_sql("insert into armory values ('10', '3', '5');"); + cur->prepare(); + while(cur->step()) { + std::cout << cur->get_int(0) << std::endl; + } + } + catch (sqlite::exception e) { + std::cerr << e.what() << std::endl; + } + return 0; +} +int DataBase::getPlayerID(){ + return DataBase::playerID; +} +void DataBase::registerPlayer(std::string playerName) { + try { + sqlite::sqlite db(DataBase::sqliteFile); + auto cur = db.get_statement(); + + std::cout << "connected to database" << std::endl; + cur->set_sql("INSERT INTO players (playerName) values (?)"); + cur->prepare(); + cur->bind(1, playerName); + cur->step(); + cur = db.get_statement(); + cur->set_sql("SELECT COUNT(*) FROM PLAYERS;"); + cur->prepare(); + cur->step(); + DataBase::playerID = cur->get_int(0); + } + catch (sqlite::exception e) { + std::cerr << e.what() << std::endl; + } +} +void DataBase::killPlayer(int playerID) { + try { + sqlite::sqlite db(DataBase::sqliteFile); + auto cur = db.get_statement(); + cur->set_sql("UPDATE players SET playerHealth = 0 WHERE playerID = ?"); + cur->prepare(); + cur->bind(1, playerID); + cur->step(); + std::cout << "You have died. :(" << std::endl; + } + catch (sqlite::exception e) { + std::cerr << e.what() << std::endl; + } +} +int DataBase::getPlayerLevel(int playerID) { + try { + sqlite::sqlite db(DataBase::sqliteFile); + auto cur = db.get_statement(); + cur->set_sql("SELECT playerLevel FROM players WHERE playerID = ?"); + cur->prepare(); + cur->bind(1, playerID); + + cur->step(); + return cur->get_int(0); + } + catch (sqlite::exception e) { + std::cerr << e.what() << std::endl; + } +} +void DataBase::levelUpPlayer(int playerID) { + try { + sqlite::sqlite db(DataBase::sqliteFile); + auto cur = db.get_statement(); + cur->set_sql("UPDATE players SET playerLevel = ? WHERE playerID = ?"); + cur->prepare(); + cur->bind(1, DataBase::getPlayerLevel(playerID) + 1); + cur->bind(2, playerID); + cur->step(); + } + catch (sqlite::exception e) { + std::cerr << e.what() << std::endl; + } +} +int DataBase::getPlayerMoney(int playerID) { + try { + sqlite::sqlite db(DataBase::sqliteFile); + auto cur = db.get_statement(); + cur->set_sql("SELECT playerMoney FROM players WHERE playerID = ?"); + cur->prepare(); + cur->bind(1, playerID); + + cur->step(); + return cur->get_int(0); + } + catch (sqlite::exception e) { + std::cerr << e.what() << std::endl; + } +} +void DataBase::modifyPlayerMoney(int playerID, int modification) { + try { + sqlite::sqlite db(DataBase::sqliteFile); + auto cur = db.get_statement(); + int current = DataBase::getPlayerMoney(playerID); + + if (current > -modification) { + cur->set_sql("UPDATE players SET playerMoney = ? WHERE playerID = ?"); + cur->prepare(); + cur->bind(1, current + modification); + cur->bind(2, playerID); + cur->step(); + } else { + cur->set_sql("UPDATE players SET playerMoney = 0 WHERE playerID = ?"); + cur->prepare(); + cur->bind(1, playerID); + cur->step(); + } + } + catch (sqlite::exception e) { + std::cerr << e.what() << std::endl; + } +} +int DataBase::getPlayerItemsTotal(int playerID) { + try { + sqlite::sqlite db(DataBase::sqliteFile); + auto cur = db.get_statement(); + cur->set_sql("SELECT playerItemsTotal FROM players WHERE playerID = ?"); + cur->prepare(); + cur->bind(1, playerID); + + cur->step(); + return cur->get_int(0); + } + catch (sqlite::exception e) { + std::cerr << e.what() << std::endl; + } +} +void DataBase::addOneToPlayerItemsTotal(int playerID) { + try { + sqlite::sqlite db(DataBase::sqliteFile); + auto cur = db.get_statement(); + cur->set_sql("UPDATE players SET playerItemsTotal = ? WHERE playerID = ?"); + cur->prepare(); + cur->bind(1, DataBase::getPlayerItemsTotal(playerID) + 1); + cur->bind(2, playerID); + cur->step(); + } + catch (sqlite::exception e) { + std::cerr << e.what() << std::endl; + } +} +int DataBase::getPlayerHealth(int playerID) { + try { + sqlite::sqlite db(DataBase::sqliteFile); + auto cur = db.get_statement(); + cur->set_sql("SELECT playerHealth FROM players WHERE playerID = ?"); + cur->prepare(); + cur->bind(1, playerID); + + cur->step(); + return cur->get_int(0); + } + catch (sqlite::exception e) { + std::cerr << e.what() << std::endl; + } +} +void DataBase::modifyPlayerHealth(int playerID, int modification) { + try { + sqlite::sqlite db(DataBase::sqliteFile); + auto cur = db.get_statement(); + int current = DataBase::getPlayerHealth(playerID); + + if (current > -modification) { + cur->set_sql("UPDATE players SET playerHealth = ? WHERE playerID = ?"); + cur->prepare(); + cur->bind(1, current + modification); + cur->bind(2, playerID); + cur->step(); + } else { + DataBase::killPlayer(playerID); + } + } + catch (sqlite::exception e) { + std::cerr << e.what() << std::endl; + } +} +int DataBase::getPlayerAttack(int playerID) { + try { + sqlite::sqlite db(DataBase::sqliteFile); + auto cur = db.get_statement(); + cur->set_sql("SELECT playerAttack FROM players WHERE playerID = ?"); + cur->prepare(); + cur->bind(1, playerID); + + cur->step(); + return cur->get_int(0); + } + catch (sqlite::exception e) { + std::cerr << e.what() << std::endl; + } +} +void DataBase::modifyPlayerAttack(int playerID, int modification) { + try { + sqlite::sqlite db(DataBase::sqliteFile); + auto cur = db.get_statement(); + int current = DataBase::getPlayerAttack(playerID); + + if (current > -modification) { + cur->set_sql("UPDATE players SET playerAttack = ? WHERE playerID = ?"); + cur->prepare(); + cur->bind(1, current + modification); + cur->bind(2, playerID); + cur->step(); + } else { + cur->set_sql("UPDATE players SET playerAttack = 0 WHERE playerID = ?"); + cur->prepare(); + cur->bind(1, playerID); + cur->step(); + } + } + catch (sqlite::exception e) { + std::cerr << e.what() << std::endl; + } +} +int DataBase::getPlayerDefense(int playerID) { + try { + sqlite::sqlite db(DataBase::sqliteFile); + auto cur = db.get_statement(); + cur->set_sql("SELECT playerDefense FROM players WHERE playerID = ?"); + cur->prepare(); + cur->bind(1, playerID); + + cur->step(); + return cur->get_int(0); + } + catch (sqlite::exception e) { + std::cerr << e.what() << std::endl; + } +} +void DataBase::modifyPlayerDefense(int playerID, int modification) { + try { + sqlite::sqlite db(DataBase::sqliteFile); + auto cur = db.get_statement(); + int current = DataBase::getPlayerDefense(playerID); + + if (current > -modification) { + cur->set_sql("UPDATE players SET playerDefense = ? WHERE playerID = ?"); + cur->prepare(); + cur->bind(1, current + modification); + cur->bind(2, playerID); + cur->step(); + } else { + cur->set_sql("UPDATE players SET playerDefense = 0 WHERE playerID = ?"); + cur->prepare(); + cur->bind(1, playerID); + cur->step(); + } + } + catch (sqlite::exception e) { + std::cerr << e.what() << std::endl; + } +} +bool DataBase::checkForMachete(int playerID) { + try { + sqlite::sqlite db(DataBase::sqliteFile); + auto cur = db.get_statement(); + + cur->set_sql("SELECT hasMachete FROM players WHERE playerID = ?"); + cur->prepare(); + cur->bind(1, playerID); + + cur->step(); + return (cur->get_int(0) == 1); + } + catch (sqlite::exception e) { + std::cerr << e.what() << std::endl; + } +} +void DataBase::assignMachete(int playerID) { + try { + sqlite::sqlite db(DataBase::sqliteFile); + auto cur = db.get_statement(); + + cur->set_sql("UPDATE players SET hasMachete=1 WHERE playerID = ?"); + cur->prepare(); + cur->bind(1, playerID); + + cur->step(); + } + catch (sqlite::exception e) { + std::cerr << e.what() << std::endl; + } +} +bool DataBase::checkForKey(int playerID) { + try { + sqlite::sqlite db(DataBase::sqliteFile); + auto cur = db.get_statement(); + + cur->set_sql("SELECT hasKey FROM players WHERE playerID = ?"); + cur->prepare(); + cur->bind(1, playerID); + + cur->step(); + return (cur->get_int(0) == 1); + } + catch (sqlite::exception e) { + std::cerr << e.what() << std::endl; + } +} +void DataBase::assignKey(int playerID) { + try { + sqlite::sqlite db(DataBase::sqliteFile); + auto cur = db.get_statement(); + + cur->set_sql("UPDATE players SET hasKey=1 WHERE playerID = ?"); + cur->prepare(); + cur->bind(1, playerID); + + cur->step(); + } + catch (sqlite::exception e) { + std::cerr << e.what() << std::endl; + } +} +bool DataBase::checkForChip(int playerID) { + try { + sqlite::sqlite db(DataBase::sqliteFile); + auto cur = db.get_statement(); + + cur->set_sql("SELECT hasChip FROM players WHERE playerID = ?"); + cur->prepare(); + cur->bind(1, playerID); + + cur->step(); + return (cur->get_int(0) == 1); + } + catch (sqlite::exception e) { + std::cerr << e.what() << std::endl; + } +} +void DataBase::assignChip(int playerID) { + try { + sqlite::sqlite db(DataBase::sqliteFile); + auto cur = db.get_statement(); + + cur->set_sql("UPDATE players SET hasChip=1 WHERE playerID = ?"); + cur->prepare(); + cur->bind(1, playerID); + + cur->step(); + } + catch (sqlite::exception e) { + std::cerr << e.what() << std::endl; + } +} +int DataBase::getPotionCount(int playerID) { + try { + sqlite::sqlite db(DataBase::sqliteFile); + auto cur = db.get_statement(); + cur->set_sql("SELECT playerPotionCount FROM players WHERE playerID = ?"); + cur->prepare(); + cur->bind(1, playerID); + cur->step(); + return cur->get_int(0); + } + catch (sqlite::exception e) { + std::cerr << e.what() << std::endl; + } +} +bool DataBase::checkForPotion(int playerID){ + return (DataBase::getPotionCount(playerID) > 0); +} +void DataBase::addOnePotion(int playerID) { + try { + sqlite::sqlite db(DataBase::sqliteFile); + auto cur = db.get_statement(); + cur->set_sql("UPDATE players SET playerPotionCount = ? WHERE playerID = ?"); + cur->prepare(); + cur->bind(1, DataBase::getPotionCount(playerID) + 1); + cur->bind(2, playerID); + cur->step(); + } + catch (sqlite::exception e) { + std::cerr << e.what() << std::endl; + } +} +void DataBase::reducePotionByOne(int playerID) { + try { + sqlite::sqlite db(DataBase::sqliteFile); + auto cur = db.get_statement(); + cur->set_sql("UPDATE players SET playerPotionCount = ? WHERE playerID = ?"); + cur->prepare(); + cur->bind(1, DataBase::getPotionCount(playerID) - 1); + cur->bind(2, playerID); + cur->step(); + } + catch (sqlite::exception e) { + std::cerr << e.what() << std::endl; + } +} +int DataBase::getBiggestAttack(int playerID) { + try { + sqlite::sqlite db(DataBase::sqliteFile); + auto cur = db.get_statement(); + cur->set_sql("SELECT MAX(weaponAtkMod) FROM weapons JOIN armory ON (weapons.weaponID=armory.weaponID) WHERE playerID = ?"); + cur->prepare(); + cur->bind(1, playerID); + cur->step(); + return cur->get_int(0); + } + catch (sqlite::exception e) { + std::cerr << e.what() << std::endl; + } +} +int DataBase::getBiggestDefense(int playerID) { + try { + sqlite::sqlite db(DataBase::sqliteFile); + auto cur = db.get_statement(); + cur->set_sql("SELECT MAX(weaponDefMod) FROM weapons JOIN armory ON (weapons.weaponID=armory.weaponID) WHERE playerID = ?"); + cur->prepare(); + cur->bind(1, playerID); + cur->step(); + return cur->get_int(0); + } + catch (sqlite::exception e) { + std::cerr << e.what() << std::endl; + } +} + + +// int main() { +// std::cout << DataBase::registerPlayer("kekkelos2") << std::endl; + // std::cout << DataBase::getPlayerHealth(3) << std::endl; + // DataBase::modifyPlayerHealth(3, -20); + + // std::cout << DataBase::getPlayerHealth(3) << std::endl; + // DataBase::modifyPlayerAttack(3, -20); + // DataBase::modifyPlayerDefense(3, -20); + + // std::cout << DataBase::getPlayerAttack(5) << std::endl; + // DataBase::modifyPlayerAttack(5, -20); + // std::cout << DataBase::getPlayerAttack(5) << std::endl; + + // std::cout << DataBase::getPlayerDefense(4) << std::endl; + // DataBase::modifyPlayerDefense(4, -20); + // std::cout << DataBase::getPlayerDefense(4) << std::endl; + // std::cout << "should happen" << std::endl; + // DataBase::tryDatabase(); + // std::cout << "right here" << std::endl; + // if (DataBase::checkForMachete(11)) { + // std::cout << "Player 10 has the machete." << std::endl; + // } else { + // std::cout << "Player 10 does not have the machete." << std::endl; + // } + // if (DataBase::checkForKey(11)) { + // std::cout << "Player 10 has the key." << std::endl; + // } else { + // std::cout << "Player 10 does not have the key." << std::endl; + // } + // if (DataBase::checkForChip(11)) { + // std::cout << "Player 10 has the chip." << std::endl; + // } else { + // std::cout << "Player 10 does not have the chip." << std::endl; + // } + // DataBase::assignMachete(11); + // if (DataBase::checkForMachete(11)) { + // std::cout << "Player 10 has the machete." << std::endl; + // } else { + // std::cout << "Player 10 does not have the machete." << std::endl; + // } +// return 0; +// } + diff --git a/database.h b/database.h new file mode 100644 index 0000000..cd55add --- /dev/null +++ b/database.h @@ -0,0 +1,45 @@ +#ifndef _DATABASE_H +#define _DATABASE_H + + +#include "libsqlite.hpp" +#include +#include + +class DataBase { +public: + static int playerID; + static const std::string sqliteFile; + static int tryDatabase(); + static int getPlayerID(); + static void registerPlayer(std::string playerName); + static void killPlayer(int playerID); + static int getPlayerLevel(int playerID); + static void levelUpPlayer(int playerID); + static int getPlayerMoney(int playerID); + static void modifyPlayerMoney(int playerID, int modification); + static int getPlayerItemsTotal(int playerID); + static void addOneToPlayerItemsTotal(int playerID); + static int getPlayerHealth(int playerID); + static void modifyPlayerHealth(int playerID, int modification); + static int getPlayerAttack(int playerID); + static void modifyPlayerAttack(int playerID, int modification); + static int getPlayerDefense(int playerID); + static void modifyPlayerDefense(int playerID, int modification); + static bool checkForMachete(int playerID); + static void assignMachete(int playerID); + static bool checkForKey(int playerID); + static void assignKey(int playerID); + static bool checkForChip(int playerID); + static void assignChip(int playerID); + static int getPotionCount(int playerID); + static bool checkForPotion(int playerID); + static void addOnePotion(int playerID); + static void reducePotionByOne(int playerID); + static int getBiggestAttack(int playerID); + static int getBiggestDefense(int playerID); + +}; +int main(); + +#endif //_DATABASE_H \ No newline at end of file diff --git a/desert_story_alicja.cpp b/desert_story_alicja.cpp new file mode 100644 index 0000000..83fbf50 --- /dev/null +++ b/desert_story_alicja.cpp @@ -0,0 +1,80 @@ +#include "desert_story_alicja.h" + +using namespace std; + +void DesertStory::draw(string type) { + if(type == "desert") { + cout <<"\n " + " _.,-*~'^'~*-,._ ( _.,-*~'^'~*-,._\n" + "| '*-,._ _.,-*' '-,._\n" + "| '*-,.__.,-*' '*-,.__.,-*,\n" + "| |\n" + "`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'`'\n" << endl; + + } +} + +void DesertStory::desert() { + cout <<"==============================================================\n" + "You woke up having no idea what happend.\n" + "You feel exhausted,\n" + "it is so hot that it fells like you are being burned alive.\n" + "When you open your eyes, you see sand all around you.\n" + "There's nothing else on the horizon, despite few cactuses.\n" + "You realise you're in the middle of the desert.\n" + "==============================================================\n" << endl; + // sleep(6); +} + +void DesertStory::desert_way1() { + cout << "You started following these footsteps\n" + "After several minutes they become bleary,\n" + "and few minute later you can't see them at all.\n" + "Suddenly the strong wind picked up.\n" + "You tried to walk faster for a while,\n" + "but you realised it is a sandstorm and you have no chance.\n" + "Sand is getting to your eyes and mouth, you barely breath.\n" + "You fell on the ground, not able to move.\n" + << endl; //dead + DataBase::killPlayer(DataBase::playerID); +} +void DesertStory::desert_way2() { + cout << "You have been walking for few hours.\n" + "You noticed a jeep on your way\n" + "You decided to approach it to see if it works\n" + "You look through the window and you notice some movement.\n" + "Suddenly huge man jump out of it with sword in his hand\n" < +#include +#include //included for sleep function +#include /* srand, rand */ +#include +#include "database.h" + + +class DesertStory +{ +public: + static void draw(std::string type); + static void desert(); + static void desert_way1(); + static void desert_way2(); + static void desert_way3(); + static void when_you_win(); +}; + +#endif //_DESERT_STORY_ALICJA_H \ No newline at end of file diff --git a/game b/game new file mode 100755 index 0000000..2062154 Binary files /dev/null and b/game differ diff --git a/game.cpp b/game.cpp new file mode 100644 index 0000000..a415426 --- /dev/null +++ b/game.cpp @@ -0,0 +1,1179 @@ +/* Game: Second Braves + * Project: Activity Led Learning + * Coventry University + * + * Contributers: Alicja, Balazs, Hamza, Herlander, Shuvas , Sharon + * 2018 © Written by all contributers + * + * The story, all names, characters, and incidents portrayed in this production are fictitious. + * No identification with actual persons (living or deceased), places, buildings, and products is intended or should be inferred. + */ + +#include "character.h" +#include "libsqlite.hpp" +#include + + +//https://codereview.stackexchange.com/questions/27986/text-based-rpg-game-using-classes +// +void CLS() +{ + system("clear"); +} + + +void Interlude(){ + + cout << "\nAhem..!" << endl; + sleep(2); + CLS(); + cout << "Once upon a time, th-" << endl; + sleep(3); + CLS(); + cout << "Huh... What's that..?" << endl; + sleep(3); + CLS(); + cout << "That's not how this story goes..?" << endl; + sleep(2); + cout << "But I thou-" << endl; + sleep(3); + CLS(); + cout << "Fine! Always sucking the joy out of everything!" << endl; + sleep(2); + CLS(); + + + cout << "\n Square Enix Presents" << endl; + sleep(2); + cout << " Distribution by Sony Interactive Entertainment" << endl; + sleep(2); + cout << " An F5 Game" << endl; + sleep(2); + CLS(); + cout << " Second Braves" << endl; + cout << " - Chapter 1: When the War Bell Tolls -" << endl; + } + +void pressAnyKey(void){ + // Use this when something else will be printed + cout << "\nPress ENTER to continue..."; + cin.get(); + cin.ignore(); + CLS(); + } + +int story1(string Player){ + CLS(); + cout << " dong..." << endl; + sleep(2); + cout << " Dong!" << endl; + sleep(2); + cout << " DONG!!!" << endl; + sleep(1); + + cout << Player << ": Arghhhhh.... just a f-few more minutes... zzz" << endl; + sleep(2); + + cout << "Hmm, it seems you're unaware of what those bells mean." << endl; + pressAnyKey(); + + + cout << " dong..." << endl; + sleep(2); + cout << " Dong!" << endl; + sleep(2); + cout << " DONG!!!" << endl; + sleep(1); + + cout << Player << ": Huh!?" << endl; + sleep(2); + cout << "You've woken from your slumber, yet to realize what is going on!" << endl; + pressAnyKey(); + + cout << Player << ": T-Those are the war bells!!" << endl; + sleep(2); + cout << "You quickly rush out of bed to the window of your room and see nothing but chaos..." << endl; + sleep(2); + cout << "The fire consumes the nearby houses, all the vegetation became dust," << endl; + sleep(2); + cout << "Your neighbours are screaming and pleading for mercy, but the creatures don't seem to understand," << endl; + sleep(2); + cout << "What used to be a town of peace, is now a town of massacre." << endl; + sleep(1); + cout << "I wonder how you even managed to sleep through all that." << endl; + sleep(2); + cout << Player << ": I've got to help them..!" << endl; + sleep(1); + pressAnyKey(); + + cout << "You put on a light armour and run downstairs to the door..." << endl; + sleep(2); + cout << "HEY!! Where are you going? It's dangerous to go alone, why don't you arm yourself first?" << endl; + sleep(2); +} + +int story2(string Player){ + CLS(); + cout << "Now you're ready for action!" << endl; + sleep(2); + cout << "You open the door an-" << endl; + sleep(2); + cout << "*slash and groans*" << endl; + sleep(1); + cout << "HOLLY HELL! Someone has just been murdered on your door." << endl; + sleep(2); + cout << "Luckily, it's just Gilbert, he stole from you last week, remember?" << endl; + sleep(2); + cout << "Still, the creature in front of you stares endlessly with blood-lusting eyes..." << endl; + sleep(2); + cout << "Hope you can fight..!" << endl; + sleep(2); + cout << Player << ": Ohh, I'll make it regret." << endl; + sleep(2); + cout << "That's the spirit! Get ready for a battle!!" << endl; +} + + + +void pausing(){ + // Use this when nothing else will be printed + cout << "\nPress ENTER to continue..."; + cin.ignore(); + } + +//Above you can find amazing functions that you needed for future reference + + + + + + + + + + + +int main() { + string sqliteFile = "osg"; + sqlite::sqlite db( sqliteFile ); + auto cur = db.get_statement(); + + 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"; + pausing(); + + string name; + + cout << "Enter the name of your character: "; + cin >> name; + Character user (name); + PlayerN = user.getName(); + + cur->set_sql("INSERT INTO players (playerName, playerLevel, playerHealth, playerAttack, playerDefense, playerItemsTotal, playerPotionCount, playerMoney) VALUES (?,1,11,4,2,0,0,0)"); + cur->prepare(); + cur->bind(1,PlayerN); + cur->step(); + + + //database + + CLS(); + + Interlude(); + + sleep(2); + + 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 + 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); + + + //more story + + + +return 0; +} diff --git a/hamza.cpp b/hamza.cpp new file mode 100644 index 0000000..bac35a9 --- /dev/null +++ b/hamza.cpp @@ -0,0 +1,594 @@ +#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"<> 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"< +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "database.h" + +class Speeches + //a class for error and unrecgonised input +{ +public: //so i can use functions in my main + static void CLS(); + void wrong(); + void hint1(); + void hint2(); + void hint3(); + void hint4(); + void hint5(); + void hint6(); +}; + + +class Locations + //scenario text for different parts eg ending text. +{ +public: + void startlocation(); //my starting scenario + void finishlocation(); // my ending scenario. once they finished + void middle_event(); //before battlesystem text + // the different plans are three paths that lead to the fight + void middle_plan1(); + void middle_plan2(); + void middle_plan3(); + void afterbattle(); //text which introduces you to the buildings + void lighthouse1(); + void beachhouse1(); + void beachhouse2(); + void brokenchapel1(); + void brokenchapel2(); + void spaceship(); + void spaceship2(); +}; + +class Beachlocations + //all the different locations you can visit at the beach. + //different locations have sql for obtaining and using objects +{ +public: + int lighthouse(); //lighthouse location + int bhouse(); + int bchapel(); + int sship(); +}; + + +// int main() +// { +// int playerID; + +// 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(playerID, 50); +// // sql function of another member +// cout << "health was increased " << endl; + +// } + +// else if(potion_choice == "attack") +// { +// DataBase::modifyPlayerAttack(playerID, 10); +// // sql function of another member +// cout << "your attack is much higher" << endl; + +// } + +// else if(potion_choice == "defense") +// { +// DataBase::modifyPlayerDefense(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; + +// } + + + + + + +// return 0; +// } + +#endif //_HAMZA_H \ No newline at end of file diff --git a/libsqlite.hpp b/libsqlite.hpp new file mode 100644 index 0000000..b4c839b --- /dev/null +++ b/libsqlite.hpp @@ -0,0 +1,245 @@ +/** + * Copyrights: + * Netlogic Belgium: + * Ruben De Smet + * + * this file is licensed under the terms stated in the LICENCE file + * + */ + +#include +#include +#include +#include +#include + +#ifndef SQLITEPP +#define SQLITEPP + +namespace sqlite +{ + class sqlite; + class statement; + typedef std::shared_ptr statement_ptr; + typedef std::shared_ptr sqlite_ptr; + + class exception : public std::exception + { + friend statement; + friend sqlite; + public: + exception(std::string msg) + { + this->_msg = msg; + } + std::string what() + { + return "Sqlite error: " + this->_msg; + } + private: + void _set_errorno(int err) + { + } + std::string _msg; + }; + + class statement + { + friend sqlite; + friend exception; + public: + void set_sql(std::string sql) + { + if(this->_prepared) + { + exception e("Can not set sql on prepared query."); + throw e; + } + else + { + this->_sql = sql; + } + } + void prepare() + { + this->_prepared = true; + const char* tail; + int rc = sqlite3_prepare_v2(this->_db, + this->_sql.c_str(), + this->_sql.length(), + &this->_s, + &tail); + if(rc != SQLITE_OK) + { + exception e("Could not prepare sql."); + e._set_errorno(rc); + throw e; + } + this->_tail = std::string(tail); + } + + bool step() + { + if(!this->_valid) + { + exception e("Trying to step an invalid statement."); + } + + int rc = sqlite3_step(this->_s); + if(rc == SQLITE_DONE) + { + this->_valid = false; + return false; + } + if(rc == SQLITE_ROW) + { + this->_has_row = true; + return true; + } + // Ok, this means error if we get here + exception e("Sqlite had an error: " + std::string(sqlite3_errmsg(this->_db))); + return false; + } + void reset() + { + int rc = sqlite3_reset(this->_s); + if(rc != SQLITE_OK) + { + exception e("Could not reset the virtual machine."); + throw e; + } + this->_valid = true; + this->_has_row = false; + this->_prepared = false; + } + + void exec() + { + this->prepare(); + this->step(); + } + + double get_double(int fieldnumber) + { + return sqlite3_column_double(this->_s, fieldnumber); + } + + int get_int(int fieldnumber) + { + return sqlite3_column_int(this->_s, fieldnumber); + } + + std::string get_text(int fieldnumber) + { + return std::string((const char*)sqlite3_column_text(this->_s, fieldnumber)); + } + std::string get_blob(int fieldnumber) + { + return std::string((const char*)sqlite3_column_blob(this->_s, fieldnumber), + sqlite3_column_bytes(this->_s, fieldnumber)); + } + + void bind(int where, std::string text) + { + int rc = sqlite3_bind_text(this->_s, where, text.c_str(), text.length(), SQLITE_STATIC); + if(rc != SQLITE_OK) + { + exception e("Could not bind text."); + throw e; + } + } + void bind(int where, double d) + { + int rc = sqlite3_bind_double(this->_s, where, d); + if(rc != SQLITE_OK) + { + exception e("Could not bind double."); + throw e; + } + } + void bind(int where, int i) + { + int rc = sqlite3_bind_int(this->_s, where, i); + if(rc != SQLITE_OK) + { + exception e("Could not bind int."); + throw e; + } + } + void bind_null(int where) + { + int rc = sqlite3_bind_null(this->_s, where); + if(rc != SQLITE_OK) + { + exception e("Could not bind to NULL."); + throw e; + } + } + + virtual ~statement() + { + sqlite3_finalize(this->_s); + } + private: + statement(sqlite3* db) + { + this->_db = db; + this->_prepared = false; + this->_valid = true; + this->_has_row = false; + } + statement(sqlite3* db, std::string sql) + { + this->_db = db; + this->_prepared = false; + this->_valid = true; + this->_has_row = false; + this->set_sql(sql); + } + sqlite3* _db; + bool _prepared, _valid, _has_row; + std::string _sql; + std::string _tail; + sqlite3_stmt* _s; + }; + + class sqlite + { + friend statement; + public: + sqlite(std::string filename) throw (exception) + { + this->_filename = filename; + int rc = sqlite3_open(filename.c_str(), &this->_db); + if(rc != SQLITE_OK) + { + exception e("Could not open '" + filename + "'"); + throw e; + } + } + std::shared_ptr get_statement() + { + statement_ptr st(new statement(this->_db)); + return st; + } + statement_ptr get_statement(std::string sql) + { + statement_ptr st(new statement(this->_db, sql)); + return st; + } + int64_t last_insert_id() + { + return sqlite3_last_insert_rowid(this->_db); + } + virtual ~sqlite() + { + sqlite3_close(this->_db); + } + private: + std::string _filename; + + sqlite3* _db; + }; +} + +#endif diff --git a/main b/main new file mode 100755 index 0000000..283c384 Binary files /dev/null and b/main differ diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..ae05ef0 --- /dev/null +++ b/main.cpp @@ -0,0 +1,1312 @@ +#include "desert_story_alicja.h" +#include "database.h" +#include "hamza.h" +#include "shuvas.h" +#include "miles.h" +#include "libsqlite.hpp" +#include +#include +#include //included for sleep function +#include /* srand, rand */ +#include +#include "character.h" +#include + +// DON'T FORGET TO UNCOMMENT ALL SLEEP STATEMENTS!!! + +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" <> 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 + cout << endl << "POINT IN CODE" << endl << endl << endl; + //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; +} + diff --git a/miles.cpp b/miles.cpp new file mode 100644 index 0000000..38eea13 --- /dev/null +++ b/miles.cpp @@ -0,0 +1,123 @@ +#include "miles.h" + +using namespace std; + +void Miles::CLS() { + system("clear"); +} +void Miles::pausing(){ + // Use this when nothing else will be printed + cout << "\nPress ENTER to continue..."; + cin.ignore(); +} + +void Miles::interlude() { + + cout << "\nAhem..!" << endl; + //sleep(2); + Miles::CLS(); + cout << "Once upon a time, th-" << endl; + //sleep(3); + Miles::CLS(); + cout << "Huh... What's that..?" << endl; + //sleep(3); + Miles::CLS(); + cout << "That's not how this story goes..?" << endl; + //sleep(2); + cout << "But I thou-" << endl; + //sleep(3); + Miles::CLS(); + cout << "Fine! Always sucking the joy out of everything!" << endl; + //sleep(2); + Miles::CLS(); + + + cout << "\n Square Enix Presents" << endl; + //sleep(2); + cout << " Distribution by Sony Interactive Entertainment" << endl; + //sleep(2); + cout << " An F5 Game" << endl; + //sleep(2); + Miles::CLS(); + cout << " Second Braves" << endl; + cout << " - Chapter 1: When the War Bell Tolls -" << endl; + } + +void Miles::pressAnyKey(void) { + // Use this when something else will be printed + cout << "\nPress ENTER to continue..."; + cin.get(); + cin.ignore(); + Miles::CLS(); + } + +int Miles::story1(string Player) { + Miles::CLS(); + cout << " dong..." << endl; + //sleep(2); + cout << " Dong!" << endl; + //sleep(2); + cout << " DONG!!!" << endl; + //sleep(1); + + cout << Player << ": Arghhhhh.... just a f-few more minutes... zzz" << endl; + //sleep(2); + + cout << "Hmm, it seems you're unaware of what those bells mean." << endl; + pressAnyKey(); + + + cout << " dong..." << endl; + //sleep(2); + cout << " Dong!" << endl; + //sleep(2); + cout << " DONG!!!" << endl; + //sleep(1); + + cout << Player << ": Huh!?" << endl; + //sleep(2); + cout << "You've woken from your slumber, yet to realize what is going on!" << endl; + pressAnyKey(); + + cout << Player << ": T-Those are the war bells!!" << endl; + //sleep(2); + cout << "You quickly rush out of bed to the window of your room and see nothing but chaos..." << endl; + //sleep(2); + cout << "The fire consumes the nearby houses, all the vegetation became dust," << endl; + //sleep(2); + cout << "Your neighbours are screaming and pleading for mercy, but the creatures don't seem to understand," << endl; + //sleep(2); + cout << "What used to be a town of peace, is now a town of massacre." << endl; + //sleep(1); + cout << "I wonder how you even managed to //sleep through all that." << endl; + //sleep(2); + cout << Player << ": I've got to help them..!" << endl; + //sleep(1); + pressAnyKey(); + + cout << "You put on a light armour and run downstairs to the door..." << endl; + //sleep(2); + cout << "HEY!! Where are you going? It's dangerous to go alone, why don't you arm yourself first?" << endl; + //sleep(2); +} + +int Miles::story2(string Player) { + Miles::CLS(); + cout << "Now you're ready for action!" << endl; + //sleep(2); + cout << "You open the door an-" << endl; + //sleep(2); + cout << "*slash and groans*" << endl; + //sleep(1); + cout << "HOLLY HELL! Someone has just been murdered on your door." << endl; + //sleep(2); + cout << "Luckily, it's just Gilbert, he stole from you last week, remember?" << endl; + //sleep(2); + cout << "Still, the creature in front of you stares endlessly with blood-lusting eyes..." << endl; + //sleep(2); + cout << "Hope you can fight..!" << endl; + //sleep(2); + cout << Player << ": Ohh, I'll make it regret." << endl; + //sleep(2); + cout << "That's the spirit! Get ready for a battle!!" << endl; +} \ No newline at end of file diff --git a/miles.h b/miles.h new file mode 100644 index 0000000..9a00d79 --- /dev/null +++ b/miles.h @@ -0,0 +1,13 @@ +#include "character.h" +#include "libsqlite.hpp" +#include + +class Miles { +public: + static void CLS(); + static void pausing(); + static void interlude(); + static void pressAnyKey(void); + static int story1(string Player); + static int story2(string Player); +}; \ No newline at end of file diff --git a/osg b/osg new file mode 100644 index 0000000..0bcff5b Binary files /dev/null and b/osg differ diff --git a/sharon_castle.cpp b/sharon_castle.cpp new file mode 100644 index 0000000..fe25523 --- /dev/null +++ b/sharon_castle.cpp @@ -0,0 +1,583 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include //sleepfunction#include +#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"<>>>>\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; +} + diff --git a/shuvas.cpp b/shuvas.cpp new file mode 100644 index 0000000..568def4 --- /dev/null +++ b/shuvas.cpp @@ -0,0 +1,451 @@ +#include "shuvas.h" + +using namespace std; + +void cls() +{ + system ("clear"); +} + +void GameClass2::beachFun() //creating and naming a function +{ + cout << "congratulations, you are at the beach now..." << endl; //used to output text on to the screen + //sleep(2); + + cout << "The sand is softly golden with just the right comforting warmth..." << endl;// endl used for a new line + //sleep(2); + + cout << "To rest on the beach feels like a cosy hug, one only matched by the sunshine filled sky..." << endl; + //sleep(2); + cout << "you can move to the next level..." << endl; + +} + + +void GameClass::wrongFun() +{ +cout << "Warning! Warning!" << endl; +cout << "You are doing it wrong player!" << endl; +cout << "Please" << endl; +cout << "Please" << endl; +cout << "Please Enter: " << endl; +cout << "1 for Yes & 2 for No" << endl; +cout << "Thank You for reading this, player!" << endl; + +} + +void GameClass::riverFun() +{ +string RiverChoice; //declaring a string a variable so it can be used to store user input + + +cout << "you are at the Rio River now. " << endl; +//sleep(3); + +cout << "the river is clear blue, beautiful and very deep(the with hasn't been here yet)." << endl; +//sleep(3); +cout << "it is also oozing with amazing sealife " << endl; +//sleep(3); +cls(); +cout << "there seems to be a shaky bridge leading to the other side of the river." << endl; +//sleep(3); + +goFish: +cout << "\nenter 1 to kill and eat a fish, enter 2 to go back to the pathway, enter 3 to cross the river"; +//sleep(2); +cout << "Enter your choice: "; + +cin >> RiverChoice;//used to capture input from the user(crucial for output) +if (RiverChoice == "1")//condition to run the if statement +{ +//beach +//increase attack +DataBase::modifyPlayerAttack(DataBase::playerID, +20); +DataBase::modifyPlayerHealth(DataBase::playerID, +20); +cout << "Your attack and health have increased by 20" << endl; +} +else if (RiverChoice == "2") +{ +//back to pathway + +choice1pathway(); +} +else if (RiverChoice == "3") +{ +GameClass2 beachObject; +beachObject.beachFun(); +} +else +{ +wrongFun(); +goto goFish; //goes back to where "goFish:" was declared +} + + +} + +void GameClass::cottageFun() +{ +//cottage +string battleStr; +cout << "the cottage looks old and dirty..." << endl; +//sleep(3); +cout << "it has a bright white door and two small windows..." << endl; +//sleep(3); +cout << "an enemy is guarding the door" << endl; +//sleep(3); + +cout << "\nDo you wish to battle? (enter 1 for yes, 2 for no)... " << endl; +cout << "Enter your choice: "; +goBattle: +cin >> battleStr; +if (battleStr == "1") +{ +string ToRiver; +cout << "you defeat the enemey but your health drops by 20..." << endl; +DataBase::modifyPlayerHealth(DataBase::playerID, -20); + +cout << "you defeat enemey so you recieve money of 1000" << endl; + +//update money +cout << "Enter 1 to battle again or Enter 2 to leave " << endl; +cout << "Enter your choice: "; +cin >> ToRiver; +if (ToRiver == "1") +{ +goto goBattle; +} +else +{ +cout << "you are forced to make your way to the extraordinary Rio River" << endl; +riverFun(); +} + + +} + +else if (battleStr == "2") +{ +cout << "you are forced to make your way to the extraordinary Rio River" << endl; +//drop defence + +riverFun(); + +} +else +{ +wrongFun(); +goto goBattle; +} + +} + +void GameClass::moreForestFun() +{ +string fightLeeches, useMachete; + + + +cout << "the sheer amount of vines and branches is overwhelming and you can't get through" << endl; +//sleep(3); +cout << "do you want to use you machete to cut through the trees and the vines?" << endl; +//sleep(3); +cout << "enter 1 for yes and 2 for no" << endl; + +goMachete: +cin >> useMachete; +if (useMachete == "1") +{ +cout << "health drops by 5" << endl; +DataBase::modifyPlayerHealth(DataBase::playerID, -20); + +} +else if (useMachete == "1") +{ +cout << "attack increases by 5" << endl; +DataBase::modifyPlayerAttack(DataBase::playerID, +20); +} +else +{ +wrongFun(); +goto goMachete; +} +cout << "dirty leeches are covering your arms and you are hurting" << endl; +//sleep(3); +cout << "health drops by 20" << endl; +DataBase::modifyPlayerHealth (DataBase::playerID, -20); + +goLeeches: +cout << "you can either burn off the leeches whilst they are on your arm...(enter 1) " << endl; +cout << "or you can remove them one by one (by entering 2)" << endl; +cout << "what do you want to do: " << endl; +cin >> fightLeeches; +if (fightLeeches == "1") +{ +cout << "whilst burning the leeches you have burned yourself too" << endl; +DataBase::modifyPlayerHealth (DataBase::playerID, -20); +cout << "you go to the river so you can cool yourself" << endl; +riverFun(); + + +} +else if (fightLeeches == "2") +{ +cout << "you have got rid of the leeches but it took you very long" << endl; +cout << "now you are very hungry so you go to the cottage" << endl; +cottageFun(); +} +else +{ +wrongFun(); +goto goLeeches; +} + + + +} + +void GameClass::followAnimal() +{ +string fightAnimals; + +cout << "It's been a few minutes since you started following this animal..." << endl; +//sleep(3); + +cout << "This animal is very ugly, your eyes hurt just looking at it..." << endl; +//sleep(3); + +cout << "This creature has lead you to its pack" << endl; +//sleep(3); + +cout << "The pack is quite large but it is possible to attack them" << endl; +//sleep(3); +cls(); + +goFightAnimals: +cout << "What do you choose to do?" << endl; +cout << "Enter 1 to attack the animals for extra attack" << endl; +cout << "Enter 2 to leave the animal and steal their money" << endl; +cout << "Enter: "; + +cin >> fightAnimals; + +if (fightAnimals == "1") +{ +DataBase::modifyPlayerAttack(DataBase::playerID, -20); + +cout << "you are too strong for the animals" << endl; +//sleep(3); + +cout << "you have completely brutally mashed up the animals and their habitat" << endl; +//sleep(3); + +cout << "there is so much blood everywhere" << endl; +//sleep(3); + +cout << "you are an evil savage" << endl; +//sleep(3); +cls(); + + +//attack increases by 20 +} + +else if (fightAnimals == "2") +{ +cout << "you recieve 20 coins and leave to the forest" << endl; +moreForestFun(); + +} + +else +{ +wrongFun(); +goto goFightAnimals; +} + +} + +void GameClass::choice1pathway () +{ +string choiceTwo_Path; + +cls(); + +//pathway +cout << "You are at the pathway" << endl; +//sleep(2); + +cout << "\nThis is a safe choice but might not lead anywhere." << endl; +//sleep(2); + +cout << "But, this could be a risky choice because you are easier to be spotted by enemeies" << endl; +//sleep(2); + + + +cout << "you walk for a half an hour"<< endl; +//sleep(2); + +cout << "a small ugly strange animal rushes past you" << endl; +//sleep(2); + +cout << "you see a small cottage in the distance" << endl; +//sleep(2); + +cout << "you have two options now " << endl; +//sleep(3); +cls(); + +gofollowAnimal2: + +cout << "Enter 1 to follow animal. Enter 2 to go to the cottage " << endl; + +do { +cin >> choiceTwo_Path; + +if(choiceTwo_Path == "1") +{ +//river +followAnimal(); + +} +else if (choiceTwo_Path == "2") +{ +//cottage +GameClass cottageObject; +cottageObject.cottageFun(); + +} +else +{ +wrongFun(); +goto gofollowAnimal2; + +} + +} while (choiceTwo_Path != "1" && choiceTwo_Path != "2"); + + +} + +void GameClass::choice2forest () + +{ +string choiceTwo_Path; + +cls(); +//forest +cout << "This is a risky choice as you might get lost" << endl; +//sleep(3); + +cout << "There is no clear way and you will need to make your own way" << endl; +//sleep(3); + + + +cout << "you have made your way through for 20 minutes but now there are too many vines and branches in your way" << endl; +//sleep(3); + +cout << "you have two choices now, you can see a small cottage in the distance outside of the forest." << endl; +//sleep(3); +cls(); + +do +{ +cout << "enter 1 to continue making your way through the forest." << endl; +cout << "enter 2 to approch the small cottage." << endl; + +cout << "\nenter your choice: "; +cin >> choiceTwo_Path; +if(choiceTwo_Path == "1") +{ +//moreForest +GameClass forestObject;//you state the class and create instance of that class +forestObject.moreForestFun(); //you assign the function to the instance + + +} +else if (choiceTwo_Path == "2") +{ +//cottage +GameClass cottageObject; +cottageObject.cottageFun(); + +} +else +{ +wrongFun(); + +} + +} while (choiceTwo_Path != "1" && choiceTwo_Path != "2"); + +} + +void GameClass::introFun () +{ + +cout <<""<< endl; +//sleep (1); +cls(); + + + +cout << "Hello|Hello|Hello|Hello|Hello|Hello|Hello|" << endl; +//sleep(1); + +cout << "And|And|And|And|And|And|And|And|And|" << endl; +//sleep(1); + +cout << "Welcome|Welcome|Welcome|Welcome|Welcome|" << endl; +//sleep(1); + +cout << "To|To|To|To|To|To|To|To|To|" << endl; +//sleep(1); + +cout << "The Forest|The Forest|The Forest|The Forest|The Forest|The Forest|The Forest|" << endl; +//sleep(2); +cls(); + +cout << "Copyrights Shuvas Rayamajhi 2018." << endl; +//sleep(2); +cls(); + +cout << "Hold up!" << endl; +//sleep(1); + +cout << "Hold up!" << endl; +//sleep(1); + +cout << "Hold up!" << endl; +//sleep(1); + +cout << "Hold up!" << endl; +//sleep(1); + +cout << "Where the hell are you...." << endl; +//sleep(2); +cout << "You look around..." << endl; +//sleep(2); + +cout << "The forest looks ancient... " << endl; +//sleep(3); + +cout << "The trees thick and old, roots that brutally twisted..." << endl; +//sleep(3); + +cout << "There might once have been filled with bird-song and animals that roamed..." << endl; +//sleep(3); + +cout << "But now it's ages past its former glory..." << endl; +//sleep(3); + +cout << "It's canopy was so dense that you could only see the occasional streak of sunlight that rarely touched the forest floor..." << endl; +//sleep(3); + +cout << "Even its thick vines were slowly taking away the last remnants of the temple that stood in the centre..." << endl; +//sleep(3); +cls(); + +} diff --git a/shuvas.h b/shuvas.h new file mode 100644 index 0000000..8d57fab --- /dev/null +++ b/shuvas.h @@ -0,0 +1,84 @@ +#ifndef _SHUVAS_H +#define _SHUVAS_H + +#include +#include +#include +#include +#include +#include +#include "database.h" + +void cls(); + +class GameClass2 //this is use to create a class and name it +{ + public: //public means that the variables within this class can be accesed from anywhere in the program + void beachFun(); //creating and naming a function + +}; + +class GameClass +{ +public: //allows othe classes to access the methods without the use of multiple steps + void wrongFun(); + void riverFun(); + void cottageFun(); + void moreForestFun(); + void followAnimal(); + void choice1pathway (); + void choice2forest (); + void introFun (); +}; + + + +// int main () +// { +// string choiceOne_Path, choiceTwo_Path, helpChoice; +// int PlayerID; +// 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 +// return 0; + +// } + +#endif //_SHUVAS_H \ No newline at end of file