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
|
#include "stdafx.h"
#include <Windows.h>
#include <stdlib.h>
#include <iostream>
#include <time.h>
#include <string>
using namespace std;
class RandomNumbers{
private:
int rSeed = (time(NULL)) * rand() % 4;
public:
int getRandomStat(){
int x;
rSeed = rSeed + (((time(NULL)) / 2)*3);
srand(rSeed);
x = rand() % 10 + 8;
return x;
}
int rollD6(){
int x;
rSeed++;
x = rand() % 6 + 1;
return x;
}
};
class Battle: public RandomNumbers{
bool battle = true, win = false, lose = false;
string pName, pWeapon, pWepStatus;
int pstr, pdex, pint, pchr, pHealth;
//to import player data
string eName, eWeapon;
int estr, edex, eint, echr, eHealth;
//to import enemy data
public:
Battle(string pname, string pweapon, string pwepStatus, int pStr, int pDex, int pInt, int pChr, int phealth,
string ename, string eweapon, int eStr, int eDex, int eInt, int eChr, int ehealth){
//1st line is importing player stats, 2nd line is importning enemy stats
pname = pName; pweapon = pWeapon; pwepStatus = pWepStatus; pStr = pstr; pDex = pdex; pInt = pint; pChr = pchr; phealth = pHealth;
ename = eName; eweapon = eWeapon; eStr = estr; eDex = edex; eInt = eint; eChr = echr; ehealth = eHealth;
//1st line is player stats being set in the battle class. the 2nd line is the enemy. The stats are pulled from their classes
}
void battleLogic(){
bool firstRound = true;
while (battle == true && pHealth >= 1 && eHealth >= 1){
if (firstRound == true){
cout << "The " << eName << " puts up it's guard!";
if (pHealth >= eHealth){ cout << "You think you can take the " << eName << ". \n"; }
else{cout << "The " << eName << " looks tough." << endl;} //flavor text
cout << "You ready your " << pWepStatus << " " << pWeapon << "." << endl;
if (pdex >= edex){
cout << "You're faster than the " << eName << "!" << endl;
cout << "The " << eName << "had " << eHealth << ": HP" << endl;
eHealth = eHealth - ((pstr / 6) + rollD6());
cout << "The " << eName << "has " << eHealth << ": HP" << endl;
}
if (pdex < edex){
cout << "The " << eName << "is faster than you!" << endl;
cout << pName << "had " << pHealth << ": HP" << endl;
pHealth = pHealth - ((estr / 6) + rollD6());
cout << pName << "has " << eHealth << ": HP" << endl;
}
firstRound = false;
}//end of first round check
battle = false; }//end of while loop
}
};
RandomNumbers ranNum;
int main()
{
Battle battle("test", "sword", "", 18, 18, 18, 18, 26, "Kobold", "sword", 10, 10, 10 , 10, 10);
battle.battleLogic();
system("PAUSE");
return 0;
}
|