16 boxes[b].emplace_back(ppl, b, sf::Vector2i(x, y));
17 boxes[b].back().peoplemon.heal();
28 boxes[box].emplace_back(ppl, box, pos);
29 boxes[box].back().peoplemon.heal();
34 for (
unsigned int i = 0; i < box.size(); ++i) {
35 if (box[i].position == pos) {
36 box.erase(box.begin() + i);
43 const sf::Vector2i& newPos) {
45 const auto it = std::find_if(
50 BL_LOG_CRITICAL <<
"Could not find Peoplemon to move at position: " << ppl.
position;
55 const auto oit = std::find_if(
59 if (oit != boxes[newBox].end()) {
60 std::swap(it->peoplemon, oit->peoplemon);
71 boxes[newBox].emplace_back(ppl);
72 boxes[ogBox].erase(it);
73 return &boxes[newBox].back();
80 if (box < 0 ||
static_cast<unsigned int>(box) >= boxes.size())
return false;
83 for (
const auto& stored : boxes[box]) {
84 if (stored.position.x == x && stored.position.y == y)
return false;
90 for (
auto& ppl : boxes[box]) {
91 if (ppl.position == pos) {
return &ppl; }
Core classes and functionality for both the editor and game.
Represents an instance of a peoplemon. Can be a wild peoplemon, trainer, or player peoplemon....
Represents a Peoplemon in storage.
std::uint16_t boxNumber
Which box the peoplemon is in.
sf::Vector2i position
The position of the peoplemon in the box.
static constexpr int BoxCount
pplmn::StoredPeoplemon * get(unsigned int box, const sf::Vector2i &pos)
Returns the peoplemon at the given position in the given box.
static constexpr int BoxHeight
static constexpr int BoxWidth
pplmn::StoredPeoplemon * move(pplmn::StoredPeoplemon &ppl, unsigned int newBox, const sf::Vector2i &newPos)
Moves the given stored peoplemon from its current location to the new location.
StorageSystem()
Construct a new Storage System.
void remove(unsigned int box, const sf::Vector2i &position)
Clears the peoplemon from the given position, if one is there.
const std::vector< pplmn::StoredPeoplemon > & getBox(unsigned int box) const
Returns the given box. Performs no bounds check.
bool add(const pplmn::OwnedPeoplemon &ppl)
Adds the given peoplemon to storage in a free slot.
bool spaceFree(int box, int x, int y) const
Returns whether or not the given storage space is free.