RSokoban 0.74 → 0.76

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. data/NEWS +33 -1
  2. data/README.rdoc +21 -14
  3. data/TODO +6 -12
  4. data/VERSION +1 -1
  5. data/bin/rsokoban +40 -3
  6. data/data/big.xsb +35 -0
  7. data/lib/rsokoban/config.rb +34 -0
  8. data/lib/rsokoban/crate.rb +4 -5
  9. data/lib/rsokoban/exception.rb +2 -0
  10. data/lib/rsokoban/game/game.rb +153 -0
  11. data/lib/rsokoban/game/game_curses.rb +11 -0
  12. data/lib/rsokoban/game/game_factory.rb +23 -0
  13. data/lib/rsokoban/game/game_gui.rb +27 -0
  14. data/lib/rsokoban/game/game_portable.rb +10 -0
  15. data/lib/rsokoban/game/game_tk.rb +11 -0
  16. data/lib/rsokoban/game/game_ui.rb +81 -0
  17. data/lib/rsokoban/game.rb +7 -238
  18. data/lib/rsokoban/install.rb +22 -0
  19. data/lib/rsokoban/layered_map.rb +139 -0
  20. data/lib/rsokoban/level.rb +112 -166
  21. data/lib/rsokoban/level_set.rb +4 -4
  22. data/lib/rsokoban/man.rb +3 -4
  23. data/lib/rsokoban/map.rb +91 -15
  24. data/lib/rsokoban/move_result.rb +2 -2
  25. data/lib/rsokoban/option.rb +4 -4
  26. data/lib/rsokoban/position.rb +1 -1
  27. data/lib/rsokoban/raw_level.rb +11 -2
  28. data/lib/rsokoban/record.rb +51 -0
  29. data/lib/rsokoban/set_loader.rb +108 -0
  30. data/lib/rsokoban/ui/base_ui.rb +1 -0
  31. data/lib/rsokoban/ui/console.rb +56 -25
  32. data/lib/rsokoban/ui/curses_console.rb +59 -33
  33. data/lib/rsokoban/ui/player_action.rb +13 -7
  34. data/lib/rsokoban/ui/skin.rb +105 -0
  35. data/lib/rsokoban/ui/tk_dialogs.rb +104 -18
  36. data/lib/rsokoban/ui/tk_ui.rb +410 -233
  37. data/lib/rsokoban/ui.rb +1 -0
  38. data/lib/rsokoban.rb +14 -2
  39. data/skins/AntiqueDesk/crate.bmp +0 -0
  40. data/skins/AntiqueDesk/crate_store.bmp +0 -0
  41. data/skins/AntiqueDesk/floor.bmp +0 -0
  42. data/skins/AntiqueDesk/man_down.bmp +0 -0
  43. data/skins/AntiqueDesk/man_left.bmp +0 -0
  44. data/skins/AntiqueDesk/man_right.bmp +0 -0
  45. data/skins/AntiqueDesk/man_store_down.bmp +0 -0
  46. data/skins/AntiqueDesk/man_store_left.bmp +0 -0
  47. data/skins/AntiqueDesk/man_store_right.bmp +0 -0
  48. data/skins/AntiqueDesk/man_store_up.bmp +0 -0
  49. data/skins/AntiqueDesk/man_up.bmp +0 -0
  50. data/skins/AntiqueDesk/outside.bmp +0 -0
  51. data/skins/AntiqueDesk/skin.conf +3 -0
  52. data/skins/AntiqueDesk/store.bmp +0 -0
  53. data/skins/AntiqueDesk/wall.bmp +0 -0
  54. data/skins/BlueGranite/outside.bmp +0 -0
  55. data/skins/BlueGranite/skin.conf +3 -0
  56. data/skins/HeavyMetal/crate.bmp +0 -0
  57. data/skins/HeavyMetal/crate_store.bmp +0 -0
  58. data/skins/HeavyMetal/floor.bmp +0 -0
  59. data/skins/HeavyMetal/man.bmp +0 -0
  60. data/skins/HeavyMetal/man_store.bmp +0 -0
  61. data/skins/HeavyMetal/outside.bmp +0 -0
  62. data/skins/HeavyMetal/skin.conf +3 -0
  63. data/skins/HeavyMetal/store.bmp +0 -0
  64. data/skins/HeavyMetal/wall.bmp +0 -0
  65. data/skins/HeavyMetal/wall_d.bmp +0 -0
  66. data/skins/HeavyMetal/wall_dl.bmp +0 -0
  67. data/skins/HeavyMetal/wall_dlr.bmp +0 -0
  68. data/skins/HeavyMetal/wall_dr.bmp +0 -0
  69. data/skins/HeavyMetal/wall_l.bmp +0 -0
  70. data/skins/HeavyMetal/wall_lr.bmp +0 -0
  71. data/skins/HeavyMetal/wall_r.bmp +0 -0
  72. data/skins/HeavyMetal/wall_u.bmp +0 -0
  73. data/skins/HeavyMetal/wall_ud.bmp +0 -0
  74. data/skins/HeavyMetal/wall_udl.bmp +0 -0
  75. data/skins/HeavyMetal/wall_udlr.bmp +0 -0
  76. data/skins/HeavyMetal/wall_udr.bmp +0 -0
  77. data/skins/HeavyMetal/wall_ul.bmp +0 -0
  78. data/skins/HeavyMetal/wall_ulr.bmp +0 -0
  79. data/skins/HeavyMetal/wall_ur.bmp +0 -0
  80. data/test/record/original.yaml +2 -0
  81. data/test/tc_game.rb +24 -15
  82. data/test/tc_game_factory.rb +40 -0
  83. data/test/tc_game_gui.rb +26 -0
  84. data/test/tc_game_ui.rb +153 -0
  85. data/test/tc_install.rb +12 -0
  86. data/test/tc_layered_map.rb +105 -0
  87. data/test/tc_level.rb +109 -107
  88. data/test/tc_level_set.rb +4 -4
  89. data/test/tc_map.rb +46 -10
  90. data/test/tc_record.rb +100 -0
  91. data/test/{tc_level_loader.rb → tc_set_loader.rb} +25 -24
  92. data/test/test.rb +9 -2
  93. data/test/ui/tc_skin.rb +71 -0
  94. metadata +89 -26
  95. data/lib/rsokoban/level_loader.rb +0 -81
  96. data/lib/rsokoban/ui/tk_box.rb +0 -21
  97. data/skins/default/outside.bmp +0 -0
  98. data/skins/default/readme +0 -1
  99. /data/skins/{default → BlueGranite}/crate.bmp +0 -0
  100. /data/skins/{default → BlueGranite}/crate_store.bmp +0 -0
  101. /data/skins/{default → BlueGranite}/floor.bmp +0 -0
  102. /data/skins/{default → BlueGranite}/man_down.bmp +0 -0
  103. /data/skins/{default → BlueGranite}/man_left.bmp +0 -0
  104. /data/skins/{default → BlueGranite}/man_right.bmp +0 -0
  105. /data/skins/{default → BlueGranite}/man_store_down.bmp +0 -0
  106. /data/skins/{default → BlueGranite}/man_store_left.bmp +0 -0
  107. /data/skins/{default → BlueGranite}/man_store_right.bmp +0 -0
  108. /data/skins/{default → BlueGranite}/man_store_up.bmp +0 -0
  109. /data/skins/{default → BlueGranite}/man_up.bmp +0 -0
  110. /data/skins/{default → BlueGranite}/store.bmp +0 -0
  111. /data/skins/{default → BlueGranite}/wall.bmp +0 -0
