aboutsummaryrefslogtreecommitdiff
path: root/src/main/game
diff options
context:
space:
mode:
authorCharlie Blake2018-04-04 16:02:31 +0100
committerGitHub2018-04-04 16:02:31 +0100
commit9bdacbca71f402507ba2a09929a9cadeaadcfdd0 (patch)
tree2f6a6473993d6df448f16253950f03c9f5c5031b /src/main/game
parentMerge pull request #47 from thecharlesblake/re-add-schema (diff)
parentAdd legal move gen tests and refactor (diff)
downloadmetasol-9bdacbca71f402507ba2a09929a9cadeaadcfdd0.tar.gz
metasol-9bdacbca71f402507ba2a09929a9cadeaadcfdd0.zip

Merge pull request #48 from thecharlesblake/wider-testing

Wider testing

Diffstat (limited to 'src/main/game')
-rw-r--r--src/main/game/game_state.h3
-rw-r--r--src/main/game/game_state.legal_moves.cpp12
-rw-r--r--src/main/game/pile.cpp4
-rw-r--r--src/main/game/pile.h4
4 files changed, 19 insertions, 4 deletions
diff --git a/src/main/game/game_state.h b/src/main/game/game_state.h
index 409fee9..a49db2c 100644
--- a/src/main/game/game_state.h
+++ b/src/main/game/game_state.h
@@ -30,6 +30,7 @@ public:
struct move {
move(pile_ref, pile_ref, pile::size_type = 1);
bool is_dominance() const;
+ friend bool operator==(const move&, const move&);
const static pile::size_type dominance_flag;
pile_ref from; pile_ref to; pile::size_type count;
@@ -51,7 +52,7 @@ public:
std::vector<move> get_legal_moves(
#ifndef NO_CARD_JUST_MOVED
- move
+ move = move(255, 255, 255)
#endif
);
diff --git a/src/main/game/game_state.legal_moves.cpp b/src/main/game/game_state.legal_moves.cpp
index f0502d1..c137b07 100644
--- a/src/main/game/game_state.legal_moves.cpp
+++ b/src/main/game/game_state.legal_moves.cpp
@@ -22,8 +22,10 @@ vector<game_state::move> game_state::get_legal_moves(
vector<move> moves;
// If we have a stock that can deal to the tableau piles, adds this move
- if (rules.stock_deal_t == sdt::TABLEAU_PILES && !piles[stock].empty()) {
- // Only does this if all the tableau piles are empty
+ if (rules.stock_size > 0
+ && rules.stock_deal_t == sdt::TABLEAU_PILES
+ && !piles[stock].empty()) {
+ // Only does this if none of the tableau piles are empty
bool no_tableau_empty = true;
for (auto tab_ref : tableau_piles) {
if (piles[tab_ref].empty()) {
@@ -394,3 +396,9 @@ bool game_state::dominance_blocks_foundation_move(pile_ref target_pile) {
return blocked;
}
+
+bool operator==(const game_state::move& a, const game_state::move& b) {
+ return (a.from == b.from )
+ && (a.to == b.to )
+ && (a.count == b.count);
+}
diff --git a/src/main/game/pile.cpp b/src/main/game/pile.cpp
index 382fa50..3136681 100644
--- a/src/main/game/pile.cpp
+++ b/src/main/game/pile.cpp
@@ -53,6 +53,10 @@ bool operator==(const pile& a, const pile& b) {
return a.pile_vec == b.pile_vec;
}
+bool operator!=(const pile& a, const pile& b) {
+ return a.pile_vec != b.pile_vec;
+}
+
bool operator<(const pile& a, const pile& b) {
if (a.size() == b.size()) {
return a.pile_vec < b.pile_vec;
diff --git a/src/main/game/pile.h b/src/main/game/pile.h
index 654f5be..d86ea37 100644
--- a/src/main/game/pile.h
+++ b/src/main/game/pile.h
@@ -33,15 +33,17 @@ public:
card operator[] (size_type) const;
friend bool operator==(const pile&, const pile&);
+ friend bool operator!=(const pile&, const pile&);
friend bool operator<(const pile&, const pile&);
friend bool operator>(const pile&, const pile&);
friend bool operator<=(const pile&, const pile&);
friend bool operator>=(const pile&, const pile&);
-private:
+
// Modify
void place(card);
card take();
+private:
// Underlying vector
std::vector<card> pile_vec;
};