55
66#include " Map/Map.h"
77
8- #include < fstream>
98#include < iostream>
109#include " Database/Database.h"
11-
10+ #include < algorithm>
11+ #include < utility>
1212#include < raylib.h>
1313#include < regex>
14- #include " ../ ApplicationConfig.h"
14+ #include " ApplicationConfig.h"
1515
1616Map::Map (Database* db) : db_(db) {
1717}
@@ -128,7 +128,7 @@ void Map::LoadFromString(const std::string& map) {
128128 score_ = 0 ;
129129 explored_map_.assign (loaded_map_.size (), false );
130130 free_tile_count_ = static_cast <int >(
131- std::count (loaded_map_. begin (), loaded_map_. end () , ' 0' )
131+ std::ranges:: count (loaded_map_, ' 0' )
132132 );
133133}
134134
@@ -141,7 +141,7 @@ void Map::LoadMapFromDB(const int map_number) {
141141 std::erase (loaded_map_, ' \r ' );
142142 explored_map_.assign (loaded_map_.size (), false );
143143 free_tile_count_ = static_cast <int >(
144- std::count (loaded_map_. begin (), loaded_map_. end () , ' 0' )
144+ std::ranges:: count (loaded_map_, ' 0' )
145145 );
146146}
147147
@@ -151,20 +151,20 @@ std::optional<MapValidationError> Map::ValidateMap(const std::string& map) {
151151 if (map.length () != 1400 ) {
152152 return MapValidationError::InvalidLength;
153153 }
154- if (std::count (map. begin (),map. end () , ' 0' )<=100 ) {
154+ if (std::ranges:: count (map, ' 0' )<=100 ) {
155155 std::cerr << " Not enough coins" << std::endl;
156156 return MapValidationError::TooFewCoins;
157157 }
158158 if (!std::regex_match (map, valid_chars)) {
159159 std::cerr << " Invalid characters found.\n " ;
160160 return MapValidationError::UnresolvableSymbols;
161161 }
162- auto player_starting_positions_count = std::count (map. begin (), map. end () , ' X' );
162+ auto player_starting_positions_count = std::ranges:: count (map, ' X' );
163163 if (player_starting_positions_count != 1 ) {
164164 std::cerr << " Invalid player count: " << player_starting_positions_count << " (expected exactly 1)\n " ;
165165 return MapValidationError::InvalidPlayerCount;
166166 }
167- auto ghost_starting_positions_count = std::count (map. begin (), map. end () , ' ?' );
167+ auto ghost_starting_positions_count = std::ranges:: count (map, ' ?' );
168168 if (ghost_starting_positions_count > 4 || ghost_starting_positions_count < 1 ) {
169169 std::cerr << " Invalid ghost count: (Must be between 1 and 4) current count: " << ghost_starting_positions_count << " \n " ;
170170 return MapValidationError::InvalidEnemyCount;
0 commit comments