Advertisement
Guest User

Main.cpp

a guest
Mar 11th, 2014
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.68 KB | None | 0 0
  1. #include "Includes.h"
  2.  
  3. int main()
  4. {
  5.     //Initialize Variables
  6.     //Temporary Name Holder
  7.     string x;
  8.     //Choice
  9.     int c;
  10.     //Random Monster Selection
  11.     int v;
  12.     //Temporary damage
  13.     int attack;
  14.     int mobAttack;
  15.  
  16.     //Initialize Random Seed
  17.     srand(time(NULL));
  18.  
  19.     //Objects
  20.     playerClass player;
  21.     monsterClass pig;
  22.     monsterClass blob;
  23.     monsterClass goat;
  24.     monsterClass sheep;
  25.     itemClass dagger;
  26.  
  27.     //Set Item Values - Name, Damage
  28.     dagger.setItem("Dagger", 2);
  29.  
  30.     cout << "Welcome to Moorwarg!" << endl;
  31.     cout << "Please enter your username: " << endl;
  32.     cin >> x;
  33.     player.setName(x);
  34.     cout << "Welcome " << player.getName() << "!" << endl;
  35.  
  36.     while(true)
  37.     {
  38.         cout << "Press 1 to Attack a monster" << endl;
  39.         cout << "Press 2 to Heal yourself" << endl;
  40.         cout << "Press 3 to enter the shop" << endl;
  41.         cout << "Press 4 for player info" << endl;
  42.         cin >> c;
  43.         switch(c)
  44.         {
  45.         case 1:
  46.             v = rand() % 4 + 1;
  47.             switch (v)
  48.             {
  49.             case 1:
  50.                 //Set Monster Values - Name, Hitpoints, Experience, Gold
  51.                 pig.setMonster("Pig", 5, 5, rand() % 5 + 1, rand() % 1);
  52.                 while(pig.getHP() > 0 && player.getHP() > 0)
  53.                 {
  54.                     srand(time(NULL));
  55.                     attack = rand() % player.getSTR() + 1;
  56.                     mobAttack = pig.getDamage();
  57.                     pig.attackHP(attack);
  58.                     player.attackHP(mobAttack);
  59.                     cout << "You hit " << attack << " on the Pig!" << endl;
  60.                     cout << "The Pig hits " << mobAttack << " on you!" << endl;
  61.                 }
  62.                 if(player.getHP() <= 0)
  63.                 {
  64.                     cout << "You have been slain!" << endl;
  65.                 }
  66.                 else if(pig.getHP() <= 0)
  67.                 {
  68.                     cout << "You have slain the Pig" << endl;
  69.                     cout << "You received " << pig.getGold() << " Gold!" << endl;
  70.                     player.setGold(pig.getGold());
  71.                 }
  72.                 break;
  73.             case 2:
  74.                 //Set Monster Values - Name, Hitpoints, Experience, Gold
  75.                 blob.setMonster("Blob", 7, 5, rand() % 10 + 4, rand() % 2);
  76.                 while(blob.getHP() > 0 && player.getHP() > 0)
  77.                 {
  78.                     srand(time(NULL));
  79.                     attack = rand() % player.getSTR() + 1;
  80.                     mobAttack = blob.getDamage();
  81.                     blob.attackHP(attack);
  82.                     player.attackHP(mobAttack);
  83.                     cout << "You hit " << attack << " on the Blob!" << endl;
  84.                     cout << "The Blob hits " << mobAttack << " on you!" << endl;
  85.                 }
  86.                 if(player.getHP() <= 0)
  87.                 {
  88.                     cout << "You have been slain!" << endl;
  89.                 }
  90.                 else if(blob.getHP() <= 0)
  91.                 {
  92.                     cout << "You have slain the Blob" << endl;
  93.                     cout << "You received " << blob.getGold() << " Gold!" << endl;
  94.                     player.setGold(blob.getGold());
  95.                 }
  96.                 break;
  97.             case 3:
  98.                 //Set Monster Values - Name, Hitpoints, Experience, Gold
  99.                 goat.setMonster("Goat", 10, 7, rand() % 15 + 4, rand() % 3);
  100.                 while(goat.getHP() > 0 && player.getHP() > 0)
  101.                 {
  102.                     srand(time(NULL));
  103.                     attack = rand() % player.getSTR() + 1;
  104.                     mobAttack = goat.getDamage();
  105.                     goat.attackHP(attack);
  106.                     player.attackHP(mobAttack);
  107.                     cout << "You hit " << attack << " on the Goat!" << endl;
  108.                     cout << "The Goat hits " << mobAttack << " on you!" << endl;
  109.                 }
  110.                 if(player.getHP() <= 0)
  111.                 {
  112.                     cout << "You have been slain!" << endl;
  113.                 }
  114.                 else if(goat.getHP() <= 0)
  115.                 {
  116.                     cout << "You have slain the Goat" << endl;
  117.                     cout << "You received " << goat.getGold() << " Gold!" << endl;
  118.                     player.setGold(goat.getGold());
  119.                 }
  120.                 break;
  121.             case 4:
  122.                 //Set Monster Values - Name, Hitpoints, Experience, Gold
  123.                 sheep.setMonster("Sheep", 20, 22, rand() % 20 + 7, rand() % 4);
  124.                 while(sheep.getHP() > 0 && player.getHP() > 0)
  125.                 {
  126.                     srand(time(NULL));
  127.                     attack = rand() % player.getSTR() + 1;
  128.                     mobAttack = sheep.getDamage();
  129.                     sheep.attackHP(attack);
  130.                     player.attackHP(mobAttack);
  131.                     cout << "You hit " << attack << " on the Sheep!" << endl;
  132.                     cout << "The Sheep hits " << mobAttack << " on you!" << endl;
  133.                 }
  134.                 if(player.getHP() <= 0)
  135.                 {
  136.                     cout << "You have been slain!" << endl;
  137.                 }
  138.                 else if(sheep.getHP() <= 0)
  139.                 {
  140.                     cout << "You have slain the Sheep" << endl;
  141.                     cout << "You received " << sheep.getGold() << " Gold!" << endl;
  142.                     player.setGold(sheep.getGold());
  143.                 }
  144.                 break;
  145.             }
  146.             break;
  147.         case 2:
  148.             cout << "You've healed yourself!" << endl;
  149.             player.setHP(player.getMaxHP());
  150.             break;
  151.         case 3:
  152.             cout << "This feature is coming soon" << endl;
  153.             break;
  154.         case 4:
  155.             cout << "Name: " << player.getName() << endl;
  156.             cout << "HP: " << player.getHP() << endl;
  157.             cout << "Exp: " << player.getEXP() << endl;
  158.             cout << "Gold: " << player.getGold() << endl;
  159.             cout << "Str: " << player.getSTR() << endl;
  160.             break;
  161.         case 5:
  162.             cout << dagger.getDamage();
  163.         default:
  164.             cout << "This is not an option!" << endl;
  165.             break;
  166.         }
  167.     }
  168.  
  169.     cin.ignore();
  170.     cin.get();
  171. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement