-
Notifications
You must be signed in to change notification settings - Fork 0
/
helper.js
39 lines (33 loc) · 887 Bytes
/
helper.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
function logGameMessage(message) {
// This function keeps console.log clutter out of mocha tests
if (process.env.NODE_ENV !== 'test') {
// eslint-disable-next-line no-console
console.log(message);
}
}
function diceRoll(numberOfSides) {
return Math.ceil(Math.random() * numberOfSides);
}
function isSentient({ amountFertilized, timeInSun, amountWatered }) {
return amountFertilized >= 4 && timeInSun === 1 && amountWatered === 1;
}
function isNormal({
amountWatered,
flowering,
sentient,
spiky,
}) {
return amountWatered >= 1
&& !flowering
&& !sentient
&& !spiky;
}
function isSpiky({ timeInSun, amountWatered }) {
return timeInSun === 5 && amountWatered === 1;
}
function isDead({ amountWatered, dead }) {
return amountWatered < 1 || dead;
}
module.exports = {
logGameMessage, isSentient, isNormal, diceRoll, isSpiky, isDead,
};