Private args per player in multipleactiveplayer state
Posted: 18 May 2025, 07:22
When entering my "useWhiteSum" state, which is an multipleactiveplayer state, each player should receive a list of valid moves as part of the "args" for that state. My problem comes when I want that each player gets their own different valid moves and these are hidden from the other players.
What I've tried:
1. Just sending args. All players get the same values, so best I can do is filter on the client side, but this makes it visible to other players if they inspect the requests.
2. Using "$this->getCurrentPlayerId" to generate the moves based on the current player (not the active one, everyone is active in this multiplayer state). This works on refresh but makes the game crash on setup. The troubleshooting guide explicitly advices against using "$this->getCurrentPlayerId" in the args function. That makes sense as in setup there is no player sending a request, thus no "current" player.
3. Sending a private notification to each player inside the "args" function. Couldn't make it work, I never received the notification in the client. I'm guessing it is sent before the listener is setup.
I'm going to explore the "private state" so each player is active in their own private state, but this seems rather complex for solving something that I could imagine being more common.
Any ideas?
What I've tried:
1. Just sending args. All players get the same values, so best I can do is filter on the client side, but this makes it visible to other players if they inspect the requests.
2. Using "$this->getCurrentPlayerId" to generate the moves based on the current player (not the active one, everyone is active in this multiplayer state). This works on refresh but makes the game crash on setup. The troubleshooting guide explicitly advices against using "$this->getCurrentPlayerId" in the args function. That makes sense as in setup there is no player sending a request, thus no "current" player.
3. Sending a private notification to each player inside the "args" function. Couldn't make it work, I never received the notification in the client. I'm guessing it is sent before the listener is setup.
I'm going to explore the "private state" so each player is active in their own private state, but this seems rather complex for solving something that I could imagine being more common.
Any ideas?