From 6ce3b5a142b3e357eeabde37368915e8ef916f3d Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Thu, 4 Jan 2018 11:38:36 +0000 Subject: Add json rules for fortunes favor --- .idea/statistic.xml | 14 +++++++++++ resources/default.json | 2 +- resources/fortunes-favor.json | 8 +++++++ resources/simple-fortunes-favor.json | 9 +++++++ src/main/input-output/input/sol_preset_types.cpp | 22 ++++++++--------- src/test/fortunes_favor_test.cpp | 28 ++++++++++++++++++++++ .../resources/fortunes_favor/ComplexSolvable.json | 7 ++++++ .../fortunes_favor/ComplexUnsolvable.json | 7 ++++++ .../resources/fortunes_favor/SimpleSolvable.json | 7 ++++++ .../resources/fortunes_favor/SimpleUnsolvable.json | 7 ++++++ 10 files changed, 99 insertions(+), 12 deletions(-) create mode 100644 .idea/statistic.xml create mode 100644 resources/fortunes-favor.json create mode 100644 resources/simple-fortunes-favor.json create mode 100644 src/test/fortunes_favor_test.cpp create mode 100644 src/test/resources/fortunes_favor/ComplexSolvable.json create mode 100644 src/test/resources/fortunes_favor/ComplexUnsolvable.json create mode 100644 src/test/resources/fortunes_favor/SimpleSolvable.json create mode 100644 src/test/resources/fortunes_favor/SimpleUnsolvable.json diff --git a/.idea/statistic.xml b/.idea/statistic.xml new file mode 100644 index 0000000..1f847e3 --- /dev/null +++ b/.idea/statistic.xml @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/resources/default.json b/resources/default.json index 12d39b2..756e31f 100644 --- a/resources/default.json +++ b/resources/default.json @@ -8,7 +8,7 @@ "max rank": 13, "hole": false, "foundations": true, + "foundation initial card": false, "cells": 0, - "reserve size": 0, "stock size": 0 } \ No newline at end of file diff --git a/resources/fortunes-favor.json b/resources/fortunes-favor.json new file mode 100644 index 0000000..b791561 --- /dev/null +++ b/resources/fortunes-favor.json @@ -0,0 +1,8 @@ +{ + "tableau piles": { + "count": 12, + "build policy": "same-suit" + }, + "foundations initial card": true, + "stock size": 36 +} \ No newline at end of file diff --git a/resources/simple-fortunes-favor.json b/resources/simple-fortunes-favor.json new file mode 100644 index 0000000..6f3cf61 --- /dev/null +++ b/resources/simple-fortunes-favor.json @@ -0,0 +1,9 @@ +{ + "tableau piles": { + "count": 3, + "build policy": "same-suit" + }, + "max rank": 4, + "foundations initial card": true, + "stock size": 3 +} \ No newline at end of file diff --git a/src/main/input-output/input/sol_preset_types.cpp b/src/main/input-output/input/sol_preset_types.cpp index 3c9d295..96cbba9 100644 --- a/src/main/input-output/input/sol_preset_types.cpp +++ b/src/main/input-output/input/sol_preset_types.cpp @@ -147,32 +147,32 @@ std::map sol_preset_types::mp = { }, { - "canfield", + "fortunes-favor", R"( { "tableau piles": { - "count": 4, - "build policy": "red-black" + "count": 12, + "build policy": "same-suit" }, - "reserve size": 14, - "stock size": 34 + "foundations initial card": true, + "stock size": 36 } )" }, { - "simple-canfield", + "simple-fortunes-favor", R"( { "tableau piles": { - "count": 2, - "build policy": "red-black" + "count": 3, + "build policy": "same-suit" }, - "max rank": 2, - "reserve size": 2, - "stock size": 2 + "max rank": 4, + "foundations initial card": true, + "stock size": 3 } )" diff --git a/src/test/fortunes_favor_test.cpp b/src/test/fortunes_favor_test.cpp new file mode 100644 index 0000000..8973a53 --- /dev/null +++ b/src/test/fortunes_favor_test.cpp @@ -0,0 +1,28 @@ +// +// Created by thecharlesblake on 10/4/17. +// + +#include + +#include "test_helper.h" + +typedef test_helper th; + +const static std::string path = "resources/spanish_patience/"; +const static std::string type = "simple-spanish-patience"; + +TEST(SpanishPatience, SimpleSolvable) { + EXPECT_TRUE(th::is_solvable(path + "SimpleSolvable.json", type)); +} + +TEST(SpanishPatience, ComplexSolvable) { + EXPECT_TRUE(th::is_solvable(path + "ComplexSolvable.json", type)); +} + +TEST(SpanishPatience, SimpleUnsolvable) { + EXPECT_FALSE(th::is_solvable(path + "SimpleUnsolvable.json", type)); +} + +TEST(SpanishPatience, ComplexUnsolvable) { + EXPECT_FALSE(th::is_solvable(path + "ComplexUnsolvable.json", type)); +} diff --git a/src/test/resources/fortunes_favor/ComplexSolvable.json b/src/test/resources/fortunes_favor/ComplexSolvable.json new file mode 100644 index 0000000..c48ce47 --- /dev/null +++ b/src/test/resources/fortunes_favor/ComplexSolvable.json @@ -0,0 +1,7 @@ +{ + "tableau piles": [ + ["AS", "2S", "AH"], + ["AD", "2D", "2H"], + ["2C", "AC"] + ] +} diff --git a/src/test/resources/fortunes_favor/ComplexUnsolvable.json b/src/test/resources/fortunes_favor/ComplexUnsolvable.json new file mode 100644 index 0000000..ba9be59 --- /dev/null +++ b/src/test/resources/fortunes_favor/ComplexUnsolvable.json @@ -0,0 +1,7 @@ +{ + "tableau piles": [ + ["AS", "2S", "AH"], + ["AD", "2D", "2H"], + ["AC", "2C"] + ] +} diff --git a/src/test/resources/fortunes_favor/SimpleSolvable.json b/src/test/resources/fortunes_favor/SimpleSolvable.json new file mode 100644 index 0000000..eacad0e --- /dev/null +++ b/src/test/resources/fortunes_favor/SimpleSolvable.json @@ -0,0 +1,7 @@ +{ + "tableau piles": [ + ["2S", "AS", "AD"], + ["2D", "2H", "AH"], + ["2C", "AC"] + ] +} diff --git a/src/test/resources/fortunes_favor/SimpleUnsolvable.json b/src/test/resources/fortunes_favor/SimpleUnsolvable.json new file mode 100644 index 0000000..99a3140 --- /dev/null +++ b/src/test/resources/fortunes_favor/SimpleUnsolvable.json @@ -0,0 +1,7 @@ +{ + "tableau piles": [ + ["AS", "2S", "2D"], + ["AD", "AH", "2H"], + ["AC", "2C"] + ] +} -- cgit v1.2.1