From d0e4f20bcffb11368935603da1205ee7bc167dc9 Mon Sep 17 00:00:00 2001 From: Philip Paquette Date: Thu, 6 Jun 2019 12:15:07 -0400 Subject: Map - Validating that coast without '/' are adjacent to nearby water locs --- diplomacy/engine/map.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'diplomacy/engine/map.py') 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: -- cgit v1.2.3