Replies: 1 comment 1 reply
-
|
Hi @JoaoCnh, where is the TrickPlay stored within the state? It may be that sharing the same PlayedCard instance is causing the issues, I’d suggest to try cloning the PlayedCard when passing it to TrickPlay so they are treated separately |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey everyone,
I want to understand how to use ViewState more effectively and correctly since I'm not really understanding from the docs.
I'm also getting weird behaviour while using it.
I have a game where the state can be described like this:
With the @view decorator this works just fine. Only the player can see their hand when inspect the view state.
In every round a trick is played and I wanted to store the won trick in a wonTricks array for the player. Similar to the hand only the player can see it. I thought it would be easy, simply by adding a similar array to the hand but it broke everything.
So if
and then added it as a @view on the Player.
when resolving the trick I would assign it to the correct player while creating new objects like
and after this even the normal trick stopped working.
What am I doing wrong here? How should this feature be tackled?
As another note, I was thinking of having the main state having 2 properties only. The entire data that is completely private and then a viewstate property that I can purposefully alter and maybe that would solve all my issues?
Like this:
I'm really not sure, I am not understanding how to use this at all.
Can anyone help?
Beta Was this translation helpful? Give feedback.
All reactions