-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.js
More file actions
41 lines (30 loc) · 979 Bytes
/
Player.js
File metadata and controls
41 lines (30 loc) · 979 Bytes
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
class Player {
constructor(logger) {
this.field = null;
this.balance = 1500;
this.totalMoves = 0;
this.poperties = [];
this.doubleRolls = 0;
this.rollsSinceJail = -1;
this.logger = logger;
}
setField = (field) => {
this.totalMoves++;
this.field = field;
this.logger.logField(field);
this.logger.logAction(`Gehe zum Feld: ${field.name}`);
}
getField = () => this.field;
increaseDoubleRolls = () => this.doubleRolls++;
getDoubleRolls = () => this.doubleRolls;
resetDoubleRolls = () => this.doubleRolls = 0;
getRollsSinceJail = () => this.rollsSinceJail;
increaseRollsSinceJail = () => this.rollsSinceJail++;
toJail = (board) => {
this.setField(board.findFieldByType("jail"));
this.rollsSinceJail++;
}
inJail = () => this.rollsSinceJail !== -1;
fromJail = () => this.rollsSinceJail = -1;
}
export default Player