summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormo k <mo@mokhan.ca>2012-02-13 13:19:50 -0700
committermo k <mo@mokhan.ca>2012-02-13 13:19:50 -0700
commit86fda8f9ff0eb0bd32f67c5d2bbdae0ec5b6033c (patch)
treea5902b6e1670fc5605e131cd4611521250d11485 /lib
parent9f635b54de51ac87b42d0f72f5f036a150bde4c9 (diff)
check bounds when facing south and moving forward.
Diffstat (limited to 'lib')
-rwxr-xr-x[-rw-r--r--]lib/south.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/south.rb b/lib/south.rb
index 04851c0..5e8a434 100644..100755
--- a/lib/south.rb
+++ b/lib/south.rb
@@ -5,7 +5,9 @@ class South
def turn_left
East.new
end
- def forward(current_location, terrain)
- current_location[:y] = current_location[:y]-1
+ def forward(location, terrain)
+ unless terrain.is_out_of_bounds({:x => location[:x], :y => location[:y]-1})
+ location[:y] = location[:y]-1
+ end
end
end