Allow users to re-enter elevator that changes indicators without moving.#74
Allow users to re-enter elevator that changes indicators without moving.#74apottere wants to merge 2 commits intomagwo:masterfrom apottere:master
Conversation
There was a problem hiding this comment.
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.
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