-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFire.cpp
More file actions
133 lines (113 loc) · 2.77 KB
/
Fire.cpp
File metadata and controls
133 lines (113 loc) · 2.77 KB
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
#include "Kopemon.h"
#include "Fire.h"
#include "Water.h"
#include "Grass.h"
#include "Attack.h"
#include "Offensive.h"
#include <string>
#include <typeinfo>
#include <stdlib.h>
#include <time.h>
#include <iostream>
using namespace std;
Fire::Fire(Offensive* pNormal, Offensive* pEspecial, string pNombre, int pHp) : Kopemon(pNombre, pHp){
especial=pEspecial;
normal=pNormal;
}
Offensive* Fire::getEspecial(){
return especial;
}
Offensive* Fire::getNormal(){
return normal;
}
void Fire::setEspecial(Offensive* pEspecial){
especial=pEspecial;
}
void Fire::setNormal(Offensive* pNormal){
normal=pNormal;
}
void Fire::Damage(Kopemon* kopemon){
if (kopemon->getHp()<=0) {
status="Fainted";
hp=0;
}
}
string Fire::Special(Kopemon* kopemon){
int special=0;
string texto = ""+name+" used "+especial->getName()+". It was so powerful it hurt itself.";
hp=hp-20;
if (hp<=0) {
status="Fainted";
texto = ""+name+" fainted when trying to use "+especial->getName();
}else{
special=(especial->getDamage() + normal->getDamage())/2;
if (typeid(*kopemon)==typeid(Grass)){
special*=2;
texto+=" Its Super Effective!";
}else if (typeid(*kopemon)==typeid(Water)) {
special/=2;
texto+=" Its not very Effective!";
}
kopemon->setHp(kopemon->getHp()-special);
if (typeid(*kopemon)==typeid(Water)) {
kopemon->Revive(kopemon);
if(kopemon->getHp()>kopemon->getOriginalHp()){
kopemon->setHp(20);
}
}
kopemon->Damage(kopemon);
}
return texto;
}
string Fire::Normal(Kopemon* kopemon){
int ataque=normal->getDamage();
string texto = ""+name+" used "+normal->getName()+".";
if (typeid(*kopemon)==typeid(Grass)){
ataque=ataque*2;
texto+=" Its Super Effective!";
}else if (typeid(*kopemon)==typeid(Water)) {
ataque=ataque/2;
texto+=" Its not very Effective!";
}
if(!Accuracy(normal->getAccuracy())){
ataque=0;
texto = ""+name+" used "+normal->getName()+". But it missed the target...";
}
if(!Paralyzed(status)){
ataque=0;
texto = ""+name+" used "+normal->getName()+". But its paralyzed and cant attack...";
}
kopemon->setHp(kopemon->getHp()-ataque);
if (typeid(*kopemon)==typeid(Water)) {
kopemon->Revive(kopemon);
if(kopemon->getHp()>kopemon->getOriginalHp()){
kopemon->setHp(20);
}
}
kopemon->Damage(kopemon);
return texto;
}
bool Fire::Accuracy(int accuracy){
bool hit=true;
srand (time(NULL));
int random=rand() %100 + 1;
if (accuracy < random) {
hit=false;
}
return hit;
}
bool Fire::Paralyzed(string status){
bool hit=true;
srand (time(NULL));
if (status=="Paralyzed") {
int random=rand() %100 + 1;
if (random < 25) {
hit=false;
}
}
return hit;
}
Fire::~Fire(){
delete normal;
delete especial;
}