Brunot
Loading...
Searching...
No Matches
Player Class Reference

The component responsible for storing information relevant to the player. More...

#include <Player.h>

Inheritance diagram for Player:
[legend]
Collaboration diagram for Player:
[legend]

Public Member Functions

 Player ()
 Player (const Player &other)=default
 Player (Player &&other) noexcept=default
 ~Player () override=default
auto operator= (const Player &other) -> Player &=default
auto operator= (Player &&other) -> Player &=default
auto clone () const -> std::unique_ptr< GameObject > override
 makes a copy a GameObject even if it's held polymorphically
auto onUpdate (float dt) -> void override
 called once every frame.
auto onRender () -> void override
 called every frame after update has been called for every object.
auto componentShowMenu () -> void override
auto onEnterEngine () -> void override
 hook that is called when a GameObject enters the Engine tree.
auto endWindow () -> void override
 currently unused, but intended to but was assumed to be necessary for a proper ImGui editor
auto load (const Stream &stream) -> void override
 Implementations will load the state of a GameObject from a th::Json Object.
auto save (Stream &stream) const -> void override
 Implementations will load the state of a GameObject to a th::Json object.
auto addCardToHand (std::unique_ptr< Card > drawnCard) -> Entity *
 Creates a card entity and adds it to the hand, but does not visually move it You would want to use this if you're going to add your own actions to the card.
auto moveCardToHand (std::unique_ptr< Card > drawnCard) -> void
 Creates a card entity and adds it to the hand.
auto fillHand (Deck *deck, float drawDuration, float initialDelay) -> void
 Draws cards from the deck until the hand is full or until the deck is empty.
auto drawCardToHand (Deck *deck, float drawDuration) -> void
 Draws a single card from the deck and adds it to the hand.
auto getNumberOfCardsInHand () const -> int
 Returns the number of cards the player is holding.
auto clearHand () -> void
 Gets rid of all the cards in the players hand.
auto decrementNumberOfCards () -> void
 Public function so Table can tell the player when they lose a card.
auto hasCards () const -> bool
 Returns if the player has any cards in their hand or not.
auto getMaxCards () const -> int
 Returns the max number cards the player can hold in their hand.
auto getFirstCard () -> Entity *
 Returns the first card Entity in the players hand.
auto getLastCard () -> Entity *
 Returns the first card Entity in the players hand.
Public Member Functions inherited from Component
auto getType () const -> ComponentTypeEnum
auto getKey () const -> Key override
 Generates a unique Key that corresponds to the GameObject.
auto showMenu () -> void override
 Called before update each frame, for calling ImGui editor code relevant to the gameObject.
auto getEntityParent () const -> Entity *
 gets the parent as an Entity.
auto pop () const -> std::unique_ptr< Component >
 Removes the Component from its Entity parent, and gives ownership to the caller.
Public Member Functions inherited from GameObject
 GameObject (std::string typeName, gobj::Type parentType, gobj::Type type)
 constructor for gameobject.
virtual ~GameObject ()
 destructor for GameObject.
 GameObject (const GameObject &other)
 Copy Constructor.
auto operator= (const GameObject &other) -> GameObject &
 copy assignment operator
 GameObject (GameObject &&other) noexcept
 Move constructor.
auto operator= (GameObject &&other) noexcept -> GameObject &
 Move assignment operator.
virtual auto update (float dt) -> void
 called once every frame.
virtual auto render () -> void
 called every frame after update has been called for every object.
virtual auto destroy () -> void
 Marks an GameObject to be destroyed.
virtual auto onSceneStart (const std::string &sceneName) -> void
 Hook that is called before the first frame a scene is run, but after the entire scene is loaded into the engine To receive the hook, simply override the function in your class.
virtual auto onSceneExit (const std::string &sceneName) -> void
 Hook that is called right before a scene is unloaded To receive the hook, simply override the function in your class.
virtual auto for_each (std::function< void(GameObject &)> func) -> void
 applies a function to every child.
virtual auto for_each (std::function< void(const GameObject &)> func) const -> void
 applies a const function to every child.
virtual auto getParent () const -> GameObject *
 Gets the parent of a GameObject.
virtual auto parentTo (GameObject *newParent) -> bool
 Sets the GameObject as a child of another GameObject.
auto getInternalParent () const -> GameObject *
 returns the actual owning parent of the GameObject
virtual auto addChild (std::unique_ptr< GameObject > newChild) -> bool
 Adds a child to a GameObject.
auto addChildLua (std::unique_ptr< GameObject > &newChild) -> bool
 for lua
auto destroyed () const -> bool
auto getUUID () const -> gobj::UUID
auto coolerGetUUID () const -> unsigned int
auto isUUID (gobj::UUID compareUUID) const -> bool
auto getName () const -> const std::string &
 Gets the type of the object as a string.
