alexobviously / bishop

A chess logic package for Dart with flexible variant support
https://pub.dev/packages/bishop
Other
19 stars 8 forks source link

JSON import/export #27

Closed alexobviously closed 1 year ago

alexobviously commented 1 year ago

It would be pretty nice if it were possible to define variants in JSON files, making variants super portable. Actually for most of the fields it's trivial, but there are some exceptions.

Firstly, piece types called with the fromBetza (i.e. almost all of them) constructor, though that isn't too bad, we just check for a betza field in the json and vice versa.

The more complex exceptions are those with custom logic callbacks, such as the new actions and promo logic. I see two possible solutions:

  1. allow embedding code in the json file (ugly, maybe risky?)
  2. require registering functions for json export in some way - like when you create an Action, it has an optional id field, which links to some table you can provide to the json import function
alexobviously commented 1 year ago

Implemented in 1.1.0 with a couple of limitations