aboutsummaryrefslogtreecommitdiff
path: root/src/main/game/sol_rules.h
blob: a2f8fe926f46824e64610bbd5d11d4e78aa24c9b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//
// Created by thecharlesblake on 10/28/17.
//

#ifndef SOLVITAIRE_SOL_RULES_H
#define SOLVITAIRE_SOL_RULES_H

#include <vector>
#include <string>

#include <boost/optional.hpp>
#include <rapidjson/document.h>

#include "card.h"

class sol_rules {
public:
    enum class valid_sol {
        BLACK_HOLE,
        SIMPLE_BLACK_HOLE,
        SPANISH_PATIENCE,
        SIMPLE_SPANISH_PATIENCE,
        FREE_CELL,
        SIMPLE_FREE_CELL,
        CANFIELD,
        SIMPLE_CANFIELD
    };
    enum class build_order {
        NO_BUILD,
        DESCENDING,
        ASCENDING,
        BOTH,
        SINGLE_CARD,
        ANY
    };
    enum class build_policy {
        CLUBS,
        DIAMONDS,
        HEARTS,
        SPADES,
        ANY_SUIT,
        SAME_SUIT,
        RED_BLACK,
        N_A
    };

    static bool is_suit(build_policy);
    static card::suit_t suit_val(build_policy);

    static const sol_rules from_preset(const std::string);
    static const sol_rules from_file(const std::string);

    uint8_t tableau_pile_count;
    build_order build_ord;
    build_policy build_pol;
    card::rank_t max_rank;
    bool hole;
    bool foundations;
    uint8_t cells;
    uint8_t reserve_size;
    uint8_t stock_size;

private:
    static sol_rules get_default();
    static void modify_sol_rules(sol_rules&, rapidjson::Document&);
    static void parse_err(const std::string&);

    static valid_sol valid_sol_enum(const std::string&);
};

#endif //SOLVITAIRE_SOL_RULES_H