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
|
void agilityPotions(character& player)
{
int choice;
do
{
cout<<"\nTo purchase an agility +3 potion for 50 gold, press 1.";
cout<<"\nTo purchase an agility +10 potion for 220 gold, press 2.";
cout<<"\nTo purchase an agility +20 potion for 400 gold, press 3.";
cout<<"\nTo purchase an agility +50 potion for 700 gold, press 4.";
cout<<"\nTo print stats, press 5.";
cout<<"\nTo exit agility potion selection, press 9.";
cin>>choice;
switch(choice)
{
case 1:
if(player.getMoney() < 50)
cout<<"\nYou don't have enough gold!"<<endl;
else
{
player.addAgility(3);
player.takeMoney(50);
cout<<"\nAgility increased by 3."<<endl;
}
break;
case 2:
if(player.getMoney() < 220)
cout<<"\nYou don't have enough gold!"<<endl;
else
{
player.addAgility(10);
player.takeMoney(220);
cout<<"\nAgility increased by 10."<<endl;
}
break;
case 3:
if(player.getMoney() < 400)
cout<<"\nYou don't have enough gold!"<<endl;
else
{
player.addAgility(20);
player.takeMoney(400);
cout<<"\nAgility increased by 20."<<endl;
}
break;
case 4:
if(player.getMoney() < 700)
cout<<"\nYou don't have enough gold!"<<endl;
else
{
player.addAgility(50);
player.takeMoney(700);
cout<<"\nAgility increased by 50."<<endl;
}
break;
case 5:
cout<<player;
break;
}
}while(choice != 9);
}
void healingPotions(character& player)
{
int choice;
do
{
cout<<"To purchase potions for the road at 50 gold each, press 1.";
cout<<"\nTo exit potion selection, press 9."<<endl;
cin>>choice;
switch(choice)
{
case 1:
if(player.getMoney() < 50)
cout<<"n\You don't have enough gold!"<<endl;
else
{
player.addPotion();
player.takeMoney(50);
cout<<"Added healing potion to your inventory."<<endl;
}
break;
}
}while(choice != 9);
}
void combat(character& player)
{
int choice;
do
{
if(player.getName() == "")
{
cout<<"\nA character has not been created.";
cout<<"\nReturning to the main menu.\n";
break;
}
cout<<"\nTo search for a monster, press 1.";
cout<<"\nTo drink a potion, press 2.";
cout<<"\nTo print character stats, press 3.";
cout<<"\nTo return to town (the main menu), press 9."<<endl;
cin>>choice;
switch(choice)
{
case 1:
fight(player);
break;
case 2:
if(player.getHealingPotions() <= 0)
cout<<player.getName()<<" is out of healing potions."<<endl;
else
{
player.takePotion();
player.replenishHealth();
cout<<player.getName()<<"'s health is now full."<<endl;
}
break;
case 3:
cout<<player;
break;
}
}while(choice != 9);
}
void fight(character& player)
{
vector<string> mobList;
vector<string> terrain;
monster baddie;
mobList.push_back("Skeleton");
mobList.push_back("Kobold");
mobList.push_back("Zombie");
mobList.push_back("Ghoul");
mobList.push_back("Beholder");
mobList.push_back("Dragon");
terrain.push_back("Forest");
terrain.push_back("Plains");
terrain.push_back("Mountains");
terrain.push_back("Swamp");
terrain.push_back("Island");
terrain.push_back("Castle");
int choice;
int mob = (rand() + time(0)) % 5;
int area = (rand() + time(0)) % 5;
int statMultiplier = player.getLevel() * 3;
int healthMultiplier = player.getLevel() * 20;
int goldMultiplier = player.getLevel() * 10;
baddie.setName(mobList[mob]);
baddie.setAgility(statMultiplier);
baddie.setStrength(statMultiplier);
baddie.setHealth(healthMultiplier);
cout<<endl<<player.getName()<<" encounters a "<<baddie.getName()<<" while traveling through the "<<terrain[area]<<"!";
while(player.isDead() == false && baddie.isDead() == false)
{
cout<<"\nTo attack, press 1.";
cout<<"\nTo defend, press 2.";
cout<<"\nTo flee, press 3.";
cout<<"\nTo drink a potion, press 4.";
cout<<"\nTo print character and monster stats, press 5."<<endl;
cin>>choice;
int playerHit, baddieHit, playerDamage, baddieDamage;
switch(choice)
{
case 1:
playerHit = (rand() + time(0)) % 101;
if(playerHit > 40)
{
cout<<"\nSuccessful hit!\n";
baddieDamage = player.damageRoll();
baddie.takeDamage(baddieDamage);
if(baddie.isDead() == true)
{
cout<<endl<<baddie.getName()<<" has been slain.\n";
player.addExperience(20);
player.addMoney(goldMultiplier);
if(player.isLevelUp() == true)
player.levelUp();
break;
}
}
else
{
cout<<"\nYou missed!\n";
baddieHit = (rand() + time(0)) % 101;
if(baddieHit > 50)
{
cout<<endl<<baddie.getName()<<" has damaged you!\n";
playerDamage = baddie.damageRoll();
player.takeDamage(playerDamage);
if(player.isDead() == true)
{
cout<<endl<<player.getName()<<" has been slain.\n";
break;
}
}
else
cout<<endl<<baddie.getName()<<" missed!\n";
}
break;
case 2:
baddieHit = (rand() + time(0)) % 101;
if(baddieHit > 75)
{
cout<<endl<<baddie.getName()<<" got a lucky hit.\n";
playerDamage = baddie.damageRoll();
player.takeDamage(playerDamage);
if(player.isDead() == true)
{
cout<<endl<<player.getName()<<" has been slain.\n";
break;
}
}
else
{
cout<<endl<<baddie.getName()<<" missed; you recover minimal health.\n";
if(player.getHealth() > 95)
player.replenishHealth();
else
player.addHealth(5);
}
break;
case 3:
baddieHit = (rand() + time(0)) % 101;
if(baddieHit > 25)
{
cout<<endl<<baddie.getName()<<" strikes as you flee.\n";
playerDamage = baddie.damageRoll();
player.takeDamage(playerDamage);
if(player.isDead() == true)
{
cout<<endl<<player.getName()<<" has been slain.\n";
break;
}
}
break;
case 4:
if(player.getHealingPotions() <= 0)
cout<<endl<<player.getName()<<" is out of potions!\n";
else
{
player.takePotion();
player.replenishHealth();
cout<<endl<<player.getName()<<"'s health is now full.\n";
}
break;
case 5:
cout<<player<<endl;
cout<<baddie<<endl;
break;
}
}
}
|