RSokoban 0.73 → 0.74
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/NEWS +16 -1
- data/README.rdoc +25 -8
- data/Rakefile +51 -0
- data/TODO +19 -41
- data/VERSION +1 -1
- data/bin/rsokoban +1 -3
- data/lib/rsokoban.rb +2 -0
- data/lib/rsokoban/exception.rb +4 -0
- data/lib/rsokoban/extensions.rb +26 -0
- data/lib/rsokoban/game.rb +161 -41
- data/lib/rsokoban/level.rb +54 -37
- data/lib/rsokoban/level_loader.rb +34 -11
- data/lib/rsokoban/move_recorder.rb +14 -2
- data/lib/rsokoban/move_result.rb +37 -0
- data/lib/rsokoban/ui/base_ui.rb +0 -3
- data/lib/rsokoban/ui/console.rb +2 -2
- data/lib/rsokoban/ui/curses_console.rb +0 -2
- data/lib/rsokoban/ui/player_action.rb +2 -2
- data/lib/rsokoban/ui/tk_box.rb +21 -0
- data/lib/rsokoban/ui/tk_dialogs.rb +240 -0
- data/lib/rsokoban/ui/tk_ui.rb +170 -269
- data/test/tc_extensions.rb +26 -0
- data/test/tc_game.rb +28 -0
- data/test/tc_level.rb +187 -112
- data/test/tc_level_loader.rb +12 -17
- data/test/tc_move_recorder.rb +41 -7
- data/test/tc_move_result.rb +45 -0
- data/test/test.rb +3 -0
- data/test/ui/tc_console.rb +3 -1
- metadata +10 -3
- data/RSokoban-0.73.gem +0 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
class TC_Extensions < Test::Unit::TestCase
|
2
|
+
|
3
|
+
def test_String_get_xsb_info_line
|
4
|
+
assert_equal "E-Mail:\n", "; E-Mail: \n".get_xsb_info_line
|
5
|
+
end
|
6
|
+
|
7
|
+
def test_String_get_xsb_info_line_from_empty_info
|
8
|
+
assert_equal "\n", ";\n".get_xsb_info_line
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_String_get_xsb_info_line_with_semi_colon_in_it
|
12
|
+
assert ";foo;bar;\n", ";;foo;bar;\n".get_xsb_info_line
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_String_get_xsb_info_line_chomp
|
16
|
+
assert_equal "E-Mail:", "; E-Mail: \n".get_xsb_info_line_chomp
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_String_get_xsb_info_line_chomp_from_empty_info
|
20
|
+
assert_equal "", ";\n".get_xsb_info_line_chomp
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_String_get_xsb_info_line_chomp_with_semi_colon_in_it
|
24
|
+
assert_equal ";foo;bar;", ";;foo;bar;\n".get_xsb_info_line_chomp
|
25
|
+
end
|
26
|
+
end
|
data/test/tc_game.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
class TC_Game < Test::Unit::TestCase
|
2
|
+
|
3
|
+
def setup
|
4
|
+
$RSOKOBAN_DATA_PATH = File.expand_path(File.dirname(__FILE__))
|
5
|
+
@game = RSokoban::Game.new :portable, 'original.xsb'
|
6
|
+
# Make Game@ui nil to not start the ui.
|
7
|
+
@game.instance_variable_set(:@ui, nil)
|
8
|
+
# Load the first level, without starting ui (see previous line)
|
9
|
+
@game.start_level
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_level_width
|
13
|
+
assert_equal 19, @game.level_width
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_level_height
|
17
|
+
assert_equal 11, @game.level_height
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_level_title
|
21
|
+
assert_equal '1', @game.level_title
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_man_x
|
25
|
+
assert_equal 11, @game.man_x
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
data/test/tc_level.rb
CHANGED
@@ -16,122 +16,116 @@ class TC_Level < Test::Unit::TestCase
|
|
16
16
|
'#$$#',
|
17
17
|
'#@ #',
|
18
18
|
'####']
|
19
|
-
|
19
|
+
|
20
|
+
def setup
|
21
|
+
@text_1 = RSokoban::Level.new(RSokoban::RawLevel.new('1', Text1))
|
22
|
+
@text_2 = RSokoban::Level.new(RSokoban::RawLevel.new('1', Text2))
|
23
|
+
@text_3 = RSokoban::Level.new(RSokoban::RawLevel.new('1', Text3))
|
24
|
+
@original_1 = RSokoban::Level.new(RSokoban::RawLevel.new('1', Level1))
|
25
|
+
end
|
26
|
+
|
20
27
|
def test_instance
|
21
|
-
|
22
|
-
|
28
|
+
assert_equal true, @text_1.instance_of?(RSokoban::Level), "Must be an instance of RSokoban::Level"
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_move_number
|
32
|
+
assert_equal 0, @text_1.move_number
|
23
33
|
end
|
24
34
|
|
25
35
|
def test_floor_with_Text1
|
26
|
-
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', Text1))
|
27
36
|
expected = [ '#####',
|
28
37
|
'# #',
|
29
38
|
'#####']
|
30
|
-
assert_equal expected,
|
39
|
+
assert_equal expected, @text_1.floor
|
31
40
|
end
|
32
41
|
|
33
42
|
def test_floor_with_Text3
|
34
|
-
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', Text3))
|
35
43
|
expected = [ '####',
|
36
44
|
'# #',
|
37
45
|
'# #',
|
38
46
|
'# #',
|
39
47
|
'####']
|
40
|
-
assert_equal expected,
|
48
|
+
assert_equal expected, @text_3.floor
|
41
49
|
end
|
42
50
|
|
43
51
|
def test_man_position
|
44
|
-
|
45
|
-
assert_equal
|
46
|
-
assert_equal 1, ins.man.y
|
52
|
+
assert_equal 3, @text_1.man.x
|
53
|
+
assert_equal 1, @text_1.man.y
|
47
54
|
end
|
48
55
|
|
49
56
|
def test_crates_is_an_Array
|
50
|
-
|
51
|
-
assert_equal true, ins.crates.instance_of?(Array), "Must be an Array"
|
57
|
+
assert_equal true, @text_1.crates.instance_of?(Array), "Must be an Array"
|
52
58
|
end
|
53
59
|
|
54
60
|
def test_crates_with_Text1_must_be_of_size_1
|
55
|
-
|
56
|
-
assert_equal 1, ins.crates.size
|
61
|
+
assert_equal 1, @text_1.crates.size
|
57
62
|
end
|
58
63
|
|
59
64
|
def test_crates_contains_some_crate
|
60
|
-
|
61
|
-
assert_equal true, ins.crates[0].instance_of?(RSokoban::Crate)
|
65
|
+
assert_equal true, @text_1.crates[0].instance_of?(RSokoban::Crate)
|
62
66
|
end
|
63
67
|
|
64
68
|
def test_crates_with_Text2_must_be_of_size_3
|
65
|
-
|
66
|
-
assert_equal 3, ins.crates.size
|
69
|
+
assert_equal 3, @text_2.crates.size
|
67
70
|
end
|
68
71
|
|
69
72
|
def test_crates_positions
|
70
|
-
|
71
|
-
assert_equal
|
72
|
-
assert_equal 1, ins.crates[0].y
|
73
|
+
assert_equal 2, @text_2.crates[0].x
|
74
|
+
assert_equal 1, @text_2.crates[0].y
|
73
75
|
|
74
|
-
assert_equal 2,
|
75
|
-
assert_equal 2,
|
76
|
+
assert_equal 2, @text_2.crates[1].x
|
77
|
+
assert_equal 2, @text_2.crates[1].y
|
76
78
|
|
77
|
-
assert_equal 2,
|
78
|
-
assert_equal 3,
|
79
|
+
assert_equal 2, @text_2.crates[2].x
|
80
|
+
assert_equal 3, @text_2.crates[2].y
|
79
81
|
end
|
80
82
|
|
81
83
|
def test_several_crates_on_a_line
|
82
|
-
|
83
|
-
assert_equal
|
84
|
-
assert_equal 2, ins.crates[0].y
|
84
|
+
assert_equal 1, @text_3.crates[0].x
|
85
|
+
assert_equal 2, @text_3.crates[0].y
|
85
86
|
|
86
|
-
assert_equal 2,
|
87
|
-
assert_equal 2,
|
87
|
+
assert_equal 2, @text_3.crates[1].x
|
88
|
+
assert_equal 2, @text_3.crates[1].y
|
88
89
|
end
|
89
90
|
|
90
91
|
def test_storages
|
91
|
-
|
92
|
-
assert_equal true, ins.storages.instance_of?(Array), "Must be an Array"
|
92
|
+
assert_equal true, @text_1.storages.instance_of?(Array), "Must be an Array"
|
93
93
|
end
|
94
94
|
|
95
95
|
def test_storages_with_Text1_must_be_of_size_1
|
96
|
-
|
97
|
-
assert_equal 1, ins.storages.size
|
96
|
+
assert_equal 1, @text_1.storages.size
|
98
97
|
end
|
99
98
|
|
100
99
|
def test_storages_with_Text2_must_be_of_size_3
|
101
|
-
|
102
|
-
assert_equal 3, ins.storages.size
|
100
|
+
assert_equal 3, @text_2.storages.size
|
103
101
|
end
|
104
102
|
|
105
103
|
def test_storages_contains_some_storage
|
106
|
-
|
107
|
-
assert_equal true, ins.storages[0].instance_of?(RSokoban::Storage)
|
104
|
+
assert_equal true, @text_1.storages[0].instance_of?(RSokoban::Storage)
|
108
105
|
end
|
109
106
|
|
110
107
|
def test_storages_positions
|
111
|
-
|
112
|
-
assert_equal 1,
|
113
|
-
assert_equal 1, ins.storages[0].y
|
108
|
+
assert_equal 1, @text_2.storages[0].x
|
109
|
+
assert_equal 1, @text_2.storages[0].y
|
114
110
|
|
115
|
-
assert_equal 1,
|
116
|
-
assert_equal 2,
|
111
|
+
assert_equal 1, @text_2.storages[1].x
|
112
|
+
assert_equal 2, @text_2.storages[1].y
|
117
113
|
|
118
|
-
assert_equal 1,
|
119
|
-
assert_equal 3,
|
114
|
+
assert_equal 1, @text_2.storages[2].x
|
115
|
+
assert_equal 3, @text_2.storages[2].y
|
120
116
|
end
|
121
117
|
|
122
118
|
def test_several_storages_on_a_line
|
123
|
-
|
124
|
-
assert_equal 1,
|
125
|
-
assert_equal 1, ins.storages[0].y
|
119
|
+
assert_equal 1, @text_3.storages[0].x
|
120
|
+
assert_equal 1, @text_3.storages[0].y
|
126
121
|
|
127
|
-
assert_equal 2,
|
128
|
-
assert_equal 1,
|
122
|
+
assert_equal 2, @text_3.storages[1].x
|
123
|
+
assert_equal 1, @text_3.storages[1].y
|
129
124
|
end
|
130
125
|
|
131
126
|
def test_equality
|
132
|
-
|
133
|
-
|
134
|
-
assert ins1 == ins2
|
127
|
+
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', Text3))
|
128
|
+
assert ins == @text_3
|
135
129
|
end
|
136
130
|
|
137
131
|
Level1 = [' #####',
|
@@ -147,8 +141,15 @@ class TC_Level < Test::Unit::TestCase
|
|
147
141
|
' #######']
|
148
142
|
|
149
143
|
def test_rawLevel
|
150
|
-
|
151
|
-
|
144
|
+
assert_equal Level1, @original_1.map
|
145
|
+
end
|
146
|
+
|
147
|
+
def test_width
|
148
|
+
assert_equal 19, @original_1.width
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_height
|
152
|
+
assert_equal 11, @original_1.height
|
152
153
|
end
|
153
154
|
|
154
155
|
Level1_u = [' #####',
|
@@ -164,8 +165,8 @@ class TC_Level < Test::Unit::TestCase
|
|
164
165
|
' #######']
|
165
166
|
|
166
167
|
def test_rawLevel_after_move_up
|
167
|
-
ins =
|
168
|
-
ins.move
|
168
|
+
ins = @original_1
|
169
|
+
ins.move(:up)
|
169
170
|
assert_equal Level1_u, ins.map
|
170
171
|
end
|
171
172
|
|
@@ -177,7 +178,9 @@ class TC_Level < Test::Unit::TestCase
|
|
177
178
|
|
178
179
|
def test_crate_on_storage_at_startup
|
179
180
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', Text4))
|
180
|
-
|
181
|
+
result = ins.move(:up)
|
182
|
+
assert_equal :win, result[:status]
|
183
|
+
assert_equal 1, result[:move_number]
|
181
184
|
end
|
182
185
|
|
183
186
|
### Move up ##############################################
|
@@ -194,14 +197,16 @@ class TC_Level < Test::Unit::TestCase
|
|
194
197
|
|
195
198
|
def test_CanMoveUp1
|
196
199
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveUp1))
|
197
|
-
|
200
|
+
result = ins.move(:up)
|
201
|
+
assert_equal :ok, result[:status]
|
202
|
+
assert_equal 1, result[:move_number]
|
198
203
|
assert_equal 1, ins.man.x
|
199
204
|
assert_equal 1, ins.man.y
|
200
205
|
end
|
201
206
|
|
202
207
|
def test_AfterMoveUp1
|
203
208
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveUp1))
|
204
|
-
ins.
|
209
|
+
ins.move(:up)
|
205
210
|
assert_equal AfterMoveUp1, ins.map
|
206
211
|
end
|
207
212
|
|
@@ -217,14 +222,16 @@ class TC_Level < Test::Unit::TestCase
|
|
217
222
|
|
218
223
|
def test_CanMoveUp2
|
219
224
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveUp2))
|
220
|
-
|
225
|
+
result = ins.move(:up)
|
226
|
+
assert_equal :ok, result[:status]
|
227
|
+
assert_equal 1, result[:move_number]
|
221
228
|
assert_equal 1, ins.man.x
|
222
229
|
assert_equal 1, ins.man.y
|
223
230
|
end
|
224
231
|
|
225
232
|
def test_AfterMoveUp2
|
226
233
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveUp2))
|
227
|
-
ins.
|
234
|
+
ins.move(:up)
|
228
235
|
assert_equal AfterMoveUp2, ins.map
|
229
236
|
end
|
230
237
|
|
@@ -242,14 +249,16 @@ class TC_Level < Test::Unit::TestCase
|
|
242
249
|
|
243
250
|
def test_CanMoveUp3
|
244
251
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveUp3))
|
245
|
-
|
252
|
+
result = ins.move(:up)
|
253
|
+
assert_equal :ok, result[:status]
|
254
|
+
assert_equal 1, result[:move_number]
|
246
255
|
assert_equal 1, ins.man.x
|
247
256
|
assert_equal 2, ins.man.y
|
248
257
|
end
|
249
258
|
|
250
259
|
def test_AfterMoveUp3
|
251
260
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveUp3))
|
252
|
-
ins.
|
261
|
+
ins.move(:up)
|
253
262
|
assert_equal AfterMoveUp3, ins.map
|
254
263
|
end
|
255
264
|
|
@@ -267,14 +276,16 @@ class TC_Level < Test::Unit::TestCase
|
|
267
276
|
|
268
277
|
def test_CanMoveUp4
|
269
278
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveUp4))
|
270
|
-
|
279
|
+
result = ins.move(:up)
|
280
|
+
assert_equal :win, result[:status]
|
281
|
+
assert_equal 1, result[:move_number]
|
271
282
|
assert_equal 1, ins.man.x
|
272
283
|
assert_equal 2, ins.man.y
|
273
284
|
end
|
274
285
|
|
275
286
|
def test_AfterMoveUp4
|
276
287
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveUp4))
|
277
|
-
ins.
|
288
|
+
ins.move(:up)
|
278
289
|
assert_equal AfterMoveUp4, ins.map
|
279
290
|
end
|
280
291
|
|
@@ -284,7 +295,9 @@ class TC_Level < Test::Unit::TestCase
|
|
284
295
|
|
285
296
|
def test_CannotMoveUp1
|
286
297
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveUp1))
|
287
|
-
|
298
|
+
result = ins.move(:up)
|
299
|
+
assert_equal :error, result[:status]
|
300
|
+
assert_equal 'wall', result[:message]
|
288
301
|
assert_equal CannotMoveUp1, ins.map
|
289
302
|
end
|
290
303
|
|
@@ -295,7 +308,9 @@ class TC_Level < Test::Unit::TestCase
|
|
295
308
|
|
296
309
|
def test_CannotMoveUp2
|
297
310
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveUp2))
|
298
|
-
|
311
|
+
result = ins.move(:up)
|
312
|
+
assert_equal :error, result[:status]
|
313
|
+
assert_equal 'wall behind crate', result[:message]
|
299
314
|
assert_equal CannotMoveUp2, ins.map
|
300
315
|
end
|
301
316
|
|
@@ -308,7 +323,9 @@ class TC_Level < Test::Unit::TestCase
|
|
308
323
|
|
309
324
|
def test_CannotMoveUp3
|
310
325
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveUp3))
|
311
|
-
|
326
|
+
result = ins.move(:up)
|
327
|
+
assert_equal :error, result[:status]
|
328
|
+
assert_equal 'double crate', result[:message]
|
312
329
|
assert_equal CannotMoveUp3, ins.map
|
313
330
|
end
|
314
331
|
|
@@ -321,7 +338,9 @@ class TC_Level < Test::Unit::TestCase
|
|
321
338
|
|
322
339
|
def test_CannotMoveUp4
|
323
340
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveUp4))
|
324
|
-
|
341
|
+
result = ins.move(:up)
|
342
|
+
assert_equal :error, result[:status]
|
343
|
+
assert_equal 'double crate', result[:message]
|
325
344
|
assert_equal CannotMoveUp4, ins.map
|
326
345
|
end
|
327
346
|
|
@@ -334,7 +353,9 @@ class TC_Level < Test::Unit::TestCase
|
|
334
353
|
|
335
354
|
def test_CannotMoveUp5
|
336
355
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveUp5))
|
337
|
-
|
356
|
+
result = ins.move(:up)
|
357
|
+
assert_equal :error, result[:status]
|
358
|
+
assert_equal 'double crate', result[:message]
|
338
359
|
assert_equal CannotMoveUp5, ins.map
|
339
360
|
end
|
340
361
|
|
@@ -347,7 +368,9 @@ class TC_Level < Test::Unit::TestCase
|
|
347
368
|
|
348
369
|
def test_CannotMoveUp6
|
349
370
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveUp6))
|
350
|
-
|
371
|
+
result = ins.move(:up)
|
372
|
+
assert_equal :error, result[:status]
|
373
|
+
assert_equal 'double crate', result[:message]
|
351
374
|
assert_equal CannotMoveUp6, ins.map
|
352
375
|
end
|
353
376
|
|
@@ -365,12 +388,14 @@ class TC_Level < Test::Unit::TestCase
|
|
365
388
|
|
366
389
|
def test_CanMoveDown1
|
367
390
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveDown1))
|
368
|
-
|
391
|
+
result = ins.move(:down)
|
392
|
+
assert_equal :ok, result[:status]
|
393
|
+
assert_equal 1, result[:move_number]
|
369
394
|
end
|
370
395
|
|
371
396
|
def test_AfterMoveDown1
|
372
397
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveDown1))
|
373
|
-
ins.
|
398
|
+
ins.move(:down)
|
374
399
|
assert_equal AfterMoveDown1, ins.map
|
375
400
|
end
|
376
401
|
|
@@ -386,12 +411,14 @@ class TC_Level < Test::Unit::TestCase
|
|
386
411
|
|
387
412
|
def test_CanMoveDown2
|
388
413
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveDown2))
|
389
|
-
|
414
|
+
result = ins.move(:down)
|
415
|
+
assert_equal :ok, result[:status]
|
416
|
+
assert_equal 1, result[:move_number]
|
390
417
|
end
|
391
418
|
|
392
419
|
def test_AfterMoveDown2
|
393
420
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveDown2))
|
394
|
-
ins.
|
421
|
+
ins.move(:down)
|
395
422
|
assert_equal AfterMoveDown2, ins.map
|
396
423
|
end
|
397
424
|
|
@@ -409,12 +436,14 @@ class TC_Level < Test::Unit::TestCase
|
|
409
436
|
|
410
437
|
def test_CanMoveDown3
|
411
438
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveDown3))
|
412
|
-
|
439
|
+
result = ins.move(:down)
|
440
|
+
assert_equal :ok, result[:status]
|
441
|
+
assert_equal 1, result[:move_number]
|
413
442
|
end
|
414
443
|
|
415
444
|
def test_AfterMoveDown3
|
416
445
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveDown3))
|
417
|
-
ins.
|
446
|
+
ins.move(:down)
|
418
447
|
assert_equal AfterMoveDown3, ins.map
|
419
448
|
end
|
420
449
|
|
@@ -432,12 +461,14 @@ class TC_Level < Test::Unit::TestCase
|
|
432
461
|
|
433
462
|
def test_CanMoveDown4
|
434
463
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveDown4))
|
435
|
-
|
464
|
+
result = ins.move(:down)
|
465
|
+
assert_equal :win, result[:status]
|
466
|
+
assert_equal 1, result[:move_number]
|
436
467
|
end
|
437
468
|
|
438
469
|
def test_AfterMoveDown4
|
439
470
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveDown4))
|
440
|
-
ins.
|
471
|
+
ins.move(:down)
|
441
472
|
assert_equal AfterMoveDown4, ins.map
|
442
473
|
end
|
443
474
|
|
@@ -447,7 +478,9 @@ class TC_Level < Test::Unit::TestCase
|
|
447
478
|
|
448
479
|
def test_CannotMoveDown1
|
449
480
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveDown1))
|
450
|
-
|
481
|
+
result = ins.move(:down)
|
482
|
+
assert_equal :error, result[:status]
|
483
|
+
assert_equal 'wall', result[:message]
|
451
484
|
assert_equal CannotMoveDown1, ins.map
|
452
485
|
end
|
453
486
|
|
@@ -458,7 +491,9 @@ class TC_Level < Test::Unit::TestCase
|
|
458
491
|
|
459
492
|
def test_CannotMoveDown2
|
460
493
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveDown2))
|
461
|
-
|
494
|
+
result = ins.move(:down)
|
495
|
+
assert_equal :error, result[:status]
|
496
|
+
assert_equal 'wall behind crate', result[:message]
|
462
497
|
assert_equal CannotMoveDown2, ins.map
|
463
498
|
end
|
464
499
|
|
@@ -471,7 +506,9 @@ class TC_Level < Test::Unit::TestCase
|
|
471
506
|
|
472
507
|
def test_CannotMoveDown3
|
473
508
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveDown3))
|
474
|
-
|
509
|
+
result = ins.move(:down)
|
510
|
+
assert_equal :error, result[:status]
|
511
|
+
assert_equal 'double crate', result[:message]
|
475
512
|
assert_equal CannotMoveDown3, ins.map
|
476
513
|
end
|
477
514
|
|
@@ -484,7 +521,9 @@ class TC_Level < Test::Unit::TestCase
|
|
484
521
|
|
485
522
|
def test_CannotMoveDown4
|
486
523
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveDown4))
|
487
|
-
|
524
|
+
result = ins.move(:down)
|
525
|
+
assert_equal :error, result[:status]
|
526
|
+
assert_equal 'double crate', result[:message]
|
488
527
|
assert_equal CannotMoveDown4, ins.map
|
489
528
|
end
|
490
529
|
|
@@ -497,7 +536,9 @@ class TC_Level < Test::Unit::TestCase
|
|
497
536
|
|
498
537
|
def test_CannotMoveDown5
|
499
538
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveDown5))
|
500
|
-
|
539
|
+
result = ins.move(:down)
|
540
|
+
assert_equal :error, result[:status]
|
541
|
+
assert_equal 'double crate', result[:message]
|
501
542
|
assert_equal CannotMoveDown5, ins.map
|
502
543
|
end
|
503
544
|
|
@@ -510,7 +551,9 @@ class TC_Level < Test::Unit::TestCase
|
|
510
551
|
|
511
552
|
def test_CannotMoveDown6
|
512
553
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveDown6))
|
513
|
-
|
554
|
+
result = ins.move(:down)
|
555
|
+
assert_equal :error, result[:status]
|
556
|
+
assert_equal 'double crate', result[:message]
|
514
557
|
assert_equal CannotMoveDown6, ins.map
|
515
558
|
end
|
516
559
|
|
@@ -526,12 +569,14 @@ class TC_Level < Test::Unit::TestCase
|
|
526
569
|
|
527
570
|
def test_CanMoveLeft1
|
528
571
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveLeft1))
|
529
|
-
|
572
|
+
result = ins.move(:left)
|
573
|
+
assert_equal :ok, result[:status]
|
574
|
+
assert_equal 1, result[:move_number]
|
530
575
|
end
|
531
576
|
|
532
577
|
def test_AfterMoveLeft1
|
533
578
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveLeft1))
|
534
|
-
ins.
|
579
|
+
ins.move(:left)
|
535
580
|
assert_equal AfterMoveLeft1, ins.map
|
536
581
|
end
|
537
582
|
|
@@ -545,12 +590,14 @@ class TC_Level < Test::Unit::TestCase
|
|
545
590
|
|
546
591
|
def test_CanMoveLeft2
|
547
592
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveLeft2))
|
548
|
-
|
593
|
+
result = ins.move(:left)
|
594
|
+
assert_equal :ok, result[:status]
|
595
|
+
assert_equal 1, result[:move_number]
|
549
596
|
end
|
550
597
|
|
551
598
|
def test_AfterMoveLeft2
|
552
599
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveLeft2))
|
553
|
-
ins.
|
600
|
+
ins.move(:left)
|
554
601
|
assert_equal AfterMoveLeft2, ins.map
|
555
602
|
end
|
556
603
|
|
@@ -564,12 +611,14 @@ class TC_Level < Test::Unit::TestCase
|
|
564
611
|
|
565
612
|
def test_CanMoveLeft3
|
566
613
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveLeft3))
|
567
|
-
|
614
|
+
result = ins.move(:left)
|
615
|
+
assert_equal :ok, result[:status]
|
616
|
+
assert_equal 1, result[:move_number]
|
568
617
|
end
|
569
618
|
|
570
619
|
def test_AfterMoveLeft3
|
571
620
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveLeft3))
|
572
|
-
ins.
|
621
|
+
ins.move(:left)
|
573
622
|
assert_equal AfterMoveLeft3, ins.map
|
574
623
|
end
|
575
624
|
|
@@ -583,12 +632,14 @@ class TC_Level < Test::Unit::TestCase
|
|
583
632
|
|
584
633
|
def test_CanMoveLeft4
|
585
634
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveLeft4))
|
586
|
-
|
635
|
+
result = ins.move(:left)
|
636
|
+
assert_equal :win, result[:status]
|
637
|
+
assert_equal 1, result[:move_number]
|
587
638
|
end
|
588
639
|
|
589
640
|
def test_AfterMoveLeft4
|
590
641
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveLeft4))
|
591
|
-
ins.
|
642
|
+
ins.move(:left)
|
592
643
|
assert_equal AfterMoveLeft4, ins.map
|
593
644
|
end
|
594
645
|
|
@@ -598,7 +649,9 @@ class TC_Level < Test::Unit::TestCase
|
|
598
649
|
|
599
650
|
def test_CannotMoveLeft1
|
600
651
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveLeft1))
|
601
|
-
|
652
|
+
result = ins.move(:left)
|
653
|
+
assert_equal :error, result[:status]
|
654
|
+
assert_equal 'wall', result[:message]
|
602
655
|
assert_equal CannotMoveLeft1, ins.map
|
603
656
|
end
|
604
657
|
|
@@ -608,7 +661,9 @@ class TC_Level < Test::Unit::TestCase
|
|
608
661
|
|
609
662
|
def test_CannotMoveLeft2
|
610
663
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveLeft2))
|
611
|
-
|
664
|
+
result = ins.move(:left)
|
665
|
+
assert_equal :error, result[:status]
|
666
|
+
assert_equal 'wall behind crate', result[:message]
|
612
667
|
assert_equal CannotMoveLeft2, ins.map
|
613
668
|
end
|
614
669
|
|
@@ -618,7 +673,9 @@ class TC_Level < Test::Unit::TestCase
|
|
618
673
|
|
619
674
|
def test_CannotMoveLeft3
|
620
675
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveLeft3))
|
621
|
-
|
676
|
+
result = ins.move(:left)
|
677
|
+
assert_equal :error, result[:status]
|
678
|
+
assert_equal 'double crate', result[:message]
|
622
679
|
assert_equal CannotMoveLeft3, ins.map
|
623
680
|
end
|
624
681
|
|
@@ -634,12 +691,14 @@ class TC_Level < Test::Unit::TestCase
|
|
634
691
|
|
635
692
|
def test_CanMoveRight1
|
636
693
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveRight1))
|
637
|
-
|
694
|
+
result = ins.move(:right)
|
695
|
+
assert_equal :ok, result[:status]
|
696
|
+
assert_equal 1, result[:move_number]
|
638
697
|
end
|
639
698
|
|
640
699
|
def test_AfterMoveRight1
|
641
700
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveRight1))
|
642
|
-
ins.
|
701
|
+
ins.move(:right)
|
643
702
|
assert_equal AfterMoveRight1, ins.map
|
644
703
|
end
|
645
704
|
|
@@ -653,12 +712,14 @@ class TC_Level < Test::Unit::TestCase
|
|
653
712
|
|
654
713
|
def test_CanMoveRight2
|
655
714
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveRight2))
|
656
|
-
|
715
|
+
result = ins.move(:right)
|
716
|
+
assert_equal :ok, result[:status]
|
717
|
+
assert_equal 1, result[:move_number]
|
657
718
|
end
|
658
719
|
|
659
720
|
def test_AfterMoveRight2
|
660
721
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveRight2))
|
661
|
-
ins.
|
722
|
+
ins.move(:right)
|
662
723
|
assert_equal AfterMoveRight2, ins.map
|
663
724
|
end
|
664
725
|
|
@@ -672,12 +733,14 @@ class TC_Level < Test::Unit::TestCase
|
|
672
733
|
|
673
734
|
def test_CanMoveRight3
|
674
735
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveRight3))
|
675
|
-
|
736
|
+
result = ins.move(:right)
|
737
|
+
assert_equal :ok, result[:status]
|
738
|
+
assert_equal 1, result[:move_number]
|
676
739
|
end
|
677
740
|
|
678
741
|
def test_AfterMoveRight3
|
679
742
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveRight3))
|
680
|
-
ins.
|
743
|
+
ins.move(:right)
|
681
744
|
assert_equal AfterMoveRight3, ins.map
|
682
745
|
end
|
683
746
|
|
@@ -691,12 +754,14 @@ class TC_Level < Test::Unit::TestCase
|
|
691
754
|
|
692
755
|
def test_CanMoveRight4
|
693
756
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveRight4))
|
694
|
-
|
757
|
+
result = ins.move(:right)
|
758
|
+
assert_equal :win, result[:status]
|
759
|
+
assert_equal 1, result[:move_number]
|
695
760
|
end
|
696
761
|
|
697
762
|
def test_AfterMoveRight4
|
698
763
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveRight4))
|
699
|
-
ins.
|
764
|
+
ins.move(:right)
|
700
765
|
assert_equal AfterMoveRight4, ins.map
|
701
766
|
end
|
702
767
|
|
@@ -706,7 +771,9 @@ class TC_Level < Test::Unit::TestCase
|
|
706
771
|
|
707
772
|
def test_CannotMoveRight1
|
708
773
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveRight1))
|
709
|
-
|
774
|
+
result = ins.move(:right)
|
775
|
+
assert_equal :error, result[:status]
|
776
|
+
assert_equal 'wall', result[:message]
|
710
777
|
assert_equal CannotMoveRight1, ins.map
|
711
778
|
end
|
712
779
|
|
@@ -716,7 +783,9 @@ class TC_Level < Test::Unit::TestCase
|
|
716
783
|
|
717
784
|
def test_CannotMoveRight2
|
718
785
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveRight2))
|
719
|
-
|
786
|
+
result = ins.move(:right)
|
787
|
+
assert_equal :error, result[:status]
|
788
|
+
assert_equal 'wall behind crate', result[:message]
|
720
789
|
assert_equal CannotMoveRight2, ins.map
|
721
790
|
end
|
722
791
|
|
@@ -726,7 +795,9 @@ class TC_Level < Test::Unit::TestCase
|
|
726
795
|
|
727
796
|
def test_CannotMoveRight3
|
728
797
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveRight3))
|
729
|
-
|
798
|
+
result = ins.move(:right)
|
799
|
+
assert_equal :error, result[:status]
|
800
|
+
assert_equal 'double crate', result[:message]
|
730
801
|
assert_equal CannotMoveRight3, ins.map
|
731
802
|
end
|
732
803
|
|
@@ -738,10 +809,12 @@ class TC_Level < Test::Unit::TestCase
|
|
738
809
|
|
739
810
|
def test_solution_avec_une_seule_caisse
|
740
811
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', Win1))
|
741
|
-
|
812
|
+
result = ins.move(:right)
|
813
|
+
assert_equal :win, result[:status]
|
814
|
+
assert_equal 1, result[:move_number]
|
742
815
|
end
|
743
816
|
|
744
|
-
###
|
817
|
+
### BUGS #######################################
|
745
818
|
|
746
819
|
# I need a 'crate on storage' in 1, 1. But Level#new don't know how to parse this.
|
747
820
|
# This is the picture I really want to test :
|
@@ -757,7 +830,7 @@ class TC_Level < Test::Unit::TestCase
|
|
757
830
|
'#.#',
|
758
831
|
'###']
|
759
832
|
|
760
|
-
def
|
833
|
+
def test_bug_first
|
761
834
|
ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveUpBug1))
|
762
835
|
# Changing 'o' to '*'
|
763
836
|
def ins.addStorage
|
@@ -768,6 +841,8 @@ class TC_Level < Test::Unit::TestCase
|
|
768
841
|
# I need to be sure that coord 1, 1 is '*'
|
769
842
|
assert_equal '#*#', ins.map[1]
|
770
843
|
|
771
|
-
|
844
|
+
result = ins.move(:up)
|
845
|
+
assert_equal :error, result[:status]
|
846
|
+
assert_equal 'wall behind crate', result[:message]
|
772
847
|
end
|
773
848
|
end
|