Worked on c++

This commit is contained in:
Lukas Wölfer
2020-03-20 00:12:32 +01:00
parent de72585989
commit 5af5282aab
8 changed files with 209 additions and 18 deletions

View File

@@ -1,27 +1,35 @@
#pragma once
#include "card.hpp"
#include "goal.hpp"
#include <array>
#include <cassert>
#include <optional>
namespace solitaire {
class Card {
bool isNormalCard();
bool isSpecialCard();
struct BunkerField {
std::optional<Card> card;
bool empty{};
bool closed{};
};
struct BunkerField{
Card card;
bool empty;
bool closed;
inline constexpr int MAX_ROW_SIZE = 13;
inline constexpr int MAX_COLUMN_SIZE = 8;
class Stack {
std::array<std::optional<Card>, MAX_COLUMN_SIZE> values{};
};
class Board {
public:
static constexpr int MAX_ROW_SIZE = 13;
static constexpr int MAX_COLUMN_SIZE = 8;
struct Board {
std::array<Stack, MAX_ROW_SIZE> field{};
std::array<BunkerField, 3> bunker{};
Goal goal{};
bool flower_gone{};
private:
std::array<std::array<Card, MAX_COLUMN_SIZE>, MAX_ROW_SIZE> field;
std::array<BunkerField, 3> bunker;
std::array<std::optional<Card>, 3> goal;
bool flower_gone;
[[nodiscard]] auto solved() const noexcept -> bool;
[[nodiscard]] auto hash() const noexcept -> std::size_t;
[[nodiscard]] auto correct() const noexcept -> bool;
};
} // namespace solitaire

View File

@@ -0,0 +1,15 @@
#pragma once
#include <cassert>
#include <string>
namespace solitaire {
enum class CardType : int { Zhong, Bai, Fa, Hua, Red, Green, Black };
auto isNormalCardType(CardType type) -> bool;
struct Card {
CardType type;
int value;
[[nodiscard]] auto toString() const noexcept -> std::string;
};
} // namespace solitaire

View File

@@ -0,0 +1,20 @@
#pragma once
#include "card.hpp"
#include <array>
#include <optional>
namespace solitaire {
class Goal {
std::array<std::optional<Card>, 3> goal{};
auto getEmptyId() -> std::optional<int>;
public:
[[nodiscard]] auto getId(CardType suit) const noexcept -> std::optional<int>;
[[nodiscard]] auto get(CardType suit) const noexcept -> std::optional<int>;
void set(CardType suit, int value) noexcept;
void inc(CardType suit) noexcept;
};
} // namespace solitaire