-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWater.cpp
More file actions
144 lines (122 loc) · 2.92 KB
/
Water.cpp
File metadata and controls
144 lines (122 loc) · 2.92 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
134
135
136
137
138
139
140
141
142
143
144
#include "Kopemon.h"
#include "Water.h"
#include "Fire.h"
#include "Grass.h"
#include "Attack.h"
#include "Offensive.h"
#include "PowerUp.h"
#include <stdlib.h>
#include <time.h>
#include <string>
#include <typeinfo>
#include <iostream>
using namespace std;
Water::Water(PowerUp* pEspecial, Offensive* pNormal, string pNombre, int pHp) : Kopemon(pNombre, pHp){
especial=pEspecial;
normal=pNormal;
}
PowerUp* Water::getEspecial(){
return especial;
}
Offensive* Water::getNormal(){
return normal;
}
int Water::getHp2(){
return hp2;
}
void Water::setEspecial(PowerUp* pEspecial){
especial=pEspecial;
}
void Water::setNormal(Offensive* pNormal){
normal=pNormal;
}
void Water::setHp2(int pHp2){
hp2=pHp2;
}
void Water::Damage(Kopemon* kopemon){
if (kopemon->getHp()<=0) {
status="Fainted";
hp=0;
}
}
string Water::Special(Kopemon* kopemon){
int ataque=especial->getEffect();
string texto = ""+name+" used "+especial->getName()+".";
hp2=especial->getEffect();
if (typeid(*kopemon) == typeid(Fire)) {
ataque=ataque*2;
texto+=" Its Super Effective!";
}else if(typeid(*kopemon) == typeid(Grass)){
ataque=ataque/2;
texto+=" Its not very Effective!";
}
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 + " It can now revive";
}
string Water::Normal(Kopemon* kopemon){
int ataque = normal->getDamage();
string texto = ""+name+" used "+normal->getName()+".";
if (typeid(*kopemon) == typeid(Fire)) {
ataque=ataque*2;
texto+=" Its Super Effective!";
}else if(typeid(*kopemon) == typeid(Grass)){
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;
}
void Water::Revive(Kopemon* kopemon){
Water* agua=dynamic_cast<Water*>(kopemon);
if(agua->getHp() <=0 ){
int extraHp=agua->getHp()+agua->getHp2();
agua->setHp(extraHp);
agua->setHp2(0);
}
}
bool Water::Accuracy(int accuracy){
bool hit=true;
srand (time(NULL));
int random=rand() %100 + 1;
if (accuracy < random) {
hit=false;
}
return hit;
}
bool Water::Paralyzed(string status){
bool hit=true;
srand (time(NULL));
if (status=="Paralyzed") {
int random=rand() %100 + 1;
if (random < 25) {
hit=false;
}
}
return hit;
}
Water::~Water(){
delete normal;
delete especial;
}