-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathThief.java
63 lines (53 loc) · 1.38 KB
/
Thief.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
Thief (Character's subclass)
*/
public class Thief extends Character{
protected int stealth;
public Thief (String name, int stealth) {
super(name);
this.stealth = stealth;
setType("Thief");
}
public Thief (Thief Base) {
super (Base);
this.stealth = Base.stealth;
setType("Thief");
}
@Override
protected int getAttackPoints () {
return super.getAttackPoints() + this.stealth;
}
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 addStealth (int stealth) {
this.stealth += stealth;
}
}