-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCharacter.java~
50 lines (32 loc) · 1.06 KB
/
Character.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
// superlcass for anyhting that can take actions (PCs, NPCs)
public abstract class Character {
private static final int maxCooldown=3; //what cooldown is after acting
private int cooldown; //turns until action can be taken
private GameActionType queuedAction;
private static final int mapSize=3; //mapTiles x mapTiles they inhabit
private Point mapCenter; //center point they inhabit
public void decCooldown() {
if(cooldown>0) cooldown--;
} //decCooldown
public boolean canAct() {
return cooldown<=0 && queuedAction!=null;
} //canAct
public GameAction dequeueAction() {
GameAction a=new GameAction(queuedAction,this);
queuedAction=null;
cooldown=maxCooldown;
return a;
} //dequeueAction
public void newAction(GameActionType t) {
if(queuedAction==null) queuedAction=t;
} //newAction
public Point getMapCenter() {
return mapCenter;
} //getMapCenter
public void setMapCenter(Point p) {
mapCenter = p;
} //setMapCenter
public int getMapSize() {
return mapSize;
} //getMapSize
} //class