diff options
author | Philip Paquette <pcpaquette@gmail.com> | 2019-06-06 12:10:39 -0400 |
---|---|---|
committer | Philip Paquette <pcpaquette@gmail.com> | 2019-06-07 20:02:12 -0400 |
commit | da8bb3f7cb66f3c08309f9bff9b46093d8194220 (patch) | |
tree | 946893e7145a50f0d7a5759ae2c6a6cd0f2af4a9 /diplomacy/engine/map.py | |
parent | cc2bc4bd4fc5474946c9f8489dd0a93511a7fc1f (diff) |
Map - Adjacency for invalid unit is always false
Diffstat (limited to 'diplomacy/engine/map.py')
-rw-r--r-- | diplomacy/engine/map.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/diplomacy/engine/map.py b/diplomacy/engine/map.py index 2730168..db2ab5c 100644 --- a/diplomacy/engine/map.py +++ b/diplomacy/engine/map.py @@ -208,11 +208,13 @@ class Map(): self.error += [err.MAP_NO_FULL_NAME % place] # Checking one-way adjacency + # Adjacencies between lower-case coast and water are supposed to be one-way for loc in abuts: if self.area_type(place) != 'SHUT' \ and self.area_type(loc) != 'SHUT' \ and not self.abuts('A', loc, '-', place) \ - and not self.abuts('F', loc, '-', place): + and not self.abuts('F', loc, '-', place) \ + and not (place.islower() and self.area_type(loc) == 'WATER'): self.error.append(err.MAP_ONE_WAY_ADJ % (place, loc)) # Validating home centers @@ -1109,6 +1111,10 @@ class Map(): # pylint: disable=too-many-return-statements unit_loc, other_loc = unit_loc.upper(), other_loc.upper() + # If the unit is not valid on the current location, returning 0 + if not self.is_valid_unit(unit_type + ' ' + unit_loc): + return 0 + # Removing coasts for support # Otherwise, if army, not adjacent since army can't move, hold, or convoy on coasts if '/' in other_loc: |