forked from brandr/Roguelike
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEffect.java
More file actions
56 lines (48 loc) · 1.12 KB
/
Effect.java
File metadata and controls
56 lines (48 loc) · 1.12 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
public class Effect { //effects that happen to players
public Effect(){
name=null;
value=0;
duration=0;
effectIndex=-1;
}
public Effect(int index){
effectIndex=index;
setName(index);
}
private void setName(int index) {
switch(index){
case 0:
name="heal or harm"; //regen or damage over time still fall into this category.
break; //TODO: should healing and harming be separate? harming potions should ignore armor.
case 1:
name="instant kill";
break;
case 2:
name="adjust max HP";
break;
default:
name=null;
break;
}
}
public void takeEffect(Monster target){
switch(effectIndex){
case 0:
target.restoreHealth(value);
break;
case 1:
target.die();
break;
case 2:
target.setMaxHitPoints(target.maxHitPoints()+value);
break;
default:
break;
}
}
//effect types: healing, harming, boosting/lowering stats like attack, armor or speed, insta-killing, teleporting, etc
protected String name;
protected int value=0; //amount healed, increase in speed, etc.
protected int duration=0; //zero is for instantaneous
protected int effectIndex;
}