aboutsummaryrefslogtreecommitdiff
path: root/metasol.cpp
diff options
context:
space:
mode:
authorTom Harley2019-02-21 16:30:32 +0000
committerTom Harley2019-02-21 16:30:32 +0000
commitda3b449ee61fc03eef5f19a8189d4cfcfd000674 (patch)
treefca322d037a30bfd7bb284cba371f55de81a4f1a /metasol.cpp
parentAdd rules file for Canfield (diff)
downloadmetasol-da3b449ee61fc03eef5f19a8189d4cfcfd000674.tar.gz
metasol-da3b449ee61fc03eef5f19a8189d4cfcfd000674.zip

Clean up rule description files

The files for describing rules have changed a bit: they are no longer .json files (although they are still parsed by a JSON parser). The description files are now their own format, with a little less boilerplate required than for JSON files.

As a result, rule description files can be given shebangs and be made executable, allowing a user to run the rule file instead of centre directly. The rules files in the repository are set up to run centre if it is on the user’s path.

Diffstat (limited to 'metasol.cpp')
-rw-r--r--metasol.cpp29
1 files changed, 27 insertions, 2 deletions
diff --git a/metasol.cpp b/metasol.cpp
index f022f12..9d8abc9 100644
--- a/metasol.cpp
+++ b/metasol.cpp
@@ -29,6 +29,7 @@ struct dictcmp {
build_policy_t str_build_policy(char *str) {
kv_dict(build_policy_t) dict = {
{ "no build", NO_BUILD },
+ { "no-build", NO_BUILD },
{ "none", NO_BUILD },
{ "same suit", BUILD_SAME_SUIT },
@@ -63,18 +64,30 @@ spaces_policy_t str_spaces_policy(char *str) {
kv_dict(spaces_policy_t) dict = {
{ "none", NO_SPACE_FILL },
{ "no fill", NO_SPACE_FILL },
+ { "no-fill", NO_SPACE_FILL },
+ { "no_fill", NO_SPACE_FILL },
{ "kings only", KINGS_FILL_SPACE },
+ { "kings-only", KINGS_FILL_SPACE },
+ { "kings_only", KINGS_FILL_SPACE },
{ "kings", KINGS_FILL_SPACE },
{ "any", ANY_FILL_SPACE },
{ "all", ANY_FILL_SPACE },
{ "reserve first", AUTO_RESERVE_THEN_WASTE },
+ { "reserve-first", AUTO_RESERVE_THEN_WASTE },
+ { "reserve_first", AUTO_RESERVE_THEN_WASTE },
{ "reserve then waste", AUTO_RESERVE_THEN_WASTE },
+ { "reserve-then-waste", AUTO_RESERVE_THEN_WASTE },
+ { "reserve_then_waste", AUTO_RESERVE_THEN_WASTE },
{ "waste first", AUTO_WASTE_THEN_STOCK },
- { "waste then stock", AUTO_WASTE_THEN_STOCK }
+ { "waste-first", AUTO_WASTE_THEN_STOCK },
+ { "waste_first", AUTO_WASTE_THEN_STOCK },
+ { "waste then stock", AUTO_WASTE_THEN_STOCK },
+ { "waste-then-stock", AUTO_WASTE_THEN_STOCK },
+ { "waste_then_stock", AUTO_WASTE_THEN_STOCK }
};
lower(str);
@@ -96,12 +109,18 @@ const char *spaces_policy_str(spaces_policy_t bp) {
accordion_policy_t str_accordion_policy(char *str) {
kv_dict(accordion_policy_t) dict = {
{ "same rank", ACCORDION_SAME_RANK },
+ { "same-rank", ACCORDION_SAME_RANK },
+ { "same_rank", ACCORDION_SAME_RANK },
{ "rank", ACCORDION_SAME_RANK },
{ "same suit", ACCORDION_SAME_SUIT },
+ { "same-suit", ACCORDION_SAME_SUIT },
+ { "same_suit", ACCORDION_SAME_SUIT },
{ "suit", ACCORDION_SAME_SUIT },
{ "alternating colour", ACCORDION_ALTERNATE_COLOUR },
+ { "alternating-colour", ACCORDION_ALTERNATE_COLOUR },
+ { "alternating_colour", ACCORDION_ALTERNATE_COLOUR },
{ "red-black", ACCORDION_ALTERNATE_COLOUR },
{ "any", ACCORDION_ANY_SUIT }
@@ -127,12 +146,18 @@ stock_deal_t str_stock_deal(char *str) {
kv_dict(stock_deal_t) dict = {
{ "waste", STOCK_TO_WASTE },
{ "stock to waste", STOCK_TO_WASTE },
+ { "stock-to-waste", STOCK_TO_WASTE },
+ { "stock_to_waste", STOCK_TO_WASTE },
{ "tableau", STOCK_TO_TABLEAU },
{ "stock to tableau", STOCK_TO_TABLEAU },
+ { "stock-to-tableau", STOCK_TO_TABLEAU },
+ { "stock_to_tableau", STOCK_TO_TABLEAU },
{ "hole", STOCK_TO_HOLE },
- { "stock to hole", STOCK_TO_HOLE }
+ { "stock to hole", STOCK_TO_HOLE },
+ { "stock-to-hole", STOCK_TO_HOLE },
+ { "stock_to_hole", STOCK_TO_HOLE }
};
lower(str);