-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandom_logic.js
More file actions
38 lines (29 loc) · 1.16 KB
/
random_logic.js
File metadata and controls
38 lines (29 loc) · 1.16 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
var randomLogic = function(){
var logic = {
};
logic.onElevatorUpRequested = function(level) {
//send closest unused elevator or elevator that will visit the level anyways
console.log("onElevatorUpRequested");
// pick a random elevator and add the target level
var elevatorIndex = getRandomNumberBetween(0, looper.state.elevators.length - 1);
looper.state.elevators[elevatorIndex].addTargetLevel(level.id);
}
logic.onElevatorDownRequested = function(level) {
//send closest unused elevator or elevator that will visit the level anyways
console.log("onElevatorDownRequested");
// pick a random elevator and add the target level
var elevatorIndex = getRandomNumberBetween(0, looper.state.elevators.length - 1);
looper.state.elevators[elevatorIndex].addTargetLevel(level.id);
}
logic.onTargetLevelsChanged = function(currentState, elevator, targetLevels) {
//go to target levels one after another
}
logic.onElevatorIdle = function(elevator) {
//stay on the level
//console.log("onElevatorIdle");
}
logic.onElevatorStopped = function(elevator) {
//console.log("onElevatorStopped");
}
return logic;
}();