data/test/tc_level.rb CHANGED
@@ -1,5 +1,6 @@
1
1
 
2
2
  class TC_Level < Test::Unit::TestCase
3
+ include RSokoban
3
4
 
4
5
  Text1 = [ '#####',
5
6
  '#.$@#',
@@ -18,14 +19,14 @@ class TC_Level < Test::Unit::TestCase
18
19
  '####']
19
20
 
20
21
  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))
22
+ @text_1 = Level.new(RawLevel.new('1', Text1))
23
+ @text_2 = Level.new(RawLevel.new('1', Text2))
24
+ @text_3 = Level.new(RawLevel.new('1', Text3))
25
+ @original_1 = Level.new(RawLevel.new('1', Level1))
25
26
  end
26
27
 
27
28
  def test_instance
28
- assert_equal true, @text_1.instance_of?(RSokoban::Level), "Must be an instance of RSokoban::Level"
29
+ assert_equal true, @text_1.instance_of?(Level), "Must be an instance of Level"
29
30
  end
30
31
 
31
32
  def test_move_number
@@ -62,7 +63,7 @@ class TC_Level < Test::Unit::TestCase
62
63
  end
63
64
 
64
65
  def test_crates_contains_some_crate
65
- assert_equal true, @text_1.crates[0].instance_of?(RSokoban::Crate)
66
+ assert_equal true, @text_1.crates[0].instance_of?(Crate)
66
67
  end
67
68
 
68
69
  def test_crates_with_Text2_must_be_of_size_3
@@ -101,7 +102,7 @@ class TC_Level < Test::Unit::TestCase
101
102
  end
102
103
 
103
104
  def test_storages_contains_some_storage
104
- assert_equal true, @text_1.storages[0].instance_of?(RSokoban::Storage)
105
+ assert_equal true, @text_1.storages[0].instance_of?(Storage)
105
106
  end
106
107
 
107
108
  def test_storages_positions
@@ -124,7 +125,7 @@ class TC_Level < Test::Unit::TestCase
124
125
  end
