magwo / elevatorsaga

The elevator programming game!

Home Page:http://play.elevatorsaga.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

goingUp and goingDown indicators are always true

avodonosov opened this issue · comments

Elevator.goingUpIndicator() and Elevator.goingDownIndicator() always return true, without regard to actual direction and the value of Elevator.destinationDirection(). This can be seen with update function like this.

        update: function(dt, elevators, floors) {
            console.log('indicators: goingUp, goingDown; destinationDirection');
            var i = 0;
            for (e of elevators) {
                console.log('elevator ' + i++, e.goingUpIndicator(), e.goingDownIndicator(), e.destinationDirection());
            }
        }

Example logs:


indicators: goingUp, goingDown; destinationDirection
elevator 0 true true down
elevator 1 true true stopped
indicators: goingUp, goingDown; destinationDirection
elevator 0 true true down
elevator 1 true true stopped
indicators: goingUp, goingDown; destinationDirection
elevator 0 true true down
elevator 1 true true stopped
indicators: goingUp, goingDown; destinationDirection
elevator 0 true true down
elevator 1 true true stopped

Is that a bug? Or the player must manage them programmatically? But there is no good event to place an update code - something like "direction-changed" would be desirable for that. But the Elevator implementation can easily do that, given that it changes the destinationDirection value.

Closing this, I think the indioators are intended for the player to manag

Yep. A better name would be elevator.allowPassengersGoingUp/elevator.allowPassengersGoingDown. The current names are also misleading in that you sometimes want both or neither (if you're just dropping off). I've written code that deliberately sets the indicators to be different from the way the elevator is going.