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,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyWarrior::Position do
|
4
4
|
before(:each) do
|
@@ -9,100 +9,100 @@ describe RubyWarrior::Position do
|
|
9
9
|
@floor.add(@unit, 1, 2, :north)
|
10
10
|
@position = @unit.position
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
it "should rotate clockwise" do
|
14
|
-
@position.direction.
|
14
|
+
expect(@position.direction).to eq(:north)
|
15
15
|
[:east, :south, :west, :north, :east].each do |dir|
|
16
16
|
@position.rotate(1)
|
17
|
-
@position.direction.
|
17
|
+
expect(@position.direction).to eq(dir)
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
it "should rotate counterclockwise" do
|
22
|
-
@position.direction.
|
22
|
+
expect(@position.direction).to eq(:north)
|
23
23
|
[:west, :south, :east, :north, :west].each do |dir|
|
24
24
|
@position.rotate(-1)
|
25
|
-
@position.direction.
|
25
|
+
expect(@position.direction).to eq(dir)
|
26
26
|
end
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
it "should get relative space in front" do
|
30
30
|
unit = RubyWarrior::Units::Base.new
|
31
31
|
@floor.add(unit, 1, 1)
|
32
|
-
@position.relative_space(1).
|
32
|
+
expect(@position.relative_space(1)).to_not be_empty
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
it "should get relative object in front when rotated" do
|
36
36
|
unit = RubyWarrior::Units::Base.new
|
37
37
|
@floor.add(unit, 2, 2)
|
38
38
|
@position.rotate(1)
|
39
|
-
@position.relative_space(1).
|
39
|
+
expect(@position.relative_space(1)).to_not be_empty
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
it "should get relative object diagonally" do
|
43
43
|
unit = RubyWarrior::Units::Base.new
|
44
44
|
@floor.add(unit, 0, 1)
|
45
|
-
@position.relative_space(1, -1).
|
45
|
+
expect(@position.relative_space(1, -1)).to_not be_empty
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
it "should get relative object diagonally when rotating" do
|
49
49
|
unit = RubyWarrior::Units::Base.new
|
50
50
|
@floor.add(unit, 0, 1)
|
51
51
|
@position.rotate(2)
|
52
|
-
@position.relative_space(-1, 1).
|
52
|
+
expect(@position.relative_space(-1, 1)).to_not be_empty
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
it "should move object on floor relatively" do
|
56
|
-
@floor.get(1, 2).
|
56
|
+
expect(@floor.get(1, 2)).to eq(@unit)
|
57
57
|
@position.move(-1, 2)
|
58
|
-
@floor.get(1, 2).
|
59
|
-
@floor.get(3, 3).
|
58
|
+
expect(@floor.get(1, 2)).to be_nil
|
59
|
+
expect(@floor.get(3, 3)).to eq(@unit)
|
60
60
|
@position.rotate(1)
|
61
61
|
@position.move(-1)
|
62
|
-
@floor.get(3, 3).
|
63
|
-
@floor.get(2, 3).
|
62
|
+
expect(@floor.get(3, 3)).to be_nil
|
63
|
+
expect(@floor.get(2, 3)).to eq(@unit)
|
64
64
|
end
|
65
|
-
|
65
|
+
|
66
66
|
it "should return distance from stairs as 0 when on stairs" do
|
67
67
|
@floor.place_stairs(1, 2)
|
68
|
-
@position.distance_from_stairs.
|
68
|
+
expect(@position.distance_from_stairs).to eq(0)
|
69
69
|
end
|
70
|
-
|
70
|
+
|
71
71
|
it "should return distance from stairs in both directions" do
|
72
72
|
@floor.place_stairs(0, 3)
|
73
|
-
@position.distance_from_stairs.
|
73
|
+
expect(@position.distance_from_stairs).to eq(2)
|
74
74
|
end
|
75
|
-
|
75
|
+
|
76
76
|
it "should return relative direction of stairs" do
|
77
77
|
@floor.place_stairs(0, 0)
|
78
|
-
@position.relative_direction_of_stairs.
|
78
|
+
expect(@position.relative_direction_of_stairs).to eq(:forward)
|
79
79
|
end
|
80
|
-
|
80
|
+
|
81
81
|
it "should return relative direction of given space" do
|
82
|
-
@position.relative_direction_of(@floor.space(5, 3)).
|
82
|
+
expect(@position.relative_direction_of(@floor.space(5, 3))).to eq(:right)
|
83
83
|
@position.rotate 1
|
84
|
-
@position.relative_direction_of(@floor.space(1, 4)).
|
84
|
+
expect(@position.relative_direction_of(@floor.space(1, 4))).to eq(:right)
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
it "should be able to determine relative direction" do
|
88
|
-
@position.relative_direction(:north).
|
89
|
-
@position.relative_direction(:south).
|
90
|
-
@position.relative_direction(:west).
|
91
|
-
@position.relative_direction(:east).
|
88
|
+
expect(@position.relative_direction(:north)).to eq(:forward)
|
89
|
+
expect(@position.relative_direction(:south)).to eq(:backward)
|
90
|
+
expect(@position.relative_direction(:west)).to eq(:left)
|
91
|
+
expect(@position.relative_direction(:east)).to eq(:right)
|
92
92
|
@position.rotate 1
|
93
|
-
@position.relative_direction(:north).
|
93
|
+
expect(@position.relative_direction(:north)).to eq(:left)
|
94
94
|
@position.rotate 1
|
95
|
-
@position.relative_direction(:north).
|
95
|
+
expect(@position.relative_direction(:north)).to eq(:backward)
|
96
96
|
@position.rotate 1
|
97
|
-
@position.relative_direction(:north).
|
97
|
+
expect(@position.relative_direction(:north)).to eq(:right)
|
98
98
|
end
|
99
|
-
|
99
|
+
|
100
100
|
it "should return a space at the same location as position" do
|
101
|
-
@position.space.location.
|
101
|
+
expect(@position.space.location).to eq([1, 2])
|
102
102
|
end
|
103
|
-
|
103
|
+
|
104
104
|
it "should return distance of given space" do
|
105
|
-
@position.distance_of(@floor.space(5, 3)).
|
106
|
-
@position.distance_of(@floor.space(4, 2)).
|
105
|
+
expect(@position.distance_of(@floor.space(5, 3))).to eq(5)
|
106
|
+
expect(@position.distance_of(@floor.space(4, 2))).to eq(3)
|
107
107
|
end
|
108
108
|
end
|
@@ -1,83 +1,83 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyWarrior::Profile do
|
4
4
|
before(:each) do
|
5
5
|
@profile = RubyWarrior::Profile.new
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
it "should have warrior name" do
|
9
9
|
@profile.warrior_name = 'Joe'
|
10
|
-
@profile.warrior_name.
|
10
|
+
expect(@profile.warrior_name).to eq('Joe')
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
it "should start level number at 0" do
|
14
|
-
@profile.level_number.
|
14
|
+
expect(@profile.level_number).to be_zero
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
it "should start score at 0 and allow it to increment" do
|
18
|
-
@profile.score.
|
18
|
+
expect(@profile.score).to be_zero
|
19
19
|
@profile.score += 5
|
20
|
-
@profile.score.
|
20
|
+
expect(@profile.score).to eq(5)
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
it "should have no abilities and allow adding" do
|
24
|
-
@profile.abilities.
|
24
|
+
expect(@profile.abilities).to eq([])
|
25
25
|
@profile.abilities += [:foo, :bar]
|
26
|
-
@profile.abilities.
|
26
|
+
expect(@profile.abilities).to eq([:foo, :bar])
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
it "should encode with marshal + base64" do
|
30
|
-
@profile.encode.
|
30
|
+
expect(@profile.encode).to eq(Base64.encode64(Marshal.dump(@profile)))
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
it "should decode with marshal + base64" do
|
34
|
-
RubyWarrior::Profile.decode(@profile.encode).warrior_name.
|
34
|
+
expect(RubyWarrior::Profile.decode(@profile.encode).warrior_name).to eq(@profile.warrior_name)
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
it "load should read file, decode and set player path" do
|
38
38
|
profile = 'profile'
|
39
39
|
profile.expects(:player_path=).with('path/to')
|
40
40
|
File.expects(:read).with('path/to/.profile').returns('encoded_profile')
|
41
41
|
RubyWarrior::Profile.expects(:decode).with('encoded_profile').returns(profile)
|
42
|
-
RubyWarrior::Profile.load('path/to/.profile').
|
42
|
+
expect(RubyWarrior::Profile.load('path/to/.profile')).to eq(profile)
|
43
43
|
end
|
44
44
|
|
45
|
-
|
45
|
+
|
46
46
|
it "should add abilities and remove duplicates" do
|
47
47
|
@profile.add_abilities(:foo, :bar, :blah, :bar)
|
48
|
-
@profile.abilities.
|
48
|
+
expect(@profile.abilities).to eq([:foo, :bar, :blah])
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
it "should fetch new level with current number" do
|
52
52
|
@profile.level_number = 1
|
53
|
-
@profile.current_level.number.
|
53
|
+
expect(@profile.current_level.number).to eq(1)
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should fetch next level" do
|
57
57
|
@profile.level_number = 1
|
58
|
-
@profile.next_level.number.
|
58
|
+
expect(@profile.next_level.number).to eq(2)
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should enable epic mode and reset scores if nil" do
|
62
62
|
@profile.epic_score = nil
|
63
63
|
@profile.current_epic_score = nil
|
64
64
|
@profile.enable_epic_mode
|
65
|
-
@profile.
|
66
|
-
@profile.epic_score.
|
67
|
-
@profile.current_epic_score.
|
65
|
+
expect(@profile).to be_epic
|
66
|
+
expect(@profile.epic_score).to be_zero
|
67
|
+
expect(@profile.current_epic_score).to be_zero
|
68
68
|
end
|
69
|
-
|
69
|
+
|
70
70
|
it "should override epic score with current one if it is higher" do
|
71
71
|
@profile.enable_epic_mode
|
72
|
-
@profile.epic_score.
|
73
|
-
@profile.average_grade.
|
72
|
+
expect(@profile.epic_score).to be_zero
|
73
|
+
expect(@profile.average_grade).to be_nil
|
74
74
|
@profile.current_epic_score = 123
|
75
75
|
@profile.current_epic_grades = { 1 => 0.7, 2 => 0.9 }
|
76
76
|
@profile.update_epic_score
|
77
|
-
@profile.epic_score.
|
78
|
-
@profile.average_grade.
|
77
|
+
expect(@profile.epic_score).to eq(123)
|
78
|
+
expect(@profile.average_grade).to eq(0.8)
|
79
79
|
end
|
80
|
-
|
80
|
+
|
81
81
|
it "should not override epic score with current one if it is lower" do
|
82
82
|
@profile.enable_epic_mode
|
83
83
|
@profile.epic_score = 124
|
@@ -85,20 +85,20 @@ describe RubyWarrior::Profile do
|
|
85
85
|
@profile.current_epic_score = 123
|
86
86
|
@profile.current_epic_grades = { 1 => 0.7, 2 => 0.9 }
|
87
87
|
@profile.update_epic_score
|
88
|
-
@profile.epic_score.
|
89
|
-
@profile.average_grade.
|
88
|
+
expect(@profile.epic_score).to eq(124)
|
89
|
+
expect(@profile.average_grade).to eq(0.9)
|
90
90
|
end
|
91
|
-
|
91
|
+
|
92
92
|
it "should not calculate average grade if no grades are present" do
|
93
93
|
@profile.enable_epic_mode
|
94
94
|
@profile.current_epic_grades = {}
|
95
|
-
@profile.calculate_average_grade.
|
95
|
+
expect(@profile.calculate_average_grade).to be_nil
|
96
96
|
end
|
97
97
|
|
98
98
|
it "should remember current level number as last_level_number" do
|
99
99
|
@profile.level_number = 7
|
100
100
|
@profile.enable_epic_mode
|
101
|
-
@profile.last_level_number.
|
101
|
+
expect(@profile.last_level_number).to eq(7)
|
102
102
|
end
|
103
103
|
|
104
104
|
it "should enable normal mode by clearing epic scores and resetting last level number" do
|
@@ -108,26 +108,26 @@ describe RubyWarrior::Profile do
|
|
108
108
|
@profile.current_epic_grades = { 1 => 100 }
|
109
109
|
@profile.average_grade = "C"
|
110
110
|
@profile.enable_normal_mode
|
111
|
-
@profile.
|
112
|
-
@profile.epic_score.
|
113
|
-
@profile.current_epic_score.
|
114
|
-
@profile.last_level_number.
|
115
|
-
@profile.average_grade.
|
116
|
-
@profile.current_epic_grades.
|
117
|
-
@profile.level_number.
|
111
|
+
expect(@profile).to_not be_epic
|
112
|
+
expect(@profile.epic_score).to be_zero
|
113
|
+
expect(@profile.current_epic_score).to be_zero
|
114
|
+
expect(@profile.last_level_number).to be_nil
|
115
|
+
expect(@profile.average_grade).to be_nil
|
116
|
+
expect(@profile.current_epic_grades).to eq({})
|
117
|
+
expect(@profile.level_number).to eq(7)
|
118
118
|
end
|
119
119
|
|
120
120
|
it "should be no level after epic if last level isn't specified" do
|
121
121
|
@profile.last_level_number = nil
|
122
|
-
@profile.
|
122
|
+
expect(@profile).to_not be_level_after_epic
|
123
123
|
end
|
124
|
-
|
124
|
+
|
125
125
|
describe "with tower path" do
|
126
126
|
before(:each) do
|
127
127
|
@profile.warrior_name = "John Smith"
|
128
128
|
@profile.tower_path = 'path/to/tower'
|
129
129
|
end
|
130
|
-
|
130
|
+
|
131
131
|
it "save should write file with encoded profile" do
|
132
132
|
file = stub
|
133
133
|
file.expects(:write).with('encoded_profile')
|
@@ -135,37 +135,37 @@ describe RubyWarrior::Profile do
|
|
135
135
|
@profile.expects(:encode).returns('encoded_profile')
|
136
136
|
@profile.save
|
137
137
|
end
|
138
|
-
|
138
|
+
|
139
139
|
it "should have a nice string representation" do
|
140
140
|
@profile.warrior_name = 'Joe'
|
141
|
-
@profile.to_s.
|
141
|
+
expect(@profile.to_s).to eq("Joe - tower - level 0 - score 0")
|
142
142
|
end
|
143
|
-
|
143
|
+
|
144
144
|
it "should include epic score in string representation" do
|
145
145
|
@profile.warrior_name = 'Joe'
|
146
146
|
@profile.enable_epic_mode
|
147
|
-
@profile.to_s.
|
147
|
+
expect(@profile.to_s).to eq("Joe - tower - first score 0 - epic score 0")
|
148
148
|
end
|
149
|
-
|
149
|
+
|
150
150
|
it "should include epic score with grade in string representation" do
|
151
151
|
@profile.warrior_name = 'Joe'
|
152
152
|
@profile.enable_epic_mode
|
153
153
|
@profile.average_grade = 0.7
|
154
|
-
@profile.to_s.
|
154
|
+
expect(@profile.to_s).to eq("Joe - tower - first score 0 - epic score 0 (C)")
|
155
155
|
end
|
156
|
-
|
156
|
+
|
157
157
|
it "should guess at the player path" do
|
158
|
-
@profile.player_path.
|
158
|
+
expect(@profile.player_path).to eq('./rubywarrior/john-smith-tower')
|
159
159
|
end
|
160
|
-
|
160
|
+
|
161
161
|
it "should use specified player path" do
|
162
162
|
@profile.player_path = "path/to/player"
|
163
|
-
@profile.player_path.
|
163
|
+
expect(@profile.player_path).to eq("path/to/player")
|
164
164
|
end
|
165
|
-
|
165
|
+
|
166
166
|
it "should load tower from path" do
|
167
|
-
RubyWarrior::Tower.expects(:new).with('
|
168
|
-
@profile.tower.
|
167
|
+
RubyWarrior::Tower.expects(:new).with('tower').returns('tower')
|
168
|
+
expect(@profile.tower).to eq('tower')
|
169
169
|
end
|
170
170
|
end
|
171
171
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyWarrior::Space do
|
4
4
|
before(:each) do
|
@@ -6,185 +6,185 @@ describe RubyWarrior::Space do
|
|
6
6
|
@floor.width = 2
|
7
7
|
@floor.height = 3
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
describe "with empty space" do
|
11
11
|
before(:each) do
|
12
12
|
@space = @floor.space(0, 0)
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
it "should not be enemy" do
|
16
|
-
@space.
|
16
|
+
expect(@space).to_not be_enemy
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
it "should not be warrior" do
|
20
|
-
@space.
|
20
|
+
expect(@space).to_not be_warrior
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
it "should be empty" do
|
24
|
-
@space.
|
24
|
+
expect(@space).to be_empty
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
it "should not be wall" do
|
28
|
-
@space.
|
28
|
+
expect(@space).to_not be_wall
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
it "should not be stairs" do
|
32
|
-
@space.
|
32
|
+
expect(@space).to_not be_stairs
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
it "should not be captive" do
|
36
|
-
@space.
|
36
|
+
expect(@space).to_not be_captive
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
it "should say 'nothing' as name" do
|
40
|
-
@space.to_s.
|
40
|
+
expect(@space.to_s).to eq('nothing')
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
it "should not be ticking" do
|
44
|
-
@space.
|
44
|
+
expect(@space).to_not be_ticking
|
45
45
|
end
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
describe "out of bounds" do
|
49
49
|
before(:each) do
|
50
50
|
@space = @floor.space(-1, 1)
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
it "should be wall" do
|
54
|
-
@space.
|
54
|
+
expect(@space).to be_wall
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
it "should not be empty" do
|
58
|
-
@space.
|
58
|
+
expect(@space).to_not be_empty
|
59
59
|
end
|
60
|
-
|
60
|
+
|
61
61
|
it "should have name of 'wall'" do
|
62
|
-
@space.to_s.
|
62
|
+
expect(@space.to_s).to eq('wall')
|
63
63
|
end
|
64
64
|
end
|
65
|
-
|
65
|
+
|
66
66
|
describe "with warrior" do
|
67
67
|
before(:each) do
|
68
68
|
warrior = RubyWarrior::Units::Warrior.new
|
69
69
|
@floor.add(warrior, 0, 0)
|
70
70
|
@space = @floor.space(0, 0)
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
it "should be warrior" do
|
74
|
-
@space.
|
74
|
+
expect(@space).to be_warrior
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
it "should be player" do
|
78
|
-
@space.
|
78
|
+
expect(@space).to be_warrior
|
79
79
|
end
|
80
|
-
|
80
|
+
|
81
81
|
it "should not be enemy" do
|
82
|
-
@space.
|
82
|
+
expect(@space).to_not be_enemy
|
83
83
|
end
|
84
|
-
|
84
|
+
|
85
85
|
it "should not be empty" do
|
86
|
-
@space.
|
86
|
+
expect(@space).to_not be_enemy
|
87
87
|
end
|
88
|
-
|
88
|
+
|
89
89
|
it "should know what unit is on that space" do
|
90
|
-
@space.unit.
|
90
|
+
expect(@space.unit).to be_kind_of(RubyWarrior::Units::Warrior)
|
91
91
|
end
|
92
92
|
end
|
93
|
-
|
93
|
+
|
94
94
|
describe "with enemy" do
|
95
95
|
before(:each) do
|
96
96
|
@floor.add(RubyWarrior::Units::Sludge.new, 0, 0)
|
97
97
|
@space = @floor.space(0, 0)
|
98
98
|
end
|
99
|
-
|
99
|
+
|
100
100
|
it "should be enemy" do
|
101
|
-
@space.
|
101
|
+
expect(@space).to be_enemy
|
102
102
|
end
|
103
|
-
|
103
|
+
|
104
104
|
it "should not be warrior" do
|
105
|
-
@space.
|
105
|
+
expect(@space).to_not be_warrior
|
106
106
|
end
|
107
|
-
|
107
|
+
|
108
108
|
it "should not be empty" do
|
109
|
-
@space.
|
109
|
+
expect(@space).to_not be_empty
|
110
110
|
end
|
111
|
-
|
111
|
+
|
112
112
|
it "should have name of unit" do
|
113
|
-
@space.to_s.
|
113
|
+
expect(@space.to_s).to eq("Sludge")
|
114
114
|
end
|
115
|
-
|
115
|
+
|
116
116
|
describe "bound" do
|
117
117
|
before(:each) do
|
118
118
|
@space.unit.bind
|
119
119
|
end
|
120
|
-
|
120
|
+
|
121
121
|
it "should be captive" do
|
122
|
-
@space.
|
122
|
+
expect(@space).to be_captive
|
123
123
|
end
|
124
|
-
|
124
|
+
|
125
125
|
it "should not look like enemy" do
|
126
|
-
@space.
|
126
|
+
expect(@space).to_not be_enemy
|
127
127
|
end
|
128
128
|
end
|
129
129
|
end
|
130
|
-
|
130
|
+
|
131
131
|
describe "with captive" do
|
132
132
|
before(:each) do
|
133
133
|
@captive = RubyWarrior::Units::Captive.new
|
134
134
|
@floor.add(@captive, 0, 0)
|
135
135
|
@space = @floor.space(0, 0)
|
136
136
|
end
|
137
|
-
|
137
|
+
|
138
138
|
it "should be captive" do
|
139
|
-
@space.
|
139
|
+
expect(@space).to be_captive
|
140
140
|
end
|
141
|
-
|
141
|
+
|
142
142
|
it "should not be enemy" do
|
143
|
-
@space.
|
143
|
+
expect(@space).to_not be_enemy
|
144
144
|
end
|
145
|
-
|
145
|
+
|
146
146
|
it "should be ticking if captive has time bomb" do
|
147
147
|
@captive.add_abilities :explode!
|
148
|
-
@space.
|
148
|
+
expect(@space).to be_ticking
|
149
149
|
end
|
150
|
-
|
150
|
+
|
151
151
|
it "should not be ticking if captive does not have time bomb" do
|
152
|
-
@space.
|
152
|
+
expect(@space).to_not be_ticking
|
153
153
|
end
|
154
154
|
end
|
155
|
-
|
155
|
+
|
156
156
|
describe "with golem" do
|
157
157
|
before(:each) do
|
158
158
|
@golem = RubyWarrior::Units::Golem.new
|
159
159
|
@floor.add(@golem, 0, 0)
|
160
160
|
@space = @floor.space(0, 0)
|
161
161
|
end
|
162
|
-
|
162
|
+
|
163
163
|
it "should be golem" do
|
164
|
-
@space.
|
164
|
+
expect(@space).to be_golem
|
165
165
|
end
|
166
|
-
|
166
|
+
|
167
167
|
it "should not be enemy" do
|
168
|
-
@space.
|
168
|
+
expect(@space).to_not be_enemy
|
169
169
|
end
|
170
|
-
|
170
|
+
|
171
171
|
it "should be player" do
|
172
|
-
@space.
|
172
|
+
expect(@space).to be_player
|
173
173
|
end
|
174
174
|
end
|
175
|
-
|
175
|
+
|
176
176
|
describe "at stairs" do
|
177
177
|
before(:each) do
|
178
178
|
@floor.place_stairs(0, 0)
|
179
179
|
@space = @floor.space(0, 0)
|
180
180
|
end
|
181
|
-
|
181
|
+
|
182
182
|
it "should be empty" do
|
183
|
-
@space.
|
183
|
+
expect(@space).to be_empty
|
184
184
|
end
|
185
|
-
|
185
|
+
|
186
186
|
it "should be stairs" do
|
187
|
-
@space.
|
187
|
+
expect(@space).to be_stairs
|
188
188
|
end
|
189
189
|
end
|
190
190
|
end
|
@@ -1,15 +1,15 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyWarrior::Tower do
|
4
4
|
before(:each) do
|
5
5
|
@tower = RubyWarrior::Tower.new('path/to/tower')
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
it "should consider last part of path as name" do
|
9
|
-
@tower.name.
|
9
|
+
expect(@tower.name).to eq('tower')
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
it "should use name when converting to string" do
|
13
|
-
@tower.to_s.
|
13
|
+
expect(@tower.to_s).to eq(@tower.name)
|
14
14
|
end
|
15
15
|
end
|