#include #include #include #include #include #include using namespace std; class Game { public: int menu(); int newGame(); int save(); int load(); int town(); int house(); int gym(); int battle(); int attack(); int flee(); int lift(); int weap(); int beat(); int changePlace(); string mname, name; int choice; int place; int exp; int mon; int temp; string talk; int hp; int mhp; int mclass; int m[7]; int atk; int matk; int str; double mstr; double def; double mdef; }; int Game::menu() { system("cls"); choice = 0; place = 0; cout <<"\n\n Welcome to Kingdom of Losers\n\n"; cout <<" 1 - New Game\n"; cout <<" 2 - Load Game\n"; cout <<"> "; cin >>choice; cin.ignore(); switch (choice) { case 1: newGame(); break; case 2: load(); break; default: menu(); } return 0; } int Game::newGame() { system("cls"); place = 1; hp = 100; atk = 5; str = 5; def = 1; exp = 5; mon = 200; cout <<"You started a new game!\n"; cin.get(); system("cls"); cout <<"What will you be known as?\n"; cout <<"> "; cin >>name; cin.ignore(); system("cls"); ofstream data("save"); data <>hp; data >>atk; data >>str; data >>def; data >>exp; data >>mon; data >>name; data >>place; } else { cout <<"Error loading data! Either you not saved or the file is corrupted!\n"; cin.get(); changePlace(); } cout <<"Data loaded successfully!\n"; cin.get(); changePlace(); return 0; } int Game::save() { system("cls"); place = 2; ofstream data("save"); data < "; cin >>choice; cin.ignore(); switch (choice) { case 1: house(); break; case 2: gym(); break; case 3: battle(); break; default: town(); } return 0; } int Game::house() { system("cls"); choice = 0; place = 2; cout <<"HP "< "; cin >>choice; cin.ignore(); switch (choice) { case 1: save(); break; case 2: menu(); break; case 3: system("cls"); cout <<"You slip under the silk covers and fall asleep.\n"; cin.get(); system("cls"); cout <<"You wake up, and stretch. You're refreshed. (HP fully restored)"; cin.get(); hp = 100; house(); break; case 4: town(); break; default: house(); break; } return 0; } int Game::gym() { system("cls"); choice = 0; cout <<"HP "< "; cin >>choice; cin.ignore(); switch (choice) { case 1: lift(); break; case 2: weap(); break; case 3: beat(); break; case 4: town(); break; default: gym(); } return 0; } int Game::lift() { system("cls"); if (mon >= 40) { mon -= 40; srand(time(NULL)); cout <<"You lift a "<= 75) { mon -= 75; srand(time(NULL)); cout <<"You pay for a sword and start lunging it around. You feel as if you learned a new technique.\n"; cin.get(); temp = rand() % exp - 2 + 1; cout <<"You gain "<= 20) { mon -= 20; srand(time(NULL)); cout <<"You pay this tough-looking guy twenty bucks to punch you in the stomach. You grimace.\n"; cin.get(); temp = rand() % exp - 1 + 1; cout <<"You gain "< "; cin >>choice; cin.ignore(); switch (choice) { case 1: attack(); break; case 2: flee(); break; default: battle(); } return 0; } int Game::attack() { system("cls"); srand(time(NULL)); int chance = rand() % 200 + 50; if (chance >= 100) { cout <