-
Notifications
You must be signed in to change notification settings - Fork 835
/
Copy paththrow_spec.rb
46 lines (42 loc) · 1.37 KB
/
throw_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
require 'spec_helper'
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)
@detonate = RubyWarrior::Abilities::Detonate.new(@warrior)
end
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, 1)
@floor.add(second_unit, 1, 1)
@detonate.perform
target_unit.health.should == 7
second_unit.health.should == 11
end
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, 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, 1)
@detonate.perform
captive.health.should == 0
@warrior.health.should == 0
end
end