diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/input-output/command_line_helper.cpp | 17 | ||||
| -rw-r--r-- | src/main/input-output/sol_preset_types.cpp | 152 |
2 files changed, 158 insertions, 11 deletions
diff --git a/src/main/input-output/command_line_helper.cpp b/src/main/input-output/command_line_helper.cpp index 37908a2..49bb300 100644 --- a/src/main/input-output/command_line_helper.cpp +++ b/src/main/input-output/command_line_helper.cpp @@ -6,6 +6,7 @@ #include <vector> #include <boost/program_options.hpp> +#include <input-output/sol_preset_types.h> #include "command_line_helper.h" #include "game/sol_rules.h" @@ -68,7 +69,7 @@ bool command_line_helper::parse(int argc, const char* argv[]) { } if (vm.count("rules")) { - rules_file = vm["type"].as<string>(); + rules_file = vm["rules"].as<string>(); } if (vm.count("random")) { @@ -100,8 +101,8 @@ bool command_line_helper::assess_errors() { } // The user must supply either a solitaire type or a rules file - if (solitaire_type.empty() && rules_file.empty() - || !solitaire_type.empty() && !rules_file.empty()) { + if ((solitaire_type.empty() && rules_file.empty()) + || (!solitaire_type.empty() && !rules_file.empty())) { print_sol_type_rules_error(); return false; } @@ -115,17 +116,11 @@ bool command_line_helper::assess_errors() { // Checks if the supplied solitaire type is in the list of valid solitaires bool command_line_helper::assess_sol_type() { - if (find(sol_rules::valid_sol_strs.begin(), - sol_rules::valid_sol_strs.end(), - solitaire_type) != sol_rules::valid_sol_strs.end()) { + if (sol_preset_types::is_valid_preset(solitaire_type)) { return true; } else { - LOG_ERROR ("Error: Solitaire type is not valid: " << solitaire_type - << "\nValid solitaire types are: "); - copy(begin(sol_rules::valid_sol_strs), end(sol_rules::valid_sol_strs), - ostream_iterator<string>(cerr, ", ")); - cerr << "\n"; + LOG_ERROR ("Error: Solitaire type is not valid: " << solitaire_type); print_help(); return false; } diff --git a/src/main/input-output/sol_preset_types.cpp b/src/main/input-output/sol_preset_types.cpp new file mode 100644 index 0000000..bd98893 --- /dev/null +++ b/src/main/input-output/sol_preset_types.cpp @@ -0,0 +1,152 @@ +// +// Created by thecharlesblake on 11/14/17. +// + +#include "sol_preset_types.h" +using namespace std; + +string sol_preset_types::get(const string& s) { + return mp[s]; +} + +bool sol_preset_types::is_valid_preset(const string& s) { + return mp.count(s) > 0; +} + +std::map<string, string> sol_preset_types::mp = { + { + "default", + + R"( +{ + "tableau piles": { + "count": 8, + "build order": "descending", + "build policy": "any-suit" + }, + "max rank": 13, + "hole": false, + "foundations": true, + "cells": 0, + "reserve size": 0, + "stock size": 0 +} +)" + + }, + { + "black-hole", + + R"( +{ + "tableau piles": { + "count": 17, + "build order": "no-build" + }, + "hole": true, + "foundations": false +} +)" + + }, + { + "simple-black-hole", + + R"( +{ + "tableau piles": { + "count": 9, + "build order": "no-build" + }, + "max rank": 7, + "hole": true, + "foundations": false +} +)" + + }, + { + "spanish-patience", + + R"( +{ + "tableau piles": { + "count": 13 + } +} +)" + + }, + { + "simple-spanish-patience", + + R"( +{ + "tableau piles": { + "count": 5 + }, + "max rank": 5 +} +)" + + }, + { + "free-cell", + + R"( +{ + "tableau piles": { + "build policy": "red-black" + }, + "cells": 4 +} +)" + + }, + { + "simple-free-cell", + + R"( +{ + "tableau piles": { + "count": 3, + "build policy": "red-black" + }, + "max rank": 3, + "cells": 1 +} +)" + + }, + { + "canfield", + + R"( +{ + "tableau piles": { + "count": 4, + "build policy": "red-black" + }, + "reserve size": 14, + "stock size": 34 +} +)" + + }, + { + "simple-canfield", + + R"( +{ + "tableau piles": { + "count": 2, + "build policy": "red-black" + }, + "max rank": 2, + "reserve size": 2, + "stock size": 2 +} +)" + + } +};
\ No newline at end of file |
