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

Allow more complex constant-based struct tag configuration #740

Open jkomoros opened 5 years ago

jkomoros commented 5 years ago

Discovered while working on #736

Ideally we'd need some way to do things like interpret NUM_PLAYERS - (NUM_PLAYERS / 2)

The constants dict should automatically be extended with things like NUM_PLAYERS and a few others (what else would they be?). All of them would have to be fixed for the life of the game. Maybe things like <DECK_NAME>_LENGTH and <ENUM_NAME>_LENGTH

And then there'd need to be a way to, given a string statement, interpret it as a float with basic math operators, so you could do things like NUM_PLAYERS - (NUM_PLAYERS / 2)

jkomoros commented 5 years ago

https://github.com/Knetic/govaluate will likely be useful

jkomoros commented 5 years ago

You can also imagine there being variables that may change at any time (maybe it's the "Computed Properties"? That introduces some weird properties to the system, but NUM_PLAYERS already invalidates certain caching strategies so 🤷‍♂