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.
adding bind ability to keep a unit from moving, but makes him look li…
…ke a captive
- Loading branch information
Showing
11 changed files
with
109 additions
and
5 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,19 @@ | ||
module RubyWarrior | ||
module Abilities | ||
class Bind < Base | ||
def description | ||
"Bind unit in given direction to keep him from moving (forward by default)." | ||
end | ||
|
||
def perform(direction = :forward) | ||
receiver = unit(direction) | ||
if receiver | ||
@unit.say "binds #{receiver}" | ||
receiver.bind | ||
else | ||
@unit.say "binds nothing" | ||
end | ||
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 |
---|---|---|
|
@@ -17,7 +17,7 @@ def enemy? | |
end | ||
|
||
def captive? | ||
unit.kind_of? Units::Captive | ||
unit.bound? | ||
end | ||
|
||
def empty? | ||
|
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 |
---|---|---|
@@ -1,6 +1,10 @@ | ||
module RubyWarrior | ||
module Units | ||
class Captive < Base | ||
def initialize | ||
bind | ||
end | ||
|
||
def max_health | ||
1 | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require File.dirname(__FILE__) + '/../../spec_helper' | ||
|
||
describe RubyWarrior::Abilities::Bind do | ||
before(:each) do | ||
@bind = RubyWarrior::Abilities::Bind.new(stub(:say => nil)) | ||
end | ||
|
||
it "should bind recipient" do | ||
receiver = RubyWarrior::Units::Base.new | ||
@bind.stubs(:unit).returns(receiver) | ||
@bind.perform | ||
receiver.should be_bound | ||
end | ||
|
||
it "should do nothing if no recipient" do | ||
@bind.stubs(:unit).returns(nil) | ||
lambda { @bind.perform }.should_not raise_error | ||
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
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