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 /diplomacy/engine | |
parent | 9cbd8b635a268dc0a3726a090d1f601d7e4e74f1 (diff) |
Map - Validating that coast without '/' are adjacent to nearby water locs
Diffstat (limited to 'diplomacy/engine')
-rw-r--r-- | diplomacy/engine/map.py | 15 |
1 files changed, 15 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: |