forked from ryanb/ruby-warrior
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module RubyWarrior | ||
module Abilities | ||
class DirectionOfStairs < Base | ||
def description | ||
"Returns the direction (:left, :right, :forward, :backward) the stairs are from your location." | ||
end | ||
|
||
def possible_arguments | ||
[[]] | ||
end | ||
|
||
def perform | ||
@unit.position.relative_direction_of_stairs | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require File.dirname(__FILE__) + '/../../spec_helper' | ||
|
||
describe RubyWarrior::Abilities::DirectionOfStairs do | ||
before(:each) do | ||
@position = stub | ||
@distance = RubyWarrior::Abilities::DirectionOfStairs.new(stub(:position => @position, :say => nil)) | ||
end | ||
|
||
it "should return relative direction of stairs" do | ||
@position.stubs(:relative_direction_of_stairs).returns(:left) | ||
@distance.perform.should == :left | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters