forked from CEN4020-FSU/Assignment1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CrazyRandomSword.cpp
44 lines (41 loc) · 904 Bytes
/
CrazyRandomSword.cpp
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
//
// CrazyRandomSword.cpp
// RPG
//
// Created by Juan Martinez on 1/28/19.
// Copyright © 2019 Juan Martinez. All rights reserved.
//
#include "CrazyRandomSword.hpp"
#include <iostream>
//#include <cstdlib>
//#include <time.h>
double CrazyRandomSword::hit(double armor)
{
double damage = 0;
//srand((int) time(NULL));
int range = (armor/3) - 2;
//std::cout << "range: " << range << std::endl;
if (range>0)
{
int ignore = (rand()%range)+2;
if(ignore<=armor)
{
damage = hitPoints - armor + ignore;
//std::cout << "ignore: " << ignore << std::endl;
}
else
damage = hitPoints;
}
else
damage = hitPoints;
if (damage>0)
return damage;
else
return 0;
}
/*
void CrazyRandomSword::ChangeHitPoints()
{
srand(time(NULL));
hitPoints = (rand()%94) +7;
}*/