Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Library.h"
- PLAYER::PLAYER()
- {
- SetName("Hero");
- strength = 1;
- intelligence = 1;
- level = 1;
- SetGold(100);
- SetExperience(0);
- SetMaxHealth(25);
- SetHealth(25);
- SetMaxMana(100);
- SetMana(100);
- SetPoisoned(false);
- SetMonster(false);
- weapon.SetName("Rusty Dagger");
- weapon.SetDamage(2);
- weapon.SetPrice(0);
- armor.SetName("None");
- armor.SetAP(0);
- armor.SetPrice(0);
- //FIREBALL fireball;
- //HEAL heal;
- //POISON poison;
- BLAZE blaze;
- RANDOM rand;
- AddSpell(&blaze);
- AddSpell(&rand);
- }
- int PLAYER::GetIntelligence()
- {
- return intelligence;
- }
- int PLAYER::GetStrength()
- {
- return strength;
- }
- void PLAYER::SetIntelligence(int newint)
- {
- intelligence = newint;
- }
- void PLAYER::SetStrength(int newstr)
- {
- strength = newstr;
- }
- void PLAYER::SetLevel(int newlevel)
- {
- level = newlevel;
- }
- int PLAYER::GetLevel()
- {
- return level;
- }
- WEAPON* PLAYER::GetWeapon()
- {
- return &weapon;
- }
- void PLAYER::SetWeapon(WEAPON newweapon)
- {
- weapon = newweapon;
- }
- ARMOR* PLAYER::GetArmor()
- {
- return &armor;
- }
- void PLAYER::SetArmor(ARMOR newarmor)
- {
- armor = newarmor;
- }
- void PLAYER::AddPotion(POTION* potion)
- {
- if (potion == NULL)
- return;
- //check for duplicate
- for (int check = 0; check < 15; check++)
- {
- if (potionlist[check] != NULL)
- {
- if (strcmp(potionlist[check]->GetName(),potion->GetName()) == 0)
- {
- //names are same
- potionlist[check]->AddQuantity(1);
- return;
- }
- }
- }
- //no duplicates found
- for (int loop=0;loop < 15; loop++)
- {
- if (potionlist[loop] == NULL)
- {
- //create a potion here
- potionlist[loop] = new POTION(potion);
- return;
- }
- }
- cout << "There is no room in your inventory.\n";
- Wait();
- cout << endl;
- }
- POTION** PLAYER::GetPotionList()
- {
- return potionlist;
- }
- void PLAYER::AddSpell(SPELL *newspell)
- {
- //check for open spot
- for (int loop=0;loop < 10;loop++)
- {
- if (spelllist[loop] == NULL)
- {
- //openspot
- //which type?
- switch (newspell->GetSpellType())
- {
- case ST_GENERIC:
- {
- spelllist[loop] = new SPELL(newspell);
- break;
- }
- case ST_FIREBALL:
- {
- spelllist[loop] = new FIREBALL((FIREBALL*)newspell);
- break;
- }
- case ST_HEAL:
- {
- spelllist[loop] = new HEAL((HEAL*)newspell);
- break;
- }
- case ST_POISON:
- {
- spelllist[loop] = new POISON((POISON*)newspell);
- break;
- }
- case ST_BLAZE:
- {
- spelllist[loop] = new BLAZE((BLAZE*)newspell);
- break;
- }
- case ST_RANDOM:
- {
- spelllist[loop] = new RANDOM((RANDOM*)newspell);
- break;
- }
- }
- loop = 10;
- }
- }
- }
- SPELL** PLAYER::GetSpellList()
- {
- return spelllist;
- }
- void PLAYER::CheckForLevelUp()
- {
- //formula
- // (level * (level * 10))
- if (GetExperience() >= (level * (level * 10)))
- {
- //level up!
- cout << "You have gained a level!\n\n";
- level++;
- int choice = -1;
- while (choice < 1 || choice > 2)
- {
- cout << "Pick a stat to increase.\n";
- cout << "1: Strength\n";
- cout << "2: Intelligence\n";
- cout << ">";
- cin >> choice;
- cin.clear();
- cin.ignore(INT_MAX,'\n');
- }
- if (choice == 1)
- {
- cout << "You feel much stronger.\n";
- strength++;
- SetMaxHealth(strength * 25);
- }
- if (choice == 2)
- {
- cout << "You feel much smarter.\n";
- intelligence++;
- SetMaxMana(intelligence * 5);
- }
- SetHealth(GetMaxHealth());
- SetMana(GetMaxMana());
- Wait();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment