jkomoros / boardgame

An in-progress framework in golang to easily build boardgame Progressive Web Apps
Apache License 2.0
31 stars 4 forks source link

A way for a Enum property to express to struct inflater a property that's not tied to a struct tag #773

Open jkomoros opened 4 years ago

jkomoros commented 4 years ago

For example, the behaviors.Color hard-codes that the enum is Color. Ideally you could have some way for a struct inflater to inspect the field and get more information about it, and that information could be plumbed in from elsewhere. (Note: things are passed to NewStructInflater when they aren't even part of an exampleState, so you'd need to figure out where to stick them). This could allow you to have different enums used.

It could also allow a behavior.ProposedEnum that could be set to a specific enum live, and not hard-coded within the behavior. (But then you could only have one enum taht could be proposed by the player).

Perhaps the mechanism is as simple as a struct tag on the behavior that can be inspected by struct inflater, not just the leaf property.

Thought of while thinking about #752