-
Notifications
You must be signed in to change notification settings - Fork 0
/
pokemon.h
151 lines (103 loc) · 2.41 KB
/
pokemon.h
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
//
// Created by Herman Karlsson on 2017-02-11.
//
#ifndef POKEMON_SIMULATION_POKEMON_H
#define POKEMON_SIMULATION_POKEMON_H
#include <random>
#include "util.h"
/*
* types:
* 0: normal
* 1: fire
* 2: water
* 3: electric
* 4: grass
* 5: ice
* 6: fighting
* 7: poison
* 8: ground
* 9: flying
* 10: psychic
* 11: bug
* 12: rock
* 13: ghost
* 14: dragon
* 15: dark
* 16: steel
* 17: fairy
*/
class pokemon {
private:
double hp, atk, def, spd, hp_start;
int type;
//std::mt19937 rng;
public:
void generate(std::mt19937 &);
void fight(pokemon &);
void atk_change(double);
void damage(double);
double weakness(pokemon&);
double health();
double hpmax();
double speed();
double attack();
double defence();
int get_type();
void heal(int);
};
void pokemon::generate(std::mt19937 &rng) {
static std::binomial_distribution<double> distribution(239);
static std::uniform_int_distribution<int> typedist(0,17);
//this->rng = rng;
this->hp = 16+distribution(rng);
this->atk = 16+distribution(rng);
this->def = 16+distribution(rng);
this->spd = 16+distribution(rng);
this->type = typedist(rng);
this->hp_start = this->hp;
}
void pokemon::damage(double dam) {
this->hp -= dam;
}
void pokemon::fight(pokemon & opp) {
double atk = this->attack();
double def = opp.defence();
double mod = type_diff(this->get_type(),opp.get_type());
//static std::uniform_real_distribution<double> dist(0.85,1);
double ran = 1;//dist(this->rng);
opp.damage(std::max(0.0,(420*atk/def/50+2)*1.25*mod*ran));
//this->atk_change(1);
//opp.atk_change(-1);
}
void pokemon::atk_change(double delta) {
this->atk += delta;
}
double pokemon::weakness(pokemon &opp) {
double atk = this->attack();
double def = opp.defence();
double mod = type_diff(this->get_type(),opp.get_type());
return std::max(0.0,this->health()-(420*atk/def/50+2)*1.25*mod);
//return std::max(0.0,this->health()-int((pkmn.attack()-this->defence()/2)*type_diff(pkmn.get_type(),this->get_type())));
}
double pokemon::health() {
return this->hp;
}
double pokemon::speed() {
return this->spd;
}
double pokemon::attack() {
return this->atk;
}
double pokemon::defence() {
return this->def;
}
double pokemon::hpmax() {
return this->hp_start;
}
int pokemon::get_type() {
return this->type;
}
void pokemon::heal(int delta = 10000) {
this->hp = std::min(this->hp_start,this->hp + delta);
}
#endif //POKEMON_SIMULATION_POKEMON_H