Remove nodiscard

This commit is contained in:
Corentin Jabot 2021-08-02 15:31:32 +02:00
parent d3cc1d90c7
commit 76c931656f
8 changed files with 27 additions and 26 deletions

View file

@ -23,7 +23,7 @@ GridPosition PacManAnimation::animationFrame(Direction direction) const {
} }
} }
[[nodiscard]] GridPosition PacManAnimation::deathAnimationFrame() const { GridPosition PacManAnimation::deathAnimationFrame() const {
return GridPosition{ animation_position, 1 }; return GridPosition{ animation_position, 1 };
} }

View file

@ -10,17 +10,18 @@
namespace pacman { namespace pacman {
[[nodiscard]] bool isWalkableForPacMan(GridPosition point); bool isWalkableForPacMan(GridPosition point);
[[nodiscard]] bool isWalkableForGhost(GridPosition point, GridPosition origin, bool isEyes); bool isWalkableForGhost(GridPosition point, GridPosition origin, bool isEyes);
[[nodiscard]] bool isInPen(GridPosition point); bool isInPen(GridPosition point);
[[nodiscard]] bool isPortal(GridPosition point, Direction direction); bool isPortal(GridPosition point, Direction direction);
[[nodiscard]] GridPosition teleport(GridPosition point); GridPosition teleport(GridPosition point);
[[nodiscard]] std::vector<GridPosition> initialPelletPositions(); std::vector<GridPosition> initialPelletPositions();
[[nodiscard]] std::vector<GridPosition> initialSuperPelletPositions(); std::vector<GridPosition> initialSuperPelletPositions();
inline Position penDoorPosition() { return { 13, 11 }; } inline Position penDoorPosition() {
return { 13, 11 }; }
inline Position initialPacManPosition() { return { 13.5, 23 }; } inline Position initialPacManPosition() { return { 13.5, 23 }; }
} // namespace pacman } // namespace pacman

View file

@ -22,17 +22,17 @@ public:
explicit Ghost(Atlas::Ghost spriteSet); explicit Ghost(Atlas::Ghost spriteSet);
virtual ~Ghost() = default; virtual ~Ghost() = default;
[[nodiscard]] GridPosition currentSprite() const; GridPosition currentSprite() const;
[[nodiscard]] Position position() const; Position position() const;
[[nodiscard]] GridPosition positionInGrid() const; GridPosition positionInGrid() const;
void update(std::chrono::milliseconds time_delta, const GameState & gameState); void update(std::chrono::milliseconds time_delta, const GameState & gameState);
void frighten(); void frighten();
void die(); void die();
[[nodiscard]] bool isFrightened() const; bool isFrightened() const;
[[nodiscard]] bool isEyes() const; bool isEyes() const;
void reset(); void reset();
private: private:
@ -56,7 +56,7 @@ protected:
std::chrono::milliseconds timeChase = {}; std::chrono::milliseconds timeChase = {};
Position pos; Position pos;
GridPosition last_grid_position = { 0, 0 }; GridPosition last_grid_position = { 0, 0 };
[[nodiscard]] bool isInPen() const; bool isInPen() const;
}; };
} // namespace pacman } // namespace pacman

View file

@ -10,7 +10,7 @@ public:
bool left = false; bool left = false;
bool right = false; bool right = false;
[[nodiscard]] Direction direction() const { Direction direction() const {
if (left) if (left)
return Direction::LEFT; return Direction::LEFT;
else if (right) else if (right)

View file

@ -13,17 +13,17 @@ class InputState;
class PacMan { class PacMan {
public: public:
[[nodiscard]] GridPosition currentSprite() const; GridPosition currentSprite() const;
[[nodiscard]] Position position() const; Position position() const;
[[nodiscard]] GridPosition positionInGrid() const; GridPosition positionInGrid() const;
void update(std::chrono::milliseconds time_delta, Direction input_direction); void update(std::chrono::milliseconds time_delta, Direction input_direction);
void die(); void die();
void reset(); void reset();
[[nodiscard]] bool hasDirection() const { bool hasDirection() const {
return direction != Direction::NONE; return direction != Direction::NONE;
} }

View file

@ -11,8 +11,8 @@ namespace pacman {
class PacManAnimation { class PacManAnimation {
public: public:
[[nodiscard]] GridPosition animationFrame(Direction direction) const; GridPosition animationFrame(Direction direction) const;
[[nodiscard]] GridPosition deathAnimationFrame() const; GridPosition deathAnimationFrame() const;
void updateAnimationPosition(std::chrono::milliseconds time_delta, bool dead); void updateAnimationPosition(std::chrono::milliseconds time_delta, bool dead);
void pause(); void pause();

View file

@ -9,11 +9,11 @@ class Pellets {
public: public:
explicit Pellets(); explicit Pellets();
[[nodiscard]] GridPosition currentSprite() const { GridPosition currentSprite() const {
return sprite; return sprite;
}; };
[[nodiscard]] std::vector<GridPosition> currentPositions() const { std::vector<GridPosition> currentPositions() const {
return positions; return positions;
} }

View file

@ -9,11 +9,11 @@ class SuperPellets {
public: public:
explicit SuperPellets(); explicit SuperPellets();
[[nodiscard]] GridPosition currentSprite() const { GridPosition currentSprite() const {
return sprite; return sprite;
} }
[[nodiscard]] std::vector<GridPosition> currentPositions() const { std::vector<GridPosition> currentPositions() const {
return positions; return positions;
} }