Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Includes.h"
- int main()
- {
- //Initialize Variables
- //Temporary Name Holder
- string x;
- //Choice
- int c;
- //Random Monster Selection
- int v;
- //Temporary damage
- int attack;
- int mobAttack;
- //Initialize Random Seed
- srand(time(NULL));
- //Objects
- playerClass player;
- monsterClass pig;
- monsterClass blob;
- monsterClass goat;
- monsterClass sheep;
- itemClass dagger;
- //Set Item Values - Name, Damage
- dagger.setItem("Dagger", 2);
- cout << "Welcome to Moorwarg!" << endl;
- cout << "Please enter your username: " << endl;
- cin >> x;
- player.setName(x);
- cout << "Welcome " << player.getName() << "!" << endl;
- while(true)
- {
- cout << "Press 1 to Attack a monster" << endl;
- cout << "Press 2 to Heal yourself" << endl;
- cout << "Press 3 to enter the shop" << endl;
- cout << "Press 4 for player info" << endl;
- cin >> c;
- switch(c)
- {
- case 1:
- v = rand() % 4 + 1;
- switch (v)
- {
- case 1:
- //Set Monster Values - Name, Hitpoints, Experience, Gold
- pig.setMonster("Pig", 5, 5, rand() % 5 + 1, rand() % 1);
- while(pig.getHP() > 0 && player.getHP() > 0)
- {
- srand(time(NULL));
- attack = rand() % player.getSTR() + 1;
- mobAttack = pig.getDamage();
- pig.attackHP(attack);
- player.attackHP(mobAttack);
- cout << "You hit " << attack << " on the Pig!" << endl;
- cout << "The Pig hits " << mobAttack << " on you!" << endl;
- }
- if(player.getHP() <= 0)
- {
- cout << "You have been slain!" << endl;
- }
- else if(pig.getHP() <= 0)
- {
- cout << "You have slain the Pig" << endl;
- cout << "You received " << pig.getGold() << " Gold!" << endl;
- player.setGold(pig.getGold());
- }
- break;
- case 2:
- //Set Monster Values - Name, Hitpoints, Experience, Gold
- blob.setMonster("Blob", 7, 5, rand() % 10 + 4, rand() % 2);
- while(blob.getHP() > 0 && player.getHP() > 0)
- {
- srand(time(NULL));
- attack = rand() % player.getSTR() + 1;
- mobAttack = blob.getDamage();
- blob.attackHP(attack);
- player.attackHP(mobAttack);
- cout << "You hit " << attack << " on the Blob!" << endl;
- cout << "The Blob hits " << mobAttack << " on you!" << endl;
- }
- if(player.getHP() <= 0)
- {
- cout << "You have been slain!" << endl;
- }
- else if(blob.getHP() <= 0)
- {
- cout << "You have slain the Blob" << endl;
- cout << "You received " << blob.getGold() << " Gold!" << endl;
- player.setGold(blob.getGold());
- }
- break;
- case 3:
- //Set Monster Values - Name, Hitpoints, Experience, Gold
- goat.setMonster("Goat", 10, 7, rand() % 15 + 4, rand() % 3);
- while(goat.getHP() > 0 && player.getHP() > 0)
- {
- srand(time(NULL));
- attack = rand() % player.getSTR() + 1;
- mobAttack = goat.getDamage();
- goat.attackHP(attack);
- player.attackHP(mobAttack);
- cout << "You hit " << attack << " on the Goat!" << endl;
- cout << "The Goat hits " << mobAttack << " on you!" << endl;
- }
- if(player.getHP() <= 0)
- {
- cout << "You have been slain!" << endl;
- }
- else if(goat.getHP() <= 0)
- {
- cout << "You have slain the Goat" << endl;
- cout << "You received " << goat.getGold() << " Gold!" << endl;
- player.setGold(goat.getGold());
- }
- break;
- case 4:
- //Set Monster Values - Name, Hitpoints, Experience, Gold
- sheep.setMonster("Sheep", 20, 22, rand() % 20 + 7, rand() % 4);
- while(sheep.getHP() > 0 && player.getHP() > 0)
- {
- srand(time(NULL));
- attack = rand() % player.getSTR() + 1;
- mobAttack = sheep.getDamage();
- sheep.attackHP(attack);
- player.attackHP(mobAttack);
- cout << "You hit " << attack << " on the Sheep!" << endl;
- cout << "The Sheep hits " << mobAttack << " on you!" << endl;
- }
- if(player.getHP() <= 0)
- {
- cout << "You have been slain!" << endl;
- }
- else if(sheep.getHP() <= 0)
- {
- cout << "You have slain the Sheep" << endl;
- cout << "You received " << sheep.getGold() << " Gold!" << endl;
- player.setGold(sheep.getGold());
- }
- break;
- }
- break;
- case 2:
- cout << "You've healed yourself!" << endl;
- player.setHP(player.getMaxHP());
- break;
- case 3:
- cout << "This feature is coming soon" << endl;
- break;
- case 4:
- cout << "Name: " << player.getName() << endl;
- cout << "HP: " << player.getHP() << endl;
- cout << "Exp: " << player.getEXP() << endl;
- cout << "Gold: " << player.getGold() << endl;
- cout << "Str: " << player.getSTR() << endl;
- break;
- case 5:
- cout << dagger.getDamage();
- default:
- cout << "This is not an option!" << endl;
- break;
- }
- }
- cin.ignore();
- cin.get();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement