rendered paste body#include <iostream>#include <fstream>#include <math.h>#include <string>using namespace std;class Game {public: int menu(); int newGame(); int save(); int load(); int changePlace(); int town(); int house(); int gym(); int battle(); int attack(); int flee(); int lift(); int weap(); int beat(); int choice, place; string name, mname; int mclass; int exp; int m[3]; double hp; int atk; int str; int def; int mon; double mhp; int matk; int mstr; int mdef; int temp;};int Game::menu() { system("cls"); choice = 0; place = 0; cout <<"\n\n WELCOME TO SIMPLE TEXT RPG 1.0\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 = 2; hp = 100; atk = 5; str = 5; def = 1; mon = 50; exp = 0; cout <<"\n\nYou have decided to start a new game! What is your name?\n"; cout <<"> "; cin >>name; cin.ignore(); ofstream data("save"); data <<hp <<endl; data <<atk <<endl; data <<str <<endl; data <<def <<endl; data <<name <<endl; data <<place <<endl; data <<mon <<endl; data <<exp; data.close(); cout <<"\nData saved successfully!"; cin.get(); changePlace(); return 0;}int Game::save() { system("cls"); place = 1; ofstream data("save"); data <<hp <<endl; data <<atk <<endl; data <<str <<endl; data <<def <<endl; data <<name <<endl; data <<place <<endl; data <<mon <<endl; data <<exp; data.close(); cout <<"Data saved successfully!\n"; cin.get(); changePlace(); return 0;}int Game::load() { system("cls"); place = 0; ifstream data("save"); if (data.is_open()) { data >>hp; data >>atk; data >>str; data >>def; data >>name; data >>place; data >>mon; data >>exp; } else { cout <<"Error loading data!\n"; cin.get(); changePlace(); } data.close(); cout <<"Data loaded! successfully!\n"; cin.get(); changePlace(); return 0;}int Game::changePlace() { switch (place) { case 0: menu(); break; case 1: house(); break; case 2: town(); break; default: changePlace(); } return 0;}int Game::town() { system("cls"); choice = 0; mclass = m[rand() % 3]; if (mclass == 1) { mname = "Ghost"; mhp = 30; matk = 1; mstr = 1; mdef = 10; } else if (mclass == 2) { mname = "Goblin"; mhp = 25; matk = 3; mstr = 5; mdef = 1; } else if (mclass == 3) { mname = "Ghoul"; mhp = 40; matk = 5; mstr = 9; mdef = 3; } else if (mclass == 0) { mname = "Pixie"; mhp = 10; matk = 2; mstr = 5; mdef = 1; } cout <<"HP " <<hp <<" - ATK " <<atk <<" STR "<<str << " DEF "<<def <<" EXP " <<exp <<"\n\n\n\n"; cout <<"The town is quiet - no one is around. There are a few shacks around you. What do you do?\n"; cout <<" 1 - ENTER HOUSE\n"; cout <<" 2 - GYM\n"; cout <<" 3 - BATTLE\n"; cout <<"> "; 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 = 1; hp = 100; cout <<"HP " <<hp <<" - ATK " <<atk <<" STR "<<str << " DEF "<<def <<" EXP " <<exp <<"\n"; cout <<"MONEY: " <<mon <<"\n\n\n\n"; cout <<"You enter the cozy shack and examine your surroundings. A fireplace is to the right of you and a small table with chairs lie in the center of the room. What do you do?\n"; cout <<" 1 - SAVE\n"; cout <<" 2 - MENU\n"; cout <<" 3 - LEAVE\n"; cout <<"> "; cin >>choice; cin.ignore(); switch (choice) { case 1: save(); break; case 2: menu(); break; case 3: town(); break; default: house(); break; } return 0;}int Game::gym() { system("cls"); choice = 0; cout <<"HP " <<hp <<" - ATK " <<atk <<" STR "<<str << " DEF "<<def <<" EXP " <<exp <<"\n"; cout <<"MONEY: " <<mon <<"\n\n\n\n"; cout <<"You enter the building and immediately you are hit by the cool breeze of air conditioning. You look around you and the place seems empty when the manager approaches you. What do you do?\n"; cout <<" 1 - LIFT WEIGHTS (+ rand() str)\n"; cout <<" 2 - PRACTICE WEAPONARY (+ rand() atk)\n"; cout <<" 3 - ENDURE BEATING (+ rand() def)\n"; cout <<" 4 - LEAVE\n"; cout <<"> "; 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 >= 50) { temp = rand() % 5 + 1; mon -= 50; cout <<"You pay fifty dollars and lift weights! (+ " <<temp << " str!)\n"; str += temp; cin.get(); gym(); } else if (mon < 50) { cout <<"You do not have enough money for lifting weights!\n"; cin.get(); gym(); } return 0;}int Game::weap() { system("cls"); if (mon >= 75) { temp = rand() % 5 + 1; mon -= 75; cout <<"You pay seventy-five dollars and practice weaponary! (+ " <<temp <<" atk!)\n"; atk += temp; cin.get(); gym(); } else if (mon < 75) { cout <<"You do not have enough money for practicing weaponary!\n"; cin.get(); gym(); } return 0;}int Game::beat() { system("cls"); if (mon >= 40) { temp = rand() % 3 + 1; mon -= 40; cout <<"You pay fourty dollars and endure a beating! (+ " <<temp << " def!)\n"; def += temp; cin.get(); gym(); } else if (mon < 40) { cout <<"You do not have enough money for enduring a beating!\n"; cin.get(); gym(); } return 0;}int Game::battle() { system("cls"); choice = 0; cout <<"HP " <<hp <<" - ATK " <<atk <<" STR "<<str << " DEF "<<def <<" EXP " <<exp <<"\n"; cout <<"MONEY: " <<mon <<"\n\n\n\n"; cout <<"You are fighting a " <<mname <<"!\n\n"; cout <<"Decide!\n"; cout <<" 1 - ATTACK\n"; cout <<" 2 - FLEE\n"; cout <<"> "; cin >>choice; cin.get(); goto choose;idle: system("cls"); cout <<"HP " <<hp <<" - ATK " <<atk <<" STR "<<str << " DEF "<<def <<" EXP " <<exp <<"\n"; cout <<"MONEY: " <<mon <<"\n\n\n\n"; cout <<"You are fighting a " <<mname <<"!\n\n"; cout <<"You twiddle your thumbs.\n"; cout <<"> "; cin >>choice; cin.get();choose: switch (choice) { case 1: attack(); break; case 2: flee(); break; default: goto idle; break; } return 0;}int Game::attack() { system("cls"); int chance = rand() % 200 + 50; if (chance >= 100) { cout <<"MHP " <<mhp <<" - MATK " <<matk <<" MSTR "<<mstr << " MDEF "<<mdef <<"\n"; cout <<"You strike for " <<atk + str - mdef <<" damage!\n"; mhp -= atk + str - mdef; cin.get(); } else if (chance < 100) { cout <<"HP " <<hp <<" - ATK " <<atk <<" STR "<<str << " DEF "<<def <<"\n"; cout <<mname <<" strikes for " <<matk + mstr - def <<" damage!\n"; hp -= matk + str - def; cin.get(); } if (hp <= 0) { cout <<"You died.\n"; cin.get(); house(); } else if (mhp <= 0) { cout <<"HP " <<hp <<" - ATK " <<atk <<" STR "<<str << " DEF "<<def <<"\n"; temp = rand() % 30 + 10; cout <<"You won the fight! (+ " <<temp <<" money!)\n"; mon += temp; cin.get(); temp = rand() % mclass + 1; cout <<"You also gained " <<temp <<" exp!"; exp += temp; cin.get(); town(); } battle(); return 0;}int Game::flee() { system("cls"); cout <<"You flee!\n"; cin.get(); town(); return 0;}int main () { Game game; game.m[0] = 0; game.m[1] = 1; game.m[2] = 2; game.m[3] = 3; game.menu(); return 0;}