Skip to content

Commit

Permalink
Rework isTileSign method in Map class.
Browse files Browse the repository at this point in the history
  • Loading branch information
przemek83 committed Sep 28, 2024
1 parent 48e5f85 commit 447637e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ std::list<Tank> Map::loadMap(std::iostream& stream)
for (std::size_t x = 0; x < mapDimension_; ++x)
{
stream >> std::noskipws >> sign;
while ((sign != EOF) && (!isTileSign(sign)))
while ((sign != EOF) && (!isValidSign(sign)))
stream >> std::noskipws >> sign;

createTile(sign, tanks, {x, y});
Expand Down Expand Up @@ -282,8 +282,12 @@ void Map::drawForeground(const Screen& screen)

bool Map::isBaseDestroyed() const { return baseDestroyed_; }

bool Map::isTileSign(char sign) const
bool Map::isValidSign(char sign) const
{
return ((sign >= '0') && (sign < '7')) || (sign == 'T') || (sign == 'E') ||
(sign == 'M') || (sign == 'S') || (sign == 'L') || (sign == 'A');
const bool isPowerUp{(sign == 'S') || (sign == 'L') || (sign == 'A') ||
(sign == 'T')};
const bool isTile{(sign >= '0') && (sign < '7')};
const bool isTank{(sign == 'E') || (sign == 'M')};

return isTile || isPowerUp || isTank;
}
2 changes: 1 addition & 1 deletion src/Map.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Map
static void shiftUp(Point& point, int tileSize);
static void shiftDown(Point& point, int tileSize);

bool isTileSign(char sign) const;
bool isValidSign(char sign) const;

void drawTile(const Screen& screen, TilePosition position);

Expand Down

0 comments on commit 447637e

Please sign in to comment.