-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLeader.js
87 lines (85 loc) · 1.86 KB
/
Leader.js
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
import Inventory from './Inventory.js';
class Leader {
constructor() {
this.name = 'You';
// this.hand1 = null;
// this.hand2 = null;
this.age = 18;
this.ageRate = 1/100;
this.fullness = 50;
this.fullnessRate = -0.5;
this.inventory = new Inventory();
this.eating = false;
this.skills = {
building: 0,
enlightenment: 0,
farming: 0,
lumbering: 0,
mining: 0,
science: 0,
survivalism: 0,
};
this.base = (window.location.hostname === '127.0.0.1') ? 40 : 2; // TODO: reduce to 1 for harder difficulty
}
older(t) {
this.age += (this.ageRate * t);
if (this.fullness < 30) {
this.eating = true;
}
if (this.inventory.food >= 1 && this.eating) {
this.inventory.food -= 1;
this.fullness += 1;
if (this.fullness >= 100) {
this.fullness = 100;
this.eating = false;
}
} else {
this.fullness += (this.fullnessRate * t);
if (this.fullness < 0) { this.fullness = 0; }
this.eating = false;
}
}
eat() {
this.eating = true;
}
meditate() {
this.skills.enlightenment += this.base;
}
experiment() {
this.skills.science += this.base;
}
forage() {
this.inventory.give('food', this.base);
this.skills.survivalism += this.base;
}
farm() {
this.inventory.give('food', 2 * this.base);
this.skills.farming += this.base;
}
gatherWood() {
this.inventory.give('wood', this.base);
this.skills.lumbering += this.base;
}
chopWood() {
this.inventory.give('wood', 2 * this.base);
this.skills.lumbering += this.base;
}
mineStone() {
this.inventory.give('stone', this.base);
this.skills.mining += this.base;
}
mineOre() {
this.inventory.give('ore', this.base);
this.skills.mining += this.base;
}
build(what) {
this.skills.building += this.base;
}
checkInventory(stuff) {
return this.inventory.check(stuff);
}
getInventoryTotal() {
return this.inventory.getTotal();
}
}
export default Leader;