From ed8dda2ff996a76a5a31ac9e760435071e347834 Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Sun, 31 Dec 2017 11:47:27 +0000 Subject: Pile efficient implementation fix --- src/main/game/pile.cpp | 7 ++++++- src/main/game/pile.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src/main') 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 pile_vec; -- cgit v1.2.1