rubywarrior 0.1.3 → 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} +11 -4
- data/Gemfile +4 -2
- data/Gemfile.lock +44 -25
- data/LICENSE +4 -4
- data/{README.rdoc → README.md} +115 -93
- data/bin/rubywarrior +1 -1
- data/features/step_definitions/common_steps.rb +2 -2
- data/features/step_definitions/interaction_steps.rb +2 -2
- data/lib/ruby_warrior/game.rb +4 -2
- data/lib/ruby_warrior/player_generator.rb +2 -2
- data/rubywarrior.gemspec +16 -0
- data/spec/ruby_warrior/abilities/attack_spec.rb +9 -9
- data/spec/ruby_warrior/abilities/base_spec.rb +18 -18
- data/spec/ruby_warrior/abilities/bind_spec.rb +4 -4
- data/spec/ruby_warrior/abilities/direction_of_spec.rb +2 -2
- data/spec/ruby_warrior/abilities/direction_of_stairs_spec.rb +2 -2
- data/spec/ruby_warrior/abilities/distance_of_spec.rb +2 -2
- data/spec/ruby_warrior/abilities/explode_spec.rb +6 -6
- data/spec/ruby_warrior/abilities/form_spec.rb +13 -13
- data/spec/ruby_warrior/abilities/health_spec.rb +2 -2
- data/spec/ruby_warrior/abilities/listen_spec.rb +2 -2
- data/spec/ruby_warrior/abilities/look_spec.rb +2 -2
- data/spec/ruby_warrior/abilities/rescue_spec.rb +7 -7
- data/spec/ruby_warrior/abilities/rest_spec.rb +6 -6
- data/spec/ruby_warrior/abilities/shoot_spec.rb +3 -3
- data/spec/ruby_warrior/abilities/throw_spec.rb +9 -9
- data/spec/ruby_warrior/abilities/walk_spec.rb +4 -4
- data/spec/ruby_warrior/core_additions_spec.rb +1 -1
- data/spec/ruby_warrior/floor_spec.rb +26 -26
- data/spec/ruby_warrior/game_spec.rb +34 -34
- data/spec/ruby_warrior/level_loader_spec.rb +18 -18
- data/spec/ruby_warrior/level_spec.rb +56 -56
- data/spec/ruby_warrior/player_generator_spec.rb +2 -2
- data/spec/ruby_warrior/position_spec.rb +42 -42
- data/spec/ruby_warrior/profile_spec.rb +57 -57
- data/spec/ruby_warrior/space_spec.rb +70 -70
- data/spec/ruby_warrior/tower_spec.rb +4 -4
- data/spec/ruby_warrior/turn_spec.rb +12 -12
- data/spec/ruby_warrior/ui_spec.rb +31 -31
- data/spec/ruby_warrior/units/archer_spec.rb +8 -8
- data/spec/ruby_warrior/units/base_spec.rb +41 -41
- data/spec/ruby_warrior/units/captive_spec.rb +8 -8
- data/spec/ruby_warrior/units/golem_spec.rb +8 -8
- data/spec/ruby_warrior/units/sludge_spec.rb +10 -10
- data/spec/ruby_warrior/units/thick_sludge_spec.rb +6 -6
- data/spec/ruby_warrior/units/warrior_spec.rb +22 -22
- data/spec/ruby_warrior/units/wizard_spec.rb +8 -8
- data/spec/spec_helper.rb +1 -0
- metadata +32 -33
@@ -5,34 +5,34 @@ describe RubyWarrior::Abilities::Base 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
|
@@ -4,16 +4,16 @@ 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
|
@@ -5,9 +5,9 @@ describe RubyWarrior::Abilities::DirectionOf 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
|
@@ -5,9 +5,9 @@ describe RubyWarrior::Abilities::DirectionOfStairs 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
|
@@ -5,9 +5,9 @@ describe RubyWarrior::Abilities::DistanceOf 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
|
@@ -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
|
@@ -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
|
@@ -5,9 +5,9 @@ describe RubyWarrior::Abilities::Health 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
|
@@ -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
|
@@ -5,11 +5,11 @@ describe RubyWarrior::Abilities::Look 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
|
@@ -5,7 +5,7 @@ describe RubyWarrior::Abilities::Rescue 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
|
@@ -5,25 +5,25 @@ describe RubyWarrior::Abilities::Rest 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
|
@@ -5,7 +5,7 @@ describe RubyWarrior::Abilities::Shoot 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
|
@@ -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
|
@@ -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
|
@@ -7,75 +7,75 @@ describe RubyWarrior::Floor do
|
|
7
7
|
@floor.width = 2
|
8
8
|
@floor.height = 3
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
it "should be able to add a unit and fetch it at that position" do
|
12
12
|
unit = RubyWarrior::Units::Base.new
|
13
13
|
@floor.add(unit, 0, 1, :north)
|
14
|
-
@floor.get(0, 1).
|
14
|
+
expect(@floor.get(0, 1)).to eq(unit)
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
it "should not consider unit on floor if no position" do
|
18
18
|
unit = RubyWarrior::Units::Base.new
|
19
19
|
@floor.add(unit, 0, 1, :north)
|
20
20
|
unit.position = nil
|
21
|
-
@floor.units.
|
21
|
+
expect(@floor.units).to_not include(unit)
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
it "should fetch other units not warrior" do
|
25
25
|
unit = RubyWarrior::Units::Base.new
|
26
26
|
warrior = RubyWarrior::Units::Warrior.new
|
27
27
|
@floor.add(unit, 0, 0, :north)
|
28
28
|
@floor.add(warrior, 1, 0, :north)
|
29
|
-
@floor.other_units.
|
30
|
-
@floor.other_units.
|
29
|
+
expect(@floor.other_units).to_not include(warrior)
|
30
|
+
expect(@floor.other_units).to include(unit)
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
it "should not consider corners out of bounds" do
|
34
|
-
@floor.
|
35
|
-
@floor.
|
36
|
-
@floor.
|
37
|
-
@floor.
|
34
|
+
expect(@floor).to_not be_out_of_bounds(0, 0)
|
35
|
+
expect(@floor).to_not be_out_of_bounds(1, 0)
|
36
|
+
expect(@floor).to_not be_out_of_bounds(1, 2)
|
37
|
+
expect(@floor).to_not be_out_of_bounds(0, 2)
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
it "should consider out of bounds when going beyond sides" do
|
41
|
-
@floor.
|
42
|
-
@floor.
|
43
|
-
@floor.
|
44
|
-
@floor.
|
41
|
+
expect(@floor).to be_out_of_bounds(-1, 0)
|
42
|
+
expect(@floor).to be_out_of_bounds(0, -1)
|
43
|
+
expect(@floor).to be_out_of_bounds(0, 3)
|
44
|
+
expect(@floor).to be_out_of_bounds(2, 0)
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
it "should return space at the specified location" do
|
48
|
-
@floor.space(0, 0).
|
48
|
+
expect(@floor.space(0, 0)).to be_kind_of(RubyWarrior::Space)
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
it "should place stairs and be able to fetch the location" do
|
52
52
|
@floor.place_stairs(1, 2)
|
53
|
-
@floor.stairs_location.
|
53
|
+
expect(@floor.stairs_location).to eq([1, 2])
|
54
54
|
end
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
describe "3x1" do
|
58
58
|
before(:each) do
|
59
59
|
@floor = RubyWarrior::Floor.new
|
60
60
|
@floor.width = 3
|
61
61
|
@floor.height = 1
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
it "should print map with stairs and unit" do
|
65
65
|
@floor.add(RubyWarrior::Units::Warrior.new, 0, 0)
|
66
66
|
@floor.place_stairs(2, 0)
|
67
|
-
@floor.character.
|
67
|
+
expect(@floor.character).to eq(<<-MAP)
|
68
68
|
---
|
69
69
|
|@ >|
|
70
70
|
---
|
71
71
|
MAP
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
it "should return unique units" do
|
75
75
|
u1 = RubyWarrior::Units::Base.new
|
76
76
|
@floor.add(u1, 0, 0)
|
77
77
|
@floor.add(RubyWarrior::Units::Base.new, 1, 0)
|
78
|
-
@floor.unique_units.
|
78
|
+
expect(@floor.unique_units).to eq([u1])
|
79
79
|
end
|
80
80
|
end
|
81
81
|
end
|