From: W. Trevor King Date: Fri, 26 Mar 2010 04:19:41 +0000 (-0400) Subject: Added adjacency checking to Engine.attack_and_fortify. X-Git-Tag: 0.1~37 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f71d508e346ae2b4bfae1d7b9d91d4de0d61ac6d;p=pyrisk.git Added adjacency checking to Engine.attack_and_fortify. --- diff --git a/risk/base.py b/risk/base.py index e1ea622..9fdda26 100644 --- a/risk/base.py +++ b/risk/base.py @@ -620,6 +620,9 @@ class Engine (ID_CmpMixin): source_name,target_name,armies = action source = self.world.territory_by_name(source_name) target = self.world.territory_by_name(target_name) + if not source.borders(target): + raise PlayerError('Cannot reach %s from %s to %s' + % (target, source, mode)) if mode == 'attack': tplayer = target.player capture = self.attack(source, target, armies)