-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPokemon.java
More file actions
166 lines (132 loc) · 4.2 KB
/
Pokemon.java
File metadata and controls
166 lines (132 loc) · 4.2 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
package PokeJava;
import java.util.Random;
public abstract class Pokemon implements Atacavel{
private String nome;
private Integer hp;
private Integer hpMax;
private Integer ataque;
private Integer defesa;
private TipoPokemon tipo;
private StatusPokemon status;
private Boolean estaDefendendo;
public Pokemon(String nome, Integer hp, Integer hpMax, Integer ataque,
Integer defesa, TipoPokemon tipo) {
this.nome = nome;
this.hp = hp;
this.hpMax = hpMax;
this.ataque = ataque;
this.defesa = defesa;
this.tipo = tipo;
this.status = StatusPokemon.NORMAL;
this.estaDefendendo = false;
}
//getters/setters
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public Integer getHp() {
return hp;
}
public void setHp(Integer hp) {
this.hp = hp;
}
public Integer getHpMax() {
return hpMax;
}
// public void setHpMax(Integer hpMax) {
// this.hpMax = hpMax;
// }
public Integer getAtaque() {
return ataque;
}
public void setAtaque(Integer ataque) {
this.ataque = ataque;
}
public Integer getDefesa() {
return defesa;
}
public void setDefesa(Integer defesa) {
this.defesa = defesa;
}
public TipoPokemon getTipo() {
return tipo;
}
public void setTipo(TipoPokemon tipo) {
this.tipo = tipo;
}
public StatusPokemon getStatus() {
return status;
}
public void setStatus(StatusPokemon status) {
this.status = status;
}
public Boolean getEstaDefendendo() {
return estaDefendendo;
}
public void setEstaDefendendo(Boolean estaDefendendo) {
this.estaDefendendo = estaDefendendo;
}
//Metodos
public void receberDano(int dano){
if(estaVivo()){
if (estaDefendendo){
dano -= dano/2;
estaDefendendo = false;
}
if(dano > hp){
hp = 0;
}else {
hp = hp - dano;
}
}
}
public boolean estaVivo(){
return hp > 0;
}
public void aplicarEfeitoStatus() throws PokemonParalisadoException{
int dano;
switch (getStatus()){
case QUEIMADO:
//perde 10% de hp maximo por turno
dano = getHpMax() * 10 / 100;
receberDano(dano);
System.out.println("O POKEMON FOI FERIDO COM QUEIMADURA");
break;
case CONFUSO:
//perde 5% de hp maximo por turno
dano = getHpMax() * 5 / 100;
receberDano(dano);
System.out.println("O POKEON ESTÁ CONFUSO, E ATACOU A SI MESMO EM SUA CONFUSÃO.");
break;
case PARALISADO:
throw new PokemonParalisadoException("O POKEMON ESTÁ PARALISADO E NÃO CONSEGUE SE MEXER!");
case NORMAL:
break;
default:
}
}
public abstract StatusPokemon getStatusEspecial();
public abstract void ArtePokemon();
//implementa interface Atacavel
@Override
public void atacar(Pokemon alvo, float multiplicador ) {
Random random = new Random();
int efetividade = random.nextInt(40 - 20 + 1) + 20; // valor aleatório de efetividade ajustar se necessario
int danoFinal = (int)(ataque * efetividade / 100 * multiplicador);
alvo.receberDano(danoFinal);
}
@Override
public void usarAtaqueEspecial(Pokemon alvo) throws HPInsuficienteException{
if(estaVivo() && hp>15){
receberDano(15); //tira 15 do seu próprio hp
alvo.setStatus(getStatusEspecial());
}else{
throw new HPInsuficienteException("HP INSUFICIENTE !");
}
System.out.println(getNome()+ " USOU ATAQUE ESPECIAL!");
System.out.println(alvo.getNome() + " FICOU " + alvo.getStatus());
}
}