125
126
 
126
127
  def test_equality
127
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', Text3))
128
+ ins = Level.new(RawLevel.new('1', Text3))
128
129
  assert ins == @text_3
129
130
  end
130
131
 
@@ -141,7 +142,7 @@ class TC_Level < Test::Unit::TestCase
141
142
  ' #######']
142
143
 
143
144
  def test_rawLevel
144
- assert_equal Level1, @original_1.map
145
+ assert_equal Level1, @original_1.map_as_array
145
146
  end
146
147
 
147
148
  def test_width
@@ -152,22 +153,23 @@ class TC_Level < Test::Unit::TestCase
152
153
  assert_equal 11, @original_1.height
153
154
  end
154
155
 
155
- Level1_u = [' #####',
156
- ' # #',
157
- ' #$ #',
158
- ' ### $##',
159
- ' # $ $ #',
160
- '### # ## # ######',
156
+ Level1_u = [
157
+ 'oooo#####oooooooooo',
158
+ 'oooo# #oooooooooo',
159
+ 'oooo#$ #oooooooooo',
160
+ 'oo### $##ooooooooo',
161
+ 'oo# $ $ #ooooooooo',
162
+ '### # ## #ooo######',
161
163
  '# # ## ##### ..#',
162
164
  '# $ $ @ ..#',
163
165
  '##### ### # ## ..#',
164
- ' # #########',
165
- ' #######']
166
+ 'oooo# #########',
167
+ 'oooo#######oooooooo']
166
168
 
167
169
  def test_rawLevel_after_move_up
168
170
  ins = @original_1
169
171
  ins.move(:up)
170
- assert_equal Level1_u, ins.map
172
+ assert_equal Level1_u, ins.map_as_array
171
173
  end
172
174
 
173
175
  Text4 = [ '####',
@@ -177,7 +179,7 @@ class TC_Level < Test::Unit::TestCase
177
179
  '####']
178
180
 
179
181
  def test_crate_on_storage_at_startup
180
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', Text4))
182
+ ins = Level.new(RawLevel.new('1', Text4))
181
183
  result = ins.move(:up)
182
184
  assert_equal :win, result[:status]
183
185
  assert_equal 1, result[:move_number]
@@ -196,7 +198,7 @@ class TC_Level < Test::Unit::TestCase
196
198
  '###']
197
199
 
198
200
  def test_CanMoveUp1
199
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveUp1))
201
+ ins = Level.new(RawLevel.new('1', CanMoveUp1))
200
202
  result = ins.move(:up)
201
203
  assert_equal :ok, result[:status]
202
204
  assert_equal 1, result[:move_number]
@@ -205,9 +207,9 @@ class TC_Level < Test::Unit::TestCase
205
207
  end
206
208
 
207
209
  def test_AfterMoveUp1
208
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveUp1))
210
+ ins = Level.new(RawLevel.new('1', CanMoveUp1))
209
211
  ins.move(:up)
210
- assert_equal AfterMoveUp1, ins.map
212
+ assert_equal AfterMoveUp1, ins.map_as_array
211
213
  end
212
214
 
213
215
  CanMoveUp2 = ['###',
@@ -221,7 +223,7 @@ class TC_Level < Test::Unit::TestCase
221
223
  '###']
222
224
 
223
225
  def test_CanMoveUp2
224
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveUp2))
226
+ ins = Level.new(RawLevel.new('1', CanMoveUp2))
225
227
  result = ins.move(:up)
226
228
  assert_equal :ok, result[:status]
227
229
  assert_equal 1, result[:move_number]
@@ -230,9 +232,9 @@ class TC_Level < Test::Unit::TestCase
230
232
  end
231
233
 
232
234
  def test_AfterMoveUp2
233
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveUp2))
235
+ ins = Level.new(RawLevel.new('1', CanMoveUp2))
234
236
  ins.move(:up)
235
- assert_equal AfterMoveUp2, ins.map
237
+ assert_equal AfterMoveUp2, ins.map_as_array
236
238
  end
237
239
 
238
240
  CanMoveUp3 = ['###',
@@ -248,7 +250,7 @@ class TC_Level < Test::Unit::TestCase
248
250
  '###']
249
251
 
250
252
  def test_CanMoveUp3
251
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveUp3))
253
+ ins = Level.new(RawLevel.new('1', CanMoveUp3))
252
254
  result = ins.move(:up)
253
255
  assert_equal :ok, result[:status]
254
256
  assert_equal 1, result[:move_number]
@@ -257,9 +259,9 @@ class TC_Level < Test::Unit::TestCase
257
259
  end
258
260
 
259
261
  def test_AfterMoveUp3
260
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveUp3))
262
+ ins = Level.new(RawLevel.new('1', CanMoveUp3))
261
263
  ins.move(:up)
