diff options
| author | thecharlesblake | 2018-01-12 16:31:38 +0000 |
|---|---|---|
| committer | thecharlesblake | 2018-01-12 16:31:38 +0000 |
| commit | 9ea820ab371c7e1c033ab912317ba6096db87caa (patch) | |
| tree | 735a13b877e7a66c597485a499a5814be841773f /src/main | |
| parent | Add basic global_cache interface (diff) | |
| download | metasol-9ea820ab371c7e1c033ab912317ba6096db87caa.tar.gz metasol-9ea820ab371c7e1c033ab912317ba6096db87caa.zip | |
Add unit tests for global cache
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/game/card.cpp | 6 | ||||
| -rw-r--r-- | src/main/game/pile.cpp | 2 | ||||
| -rw-r--r-- | src/main/game/pile.h | 1 | ||||
| -rw-r--r-- | src/main/game/sol_rules.cpp | 29 | ||||
| -rw-r--r-- | src/main/game/sol_rules.h | 2 |
5 files changed, 37 insertions, 3 deletions
diff --git a/src/main/game/card.cpp b/src/main/game/card.cpp index 80ebef6..2f4cc08 100644 --- a/src/main/game/card.cpp +++ b/src/main/game/card.cpp @@ -77,9 +77,9 @@ bool operator!=(const card& l, const card& r) { size_t hash_value(card const& c) { boost::hash<unsigned char> hasher; - auto raw_val = static_cast<unsigned char>( - static_cast<std::underlying_type_t<card::suit_t>>(c.get_suit()) - * 13 + c.get_rank()); + + auto suit_val = static_cast<std::underlying_type_t<card::suit_t>>(c.get_suit()); + auto raw_val = static_cast<unsigned char>(suit_val * 13 + c.get_rank()); return hasher(raw_val); }
\ No newline at end of file diff --git a/src/main/game/pile.cpp b/src/main/game/pile.cpp index 82ae344..ad7b85e 100644 --- a/src/main/game/pile.cpp +++ b/src/main/game/pile.cpp @@ -12,6 +12,8 @@ using namespace std; using namespace boost; +pile::pile(std::vector<card> pv) : pile_vec(pv) {} + card pile::top_card() const { assert(!empty()); return pile_vec.back(); diff --git a/src/main/game/pile.h b/src/main/game/pile.h index f2600fe..fb7bc38 100644 --- a/src/main/game/pile.h +++ b/src/main/game/pile.h @@ -13,6 +13,7 @@ class pile { public: + pile(std::vector<card>); typedef uint8_t size_type; // Inspect diff --git a/src/main/game/sol_rules.cpp b/src/main/game/sol_rules.cpp new file mode 100644 index 0000000..6c16b4a --- /dev/null +++ b/src/main/game/sol_rules.cpp @@ -0,0 +1,29 @@ +// +// Created by thecharlesblake on 1/12/18. +// + +#include "sol_rules.h" + +typedef sol_rules::build_policy pol; +typedef sol_rules::spaces_policy s_pol; +typedef sol_rules::stock_deal_type sdt; + +// Note that the 'default' sol rules are set up by parsing the default json +// rules description. This initialisation is really just for testing purposes. +sol_rules::sol_rules() : + tableau_pile_count(0), + build_pol(pol::ANY_SUIT), + spaces_pol(s_pol::ANY), + move_built_group(false), + two_decks(false), + max_rank(13), + hole(false), + foundations(true), + foundations_init_card(false), + diagonal_deal(false), + cells(0), + stock_size(0), + stock_deal_t(sdt::WASTE), + reserve_size(0), + reserve_stacked(false) { +} diff --git a/src/main/game/sol_rules.h b/src/main/game/sol_rules.h index 812e82c..8aae42b 100644 --- a/src/main/game/sol_rules.h +++ b/src/main/game/sol_rules.h @@ -12,6 +12,8 @@ #include "card.h" struct sol_rules { + sol_rules(); + // Tableau policies enum class build_policy { NO_BUILD, |
