aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorthecharlesblake2017-12-31 11:47:27 +0000
committerthecharlesblake2017-12-31 11:47:27 +0000
commited8dda2ff996a76a5a31ac9e760435071e347834 (patch)
treeb8c646a28a1f49b41ba597cbe65bb13ab2f8cb67 /src/main
parentCard efficient implementation fix (diff)
downloadmetasol-ed8dda2ff996a76a5a31ac9e760435071e347834.tar.gz
metasol-ed8dda2ff996a76a5a31ac9e760435071e347834.zip

Pile efficient implementation fix

Diffstat (limited to 'src/main')
-rw-r--r--src/main/game/pile.cpp7
-rw-r--r--src/main/game/pile.h2
2 files changed, 7 insertions, 2 deletions
diff --git a/src/main/game/pile.cpp b/src/main/game/pile.cpp
index 28eb0a8..641174e 100644
--- a/src/main/game/pile.cpp
+++ b/src/main/game/pile.cpp
@@ -73,14 +73,19 @@ bool pile::can_place(const card c) const {
card top_c = top_card();
- // Check suit
+ // Checks violation of same suit policy
if (build_policy == pol::SAME_SUIT && c.get_suit() != top_c.get_suit()) {
return false;
}
+ // Checks violation of specific suit policy
if (sol_rules::is_suit(build_policy) && c.get_suit()
!= sol_rules::suit_val(build_policy)) {
return false;
}
+ // Checks violation of red-black suit policy
+ if (build_policy == pol::RED_BLACK && c.get_colour() == top_c.get_colour()) {
+ return false;
+ }
int tc_r = top_c.get_rank();
int comp_r = c.get_rank();
diff --git a/src/main/game/pile.h b/src/main/game/pile.h
index 853caf3..978e32e 100644
--- a/src/main/game/pile.h
+++ b/src/main/game/pile.h
@@ -55,8 +55,8 @@ private:
const sol_rules::build_order build_order;
const sol_rules::build_policy build_policy;
const bool removable;
- const int max_rank;
const bool build_order_loops;
+ const int max_rank;
// Underlying vector
std::vector<card> pile_vec;