RSokoban 0.71 → 0.73

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.
Files changed (50) hide show
  1. data/NEWS +22 -0
  2. data/README.rdoc +19 -19
  3. data/RSokoban-0.73.gem +0 -0
  4. data/TODO +25 -18
  5. data/VERSION +1 -0
  6. data/bin/rsokoban +65 -1
  7. data/lib/rsokoban/exception.rb +4 -0
  8. data/lib/rsokoban/game.rb +42 -29
  9. data/lib/rsokoban/level.rb +67 -30
  10. data/lib/rsokoban/level_loader.rb +4 -4
  11. data/lib/rsokoban/level_set.rb +20 -10
  12. data/lib/rsokoban/map.rb +51 -0
  13. data/lib/rsokoban/move_recorder.rb +38 -0
  14. data/lib/rsokoban/option.rb +29 -12
  15. data/lib/rsokoban/raw_level.rb +15 -4
  16. data/lib/rsokoban/ui/base_ui.rb +37 -0
  17. data/lib/rsokoban/ui/console.rb +43 -33
  18. data/lib/rsokoban/ui/curses_console.rb +45 -36
  19. data/lib/rsokoban/ui/player_action.rb +74 -0
  20. data/lib/rsokoban/ui/tk_ui.rb +474 -0
  21. data/lib/rsokoban/ui.rb +10 -0
  22. data/lib/rsokoban.rb +4 -5
  23. data/skins/default/crate.bmp +0 -0
  24. data/skins/default/crate_store.bmp +0 -0
  25. data/skins/default/floor.bmp +0 -0
  26. data/skins/default/man_down.bmp +0 -0
  27. data/skins/default/man_left.bmp +0 -0
  28. data/skins/default/man_right.bmp +0 -0
  29. data/skins/default/man_store_down.bmp +0 -0
  30. data/skins/default/man_store_left.bmp +0 -0
  31. data/skins/default/man_store_right.bmp +0 -0
  32. data/skins/default/man_store_up.bmp +0 -0
  33. data/skins/default/man_up.bmp +0 -0
  34. data/skins/default/outside.bmp +0 -0
  35. data/skins/default/readme +1 -0
  36. data/skins/default/store.bmp +0 -0
  37. data/skins/default/wall.bmp +0 -0
  38. data/test/original.xsb +0 -2
  39. data/test/tc_level.rb +37 -37
  40. data/test/tc_level_loader.rb +14 -2
  41. data/test/tc_level_set.rb +8 -0
  42. data/test/tc_map.rb +40 -0
  43. data/test/tc_move_recorder.rb +100 -0
  44. data/test/tc_raw_level.rb +5 -5
  45. data/test/test.rb +3 -1
  46. data/test/test_file2.xsb +2 -0
  47. data/test/ui/tc_console.rb +27 -13
  48. data/test/ui/tc_player_action.rb +156 -0
  49. metadata +38 -25
  50. data/lib/rsokoban/ui/ui.rb +0 -44
