From 76c931656f960738783ba3c1a419387f7f9db13d Mon Sep 17 00:00:00 2001 From: Corentin Jabot Date: Mon, 2 Aug 2021 15:31:32 +0200 Subject: [PATCH] Remove nodiscard --- lib/PacManAnimation.cpp | 2 +- lib/include/Board.hpp | 17 +++++++++-------- lib/include/Ghost.hpp | 12 ++++++------ lib/include/InputState.hpp | 2 +- lib/include/PacMan.hpp | 8 ++++---- lib/include/PacManAnimation.hpp | 4 ++-- lib/include/Pellets.hpp | 4 ++-- lib/include/SuperPellets.hpp | 4 ++-- 8 files changed, 27 insertions(+), 26 deletions(-) diff --git a/lib/PacManAnimation.cpp b/lib/PacManAnimation.cpp index b5663aa..ea67a25 100644 --- a/lib/PacManAnimation.cpp +++ b/lib/PacManAnimation.cpp @@ -23,7 +23,7 @@ GridPosition PacManAnimation::animationFrame(Direction direction) const { } } -[[nodiscard]] GridPosition PacManAnimation::deathAnimationFrame() const { +GridPosition PacManAnimation::deathAnimationFrame() const { return GridPosition{ animation_position, 1 }; } diff --git a/lib/include/Board.hpp b/lib/include/Board.hpp index 4016107..783a344 100644 --- a/lib/include/Board.hpp +++ b/lib/include/Board.hpp @@ -10,17 +10,18 @@ namespace pacman { - [[nodiscard]] bool isWalkableForPacMan(GridPosition point); - [[nodiscard]] bool isWalkableForGhost(GridPosition point, GridPosition origin, bool isEyes); - [[nodiscard]] bool isInPen(GridPosition point); - [[nodiscard]] bool isPortal(GridPosition point, Direction direction); - [[nodiscard]] GridPosition teleport(GridPosition point); +bool isWalkableForPacMan(GridPosition point); +bool isWalkableForGhost(GridPosition point, GridPosition origin, bool isEyes); +bool isInPen(GridPosition point); +bool isPortal(GridPosition point, Direction direction); +GridPosition teleport(GridPosition point); - [[nodiscard]] std::vector initialPelletPositions(); +std::vector initialPelletPositions(); - [[nodiscard]] std::vector initialSuperPelletPositions(); +std::vector initialSuperPelletPositions(); - inline Position penDoorPosition() { return { 13, 11 }; } +inline Position penDoorPosition() { + return { 13, 11 }; } inline Position initialPacManPosition() { return { 13.5, 23 }; } } // namespace pacman diff --git a/lib/include/Ghost.hpp b/lib/include/Ghost.hpp index c353090..982c62e 100644 --- a/lib/include/Ghost.hpp +++ b/lib/include/Ghost.hpp @@ -22,17 +22,17 @@ public: explicit Ghost(Atlas::Ghost spriteSet); 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 frighten(); void die(); - [[nodiscard]] bool isFrightened() const; - [[nodiscard]] bool isEyes() const; + bool isFrightened() const; + bool isEyes() const; void reset(); private: @@ -56,7 +56,7 @@ protected: std::chrono::milliseconds timeChase = {}; Position pos; GridPosition last_grid_position = { 0, 0 }; - [[nodiscard]] bool isInPen() const; + bool isInPen() const; }; } // namespace pacman diff --git a/lib/include/InputState.hpp b/lib/include/InputState.hpp index cdefacb..813abad 100644 --- a/lib/include/InputState.hpp +++ b/lib/include/InputState.hpp @@ -10,7 +10,7 @@ public: bool left = false; bool right = false; - [[nodiscard]] Direction direction() const { + Direction direction() const { if (left) return Direction::LEFT; else if (right) diff --git a/lib/include/PacMan.hpp b/lib/include/PacMan.hpp index 39ea40e..113b1d7 100644 --- a/lib/include/PacMan.hpp +++ b/lib/include/PacMan.hpp @@ -13,17 +13,17 @@ class InputState; class PacMan { 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 die(); void reset(); - [[nodiscard]] bool hasDirection() const { + bool hasDirection() const { return direction != Direction::NONE; } diff --git a/lib/include/PacManAnimation.hpp b/lib/include/PacManAnimation.hpp index cd49ee4..42dcde0 100644 --- a/lib/include/PacManAnimation.hpp +++ b/lib/include/PacManAnimation.hpp @@ -11,8 +11,8 @@ namespace pacman { class PacManAnimation { public: - [[nodiscard]] GridPosition animationFrame(Direction direction) const; - [[nodiscard]] GridPosition deathAnimationFrame() const; + GridPosition animationFrame(Direction direction) const; + GridPosition deathAnimationFrame() const; void updateAnimationPosition(std::chrono::milliseconds time_delta, bool dead); void pause(); diff --git a/lib/include/Pellets.hpp b/lib/include/Pellets.hpp index dac6bfe..90f0514 100644 --- a/lib/include/Pellets.hpp +++ b/lib/include/Pellets.hpp @@ -9,11 +9,11 @@ class Pellets { public: explicit Pellets(); - [[nodiscard]] GridPosition currentSprite() const { + GridPosition currentSprite() const { return sprite; }; - [[nodiscard]] std::vector currentPositions() const { + std::vector currentPositions() const { return positions; } diff --git a/lib/include/SuperPellets.hpp b/lib/include/SuperPellets.hpp index 03e43ef..245daae 100644 --- a/lib/include/SuperPellets.hpp +++ b/lib/include/SuperPellets.hpp @@ -9,11 +9,11 @@ class SuperPellets { public: explicit SuperPellets(); - [[nodiscard]] GridPosition currentSprite() const { + GridPosition currentSprite() const { return sprite; } - [[nodiscard]] std::vector currentPositions() const { + std::vector currentPositions() const { return positions; }