-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWizard.java
63 lines (53 loc) · 1.39 KB
/
Wizard.java
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
/*
Author: Marcello de Paula Ferreira Costa
#USP: 7960690
Author: Jessika Darambaris
#USP: 7961026
Universidade de São Paulo
Trabalho para o Curso de Programação Orientada à Objetos
Wizard (Character's subclass)
*/
public class Wizard extends Character{
protected int wisdom;
public Wizard (String name, int wisdom) {
super(name);
this.wisdom = wisdom;
setType("Wizard");
}
public Wizard (Wizard Base) {
super (Base);
this.wisdom = Base.wisdom;
setType("Wizard");
}
@Override
protected int getDefensePoints () {
return super.getDefensePoints() + (int)(this.wisdom/2.0);
}
public void attack(Character target) {
double p; /* p is be used as an random probability
* and also as an auxiliar variable */
int damage;
p = Math.random() * 100.0;
if (!(p <= 10.0/(double)this.xp)) {
p = (getAttackPoints() - target.getDefensePoints() + (Math.random()*10.0-5.0));
if (p < 0.0 || (int)p == 0) {
damage = 1;
}
else damage = (int)p;
/* Critical Attack probability */
p = Math.random() * 100.0;
if (p < (0.02*(double)this.xp/2.0)*100.0) {
damage += damage;
//System.out.print("Critical Strike! ");
}
//System.out.println("Damage dealt: "+damage);
target.addHP((-damage));
}
else {
//System.out.println("You missed your attack! Be cafeful!");
}
}
public void addWisdom(int wisdom) {
this.wisdom += wisdom;
}
}