-
Notifications
You must be signed in to change notification settings - Fork 707
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
feat: Add endStage
and setStage
events
#458
feat: Add endStage
and setStage
events
#458
Conversation
This moves the logic that resets an empty `activePlayers` to next, previous or `null` values into `UpdateActivePlayers`, so that it can be called from an `EndStage` event and not just inside `ProcessMove`.
If `arg.moveLimit` could reach `UpdateStage` this logic would update `ctx` appropriately.
The easiest solution might be to use the short form / long form pattern that we follow elsewhere. setStage('B')
setStage({ stage: 'B, moveLimit: 2 }) So now you only have one argument. |
Oh, right, good idea. I’ll go with that for now :-) |
Supports `moveLimit` with an object argument: `setStage({ stage, moveLimit })`
@nicolodavis How should I test for the |
The only "automatic" end of stage that we have right now is triggered via |
OK! One thing: right now If I understood correctly, events are only callable by |
We might have to relax the condition. Maybe let's have any player that is "active" (i.e. one of the |
That makes sense to me. I guess at some point some config for what events are enabled etc. might be needed, but for now stages are the loosest of all the game elements. (Unlike phases there are no checks that a stage is actually declared when setting it and at the moment they only declare moves.) I’m not sure exactly how to go about those changes, so I’ll proceed like I suggested with |
Thanks again for getting the |
Allow a `playerID` to be passed to `EndStage` and `UpdateStage` so they can be used to end/update any player in `activePlayers`. They default to `ctx.currentPlayer` when called from the client, which could need changing once any active player can call events.
It’s been fun slowly figuring out how all the internals work!
|
endStage
and setStage
eventsendStage
and setStage
events
OK, I think this is good to go. Test coverage is just missing one branch where Flow({
events: {
setStage: false,
setPhase: false,
},
}); will not actually have any effect. So I guess, maybe the logic that sets |
Closes #445
Closes #446
Closes #447
🎉
I have tried adding the
endStage
andsetStage
events as discussed in #445, #446 and #447.I’m most of the way there, but ran into a roadblock with adding the
moveLimit
option forsetStage
. If I understood correctly (and I’ll admit I felt a little lost reading through all the event-related code), when calling an event from the client, the single passed argument is used as the payload for the action sent to the reducer. So that makes my imagined syntax ofsetStage('B', { moveLimit: 2 })
not as trivial to implement as I imagined.Presumably there would need to be a wrapper somewhere that formats arguments to client events so that supporting a second optional argument is possible, but I’m not sure exactly where or how that should be implemented.
In the meantime, I have added a failing test for
moveLimit
andUpdateStage
in flow.js does contain the correct logic to hypothetically updatectx
were themoveLimit
argument to reach it. If you have any pointers, I can try to implement something, or if you prefer to get this merged without themoveLimit
support, I can strip those parts out to be figured out later.