-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboolean concepts.js
More file actions
51 lines (51 loc) · 1.5 KB
/
boolean concepts.js
File metadata and controls
51 lines (51 loc) · 1.5 KB
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
/**
* The fast attack is available when the knight is sleeping
*
* @param {boolean} knightIsAwake
*
* @return {boolean} Whether or not you can execute a fast attack.
*/
export function canExecuteFastAttack(knightIsAwake) {
return !knightIsAwake;
}
/**
* A useful spy captures information, which they can't do if everyone's asleep.
*
* @param {boolean} knightIsAwake
* @param {boolean} archerIsAwake
* @param {boolean} prisonerIsAwake
*
* @returns {boolean} Whether or not you can spy on someone.
*/
export function canSpy(knightIsAwake, archerIsAwake, prisonerIsAwake) {
return knightIsAwake || archerIsAwake || prisonerIsAwake;
}
/**
* You'll get caught by the archer if you signal while they're awake.
*
* @param {boolean} archerIsAwake
* @param {boolean} prisonerIsAwake
*
* @returns {boolean} Whether or not you can send a signal to the prisoner.
*/
export function canSignalPrisoner(archerIsAwake, prisonerIsAwake) {
return ((archerIsAwake==!true) && (prisonerIsAwake));
}
/**
* The final stage in the plan: freeing Annalyn's best friend.
*
* @param {boolean} knightIsAwake
* @param {boolean} archerIsAwake
* @param {boolean} prisonerIsAwake
* @param {boolean} petDogIsPresent
*
* @returns {boolean} Whether or not you can free Annalyn's friend.
*/
export function canFreePrisoner(
knightIsAwake,
archerIsAwake,
prisonerIsAwake,
petDogIsPresent
) {
return ((petDogIsPresent) && (archerIsAwake==!true)) || ((prisonerIsAwake) && (archerIsAwake==!true) && (knightIsAwake==!true));
}