//conducts the battle between player and enemy also increments or decrements gold void battle(KillCount& kMap, Hero<int> &hero, Enemy<int> &e, int &gold){ cout << endl; //show enemy stats and players stats before player chooses weapon cout << "Now battling " << e.getName() << " " << e.getID() << " carrying " << e.getEgold() << " gold" << endl; cout << "Enemy has " << e.getAttk() << " attack" << endl; cout << hero.getName() << " has " << hero.getAttack() << endl; //player attack after the have chosen a weapon int heroBattleAttk = hero.getAttack() + hero.boost(); //show player attack after they have chosen a weapon cout << hero.getName() << " Attack become " << heroBattleAttk << endl; if(e.getAttk() > heroBattleAttk){ //if enemy has more attack player loses gold equal to amount carried by enemy cout << "You have lost battle " << e.getEgold() << " gold lost" << endl; gold -= e.getEgold(); cout << "Gold count now: " << gold << endl; }else if(e.getAttk() < heroBattleAttk){ //if player has more attack than enemy player gains gold gold carried by enemy cout << "You have won battle " << e.getEgold() << " gold gained" << endl; gold += e.getEgold(); kMap.incrementCount(e.getName()); cout << "Gold count now: " << gold << endl; }else{ //if tie no gold won or lost cout << "Battle is a tie no gold gained or lost" << endl; gold +=0; cout << "Gold count now: " << gold << endl; } }
//introduction for the game explains objective and game play void intro(Hero<int> &h, int gold){ cout <<"OK " << h.getName() << " your adventure begins here" << endl; cout << "Your interdimensional transport ship has run out of fuel(gold) in a \n" << "mysterious dimension you must collect at least 35 gold pieces in order \n" << "to make the trip home" << endl; cout << "Collect gold by defeating enemies in the various areas" << endl; cout << "winning gives you their gold losing removes gold equal to what the enemy " << "was carrying" << endl; cout << "your base attack is: " << h.getAttack() << endl; cout << "your base special attack is: " << h.getSpecial() << endl; cout << "you have " << gold << " to start collect at leat 35 to win" << endl; cout << "if no gold remaining you lose" << endl; cout << endl; }
void ArcherWeapons::ArcherShop(Hero& hero) { /*this->archer_weapons = {//name, damage, price {1, Weapon("Arondight", 4, 150, 1)}, {2, Weapon("Gugnir", 10, 230, 2)}, {3, Weapon("Susano'", 16, 300, 3)}, {4, Weapon("Longinus", 24, 550, 4)}, {5, Weapon("Hrunting", 32, 610, 5)}, {6, Weapon("Clarent", 40, 690, 6)}, {7, Weapon("Shinigami", 52, 750, 7)}, {8, Weapon("Caliburn", 60, 900, 8)} };*/ this->init_map_values();//Inherits init_map_values from mainshop this->archer_weapons = {//name, damage, price {1, Weapon("Arondight",map_effect_array[0], map_price_array[0],map_sellValue_array[0], 1)}, {2, Weapon("Gugnir", map_effect_array[1], map_price_array[1],map_sellValue_array[1], 2)}, {3, Weapon("Susano'", map_effect_array[2], map_price_array[2],map_sellValue_array[2], 3)}, {4, Weapon("Longinus", map_effect_array[3], map_price_array[3],map_sellValue_array[3], 4)}, {5, Weapon("Hrunting", map_effect_array[4], map_price_array[4],map_sellValue_array[4], 5)}, {6, Weapon("Clarent", map_effect_array[5], map_price_array[5],map_sellValue_array[5], 6)}, {7, Weapon("Shinigami",map_effect_array[6], map_price_array[6],map_sellValue_array[6], 7)}, {8, Weapon("Caliburn", map_effect_array[7], map_price_array[7],map_sellValue_array[7], 8)} }; //Check class if (hero.My_class != "Archer") { cout << "\nNote:You can only buy from this category if you are of a Archer class\n"; cout << "...\nSorry, you are not of type Archer class, therefore you cannot buy Archer related items.\n"; MainShop::mainShop(hero); return; } this->getArcherWeapons();//Display options cout << "Select what you would like to buy, or enter 9 to quit!\n"; cin >> choice2; switch (choice2) { case 1: for (map <int, Weapon>::iterator iter = archer_weapons.begin(); iter != archer_weapons.end(); iter++) { if(iter->first == 1) { if (hero.getMoney() >= iter->second._price) {//Add a function-if you already have a weapon, you cannot buy it again add_weapon(iter->second); hero.setMoney(hero.getMoney() - iter->second._price); hero.setAttack(hero.getAttack() + iter->second._damage); cout << "\nYou have Successfully Bought " << iter->second._name << "\nIt has been added to your inventory\n"; cout << "your total items are: "<< weapon_inventory.size() << endl; break;//break for loop } else { cout << "You do not have enough money to buy this weapon\nPlease try again\n" << endl; //system("CLS");//cout << string(50, '\n'); this->ArcherShop(hero); break;//break for loop } } } break;//break switch case 2: for (map <int, Weapon>::iterator iter = archer_weapons.begin(); iter != archer_weapons.end(); iter++) { if(iter->first == 2) { if (hero.getMoney() >= iter->second._price) {//Add a function-if you already have a weapon, you cannot buy it again add_weapon(iter->second); hero.setMoney(hero.getMoney() - iter->second._price); hero.setAttack(hero.getAttack() + iter->second._damage); cout << "\nYou have Successfully Bought " << iter->second._name << "\nIt has been added to your inventory\n"; cout << "your total items are: "<< weapon_inventory.size() << endl; break;//break for loop } else { cout << "You do not have enough money to buy this weapon\nPlease try again\n" << endl; //system("CLS");//cout << string(50, '\n'); this->ArcherShop(hero); break;//break for loop } } } break;//break switch case 3: for (map <int, Weapon>::iterator iter = archer_weapons.begin(); iter != archer_weapons.end(); iter++) { if(iter->first == 3) { if (hero.getMoney() >= iter->second._price) {//Add a function-if you already have a weapon, you cannot buy it again add_weapon(iter->second); hero.setMoney(hero.getMoney() - iter->second._price); hero.setAttack(hero.getAttack() + iter->second._damage); cout << "\nYou have Successfully Bought " << iter->second._name << "\nIt has been added to your inventory\n"; cout << "your total items are: "<< weapon_inventory.size() << endl; break;//break for loop } else { cout << "You do not have enough money to buy this weapon\nPlease try again\n" << endl; //system("CLS");//cout << string(50, '\n'); this->ArcherShop(hero); break;//break for loop } } } break;//break switch case 4: for (map <int, Weapon>::iterator iter = archer_weapons.begin(); iter != archer_weapons.end(); iter++) { if(iter->first == 4) { if (hero.getMoney() >= iter->second._price) {//Add a function-if you already have a weapon, you cannot buy it again add_weapon(iter->second); hero.setMoney(hero.getMoney() - iter->second._price); hero.setAttack(hero.getAttack() + iter->second._damage); cout << "\nYou have Successfully Bought " << iter->second._name << "\nIt has been added to your inventory\n"; cout << "your total items are: "<< weapon_inventory.size() << endl; break;//break for loop } else { cout << "You do not have enough money to buy this weapon\nPlease try again\n" << endl; //system("CLS");//cout << string(50, '\n'); this->ArcherShop(hero); break;//break for loop } } } break;//break switch case 5: for (map <int, Weapon>::iterator iter = archer_weapons.begin(); iter != archer_weapons.end(); iter++) { if(iter->first == 5) { if (hero.getMoney() >= iter->second._price) {//Add a function-if you already have a weapon, you cannot buy it again add_weapon(iter->second); hero.setMoney(hero.getMoney() - iter->second._price); hero.setAttack(hero.getAttack() + iter->second._damage); cout << "\nYou have Successfully Bought " << iter->second._name << "\nIt has been added to your inventory\n"; cout << "your total items are: "<< weapon_inventory.size() << endl; break;//break for loop } else { cout << "You do not have enough money to buy this weapon\nPlease try again\n" << endl; //system("CLS");//cout << string(50, '\n'); this->ArcherShop(hero); break;//break for loop } } } break;//break switch case 6: for (map <int, Weapon>::iterator iter = archer_weapons.begin(); iter != archer_weapons.end(); iter++) { if(iter->first == 6) { if (hero.getMoney() >= iter->second._price) {//Add a function-if you already have a weapon, you cannot buy it again add_weapon(iter->second); hero.setMoney(hero.getMoney() - iter->second._price); hero.setAttack(hero.getAttack() + iter->second._damage); cout << "\nYou have Successfully Bought " << iter->second._name << "\nIt has been added to your inventory\n"; cout << "your total items are: "<< weapon_inventory.size() << endl; break;//break for loop } else { cout << "You do not have enough money to buy this weapon\nPlease try again\n" << endl; //system("CLS");//cout << string(50, '\n'); this->ArcherShop(hero); break;//break for loop } } } break;//break switch case 7: for (map <int, Weapon>::iterator iter = archer_weapons.begin(); iter != archer_weapons.end(); iter++) { if(iter->first == 7) { if (hero.getMoney() >= iter->second._price) {//Add a function-if you already have a weapon, you cannot buy it again add_weapon(iter->second); hero.setMoney(hero.getMoney() - iter->second._price); hero.setAttack(hero.getAttack() + iter->second._damage); cout << "\nYou have Successfully Bought " << iter->second._name << "\nIt has been added to your inventory\n"; cout << "your total items are: "<< weapon_inventory.size() << endl; break;//break for loop } else { cout << "You do not have enough money to buy this weapon\nPlease try again\n" << endl; //system("CLS");//cout << string(50, '\n'); this->ArcherShop(hero); break;//break for loop } } } break;//break switch case 8: for (map <int, Weapon>::iterator iter = archer_weapons.begin(); iter != archer_weapons.end(); iter++) { if(iter->first == 8) { if (hero.getMoney() >= iter->second._price) {//Add a function-if you already have a weapon, you cannot buy it again add_weapon(iter->second); hero.setMoney(hero.getMoney() - iter->second._price); hero.setAttack(hero.getAttack() + iter->second._damage); cout << "\nYou have Successfully Bought " << iter->second._name << "\nIt has been added to your inventory\n"; cout << "your total items are: "<< weapon_inventory.size() << endl; break;//break for loop } else { cout << "You do not have enough money to buy this weapon\nPlease try again\n" << endl; //system("CLS");//cout << string(50, '\n'); this->ArcherShop(hero); break;//break for loop } } } break;//break switch case 9: cout << "Exiting Bow shop...\n\n"; break; default: cout << "Error! You have entered an invalid answer\nPlease try again"; this->ArcherShop(hero); } }