smagacor 0.0.1 → 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 CHANGED
@@ -1,4 +1,66 @@
1
1
  ------------------------------------------------------------------------
2
+ r363 | thomas | 2005-11-26 19:16:30 +0100 (Sat, 26 Nov 2005) | 2 lines
3
+ Changed paths:
4
+ D /trunk/smagacor/data/smagacor/sokoban/levels/sokoban_levels.txt
5
+ M /trunk/smagacor/data/smagacor/sokoban/sokobanui.rb
6
+
7
+ * removed old levels
8
+ * added credits for sokoban levels
9
+ ------------------------------------------------------------------------
10
+ r362 | thomas | 2005-11-26 18:56:46 +0100 (Sat, 26 Nov 2005) | 4 lines
11
+ Changed paths:
12
+ M /trunk/smagacor/Rakefile
13
+ M /trunk/smagacor/TODO
14
+ A /trunk/smagacor/data/smagacor/smagacor-logo.png
15
+ A /trunk/smagacor/data/smagacor/sokoban
16
+ A /trunk/smagacor/data/smagacor/sokoban/game.info
17
+ A /trunk/smagacor/data/smagacor/sokoban/levels
18
+ A /trunk/smagacor/data/smagacor/sokoban/levels/loma.lvl
19
+ A /trunk/smagacor/data/smagacor/sokoban/levels/mas_microban.lvl
20
+ A /trunk/smagacor/data/smagacor/sokoban/levels/mas_sasquatch.lvl
21
+ A /trunk/smagacor/data/smagacor/sokoban/levels/microban.lvl
22
+ A /trunk/smagacor/data/smagacor/sokoban/levels/sasquatch.lvl
23
+ A /trunk/smagacor/data/smagacor/sokoban/levels/sasquatch_III.lvl
24
+ A /trunk/smagacor/data/smagacor/sokoban/levels/sasquatch_IV.lvl
25
+ A /trunk/smagacor/data/smagacor/sokoban/levels/sasquatch_V.lvl
26
+ A /trunk/smagacor/data/smagacor/sokoban/levels/sasquatch_VI.lvl
27
+ A /trunk/smagacor/data/smagacor/sokoban/levels/sasquatch_VII.lvl
28
+ A /trunk/smagacor/data/smagacor/sokoban/levels/sokoban_levels.txt
29
+ A /trunk/smagacor/data/smagacor/sokoban/sokobanui.rb
30
+ M /trunk/smagacor/data/smagacor/tictactoe/game.info
31
+ D /trunk/smagacor/data/smagacor/tictactoe/tictactoe.png
32
+ M /trunk/smagacor/data/smagacor/tictactoe/tictactoe.rb
33
+ D /trunk/smagacor/lib/smagacor/controller.rb
34
+ A /trunk/smagacor/lib/smagacor/listener.rb
35
+ M /trunk/smagacor/lib/smagacor/smagacor-ui.rb
36
+ A /trunk/smagacor/lib/smagacor/util.rb
37
+ A /trunk/smagacor/otherdata/sokoban
38
+ A /trunk/smagacor/otherdata/sokoban/common.inc
39
+ A /trunk/smagacor/otherdata/sokoban/crate.pov
40
+ A /trunk/smagacor/otherdata/sokoban/floor.pov
41
+ A /trunk/smagacor/otherdata/sokoban/man.pov
42
+ A /trunk/smagacor/otherdata/sokoban/storage.pov
43
+ A /trunk/smagacor/otherdata/sokoban/wall.pov
44
+ A /trunk/smagacor/otherdata/tictactoe
45
+ A /trunk/smagacor/otherdata/tictactoe/o.svg
46
+ A /trunk/smagacor/otherdata/tictactoe/tictactoe.svg (from /trunk/smagacor/otherdata/tictactoe.svg:340)
47
+ A /trunk/smagacor/otherdata/tictactoe/x.svg
48
+ D /trunk/smagacor/otherdata/tictactoe.svg
49
+
50
+ * added the game of Sokoban
51
+ * change from Fox-GUI to Qt
52
+ * added UndoManager
53
+ * all graphics are now generated from source files
54
+ ------------------------------------------------------------------------
55
+ r358 | thomas | 2005-09-14 15:58:21 +0200 (Wed, 14 Sep 2005) | 1 line
56
+ Changed paths:
57
+ M /trunk/smagacor/TODO
58
+ M /trunk/smagacor/data/smagacor/tictactoe/tictactoe.rb
59
+ M /trunk/smagacor/lib/smagacor/controller.rb
60
+ M /trunk/smagacor/lib/smagacor/smagacor-ui.rb
61
+
62
+ * updated to fox version 1.2.0
63
+ ------------------------------------------------------------------------
2
64
  r197 | thomas | 2005-02-09 14:42:17 +0100 (Wed, 09 Feb 2005) | 1 line
