Advertisement
Guest User

RPG.cpp

a guest
Sep 27th, 2013
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.10 KB | None | 0 0
  1. // RPG.cpp : The main class.
  2.  
  3. #include "stdafx.h"
  4. #include <stdio.h>    
  5. #include <stdlib.h>    
  6. #include <time.h>
  7. #include <string>
  8. #include <sstream>
  9. #include <iostream>
  10. #include "Monster.h"
  11. #include "Monster.cpp"
  12.  
  13.     using namespace std;
  14.  
  15. int main()
  16. {
  17.     unsigned int randomNumber;
  18.     srand (time(0));
  19.     randomNumber = rand() % 11;
  20.  
  21.     string playerName;
  22.  
  23.     int choice = 0;
  24.  
  25.     int health = 10;
  26.     int attack = 1;
  27.     int level = 1;
  28.     int exp = 0;
  29.     int expToLevel = level * ((level + level + 2) / level);
  30.     int currentHealth;
  31.     int currentExp;
  32.  
  33.     string monsterNamer;
  34.     string monsterPicker[5] = {"Arckolit", "Gruduum'gro", "Naxhiksil", "Urist McFighter", "Zul'fihk"};
  35.  
  36.     Monster Monster;
  37.  
  38.     cout << "This is an experimental RPG game.\nFeatures will be added, and updated with time." << endl;
  39.     cout << "You can go ahead and type your name in here." << endl;
  40.     cout << ": ";
  41.     getline (cin, playerName);
  42.     cout << "" << endl;
  43.     cout << "Alright, " << playerName << ", this game will refer to you by that name." << endl;
  44.     cout << "" << endl;
  45.     cout << "As for this game." << endl;
  46.     cout << "You are in a room with no exits. Only one door." << endl;
  47.     cout << "The door leads to another room with no exits." << endl;
  48.     cout << "This room will have a monster in it at all times." << endl;
  49.     cout << "When you defeat the monster, another one will be put in its place." << endl;
  50.     cout << "" << endl;
  51.  
  52.     //-----------------------------------------------------------------------------------------//
  53.  
  54.     while(choice != 2){
  55.     cout << "Your current stats are-" << endl;
  56.     cout << playerName << ": Health " << health << ": Attack " << attack << ": Level " << level << ": Experience " << exp << endl;
  57.     cout << "" << endl;
  58.     cout << "" << endl;
  59.     cout << "What would you like to do?" << endl;
  60.     cout << "1| Fight a monster" << endl;
  61.     cout << "2| Exit the game" << endl;
  62.     cout << "" << endl;
  63.     currentHealth = health;
  64.  
  65.     cin.clear();
  66.  
  67.     if(cin >> choice){
  68.     while(choice < 1 || choice > 2){
  69.         cout << "" << endl;
  70.         cout << "That's not a good choice, " << playerName << ". Let's try again." << endl;
  71.         cout << "" << endl;
  72.         cin >> choice;
  73.     }
  74.     }
  75.     else
  76.     {
  77.         cout << "" << endl;
  78.         cout << "That's not a good choice, " << playerName << ". Let's try again." << endl;
  79.         cout << "" << endl;
  80.         cin.clear();
  81.         cin.ignore(numeric_limits<streamsize>::max(), '\n');
  82.     }
  83.     cout << "" << endl;
  84.    
  85.             while(randomNumber > 4){
  86.          switch(randomNumber){
  87.  
  88.      case 0:
  89.          monsterNamer = monsterPicker[0];
  90.          break;
  91.  
  92.      case 1:
  93.          monsterNamer = monsterPicker[1];
  94.          break;
  95.  
  96.      case 2:
  97.          monsterNamer = monsterPicker[2];
  98.          break;
  99.  
  100.      case 3:
  101.          monsterNamer = monsterPicker[3];
  102.          break;
  103.  
  104.      case 4:
  105.          monsterNamer = monsterPicker[4];
  106.          break;
  107.  
  108.      default:
  109.          break;
  110.                 }
  111.             }
  112.            
  113.     switch(choice){
  114.  
  115.     case 1:
  116.  
  117.         Monster.fightMonster(monsterNamer, health, attack, level + (level * level) / (level + (level / 2)));
  118.         break;
  119.     case 2:
  120.         cout << "Goodbye." << endl;
  121.         system("exit");
  122.         break;
  123.     default:
  124.         cout << "That is not a good choice, " << playerName << ". Let's try again." << endl;
  125.         break;
  126.         }
  127.     }
  128.     return 0;
  129. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement