In the final version of the Mjai protocol (protocol_version == 3), messages sent from the server to the client include possible_actions and cannot_dahai fields.
This field allows the server to explicitly communicate which actions are available to the client, including the set of possible calls, whether winning is allowed, and which tiles cannot be discarded due to kuikae restrictions or after declaring riichi.
Pros
- The client no longer needs to compute its own set of legal actions, reducing implementation complexity.
Cons
- The server must customize outgoing messages for each client.
- Messages sent to clients during a match must be separated from those stored as logs.
Reference
For reference, the corresponding implementation in the original mjai project can be found here:
https://github.com/gimite/mjai/blob/master/lib/mjai/game.rb