262
- assert_equal AfterMoveUp3, ins.map
264
+ assert_equal AfterMoveUp3, ins.map_as_array
263
265
  end
264
266
 
265
267
  CanMoveUp4 = ['###',
@@ -275,7 +277,7 @@ class TC_Level < Test::Unit::TestCase
275
277
  '###']
276
278
 
277
279
  def test_CanMoveUp4
278
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveUp4))
280
+ ins = Level.new(RawLevel.new('1', CanMoveUp4))
279
281
  result = ins.move(:up)
280
282
  assert_equal :win, result[:status]
281
283
  assert_equal 1, result[:move_number]
@@ -284,9 +286,9 @@ class TC_Level < Test::Unit::TestCase
284
286
  end
285
287
 
286
288
  def test_AfterMoveUp4
287
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveUp4))
289
+ ins = Level.new(RawLevel.new('1', CanMoveUp4))
288
290
  ins.move(:up)
289
- assert_equal AfterMoveUp4, ins.map
291
+ assert_equal AfterMoveUp4, ins.map_as_array
290
292
  end
291
293
 
292
294
  CannotMoveUp1 = ['###',
@@ -294,11 +296,11 @@ class TC_Level < Test::Unit::TestCase
294
296
  '###']
295
297
 
296
298
  def test_CannotMoveUp1
297
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveUp1))
299
+ ins = Level.new(RawLevel.new('1', CannotMoveUp1))
298
300
  result = ins.move(:up)
299
301
  assert_equal :error, result[:status]
300
302
  assert_equal 'wall', result[:message]
301
- assert_equal CannotMoveUp1, ins.map
303
+ assert_equal CannotMoveUp1, ins.map_as_array
302
304
  end
303
305
 
304
306
  CannotMoveUp2 = ['###',
@@ -307,11 +309,11 @@ class TC_Level < Test::Unit::TestCase
307
309
  '###']
308
310
 
309
311
  def test_CannotMoveUp2
310
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveUp2))
312
+ ins = Level.new(RawLevel.new('1', CannotMoveUp2))
311
313
  result = ins.move(:up)
312
314
  assert_equal :error, result[:status]
313
315
  assert_equal 'wall behind crate', result[:message]
314
- assert_equal CannotMoveUp2, ins.map
316
+ assert_equal CannotMoveUp2, ins.map_as_array
315
317
  end
316
318
 
317
319
  CannotMoveUp3 = ['###',
@@ -322,11 +324,11 @@ class TC_Level < Test::Unit::TestCase
322
324
  '###']
323
325
 
324
326
  def test_CannotMoveUp3
325
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveUp3))
327
+ ins = Level.new(RawLevel.new('1', CannotMoveUp3))
326
328
  result = ins.move(:up)
327
329
  assert_equal :error, result[:status]
328
330
  assert_equal 'double crate', result[:message]
329
- assert_equal CannotMoveUp3, ins.map
331
+ assert_equal CannotMoveUp3, ins.map_as_array
330
332
  end
331
333
 
332
334
  CannotMoveUp4 = ['###',
@@ -337,11 +339,11 @@ class TC_Level < Test::Unit::TestCase
337
339
  '###']
338
340
 
339
341
  def test_CannotMoveUp4
340
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveUp4))
342
+ ins = Level.new(RawLevel.new('1', CannotMoveUp4))
341
343
  result = ins.move(:up)
342
344
  assert_equal :error, result[:status]
343
345
  assert_equal 'double crate', result[:message]
344
- assert_equal CannotMoveUp4, ins.map
346
+ assert_equal CannotMoveUp4, ins.map_as_array
345
347
  end
346
348
 
347
349
  CannotMoveUp5 = ['###',
@@ -352,11 +354,11 @@ class TC_Level < Test::Unit::TestCase
352
354
  '###']
353
355
 
354
356
  def test_CannotMoveUp5
355
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveUp5))
357
+ ins = Level.new(RawLevel.new('1', CannotMoveUp5))
356
358
  result = ins.move(:up)
357
359
  assert_equal :error, result[:status]
358
360
  assert_equal 'double crate', result[:message]
359
- assert_equal CannotMoveUp5, ins.map
361
+ assert_equal CannotMoveUp5, ins.map_as_array
360
362
  end
361
363
 
362
364
  CannotMoveUp6 = ['###',
@@ -367,11 +369,11 @@ class TC_Level < Test::Unit::TestCase
367
369
  '###']
368
370
 
369
371
  def test_CannotMoveUp6
370
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveUp6))
372
+ ins = Level.new(RawLevel.new('1', CannotMoveUp6))
371
373
  result = ins.move(:up)
372
374
  assert_equal :error, result[:status]
373
375
  assert_equal 'double crate', result[:message]
374
- assert_equal CannotMoveUp6, ins.map
376
+ assert_equal CannotMoveUp6, ins.map_as_array
375
377
  end
