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
data/test/tc_level_loader.rb
CHANGED
@@ -18,25 +18,12 @@ class TC_LevelLoader < Test::Unit::TestCase
|
|
18
18
|
|
19
19
|
def test_title_of_set
|
20
20
|
ins = RSokoban::LevelLoader.new "test_file1.xsb"
|
21
|
-
assert_equal 'test level', ins.
|
21
|
+
assert_equal 'test level', ins.title
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_description_of_set
|
25
25
|
ins = RSokoban::LevelLoader.new "test_file1.xsb"
|
26
|
-
assert_equal "one simple level to test\n", ins.
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_map
|
30
|
-
ins = RSokoban::LevelLoader.new "test_file1.xsb"
|
31
|
-
expected = [ '#####',
|
32
|
-
'#.$@#',
|
33
|
-
'#####']
|
34
|
-
assert_equal expected, ins.set.rawLevels[0].map
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_title_of_level
|
38
|
-
ins = RSokoban::LevelLoader.new "test_file1.xsb"
|
39
|
-
assert_equal "1", ins.set.rawLevels[0].title
|
26
|
+
assert_equal "one simple level to test\n", ins.file_description
|
40
27
|
end
|
41
28
|
|
42
29
|
def test_level_1
|
@@ -87,14 +74,22 @@ class TC_LevelLoader < Test::Unit::TestCase
|
|
87
74
|
|
88
75
|
def test_get_size_of_set
|
89
76
|
ins = RSokoban::LevelLoader.new "original.xsb"
|
90
|
-
assert_equal 90, ins.
|
77
|
+
assert_equal 90, ins.size
|
91
78
|
end
|
92
79
|
|
80
|
+
def test_get_the_description_of_a_set
|
81
|
+
ins = RSokoban::LevelLoader.new "original.xsb"
|
82
|
+
desc = "Copyright: a\nE-Mail:\nWeb Site:\n\nThe 50 original levels from Sokoban plus the 40 from Extra.\n"
|
83
|
+
assert_equal desc, ins.file_description
|
84
|
+
end
|
85
|
+
|
86
|
+
####### BUGS ############################
|
87
|
+
|
93
88
|
# There was a bug where size was majored by one when the xsb file
|
94
89
|
# finish by several blank lines.
|
95
90
|
def test_get_size_of_set_buggy
|
96
91
|
ins = RSokoban::LevelLoader.new "test_file2.xsb"
|
97
|
-
assert_equal 6, ins.
|
92
|
+
assert_equal 6, ins.size
|
98
93
|
end
|
99
94
|
|
100
95
|
end
|
data/test/tc_move_recorder.rb
CHANGED
@@ -6,6 +6,7 @@ class TC_MoveRecorder < Test::Unit::TestCase
|
|
6
6
|
# For testing purpose, add a method to reset the queue of moves.
|
7
7
|
def @mr.empty_for_testing
|
8
8
|
@queue = []
|
9
|
+
@redo =[]
|
9
10
|
end
|
10
11
|
|
11
12
|
# For testing purpose, add a method to fill the queue of moves with known values.
|
@@ -23,13 +24,6 @@ class TC_MoveRecorder < Test::Unit::TestCase
|
|
23
24
|
assert @mr.instance_of?(RSokoban::MoveRecorder)
|
24
25
|
end
|
25
26
|
|
26
|
-
def test_raise_exception_if_we_undo_an_empty_queue
|
27
|
-
@mr.empty_for_testing
|
28
|
-
assert_raise(RSokoban::EmptyMoveQueueError) do
|
29
|
-
@mr.undo
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
27
|
def test_record_up
|
34
28
|
@mr.empty_for_testing
|
35
29
|
@mr.record :up
|
@@ -86,6 +80,15 @@ class TC_MoveRecorder < Test::Unit::TestCase
|
|
86
80
|
end
|
87
81
|
end
|
88
82
|
|
83
|
+
### undo ###
|
84
|
+
|
85
|
+
def test_raise_exception_if_we_undo_an_empty_queue
|
86
|
+
@mr.empty_for_testing
|
87
|
+
assert_raise(RSokoban::EmptyMoveQueueError) do
|
88
|
+
@mr.undo
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
89
92
|
def test_undo_give_the_last_move
|
90
93
|
@mr.fill_for_testing [:up, :up, :left]
|
91
94
|
assert_equal :left, @mr.undo
|
@@ -97,4 +100,35 @@ class TC_MoveRecorder < Test::Unit::TestCase
|
|
97
100
|
assert_equal [:up, :up], @mr.get_for_testing
|
98
101
|
end
|
99
102
|
|
103
|
+
### redo ###
|
104
|
+
|
105
|
+
def test_redo_exception
|
106
|
+
@mr.empty_for_testing
|
107
|
+
assert_raise(RSokoban::EmptyRedoError) do
|
108
|
+
@mr.redo
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_redo_give_the_last_undo
|
113
|
+
@mr.fill_for_testing [:up, :up, :left]
|
114
|
+
@mr.undo
|
115
|
+
assert_equal :left, @mr.redo
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_redo_refill_undo
|
119
|
+
@mr.fill_for_testing [:up, :up, :left]
|
120
|
+
@mr.undo
|
121
|
+
@mr.redo
|
122
|
+
assert_equal :left, @mr.undo
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_record_reset_redo
|
126
|
+
@mr.fill_for_testing [:up, :up, :left]
|
127
|
+
@mr.undo
|
128
|
+
@mr.record :down
|
129
|
+
assert_raise(RSokoban::EmptyRedoError) do
|
130
|
+
@mr.redo
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
100
134
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
class TC_MoveResult < Test::Unit::TestCase
|
2
|
+
|
3
|
+
def setup
|
4
|
+
@res_ok = RSokoban::MoveResult.new(:status => :ok, :move_number => 123)
|
5
|
+
@res_win = RSokoban::MoveResult.new(:status => :win, :move_number => 456)
|
6
|
+
@res_err = RSokoban::MoveResult.new(:status => :error, :message => 'wall')
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_status_ok
|
10
|
+
assert_equal :ok, @res_ok[:status]
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_question_ok
|
14
|
+
assert_equal true, @res_ok.ok?
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_move_number_ok
|
18
|
+
assert_equal 123, @res_ok[:move_number]
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_status_win
|
22
|
+
assert_equal :win, @res_win[:status]
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_question_win
|
26
|
+
assert_equal true, @res_win.win?
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_move_number_win
|
30
|
+
assert_equal 456, @res_win[:move_number]
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_status_error
|
34
|
+
assert_equal :error, @res_err[:status]
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_question_error
|
38
|
+
assert_equal true, @res_err.error?
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_message
|
42
|
+
assert_equal 'wall', @res_err[:message]
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
data/test/test.rb
CHANGED
data/test/ui/tc_console.rb
CHANGED
@@ -7,7 +7,9 @@ class TC_Console < Test::Unit::TestCase
|
|
7
7
|
def @console.public_parse(*args)
|
8
8
|
parse(*args)
|
9
9
|
end
|
10
|
-
|
10
|
+
# Lets pretend the set of levels used by @console is 99 levels length.
|
11
|
+
@console.instance_variable_set(:@set_total, 99)
|
12
|
+
|
11
13
|
@pa = RSokoban::UI::PlayerAction.new
|
12
14
|
end
|
13
15
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: RSokoban
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "0.
|
4
|
+
version: "0.74"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xavier Nayrac
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2011-01-
|
12
|
+
date: 2011-01-31 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -34,6 +34,8 @@ files:
|
|
34
34
|
- lib/rsokoban/ui/curses_console.rb
|
35
35
|
- lib/rsokoban/ui/base_ui.rb
|
36
36
|
- lib/rsokoban/ui/tk_ui.rb
|
37
|
+
- lib/rsokoban/ui/tk_dialogs.rb
|
38
|
+
- lib/rsokoban/ui/tk_box.rb
|
37
39
|
- lib/rsokoban/ui/console.rb
|
38
40
|
- lib/rsokoban/ui/player_action.rb
|
39
41
|
- lib/rsokoban/level_loader.rb
|
@@ -41,7 +43,9 @@ files:
|
|
41
43
|
- lib/rsokoban/position.rb
|
42
44
|
- lib/rsokoban/level.rb
|
43
45
|
- lib/rsokoban/map.rb
|
46
|
+
- lib/rsokoban/extensions.rb
|
44
47
|
- lib/rsokoban/level_set.rb
|
48
|
+
- lib/rsokoban/move_result.rb
|
45
49
|
- lib/rsokoban/man.rb
|
46
50
|
- bin/rsokoban
|
47
51
|
- data/original.xsb
|
@@ -66,22 +70,25 @@ files:
|
|
66
70
|
- README.rdoc
|
67
71
|
- TODO
|
68
72
|
- NEWS
|
69
|
-
- RSokoban-0.73.gem
|
70
73
|
- VERSION
|
71
74
|
- COPYING
|
75
|
+
- Rakefile
|
72
76
|
- test/test_file1.xsb
|
73
77
|
- test/tc_move_recorder.rb
|
74
78
|
- test/tc_level_loader.rb
|
75
79
|
- test/test_file2.xsb
|
76
80
|
- test/tc_level.rb
|
81
|
+
- test/tc_move_result.rb
|
77
82
|
- test/tc_position.rb
|
78
83
|
- test/original.xsb
|
79
84
|
- test/ui
|
80
85
|
- test/ui/tc_console.rb
|
81
86
|
- test/ui/tc_player_action.rb
|
82
87
|
- test/tc_map.rb
|
88
|
+
- test/tc_extensions.rb
|
83
89
|
- test/tc_raw_level.rb
|
84
90
|
- test/tc_man.rb
|
91
|
+
- test/tc_game.rb
|
85
92
|
- test/test.rb
|
86
93
|
- test/tc_moveable.rb
|
87
94
|
- test/tc_level_set.rb
|
data/RSokoban-0.73.gem
DELETED
Binary file
|