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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339
|
#include <iostream>
#include <cstdlib>
#include <time.h>
using namespace std;
class ShortSword{
public:
ShortSword();
ShortSword(int);
private:
int numDamage;
int numRange;
int numSpeed;
};
class LongBow{
public:
LongBow();
private:
int num_damage;
int num_range;
};
class Hammer{
public:
Hammer();
private:
int num_damage;
int num_range;
};
class Monster{
//constructors
public:
Monster();
Monster(int,int,int);
int modifier; //reduce its damage, can i make a global damage modifier and just add them to each object?
//unless the player is actually changing something then keep it all private
private:
double num_burning_arrow_damage;
double num_fire_breath_damage;
double num_hit_points;
double num_level;
};
class Dice{
//Constructor
public:
Dice();
Dice(int);
double score();
double randPoints;
int pointTotal, a;
double getRolls();
void setRolls(double&,double&);
char x;
//methods
int roll();
void resetNumRolls();
int getNumRolls();
int playerPoints();
int compPoints();
int pointsTotal(); //this doesnt make sense because a dice can't calculate points
int computerTotal();//this OBJECT called DICE should behave like a real dice
//unless the player is actually changing something then keep it all private
private:
//properties
int numRolls;
int numSides;
int numPoints;
int rollTotal;
double rolls;
};
/**********************************************************
The shortsword
***********************************************************/
ShortSword::ShortSword(int damage){
numDamage=20;
numSpeed=2;
numRange=5;
};
/******************************************************************************************************************/
/**********************************************************
The Dice
Paramerterized constructor
set the number of sides when created
@param sides is the number of sides for this die
***************************************************/
Dice::Dice(int sides){
numSides=6;
numRolls=0;
numPoints=50;
//initialize random # generator
srand(time(NULL));
};
/**********************************************************
Default Constructor. Creates a die with 6 sides
***************************************************/
Dice::Dice(){
numSides=6;
numRolls=0;
numPoints=50;
//initialize random # generator
srand(time(NULL));
};
/*************************************************
*"Rolls" the dice
*@return a number between [1, numSides]
**************************************************/
int Dice::roll(){
//generate a number between 1 - numSides
int rollVal = (rand() % numSides) + 1;
return rollVal;
};
int Dice::playerPoints(){
int randPoints = (rand() % 5 ) ; //the players points
return randPoints;
};
int Dice::compPoints(){
int randPoints = (rand() % 5 ) + 1;//the computers points
return randPoints;
};
int Dice::pointsTotal(){
int x = 0;
int total = x+playerPoints();
return total;
};
double Dice::getRolls(){
return(rolls);
};
/************************************************************************************************************/
/************************************************************
Gives the user the number of rolls
**********************system("color fc")*********************/
/************************************************
Reset the number of rolls to 0
*****************************************/
/*
void Dice::resetNumRolls(){
numRolls = 0;
}*/
int main(){
Dice playerOne;
Dice playerTwo;
ShortSword beginner;
/************************************************
Main Variables for dice game
*************************************************/
char x;
int r;
int tile=0;
int total;
int g;
int playerPoints();
int pointsTotal();
int playerOnePosition;
int move;
int randomNum=2;//probably dont need this
int randomize=12;
int spot;
int score=0;
int scoreTwo=0;
int spotTwo;
int attack=0;
int upgrade=0;
int upgrade_two=0;
int upgrade_three=0;
srand (0);
int maxMove=12;//player cant go over this in one turn
randomNum=move;
int card=0;
while(x != 'n'){ //stopped working all of a sudden, would stop the game, fix later
/************************************************
Round keeper
*************************************************/
for(r=1; r<=2000; move=1){
cout<<"********************Round:"<<r<<"**********************"<<endl;
/************************************************
Spot keeper
*************************************************/
cout<<"PlayerOne is on tile "<<spot<<", Player Two's turn!"<<endl;
cout<<"PlayerTwo is on tile "<<spotTwo<<endl;
spotTwo=(rand() % 7 + 1) + spotTwo;
spot=(rand() % 6 + 1 ) +spot;
/************************************************
Point keeper
*************************************************/
cout<<"You've earned "<<playerOne.playerPoints()<<" points"<<endl; //basically a roll i made for myself
cout<<"Computer earned "<<playerOne.compPoints()<<" points"<<endl; //basically a roll i made for the comp, in his favor
/************************************************
Random events
*************************************************/
attack=(rand() % 7); //a random attack by the computer
upgrade=(rand() % 20+1);
upgrade_two=(rand() % 50+1);
upgrade_three=(rand() % 100+1);
if(upgrade == 10 ){
cout<<"RARE:Upgrade Omega unlocked, 30% damage increase for 1 turn"<<endl;
score=score+2;
};
if(upgrade_two == 50){
cout<<"ULTRA RARITY: Upgrade Beta unlocked, 50% damage increase for 1 turn"<<endl;
score=score+6;
};
if(upgrade_three == 50){
cout<<"EPIC RARITY: Upgrade Alpha unlocked, 75% damage increase for 1 turn"<<endl;
score=score+5;
};
if(attack == 6){
cout<<"Computer used burning arrow, you take 60 damage!"<<endl;
score=score-60;
};
if(spot > 50){
score=score+100;
spot=0;
};
if(spotTwo > 50){
scoreTwo=scoreTwo+100;
spotTwo=0;
};
if(spot == 50){
cout<<"Target practice has been doing you some good! 200 Bonus points!"<<endl;
score=score+200;
};
if(spot == 10){
cout<<"Enemy sets loose a barrage of archers on your men! 150 points lost!"<<endl;
score=score-150;
};
};
};
return 0;
};
| |