376
378
 
377
379
  ### Move down ##############################################
@@ -387,16 +389,16 @@ class TC_Level < Test::Unit::TestCase
387
389
  '###']
388
390
 
389
391
  def test_CanMoveDown1
390
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveDown1))
392
+ ins = Level.new(RawLevel.new('1', CanMoveDown1))
391
393
  result = ins.move(:down)
392
394
  assert_equal :ok, result[:status]
393
395
  assert_equal 1, result[:move_number]
394
396
  end
395
397
 
396
398
  def test_AfterMoveDown1
397
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveDown1))
399
+ ins = Level.new(RawLevel.new('1', CanMoveDown1))
398
400
  ins.move(:down)
399
- assert_equal AfterMoveDown1, ins.map
401
+ assert_equal AfterMoveDown1, ins.map_as_array
400
402
  end
401
403
 
402
404
  CanMoveDown2 = ['###',
@@ -410,16 +412,16 @@ class TC_Level < Test::Unit::TestCase
410
412
  '###']
411
413
 
412
414
  def test_CanMoveDown2
413
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveDown2))
415
+ ins = Level.new(RawLevel.new('1', CanMoveDown2))
414
416
  result = ins.move(:down)
415
417
  assert_equal :ok, result[:status]
416
418
  assert_equal 1, result[:move_number]
417
419
  end
418
420
 
419
421
  def test_AfterMoveDown2
420
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveDown2))
422
+ ins = Level.new(RawLevel.new('1', CanMoveDown2))
421
423
  ins.move(:down)
422
- assert_equal AfterMoveDown2, ins.map
424
+ assert_equal AfterMoveDown2, ins.map_as_array
423
425
  end
424
426
 
425
427
  CanMoveDown3 = ['###',
@@ -435,16 +437,16 @@ class TC_Level < Test::Unit::TestCase
435
437
  '###']
436
438
 
437
439
  def test_CanMoveDown3
438
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveDown3))
440
+ ins = Level.new(RawLevel.new('1', CanMoveDown3))
439
441
  result = ins.move(:down)
440
442
  assert_equal :ok, result[:status]
441
443
  assert_equal 1, result[:move_number]
442
444
  end
443
445
 
444
446
  def test_AfterMoveDown3
445
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveDown3))
447
+ ins = Level.new(RawLevel.new('1', CanMoveDown3))
446
448
  ins.move(:down)
447
- assert_equal AfterMoveDown3, ins.map
449
+ assert_equal AfterMoveDown3, ins.map_as_array
448
450
  end
449
451
 
450
452
  CanMoveDown4 = ['###',
@@ -460,16 +462,16 @@ class TC_Level < Test::Unit::TestCase
460
462
  '###']
461
463
 
462
464
  def test_CanMoveDown4
463
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveDown4))
465
+ ins = Level.new(RawLevel.new('1', CanMoveDown4))
464
466
  result = ins.move(:down)
465
467
  assert_equal :win, result[:status]
466
468
  assert_equal 1, result[:move_number]
467
469
  end
468
470
 
469
471
  def test_AfterMoveDown4
470
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveDown4))
472
+ ins = Level.new(RawLevel.new('1', CanMoveDown4))
471
473
  ins.move(:down)
472
- assert_equal AfterMoveDown4, ins.map
474
+ assert_equal AfterMoveDown4, ins.map_as_array
473
475
  end
474
476
 
475
477
  CannotMoveDown1 = ['###',
@@ -477,11 +479,11 @@ class TC_Level < Test::Unit::TestCase
477
479
  '###']
478
480
 
479
481
  def test_CannotMoveDown1
480
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveDown1))
482
+ ins = Level.new(RawLevel.new('1', CannotMoveDown1))
481
483
  result = ins.move(:down)
482
484
  assert_equal :error, result[:status]
483
485
  assert_equal 'wall', result[:message]
484
- assert_equal CannotMoveDown1, ins.map
486
+ assert_equal CannotMoveDown1, ins.map_as_array
485
487
  end
486
488
 
487
489
  CannotMoveDown2 = ['###',
@@ -490,11 +492,11 @@ class TC_Level < Test::Unit::TestCase
490
492
  '###']
491
493
 
492
494
  def test_CannotMoveDown2
493
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveDown2))
495
+ ins = Level.new(RawLevel.new('1', CannotMoveDown2))
494
496
  result = ins.move(:down)
495
497
  assert_equal :error, result[:status]
496
498
  assert_equal 'wall behind crate', result[:message]
497
- assert_equal CannotMoveDown2, ins.map
499
+ assert_equal CannotMoveDown2, ins.map_as_array
498
500
  end
499
501
 
500
502
  CannotMoveDown3 = ['###',
@@ -505,11 +507,11 @@ class TC_Level < Test::Unit::TestCase
505
507
  '###']
