Open jkomoros opened 4 years ago
See also #752, which proposes a mechanism where beahviors.Color
has Color
and ProposedColor
. A player may set their own ProposedColor live, but it can only be copied from ProposedColor to Color by the administrator. But the admin might also play a move that disallows anyone but admins to modify even proposed color right now.
In general admin is not a bool, but something that is specific to each particular move. You want some mechanism that allows configuration of which playerState is allowed to apply which moves right now. Maybe it's a type of move that is called RequirePermission
or something, that is designed to be embedded within other moves, that has a PlayerHasPermission(playerState) error
that is called within its legal method for the proposer, and where PlayerAllowed(playerState) has some prebaked smart logic. That method could by default consult move.MinimumPermissionLevel(), and if the playerState has Permission that has an enum value larger than that, then it allows it. And then there's a WithMiminumPermission(level int) to configure that without writing code.
And maybe you could do something smart with tree enum behavior or something.
And then by default everyone starts with a permission of 0, and admin is 1, but you can override that and be as bespoke as you want.
There are some actions, like reassign teams, reorder players, WaitForEnoughPlayers, that only some players should be able to do.
A prebaked
behaviors.GameAdministrator
that has a MayAdministerGame bool. If true, then actions like the above are allowed to proceed. If false, then those moves are only allowed if the move has been explicitly configured to allow anyone to do the action, or some other test. (Conceivably you might want a different bit for the different prebaked moves)If behaviors.GameAdministrator is included, by default player 0 is set to administrator only. But the admin can also assign another person to be admin.
Ideally delegate.GroupMembership and related machinery could be used in Legal methods.
Related to #491. See also #770. See also #768