diff options
author | Philip Paquette <pcpaquette@gmail.com> | 2019-06-06 12:15:07 -0400 |
---|---|---|
committer | Philip Paquette <pcpaquette@gmail.com> | 2019-06-07 20:02:12 -0400 |
commit | d0e4f20bcffb11368935603da1205ee7bc167dc9 (patch) | |
tree | 71352bc3ed3ba3fbc26cef472c7aaec27f779cc2 | |
parent | 9cbd8b635a268dc0a3726a090d1f601d7e4e74f1 (diff) |
Map - Validating that coast without '/' are adjacent to nearby water locs
-rw-r--r-- | diplomacy/engine/map.py | 15 | ||||
-rw-r--r-- | diplomacy/utils/errors.py | 1 |
2 files changed, 16 insertions, 0 deletions
diff --git a/diplomacy/engine/map.py b/diplomacy/engine/map.py index db2ab5c..13d430b 100644 --- a/diplomacy/engine/map.py +++ b/diplomacy/engine/map.py @@ -217,6 +217,21 @@ class Map(): and not (place.islower() and self.area_type(loc) == 'WATER'): self.error.append(err.MAP_ONE_WAY_ADJ % (place, loc)) + # Loc without coasts (e.g. 'spa' on the standard map) need to be adjacent to all nearby water locations + # Computing the list of water locs adjacent from coast locs (e.g. 'SPA/NC') and making sure they + # are also adjacent to the coast without loc (i.e. 'spa') + if place != place.lower(): + continue + + adj_water_locs = set() + for coast_loc in self.find_coasts(place): + if coast_loc.upper() == place.upper(): + continue + adj_water_locs |= {loc.upper() for loc in self.loc_abut[coast_loc] if self.area_type(loc) == 'WATER'} + missing_water_locs = adj_water_locs - set(up_abuts) + for water_loc in missing_water_locs: + self.error.append(err.MAP_MISSING_ADJ % (place, water_loc)) + # Validating home centers for power_name, places in self.homes.items(): for site in places: diff --git a/diplomacy/utils/errors.py b/diplomacy/utils/errors.py index b95da38..cf20e03 100644 --- a/diplomacy/utils/errors.py +++ b/diplomacy/utils/errors.py @@ -61,6 +61,7 @@ MAP_RENAMING_POWER_NOT_SUPPORTED = 'THE RENAME POWER OPERATOR -> IS NO LONGER SU MAP_POWER_NAME_EMPTY_KEYWORD = 'POWER NAME IS EMPTY KEYWORD: %s' MAP_POWER_NAME_CAN_BE_CONFUSED = 'POWER NAME CAN BE CONFUSED WITH LOCATION ALIAS OR ORDER TYPE: %s' MAP_ILLEGAL_POWER_ABBREV = 'ILLEGAL POWER ABBREVIATION' +MAP_MISSING_ADJ = 'MISSING ADJACENCY: %s -> %s' GAME_UNKNOWN_POWER = 'UNKNOWN POWER OR PLACENAME: %s' GAME_UNKNOWN_UNIT_TYPE = 'UNKNOWN UNIT TYPE: %s' |