506
508
 
507
509
  def test_CannotMoveDown3
508
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveDown3))
510
+ ins = Level.new(RawLevel.new('1', CannotMoveDown3))
509
511
  result = ins.move(:down)
510
512
  assert_equal :error, result[:status]
511
513
  assert_equal 'double crate', result[:message]
512
- assert_equal CannotMoveDown3, ins.map
514
+ assert_equal CannotMoveDown3, ins.map_as_array
513
515
  end
514
516
 
515
517
  CannotMoveDown4 = ['###',
@@ -520,11 +522,11 @@ class TC_Level < Test::Unit::TestCase
520
522
  '###']
521
523
 
522
524
  def test_CannotMoveDown4
523
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveDown4))
525
+ ins = Level.new(RawLevel.new('1', CannotMoveDown4))
524
526
  result = ins.move(:down)
525
527
  assert_equal :error, result[:status]
526
528
  assert_equal 'double crate', result[:message]
527
- assert_equal CannotMoveDown4, ins.map
529
+ assert_equal CannotMoveDown4, ins.map_as_array
528
530
  end
529
531
 
530
532
  CannotMoveDown5 = ['###',
@@ -535,11 +537,11 @@ class TC_Level < Test::Unit::TestCase
535
537
  '###']
536
538
 
537
539
  def test_CannotMoveDown5
538
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveDown5))
540
+ ins = Level.new(RawLevel.new('1', CannotMoveDown5))
539
541
  result = ins.move(:down)
540
542
  assert_equal :error, result[:status]
541
543
  assert_equal 'double crate', result[:message]
542
- assert_equal CannotMoveDown5, ins.map
544
+ assert_equal CannotMoveDown5, ins.map_as_array
543
545
  end
544
546
 
545
547
  CannotMoveDown6 = ['###',
@@ -550,11 +552,11 @@ class TC_Level < Test::Unit::TestCase
550
552
  '###']
551
553
 
552
554
  def test_CannotMoveDown6
553
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveDown6))
555
+ ins = Level.new(RawLevel.new('1', CannotMoveDown6))
554
556
  result = ins.move(:down)
555
557
  assert_equal :error, result[:status]
556
558
  assert_equal 'double crate', result[:message]
557
- assert_equal CannotMoveDown6, ins.map
559
+ assert_equal CannotMoveDown6, ins.map_as_array
558
560
  end
559
561
 
560
562
  ### Move left ##############################################
@@ -568,16 +570,16 @@ class TC_Level < Test::Unit::TestCase
568
570
  '####']
569
571
 
570
572
  def test_CanMoveLeft1
571
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveLeft1))
573
+ ins = Level.new(RawLevel.new('1', CanMoveLeft1))
572
574
  result = ins.move(:left)
573
575
  assert_equal :ok, result[:status]
574
576
  assert_equal 1, result[:move_number]
575
577
  end
576
578
 
577
579
  def test_AfterMoveLeft1
578
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveLeft1))
580
+ ins = Level.new(RawLevel.new('1', CanMoveLeft1))
579
581
  ins.move(:left)
580
- assert_equal AfterMoveLeft1, ins.map
582
+ assert_equal AfterMoveLeft1, ins.map_as_array
581
583
  end
582
584
 
583
585
  CanMoveLeft2 = ['####',
@@ -589,16 +591,16 @@ class TC_Level < Test::Unit::TestCase
589
591
  '####']
590
592
 
591
593
  def test_CanMoveLeft2
592
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveLeft2))
594
+ ins = Level.new(RawLevel.new('1', CanMoveLeft2))
593
595
  result = ins.move(:left)
594
596
  assert_equal :ok, result[:status]
595
597
  assert_equal 1, result[:move_number]
596
598
  end
597
599
 
598
600
  def test_AfterMoveLeft2
599
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveLeft2))
601
+ ins = Level.new(RawLevel.new('1', CanMoveLeft2))
600
602
  ins.move(:left)
601
- assert_equal AfterMoveLeft2, ins.map
603
+ assert_equal AfterMoveLeft2, ins.map_as_array
602
604
  end
603
605
 
604
606
  CanMoveLeft3 = ['#####',
@@ -610,16 +612,16 @@ class TC_Level < Test::Unit::TestCase
610
612
  '#####']
611
613
 
612
614
  def test_CanMoveLeft3
613
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveLeft3))
615
+ ins = Level.new(RawLevel.new('1', CanMoveLeft3))
614
616
  result = ins.move(:left)
615
617
  assert_equal :ok, result[:status]
616
618
  assert_equal 1, result[:move_number]
617
619
  end
618
620
 
619
621
  def test_AfterMoveLeft3
620
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveLeft3))
622
+ ins = Level.new(RawLevel.new('1', CanMoveLeft3))
621
623
  ins.move(:left)
