From f71d508e346ae2b4bfae1d7b9d91d4de0d61ac6d Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 26 Mar 2010 00:19:41 -0400 Subject: [PATCH] Added adjacency checking to Engine.attack_and_fortify. --- risk/base.py | 3 +++ 1 file changed, 3 insertions(+) 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) -- 2.26.2