3
65
  Changed paths:
4
66
  M /trunk/smagacor/Rakefile
data/Rakefile CHANGED
@@ -33,7 +33,7 @@ require 'rake/testtask'
33
33
  # General actions ##############################################################
34
34
 
35
35
  $:.push "lib"
36
- require 'smagacor/controller'
36
+ require 'smagacor/util'
37
37
 
38
38
  PKG_NAME = "smagacor"
39
39
  PKG_VERSION = Smagacor::VERSION.join( '.' )
@@ -97,7 +97,6 @@ end
97
97
 
98
98
  PKG_FILES = FileList.new( [
99
99
  'setup.rb',
100
- 'install.rb',
101
100
  'TODO',
102
101
  'COPYING',
103
102
  'README',
@@ -110,15 +109,9 @@ PKG_FILES = FileList.new( [
110
109
  'test/**/*',
111
110
  'data/**/*'
112
111
  ]) do |fl|
113
- fl.exclude( /\bsvn\b/ )
114
112
  fl.exclude( 'doc/output' )
115
113
  end
116
-
117
- task :package => [:gen_files] do
118
- chdir 'pkg' do
119
- sh "rpaadmin packport #{PKG_NAME}-#{PKG_VERSION}"
120
- end
121
- end
114
+ PKG_FILES_DUPPED = PKG_FILES.clone
122
115
 
123
116
  task :gen_changelog do
124
117
  sh "svn log -r HEAD:1 -v > ChangeLog"
@@ -129,34 +122,22 @@ task :gen_version do
129
122
  File.open( 'VERSION', 'w+' ) do |file| file.write( PKG_VERSION + "\n" ) end
130
123
  end
131
124
 
132
- task :gen_installrb do
133
- puts "Generating install.rb file"
134
- File.open( 'install.rb', 'w+' ) do |file|
135
- file.write "
136
- require 'rpa/install'
137
-
138
- class Install_#{PKG_NAME} < RPA::Install::FullInstaller
139
- name '#{PKG_NAME}'
140
- version '#{PKG_VERSION}-1'
141
- classification Application
142
- build do
143
- installdocs %w[COPYING ChangeLog TODO]
144
- installdocs 'docs'
145
- installrdoc %w[README] + Dir['lib/**/*.rb']
146
- installdata
125
+ task :gen_files => [:gen_changelog, :gen_version, :gen_otherdata]
126
+ CLOBBER << "ChangeLog" << "VERSION"
127
+
128
+ desc "Workaround because generated graphcis are not included"
129
+ task :check_gen_included do
130
+ if !(PKG_FILES == PKG_FILES_DUPPED)
131
+ puts
132
+ puts
133
+ puts "!!! File list changed! You need to invoke the rake task again!"
134
+ puts
135
+ puts
136
+ exit
147
137
  end
148
- description <<-EOF
149
- #{PKG_SUMMARY}
150
-
151
- #{PKG_DESCRIPTION}
152
- EOF
153
- end
154
- "
155
- end
156
138
  end
157
139
 
158
- task :gen_files => [:gen_changelog, :gen_version, :gen_installrb]
159
- CLOBBER << "ChangeLog" << "VERSION" << "install.rb"
140
+ task :package => [:gen_files, :check_gen_included]
160
141
 
161
142
  Rake::PackageTask.new( PKG_NAME, PKG_VERSION ) do |p|
162
143
  p.need_tar = true
@@ -176,7 +157,7 @@ if defined? Gem
176
157
 
177
158
  #### Dependencies, requirements and files
178
159
 
179
- s.files = PKG_FILES.to_a
160
+ s.files = PKG_FILES
180
161
 
181
162
  s.autorequire = nil
182
163
  s.executables = [ 'smagacor']
@@ -186,7 +167,7 @@ if defined? Gem
186
167
 
187
168
  s.has_rdoc = true
188
169
  s.extra_rdoc_files = rd.rdoc_files.reject do |fn| fn =~ /\.rb$/ end.to_a
189
- s.rdoc_options = ['--line-numbers', '-m README']
170
+ s.rdoc_options = ['--line-numbers', '-m', 'README']
190
171
 
191
172
  #### Author and project details
192
173
 
@@ -202,15 +183,6 @@ if defined? Gem
202
183
  end
203
184
  end
204
185
 
205
- =begin
206
- desc "Creates a tag in the repository"
207
- task :tag do
208
- repositoryPath = File.dirname( $1 ) if `svn info` =~ /^URL: (.*)$/
209
- fail "Tag already created in repository " if /#{PKG_FULLNAME}/ =~ `svn ls #{repositoryPath}/versions`
210
- sh "svn cp -m 'Created version #{PKG_FULLNAME}' #{repositoryPath}/trunk/#{PKG_NAME} #{repositoryPath}/versions/#{PKG_FULLNAME}"
211
- end
212
- =end
213
-
214
186
  desc "Upload documentation to homepage"
215
187
  task :uploaddoc => [:doc] do
216
188
  Dir.chdir('doc/output')
@@ -220,36 +192,79 @@ end
220
192
 
221
193
  # Misc tasks ###################################################################
222
194
 
195
+ begin
196
+ require 'RMagick'
197
+ include Magick
223
198
 
224
- def count_lines( filename )
225
- lines = 0
226
- codelines = 0
227
- open( filename ) do |f|
228
- f.each do |line|
229
- lines += 1
230
- next if line =~ /^\s*$/
231
- next if line =~ /^\s*#/
232
- codelines += 1
233
- end
199
+ ICON_SIZE=64
200
+
201
+ def data_path( game )
202
+ "data/smagacor/#{game}"
203
+ end
204
+
205
+ def src_newer?( src, dest )
206
+ !File.exists?( dest ) || File.mtime( src ) > File.mtime( dest )
234
207
  end
235
- [lines, codelines]
236
- end
237
208
 
209
+ def inkscape_export_svg( svg, png, width )
210
+ sh "inkscape -z --export-png=#{png} -w #{width} -j -i layer1 #{svg}" if src_newer?( svg, png )
211
+ end
238
212
 
239
- def show_line( msg, lines, loc )
240
- printf "%6s %6s %s\n", lines.to_s, loc.to_s, msg
241
- end
213
+ def povray( pov, png, size )
214
+ sh "povray #{pov} -geometry #{size[0]}x#{size[1]} +Q9 +A +O'#{png}'" if src_newer?( pov, png )
215
+ end
242
216
 
243
- desc "Show statistics"
244
- task :statistics do
245
- total_lines = 0
246
- total_code = 0
247
- show_line( "File Name", "Lines", "LOC" )
248
- SRC_RB.each do |fn|
249
- lines, codelines = count_lines fn
250
- show_line( fn, lines, codelines )
251
- total_lines += lines
252
- total_code += codelines
217
+ CLOBBER << File.join( data_path('tictactoe'), 'tictactoe.png' )
218
+ CLOBBER << File.join( data_path('tictactoe'), 'x.png' )
219
+ CLOBBER << File.join( data_path('tictactoe'), 'o.png' )
220
+ task :gen_game_tictactoe do
221
+ inkscape_export_svg( 'otherdata/tictactoe/tictactoe.svg', File.join( data_path('tictactoe'), 'tictactoe.png' ), ICON_SIZE )
222
+ inkscape_export_svg( 'otherdata/tictactoe/x.svg', File.join( data_path('tictactoe'), 'x.png' ), 100 )
223
+ inkscape_export_svg( 'otherdata/tictactoe/o.svg', File.join( data_path('tictactoe'), 'o.png' ), 100 )
253
224
  end
254
- show_line( "Total", total_lines, total_code )
225
+
226
+ CLOBBER << File.join( data_path('sokoban'), 'sokoban.png' )
227
+ CLOBBER << File.join( data_path('sokoban'), 'crate.png' )
228
+ CLOBBER << File.join( data_path('sokoban'), 'storage.png' )
229
+ CLOBBER << File.join( data_path('sokoban'), 'floor.png' )
230
+ CLOBBER << File.join( data_path('sokoban'), 'wall.png' )
231
+ CLOBBER << File.join( data_path('sokoban'), 'man.png' )
232
+ task :gen_game_sokoban do
233
+ cd 'otherdata/sokoban' do
234
+ %w[crate storage floor wall man].each do |pov|
235
+ dest = File.join( '../../' + data_path('sokoban'), pov + '.png')
236
+ povray( pov + '.pov', dest, [128,128] )
237
+ end
238
+ end
239
+
240
+ # make crate.png, storage.png pixels transparent
241
+ ['crate.png', 'storage.png', 'man.png'].each do |png|
242
+ img = Image.read( File.join( data_path( 'sokoban'), png ) ).first
243
+ img.fuzz = 10
244
+ img = img.matte_replace( 0, 0 )
245
+ img.write( File.join( data_path( 'sokoban' ), png ) )
246
+ end
247
+
248
+ # create logo
249
+ w = ICON_SIZE/4
250
+ img = Image.new( ICON_SIZE, ICON_SIZE ) { self.background_color = 'white' }
251
+ tiles = ImageList.new( *%w[crate storage floor wall man].collect {|f| File.join( data_path( 'sokoban'), f+'.png' ) } )
252
+ tiles.each { |tile| tile.change_geometry!( "#{w}x#{w}" ) {|c,r,i| i.resize!(c,r)} }
253
+
254
+ lvl = "3333
255
+ 3013
256
+ 3243
257
+ 3333"
258
+ lvl.split( /\n/ ).each_with_index do |line, y|
259
+ line.unpack( 'C*' ).each_with_index do |c,x|
260
+ img.composite!( tiles[2], w*x, w*y, OverCompositeOp )
261
+ img.composite!( tiles[c.chr.to_i], w*x, w*y, OverCompositeOp )
262
+ end
263
+ end
264
+ img.write( File.join( data_path( 'sokoban' ), 'sokoban.png' ) )
265
+ end
266
+
267
+ task :gen_otherdata => [:gen_game_tictactoe, :gen_game_sokoban]
268
+
269
+ rescue
255
270
  end
data/TODO CHANGED
@@ -1,19 +1,36 @@
1
1
  ---- CURRENT ----
2
2
 
3
+ -- GENERAL --
4
+
5
+ * log window: remove blank line between log lines
6
+ * implement load dialog when loading a game (e.g. for sokoban when creating level images)
7
+ * implement networking ability
3
8
  * help -> help for current game
4
9
  * make splitter not moveable
5
10
  * make splitter hideable
6
11
  * implement Pong
7
12
  * implement UNDO mechanism
8
13
  * implement State saver
9
- * TicTacToe AI opponent (on base of mini-max, nega-max,...)
10
14
  * complete tests
11
15
 
16
+ -- SOKOBAN --
17
+
18
+ * BUG: sokoban man does not get drawn sometimes
19
+ * move to next level when level finished
20
+ * show moves and score
21
+
22
+ -- TICTACTOE --
23
+
24
+ * Undo does not work correctly (cur player does not get undone)
25
+ * TicTacToe AI opponent (on base of mini-max, nega-max,...)
26
+
12
27
  ---- FUTURE ----
13
28
 
14
- * implement Sokoban
15
29
 
16
30
  ---- DONE ----
17
31
 
18
32
  * BUG: log window should stay behind main window
19
33
  * BUG: rake install broken on windows
34
+ * create icon for window
35
+ * implement Sokoban
36
+ * implement undo mechanism for each game
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
Binary file
Binary file
Binary file
@@ -0,0 +1,7 @@
1
+ --- !thomasleitner,2004/gameinfo
2
+ name: Sokoban
3
+ icon: sokoban.png
4
+ file: sokobanui.rb
5
+ classname: Smagacor::Sokoban::SokobanGame
6
+ description: This is the game of Sokoban.
7
+ category: Strategy Games
@@ -0,0 +1,288 @@
1
+
2
+ ; 1
3
+ 'LOMA 1a'
4
+
5
+ #####
6
+ ## ##
7
+ ### # #
8
+ ###$.# #
9
+ # $.#@#
10
+ # #$.# #
11
+ # # #
12
+ # # ###
13
+ ## ##
14
+ #####
15
+
16
+ ; 2
17
+ 'LOMA 1b'
18
+
19
+ ########
20
+ # #
21
+ # #$.@ #
22
+ # $.###
23
+ # #$.#
24
+ # ##
25
+ #####
26
+
27
+ ; 3
28
+ 'LOMA 1c'
29
+
30
+ #####
31
+ # ####
32
+ # $. #
33
+ ## $. #
34
+ ##$.###
35
+ #@ #
36
+ ####
37
+
38
+ ; 4
39
+ 'LOMA 2a'
40
+
41
+ #####
42
+ # ####
43
+ # #$. #
44
+ # .$#@#
45
+ ###$. #
46
+ # ###
47
+ # #
48
+ ####
49
+
50
+ ; 5
51
+ 'LOMA 2b'
52
+
53
+ ######
54
+ ### #
55
+ # ## #
56
+ # #$. #
57
+ #@#.$###
58
+ # #$.##
59
+ # #
60
+ ### #
61
+ #####
62
+
63
+ ; 6
64
+ 'LOMA 3a'
65
+
66
+ ####
67
+ ## #
68
+ # . #
69
+ # * #
70
+ ## *###
71
+ # $ #
72
+ # @ #
73
+ # ###
74
+ ####
75
+
76
+ ; 7
77
+ 'LOMA 3b'
78
+
79
+ ####
80
+ # ####
81
+ # #
82
+ # .# #
83
+ ###*# ##
84
+ #@* #
85
+ # $ #
86
+ ### ##
87
+ ####
88
+
89
+ ; 8
90
+ 'LOMA 4a'
91
+
92
+ ###### #
93
+ # ## #
94
+ # . #
95
+ # $ ###
96
+ ## * @ #
97
+ ###$ # #
98
+ #.# #
99
+ # # ##
100
+ # ######
101
+
102
+ ; 9
103
+ 'LOMA 4b'
104
+
105
+ #####
106
+ # ##
107
+ # #. ###
108
+ # $ @ #
109
+ ###* #
110
+ # $ ###
111
+ # #.##
112
+ # #
113
+ #####
114
+
115
+ ; 10
116
+ 'LOMA 5a'
117
+
118
+ ####
119
+ # #
120
+ # #
121
+ # ####
122
+ ###$$ #
123
+ # $. #
124
+ # #..###
125
+ # @# #
126
+ ## #
127
+ ######
128
+
129
+ ; 11
130
+ 'LOMA 5b'
131
+
132
+ #####
133
+ # @####
134
+ # #$$ #
135
+ # $.# #
136
+ ###.. #
137
+ ## #
138
+ #####
139
+
140
+ ; 12
141
+ 'LOMA 6a'
142
+
143
+ #####
144
+ ## #
145
+ ### #
146
+ # $ #
147
+ # .*.##
148
+ ## $ #
149
+ ###@ #
150
+ ####
151
+
152
+ ; 13
153
+ 'LOMA 6b'
154
+
155
+ ####
156
+ ## #
157
+ ###$ #
158
+ # .*.#
159
+ # #$ #
160
+ # @ #
161
+ # ##
162
+ #####
163
+
164
+ ; 14
165
+ 'LOMA 7a'
166
+
167
+ #####
168
+ # ##
169
+ # $ ##
170
+ ##$*. ##
171
+ # .@ #
172
+ # # #
173
+ ##### #
174
+ ## ####
175
+
176
+ ; 15
177
+ 'LOMA 7b'
178
+
179
+ #####
180
+ # ####
181
+ # #@$ #
182
+ # $*. #
183
+ ####. ##
184
+ # #
185
+ # ##
186
+ #####
187
+
188
+ ; 16
189
+ 'LOMA 7c'
190
+
191
+ ########
192
+ # #
193
+ ### #### #
194
+ # @$ # #
195
+ # $*. # #
196
+ # #.### #
197
+ # # #
198
+ ##########
199
+
200
+ ; 17
201
+ 'LOMA 8a'
202
+
203
+ #####
204
+ ## #
205
+ ### #
206
+ # * ##
207
+ # .@$##
208
+ # * ##
209
+ ## ##
210
+ #####
211
+
212
+ ; 18
213
+ 'LOMA 8b'
214
+
215
+ ####
216
+ # ##
217
+ ## * ##
218
+ # .@$ #
219
+ # * #
220
+ # # #
221
+ #######
222
+
223
+ ; 19
224
+ 'LOMA 9a'
225
+
226
+ ####
227
+ # #
228
+ ### ###
229
+ ## $* #
230
+ # *. @#
231
+ # ####
232
+ # ##
233
+ #####
234
+
235
+ ; 20
236
+ 'LOMA 9b'
237
+
238
+ #####
239
+ # #####
240
+ # # #
241
+ ## $*@ #
242
+ # *. ##
243
+ # ####
244
+ ####
245
+
246
+ ; 21
247
+ 'LOMA 10a'
248
+
249
+ #### ###
250
+ #@ ### #
251
+ # $$ ###
252
+ # $ . #
253
+ ## .. #
254
+ #######
255
+
256
+ ; 22
257
+ 'LOMA 10b'
258
+
259
+ ####
260
+ # #
261
+ #@ ###
262
+ # $$ ##
263
+ # $ . #
264
+ ###.. #
265
+ # ##
266
+ # #
267
+ #####
268
+
269
+ ; 23
270
+ 'LOMA 10c'
271
+
272
+ ######
273
+ # #
274
+ # #
275
+ ## $$##
276
+ # $@.#
277
+ ## ..#
278
+ #####
279
+
280
+ ; 24
281
+ 'LOMA 10d'
282
+
283
+ #####
284
+ ### #
285
+ # $$# #
286
+ # $@. #
287
+ # .. #
288
+ #######