Allowed moves as function#164
Conversation
…game.io into allowedMoves_as_function
| * allowedMoves: ['moveA', ...], | ||
| * // List of moves or a function that returns a list of moves | ||
| * // that are allowed in this phase. | ||
| * allowedMoves: (G, ctx) => ['moveA', ...], |
There was a problem hiding this comment.
Let's also make this available on a per-game basis (not just on a per-phase basis)?
There was a problem hiding this comment.
Oops, forgot to wait for this. No worries, I'll just add this myself.
|
Hijacking this thread for a moment to discuss something broader. We don't need to implement any of the following in this PR. One of us will follow up later: We now have a few different mechanisms to disallow moves:
1 is designed to handle disabling types of moves. 2 and 3 are designed to disable specific instances of a move (with a particular argument combination for example). Both are valuable, but I would recommend that we only use one out of 2 and 3 to do the latter. I'm leaning toward retiring 2 (i.e. not allowing the user to override canMakeMove). Also, we should probably expose 1 through ctx so that it is a helpful hint to the UI to figure out what moves to highlight. @Stefan-Hanke, what do you think? @felizardo, this might also be useful for the AI code. Let's consolidate what we have there as well. |
|
I think exposing it to ctx is perfect, exactly what’s needed to make it work at the top level, and I like returning undefined from a move to specifically disallow it, but I was wondering if at the top level of the config should it maybe be a |
|
Let's just use allowedMoves everywhere. It's much less confusing that way. About the semantics of the override, let's just have the phase level config override the global config whenever it is defined. We can use For example, if a game has three moves: A, B and C. |
|
@nicolodavis Sorry I've been a little bit busy IRL, so I lost a little bit the track of the changes, I will try to catch up this weekend |
Checklist
master).here it is only on the phase level, im having trouble getting it working on the top level in flow, i want to return all move names by default, or should it just stay undefined by default at the top level? any suggestions would be very appreicated