@@ -0,0 +1,156 @@
1
+ class TC_PlayerAction < Test::Unit::TestCase
2
+
3
+ def setup
4
+ @pa = RSokoban::UI::PlayerAction.new
5
+ end
6
+
7
+ def test_default_action_is_nil
8
+ assert_equal nil, RSokoban::UI::PlayerAction.new.action
9
+ end
10
+
11
+ def test_set_action_quit
12
+ @pa.action = :quit
13
+ assert_equal :quit, @pa.action
14
+ end
15
+
16
+ def test_set_action_along_constructor
17
+ pa = RSokoban::UI::PlayerAction.new(:quit)
18
+ assert_equal :quit, pa.action
19
+ end
20
+
21
+ def test_set_action_next
22
+ @pa.action = :next
23
+ assert_equal :next, @pa.action
24
+ end
25
+
26
+ def test_set_action_retry
27
+ @pa.action = :retry
28
+ assert_equal :retry, @pa.action
29
+ end
30
+
31
+ def test_set_action_undo
32
+ @pa.action = :undo
33
+ assert_equal :undo, @pa.action
34
+ end
35
+
36
+ def test_set_action_up
37
+ @pa.action = :up
38
+ assert_equal :up, @pa.action
39
+ end
40
+
41
+ def test_set_action_down
42
+ @pa.action = :down
43
+ assert_equal :down, @pa.action
44
+ end
45
+
46
+ def test_set_action_left
47
+ @pa.action = :left
48
+ assert_equal :left, @pa.action
49
+ end
50
+
51
+ def test_set_action_right
52
+ @pa.action = :right
53
+ assert_equal :right, @pa.action
54
+ end
55
+
56
+ def test_no_other_symbols_allowed
57
+ assert_raise(ArgumentError) do
58
+ @pa.action = :not_allowed
59
+ end
60
+ end
61
+
62
+ def test_action_is_a_level_number
63
+ @pa.action = 23
64
+ assert_equal 23, @pa.action
65
+ end
66
+
67
+ def test_action_is_an_xsb_filename
68
+ @pa.action = 'file.xsb'
69
+ assert_equal 'file.xsb', @pa.action
70
+ end
71
+
72
+ def test_bad_filename
73
+ assert_raise(ArgumentError) do
74
+ @pa.action = 'file.x'
75
+ end
76
+ end
77
+
78
+ def test_is_level_number
79
+ @pa.action = 23
80
+ assert_equal true, @pa.level_number?
81
+ end
82
+
83
+ def test_is_not_level_number
84
+ @pa.action = :quit
85
+ assert_equal false, @pa.level_number?
86
+ end
87
+
88
+ def test_is_set_name
89
+ @pa.action = 'file.xsb'
90
+ assert_equal true, @pa.set_name?
91
+ end
92
+
93
+ def test_is_not_set_name
94
+ @pa.action = :quit
95
+ assert_equal false, @pa.set_name?
96
+ end
97
+
98
+ def test_is_quit
99
+ @pa.action = :quit
100
+ assert_equal true, @pa.quit?
101
+ end
102
+
103
+ def test_is_not_quit
104
+ @pa.action = :up
105
+ assert_equal false, @pa.quit?
106
+ end
107
+
108
+ def test_is_next
109
+ @pa.action = :next
110
+ assert_equal true, @pa.next?
111
+ end
112
+
113
+ def test_is_not_next
114
+ @pa.action = :up
115
+ assert_equal false, @pa.next?
116
+ end
117
+
118
+ def test_is_retry
119
+ @pa.action = :retry
120
+ assert_equal true, @pa.retry?
121
+ end
122
+
123
+ def test_is_not_retry
124
+ @pa.action = :up
125
+ assert_equal false, @pa.retry?
126
+ end
127
+
128
+ def test_is_move
129
+ @pa.action = :up
130
+ assert_equal true, @pa.move?
131
+
132
+ @pa.action = :down
133
+ assert_equal true, @pa.move?
134
+
135
+ @pa.action = :left
136
+ assert_equal true, @pa.move?
137
+
138
+ @pa.action = :right
139
+ assert_equal true, @pa.move?
140
+ end
141
+
142
+ def test_is_not_move
143
+ @pa.action = :quit
144
+ assert_equal false, @pa.move?
145
+ end
146
+
147
+ def test_is_undo
148
+ @pa.action = :undo
149
+ assert_equal true, @pa.undo?
150
+ end
151
+
152
+ def test_is_not_undo
153
+ @pa.action = :up
154
+ assert_equal false, @pa.undo?
155
+ end
156
+ end
metadata CHANGED
@@ -1,11 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: RSokoban
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 71
8
- version: "0.71"
4
+ version: "0.73"
9
5
  platform: ruby
10
6
  authors:
11
7
  - Xavier Nayrac
@@ -13,14 +9,11 @@ autorequire:
13
9
  bindir: bin
14
10
  cert_chain: []
15
11
 
16
- date: 2011-01-21 00:00:00 +01:00
12
+ date: 2011-01-27 00:00:00 +01:00
17
13
  default_executable:
18
14
  dependencies: []
19
15
 
20
- description: |-
21
- RSokoban is a clone of the famous Sokoban game.
22
- I wrote this program just to improve my skills in Ruby. Currently, you can play only in a console window.
23
- Enjoy the game !
16
+ description: RSokoban is a clone of the famous Sokoban game. I wrote this program just to improve my skills in Ruby. Currently, you can play only in a console window. Enjoy the game !
24
17
  email: xavier.nayrac@gmail.com
25
18
  executables:
26
19
  - rsokoban
@@ -35,68 +28,88 @@ files:
35
28
  - lib/rsokoban/exception.rb
36
29
  - lib/rsokoban/crate.rb
37
30
  - lib/rsokoban/storage.rb
31
+ - lib/rsokoban/ui.rb
32
+ - lib/rsokoban/move_recorder.rb
38
33
  - lib/rsokoban/moveable.rb
39
34
  - lib/rsokoban/ui/curses_console.rb
40
- - lib/rsokoban/ui/ui.rb
35
+ - lib/rsokoban/ui/base_ui.rb
36
+ - lib/rsokoban/ui/tk_ui.rb
41
37
  - lib/rsokoban/ui/console.rb
38
+ - lib/rsokoban/ui/player_action.rb
42
39
  - lib/rsokoban/level_loader.rb
