aboutsummaryrefslogtreecommitdiff
path: root/src/main/game/game_state.h
diff options
context:
space:
mode:
authorCharlie Blake2017-11-13 09:52:23 +0000
committerGitHub2017-11-13 09:52:23 +0000
commit96f9d446750e07c039ce5d482c92c464593c5bc9 (patch)
tree5731e7eee2c041166479585daab804bc6d8e445c /src/main/game/game_state.h
parentMerge pull request #19 from thecharlesblake/canfield (diff)
parentRefactor solver (diff)
downloadmetasol-96f9d446750e07c039ce5d482c92c464593c5bc9.tar.gz
metasol-96f9d446750e07c039ce5d482c92c464593c5bc9.zip

Merge pull request #20 from thecharlesblake/initial-code-cleanup

Initial code cleanup

Diffstat (limited to 'src/main/game/game_state.h')
-rw-r--r--src/main/game/game_state.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/main/game/game_state.h b/src/main/game/game_state.h
new file mode 100644
index 0000000..12dcda9
--- /dev/null
+++ b/src/main/game/game_state.h
@@ -0,0 +1,56 @@
+//
+// Created by thecharlesblake on 10/24/17.
+//
+
+#ifndef SOLVITAIRE_GAME_STATE_H
+#define SOLVITAIRE_GAME_STATE_H
+
+#include <vector>
+#include <ostream>
+#include <string>
+
+#include <rapidjson/document.h>
+
+#include "card.h"
+#include "sol_rules.h"
+#include "pile.h"
+
+class game_state {
+public:
+ // Create a game state representation from a JSON doc
+ game_state(const rapidjson::Document&);
+ // Do the same from a 'rules' object
+ game_state(int seed, const sol_rules&);
+
+ const std::vector<game_state> get_next_legal_states() const;
+ bool is_solved() const;
+
+ std::ostream& print(std::ostream&) const;
+
+ friend bool operator==(const game_state&, const game_state&);
+ friend std::ostream& operator<< (std::ostream&, const game_state&);
+
+private:
+ static std::vector<card> shuffled_deck(int, int);
+
+ const game_state move(game_state&, pile*, pile*) const;
+ std::vector<pile*> get_regular_pile_refs();
+
+ void print_header(std::ostream&, const char*) const;
+ void print_piles(std::ostream&, const std::vector<pile>&) const;
+ void print_pile(std::ostream&, const pile&) const;
+ void print_top_of_piles(std::ostream&, const std::vector<pile>&) const;
+ void print_top_of_pile(std::ostream&, const pile&) const;
+
+ std::vector<pile> foundations;
+ std::vector<pile> cells;
+ std::vector<pile> tableau_piles;
+ pile reserve;
+ pile stock;
+ pile waste;
+ pile hole;
+ sol_rules rules;
+};
+
+
+#endif //SOLVITAIRE_GAME_STATE_H