-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStats.pde
105 lines (89 loc) · 1.91 KB
/
Stats.pde
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
public class Stats {
private int body;
private int wits;
private int craft;
private int luck;
private int life;
public Stats(int[] stat_array) {
assert(stat_array.length == 5);
body = stat_array[0];
wits = stat_array[1];
craft = stat_array[2];
luck = stat_array[3];
life = stat_array[4];
}
public Stats(int new_body, int new_wits, int new_craft, int new_luck, int new_life) {
this(new int[]{new_body, new_wits, new_craft, new_luck, new_life});
}
public int get_body() {
return body;
}
public void set_body(int new_body) {
body = new_body;
}
public int get_wits() {
return wits;
}
public void set_wits(int new_wits) {
body = new_wits;
}
public int get_craft() {
return craft;
}
public void set_craft(int new_craft) {
body = new_craft;
}
public int get_luck() {
return luck;
}
public void set_luck(int new_luck) {
body = new_luck;
}
public int get_life() {
return life;
}
public void set_life(int new_life) {
body = new_life;
}
public int get_stat(int id) {
assert(id >= 0 && id < 5);
switch (id) {
case 0:
return get_body();
case 1:
return get_wits();
case 2:
return get_craft();
case 3:
return get_luck();
case 4:
return get_life();
}
return -1;
}
public void set_stat(int id, int new_val) {
assert(id >= 0 && id < 5);
switch (id) {
case 0:
body = new_val;
break;
case 1:
wits = new_val;
break;
case 2:
craft = new_val;
break;
case 3:
luck = new_val;
break;
case 4:
life = new_val;
break;
}
}
public void apply_to_player(int sign) {
for (int i = 0; i < 5; i++) {
player_stats.set_stat(i, max(0, player_stats.get_stat(i) + sign * get_stat(i)));
}
}
}