Skip to content

Commit

Permalink
Remove misleading Game::setPower method. Move method body into place …
Browse files Browse the repository at this point in the history
…of use.
  • Loading branch information
przemek83 committed Oct 9, 2024
1 parent f32bf0d commit f8c94e1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
12 changes: 4 additions & 8 deletions src/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ void Game::movePlayerTank(const std::set<InputAction>& actions)
{
Tank& tank{getPlayerTank()};

setPower(tank);
if (auto [takenPowerUp, powerUpType]{map_.takePowerUp(tank.getCenter())};
takenPowerUp)
tank.applyPowerUp(powerUpType);

if (const auto now{std::chrono::system_clock::now()};
containsAction(actions, InputAction::FIRE) && tank.canFire(now))
bullets_.emplace_back(tank.fire(now));
Expand Down Expand Up @@ -215,13 +218,6 @@ void Game::draw(const Display& display)
status_.update(getPlayerTank().getStats(), display);
}

void Game::setPower(Tank& tank)
{
if (auto [takenPowerUp, powerUp]{map_.takePowerUp(tank.getCenter())};
takenPowerUp)
tank.applyPowerUp(powerUp);
}

bool Game::containsAction(const std::set<InputAction>& actions,
InputAction action)
{
Expand Down
1 change: 0 additions & 1 deletion src/Game.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class Game
void drawTanks(const Display& display) const;
void drawEndOfGame(Display& display, const std::string& text) const;
void drawBullets(const Display& display) const;
void setPower(Tank& tank);

static std::pair<bool, Direction> inputActionsToDirection(
const std::set<InputAction>& actions);
Expand Down

0 comments on commit f8c94e1

Please sign in to comment.