auto getNickname () const -> const std::string &
 Gets the nickname (custom, writable name) of a GameObject.
auto getFormattedName () const -> const std::string &
 combines a GameObjects Type, Nickname, and UUID into one string, for use with logging.
auto nameEquals (const std::string &compareString) const -> bool
 check whether a GameObjects typeName is equivilent to a given string.
auto isType (gobj::Type otherType) const -> bool
 check whether the GameObject is the same as a given type.
auto getObjectType () const -> gobj::Type
 gets the internal type of the GameObject, as an enum
auto setNickname (const std::string &newNickname) -> void
 sets the GameObjects nickname.
auto updates () const -> bool
auto renders () const -> bool
auto receivesMessages () const -> bool
auto isActive () const -> bool
virtual auto setShouldUpdate (bool _shouldUpdate) -> void
 set whether the GameObject should update every frame, and whether all of it's children should update every frame
virtual auto setShouldRender (bool _shouldRender) -> void
 set whether the GameObject should render every frame, and whether all of it's children should render every frame
virtual auto setShouldReceiveMessages (bool _shouldReceiveMessages) -> void
 set whether the GameObject should Receive Messags, and whether all of it's children should receive messages
auto setActive (bool shouldBeActive) -> void
 set the GameObject should update, render, and receive messages
auto getGameObjectJson () const -> json
 Used for serializing GameObjects.
auto setGameObjectJson (const json &stream) -> void
 used for deserializing GameObjects

Static Public Member Functions

static auto bindLuaTypes (sol::state &lua) -> void
static auto getEnum () -> ComponentTypeEnum

Private Member Functions

auto createCardToMenu (std::unique_ptr< Card > cardToAdd) -> Entity *
 Actually handles the logic of adding a card to the player's hand.
auto addCardLua (std::unique_ptr< Card > &drawnCard) -> void
 wrapper around addCard so that it can be bound to lua

Private Attributes

int numberOfCardsInHand
 The number of cards the player is holding.
int maxNumberOfCards
 The maximum number of cards the player can hold.

Friends

auto to_json (json &j, const Player &p) ->void
auto from_json (const json &j, Player &p) ->void

Additional Inherited Members

Public Types inherited from Component
enum  ComponentTypeEnum : unsigned short { cErrorType = 0 , cNewComponentStub = 1 }
 This enum lists out every type of component we have. More...
Public Attributes inherited from GameObject
friend Entity
friend Node
friend Engine
Protected Member Functions inherited from Component
 Component (ComponentTypeEnum type, const char *typeName)
auto getComponentJson () const -> json
auto getChildren () const -> std::shared_ptr< std::vector< GameObject * > > override
 override for component to return a vector of no children
Protected Member Functions inherited from GameObject
auto setInternalParent (GameObject *parent) -> bool
 sets the internal parent of a GameObject directly, avoiding abstractions provided by ParentTo().
auto checkAddToSceneHook () -> void
 Determine if the GameObject was recently added to the engine, and if it was, call onEngineEnter.

Detailed Description

The component responsible for storing information relevant to the player.

@Player.h

Constructor & Destructor Documentation

◆ Player() [1/3]

Player::Player ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Player() [2/3]

Player::Player ( const Player & other)
default
Here is the call graph for this function:

◆ Player() [3/3]

Player::Player ( Player && other)
defaultnoexcept
Here is the call graph for this function:

◆ ~Player()

Player::~Player ( )
overridedefault

Member Function Documentation

◆ addCardLua()

auto Player::addCardLua ( std::unique_ptr< Card > & drawnCard) ->void
private

wrapper around addCard so that it can be bound to lua

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addCardToHand()

auto Player::addCardToHand ( std::unique_ptr< Card > drawnCard) ->Entity *

Creates a card entity and adds it to the hand, but does not visually move it You would want to use this if you're going to add your own actions to the card.

Parameters
drawnCardThe card that you want to be added to the players hand
Returns
The card that was created
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bindLuaTypes()

auto Player::bindLuaTypes ( sol::state & lua) ->void
static
Here is the call graph for this function:

◆ clearHand()

auto Player::clearHand ( ) ->void

Gets rid of all the cards in the players hand.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clone()

auto Player::clone ( ) const->std::unique_ptr< GameObject >
overridevirtual

makes a copy a GameObject even if it's held polymorphically

Warning
When overriding this function, make sure to set the parents object to this
Returns
a unique_ptr to a new stack allocated object that is a copy of the object

Implements GameObject.

Here is the call graph for this function:

◆ componentShowMenu()

auto Player::componentShowMenu ( ) ->void
overridevirtual

Reimplemented from Component.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createCardToMenu()

