Browse files

renaming throw to detonate and damage closer including warrior

  • Loading branch information...
1 parent 216c657 commit c31ea4a6313c2f1322c4ba04049cf443d4516ebd @ryanb committed Jun 2, 2010
View
2 lib/ruby_warrior.rb
@@ -42,4 +42,4 @@
require 'ruby_warrior/abilities/direction_of_stairs'
require 'ruby_warrior/abilities/direction_of'
require 'ruby_warrior/abilities/explode'
-require 'ruby_warrior/abilities/throw'
+require 'ruby_warrior/abilities/detonate'
View
12 lib/ruby_warrior/abilities/throw.rb → lib/ruby_warrior/abilities/detonate.rb
@@ -1,16 +1,16 @@
module RubyWarrior
module Abilities
- class Throw < Base
+ class Detonate < Base
def description
- "Throw a bomb in a given direction (forward by default) which damages second space and lightly damages surrounding 4 spaces."
+ "Detonate a bomb in a given direction (forward by default) which damages that space and surrounding 4 spaces (including yourself)."
end
def perform(direction = :forward)
if @unit.position
- @unit.say "throws a bomb #{direction}"
- bomb(direction, 2, 0, 4)
- [[2, 1], [2, -1], [3, 0], [1, 0]].each do |x, y|
- bomb(direction, x, y, 2)
+ @unit.say "detonates a bomb #{direction}"
+ bomb(direction, 1, 0, 8)
+ [[1, 1], [1, -1], [2, 0], [0, 0]].each do |x, y|
+ bomb(direction, x, y, 4)
end
end
end
View
32 spec/ruby_warrior/abilities/throw_spec.rb
@@ -1,45 +1,45 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-describe RubyWarrior::Abilities::Throw do
+describe RubyWarrior::Abilities::Detonate do
before(:each) do
@floor = RubyWarrior::Floor.new
@floor.width = 3
@floor.height = 3
@warrior = RubyWarrior::Units::Warrior.new
@floor.add(@warrior, 0, 0, :south)
- @throw = RubyWarrior::Abilities::Throw.new(@warrior)
+ @detonate = RubyWarrior::Abilities::Detonate.new(@warrior)
end
- it "should subtract 4 from unit two spaces forward and 2 from units surrounding that space" do
+ it "should subtract 8 from forward unit and 4 from surrounding units" do
target_unit = RubyWarrior::Units::Base.new
target_unit.health = 15
second_unit = RubyWarrior::Units::Base.new
second_unit.health = 15
- @floor.add(target_unit, 0, 2)
- @floor.add(second_unit, 1, 2)
- @throw.perform
- target_unit.health.should == 11
- second_unit.health.should == 13
+ @floor.add(target_unit, 0, 1)
+ @floor.add(second_unit, 1, 1)
+ @detonate.perform
+ target_unit.health.should == 7
+ second_unit.health.should == 11
end
- it "should subtract 4 from unit two spaces left and 2 from units surrounding that space" do
+ it "should subtract 8 from left unit and 4 from surrounding units" do
target_unit = RubyWarrior::Units::Base.new
target_unit.health = 15
second_unit = RubyWarrior::Units::Base.new
second_unit.health = 15
- @floor.add(target_unit, 2, 0)
- @floor.add(second_unit, 2, 1)
- @throw.perform(:left)
- target_unit.health.should == 11
- second_unit.health.should == 13
+ @floor.add(target_unit, 1, 0)
+ @floor.add(second_unit, 1, 1)
+ @detonate.perform(:left)
+ target_unit.health.should == 7
+ second_unit.health.should == 11
end
it "should detonate an explosive if any unit has one" do
captive = RubyWarrior::Units::Captive.new
captive.health = 1
captive.add_abilities :explode!
- @floor.add(captive, 1, 2)
- @throw.perform
+ @floor.add(captive, 1, 1)
+ @detonate.perform
captive.health.should == -99
@warrior.health.should == -80
end

0 comments on commit c31ea4a

Please sign in to comment.