Skip to content

Commit c31ea4a

Browse files
committed
renaming throw to detonate and damage closer including warrior
1 parent 216c657 commit c31ea4a

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

lib/ruby_warrior.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@
4242
require 'ruby_warrior/abilities/direction_of_stairs'
4343
require 'ruby_warrior/abilities/direction_of'
4444
require 'ruby_warrior/abilities/explode'
45-
require 'ruby_warrior/abilities/throw'
45+
require 'ruby_warrior/abilities/detonate'

lib/ruby_warrior/abilities/throw.rb lib/ruby_warrior/abilities/detonate.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
module RubyWarrior
22
module Abilities
3-
class Throw < Base
3+
class Detonate < Base
44
def description
5-
"Throw a bomb in a given direction (forward by default) which damages second space and lightly damages surrounding 4 spaces."
5+
"Detonate a bomb in a given direction (forward by default) which damages that space and surrounding 4 spaces (including yourself)."
66
end
77

88
def perform(direction = :forward)
99
if @unit.position
10-
@unit.say "throws a bomb #{direction}"
11-
bomb(direction, 2, 0, 4)
12-
[[2, 1], [2, -1], [3, 0], [1, 0]].each do |x, y|
13-
bomb(direction, x, y, 2)
10+
@unit.say "detonates a bomb #{direction}"
11+
bomb(direction, 1, 0, 8)
12+
[[1, 1], [1, -1], [2, 0], [0, 0]].each do |x, y|
13+
bomb(direction, x, y, 4)
1414
end
1515
end
1616
end

spec/ruby_warrior/abilities/throw_spec.rb

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
11
require File.dirname(__FILE__) + '/../../spec_helper'
22

3-
describe RubyWarrior::Abilities::Throw do
3+
describe RubyWarrior::Abilities::Detonate do
44
before(:each) do
55
@floor = RubyWarrior::Floor.new
66
@floor.width = 3
77
@floor.height = 3
88
@warrior = RubyWarrior::Units::Warrior.new
99
@floor.add(@warrior, 0, 0, :south)
10-
@throw = RubyWarrior::Abilities::Throw.new(@warrior)
10+
@detonate = RubyWarrior::Abilities::Detonate.new(@warrior)
1111
end
1212

13-
it "should subtract 4 from unit two spaces forward and 2 from units surrounding that space" do
13+
it "should subtract 8 from forward unit and 4 from surrounding units" do
1414
target_unit = RubyWarrior::Units::Base.new
1515
target_unit.health = 15
1616
second_unit = RubyWarrior::Units::Base.new
1717
second_unit.health = 15
18-
@floor.add(target_unit, 0, 2)
19-
@floor.add(second_unit, 1, 2)
20-
@throw.perform
21-
target_unit.health.should == 11
22-
second_unit.health.should == 13
18+
@floor.add(target_unit, 0, 1)
19+
@floor.add(second_unit, 1, 1)
20+
@detonate.perform
21+
target_unit.health.should == 7
22+
second_unit.health.should == 11
2323
end
2424

25-
it "should subtract 4 from unit two spaces left and 2 from units surrounding that space" do
25+
it "should subtract 8 from left unit and 4 from surrounding units" do
2626
target_unit = RubyWarrior::Units::Base.new
2727
target_unit.health = 15
2828
second_unit = RubyWarrior::Units::Base.new
2929
second_unit.health = 15
30-
@floor.add(target_unit, 2, 0)
31-
@floor.add(second_unit, 2, 1)
32-
@throw.perform(:left)
33-
target_unit.health.should == 11
34-
second_unit.health.should == 13
30+
@floor.add(target_unit, 1, 0)
31+
@floor.add(second_unit, 1, 1)
32+
@detonate.perform(:left)
33+
target_unit.health.should == 7
34+
second_unit.health.should == 11
3535
end
3636

3737
it "should detonate an explosive if any unit has one" do
3838
captive = RubyWarrior::Units::Captive.new
3939
captive.health = 1
4040
captive.add_abilities :explode!
41-
@floor.add(captive, 1, 2)
42-
@throw.perform
41+
@floor.add(captive, 1, 1)
42+
@detonate.perform
4343
captive.health.should == -99
4444
@warrior.health.should == -80
4545
end

0 commit comments

Comments
 (0)