rubywarrior 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/{CHANGELOG.rdoc → CHANGELOG.md} +21 -3
- data/Gemfile +10 -0
- data/Gemfile.lock +55 -0
- data/LICENSE +4 -4
- data/{README.rdoc → README.md} +115 -93
- data/Rakefile +4 -9
- data/bin/rubywarrior +1 -1
- data/features/step_definitions/common_steps.rb +2 -2
- data/features/step_definitions/interaction_steps.rb +7 -7
- data/features/support/env.rb +1 -1
- data/lib/ruby_warrior/game.rb +5 -3
- data/lib/ruby_warrior/level.rb +5 -1
- data/lib/ruby_warrior/player_generator.rb +3 -3
- data/lib/ruby_warrior/profile.rb +1 -1
- data/lib/ruby_warrior/tower.rb +1 -1
- data/rubywarrior.gemspec +16 -0
- data/spec/ruby_warrior/abilities/attack_spec.rb +10 -10
- data/spec/ruby_warrior/abilities/base_spec.rb +19 -19
- data/spec/ruby_warrior/abilities/bind_spec.rb +5 -5
- data/spec/ruby_warrior/abilities/direction_of_spec.rb +3 -3
- data/spec/ruby_warrior/abilities/direction_of_stairs_spec.rb +3 -3
- data/spec/ruby_warrior/abilities/distance_of_spec.rb +3 -3
- data/spec/ruby_warrior/abilities/explode_spec.rb +7 -7
- data/spec/ruby_warrior/abilities/feel_spec.rb +1 -1
- data/spec/ruby_warrior/abilities/form_spec.rb +14 -14
- data/spec/ruby_warrior/abilities/health_spec.rb +3 -3
- data/spec/ruby_warrior/abilities/listen_spec.rb +3 -3
- data/spec/ruby_warrior/abilities/look_spec.rb +3 -3
- data/spec/ruby_warrior/abilities/pivot_spec.rb +1 -1
- data/spec/ruby_warrior/abilities/rescue_spec.rb +8 -8
- data/spec/ruby_warrior/abilities/rest_spec.rb +7 -7
- data/spec/ruby_warrior/abilities/shoot_spec.rb +4 -4
- data/spec/ruby_warrior/abilities/throw_spec.rb +10 -10
- data/spec/ruby_warrior/abilities/walk_spec.rb +5 -5
- data/spec/ruby_warrior/core_additions_spec.rb +2 -2
- data/spec/ruby_warrior/floor_spec.rb +27 -27
- data/spec/ruby_warrior/game_spec.rb +36 -36
- data/spec/ruby_warrior/level_loader_spec.rb +19 -19
- data/spec/ruby_warrior/level_spec.rb +57 -57
- data/spec/ruby_warrior/player_generator_spec.rb +3 -3
- data/spec/ruby_warrior/position_spec.rb +43 -43
- data/spec/ruby_warrior/profile_spec.rb +59 -59
- data/spec/ruby_warrior/space_spec.rb +71 -71
- data/spec/ruby_warrior/tower_spec.rb +5 -5
- data/spec/ruby_warrior/turn_spec.rb +13 -13
- data/spec/ruby_warrior/ui_spec.rb +32 -32
- data/spec/ruby_warrior/units/archer_spec.rb +9 -9
- data/spec/ruby_warrior/units/base_spec.rb +42 -42
- data/spec/ruby_warrior/units/captive_spec.rb +9 -9
- data/spec/ruby_warrior/units/golem_spec.rb +9 -9
- data/spec/ruby_warrior/units/sludge_spec.rb +11 -11
- data/spec/ruby_warrior/units/thick_sludge_spec.rb +7 -7
- data/spec/ruby_warrior/units/warrior_spec.rb +23 -23
- data/spec/ruby_warrior/units/wizard_spec.rb +9 -9
- data/spec/spec_helper.rb +3 -2
- data/towers/beginner/level_002.rb +1 -1
- data/towers/beginner/level_003.rb +1 -1
- data/towers/beginner/level_005.rb +2 -2
- data/towers/beginner/level_006.rb +2 -2
- data/towers/intermediate/level_002.rb +1 -1
- data/towers/intermediate/level_003.rb +2 -2
- metadata +47 -67
@@ -1,37 +1,37 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyWarrior::Abilities::Attack do
|
4
4
|
before(:each) do
|
5
5
|
@attacker = stub(:position => stub, :attack_power => 3, :say => nil)
|
6
6
|
@attack = RubyWarrior::Abilities::Attack.new(@attacker)
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
it "should subtract attack power amount from health" do
|
10
10
|
receiver = RubyWarrior::Units::Base.new
|
11
11
|
receiver.stubs(:alive?).returns(true)
|
12
12
|
receiver.health = 5
|
13
13
|
@attack.stubs(:unit).returns(receiver)
|
14
14
|
@attack.perform
|
15
|
-
receiver.health.
|
15
|
+
expect(receiver.health).to eq(2)
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
it "should do nothing if recipient is nil" do
|
19
19
|
@attack.stubs(:unit).returns(nil)
|
20
|
-
|
20
|
+
expect { @attack.perform }.to_not raise_error
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
it "should get object at position from offset" do
|
24
24
|
@attacker.position.expects(:relative_space).with(1, 0)
|
25
25
|
@attack.space(:forward)
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
it "should award points when killing unit" do
|
29
29
|
receiver = stub(:take_damage => nil, :max_health => 8, :alive? => false)
|
30
30
|
@attack.stubs(:unit).returns(receiver)
|
31
31
|
@attacker.expects(:earn_points).with(8)
|
32
32
|
@attack.perform
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
it "should not award points when not killing unit" do
|
36
36
|
receiver = stub(:max_health => 8, :alive? => true)
|
37
37
|
receiver.expects(:take_damage)
|
@@ -39,13 +39,13 @@ describe RubyWarrior::Abilities::Attack do
|
|
39
39
|
@attacker.expects(:earn_points).never
|
40
40
|
@attack.perform
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
it "should reduce attack power when attacking backward" do
|
44
44
|
receiver = RubyWarrior::Units::Base.new
|
45
45
|
receiver.stubs(:alive?).returns(true)
|
46
46
|
receiver.health = 5
|
47
47
|
@attack.stubs(:unit).returns(receiver)
|
48
48
|
@attack.perform(:backward)
|
49
|
-
receiver.health.
|
49
|
+
expect(receiver.health).to eq(3)
|
50
50
|
end
|
51
51
|
end
|
@@ -1,38 +1,38 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyWarrior::Abilities::Base do
|
4
4
|
before(:each) do
|
5
5
|
@unit = stub
|
6
6
|
@ability = RubyWarrior::Abilities::Base.new(@unit)
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
it "should have offset for directions" do
|
10
|
-
@ability.offset(:forward).
|
11
|
-
@ability.offset(:right).
|
12
|
-
@ability.offset(:backward).
|
13
|
-
@ability.offset(:left).
|
10
|
+
expect(@ability.offset(:forward)).to eq([1, 0])
|
11
|
+
expect(@ability.offset(:right)).to eq([0, 1])
|
12
|
+
expect(@ability.offset(:backward)).to eq([-1, 0])
|
13
|
+
expect(@ability.offset(:left)).to eq([0, -1])
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
it "should have offset for relative forward/right amounts" do
|
17
|
-
@ability.offset(:forward, 2).
|
18
|
-
@ability.offset(:forward, 2, 1).
|
19
|
-
@ability.offset(:right, 2, 1).
|
20
|
-
@ability.offset(:backward, 2, 1).
|
21
|
-
@ability.offset(:left, 2, 1).
|
17
|
+
expect(@ability.offset(:forward, 2)).to eq([2, 0])
|
18
|
+
expect(@ability.offset(:forward, 2, 1)).to eq([2, -1])
|
19
|
+
expect(@ability.offset(:right, 2, 1)).to eq([1, 2])
|
20
|
+
expect(@ability.offset(:backward, 2, 1)).to eq([-2, 1])
|
21
|
+
expect(@ability.offset(:left, 2, 1)).to eq([-1, -2])
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
it "should fetch unit at given direction with distance" do
|
25
25
|
@ability.expects(:space).with(:right, 3, 1).returns(stub(:unit => 'unit'))
|
26
|
-
@ability.unit(:right, 3, 1).
|
26
|
+
expect(@ability.unit(:right, 3, 1)).to eq('unit')
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
it "should have no description" do
|
30
|
-
@ability.description.
|
30
|
+
expect(@ability.description).to be_nil
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
it "should raise an exception if direction isn't recognized" do
|
34
|
-
|
34
|
+
expect {
|
35
35
|
@ability.verify_direction(:foo)
|
36
|
-
}.
|
36
|
+
}.to raise_error("Unknown direction :foo. Should be :forward, :backward, :left or :right.")
|
37
37
|
end
|
38
38
|
end
|
@@ -1,19 +1,19 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyWarrior::Abilities::Bind do
|
4
4
|
before(:each) do
|
5
5
|
@bind = RubyWarrior::Abilities::Bind.new(stub(:say => nil))
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
it "should bind recipient" do
|
9
9
|
receiver = RubyWarrior::Units::Base.new
|
10
10
|
@bind.stubs(:unit).returns(receiver)
|
11
11
|
@bind.perform
|
12
|
-
receiver.
|
12
|
+
expect(receiver).to be_bound
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
it "should do nothing if no recipient" do
|
16
16
|
@bind.stubs(:unit).returns(nil)
|
17
|
-
|
17
|
+
expect { @bind.perform }.to_not raise_error
|
18
18
|
end
|
19
19
|
end
|
@@ -1,13 +1,13 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyWarrior::Abilities::DirectionOf do
|
4
4
|
before(:each) do
|
5
5
|
@position = stub
|
6
6
|
@distance = RubyWarrior::Abilities::DirectionOf.new(stub(:position => @position, :say => nil))
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
it "should return relative direction of given space" do
|
10
10
|
@position.stubs(:relative_direction_of).with(:space).returns(:left)
|
11
|
-
@distance.perform(:space).
|
11
|
+
expect(@distance.perform(:space)).to eq(:left)
|
12
12
|
end
|
13
13
|
end
|
@@ -1,13 +1,13 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyWarrior::Abilities::DirectionOfStairs do
|
4
4
|
before(:each) do
|
5
5
|
@position = stub
|
6
6
|
@distance = RubyWarrior::Abilities::DirectionOfStairs.new(stub(:position => @position, :say => nil))
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
it "should return relative direction of stairs" do
|
10
10
|
@position.stubs(:relative_direction_of_stairs).returns(:left)
|
11
|
-
@distance.perform.
|
11
|
+
expect(@distance.perform).to eq(:left)
|
12
12
|
end
|
13
13
|
end
|
@@ -1,13 +1,13 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyWarrior::Abilities::DistanceOf do
|
4
4
|
before(:each) do
|
5
5
|
@position = stub
|
6
6
|
@distance = RubyWarrior::Abilities::DistanceOf.new(stub(:position => @position, :say => nil))
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
it "should return distance from stairs" do
|
10
10
|
@position.stubs(:distance_of).with(:space).returns(5)
|
11
|
-
@distance.perform(:space).
|
11
|
+
expect(@distance.perform(:space)).to eq(5)
|
12
12
|
end
|
13
13
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyWarrior::Abilities::Explode do
|
4
4
|
before(:each) do
|
@@ -9,24 +9,24 @@ describe RubyWarrior::Abilities::Explode do
|
|
9
9
|
@floor.add(@captive, 0, 0)
|
10
10
|
@explode = RubyWarrior::Abilities::Explode.new(@captive)
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
it "should subtract 100 health from each unit on the floor" do
|
14
14
|
unit = RubyWarrior::Units::Base.new
|
15
15
|
unit.health = 20
|
16
16
|
@floor.add(unit, 0, 1)
|
17
17
|
@captive.health = 10
|
18
18
|
@explode.perform
|
19
|
-
@captive.health.
|
20
|
-
unit.health.
|
19
|
+
expect(@captive.health).to eq(-90)
|
20
|
+
expect(unit.health).to eq(-80)
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
it "should explode when bomb time reaches zero" do
|
24
24
|
@captive.health = 10
|
25
25
|
@explode.time = 3
|
26
26
|
@explode.pass_turn
|
27
27
|
@explode.pass_turn
|
28
|
-
@captive.health.
|
28
|
+
expect(@captive.health).to eq(10)
|
29
29
|
@explode.pass_turn
|
30
|
-
@captive.health.
|
30
|
+
expect(@captive.health).to eq(-90)
|
31
31
|
end
|
32
32
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyWarrior::Abilities::Form do
|
4
4
|
before(:each) do
|
@@ -9,40 +9,40 @@ describe RubyWarrior::Abilities::Form do
|
|
9
9
|
@floor.add(@warrior, 0, 0, :east)
|
10
10
|
@form = RubyWarrior::Abilities::Form.new(@warrior)
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
it "should form a golem in front of warrior" do
|
14
14
|
@form.perform
|
15
|
-
@floor.get(1, 0).
|
15
|
+
expect(@floor.get(1, 0)).to be_kind_of(RubyWarrior::Units::Golem)
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
it "should form a golem in given direction" do
|
19
19
|
@form.perform(:right)
|
20
|
-
@floor.get(0, 1).
|
20
|
+
expect(@floor.get(0, 1)).to be_kind_of(RubyWarrior::Units::Golem)
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
it "should not form golem if space isn't empty" do
|
24
24
|
@floor.add(RubyWarrior::Units::Base.new, 1, 0)
|
25
25
|
@form.perform(:forward)
|
26
26
|
@form.perform(:left)
|
27
|
-
@floor.units.size.
|
27
|
+
expect(@floor.units.size).to eq(2)
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
it "should reduce warrior's health by half (rounding down) and give it to the golem" do
|
31
31
|
@warrior.health = 19
|
32
32
|
@form.perform
|
33
|
-
@warrior.health.
|
34
|
-
@floor.get(1, 0).max_health.
|
33
|
+
expect(@warrior.health).to eq(10)
|
34
|
+
expect(@floor.get(1, 0).max_health).to eq(9)
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
it "should add passed block as golem's turn block" do
|
38
38
|
@passed = nil
|
39
39
|
@form.perform(:forward) { |turn| @passed = turn }
|
40
40
|
@floor.get(1, 0).play_turn(:turn)
|
41
|
-
@passed.
|
41
|
+
expect(@passed).to eq(:turn)
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
it "should start in same direction as warrior" do
|
45
45
|
@form.perform(:right)
|
46
|
-
@floor.get(0, 1).position.direction.
|
46
|
+
expect(@floor.get(0, 1).position.direction).to eq(:east)
|
47
47
|
end
|
48
48
|
end
|
@@ -1,13 +1,13 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyWarrior::Abilities::Health do
|
4
4
|
before(:each) do
|
5
5
|
@warrior = RubyWarrior::Units::Warrior.new
|
6
6
|
@health = RubyWarrior::Abilities::Health.new(@warrior)
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
it "should return the amount of health" do
|
10
10
|
@warrior.health = 10
|
11
|
-
@health.perform.
|
11
|
+
expect(@health.perform).to eq(10)
|
12
12
|
end
|
13
13
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyWarrior::Abilities::Listen do
|
4
4
|
before(:each) do
|
@@ -9,9 +9,9 @@ describe RubyWarrior::Abilities::Listen do
|
|
9
9
|
@floor.add(@warrior, 0, 0)
|
10
10
|
@listen = RubyWarrior::Abilities::Listen.new(@warrior)
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
it "should return an array of spaces which have units on them besides main unit" do
|
14
14
|
@floor.add(RubyWarrior::Units::Base.new, 0, 1)
|
15
|
-
@listen.perform.
|
15
|
+
expect(@listen.perform.size).to eq(1)
|
16
16
|
end
|
17
17
|
end
|
@@ -1,15 +1,15 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyWarrior::Abilities::Look do
|
4
4
|
before(:each) do
|
5
5
|
@unit = stub(:position => stub, :say => nil)
|
6
6
|
@feel = RubyWarrior::Abilities::Look.new(@unit)
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
it "should get 3 objects at position from offset" do
|
10
10
|
@unit.position.expects(:relative_space).with(1, 0).returns(1)
|
11
11
|
@unit.position.expects(:relative_space).with(2, 0).returns(2)
|
12
12
|
@unit.position.expects(:relative_space).with(3, 0).returns(3)
|
13
|
-
@feel.perform(:forward).
|
13
|
+
expect(@feel.perform(:forward)).to eq([1, 2, 3])
|
14
14
|
end
|
15
15
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyWarrior::Abilities::Rescue do
|
4
4
|
before(:each) do
|
5
5
|
@warrior = RubyWarrior::Units::Warrior.new
|
6
6
|
@rescue = RubyWarrior::Abilities::Rescue.new(@warrior)
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
it "should rescue captive" do
|
10
10
|
captive = RubyWarrior::Units::Captive.new
|
11
11
|
captive.position = stub
|
@@ -13,9 +13,9 @@ describe RubyWarrior::Abilities::Rescue do
|
|
13
13
|
@rescue.expects(:unit).with(:forward).returns(captive)
|
14
14
|
@warrior.expects(:earn_points).with(20)
|
15
15
|
@rescue.perform
|
16
|
-
captive.position.
|
16
|
+
expect(captive.position).to be_nil
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
it "should do nothing to other unit if not bound" do
|
20
20
|
unit = RubyWarrior::Units::Base.new
|
21
21
|
unit.position = stub
|
@@ -23,9 +23,9 @@ describe RubyWarrior::Abilities::Rescue do
|
|
23
23
|
@rescue.expects(:unit).with(:forward).never
|
24
24
|
@warrior.expects(:earn_points).never
|
25
25
|
@rescue.perform
|
26
|
-
unit.position.
|
26
|
+
expect(unit.position).to_not be_nil
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
it "should release other unit when bound" do
|
30
30
|
unit = RubyWarrior::Units::Base.new
|
31
31
|
unit.bind
|
@@ -34,7 +34,7 @@ describe RubyWarrior::Abilities::Rescue do
|
|
34
34
|
@rescue.expects(:unit).with(:forward).returns(unit)
|
35
35
|
@warrior.expects(:earn_points).never
|
36
36
|
@rescue.perform
|
37
|
-
unit.
|
38
|
-
unit.position.
|
37
|
+
expect(unit).to_not be_bound
|
38
|
+
expect(unit.position).to_not be_nil
|
39
39
|
end
|
40
40
|
end
|
@@ -1,29 +1,29 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyWarrior::Abilities::Rest do
|
4
4
|
before(:each) do
|
5
5
|
@warrior = RubyWarrior::Units::Warrior.new
|
6
6
|
@rest = RubyWarrior::Abilities::Rest.new(@warrior)
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
it "should give 10% health back" do
|
10
10
|
@warrior.stubs(:max_health).returns(20)
|
11
11
|
@warrior.health = 10
|
12
12
|
@rest.perform
|
13
|
-
@warrior.health.
|
13
|
+
expect(@warrior.health).to eq(12)
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
it "should add health when at max" do
|
17
17
|
@warrior.stubs(:max_health).returns(20)
|
18
18
|
@warrior.health = 20
|
19
19
|
@rest.perform
|
20
|
-
@warrior.health.
|
20
|
+
expect(@warrior.health).to eq(20)
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
it "should not go over max health" do
|
24
24
|
@warrior.stubs(:max_health).returns(20)
|
25
25
|
@warrior.health = 19
|
26
26
|
@rest.perform
|
27
|
-
@warrior.health.
|
27
|
+
expect(@warrior.health).to eq(20)
|
28
28
|
end
|
29
29
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyWarrior::Abilities::Shoot do
|
4
4
|
before(:each) do
|
5
5
|
@shooter = stub(:position => stub, :shoot_power => 2, :say => nil)
|
6
6
|
@shoot = RubyWarrior::Abilities::Shoot.new(@shooter)
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
it "should shoot only first unit" do
|
10
10
|
receiver = stub(:alive? => true)
|
11
11
|
receiver.expects(:take_damage).with(2)
|
@@ -14,9 +14,9 @@ describe RubyWarrior::Abilities::Shoot do
|
|
14
14
|
@shoot.expects(:multi_unit).with(:forward, anything).returns([nil, receiver, other, nil])
|
15
15
|
@shoot.perform
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
it "should shoot and do nothing if no units in the way" do
|
19
19
|
@shoot.expects(:multi_unit).with(:forward, anything).returns([nil, nil])
|
20
|
-
|
20
|
+
expect { @shoot.perform }.to_not raise_error
|
21
21
|
end
|
22
22
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyWarrior::Abilities::Detonate do
|
4
4
|
before(:each) do
|
@@ -9,7 +9,7 @@ describe RubyWarrior::Abilities::Detonate do
|
|
9
9
|
@floor.add(@warrior, 0, 0, :south)
|
10
10
|
@detonate = RubyWarrior::Abilities::Detonate.new(@warrior)
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
it "should subtract 8 from forward unit and 4 from surrounding units" do
|
14
14
|
target_unit = RubyWarrior::Units::Base.new
|
15
15
|
target_unit.health = 15
|
@@ -18,10 +18,10 @@ describe RubyWarrior::Abilities::Detonate do
|
|
18
18
|
@floor.add(target_unit, 0, 1)
|
19
19
|
@floor.add(second_unit, 1, 1)
|
20
20
|
@detonate.perform
|
21
|
-
target_unit.health.
|
22
|
-
second_unit.health.
|
21
|
+
expect(target_unit.health).to eq(7)
|
22
|
+
expect(second_unit.health).to eq(11)
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
it "should subtract 8 from left unit and 4 from surrounding units" do
|
26
26
|
target_unit = RubyWarrior::Units::Base.new
|
27
27
|
target_unit.health = 15
|
@@ -30,17 +30,17 @@ describe RubyWarrior::Abilities::Detonate do
|
|
30
30
|
@floor.add(target_unit, 1, 0)
|
31
31
|
@floor.add(second_unit, 1, 1)
|
32
32
|
@detonate.perform(:left)
|
33
|
-
target_unit.health.
|
34
|
-
second_unit.health.
|
33
|
+
expect(target_unit.health).to eq(7)
|
34
|
+
expect(second_unit.health).to eq(11)
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
it "should detonate an explosive if any unit has one" do
|
38
38
|
captive = RubyWarrior::Units::Captive.new
|
39
39
|
captive.health = 1
|
40
40
|
captive.add_abilities :explode!
|
41
41
|
@floor.add(captive, 1, 1)
|
42
42
|
@detonate.perform
|
43
|
-
captive.health.
|
44
|
-
@warrior.health.
|
43
|
+
expect(captive.health).to eq(-99)
|
44
|
+
expect(@warrior.health).to eq(-80)
|
45
45
|
end
|
46
46
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyWarrior::Abilities::Walk do
|
4
4
|
before(:each) do
|
@@ -6,20 +6,20 @@ describe RubyWarrior::Abilities::Walk do
|
|
6
6
|
@position = stub(:relative_space => @space, :move => nil)
|
7
7
|
@walk = RubyWarrior::Abilities::Walk.new(stub(:position => @position, :say => nil))
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
it "should move position forward when calling perform" do
|
11
11
|
@position.expects(:move).with(1, 0)
|
12
12
|
@walk.perform
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
it "should move position right if that is direction" do
|
16
16
|
@position.expects(:move).with(0, 1)
|
17
17
|
@walk.perform(:right)
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
it "should keep position if something is in the way" do
|
21
21
|
@position.stubs(:move).raises("shouldn't be called")
|
22
22
|
@space.stubs(:empty?).returns(false)
|
23
|
-
|
23
|
+
expect { @walk.perform(:right) }.to_not raise_error
|
24
24
|
end
|
25
25
|
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe String do
|
4
4
|
it "should wrap text at white space when over a specific character length" do
|
5
|
-
"foo bar blah".hard_wrap(10).
|
5
|
+
expect("foo bar blah".hard_wrap(10)).to eq("foo bar\nblah")
|
6
6
|
end
|
7
7
|
end
|