1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357
|
#include <iostream>
#include <cstdlib>
using namespace std;
//MENU FUNCTION
int LifeMenu(int x ){
x = 3;
string answer;
cout << "WELCOME TO RPG LIFE!!\n\n";
cout << "Press y or n to make choice.\n";
cout << "At anytime, press i to show stats.\n\n";
cout << "Are you ready to play?\n";
cout << "y/n?";
cout << endl;
do{
cout << "Input: ";
cin >> answer;
if(answer == "y"){
cout << endl;
cout << "Great!\n";
x = 1;
return x;
}
else if(answer == "n"){
cout << endl;
cout<< "ok, bye then!!\n";
x = 0;
return x;
}
else cout << "Wrong Input!!!\n\n";
}while(x == 3);
}
int FindMoney(int x, int hp){
string answer;
x = x;
hp = hp;
int y = 3; //Value to manage do-while loop
do{
cout << "You are walking along when you find some money on the ground.\n\n";
cout << "Pick it up?\n";
//Input option
cout << "y/n?\n";
cout << "Input: ";
cin >> answer;
cout << endl;
//if answer is y then pick up the money
if(answer == "y"){
cout << "You pick up 20 dollars!\n";
x += 20; // x = x + 20
return x;
y = 1;
}
//if answer is n, do not pick up the money
else if(answer == "n"){
cout << "You leave the money on the ground!\n";
cout << endl;
x = x;
return x;
y = 2;
}
else if(answer == "i"){
system("CLS");
cout << "Your Inventory:\n\n";
cout << "Money: " << x;
cout << endl;
cout << "Health: " << hp;
cout << endl;
cout << endl;
cout << endl;
cin.get();
}
else cout << "wrong input!\n";
}while( y == 3);
}
int EnterShop(int x, int knife, int hp){
knife = 0;
int y = 3;
string answer;
do{
cout << "You enter a shop and see a pocket knife for 25 dollars.\n";
cout << "Would you like to buy it?\n";
cout << "y/n?\n";
cout << "Input: ";
cin >> answer;
if(answer == "y"){
if(x >= 25 ){
cout << "You buy the knife!\n";
knife = 1;
y = 1;
return knife;
x -= 25;
return x;
}
else cout << "You do not have enough money!!\n";
knife = 0;
}
else if(answer == "n"){
cout << "You leave the knife on the shelf and walk away\n";
y = 1;
return knife;
}
else if(answer == "i"){
system("CLS");
cout << "Your Inventory:\n\n";
cout << "Money: " << x;
cout << endl;
cout << "Health: " << hp;
cout << endl;
cout << endl;
cout << endl;
cin.get();
}
else cout << "Invalid Input!\n";
}while(y != 1);
}
int HostileMan(int x, int knife, int hp){
string answer;
int y = 3;
x = x;
do{
cout << "Upon leaving the shop you are pulled into a back alley\n";
cout << "A dark hooded figure with a low pitched voice says:\n\n";
cout << " 'Give me your MONEY'\n\n";
cout << "Do you want to attack him?\n";
cout << "y/n\n";
cout << "Input: ";
cin >> answer;
if(answer == "y"){
y = 1;
system("CLS");
if(knife == 1 ){
cout << "You stab the man in the chest and run!\n";
hp = hp;
return hp;
}
else if(knife == 0){
cout << "You hit the man, but he breaks your arm\n";
cout << "He takes your money and runs!\n";
hp -=60;
return hp;
}
}
else if(answer == "n"){
y = 1;
system("CLS");
cout << "You make a dart behind you but the man grabs your jumper\n";
cout << "He then proceeds to rape you....\n";
hp -= 20;
return hp;
}
if(answer == "i"){
system("CLS");
cout << "Your Inventory:\n\n";
cout << "Money: " << x;
cout << endl;
cout << "Health: " << hp;
cout << endl;
if (knife == 1 ){
cout << "A knife.";
}
cout << endl;
cout << endl;
cout << endl;
cin.get();
}
}while(y != 1);
}
int HaveAShower(int x, int knife,int hp){
string answer;
int y = 3;
system("CLS");
do{
cout << "You quickly make your way back home.\n";
cout << "Would you like to have a shower?\n";
cout << "y/n?\n";
cout << "Input: ";
cin >> answer;
if(answer == "y"){
y = 1;
system("CLS");
cout << "Your hp increases by 25 (if not already at 100)\n";
if(hp < 100)
hp += 25;
if(hp > 100)
hp = 100;
return hp;
}
else if(answer == "n"){
y = 1;
system("CLS");
cout << "You decide not to have a shower.\n";
}
else if(answer == "i"){
system("CLS");
cout << "Your Inventory:\n\n";
cout << "Money: " << x;
cout << endl;
cout << "Health: " << hp;
cout << endl;
if (knife == 1 ){
cout << "A knife.";
}
cout << endl;
cout << endl;
cout << endl;
cin.get();
}
}while(y == 3);
}
int SeeMan(int x, int knife, int hp, int enemy){
string answer;
int y = 3;
system("CLS");
enemy = 0;
do{
cout << "You hear a sound at the front door.\n";
cout << "Do you investigate?\n";
cout << "y/n?\n";
cout << "Input: ";
cin >> answer;
if(answer == "y"){
y = 1;
system("CLS");
cout << "You walk to the door and put your eye to the door....\n";
cout << "To your HORROR you recognise the man in the hoody!!\n";
enemy = 1;
return enemy;
}
else if(answer == "n"){
y = 1;
system("CLS");
cout << "You put your focus back onto the TV.\n";
}
else if(answer == "i"){
system("CLS");
cout << "Your Inventory:\n\n";
cout << "Money: " << x;
cout << endl;
cout << "Health: " << hp;
cout << endl;
if (knife == 1 ){
cout << "A knife.";
}
cout << endl;
cout << endl;
cout << endl;
cin.get();
}
}while(y == 3);
}
int main()
{
//VARIABLES
int play;//play or not play
int money = 5;//Variable to hold amount of money
int weapon = 0;//weapon or no weapon
int health = 100;//health variable
int seen = 0;
play = LifeMenu(play); //play variable is equal to value returned from function
switch(play){ //switch the play variable
case 1:
system("CLS"); //clear screen
money = FindMoney(money,health); //money equal to variable of money returned from function
system("CLS");
weapon = EnterShop(money,weapon,health); //weapon variable equal to variable of money returned from function
if(weapon == 1 ) //if brought a weapin, deduct $20 from money variable
{
money -= 20;
}
system("CLS");
health = HostileMan(money,weapon, health); //Health variable changes depending on fight
if(health != 100 ) //if health not equal to 100...
{
money -= money; //Take away ALL money
}
health = HaveAShower(money, weapon, health);
seen = SeeMan(money, weapon, health, seen);
case 2:
break;
default:
break;
}
}
|