· 8 years ago · Jun 18, 2018, 11:02 PM
1/*Constructor*/
2Game::Game()
3{
4 srand(time(NULL));
5 damageTree = new BST<int>;
6 for (int i = rand() % 5 + 10; i > 0; i--)
7 {
8 damageTree->setRoot(damageTree->insertBST(damageTree->getRoot(), (rand() % 3 + 1)));
9 }
10 successEncounter = false;
11 encounterMAX = 10;
12 enemystat = 7;
13 enemyTable = new HashTable<Enemy>;
14 createEnemyTable();
15 createNPCs();
16}
17
18/*********************************************************************************************/
19//Game functions
20/*********************************************************************************************/
21/*Display in-game Stage action menu
22 Pre: Player pointer
23 Post: one of four Stage actions is executed*/
24void Game::playerChoiceScreen(Player *yourPlayer)
25{
26 //continue STAGE operations if player is still alive
27 if (yourPlayer->getEncounterNum() <= encounterMAX)
28 {
29 while (yourPlayer->getCurrentHealth() > 0 && yourPlayer->getEncounterNum() <= encounterMAX)
30 {
31 int choice = 0;
32 bool valid = false; //used to validate STAGE action user input
33 do
34 {
35 //prompt player for STAGE action
36 std::cout << "\n==============================================\n";
37 std::cout << "Stage: " << yourPlayer->getEncounterNum() << std::endl; //completed encounters only
38 std::cout << "Health: " << yourPlayer->getCurrentHealth() << "/" << yourPlayer->getHealth() << std::endl;
39 std::cout << "1. Continue Forward\n2. Check Journal\n3. Save Game\n4. Cheat\n5. Exit to Main Menu\nYour Choice: ";
40 std::cin >> choice; //need to add check for invalid input //Ram will add later
41 std::cin.ignore();
42 if (std::cin.fail())
43 {
44 std::cin.clear(); //clear error flage
45 std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
46 std::cout << "Invalid, input must be an integer." << std::endl;
47 }
48 //validate input range
49 else if (choice < 1 || choice > 5)
50 {
51 std::cout << "Invalid, choice must be between 1 & 4." << std::endl;
52 }
53 //input is valid
54 else
55 valid = true;
56 } while (!valid);
57
58 std::cout << std::endl
59 << "==============================================" << std::endl;
60
61 //execute player STAGE action
62 if (choice == 5) //exit game
63 {
64 break;
65 }
66 else if (choice == 1) //player encounter
67 {
68 launchEncounter(yourPlayer);
69 }
70 else if (choice == 2) //player journal
71 {
72 showJournal(yourPlayer);
73 }
74 else if (choice == 3) //save game to file
75 {
76 saveGame(yourPlayer);
77 }
78 else if (choice == 4)
79 {
80 std::cout << "You have chosen to cheat." << std::endl;
81 edit(yourPlayer);
82 }
83 }//END OF WHILE
84 }
85 else
86 {
87 std::cout << "Congratulation on clearing our Data abstraction Project!\n";
88 std::cout << "To play again you will be returned to the main menu to either reset this file, or create a new one!\n";
89 std::cout << "Thank you for playing our Game.\n";
90 std::cout << "CREDITS:\nDesign Team: Ram, Hamdan Syed, David Garcia\nSpecial Thanks: Ferdinand A., Mr. Goel.";
91 }
92}
93
94/*Hash table of Enemy objects is created from input file of Enemy data values
95 Pre: void
96 Post: hash table is filled with Enemy objects*/
97void Game::createEnemyTable()
98{
99 std::ifstream enemyFile;
100 std::string dummy;
101 enemyFile.open("EnemyList.txt");
102 if (!enemyFile)
103 {
104 char y = 'a';
105 throw y;
106 }
107 Enemy newEnemy;
108 int intconvert = 0;
109 std::string stringInput;
110 while (!enemyFile.eof())
111 {
112 for (int estat = 0; estat < enemystat; estat++)
113 {
114 std::getline(enemyFile, stringInput, '\t');
115 if (estat == 0)
116 {
117 newEnemy.setName(stringInput);
118 }
119 else if (estat > 0 && estat < 6)
120 {
121 intconvert = std::stoi(stringInput);
122 if (estat == 1)
123 newEnemy.setEnemyID(intconvert);
124 else if (estat == 2)
125 {
126 newEnemy.setHealth(intconvert);
127 newEnemy.setCurrentHealth(intconvert); //enemy health does not need to updated like players does between saves.
128 }
129 else if (estat == 3)
130 newEnemy.setAttack(intconvert);
131 else if (estat == 4)
132 newEnemy.setDefense(intconvert);
133 else if (estat == 5)
134 newEnemy.setSpeed(intconvert);
135 }
136 else
137 {
138 double goldcount = std::stod(stringInput);
139 newEnemy.setGold(goldcount);
140 }
141 }
142 enemyTable->insertData(newEnemy);
143 std::getline(enemyFile, dummy, '\n');
144 }
145}
146
147/*Member NPC pointers intialized to different types of NPCS
148 Pre: void
149 Post: NPC objects initialized to unique types*/
150void Game::createNPCs()
151{
152 //Dynamically allocate NPCs on the heap
153 shopKeep = new NPC;
154 salesMan = new NPC;
155 bazaar = new NPC;
156 //Initialize NPCs with preset values
157 //npc 1 ShopKeep
158 shopKeep->setName("Old Man");
159 shopKeep->setBagSize(3);
160 shopKeep->setUpShop();
161 shopKeep->addToShop("Potion", 20, 0);
162 shopKeep->addToShop("Shield", 25, 1);
163 shopKeep->addToShop("Wooden Sword", 30, 2);
164 shopKeep->setSlogan("It's dangerous to go alone! BUY these: \n");
165 //npc 2 SalesMan
166 salesMan->setName("Gavlan");
167 salesMan->setBagSize(6);
168 salesMan->setUpShop();
169 salesMan->addToShop("Defence Up", 60, 0);
170 salesMan->addToShop("Bomb", 45, 1);
171 salesMan->addToShop("Bow", 40, 2);
172 salesMan->addToShop("Potion", 15, 3);
173 salesMan->addToShop("Deku Stick", 70, 4);
174 salesMan->addToShop("Bottle", 999, 5);
175 salesMan->setSlogan("Gavlan wheel, Gavlan Deal!: \n");
176 //npc 3 Bazaar
177 bazaar->setName("Griswold");
178 bazaar->setBagSize(3);
179 bazaar->setUpShop();
180 bazaar->addToShop("Master Sword", 200, 0);
181 bazaar->addToShop("Falchion", 200, 1);
182 bazaar->addToShop("Attack Up", 100, 2);
183 bazaar->setSlogan("What can I do for ya?: \n");
184}
185
186/*Saves game Enemy objects from Hash Table into Enemy input file
187 Pre: void
188 Post: input Enemy file updated with hash table data*/
189void Game::updateEnemyFile() //mock version not accounting for collisions
190{
191 Enemy storage;
192 std::ofstream enemyFile;
193 enemyFile.open("EnemyList.txt");
194 for (int i = 1; i <= enemyTable->getSize(); i++) //starts at 1 cause lowest id is 1.
195 {
196 storage = enemyTable->fetchData(i);
197 enemyFile << storage.getName() << '\t';
198 enemyFile << storage.getEnemyID() << '\t';
199 enemyFile << storage.getHealth() << '\t';
200 enemyFile << storage.getAttack() << '\t';
201 enemyFile << storage.getDefense() << '\t';
202 enemyFile << storage.getSpeed() << '\t';
203 enemyFile << storage.getGold() << '\t';
204 if (i == enemyTable->getSize())// if on the very last element
205 enemyFile.close();
206 else
207 enemyFile << '\n'; //do not need to output new line if on the last element.
208 }
209}
210
211/*Current game progress is saved to game save file
212 Pre: Player pointer
213 Post: current player and game data is saved to ouput file*/
214void Game::saveGame(Player *yourPlayer) //new 6/3/18 //not confirmed if working just groundwork code //IMPORTANT NOTE OVERWRITTING A SAVE DOES NOT PROPERLY UPDATE THE OUPUT DATA IN SHOWSAVE IF A USER RETURNS THERE FORM THE MAIN MENU. THE LIKELY RESULT IS BECAUSE PLAYERTHREE IS NOT UPDATED.
215{
216 std::fstream saveFile;
217 std::string schoice;
218 std::cout << "Overwritting this file will permanently remove its previous set of data from the game.\n Are you sure you want to overwrite it?(y/n): ";
219 std::getline(std::cin, schoice);
220 if (schoice == "y")
221 {
222 std::string save;
223 save = yourPlayer->getName() + ".txt";
224
225 saveFile.open(save, std::ios::out | std::fstream::trunc); //clears character data in file
226 //saveFile.close();
227 //saveFile.open(save, std::ios::out); //reset the file
228 saveFile << yourPlayer->getName() << '\t';
229 saveFile << yourPlayer->getPassword() << '\t';
230 saveFile << yourPlayer->getHealth() << '\t';
231 saveFile << yourPlayer->getCurrentHealth() << '\t';
232 saveFile << yourPlayer->getAttack() << '\t';
233 saveFile << yourPlayer->getDefense() << '\t';
234 saveFile << yourPlayer->getSpeed() << '\t';
235 saveFile << yourPlayer->getEncounterNum() << '\t';
236 saveFile << yourPlayer->getGold() << '\t';
237 saveFile << yourPlayer->getBagSize() << '\t';
238 saveFile << yourPlayer->getJournalSize() << '\t';
239 std::string bagitem;
240 for (int items = 0; items < yourPlayer->getBagSize(); items++)
241 {
242 bagitem = yourPlayer->outputBag(items);
243 saveFile << bagitem << '\t';
244 }
245 std::string jentry = "";
246 jentry = yourPlayer->getJournalEntries(yourPlayer->getJournalSize());
247 saveFile << jentry;
248 saveFile.close();
249
250 std::cout << "Your game has been saved.\n";
251 }
252}
253
254/*Displays player journal consisting of game events and encounters in sequence
255 Pre: Player pointer
256 Post: player journal displayed*/
257void Game::showJournal(Player *yourPlayer) //new 6/3/18 not confirmed if working just groundowrk code
258{
259 std::string jchoice;
260 bool exists = false;
261 std::cout << "\n==============================================\nThese are your journal entries:\n";
262 yourPlayer->outputJournal();
263 std::cout << "==============================================\n";
264 std::cout << "Which journal entry would you liked to see? (enter name) CASE SENSITIVE: ";
265 std::getline(std::cin, jchoice);
266 exists = yourPlayer->checkJournal(jchoice);
267 if (exists)
268 {
269 std::cout << "Entry found.\n";
270 journalDB(jchoice);
271 }
272 else
273 {
274 std::cout << "Entry not found.\n";
275 }
276}
277
278/*Journal entries database consisting of encountered items and events
279 Pre: string entry
280 Post: void*/
281void Game::journalDB(std::string entry)
282{
283 std::cout << "*******************************************************\n";
284 if (entry == "Potion")
285 {
286 std::cout << "An elixer with healing properties. If consumed it will restore 60 health.\n";
287 }
288 else if (entry == "Shield")
289 {
290 std::cout << "A small shield. Lowers the amount of damage taken during current fight.\n";
291 }
292 else if (entry == "Wooden Sword")
293 {
294 std::cout << "Though it may be made out of wood, splinters are nothing to joke about.\n";
295 }
296 else if (entry == "Defence Up")
297 {
298 std::cout << "Permanently raise your characters defense!\n";
299 }
300 else if (entry == "Attack Up")
301 {
302 std::cout << "Permanently raise your characters offense!\n";
303 }
304 else if (entry == "Bomb")
305 {
306 std::cout << "Obtained by stealing them from Tetra's crew on WindFall Island. Deals 70 damage to the enemy.\n";
307 }
308 else if (entry == "Bow")
309 {
310 std::cout << "Become the William Tell of Visual Studios. Deals 45 damage to the enemy while lowering their defense.\n";
311 }
312 else if (entry == "Bottle")
313 {
314 std::cout << "Get em for 100% completion.\n";
315 }
316 else if (entry == "Deku Stick")
317 {
318 std::cout << "Why did you buy this from Gavlan?\n";
319 }
320 else if (entry == "Steel Sword")
321 {
322 std::cout << "Deals 80 damage to the enemy. Substantially stronger than its' Wooden counterpart.\n";
323 }
324 else if (entry == "Master Sword")
325 {
326 std::cout << "Evil's Bane. Deals a whopping 300 damage to the enemy while lowering their defences.\n";
327 }
328 else if (entry == "Falchion")
329 {
330 std::cout << "The sword of the chosen fighter. Deals 250 Damage to the enemy while raising your Attack.\n";
331 }
332 else if (entry == "Old Man")
333 {
334 std::cout << "Save the Princess!\n";
335 }
336 else if (entry == "Gavlan")
337 {
338 std::cout << "Gavlan Wheel! Gavlan Deal!\n";
339 }
340 else if (entry == "Griswold")
341 {
342 std::cout << "obvBrk\n";
343 }
344 else if (entry == "Ferdinand")
345 {
346 std::cout << "Contributed to the design of the game in it's early stages.\n";
347 }
348 else
349 {
350 std::cout << "Extra Monster Data has not been properly recorded.\n";
351 }
352 std::cout << "*******************************************************\n";
353}
354
355/*********************************************************************************************/
356//Encounter functions
357/*********************************************************************************************/
358/*Executes encounter type (NPC, Loot, Enemy)
359 Pre: Player pointer
360 Post: Player interacts with corresponding encounter type*/
361void Game::launchEncounter(Player *yourPlayer)
362{
363 //generate random integer 1-100
364 int type = rand() % 100 + 1;
365 //after 10th stage the encounter will be a BOSS fight
366 if (yourPlayer->getEncounterNum() == encounterMAX)
367 {
368 std::cout << "*****WARNING*****\n*****WARNING*****\n*****WARNING*****\n";
369 Enemy Boss = enemyTable->fetchData(25);
370 fight(yourPlayer, &Boss);
371 std::cout << "Mr. Goel appears! Should have dropped the class! Hope you are ready to get Schooled!\n";
372 if (yourPlayer->getCurrentHealth() > 0)
373 {
374 std::cout << "You Won!" << std::endl;
375 yourPlayer->addNewEntry(Boss.getName());
376 yourPlayer->setGold(yourPlayer->getGold() + Boss.getGold());
377 std::cout << "You got " << Boss.getGold() << " gold for winning!\n";
378 yourPlayer->setEncounterNum(yourPlayer->getEncounterNum() + 1);
379 }
380 else
381 std::cout << "You Died!" << std::endl;
382 return;
383 }
384 //ENEMY encounter
385 else if (type <= 70)
386 {
387 //launch ENEMY encounter
388 enemyEncounter(yourPlayer);
389 //player won battle
390 if (yourPlayer->getCurrentHealth() > 0)
391 {
392 std::cout << "Your stats have increased!" << std::endl;
393 yourPlayer->setHealth(yourPlayer->getHealth() + 20);
394 yourPlayer->setCurrentHealth(yourPlayer->getCurrentHealth() + 20);
395 yourPlayer->setAttack(yourPlayer->getAttack() + 3);
396 yourPlayer->setDefense(yourPlayer->getDefense() + 3);
397 yourPlayer->setSpeed(yourPlayer->getSpeed() + 3);
398 yourPlayer->setEncounterNum(yourPlayer->getEncounterNum() + 1);
399 }
400 //player lost battle
401 else
402 {
403 std::cout << "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nYou have died, returning to main menu.\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n";
404 yourPlayer->setCurrentHealth(yourPlayer->getHealth());
405 std::cout << "Returning you to checkpoint.\n";
406 }
407 }
408 //NPC encounter
409 else if (type > 70 || type <= 90)
410 {
411 //launch NPC encounter
412 npcEncounter(yourPlayer);
413 //increment Player's Game Stage
414 yourPlayer->setEncounterNum(yourPlayer->getEncounterNum() + 1);
415 }
416 //LOOT encounter
417 else if (type > 90)
418 {
419 //launch LOOT encounter
420 lootEncounter(yourPlayer);
421 //increment Player's Game Stage
422 yourPlayer->setEncounterNum(yourPlayer->getEncounterNum() + 1);
423 }
424}
425
426/*BATTLE type encounter; A random Enemy object from the Enemy array and the Player object are passed to Game::fight(), after the fight
427it checks if the player is alive and displays a message, a separate message if he is dead.
428 Pre: Player pointer
429 Post: Player interacts with Enemy object*/
430void Game::enemyEncounter(Player *yourPlayer)
431{
432 Enemy myenemy;
433 //temprary case until we add in hash table //myenemy is being left as a static local variable because if we kill an enemy, we still want it's data to remain constant in the heap in case it is called again.
434 int enemyType;
435 if (yourPlayer->getEncounterNum() < 4)
436 enemyType = rand() % 7 + 1;
437 else if (yourPlayer->getEncounterNum() > 3 || yourPlayer->getEncounterNum() < 7)
438 enemyType = rand() % (17 - 10) + 10;
439 else if (yourPlayer->getEncounterNum() > 6)
440 enemyType = rand() % (24 - 18) + 18;
441 myenemy = enemyTable->fetchData(enemyType);
442 std::cout << "You have encountered an enemy: " << myenemy.getName() << "!" << std::endl << std::endl;
443 //commence fight
444 fight(yourPlayer, &myenemy);
445 std::cout << std::endl << "Battle is over." << std::endl;
446 //check who survived
447 if (yourPlayer->getCurrentHealth() > 0)
448 {
449 std::cout << "You Won!" << std::endl;
450 yourPlayer->addNewEntry(myenemy.getName());
451 yourPlayer->setGold(yourPlayer->getGold() + myenemy.getGold());
452 std::cout << "You got " << myenemy.getGold() << " gold for winning!\n";
453 }
454 else
455 std::cout << "You Died!" << std::endl;
456}
457
458/*BATTLE type encounter; Displays battle ACTIONS player can perform (ATTACK, DEFEND, USE ITEM, RUNAWAY), reads player choice, and passes the
459validated action choice to Game::launchBattleAction().
460 Pre: Player Pointer
461 Enemy Pointer
462 Post: - Player chooses a Battle action*/
463void Game::chooseAction(Player *yourPlayer, Enemy* enemy)
464{
465 //prompt user for battle ACTION
466 std::cout << std::endl << "Your move, what would you like to do?" << std::endl;
467
468 //display battle ACTIONS
469 showBattleMenu(yourPlayer, enemy);
470
471 //read in and validate ACTION choice
472 std::cout << "Action choice: ";
473 int actionChoice;
474 bool valid = false;
475 do
476 {
477 //read in action choice
478 std::cin >> actionChoice;
479
480 //validate input type
481 if (std::cin.fail())
482 {
483 std::cin.clear(); //clear error flag
484 std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
485 std::cout << "Invalid, input must be an integer." << std::endl;
486 }
487
488 //validate input range
489 else if (actionChoice < 1 || actionChoice > 4)
490 {
491 std::cout << "Invalid, choice must be between 1 & 4." << std::endl;
492 std::cin.ignore();
493 }
494
495 //input is valid
496 else
497 {
498 valid = true;
499 }
500 } while (!valid);
501
502 std::cout << std::endl;
503
504 //execute Player battle ACTION
505 launchBattleAction(yourPlayer, enemy, actionChoice);
506}
507
508/*BATTLE type encounter: compares action integer to either execute ATTACK, DEFEND, USE ITEM, or RUNAWAY.
509Each action counts as a complete battle turn.
510ATTACK: player does damage to enemy, determined by Player base damage and damage generator
511DEFEND: uses Player defend attribute to minimise attack from Enemy object.
512USE ITEM: launches bag menu to choose Item
513RUNAWAY: 50% chance of succesful escape, otherwise lost turn and Enemy attacks.
514 Pre: Player pointer
515 Enemy pointer
516 Integer action
517 Post: Game executes a Battle action*/
518void Game::launchBattleAction(Player* yourPlayer, Enemy* enemy, int action)
519{
520 bool actionComplete = true;
521 do
522 {
523 if (actionComplete == false)
524 {
525 showBattleMenu(yourPlayer, enemy);
526 std::cout << "Action choice: ";
527 bool valid = false;
528 do
529 {
530 //read in action choice
531 std::cin >> action;
532
533 //validate input type
534 if (std::cin.fail())
535 {
536 std::cin.clear(); //clear error flag
537 std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
538 std::cout << "Invalid, input must be an integer." << std::endl;
539 }
540
541 //validate input range
542 else if (action < 1 || action > 4)
543 {
544 std::cout << "Invalid, choice must be between 1 & 4." << std::endl;
545 std::cin.ignore();
546 }
547
548 //input is valid
549 else
550 {
551 valid = true;
552 }
553 } while (!valid);
554 }
555 //ATTACK action
556 if (action == 1)
557 {
558 //player attacks
559 damage = hitorcrit(yourPlayer->getAttack()) - (enemy->getDefense() * hit() / 2); // plus hamdans random generator
560 if (damage < 0)
561 damage = 0;
562 std::cout << "Your attack did " << damage << " damage." << std::endl;
563
564 //update enemy health
565 enemy->setCurrentHealth(enemy->getCurrentHealth() - damage);
566 actionComplete = true;
567 }
568 //DEFEND action
569 else if (action == 2)
570 {
571 //set enemy attack damage reduced by player defense
572 damage = hitorcrit(enemy->getAttack()) - (yourPlayer->getDefense() * hit() / 2);
573 //diplay damage amount player defended from
574 //display damage amount player took
575 if (damage > 0)
576 {
577 std::cout << "Your defence helped against " << damage << " damage";
578 //update player health
579 yourPlayer->setCurrentHealth(yourPlayer->getCurrentHealth() - damage);
580 }
581 //player blocked full attack
582 else
583 {
584 std::cout << "You blocked the attack and took no damage!" << std::endl << std::endl;
585 }
586 actionComplete = true;
587 }
588 //USE ITEM action
589 else if (action == 3)
590 {
591 std::cout << std::endl << "Player bag size: " << yourPlayer->getBagSize() << std::endl;
592 //get item from bag
593 if (yourPlayer->getBagSize() < 1)
594 {
595 std::cout << "Item Bag is empty.\n";
596 actionComplete = true;
597 }
598 else
599 {
600 std::string playerItem = itemMenu(yourPlayer);
601 if (playerItem == "exit")
602 {
603 actionComplete = false;
604 }
605 else
606 {
607 //std::cout << "Using item: " << playerItem << " from bag." << std::endl;
608 itemEffectDB(playerItem, yourPlayer, enemy);
609 actionComplete = true;
610 }
611 }
612 }
613 //RUNAWAY action
614 else if (action == 4)
615 {
616 //player cannot run back if at stage 0
617 if (yourPlayer->getEncounterNum() == 0)
618 std::cout << std::endl << "You cannot runaway you just started the game!" << std::endl;
619 else
620 {
621 //calculate random chance of succesfull escape
622 int escaped = rand() % 100 + 1;
623 std::cout << "You try to runaway, you have 30% chance of escaping." << std::endl;
624 //30% chance of escape
625 if (escaped >= 70)
626 {
627 //alert Player of escape status
628 std::cout << "You escaped!" << std::endl << std::endl;
629 //bring player back a stage
630 //yourPlayer->setEncounterNum(yourPlayer->getEncounterNum() - 1);
631 //std::cout << std::endl << "You ran all the way back to stage: " << yourPlayer->getEncounterNum() << std::endl;
632 }
633 else
634 {
635 //alert Player of escape status
636 std::cout << "You failed to escape!" << " Enemy caught and attacked you!" << std::endl;
637 //enemy attacks
638 damage = hitorcrit(enemy->getAttack());
639 //display damage amount
640 std::cout << std::endl << "Enemy did " << damage << " damage to you!" << std::endl;
641 //update player health
642 yourPlayer->setCurrentHealth(yourPlayer->getCurrentHealth() - damage);
643 }
644 }
645 actionComplete = true;
646 }
647 } while (!actionComplete);
648}
649
650/*LOOT type encounter; A random integer from 1 to 15 is used to calculate if the loot will be COMMON, RARE, or LEGENDARY.
651The loot (GOLD) is added to the Player object.
652 Pre: Player pointer
653 Post: Player interacts with loot type*/
654void Game::lootEncounter(Player *yourPlayer)
655{
656 //alert player of encounter type
657 std::cout << "You have encountered loot!" << std::endl;
658 //calculate loot RARITY
659 int rarity = rand() % 15 + 1;
660 //COMMON loot
661 if (rarity < 9)
662 {
663 std::cout << "You found Common loot!" << std::endl;
664 yourPlayer->setGold(yourPlayer->getGold() + 30);
665 std::cout << "You now have " << yourPlayer->getGold() << " gold." << std::endl;
666 }
667 //RARE loot
668 else if (rarity >= 9 && rarity < 13)
669 {
670 std::cout << "You found Rare loot!" << std::endl;
671 std::cout << "You have found a Steel Sword!\n";
672 yourPlayer->addNewItem("Steel Sword");
673 yourPlayer->addNewEntry("Steel Sword");
674 }
675 //LEGENDARY loot
676 else if (rarity >= 13 && rarity < 16)
677 {
678 std::cout << "You found Legendary loot!" << std::endl;
679 yourPlayer->setGold(yourPlayer->getGold() + 200);
680 std::cout << "You now have " << yourPlayer->getGold() << " gold." << std::endl;
681 }
682}
683
684/*NPC type encounter: a random NPC type is choosen to interact with player
685 Pre: Player pointer
686 Post: Player interacts with NPC type*/
687void Game::npcEncounter(Player *yourPlayer) //inefficient case specific random npc encounter. should be recoded for future proofing in case of additions.
688{
689 int random = rand() % 100 + 1;
690
691 //allocate a new default NPC on the heap
692 NPC *yourNPC = new NPC;
693
694 //Initialze a randomly chosen Preset NPC, based on current Game Stage
695 //STAGE 1 - 3
696 if (yourPlayer->getEncounterNum() <= 3)
697 {
698 //80% ShopKeep
699 if (random <= 80)
700 yourNPC = shopKeep;
701 //20% SalesMan
702 else
703 yourNPC = salesMan;
704 }
705 //STAGE 4 - 5
706 else if (yourPlayer->getEncounterNum() > 3 || yourPlayer->getEncounterNum() < 6)
707 {
708 //40% ShopKeep
709 if (random <= 40)
710 yourNPC = shopKeep;
711 //50% SalesMan
712 else if (random > 40 || random <= 90)
713 yourNPC = salesMan;
714 //10% Bazaar
715 else
716 yourNPC = bazaar;
717 }
718 //STAGE 6+
719 else if (yourPlayer->getEncounterNum() >= 6)
720 {
721 //33% ShopKeep
722 if (random <= 33)
723 yourNPC = shopKeep;
724 //33% SalesMan
725 else if (random > 33 || random <= 66)
726 yourNPC = salesMan;
727 //67% Bazaar
728 else
729 yourNPC = bazaar;
730 }
731
732 //launch NPC Shop with Initialized NPC
733 std::cout << "You have encountered an NPC: " << yourNPC->getName() << "!" << std::endl;
734 npcShop(yourPlayer, yourNPC);
735
736 //unreference NPC pointer
737 yourNPC = nullptr;
738}
739
740/*NPC type encounter: displays NPC type and its Shop menu of available items for sale
741 Pre: Player pointer
742 NPC pointer
743 Post: Player interacts with NPC's shop of items for sale*/
744void Game::npcShop(Player* yourPlayer, NPC* yourNPC) //not finished //idea to create item class for item element storage
745{
746 int choice;
747 Item item;
748 do
749 {
750 //Display NPC dialogue
751 std::cout << yourNPC->getName() << ": " << yourNPC->getSlogan() << std::endl;
752
753 //validate input purchase item choice
754 bool valid = false;
755 do
756 {
757 std::cout << std::setw(16) << std::left << "Items: " << "Price: \n";
758 for (int i = 0; i < yourNPC->getBagSize(); i++)
759 {
760 item = yourNPC->showItem(i);
761 std::cout << i + 1 << ". " << item << std::endl; //need to add prices
762 }
763 std::cout << yourNPC->getBagSize() + 1 << ". Exit Shop.\n";
764 std::cout << "==============================================\nYour Funds: " << yourPlayer->getGold() << "g.\n";
765 std::cout << "What would you like to purchase?: ";
766 std::cin >> choice;
767 std::cin.ignore();
768
769 if (std::cin.fail())
770 {
771 std::cin.clear();
772 std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
773 std::cout << std::endl << "Invalid input! Must be an integer. " << std::endl;
774 }
775 //input range validation
776 else if (choice < 1 || choice > yourNPC->getBagSize() + 1)
777 std::cout << std::endl << "Input out of range! Choose a valid item." << std::endl << std::endl;
778 else
779 {
780 valid = true;
781 }
782 } while (!valid);
783
784 choice -= 1; //set choice to reflect the index;
785 if (choice < yourNPC->getBagSize())
786 {
787 item = yourNPC->showItem(choice);
788 if (yourPlayer->getGold() >= item.getPrice())
789 {
790 yourPlayer->addNewItem(item.getItemName());
791 yourPlayer->addNewEntry(yourNPC->getName());
792 yourPlayer->setGold(yourPlayer->getGold() - item.getPrice());
793 std::cout << "You have purchased: " << item.getItemName() << ". Remaining funds: " << yourPlayer->getGold() << "g.\n";
794 yourPlayer->addNewEntry(item.getItemName());
795 }
796 else
797 std::cout << "\nNot enough funds for this purchase.\n";
798 }
799 else
800 {
801 std::cout << std::endl << "Leaving NPC Shop" << std::endl;
802 break;
803 }
804 } while (yourPlayer->getGold() > 0);
805}
806
807/*********************************************************************************************/
808//Battle functions
809/*********************************************************************************************/
810/*Enemy tpye encounter: Player has encountered enemy has to battle
811 Pre: Player pointer
812 Enemy pointer
813 Post: Player interacts with battle system*/
814void Game::fight(Player *yourPlayer, Enemy* enemy)
815{
816 //initial attack
817 //Enemy is faster
818 if (yourPlayer->getSpeed() < enemy->getSpeed() && moves == 0)
819 {
820 damage = hitorcrit(enemy->getAttack()) - (yourPlayer->getDefense() * hit() / 2);
821 std::cout << "Enemy is faster than you, attacks first and does " << damage << " damage." << std::endl;
822 //update player health
823 yourPlayer->setCurrentHealth(yourPlayer->getCurrentHealth() - damage);
824 }
825 //fight until someone is dead
826 while (yourPlayer->getCurrentHealth() > 0 && enemy->getCurrentHealth() > 0) //implement attack type for user to choose //need to add in constant output of enemy and player health.
827 {
828 std::cout << std::setw(70) << "_____________________________________________________________________\n";
829 //prompt Player for battle ACTION
830 int tempStage = yourPlayer->getEncounterNum();
831 chooseAction(yourPlayer, enemy);
832 std::cout << std::setw(70) << "_____________________________________________________________________\n";
833
834 //player did not choose to Flee, Battle can continue
835 if (tempStage == yourPlayer->getEncounterNum())
836 {
837 //enemy attacks
838 if (enemy->getCurrentHealth() > 0)
839 {
840 damage = hitorcrit(enemy->getAttack()) - (yourPlayer->getDefense() * hit() / 2);
841 if (damage < 0)
842 damage = 0;
843 //update player health
844 yourPlayer->setCurrentHealth(yourPlayer->getCurrentHealth() - damage);
845
846 //display damage Player sustained
847 std::cout << std::endl << "Enemies turn:" << std::endl;
848 std::cout << "Enemy attacked you and did " << damage << " damage!" << std::endl;
849 }
850 }
851
852 //increment moves
853 moves++;
854 }
855 //std::cout << std::setw(70) << "_____________________________________________________________________\n";
856}
857
858/*BATTLE type encounter: Displays both Player and Enemy object statistics and Player Battle Action options, should be used before every Player move after the initial SPEED based attack.
859 Pre: Player pointer
860 Enemy pointer
861 Post: Player battle action options displayer in numbered order*/
862void Game::showBattleMenu(Player *yourPlayer, Enemy* enemy)
863{
864 std::cout << std::setw(20) << std::left << "Your choices" << std::setw(20) << std::left << yourPlayer->getName() << std::setw(20) << std::left << enemy->getName() << std::endl;
865 std::cout << std::setw(20) << std::left << "(1) Attack" << "Health: " << yourPlayer->getCurrentHealth() << "/" << std::setw(8) << std::left << yourPlayer->getHealth() << "Health: " << enemy->getCurrentHealth() << "/" << enemy->getHealth() << std::endl;
866 std::cout << std::setw(20) << std::left << "(2) Defend" << std::setw(20) << std::left << "Attack: " + std::to_string(yourPlayer->getAttack()) << std::setw(20) << std::left << "Attack: " + std::to_string(enemy->getAttack()) << std::endl;
867 std::cout << std::setw(20) << std::left << "(3) Item" << std::setw(20) << std::left << "Defense: " + std::to_string(yourPlayer->getDefense()) << std::setw(20) << std::left << "Defense: " + std::to_string(enemy->getDefense()) << std::endl;
868 std::cout << std::setw(20) << std::left << "(4) Flee" << std::setw(20) << std::left << "Speed: " + std::to_string(yourPlayer->getSpeed()) << std::setw(20) << std::left << "Speed: " + std::to_string(enemy->getSpeed()) << std::endl;
869}
870
871/*BATTLE type encounter; Speed from both Player and Enemy object are compared, the greater of the two
872is the first to attack, ONLY ONCE AT THE BEGGINING of a fight. Following actions are decided by user through an ACTION MENU
873and enemy always follows up with an Attack. Battling continues until one character dies.
874 Pre: Player pointer
875 Post: Player bag of items is displayed*/
876std::string Game::itemMenu(Player* yourPlayer)
877{
878 //Display bag contents
879 std::cout << "Bag contents: " << std::endl;
880 for (int i = 0; i < yourPlayer->getBagSize(); i++)
881 {
882 //prefix item with number
883 std::cout << i + 1 << ". " << yourPlayer->getBagItem(i + 1) << std::endl;
884 }
885 std::cout << yourPlayer->getBagSize() + 1 << ". Exit item menu.\n";
886
887 //READ in user item choice and validate
888 bool valid = false;
889 int choice;
890 do
891 {
892 //prompt user for item choice
893 std::cout << "Enter item choice: ";
894 std::cin >> choice;
895
896 //input is not a number
897 if (std::cin.fail())
898 {
899 std::cin.clear();
900 std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
901 std::cout << "Invalid input! Must be an integer" << std::endl;
902 }
903
904 //input is out of valid range
905 else if (choice < 1 || choice > yourPlayer->getBagSize() + 1)
906 {
907 std::cout << "Item choice out of range, must be an item from your bag" << std::endl;
908 }
909
910 //choose to exit to screen
911 else if (choice == yourPlayer->getBagSize() + 1)
912 {
913 return "exit";
914 }
915
916 //input is valid
917 else
918 {
919 valid = true;
920 }
921 } while (!valid);
922
923 //return item as string
924 std::string itemChoice = yourPlayer->getBagItem(choice);
925
926 //remove item from bag
927 yourPlayer->removeBagItem(choice);
928
929 return itemChoice;
930}
931
932/*Battle type encounter: item type database that can be used in battle
933 Pre: string item
934 Player pointer
935 Enemy pointer
936 Post: item and effect retrieved from database and applied to battle*/
937void Game::itemEffectDB(std::string item, Player *yourPlayer, Enemy *enemy)
938{
939 std::cout << "\n*********************************************************************\n";
940 if (item == "Potion")
941 {
942 yourPlayer->setCurrentHealth(yourPlayer->getCurrentHealth() + 60);
943 if (yourPlayer->getCurrentHealth() > yourPlayer->getHealth())
944 yourPlayer->setCurrentHealth(yourPlayer->getHealth());
945 std::cout << "You have consumed a Potion healing you for 60 HP.\n";
946 }
947 else if (item == "Wooden Sword")
948 {
949 enemy->setCurrentHealth(enemy->getCurrentHealth() - 30);
950 std::cout << "You use the Wooden Sword and deal 30 damage to the enemy.\n";
951 }
952 else if (item == "Shield")
953 {
954 enemy->setAttack(enemy->getAttack() - 5);
955 std::cout << "Your shield will mitigate enemy attacks!\n";
956 }
957 else if (item == "Bomb")
958 {
959 enemy->setCurrentHealth(enemy->getCurrentHealth() - 70);
960 yourPlayer->setCurrentHealth(yourPlayer->getCurrentHealth() - 20);
961 std::cout << "You deal 70 damage to the enemy, but the explosion damages you for 20.\n";
962 }
963 else if (item == "Bow")
964 {
965 enemy->setDefense(enemy->getDefense() - 5);
966 enemy->setCurrentHealth(enemy->getCurrentHealth() - 45);
967 std::cout << "Your shot pierces their defences for 45 damage, lowering their guard!\n";
968 }
969 else if (item == "Defence Up")
970 {
971 yourPlayer->setDefense(yourPlayer->getDefense() + 10);
972 std::cout << "You consume the Defense Up elixer, raising your defence permanently!\n";
973 }
974 else if (item == "Attack Up")
975 {
976 yourPlayer->setAttack(yourPlayer->getAttack() + 10);
977 std::cout << "You consume theAttack Up elixer, raising your attack permanently!\n";
978 }
979 else if (item == "Steel Sword")
980 {
981 enemy->setCurrentHealth(enemy->getCurrentHealth() - 80);
982 std::cout << "Your Steel Blade dices the enemy for 80 damage.\n";
983 }
984 else if (item == "Bottle")
985 {
986 std::cout << "Ay lmao didn't add anything for Bottles, go play Zelda ya goon.\n";
987 }
988 else if (item == "Deku Stick")
989 {
990 std::cout << "Oak's words echoed: there is a time and place for everything, but not now.\n";
991 }
992 else if (item == "Master Sword")
993 {
994 enemy->setCurrentHealth(enemy->getCurrentHealth() - 350);
995 enemy->setDefense(enemy->getDefense() - 10);
996 std::cout << "The hero's sword critically strikes the enemy for 300 damage, and also reduces their defence!\n";
997 }
998 else if (item == "Falchion")
999 {
1000 enemy->setCurrentHealth(enemy->getCurrentHealth() - 250);
1001 yourPlayer->setAttack(yourPlayer->getAttack() + 15);
1002 std::cout << "The legenday blade smites your foe for 250hp, and raises your attack!\n";
1003 }
1004 else
1005 std::cout << "173M ERROR.\n%$^&^$@#";
1006 std::cout << "\n*********************************************************************\n";
1007}
1008
1009/*Battle type encounter: A random total is generated for hit damage used in battle against an enemy
1010 Pre: void
1011 Post: hit damage calculated*/
1012int Game::hit()
1013{
1014 int random = rand() % 3 + 1;
1015 int total = 0, i = random;
1016 while (i != 0)
1017 {
1018 total += generator();
1019 i--;
1020 }
1021 total = total / random;
1022 return total;
1023}
1024
1025/*Battle type encounter: Random hit damage multiplier is retrieved from BST and applied to attack in battle
1026 Pre: void
1027 Post: BST damage is accessed
1028 Return: damage value*/
1029int Game::generator() //is this creating anew tree every call? or are wel clearing that tree on every call
1030{
1031 int stackVal = rand() % (damageTree->getSize()) + 1;
1032 damageTree->BsttoStack(damageTree->getRoot());
1033 return damageTree->getVal(stackVal);
1034}
1035
1036/*Critical hit is randomly generated and applied to attack in battle
1037 Pre: void
1038 Post: total is generated
1039 Return: total damage*/
1040int Game::crit()
1041{
1042 int random = rand() % 3 + 1;
1043 int total = 0, i = 2 * random;
1044 while (i != 0)
1045 {
1046 total += generator();
1047 i--;
1048 }
1049 total = total / random;
1050 return total;
1051}
1052
1053/*Randomly generated hit or critical hit is determined and used in battle
1054 Pre: int attack
1055 Post: either a normal hit or a critical hit is used in battle*/
1056int Game::hitorcrit(int attack)
1057{
1058 int hoc = rand() % 10 + 1;
1059 if (hoc < 10)
1060 attack = attack * hit();
1061 else
1062 attack = attack * crit();
1063 return attack;
1064}
1065
1066/*********************************************************************************************/
1067//Enemy hash table functions
1068/*********************************************************************************************/
1069/*Adds new Enemy object into hash table
1070 Pre: Enemy temp
1071 Post: new Enemy object inserted into hash table*/
1072void Game::addToTable(Enemy temp)
1073{
1074 enemyTable->insertData(temp);
1075}
1076
1077/*Enemy object removed from hash table
1078 Pre: Enemy temp
1079 Post: Enemy object removed from hash table*/
1080void Game::removeFromTable(Enemy temp)
1081{
1082 enemyTable->removeData(temp);
1083}
1084
1085/*Displays the hash table contents in key sequence order to console
1086 Pre: void
1087 Post: all hash table values are displayed*/
1088void Game::hashOut()
1089{
1090 enemyTable->OutputKeySequence();
1091}
1092
1093/*Displays hash table contents in order to console
1094 Pre: void
1095 Post: hash table values displayed in orderd*/
1096void Game::sortedHashOut()
1097{
1098 enemyTable->OutputInorder();
1099}
1100
1101/*Looks up an Enemy based on Enemy ID
1102 Pre: void
1103 Post: locates Enemy with user defined Enemy ID*/
1104void Game::Find()
1105{
1106 Enemy temp;
1107
1108 int tempI;
1109 std::cout << "What is the monster's ID: "; std::cin >> tempI;
1110 temp = enemyTable->fetchData(tempI);
1111 if (temp.getEnemyID() == tempI)
1112 {
1113 std::cout << "Monster ID: " << temp.getEnemyID() << std::endl
1114 << "Name: " << temp.getName() << std::endl
1115 << "Attack: " << temp.getAttack() << std::endl
1116 << "Defense: " << temp.getDefense() << std::endl
1117 << "Speed: " << temp.getSpeed() << std::endl
1118 << "Gold: " << temp.getGold() << std::endl;
1119 }
1120 else
1121 {
1122 int pos = 1;
1123 while (temp.getEnemyID() != tempI)
1124 {
1125 temp = enemyTable->fetchData(tempI, pos);
1126 pos++;
1127 }
1128 std::cout << "Monster ID: " << temp.getEnemyID() << std::endl
1129 << "Name: " << temp.getName() << std::endl
1130 << "Attack: " << temp.getAttack() << std::endl
1131 << "Defense: " << temp.getDefense() << std::endl
1132 << "Speed: " << temp.getSpeed() << std::endl
1133 << "Gold: " << temp.getGold() << std::endl;
1134 }
1135}
1136
1137/*Modifies a players attributes (only used by admin)
1138 Pre: Player pointer
1139 Post: player object is modified by admin*/
1140void Game::edit(Player* player)
1141{
1142 int pos = 0;
1143 char bagChoice = 'c';
1144 std::string sTemp = "";
1145 int iTemp = 0;
1146 int choice;
1147 do
1148 {
1149 std::cout << "(1) Password, currently: " << player->getPassword() << std::endl;
1150 std::cout << "(2) Name, currently: " << player->getName() << std::endl;
1151 std::cout << "(3) Health, currently: " << player->getHealth() << std::endl;
1152 std::cout << "(4) current Health, currently: " << player->getCurrentHealth() << std::endl;
1153 std::cout << "(5) Attack, currently: " << player->getAttack() << std::endl;
1154 std::cout << "(6) Defense, currently: " << player->getDefense() << std::endl;
1155 std::cout << "(7) Speed, currently: " << player->getSpeed() << std::endl;
1156 std::cout << "(8) Gold, currently: " << player->getGold() << std::endl;
1157 std::cout << "(9) Bag (display of contents shown when selected)" << std::endl;
1158 std::cout << "(10) Encounter number, currently: " << player->getEncounterNum() << std::endl;
1159 std::cout << "(11) finish edits" << std::endl;
1160 std::cout << "What would you like to change: ";
1161
1162 std::cin >> choice; std::cout << std::endl;
1163 std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
1164 if (choice < 1 || choice > 11)continue;
1165 switch (choice) {
1166 case 1:
1167 std::cout << "What would you like to change the password to: "; std::getline(std::cin, sTemp); player->setPassword(sTemp);
1168 break;
1169 case 2:
1170 std::cout << "What would you like to change the Name to: "; std::getline(std::cin, sTemp); player->setName(sTemp);
1171 break;
1172 case 3:
1173 std::cout << "What would you like to change the Health to: "; while (!(std::cin >> iTemp)) {
1174 std::cout << "must be a number." << std::endl;
1175 std::cin.clear(); std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
1176 } player->setHealth(iTemp);
1177 if (player->getCurrentHealth() > player->getHealth())player->setCurrentHealth(player->getHealth());
1178 break;
1179 case 4:
1180 std::cout << "What would you like to change the current Health to: ";
1181 while (!(std::cin >> iTemp)) {
1182 std::cout << "must be a number." << std::endl;
1183 std::cin.clear(); std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
1184 } player->setCurrentHealth(iTemp);
1185 break;
1186 case 5:
1187 std::cout << "What would you like to change the Attack to: ";
1188 while (!(std::cin >> iTemp)) {
1189 std::cout << "must be a number." << std::endl;
1190 std::cin.clear(); std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
1191 } player->setAttack(iTemp);
1192 break;
1193 case 6:
1194 std::cout << "What would you like to change the Defense to: ";
1195 while (!(std::cin >> iTemp)) {
1196 std::cout << "must be a number." << std::endl;
1197 std::cin.clear(); std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
1198 } player->setDefense(iTemp);//defense
1199 break;
1200 case 7:
1201 std::cout << "What would you like to change the Speed to: ";
1202 while (!(std::cin >> iTemp)) {
1203 std::cout << "must be a number." << std::endl;
1204 std::cin.clear(); std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
1205 } player->setSpeed(iTemp);//speed
1206 break;
1207 case 8:
1208 std::cout << "What would you like to change the Gold to: ";
1209 while (!(std::cin >> iTemp)) {
1210 std::cout << "must be a number." << std::endl;
1211 std::cin.clear(); std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
1212 } player->setGold(iTemp);//gold
1213 break;
1214 case 9:
1215 pos = 0;
1216 bagChoice = 'c';
1217 std::cout << "Here is the list of what's in the bag currently." << std::endl;
1218 (player->getBag())->printNumList();//sortInsert(node)//bag
1219 while (bagChoice < 'a' || bagChoice > 'b')
1220 {
1221 std::cout << "\t(a) add to bag" << std::endl << "\t(b) remove from bag" << std::endl;
1222 std::cout << "character choice: ";
1223 while (!(std::cin >> bagChoice)) {
1224 std::cout << "must be a character." << std::endl;
1225 std::cin.clear(); std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
1226 }
1227 if (bagChoice == 'a')
1228 {
1229 std::cout << "The list of items currently in the game: " << std::endl;
1230 std::cout << "(1) Potion" << std::endl << "(2) Shield" << std::endl << "(3) Defence Up potion" << std::endl << "(4) Attack Up potion" << std::endl << "(5) Bomb" << std::endl << "(6) Bow"
1231 << std::endl << "(7) Bottle" << std::endl << "(8) Deku Stick" << std::endl << "(9) Wooden Sword" << std::endl << "(10) Steel Sword" << std::endl << "(11) Master Sword" << std::endl << "(12) Falchion" << std::endl;
1232 std::cout << "which item would you like to add to the bag: ";
1233 while (pos > 12 || pos < 1)
1234 {
1235 while (!(std::cin >> pos))
1236 {
1237 std::cout << "must be a number." << std::endl;
1238 std::cin.clear(); std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
1239 }
1240 }
1241 switch (pos) {
1242 case 1: player->addToBag("Potion");
1243 player->addNewEntry("Potion");
1244 break;
1245 case 2: player->addToBag("Shield");
1246 player->addNewEntry("Shield");
1247 break;
1248 case 3: player->addToBag("Defence Up");
1249 player->addNewEntry("Defence Up");
1250 break;
1251 case 4: player->addToBag("Attack Up");
1252 player->addNewEntry("Attack Up");
1253 break;
1254 case 5: player->addToBag("Bomb");
1255 player->addNewEntry("Bomb");
1256 break;
1257 case 6: player->addToBag("Bow");
1258 player->addNewEntry("Bow");
1259 break;
1260 case 7: player->addToBag("Bottle");
1261 player->addNewEntry("Bottle");
1262 break;
1263 case 8: player->addToBag("Deku Stick");
1264 player->addNewEntry("Deku Stick");
1265 break;
1266 case 9: player->addToBag("Wooden Sword");
1267 player->addNewEntry("Wooden Sword");
1268 break;
1269 case 10: player->addToBag("Steel Sword");
1270 player->addNewEntry("Steel Sword");
1271 break;
1272 case 11: player->addToBag("Master Sword");
1273 player->addNewEntry("Master Sword");
1274 break;
1275 case 12: player->addToBag("Falchion");
1276 player->addNewEntry("Falchion");
1277 break;
1278 }
1279 std::cout << "The Bag after adding the item: " << std::endl; (player->getBag())->printList();
1280 //print out a list of items to that player can put in bag
1281 }
1282 if (bagChoice == 'b')
1283 {
1284 std::cout << "What is the position of the item you want to remove: "; while (!(std::cin >> pos)) {
1285 std::cout << "must be a number." << std::endl;
1286 std::cin.clear(); std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
1287 }
1288 player->removeBagItem(pos);
1289 std::cout << "The new bag with the item removed: \n"; (player->getBag())->printNumList();
1290 }
1291 }
1292 std::cout << std::endl;
1293 break;
1294 case 10:
1295 std::cout << "What would you like to change the Encounter number to: "; while (!(std::cin >> iTemp)) {
1296 std::cout << "must be a number." << std::endl;
1297 std::cin.clear(); std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
1298 } if (iTemp > 10) {
1299 std::cout << "The encounter value you put is too large, setting it to the maximum." << std::endl; iTemp = 10;
1300 } player->setEncounterNum(iTemp);//encounter
1301 break;
1302 case 11:
1303 break;
1304 }
1305 } while (choice != 11);
1306 saveGame(player);
1307 return;
1308}