Brunot
Loading...
Searching...
No Matches
Deck.h
Go to the documentation of this file.
1
11// ____ __ __ __
12// /\__ _\/\ \ /\ \/\ \
13// \/_/\ \/\ \ \___ __ \ \ \_\ \ ___ __ __ ____ __
14// \ \ \ \ \ _ `\ /'__`\ \ \ _ \ / __`\/\ \/\ \ /',__\ /'__`\
15// \ \ \ \ \ \ \ \/\ __/ \ \ \ \ \/\ \L\ \ \ \_\ \/\__, `\/\ __/
16// \ \_\ \ \_\ \_\ \____\ \ \_\ \_\ \____/\ \____/\/\____/\ \____\
17// \/_/ \/_/\/_/\/____/ \/_/\/_/\/___/ \/___/ \/___/ \/____/
18
19
20#pragma once
21#include "Framework/Component.h"
22
23enum class cardSuit : char;
24class Card;
25
30class Deck : public Component
31{
32public:
33#pragma region static_functions
34 static auto bindLuaTypes(sol::state& lua) -> void;
35 static auto getEnum() -> ComponentTypeEnum
36 {
37 return cDeck;
38 }
39
40#pragma endregion
41
42 Deck();
43 Deck(const Deck&);
44 auto operator=(const Deck&) -> Deck&;
45 ~Deck() override = default;
46 Deck(Deck&& other) noexcept = default;
47 auto operator=(Deck&& other) noexcept -> Deck& = default;
48
49#pragma region overriden_functions
50
51 auto clone() const -> std::unique_ptr<GameObject> override
52 {
53 return std::make_unique<Deck>(*this);
54 }
55
56 auto componentShowMenu() -> void override
57 {
58 } // for debug ImGUI
59 auto onUpdate(float dt) -> void override;
60
61 auto endWindow() -> void override
62 {
63 } // for debug ImGUI
64 auto onRender() -> void override;
65 auto load(const Stream& stream) -> void override;
66 auto save(Stream& stream) const -> void override;
67
68 friend auto to_json(json& j, const Deck& d) -> void;
69 friend auto from_json(const json& j, Deck& d) -> void;
70
71
72#pragma endregion
73
74#pragma region Deck_functions
75
76 auto size() const -> int;
77 auto isEmpty() const -> bool;
78 auto shuffleDeck() -> void;
79 auto drawCardFromDeck() -> std::unique_ptr<Card>;
80
86 auto drawSetFromDeck(int numberOfCards) -> std::vector<std::unique_ptr<Card>>;
87
91 auto remakeDeck() -> void;
92
93#pragma endregion
94
95#pragma region messaging_functions
96#pragma endregion
97
98private:
99#pragma region member_variables
100
108 std::vector<std::unique_ptr<Card>> deck;
109
110
111#pragma endregion
112
113#pragma region helper_functions
114
119 auto cloneDeck(const std::vector<std::unique_ptr<Card>>& otherDeck) -> void;
120
121#pragma endregion
122
123#pragma region static_variables
124
125#pragma endregion
126
127};
sys::Json Stream
Definition AudioObject.h:20
cardSuit
Definition Card.h:25
The base class for components, holding all of their shared All components should inherit from this.
nlohmann::json json
Definition Json.cpp:19
Definition Card.h:34
ComponentTypeEnum
This enum lists out every type of component we have.
Definition Component.h:39
Component(ComponentTypeEnum type, const char *typeName)
Definition Component.cpp:72
Component that represents a deck of playing cards.
Definition Deck.h:31
auto remakeDeck() -> void
Resets the deck to the standard 52 cards.
Definition Deck.cpp:153
friend auto from_json(const json &j, Deck &d) -> void
Definition Deck.cpp:95
auto isEmpty() const -> bool
Definition Deck.cpp:109
auto componentShowMenu() -> void override
Definition Deck.h:56
static auto getEnum() -> ComponentTypeEnum
Definition Deck.h:35
auto drawCardFromDeck() -> std::unique_ptr< Card >
Definition Deck.cpp:129
std::vector< std::unique_ptr< Card > > deck
The actual storage of the cards that exist inside a deck.
Definition Deck.h:108
auto endWindow() -> void override
currently unused, but intended to but was assumed to be necessary for a proper ImGui editor
Definition Deck.h:61
auto drawSetFromDeck(int numberOfCards) -> std::vector< std::unique_ptr< Card > >
Draws multiple cards from the deck.
Definition Deck.cpp:137
auto size() const -> int
Definition Deck.cpp:103
Deck()
Definition Deck.cpp:46
Deck(Deck &&other) noexcept=default
auto clone() const -> std::unique_ptr< GameObject > override
makes a copy a GameObject even if it's held polymorphically
Definition Deck.h:51
static auto bindLuaTypes(sol::state &lua) -> void
Definition Deck.cpp:33
auto onRender() -> void override
called every frame after update has been called for every object.
Definition Deck.cpp:74
auto save(Stream &stream) const -> void override
Implementations will load the state of a GameObject to a th::Json object.
Definition Deck.cpp:83
auto onUpdate(float dt) -> void override
called once every frame.
Definition Deck.cpp:69
auto load(const Stream &stream) -> void override
Implementations will load the state of a GameObject from a th::Json Object.
Definition Deck.cpp:78
auto operator=(const Deck &) -> Deck &
Definition Deck.cpp:58
auto operator=(Deck &&other) noexcept -> Deck &=default
friend auto to_json(json &j, const Deck &d) -> void
Definition Deck.cpp:88
auto shuffleDeck() -> void
Definition Deck.cpp:118
auto cloneDeck(const std::vector< std::unique_ptr< Card > > &otherDeck) -> void
Duplicates all the elements in another deck into this one.
Definition Deck.cpp:166
~Deck() override=default
GameObject(std::string typeName, gobj::Type parentType, gobj::Type type)
constructor for gameobject.
Definition GameObject.cpp:24