pacman/lib/Pellets.cpp
Corentin Jabot f911f6e2a8 Eat pellets
2021-06-16 13:59:16 +02:00

13 lines
330 B
C++

#include "Pellets.hpp"
#include <algorithm>
Pellets::Pellets(const Board & board)
: positions(board.initialPelletPositions()) {}
bool Pellets::eatPelletAtPosition(Position p) {
auto it = std::find(positions.begin(), positions.end(), p);
if (it == positions.end())
return false;
positions.erase(it);
return true;
}