622
- assert_equal AfterMoveLeft3, ins.map
624
+ assert_equal AfterMoveLeft3, ins.map_as_array
623
625
  end
624
626
 
625
627
  CanMoveLeft4 = ['#####',
@@ -631,16 +633,16 @@ class TC_Level < Test::Unit::TestCase
631
633
  '#####']
632
634
 
633
635
  def test_CanMoveLeft4
634
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveLeft4))
636
+ ins = Level.new(RawLevel.new('1', CanMoveLeft4))
635
637
  result = ins.move(:left)
636
638
  assert_equal :win, result[:status]
637
639
  assert_equal 1, result[:move_number]
638
640
  end
639
641
 
640
642
  def test_AfterMoveLeft4
641
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveLeft4))
643
+ ins = Level.new(RawLevel.new('1', CanMoveLeft4))
642
644
  ins.move(:left)
643
- assert_equal AfterMoveLeft4, ins.map
645
+ assert_equal AfterMoveLeft4, ins.map_as_array
644
646
  end
645
647
 
646
648
  CannotMoveLeft1 = ['###',
@@ -648,11 +650,11 @@ class TC_Level < Test::Unit::TestCase
648
650
  '###']
649
651
 
650
652
  def test_CannotMoveLeft1
651
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveLeft1))
653
+ ins = Level.new(RawLevel.new('1', CannotMoveLeft1))
652
654
  result = ins.move(:left)
653
655
  assert_equal :error, result[:status]
654
656
  assert_equal 'wall', result[:message]
655
- assert_equal CannotMoveLeft1, ins.map
657
+ assert_equal CannotMoveLeft1, ins.map_as_array
656
658
  end
657
659
 
658
660
  CannotMoveLeft2 = ['####',
@@ -660,11 +662,11 @@ class TC_Level < Test::Unit::TestCase
660
662
  '####']
661
663
 
662
664
  def test_CannotMoveLeft2
663
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveLeft2))
665
+ ins = Level.new(RawLevel.new('1', CannotMoveLeft2))
664
666
  result = ins.move(:left)
665
667
  assert_equal :error, result[:status]
666
668
  assert_equal 'wall behind crate', result[:message]
667
- assert_equal CannotMoveLeft2, ins.map
669
+ assert_equal CannotMoveLeft2, ins.map_as_array
668
670
  end
669
671
 
670
672
  CannotMoveLeft3 = ['######',
@@ -672,11 +674,11 @@ class TC_Level < Test::Unit::TestCase
672
674
  '######']
673
675
 
674
676
  def test_CannotMoveLeft3
675
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveLeft3))
677
+ ins = Level.new(RawLevel.new('1', CannotMoveLeft3))
676
678
  result = ins.move(:left)
677
679
  assert_equal :error, result[:status]
678
680
  assert_equal 'double crate', result[:message]
679
- assert_equal CannotMoveLeft3, ins.map
681
+ assert_equal CannotMoveLeft3, ins.map_as_array
680
682
  end
681
683
 
682
684
  ### Move right ##############################################
@@ -690,16 +692,16 @@ class TC_Level < Test::Unit::TestCase
690
692
  '####']
691
693
 
692
694
  def test_CanMoveRight1
693
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveRight1))
695
+ ins = Level.new(RawLevel.new('1', CanMoveRight1))
694
696
  result = ins.move(:right)
695
697
  assert_equal :ok, result[:status]
696
698
  assert_equal 1, result[:move_number]
697
699
  end
698
700
 
699
701
  def test_AfterMoveRight1
700
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveRight1))
702
+ ins = Level.new(RawLevel.new('1', CanMoveRight1))
701
703
  ins.move(:right)
702
- assert_equal AfterMoveRight1, ins.map
704
+ assert_equal AfterMoveRight1, ins.map_as_array
703
705
  end
704
706
 
705
707
  CanMoveRight2 = ['####',
@@ -711,16 +713,16 @@ class TC_Level < Test::Unit::TestCase
711
713
  '####']
712
714
 
713
715
  def test_CanMoveRight2
714
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveRight2))
716
+ ins = Level.new(RawLevel.new('1', CanMoveRight2))
715
717
  result = ins.move(:right)
716
718
  assert_equal :ok, result[:status]
717
719
  assert_equal 1, result[:move_number]
718
720
  end
719
721
 
720
722
  def test_AfterMoveRight2
721
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveRight2))
723
+ ins = Level.new(RawLevel.new('1', CanMoveRight2))
722
724
  ins.move(:right)
723
- assert_equal AfterMoveRight2, ins.map
725
+ assert_equal AfterMoveRight2, ins.map_as_array
724
726
  end
725
727
 
726
728
  CanMoveRight3 = ['#####',
@@ -732,16 +734,16 @@ class TC_Level < Test::Unit::TestCase
732
734
  '#####']
