Brunot
Loading...
Searching...
No Matches
Deck.h
Go to the documentation of this file.
1
12// ____ __ __ __
13// /\__ _\/\ \ /\ \/\ \
14// \/_/\ \/\ \ \___ __ \ \ \_\ \ ___ __ __ ____ __
15// \ \ \ \ \ _ `\ /'__`\ \ \ _ \ / __`\/\ \/\ \ /',__\ /'__`\
16// \ \ \ \ \ \ \ \/\ __/ \ \ \ \ \/\ \L\ \ \ \_\ \/\__, `\/\ __/
17// \ \_\ \ \_\ \_\ \____\ \ \_\ \_\ \____/\ \____/\/\____/\ \____\
18// \/_/ \/_/\/_/\/____/ \/_/\/_/\/___/ \/___/ \/___/ \/____/
19
20
21#pragma once
22#include "Framework/Component.h"
23
24class Card;
25
30class Deck : public Component
31{
32public:
33#pragma region static_functions
34
35#pragma endregion
36
37 Deck();
38 // If you have messages, you will need to un-default the copy and move constructor and call linkMessages in them
39 Deck(const Deck&);
40 auto operator=(const Deck&) -> Deck& = default;
41 ~Deck() override = default;
42 Deck(Deck&& other) noexcept = default;
43 auto operator=(Deck&& other) noexcept -> Deck& = default;
44
45#pragma region overriden_functions
46
47 auto clone() const -> std::unique_ptr<GameObject> override
48 {
49 return std::make_unique<Deck>(*this);
50 }
51
52 auto componentShowMenu() -> void override
53 {
54 } // for debug ImGUI
55 auto onUpdate(float dt) -> void override;
56
57 auto endWindow() -> void override
58 {
59 } // for debug ImGUI
60 auto onRender() -> void override;
61 auto load(Stream& stream) -> void override;
62 auto save(Stream& stream) const -> void override;
63
64 friend auto to_json(json& j, const Deck& d) -> void;
65 friend auto from_json(const json& j, Deck& d) -> void;
66
67
68#pragma endregion
69
70#pragma region Deck_functions
71
72 auto isEmpty() const -> bool;
73 auto shuffleDeck() -> void;
74 auto drawCardFromDeck() -> std::unique_ptr<Card>;
79 auto remakeDeck() -> void;
80 auto size() const -> int;
81
82#pragma endregion
83
84#pragma region messaging_functions
85#pragma endregion
86
87private:
88#pragma region member_variables
89
90 std::vector<std::unique_ptr<Card>> deck;
91
92
93#pragma endregion
94
95#pragma region helper_functions
96
101 auto cloneDeck(const std::vector<std::unique_ptr<Card>>& otherDeck) -> void;
102
103#pragma endregion
104
105#pragma region static_variables
106
107#pragma endregion
108
109};
sys::Json Stream
Definition AudioObject.h:20
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
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
Refills the deck with the standard 52 cards.
Definition Deck.cpp:106
friend auto from_json(const json &j, Deck &d) -> void
Definition Deck.cpp:73
auto isEmpty() const -> bool
Definition Deck.cpp:81
auto componentShowMenu() -> void override
Definition Deck.h:52
auto drawCardFromDeck() -> std::unique_ptr< Card >
Definition Deck.cpp:98
std::vector< std::unique_ptr< Card > > deck
Definition Deck.h:90
auto endWindow() -> void override
currently unused, but intended to but was assumed to be necessary for a proper ImGui editor
Definition Deck.h:57
auto size() const -> int
Definition Deck.cpp:119
Deck()
Definition Deck.cpp:29
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:47
auto operator=(const Deck &) -> Deck &=default
auto onRender() -> void override
called every frame after update has been called for every object.
Definition Deck.cpp:52
auto load(Stream &stream) -> void override
Implementations will load the state of a GameObject from a th::Json Object.
Definition Deck.cpp:56
auto save(Stream &stream) const -> void override
Implementations will load the state of a GameObject to a th::Json object.
Definition Deck.cpp:61
auto onUpdate(float dt) -> void override
called once every frame.
Definition Deck.cpp:47
auto operator=(Deck &&other) noexcept -> Deck &=default
friend auto to_json(json &j, const Deck &d) -> void
Definition Deck.cpp:66
auto shuffleDeck() -> void
Definition Deck.cpp:90
auto cloneDeck(const std::vector< std::unique_ptr< Card > > &otherDeck) -> void
Duplicates all the elements in another deck into this one.
Definition Deck.cpp:124
~Deck() override=default
GameObject(std::string typeName, gobj::Type parentType, gobj::Type type)
constructor for gameobject.
Definition GameObject.cpp:23