Brunot
Loading...
Searching...
No Matches
Player.h
Go to the documentation of this file.
1
12// ____ __ __ __
13// /\__ _\/\ \ /\ \/\ \
14// \/_/\ \/\ \ \___ __ \ \ \_\ \ ___ __ __ ____ __
15// \ \ \ \ \ _ `\ /'__`\ \ \ _ \ / __`\/\ \/\ \ /',__\ /'__`\
16// \ \ \ \ \ \ \ \/\ __/ \ \ \ \ \/\ \L\ \ \ \_\ \/\__, `\/\ __/
17// \ \_\ \ \_\ \_\ \____\ \ \_\ \_\ \____/\ \____/\/\____/\ \____\
18// \/_/ \/_/\/_/\/____/ \/_/\/_/\/___/ \/___/ \/___/ \/____/
19#pragma once
20
21#include "Framework/Component.h"
22#include "Component/Card.h"
23#include "Deck.h"
24#include <vector>
25
30class Player : public Component
31{
32public:
33 Player();
34 Player(const Player& other) = default;
35 Player(Player&& other) noexcept = default;
36 ~Player() override = default;
37
38 auto operator=(const Player& other) -> Player& = default;
39 auto operator=(Player&& other) -> Player& = default;
40
41 auto clone() const -> std::unique_ptr<GameObject> override;
42
43 auto onUpdate(float dt) -> void override;
44 auto onRender() -> void override;
45 auto componentShowMenu() -> void override;
46
47 auto endWindow() -> void override
48 {
49 } // for debug ImGUI
50 auto load(Stream& stream) -> void override;
51 auto save(Stream& stream) const -> void override;
52
53 friend auto to_json(json& j, const Player& p) -> void;
54 friend auto from_json(const json& j, Player& p) -> void;
55
57 auto addCardToHand(std::unique_ptr<Card> drawnCard) -> void;
58
60 auto getNumberOfCardsInHand() const -> int;
61
63 auto clearHand() -> void;
64
66 auto decrementNumberofCards() -> void;
67
69 auto hasCards() const -> bool;
70
71private:
73 auto createCardToMenu(std::unique_ptr<Card> drawnCard) -> void;
74
77
78};
sys::Json Stream
Definition AudioObject.h:20
The card component that is moved around on the board.
The base class for components, holding all of their shared All components should inherit from this.
Component that represents a deck of playing cards.
nlohmann::json json
Definition Json.cpp:19
Definition Card.h:34
Component(ComponentTypeEnum type, const char *typeName)
Definition Component.cpp:72
GameObject(std::string typeName, gobj::Type parentType, gobj::Type type)
constructor for gameobject.
Definition GameObject.cpp:23
The component responsible for storing information relevant to the player.
Definition Player.h:31
~Player() override=default
auto load(Stream &stream) -> void override
Implementations will load the state of a GameObject from a th::Json Object.
Definition Player.cpp:63
auto componentShowMenu() -> void override
Definition Player.cpp:88
auto hasCards() const -> bool
Returns if the player has any cards in their hand or not.
Definition Player.cpp:133
auto onRender() -> void override
called every frame after update has been called for every object.
Definition Player.cpp:59
auto addCardToHand(std::unique_ptr< Card > drawnCard) -> void
Creates a card entity and adds it to the hand.
Definition Player.cpp:99
auto decrementNumberofCards() -> void
Public function so Table can tell the player when they lose a card.
Definition Player.cpp:128
auto createCardToMenu(std::unique_ptr< Card > drawnCard) -> void
Actually handles the logic of creating a playing card Entity and adding it to the hand.
Definition Player.cpp:138
auto operator=(const Player &other) -> Player &=default
auto getNumberOfCardsInHand() const -> int
Returns the number of cards the player is holding.
Definition Player.cpp:105
auto endWindow() -> void override
currently unused, but intended to but was assumed to be necessary for a proper ImGui editor
Definition Player.h:47
Player(const Player &other)=default
auto clearHand() -> void
Gets rid of all the cards in the players hand.
Definition Player.cpp:110
int numberOfCardsInHand
The number of cards the player is holding.
Definition Player.h:76
auto onUpdate(float dt) -> void override
called once every frame.
Definition Player.cpp:55
friend auto to_json(json &j, const Player &p) -> void
Definition Player.cpp:74
Player(Player &&other) noexcept=default
auto operator=(Player &&other) -> Player &=default
auto save(Stream &stream) const -> void override
Implementations will load the state of a GameObject to a th::Json object.
Definition Player.cpp:68
friend auto from_json(const json &j, Player &p) -> void
Definition Player.cpp:82
auto clone() const -> std::unique_ptr< GameObject > override
makes a copy a GameObject even if it's held polymorphically
Definition Player.cpp:50
Player()
Definition Player.cpp:41