Skip to content
Browse files

adding look ability

  • Loading branch information...
1 parent b7aaf63 commit 742a8d4b60f5d471762ad9221438e9fa3eb3a90c @ryanb committed Jul 15, 2008
View
4 README
@@ -36,7 +36,7 @@ Your objective is to not only reach the goal, but to get the highest score you c
- defeat an enemy to add his max health to your score
- rescue a captive to earn 50 points
- pass the level within the bonus time to earn the amount of bonus time remaining
- - defeat all enemies and rescue all captives to receive a 10% bonus
+ - defeat all enemies and rescue all captives to receive a 20% bonus
The score is only added once you pass the level. If you die your score for that level is lost.
@@ -50,7 +50,7 @@ Even though this is a text-based game, think of it as two-dimensional where you
Commanding the Warrior
----------------------
-When you first start your warrior will only have a few abilities, but with each level your abilities will grow. A warrior has two kinds of abilities: actions and senses.
+When you first start, your warrior will only have a few abilities, but with each level your abilities will grow. A warrior has two kinds of abilities: actions and senses.
An action is something that effects the game in some way. You can easily tell an action because it ends in an exclamation mark. Only one action can be performed per turn, so choose wisely. Here are some examples of actions.
View
1 lib/ruby_warrior.rb
@@ -22,3 +22,4 @@
require 'ruby_warrior/abilities/feel'
require 'ruby_warrior/abilities/rest'
require 'ruby_warrior/abilities/health'
+require 'ruby_warrior/abilities/look'
View
8 lib/ruby_warrior/abilities/base.rb
@@ -12,12 +12,12 @@ def initialize(unit)
@unit = unit
end
- def offset(direction)
- DIRECTIONS[direction]
+ def offset(direction, amount = 1)
+ DIRECTIONS[direction].map { |i| i*amount }
end
- def space(direction)
- @unit.position.relative_space(*offset(direction))
+ def space(direction, amount = 1)
+ @unit.position.relative_space(*offset(direction, amount))
end
def unit(direction)
View
15 lib/ruby_warrior/abilities/look.rb
@@ -0,0 +1,15 @@
+module RubyWarrior
+ module Abilities
+ class Look < Base
+ def possible_arguments
+ [[], :forward, :left, :right]
+ end
+
+ def perform(direction = :forward)
+ [1, 2, 3].map do |amount|
+ space(direction, amount)
+ end
+ end
+ end
+ end
+end
View
19 spec/ruby_warrior/abilities/look_spec.rb
@@ -0,0 +1,19 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe RubyWarrior::Abilities::Look do
+ before(:each) do
+ @unit = stub(:position => stub, :say => nil)
+ @feel = RubyWarrior::Abilities::Look.new(@unit)
+ end
+
+ it "should get 3 objects at position from offset" do
+ @unit.position.expects(:relative_space).with(1, 0).returns(1)
+ @unit.position.expects(:relative_space).with(2, 0).returns(2)
+ @unit.position.expects(:relative_space).with(3, 0).returns(3)
+ @feel.perform(:forward).should == [1, 2, 3]
+ end
+
+ it "should have all directions except back as possible arguments" do
+ @feel.possible_arguments.to_set.should == [[], :forward, :left, :right].to_set
+ end
+end

0 comments on commit 742a8d4

Please sign in to comment.
Something went wrong with that request. Please try again.