Bug: Player props only work after page refresh
Closed this issue · 9 comments
If you open the game website the first time so that the local storage is not set yet, player props do not get stored properly.
Only after page refresh they are available.
Steps to reproduce:
- open a incognito tab or window
- go to https://zero-to-mastery.github.io/ZTM-Quest/
- go to the toilet
- wash your hands
- talk to bruno
- try to go out
What should happen:
You should be able to go outside
What actually happens:
If you try to go out, you will get the message saying you should talk to Bruno although you already did.
After refreshing the page, you are able to go outside right away
@gdsouza1992 wanna fix this one because you added the feature in #50?
i think the issue is with how we are setting the state values, we only set them on dialog completion
player.onCollide('restroom_sink', () => {
player.isInDialog = true;
displayDialogueWithoutCharacter(
['You washed your hands. Good job!'],
() => {
player.state.hasHandsWashed = true;
player.isInDialog = false;
}
);
});
can you reproduce the issue if you click next on the dialogs until they close?
ill upload a video showing this behavior when i get some time. I think for cases like talking to Bruno it makes sense, but for just visiting the restroom it should be on collide.
i think the issue is with how we are setting the state values, we only set them on dialog completion
player.onCollide('restroom_sink', () => {
player.isInDialog = true;
displayDialogueWithoutCharacter(
['You washed your hands. Good job!'],
() => {
player.state.hasHandsWashed = true;
player.isInDialog = false;
}
);
});can you reproduce the issue if you click next on the dialogs until they close?
Yep, does also happen if you click next because you can't close thd dialog before reaching the last part of the text?
Did you try to reproduce it like I mentioned?
@gdsouza1992 yep, also if you hit next.
Only a page refresh makes it work.
Exactly, the next button is in some cases there although it shouldn't (see #55)
I fixed this in #78. The proxy needed a getter
Thanks for looking into it. I kept going down the rabit hole of initializing the state rather than thinking the issue could be in the retrieval
Good job guys 🔥💯