733
735
 
734
736
  def test_CanMoveRight3
735
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveRight3))
737
+ ins = Level.new(RawLevel.new('1', CanMoveRight3))
736
738
  result = ins.move(:right)
737
739
  assert_equal :ok, result[:status]
738
740
  assert_equal 1, result[:move_number]
739
741
  end
740
742
 
741
743
  def test_AfterMoveRight3
742
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveRight3))
744
+ ins = Level.new(RawLevel.new('1', CanMoveRight3))
743
745
  ins.move(:right)
744
- assert_equal AfterMoveRight3, ins.map
746
+ assert_equal AfterMoveRight3, ins.map_as_array
745
747
  end
746
748
 
747
749
  CanMoveRight4 = ['#####',
@@ -753,16 +755,16 @@ class TC_Level < Test::Unit::TestCase
753
755
  '#####']
754
756
 
755
757
  def test_CanMoveRight4
756
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveRight4))
758
+ ins = Level.new(RawLevel.new('1', CanMoveRight4))
757
759
  result = ins.move(:right)
758
760
  assert_equal :win, result[:status]
759
761
  assert_equal 1, result[:move_number]
760
762
  end
761
763
 
762
764
  def test_AfterMoveRight4
763
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CanMoveRight4))
765
+ ins = Level.new(RawLevel.new('1', CanMoveRight4))
764
766
  ins.move(:right)
765
- assert_equal AfterMoveRight4, ins.map
767
+ assert_equal AfterMoveRight4, ins.map_as_array
766
768
  end
767
769
 
768
770
  CannotMoveRight1 = ['###',
@@ -770,11 +772,11 @@ class TC_Level < Test::Unit::TestCase
770
772
  '###']
771
773
 
772
774
  def test_CannotMoveRight1
773
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveRight1))
775
+ ins = Level.new(RawLevel.new('1', CannotMoveRight1))
774
776
  result = ins.move(:right)
775
777
  assert_equal :error, result[:status]
776
778
  assert_equal 'wall', result[:message]
777
- assert_equal CannotMoveRight1, ins.map
779
+ assert_equal CannotMoveRight1, ins.map_as_array
778
780
  end
779
781
 
780
782
  CannotMoveRight2 = ['####',
@@ -782,11 +784,11 @@ class TC_Level < Test::Unit::TestCase
782
784
  '####']
783
785
 
784
786
  def test_CannotMoveRight2
785
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveRight2))
787
+ ins = Level.new(RawLevel.new('1', CannotMoveRight2))
786
788
  result = ins.move(:right)
787
789
  assert_equal :error, result[:status]
788
790
  assert_equal 'wall behind crate', result[:message]
789
- assert_equal CannotMoveRight2, ins.map
791
+ assert_equal CannotMoveRight2, ins.map_as_array
790
792
  end
791
793
 
792
794
  CannotMoveRight3 = ['######',
@@ -794,11 +796,11 @@ class TC_Level < Test::Unit::TestCase
794
796
  '######']
795
797
 
796
798
  def test_CannotMoveRight3
797
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveRight3))
799
+ ins = Level.new(RawLevel.new('1', CannotMoveRight3))
798
800
  result = ins.move(:right)
799
801
  assert_equal :error, result[:status]
800
802
  assert_equal 'double crate', result[:message]
801
- assert_equal CannotMoveRight3, ins.map
803
+ assert_equal CannotMoveRight3, ins.map_as_array
802
804
  end
803
805
 
804
806
  ### WIN ########################################################
@@ -808,7 +810,7 @@ class TC_Level < Test::Unit::TestCase
808
810
  '#####']
809
811
 
810
812
  def test_solution_avec_une_seule_caisse
811
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', Win1))
813
+ ins = Level.new(RawLevel.new('1', Win1))
812
814
  result = ins.move(:right)
813
815
  assert_equal :win, result[:status]
814
816
  assert_equal 1, result[:move_number]
@@ -831,15 +833,15 @@ class TC_Level < Test::Unit::TestCase
831
833
  '###']
832
834
 
833
835
  def test_bug_first
834
- ins = RSokoban::Level.new(RSokoban::RawLevel.new('1', CannotMoveUpBug1))
836
+ ins = Level.new(RawLevel.new('1', CannotMoveUpBug1))
835
837
  # Changing 'o' to '*'
836
838
  def ins.addStorage
837
- @storages.push RSokoban::Storage.new(1, 1)
839
+ @layered_map.storages.push Storage.new(1, 1)
838
840
  end
839
841
  ins.addStorage
840
842
 
841
843
  # I need to be sure that coord 1, 1 is '*'
842
- assert_equal '#*#', ins.map[1]
844
+ assert_equal '#*#', ins.map_as_array[1]
843
845
 
844
846
  result = ins.move(:up)
845
847
  assert_equal :error, result[:status]