Skip to content

Commit

Permalink
renaming throw to detonate and damage closer including warrior
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanb committed Jun 3, 2010
1 parent 216c657 commit c31ea4a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion lib/ruby_warrior.rb
Expand Up @@ -42,4 +42,4 @@
require 'ruby_warrior/abilities/direction_of_stairs' require 'ruby_warrior/abilities/direction_of_stairs'
require 'ruby_warrior/abilities/direction_of' require 'ruby_warrior/abilities/direction_of'
require 'ruby_warrior/abilities/explode' require 'ruby_warrior/abilities/explode'
require 'ruby_warrior/abilities/throw' require 'ruby_warrior/abilities/detonate'
@@ -1,16 +1,16 @@
module RubyWarrior module RubyWarrior
module Abilities module Abilities
class Throw < Base class Detonate < Base
def description 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 end


def perform(direction = :forward) def perform(direction = :forward)
if @unit.position if @unit.position
@unit.say "throws a bomb #{direction}" @unit.say "detonates a bomb #{direction}"
bomb(direction, 2, 0, 4) bomb(direction, 1, 0, 8)
[[2, 1], [2, -1], [3, 0], [1, 0]].each do |x, y| [[1, 1], [1, -1], [2, 0], [0, 0]].each do |x, y|
bomb(direction, x, y, 2) bomb(direction, x, y, 4)
end end
end end
end end
Expand Down
32 changes: 16 additions & 16 deletions spec/ruby_warrior/abilities/throw_spec.rb
@@ -1,45 +1,45 @@
require File.dirname(__FILE__) + '/../../spec_helper' require File.dirname(__FILE__) + '/../../spec_helper'


describe RubyWarrior::Abilities::Throw do describe RubyWarrior::Abilities::Detonate do
before(:each) do before(:each) do
@floor = RubyWarrior::Floor.new @floor = RubyWarrior::Floor.new
@floor.width = 3 @floor.width = 3
@floor.height = 3 @floor.height = 3
@warrior = RubyWarrior::Units::Warrior.new @warrior = RubyWarrior::Units::Warrior.new
@floor.add(@warrior, 0, 0, :south) @floor.add(@warrior, 0, 0, :south)
@throw = RubyWarrior::Abilities::Throw.new(@warrior) @detonate = RubyWarrior::Abilities::Detonate.new(@warrior)
end 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 = RubyWarrior::Units::Base.new
target_unit.health = 15 target_unit.health = 15
second_unit = RubyWarrior::Units::Base.new second_unit = RubyWarrior::Units::Base.new
second_unit.health = 15 second_unit.health = 15
@floor.add(target_unit, 0, 2) @floor.add(target_unit, 0, 1)
@floor.add(second_unit, 1, 2) @floor.add(second_unit, 1, 1)
@throw.perform @detonate.perform
target_unit.health.should == 11 target_unit.health.should == 7
second_unit.health.should == 13 second_unit.health.should == 11
end 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 = RubyWarrior::Units::Base.new
target_unit.health = 15 target_unit.health = 15
second_unit = RubyWarrior::Units::Base.new second_unit = RubyWarrior::Units::Base.new
second_unit.health = 15 second_unit.health = 15
@floor.add(target_unit, 2, 0) @floor.add(target_unit, 1, 0)
@floor.add(second_unit, 2, 1) @floor.add(second_unit, 1, 1)
@throw.perform(:left) @detonate.perform(:left)
target_unit.health.should == 11 target_unit.health.should == 7
second_unit.health.should == 13 second_unit.health.should == 11
end end


it "should detonate an explosive if any unit has one" do it "should detonate an explosive if any unit has one" do
captive = RubyWarrior::Units::Captive.new captive = RubyWarrior::Units::Captive.new
captive.health = 1 captive.health = 1
captive.add_abilities :explode! captive.add_abilities :explode!
@floor.add(captive, 1, 2) @floor.add(captive, 1, 1)
@throw.perform @detonate.perform
captive.health.should == -99 captive.health.should == -99
@warrior.health.should == -80 @warrior.health.should == -80
end end
Expand Down

0 comments on commit c31ea4a

Please sign in to comment.