43
40
  - lib/rsokoban/raw_level.rb
44
41
  - lib/rsokoban/position.rb
45
42
  - lib/rsokoban/level.rb
43
+ - lib/rsokoban/map.rb
46
44
  - lib/rsokoban/level_set.rb
47
45
  - lib/rsokoban/man.rb
48
46
  - bin/rsokoban
49
47
  - data/original.xsb
50
48
  - data/test.xsb
51
49
  - data/microban.xsb
50
+ - skins/default
51
+ - skins/default/outside.bmp
52
+ - skins/default/store.bmp
53
+ - skins/default/man_left.bmp
54
+ - skins/default/man_up.bmp
55
+ - skins/default/man_store_right.bmp
56
+ - skins/default/man_right.bmp
57
+ - skins/default/crate_store.bmp
58
+ - skins/default/readme
59
+ - skins/default/man_store_up.bmp
60
+ - skins/default/floor.bmp
61
+ - skins/default/man_store_left.bmp
62
+ - skins/default/crate.bmp
63
+ - skins/default/man_store_down.bmp
64
+ - skins/default/wall.bmp
65
+ - skins/default/man_down.bmp
52
66
  - README.rdoc
53
67
  - TODO
68
+ - NEWS
69
+ - RSokoban-0.73.gem
70
+ - VERSION
54
71
  - COPYING
55
72
  - test/test_file1.xsb
73
+ - test/tc_move_recorder.rb
56
74
  - test/tc_level_loader.rb
57
75
  - test/test_file2.xsb
58
76
  - test/tc_level.rb
59
77
  - test/tc_position.rb
60
78
  - test/original.xsb
79
+ - test/ui
61
80
  - test/ui/tc_console.rb
81
+ - test/ui/tc_player_action.rb
82
+ - test/tc_map.rb
62
83
  - test/tc_raw_level.rb
63
84
  - test/tc_man.rb
64
85
  - test/test.rb
65
86
  - test/tc_moveable.rb
66
87
  - test/tc_level_set.rb
67
- has_rdoc: true
88
+ has_rdoc: false
68
89
  homepage: https://github.com/lkdjiin/RSokoban/wiki
69
- licenses:
70
- - GPL-3
71
90
  post_install_message:
72
91
  rdoc_options: []
73
92
 
74
93
  require_paths:
75
94
  - lib
76
95
  required_ruby_version: !ruby/object:Gem::Requirement
77
- none: false
78
96
  requirements:
79
97
  - - ">="
80
98
  - !ruby/object:Gem::Version
81
- segments:
82
- - 1
83
- - 9
84
- - 0
85
- version: 1.9.0
99
+ version: 1.8.7
100
+ version:
86
101
  required_rubygems_version: !ruby/object:Gem::Requirement
87
- none: false
88
102
  requirements:
89
103
  - - ">="
90
104
  - !ruby/object:Gem::Version
91
- segments:
92
- - 0
93
105
  version: "0"
106
+ version:
94
107
  requirements: []
95
108
 
96
109
  rubyforge_project:
97
- rubygems_version: 1.3.7
110
+ rubygems_version: 1.2.0
98
111
  signing_key:
99
- specification_version: 3
112
+ specification_version: 2
100
113
  summary: Clone of the Sokoban game.
101
114
  test_files:
102
115
  - test/test.rb
@@ -1,44 +0,0 @@
1
- module RSokoban
2
-
3
- # Module dedicated to user interfaces.
4
- module UI
5
-
6
- # Every concrete UI should inherits from me.
7
- class BaseUI
8
-
9
- def initialize
10
- @level_title = ''
11
- end
12
-
13
- # Based on things found in the arguments, I display the game
14
- # to the user. Then he can tell what it want to do. Whatever
15
- # my childs permit the user to do, they can only return one
16
- # of the following actions.
17
- #
18
- # List of action I must be able to parse and return :
19
- # :quit to quit game
20
- # :next to load and play next level
21
- # :retry to restart the current level
22
- # :up, :down, :left, :right to move the man
23
- # a number to load this level number
24
- # an .xsb filename to load the set with this name
25
- #
26
- # @param ['START'|'DISPLAY'|'WIN'] type the type of message
27
- # @param [Array<String>] level the picture of the level
28
- # @param [String] message a message to be displayed. See Level#move
29
- # to learn more about the message format and content.
30
- # @return [Object] the user's action
31
- # @since 0.71
32
- # @todo write some examples
33
- # @todo action diserves its own class
34
- # @todo picture diserves its own class
35
- # @todo document better +type+
36
- def get_action(type, level, message)
37
- raise "Please implement me !"
38
- end
39
-
40
- end
41
-
42
- end
43
-
44
- end