auto Player::createCardToMenu ( std::unique_ptr< Card > cardToAdd) ->Entity *
private

Actually handles the logic of adding a card to the player's hand.

Parameters
cardToAddThe card to be added to the hand
Returns
The entity that was created
Here is the call graph for this function:
Here is the caller graph for this function:

◆ decrementNumberOfCards()

auto Player::decrementNumberOfCards ( ) ->void

Public function so Table can tell the player when they lose a card.

Here is the caller graph for this function:

◆ drawCardToHand()

auto Player::drawCardToHand ( Deck * deck,
float drawDuration )->void

Draws a single card from the deck and adds it to the hand.

Basically just fillHand but on one card

Parameters
deckThe deck to draw from
drawDurationHow long the cards take travelling from the deck to the hand
Here is the call graph for this function:

◆ endWindow()

auto Player::endWindow ( ) ->void
inlineoverridevirtual

currently unused, but intended to but was assumed to be necessary for a proper ImGui editor

Implements GameObject.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fillHand()

auto Player::fillHand ( Deck * deck,
float drawDuration,
float initialDelay )->void

Draws cards from the deck until the hand is full or until the deck is empty.

Then, makes actions to visually move the cards from the deck to the players hand

Parameters
deckThe deck you want to draw cards from
drawDurationHow long you want the cards to take traveling from the deck to the hand
initialDelayDelays the initial draw animation
Here is the call graph for this function:

◆ getEnum()

auto Player::getEnum ( ) ->ComponentTypeEnum
inlinestatic

◆ getFirstCard()

auto Player::getFirstCard ( ) ->Entity *

Returns the first card Entity in the players hand.

◆ getLastCard()

auto Player::getLastCard ( ) ->Entity *

Returns the first card Entity in the players hand.

◆ getMaxCards()

auto Player::getMaxCards ( ) const->int

Returns the max number cards the player can hold in their hand.

◆ getNumberOfCardsInHand()

auto Player::getNumberOfCardsInHand ( ) const->int

Returns the number of cards the player is holding.

Here is the caller graph for this function:

◆ hasCards()

auto Player::hasCards ( ) const->bool

Returns if the player has any cards in their hand or not.

Here is the caller graph for this function:

◆ load()

auto Player::load ( const Stream & stream) ->void
overridevirtual

Implementations will load the state of a GameObject from a th::Json Object.

Unimplemented in GameObject

Parameters
streamth::Json Object

Implements GameObject.

◆ moveCardToHand()

auto Player::moveCardToHand ( std::unique_ptr< Card > drawnCard) ->void

Creates a card entity and adds it to the hand.

Then, makes an action to visually move the card from its old position to its new one You want to call this one if you are adding a card that exists in the game world to the players hand

Warning
Should only be called on cards that already exist in the game world
Parameters
drawnCardThe card you want to add
Here is the call graph for this function:

◆ onEnterEngine()

void Player::onEnterEngine ( ) ->void
overridevirtual

hook that is called when a GameObject enters the Engine tree.

The hook is called immediately after a GameObject's parent is called. Functionality may not be correct if an object was removed from the engine then re-added. To receive the hook, simply override the function in your class

Reimplemented from GameObject.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onRender()

auto Player::onRender ( ) ->void
overridevirtual

called every frame after update has been called for every object.

Generally used for rendering an object to the screen, when applicable. Unimplemented in GameObject

Implements GameObject.

Here is the caller graph for this function:

◆ onUpdate()

auto Player::onUpdate ( float dt) ->void
overridevirtual

called once every frame.

Generally used for timers, movement, condition checks, etc. Unimplemented in GameObject

Parameters
dtthe time in seconds that has elapsed

Implements GameObject.

Here is the caller graph for this function:

◆ operator=() [1/2]

auto Player::operator= ( const Player & other) ->Player &=default
default
Here is the call graph for this function:

◆ operator=() [2/2]

auto Player::operator= ( Player && other) ->Player &=default
default
Here is the call graph for this function:

◆ save()

auto Player::save ( Stream & stream) const->void
overridevirtual

Implementations will load the state of a GameObject to a th::Json object.

Unimplemented in GameObject

Parameters
streamth::Json Object

Implements GameObject.

◆ from_json

auto from_json ( const json & j,
Player & p )->void
friend

◆ to_json

auto to_json ( json & j,
const Player & p )->void
friend

Member Data Documentation

◆ maxNumberOfCards

int Player::maxNumberOfCards
private

The maximum number of cards the player can hold.

◆ numberOfCardsInHand

int Player::numberOfCardsInHand
private

The number of cards the player is holding.


The documentation for this class was generated from the following files:
  • /home/egrazil/sites/Brunot/The House/source/Component/Player.h
  • /home/egrazil/sites/Brunot/The House/source/Component/Player.cpp