pacman/lib/Pellets.cpp

18 lines
386 B
C++
Raw Normal View History

#include "Pellets.hpp"
2021-06-16 11:59:16 +00:00
#include <algorithm>
2021-07-05 12:10:01 +00:00
namespace pacman {
Pellets::Pellets(const Board & board)
2021-07-07 09:24:12 +00:00
: positions(pacman::Board::initialPelletPositions()) {}
2021-06-16 11:59:16 +00:00
2021-07-05 11:54:54 +00:00
bool Pellets::eatPelletAtPosition(GridPosition p) {
2021-06-16 11:59:16 +00:00
auto it = std::find(positions.begin(), positions.end(), p);
if (it == positions.end())
return false;
positions.erase(it);
return true;
}
2021-07-05 12:10:01 +00:00
} // namespace pacman