Peoplemon  0.1.0
Peoplemon 3 game source documentation
Public Member Functions | Static Public Attributes | Friends | List of all members
core::player::StorageSystem Class Reference

Peoplemon storage system for extra peoplemon the player has. More...

#include <StorageSystem.hpp>

Public Member Functions

 StorageSystem ()
 Construct a new Storage System. More...
 
bool add (const pplmn::OwnedPeoplemon &ppl)
 Adds the given peoplemon to storage in a free slot. More...
 
void add (unsigned int box, const sf::Vector2i &pos, const pplmn::OwnedPeoplemon &ppl)
 Adds the peoplemon to storage at the given position. Does not check if the position is available, the caller must ensure that it is free. More...
 
void remove (unsigned int box, const sf::Vector2i &position)
 Clears the peoplemon from the given position, if one is there. More...
 
pplmn::StoredPeoplemonmove (pplmn::StoredPeoplemon &ppl, unsigned int newBox, const sf::Vector2i &newPos)
 Moves the given stored peoplemon from its current location to the new location. More...
 
bool spaceFree (int box, int x, int y) const
 Returns whether or not the given storage space is free. More...
 
pplmn::StoredPeoplemonget (unsigned int box, const sf::Vector2i &pos)
 Returns the peoplemon at the given position in the given box. More...
 
const std::vector< pplmn::StoredPeoplemon > & getBox (unsigned int box) const
 Returns the given box. Performs no bounds check. More...
 

Static Public Attributes

static constexpr int BoxCount = 14
 
static constexpr int BoxWidth = 12
 
static constexpr int BoxHeight = 10
 

Friends

class system::Player
 

Detailed Description

Peoplemon storage system for extra peoplemon the player has.

Definition at line 22 of file StorageSystem.hpp.

Constructor & Destructor Documentation

◆ StorageSystem()

core::player::StorageSystem::StorageSystem ( )

Construct a new Storage System.

Definition at line 9 of file StorageSystem.cpp.

Member Function Documentation

◆ add() [1/2]

bool core::player::StorageSystem::add ( const pplmn::OwnedPeoplemon ppl)

Adds the given peoplemon to storage in a free slot.

Parameters
pplThe peoplemon to add
Returns
True if the peoplemon could be stored, false if full

Definition at line 11 of file StorageSystem.cpp.

◆ add() [2/2]

void core::player::StorageSystem::add ( unsigned int  box,
const sf::Vector2i &  pos,
const pplmn::OwnedPeoplemon ppl 
)

Adds the peoplemon to storage at the given position. Does not check if the position is available, the caller must ensure that it is free.

Parameters
boxThe box to add to [0, 13]
posThe position in the box
pplThe peoplemon to add

Definition at line 26 of file StorageSystem.cpp.

◆ get()

pplmn::StoredPeoplemon * core::player::StorageSystem::get ( unsigned int  box,
const sf::Vector2i &  pos 
)

Returns the peoplemon at the given position in the given box.

Parameters
boxThe box to search in
posThe position to check
Returns
pplmn::StoredPeoplemon* The peoplemon or nullptr if the spot is empty

Definition at line 89 of file StorageSystem.cpp.

◆ getBox()

const std::vector< pplmn::StoredPeoplemon > & core::player::StorageSystem::getBox ( unsigned int  box) const

Returns the given box. Performs no bounds check.

Parameters
boxThe box to get
Returns
const std::vector<pplmn::StoredPeoplemon>& The box at the given index

Definition at line 96 of file StorageSystem.cpp.

◆ move()

pplmn::StoredPeoplemon * core::player::StorageSystem::move ( pplmn::StoredPeoplemon ppl,
unsigned int  newBox,
const sf::Vector2i &  newPos 
)

Moves the given stored peoplemon from its current location to the new location.

Parameters
pplThe peoplemon to move
newBoxThe box to place it in
newPosThe new position to give it
Returns
pplmn::StoredPeoplemon* The new address of the stored peoplemon

Definition at line 42 of file StorageSystem.cpp.

◆ remove()

void core::player::StorageSystem::remove ( unsigned int  box,
const sf::Vector2i &  position 
)

Clears the peoplemon from the given position, if one is there.

Parameters
boxThe box to remove from
positionThe position to remove from

Definition at line 32 of file StorageSystem.cpp.

◆ spaceFree()

bool core::player::StorageSystem::spaceFree ( int  box,
int  x,
int  y 
) const

Returns whether or not the given storage space is free.

Parameters
boxThe box number to check
xThe x position
yThe y position
Returns
True if that slot is open, false otherwise

Definition at line 79 of file StorageSystem.cpp.

Friends And Related Function Documentation

◆ system::Player

friend class system::Player
friend

Definition at line 101 of file StorageSystem.hpp.

Member Data Documentation

◆ BoxCount

constexpr int core::player::StorageSystem::BoxCount = 14
staticconstexpr

Definition at line 24 of file StorageSystem.hpp.

◆ BoxHeight

constexpr int core::player::StorageSystem::BoxHeight = 10
staticconstexpr

Definition at line 26 of file StorageSystem.hpp.

◆ BoxWidth

constexpr int core::player::StorageSystem::BoxWidth = 12
staticconstexpr

Definition at line 25 of file StorageSystem.hpp.


The documentation for this class was generated from the following files: