-
Notifications
You must be signed in to change notification settings - Fork 320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow users to re-enter elevator that changes indicators without moving. #74
base: master
Are you sure you want to change the base?
Conversation
@@ -120,6 +120,12 @@ var createWorldCreator = function() { | |||
} | |||
}); | |||
}); | |||
elevator.on("indicatorstate_change", function() { | |||
var elevator = this; | |||
if(elevator.isOnAFloor() && !elevator.isMoving && !elevator.isFull()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this addition, the expression elevator.isOnAFloor() && !elevator.isMoving && !elevator.isFull()
appears twice in world.js
. I think it should be refactored into a function elevator.isSuitableForUserEntrance()
. Though that could be done after your pull request is accepted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did think about that, but I wanted to touch as little existing code as possible. I could certainly pull that after this gets merged.
I'm afraid this probably can't be done like this.. I think this will cause "sliding users", meaning passengers that are entering the elevator just as it starts moving, making them fly into the elevator between floors sort of. This should be done like the re-arrival behaviour - queueing the floor another time. It's a little messy. |
Then it sounds like this pull request can be fixed by changing elevator.trigger("entrance_available"); to elevator.goToFloor(elevator.currentFloor(), true); But I think before that line, you must either wrap |
Yes, basically. I'm thinking of moving the queue logic into the elevator object so that this type of thing can be done without involving the interface object. What do you think about that? |
Hmm, well, in both uses of the interface in So yes, moving the queue logic to the elevator object is better than the current organization. It might not be the best design overall, but I can’t think of a better design right now. |
Agree. |
I did try re-queueing it like it's done below, but that's causes an issue where elevators changing their indicators after they've already been told to goToFloor has passengers load, but they never go to the next floor. |
@apottere Are you calling |
I was calling it on the interface, like a few lines below:
That would cancel the call I made in my game script, which was essentially:
|
I updated to use the interface - I'm not sure what I thought was broken last time I tried that, but I'm certainly not seeing it now. With that change, the code below works on challenge #1, and the goToFloor call doesn't get canceled:
|
This has come up in our play of the game. Hope it gets fixed! |
Any updates on this? |
See #59