-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tank.java
83 lines (65 loc) · 1.51 KB
/
Tank.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
public class Tank extends Character{
public Tank() {
super();
hp = 500;
speed = 10;
damage = 80;
luck = 60;
money = 0;
normalstats[0] = hp;
normalstats[1] = speed;
normalstats[2] = damage;
normalstats[3] = luck;
image = convertString(new String[]
{ " _____ ",
"/ \\",
"| ==",
"\\_____/",
" | ",
" __|\\ ",
"/ \\ + ",
"| | | ",
"\\__/\\| "}
);
attackNames = new String[]{ "Swing","Shield Bash","Rampage","Charge"};
}
public Tank(String name) {
this();
this.name = name;
}
public String attack1( Monster mon, BattleMap map ){
int temp = mon.lowerHealth(damage);
String s = attackNames[0];
if(temp == 0) {
s += ", but missed";
}
return s;
}
public String attack2( Monster mon, BattleMap map ){
int temp = mon.lowerHealth( (int ) ( 0.8 * damage + (0.4 * damage * Math.random()) )) ;
String s = attackNames[1];
if(!(temp == 0)) {
mon.setSpeed( 2 );
return s;
}
s += ", but missed";
return s;
}
public String attack3( Monster mon, BattleMap map ){
int temp = mon.lowerHealth( (int) (damage + ( damage * ( Math.random() + 0.5 ))) );
this.setSpeed( this.getSpeed() - 3 );
String s = attackNames[2];
if(temp == 0) {
s += ", but missed";
}
return s;
}
public String attack4( Monster mon, BattleMap map ){
int temp = mon.lowerHealth( (int) (damage * 2 * Math.random()) );
String s = attackNames[3];
if(temp == 0) {
s += ", but missed";
}
return s;
}
}