Added adjacency checking to Engine.attack_and_fortify.
authorW. Trevor King <wking@drexel.edu>
Fri, 26 Mar 2010 04:19:41 +0000 (00:19 -0400)
committerW. Trevor King <wking@drexel.edu>
Fri, 26 Mar 2010 04:19:41 +0000 (00:19 -0400)
risk/base.py

index e1ea6224a8b23529cb2a8b57d18f6c4eb1c68d72..9fdda2630e28ed9670a4eff1cf7999051ea10f31 100644 (file)
@@ -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)