rubywarrior-i18n 0.0.2
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.
- data/CHANGELOG.rdoc +38 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +44 -0
- data/LICENSE +20 -0
- data/README.md +199 -0
- data/Rakefile +17 -0
- data/bin/rubywarrior +5 -0
- data/features/command_options.feature +46 -0
- data/features/levels.feature +71 -0
- data/features/profiles.feature +56 -0
- data/features/step_definitions/common_steps.rb +19 -0
- data/features/step_definitions/interaction_steps.rb +65 -0
- data/features/support/env.rb +12 -0
- data/features/support/mockio.rb +57 -0
- data/features/towers.feature +14 -0
- data/i18n/en.yml +232 -0
- data/i18n/es.yml +233 -0
- data/lib/ruby_warrior.rb +53 -0
- data/lib/ruby_warrior/abilities/attack.rb +25 -0
- data/lib/ruby_warrior/abilities/base.rb +44 -0
- data/lib/ruby_warrior/abilities/bind.rb +20 -0
- data/lib/ruby_warrior/abilities/detonate.rb +34 -0
- data/lib/ruby_warrior/abilities/direction_of.rb +13 -0
- data/lib/ruby_warrior/abilities/direction_of_stairs.rb +13 -0
- data/lib/ruby_warrior/abilities/distance_of.rb +13 -0
- data/lib/ruby_warrior/abilities/explode.rb +28 -0
- data/lib/ruby_warrior/abilities/feel.rb +14 -0
- data/lib/ruby_warrior/abilities/form.rb +25 -0
- data/lib/ruby_warrior/abilities/health.rb +13 -0
- data/lib/ruby_warrior/abilities/listen.rb +15 -0
- data/lib/ruby_warrior/abilities/look.rb +16 -0
- data/lib/ruby_warrior/abilities/pivot.rb +17 -0
- data/lib/ruby_warrior/abilities/rescue.rb +24 -0
- data/lib/ruby_warrior/abilities/rest.rb +20 -0
- data/lib/ruby_warrior/abilities/shoot.rb +24 -0
- data/lib/ruby_warrior/abilities/walk.rb +21 -0
- data/lib/ruby_warrior/config.rb +22 -0
- data/lib/ruby_warrior/core_additions.rb +29 -0
- data/lib/ruby_warrior/floor.rb +71 -0
- data/lib/ruby_warrior/game.rb +209 -0
- data/lib/ruby_warrior/level.rb +123 -0
- data/lib/ruby_warrior/level_loader.rb +56 -0
- data/lib/ruby_warrior/player_generator.rb +41 -0
- data/lib/ruby_warrior/position.rb +82 -0
- data/lib/ruby_warrior/profile.rb +120 -0
- data/lib/ruby_warrior/runner.rb +34 -0
- data/lib/ruby_warrior/space.rb +71 -0
- data/lib/ruby_warrior/tower.rb +14 -0
- data/lib/ruby_warrior/turn.rb +38 -0
- data/lib/ruby_warrior/ui.rb +54 -0
- data/lib/ruby_warrior/units/archer.rb +34 -0
- data/lib/ruby_warrior/units/base.rb +100 -0
- data/lib/ruby_warrior/units/captive.rb +17 -0
- data/lib/ruby_warrior/units/golem.rb +20 -0
- data/lib/ruby_warrior/units/sludge.rb +30 -0
- data/lib/ruby_warrior/units/thick_sludge.rb +13 -0
- data/lib/ruby_warrior/units/warrior.rb +73 -0
- data/lib/ruby_warrior/units/wizard.rb +34 -0
- data/lib/ruby_warrior/version.rb +3 -0
- data/spec/fixtures/short-tower/level_001.rb +15 -0
- data/spec/fixtures/short-tower/level_002.rb +15 -0
- data/spec/fixtures/walking_player.rb +5 -0
- data/spec/ruby_warrior/abilities/attack_spec.rb +51 -0
- data/spec/ruby_warrior/abilities/base_spec.rb +38 -0
- data/spec/ruby_warrior/abilities/bind_spec.rb +19 -0
- data/spec/ruby_warrior/abilities/direction_of_spec.rb +13 -0
- data/spec/ruby_warrior/abilities/direction_of_stairs_spec.rb +13 -0
- data/spec/ruby_warrior/abilities/distance_of_spec.rb +13 -0
- data/spec/ruby_warrior/abilities/explode_spec.rb +32 -0
- data/spec/ruby_warrior/abilities/feel_spec.rb +13 -0
- data/spec/ruby_warrior/abilities/form_spec.rb +48 -0
- data/spec/ruby_warrior/abilities/health_spec.rb +13 -0
- data/spec/ruby_warrior/abilities/listen_spec.rb +17 -0
- data/spec/ruby_warrior/abilities/look_spec.rb +15 -0
- data/spec/ruby_warrior/abilities/pivot_spec.rb +18 -0
- data/spec/ruby_warrior/abilities/rescue_spec.rb +40 -0
- data/spec/ruby_warrior/abilities/rest_spec.rb +29 -0
- data/spec/ruby_warrior/abilities/shoot_spec.rb +22 -0
- data/spec/ruby_warrior/abilities/throw_spec.rb +46 -0
- data/spec/ruby_warrior/abilities/walk_spec.rb +25 -0
- data/spec/ruby_warrior/core_additions_spec.rb +7 -0
- data/spec/ruby_warrior/floor_spec.rb +81 -0
- data/spec/ruby_warrior/game_spec.rb +119 -0
- data/spec/ruby_warrior/level_loader_spec.rb +54 -0
- data/spec/ruby_warrior/level_spec.rb +203 -0
- data/spec/ruby_warrior/player_generator_spec.rb +12 -0
- data/spec/ruby_warrior/position_spec.rb +108 -0
- data/spec/ruby_warrior/profile_spec.rb +171 -0
- data/spec/ruby_warrior/space_spec.rb +190 -0
- data/spec/ruby_warrior/tower_spec.rb +15 -0
- data/spec/ruby_warrior/turn_spec.rb +42 -0
- data/spec/ruby_warrior/ui_spec.rb +93 -0
- data/spec/ruby_warrior/units/archer_spec.rb +23 -0
- data/spec/ruby_warrior/units/base_spec.rb +133 -0
- data/spec/ruby_warrior/units/captive_spec.rb +23 -0
- data/spec/ruby_warrior/units/golem_spec.rb +28 -0
- data/spec/ruby_warrior/units/sludge_spec.rb +27 -0
- data/spec/ruby_warrior/units/thick_sludge_spec.rb +19 -0
- data/spec/ruby_warrior/units/warrior_spec.rb +65 -0
- data/spec/ruby_warrior/units/wizard_spec.rb +23 -0
- data/spec/spec_helper.rb +10 -0
- data/templates/README.erb +33 -0
- data/templates/player.rb +5 -0
- data/towers/beginner/level_001.rb +18 -0
- data/towers/beginner/level_002.rb +19 -0
- data/towers/beginner/level_003.rb +23 -0
- data/towers/beginner/level_004.rb +20 -0
- data/towers/beginner/level_005.rb +24 -0
- data/towers/beginner/level_006.rb +21 -0
- data/towers/beginner/level_007.rb +20 -0
- data/towers/beginner/level_008.rb +23 -0
- data/towers/beginner/level_009.rb +22 -0
- data/towers/intermediate/level_001.rb +20 -0
- data/towers/intermediate/level_002.rb +22 -0
- data/towers/intermediate/level_003.rb +25 -0
- data/towers/intermediate/level_004.rb +26 -0
- data/towers/intermediate/level_005.rb +21 -0
- data/towers/intermediate/level_006.rb +25 -0
- data/towers/intermediate/level_007.rb +27 -0
- data/towers/intermediate/level_008.rb +25 -0
- data/towers/intermediate/level_009.rb +33 -0
- metadata +226 -0
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RubyWarrior::PlayerGenerator do
|
4
|
+
before(:each) do
|
5
|
+
@level = RubyWarrior::Level.new(RubyWarrior::Profile.new, 15)
|
6
|
+
@generator = RubyWarrior::PlayerGenerator.new(@level)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should know templates path" do
|
10
|
+
@generator.templates_path.should == File.expand_path("../../../templates", __FILE__)
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RubyWarrior::Position do
|
4
|
+
before(:each) do
|
5
|
+
@unit = RubyWarrior::Units::Base.new
|
6
|
+
@floor = RubyWarrior::Floor.new
|
7
|
+
@floor.width = 6
|
8
|
+
@floor.height = 5
|
9
|
+
@floor.add(@unit, 1, 2, :north)
|
10
|
+
@position = @unit.position
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should rotate clockwise" do
|
14
|
+
@position.direction.should == :north
|
15
|
+
[:east, :south, :west, :north, :east].each do |dir|
|
16
|
+
@position.rotate(1)
|
17
|
+
@position.direction.should == dir
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should rotate counterclockwise" do
|
22
|
+
@position.direction.should == :north
|
23
|
+
[:west, :south, :east, :north, :west].each do |dir|
|
24
|
+
@position.rotate(-1)
|
25
|
+
@position.direction.should == dir
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should get relative space in front" do
|
30
|
+
unit = RubyWarrior::Units::Base.new
|
31
|
+
@floor.add(unit, 1, 1)
|
32
|
+
@position.relative_space(1).should_not be_empty
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should get relative object in front when rotated" do
|
36
|
+
unit = RubyWarrior::Units::Base.new
|
37
|
+
@floor.add(unit, 2, 2)
|
38
|
+
@position.rotate(1)
|
39
|
+
@position.relative_space(1).should_not be_empty
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should get relative object diagonally" do
|
43
|
+
unit = RubyWarrior::Units::Base.new
|
44
|
+
@floor.add(unit, 0, 1)
|
45
|
+
@position.relative_space(1, -1).should_not be_empty
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should get relative object diagonally when rotating" do
|
49
|
+
unit = RubyWarrior::Units::Base.new
|
50
|
+
@floor.add(unit, 0, 1)
|
51
|
+
@position.rotate(2)
|
52
|
+
@position.relative_space(-1, 1).should_not be_empty
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should move object on floor relatively" do
|
56
|
+
@floor.get(1, 2).should == @unit
|
57
|
+
@position.move(-1, 2)
|
58
|
+
@floor.get(1, 2).should be_nil
|
59
|
+
@floor.get(3, 3).should == @unit
|
60
|
+
@position.rotate(1)
|
61
|
+
@position.move(-1)
|
62
|
+
@floor.get(3, 3).should be_nil
|
63
|
+
@floor.get(2, 3).should == @unit
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should return distance from stairs as 0 when on stairs" do
|
67
|
+
@floor.place_stairs(1, 2)
|
68
|
+
@position.distance_from_stairs.should == 0
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should return distance from stairs in both directions" do
|
72
|
+
@floor.place_stairs(0, 3)
|
73
|
+
@position.distance_from_stairs.should == 2
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should return relative direction of stairs" do
|
77
|
+
@floor.place_stairs(0, 0)
|
78
|
+
@position.relative_direction_of_stairs.should == :forward
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should return relative direction of given space" do
|
82
|
+
@position.relative_direction_of(@floor.space(5, 3)).should == :right
|
83
|
+
@position.rotate 1
|
84
|
+
@position.relative_direction_of(@floor.space(1, 4)).should == :right
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should be able to determine relative direction" do
|
88
|
+
@position.relative_direction(:north).should == :forward
|
89
|
+
@position.relative_direction(:south).should == :backward
|
90
|
+
@position.relative_direction(:west).should == :left
|
91
|
+
@position.relative_direction(:east).should == :right
|
92
|
+
@position.rotate 1
|
93
|
+
@position.relative_direction(:north).should == :left
|
94
|
+
@position.rotate 1
|
95
|
+
@position.relative_direction(:north).should == :backward
|
96
|
+
@position.rotate 1
|
97
|
+
@position.relative_direction(:north).should == :right
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should return a space at the same location as position" do
|
101
|
+
@position.space.location.should == [1, 2]
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should return distance of given space" do
|
105
|
+
@position.distance_of(@floor.space(5, 3)).should == 5
|
106
|
+
@position.distance_of(@floor.space(4, 2)).should == 3
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,171 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RubyWarrior::Profile do
|
4
|
+
before(:each) do
|
5
|
+
@profile = RubyWarrior::Profile.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should have warrior name" do
|
9
|
+
@profile.warrior_name = 'Joe'
|
10
|
+
@profile.warrior_name.should == 'Joe'
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should start level number at 0" do
|
14
|
+
@profile.level_number.should be_zero
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should start score at 0 and allow it to increment" do
|
18
|
+
@profile.score.should be_zero
|
19
|
+
@profile.score += 5
|
20
|
+
@profile.score.should == 5
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should have no abilities and allow adding" do
|
24
|
+
@profile.abilities.should == []
|
25
|
+
@profile.abilities += [:foo, :bar]
|
26
|
+
@profile.abilities.should == [:foo, :bar]
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should encode with marshal + base64" do
|
30
|
+
@profile.encode.should == Base64.encode64(Marshal.dump(@profile))
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should decode with marshal + base64" do
|
34
|
+
RubyWarrior::Profile.decode(@profile.encode).warrior_name.should == @profile.warrior_name
|
35
|
+
end
|
36
|
+
|
37
|
+
it "load should read file, decode and set player path" do
|
38
|
+
profile = 'profile'
|
39
|
+
profile.expects(:player_path=).with('path/to')
|
40
|
+
File.expects(:read).with('path/to/.profile').returns('encoded_profile')
|
41
|
+
RubyWarrior::Profile.expects(:decode).with('encoded_profile').returns(profile)
|
42
|
+
RubyWarrior::Profile.load('path/to/.profile').should == profile
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
it "should add abilities and remove duplicates" do
|
47
|
+
@profile.add_abilities(:foo, :bar, :blah, :bar)
|
48
|
+
@profile.abilities.should == [:foo, :bar, :blah]
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should fetch new level with current number" do
|
52
|
+
@profile.level_number = 1
|
53
|
+
@profile.current_level.number.should == 1
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should fetch next level" do
|
57
|
+
@profile.level_number = 1
|
58
|
+
@profile.next_level.number.should == 2
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should enable epic mode and reset scores if nil" do
|
62
|
+
@profile.epic_score = nil
|
63
|
+
@profile.current_epic_score = nil
|
64
|
+
@profile.enable_epic_mode
|
65
|
+
@profile.should be_epic
|
66
|
+
@profile.epic_score.should be_zero
|
67
|
+
@profile.current_epic_score.should be_zero
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should override epic score with current one if it is higher" do
|
71
|
+
@profile.enable_epic_mode
|
72
|
+
@profile.epic_score.should be_zero
|
73
|
+
@profile.average_grade.should be_nil
|
74
|
+
@profile.current_epic_score = 123
|
75
|
+
@profile.current_epic_grades = { 1 => 0.7, 2 => 0.9 }
|
76
|
+
@profile.update_epic_score
|
77
|
+
@profile.epic_score.should == 123
|
78
|
+
@profile.average_grade.should == 0.8
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should not override epic score with current one if it is lower" do
|
82
|
+
@profile.enable_epic_mode
|
83
|
+
@profile.epic_score = 124
|
84
|
+
@profile.average_grade = 0.9
|
85
|
+
@profile.current_epic_score = 123
|
86
|
+
@profile.current_epic_grades = { 1 => 0.7, 2 => 0.9 }
|
87
|
+
@profile.update_epic_score
|
88
|
+
@profile.epic_score.should == 124
|
89
|
+
@profile.average_grade.should == 0.9
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should not calculate average grade if no grades are present" do
|
93
|
+
@profile.enable_epic_mode
|
94
|
+
@profile.current_epic_grades = {}
|
95
|
+
@profile.calculate_average_grade.should be_nil
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should remember current level number as last_level_number" do
|
99
|
+
@profile.level_number = 7
|
100
|
+
@profile.enable_epic_mode
|
101
|
+
@profile.last_level_number.should == 7
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should enable normal mode by clearing epic scores and resetting last level number" do
|
105
|
+
@profile.last_level_number = 7
|
106
|
+
@profile.epic_score = 123
|
107
|
+
@profile.current_epic_score = 100
|
108
|
+
@profile.current_epic_grades = { 1 => 100 }
|
109
|
+
@profile.average_grade = "C"
|
110
|
+
@profile.enable_normal_mode
|
111
|
+
@profile.should_not be_epic
|
112
|
+
@profile.epic_score.should be_zero
|
113
|
+
@profile.current_epic_score.should be_zero
|
114
|
+
@profile.last_level_number.should be_nil
|
115
|
+
@profile.average_grade.should be_nil
|
116
|
+
@profile.current_epic_grades.should == {}
|
117
|
+
@profile.level_number.should == 7
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should be no level after epic if last level isn't specified" do
|
121
|
+
@profile.last_level_number = nil
|
122
|
+
@profile.should_not be_level_after_epic
|
123
|
+
end
|
124
|
+
|
125
|
+
describe "with tower path" do
|
126
|
+
before(:each) do
|
127
|
+
@profile.warrior_name = "John Smith"
|
128
|
+
@profile.tower_path = 'path/to/tower'
|
129
|
+
end
|
130
|
+
|
131
|
+
it "save should write file with encoded profile" do
|
132
|
+
file = stub
|
133
|
+
file.expects(:write).with('encoded_profile')
|
134
|
+
File.expects(:open).with(@profile.player_path + '/.profile', 'w').yields(file)
|
135
|
+
@profile.expects(:encode).returns('encoded_profile')
|
136
|
+
@profile.save
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should have a nice string representation" do
|
140
|
+
@profile.warrior_name = 'Joe'
|
141
|
+
@profile.to_s.should == "Joe - tower - level 0 - score 0"
|
142
|
+
end
|
143
|
+
|
144
|
+
it "should include epic score in string representation" do
|
145
|
+
@profile.warrior_name = 'Joe'
|
146
|
+
@profile.enable_epic_mode
|
147
|
+
@profile.to_s.should == "Joe - tower - first score 0 - epic score 0"
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should include epic score with grade in string representation" do
|
151
|
+
@profile.warrior_name = 'Joe'
|
152
|
+
@profile.enable_epic_mode
|
153
|
+
@profile.average_grade = 0.7
|
154
|
+
@profile.to_s.should == "Joe - tower - first score 0 - epic score 0 (C)"
|
155
|
+
end
|
156
|
+
|
157
|
+
it "should guess at the player path" do
|
158
|
+
@profile.player_path.should == './rubywarrior/john-smith-tower'
|
159
|
+
end
|
160
|
+
|
161
|
+
it "should use specified player path" do
|
162
|
+
@profile.player_path = "path/to/player"
|
163
|
+
@profile.player_path.should == "path/to/player"
|
164
|
+
end
|
165
|
+
|
166
|
+
it "should load tower from path" do
|
167
|
+
RubyWarrior::Tower.expects(:new).with('tower').returns('tower')
|
168
|
+
@profile.tower.should == 'tower'
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
@@ -0,0 +1,190 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RubyWarrior::Space do
|
4
|
+
before(:each) do
|
5
|
+
@floor = RubyWarrior::Floor.new
|
6
|
+
@floor.width = 2
|
7
|
+
@floor.height = 3
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "with empty space" do
|
11
|
+
before(:each) do
|
12
|
+
@space = @floor.space(0, 0)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should not be enemy" do
|
16
|
+
@space.should_not be_enemy
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should not be warrior" do
|
20
|
+
@space.should_not be_warrior
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should be empty" do
|
24
|
+
@space.should be_empty
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should not be wall" do
|
28
|
+
@space.should_not be_wall
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should not be stairs" do
|
32
|
+
@space.should_not be_stairs
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should not be captive" do
|
36
|
+
@space.should_not be_captive
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should say 'nothing' as name" do
|
40
|
+
@space.to_s.should == 'nothing'
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should not be ticking" do
|
44
|
+
@space.should_not be_ticking
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "out of bounds" do
|
49
|
+
before(:each) do
|
50
|
+
@space = @floor.space(-1, 1)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should be wall" do
|
54
|
+
@space.should be_wall
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should not be empty" do
|
58
|
+
@space.should_not be_empty
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should have name of 'wall'" do
|
62
|
+
@space.to_s.should == 'wall'
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "with warrior" do
|
67
|
+
before(:each) do
|
68
|
+
warrior = RubyWarrior::Units::Warrior.new
|
69
|
+
@floor.add(warrior, 0, 0)
|
70
|
+
@space = @floor.space(0, 0)
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should be warrior" do
|
74
|
+
@space.should be_warrior
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should be player" do
|
78
|
+
@space.should be_warrior
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should not be enemy" do
|
82
|
+
@space.should_not be_enemy
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should not be empty" do
|
86
|
+
@space.should_not be_enemy
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should know what unit is on that space" do
|
90
|
+
@space.unit.should be_kind_of(RubyWarrior::Units::Warrior)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe "with enemy" do
|
95
|
+
before(:each) do
|
96
|
+
@floor.add(RubyWarrior::Units::Sludge.new, 0, 0)
|
97
|
+
@space = @floor.space(0, 0)
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should be enemy" do
|
101
|
+
@space.should be_enemy
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should not be warrior" do
|
105
|
+
@space.should_not be_warrior
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should not be empty" do
|
109
|
+
@space.should_not be_empty
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should have name of unit" do
|
113
|
+
@space.to_s.should == "Sludge"
|
114
|
+
end
|
115
|
+
|
116
|
+
describe "bound" do
|
117
|
+
before(:each) do
|
118
|
+
@space.unit.bind
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should be captive" do
|
122
|
+
@space.should be_captive
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should not look like enemy" do
|
126
|
+
@space.should_not be_enemy
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe "with captive" do
|
132
|
+
before(:each) do
|
133
|
+
@captive = RubyWarrior::Units::Captive.new
|
134
|
+
@floor.add(@captive, 0, 0)
|
135
|
+
@space = @floor.space(0, 0)
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should be captive" do
|
139
|
+
@space.should be_captive
|
140
|
+
end
|
141
|
+
|
142
|
+
it "should not be enemy" do
|
143
|
+
@space.should_not be_enemy
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should be ticking if captive has time bomb" do
|
147
|
+
@captive.add_abilities :explode!
|
148
|
+
@space.should be_ticking
|
149
|
+
end
|
150
|
+
|
151
|
+
it "should not be ticking if captive does not have time bomb" do
|
152
|
+
@space.should_not be_ticking
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
describe "with golem" do
|
157
|
+
before(:each) do
|
158
|
+
@golem = RubyWarrior::Units::Golem.new
|
159
|
+
@floor.add(@golem, 0, 0)
|
160
|
+
@space = @floor.space(0, 0)
|
161
|
+
end
|
162
|
+
|
163
|
+
it "should be golem" do
|
164
|
+
@space.should be_golem
|
165
|
+
end
|
166
|
+
|
167
|
+
it "should not be enemy" do
|
168
|
+
@space.should_not be_enemy
|
169
|
+
end
|
170
|
+
|
171
|
+
it "should be player" do
|
172
|
+
@space.should be_player
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
describe "at stairs" do
|
177
|
+
before(:each) do
|
178
|
+
@floor.place_stairs(0, 0)
|
179
|
+
@space = @floor.space(0, 0)
|
180
|
+
end
|
181
|
+
|
182
|
+
it "should be empty" do
|
183
|
+
@space.should be_empty
|
184
|
+
end
|
185
|
+
|
186
|
+
it "should be stairs" do
|
187
|
+
@space.should be_stairs
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|