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 +62 -0
- data/Rakefile +86 -71
- data/TODO +19 -2
- data/VERSION +1 -1
- data/data/smagacor/smagacor-logo.png +0 -0
- data/data/smagacor/sokoban/crate.png +0 -0
- data/data/smagacor/sokoban/floor.png +0 -0
- data/data/smagacor/sokoban/game.info +7 -0
- data/data/smagacor/sokoban/levels/loma.lvl +288 -0
- data/data/smagacor/sokoban/levels/mas_microban.lvl +1812 -0
- data/data/smagacor/sokoban/levels/mas_sasquatch.lvl +891 -0
- data/data/smagacor/sokoban/levels/microban.lvl +1834 -0
- data/data/smagacor/sokoban/levels/sasquatch.lvl +846 -0
- data/data/smagacor/sokoban/levels/sasquatch_III.lvl +903 -0
- data/data/smagacor/sokoban/levels/sasquatch_IV.lvl +812 -0
- data/data/smagacor/sokoban/levels/sasquatch_V.lvl +868 -0
- data/data/smagacor/sokoban/levels/sasquatch_VI.lvl +902 -0
- data/data/smagacor/sokoban/levels/sasquatch_VII.lvl +898 -0
- data/data/smagacor/sokoban/man.png +0 -0
- data/data/smagacor/sokoban/sokoban.png +0 -0
- data/data/smagacor/sokoban/sokobanui.rb +597 -0
- data/data/smagacor/sokoban/storage.png +0 -0
- data/data/smagacor/sokoban/wall.png +0 -0
- data/data/smagacor/tictactoe/game.info +1 -1
- data/data/smagacor/tictactoe/tictactoe.png +0 -0
- data/data/smagacor/tictactoe/tictactoe.rb +295 -206
- data/data/smagacor/tictactoe/x.png +0 -0
- data/lib/smagacor/listener.rb +50 -0
- data/lib/smagacor/smagacor-ui.rb +208 -127
- data/lib/smagacor/{controller.rb → util.rb} +106 -7
- metadata +68 -45
- data/install.rb +0 -21
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
#--
|
3
3
|
#
|
4
|
-
# $Id:
|
4
|
+
# $Id: util.rb 362 2005-11-26 17:56:46Z thomas $
|
5
5
|
#
|
6
6
|
# smagacor - a collection of small games in ruby
|
7
7
|
# Copyright (C) 2004 Thomas Leitner
|
@@ -22,6 +22,7 @@
|
|
22
22
|
require 'rbconfig'
|
23
23
|
require "yaml"
|
24
24
|
require 'logger'
|
25
|
+
require 'smagacor/listener'
|
25
26
|
|
26
27
|
class Object
|
27
28
|
|
@@ -44,7 +45,7 @@ end
|
|
44
45
|
module Smagacor
|
45
46
|
|
46
47
|
# The version of this copy of Smagacor
|
47
|
-
VERSION = [0, 0,
|
48
|
+
VERSION = [0, 0, 2]
|
48
49
|
|
49
50
|
class GameInfo
|
50
51
|
|
@@ -59,7 +60,7 @@ module Smagacor
|
|
59
60
|
attr_reader :classname
|
60
61
|
attr_reader :category
|
61
62
|
|
62
|
-
def
|
63
|
+
def interface_class
|
63
64
|
@classname.split( /::/ ).inject( Object ) {|mod, name| mod.const_get( name )}
|
64
65
|
end
|
65
66
|
|
@@ -85,15 +86,110 @@ module Smagacor
|
|
85
86
|
|
86
87
|
end
|
87
88
|
|
89
|
+
class GameState
|
88
90
|
|
89
|
-
|
91
|
+
attr_accessor :state
|
92
|
+
attr_accessor :undo_manager
|
93
|
+
|
94
|
+
def initialize( game_info )
|
95
|
+
@game_info = game_info
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
class GamePlugin
|
101
|
+
|
102
|
+
def menu
|
103
|
+
nil
|
104
|
+
end
|
105
|
+
|
106
|
+
def game_widget
|
107
|
+
raise NotImplementedError
|
108
|
+
end
|
109
|
+
|
110
|
+
def set_undo_manager( manager )
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
|
116
|
+
class UndoManager
|
117
|
+
|
118
|
+
include Listener
|
119
|
+
|
120
|
+
attr_reader :history
|
121
|
+
|
122
|
+
def initialize
|
123
|
+
@history = []
|
124
|
+
@index = -1
|
125
|
+
add_msg_name( :possible_actions )
|
126
|
+
add_msg_name( :undo )
|
127
|
+
add_msg_name( :redo )
|
128
|
+
end
|
129
|
+
|
130
|
+
def add_undo_info( info )
|
131
|
+
@history[@index+1..-1] = []
|
132
|
+
@history.push( info )
|
133
|
+
@index += 1
|
134
|
+
dispatch_msg( :possible_actions, possible_actions )
|
135
|
+
end
|
136
|
+
|
137
|
+
def clear
|
138
|
+
@history = []
|
139
|
+
@index = -1
|
140
|
+
end
|
141
|
+
|
142
|
+
def undo
|
143
|
+
if @index > -1
|
144
|
+
info = @history[@index]
|
145
|
+
@index -= 1
|
146
|
+
dispatch_msg( :possible_actions, possible_actions )
|
147
|
+
dispatch_msg( :undo, info )
|
148
|
+
info
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def undo_possible?
|
153
|
+
@history.length > 0 && @index > -1
|
154
|
+
end
|
155
|
+
|
156
|
+
def redo
|
157
|
+
if @index < @history.length - 1
|
158
|
+
@index += 1
|
159
|
+
info = @history[@index]
|
160
|
+
dispatch_msg( :possible_actions, possible_actions )
|
161
|
+
dispatch_msg( :redo, info )
|
162
|
+
info
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
def redo_possible?
|
167
|
+
@history.length > 0 && @index < @history.length - 1
|
168
|
+
end
|
169
|
+
|
170
|
+
#######
|
171
|
+
private
|
172
|
+
#######
|
173
|
+
|
174
|
+
def possible_actions
|
175
|
+
a = []
|
176
|
+
a << :undo if undo_possible?
|
177
|
+
a << :redo if redo_possible?
|
178
|
+
a
|
179
|
+
end
|
180
|
+
|
181
|
+
end
|
182
|
+
|
183
|
+
|
184
|
+
class Configuration
|
90
185
|
|
91
186
|
attr_reader :gamespath
|
92
187
|
attr_reader :games
|
188
|
+
attr_reader :homepath
|
93
189
|
|
94
190
|
def initialize
|
95
191
|
@gamespath = [ File.join( ::Config::CONFIG["datadir"], "smagacor" ), 'data/smagacor' ]
|
96
|
-
if defined? Gem::Cache
|
192
|
+
if defined?( Gem::Cache )
|
97
193
|
gem = Gem::Cache.from_installed_gems.search( "smagacor", "=#{::Smagacor::VERSION.join('.')}" ).last
|
98
194
|
@gamespath << File.join( gem.full_gem_path, "data", "smagacor" ) if gem
|
99
195
|
end
|
@@ -102,7 +198,8 @@ module Smagacor
|
|
102
198
|
rescue
|
103
199
|
homepath = ENV['USERPROFILE'] || ENV['HOMEDRIVE']+ENV['HOMEPATH']
|
104
200
|
end
|
105
|
-
@
|
201
|
+
@homepath = File.join( homepath, '.smagacor' )
|
202
|
+
@gamespath.unshift( @homepath )
|
106
203
|
@games = []
|
107
204
|
end
|
108
205
|
|
@@ -119,11 +216,13 @@ module Smagacor
|
|
119
216
|
Dir[path + '/*/game.info'].each do |file|
|
120
217
|
gi = YAML::load( File.open( file ) )
|
121
218
|
gi.directory = File.dirname( file )
|
122
|
-
@games.push gi
|
219
|
+
@games.push( gi )
|
123
220
|
end
|
124
221
|
end
|
125
222
|
end
|
126
223
|
|
127
224
|
end
|
128
225
|
|
226
|
+
Config = Configuration.new
|
227
|
+
|
129
228
|
end
|
metadata
CHANGED
@@ -1,69 +1,92 @@
|
|
1
|
-
|
2
|
-
rubygems_version: 0.8.
|
1
|
+
!ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.8.6
|
3
3
|
specification_version: 1
|
4
4
|
name: smagacor
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.
|
7
|
-
date: 2005-
|
6
|
+
version: 0.0.2
|
7
|
+
date: 2005-11-26
|
8
8
|
summary: A collection of small games in ruby
|
9
9
|
require_paths:
|
10
|
-
|
10
|
+
- lib
|
11
11
|
email: t_leitner@gmx.at
|
12
12
|
homepage: smagacor.rubyforge.org
|
13
13
|
rubyforge_project: smagacor
|
14
|
-
description:
|
15
|
-
new games should not be to hard, as Smagacor provides some useful classes for
|
16
|
-
games."
|
14
|
+
description: Smagacor is a collection of some small games, like TicTacToe and Pong. Adding new games should not be to hard, as Smagacor provides some useful classes for games.
|
17
15
|
autorequire:
|
18
16
|
default_executable: smagacor
|
19
17
|
bindir: bin
|
20
18
|
has_rdoc: true
|
21
19
|
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
22
20
|
requirements:
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
version: 0.0.0
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
27
24
|
version:
|
28
25
|
platform: ruby
|
29
26
|
authors:
|
30
|
-
|
27
|
+
- Thomas Leitner
|
31
28
|
files:
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
29
|
+
- setup.rb
|
30
|
+
- TODO
|
31
|
+
- COPYING
|
32
|
+
- README
|
33
|
+
- Rakefile
|
34
|
+
- ChangeLog
|
35
|
+
- VERSION
|
36
|
+
- bin/smagacor
|
37
|
+
- lib/smagacor
|
38
|
+
- lib/smagacor/listener.rb
|
39
|
+
- lib/smagacor/util.rb
|
40
|
+
- lib/smagacor/smagacor-ui.rb
|
41
|
+
- test/games
|
42
|
+
- test/runtests.rb
|
43
|
+
- test/smagacor
|
44
|
+
- test/games/tictactoe
|
45
|
+
- test/games/tictactoe/game.info
|
46
|
+
- test/smagacor/tc_controller.rb
|
47
|
+
- data/smagacor
|
48
|
+
- data/smagacor/sokoban
|
49
|
+
- data/smagacor/smagacor-logo.png
|
50
|
+
- data/smagacor/tictactoe
|
51
|
+
- data/smagacor/smagacor.png
|
52
|
+
- data/smagacor/sokoban/storage.png
|
53
|
+
- data/smagacor/sokoban/man.png
|
54
|
+
- data/smagacor/sokoban/crate.png
|
55
|
+
- data/smagacor/sokoban/floor.png
|
56
|
+
- data/smagacor/sokoban/wall.png
|
57
|
+
- data/smagacor/sokoban/levels
|
58
|
+
- data/smagacor/sokoban/sokobanui.rb
|
59
|
+
- data/smagacor/sokoban/sokoban.png
|
60
|
+
- data/smagacor/sokoban/game.info
|
61
|
+
- data/smagacor/sokoban/levels/sasquatch_VII.lvl
|
62
|
+
- data/smagacor/sokoban/levels/sasquatch.lvl
|
63
|
+
- data/smagacor/sokoban/levels/mas_sasquatch.lvl
|
64
|
+
- data/smagacor/sokoban/levels/sasquatch_III.lvl
|
65
|
+
- data/smagacor/sokoban/levels/mas_microban.lvl
|
66
|
+
- data/smagacor/sokoban/levels/sasquatch_IV.lvl
|
67
|
+
- data/smagacor/sokoban/levels/microban.lvl
|
68
|
+
- data/smagacor/sokoban/levels/sasquatch_VI.lvl
|
69
|
+
- data/smagacor/sokoban/levels/loma.lvl
|
70
|
+
- data/smagacor/sokoban/levels/sasquatch_V.lvl
|
71
|
+
- data/smagacor/tictactoe/o.png
|
72
|
+
- data/smagacor/tictactoe/x.png
|
73
|
+
- data/smagacor/tictactoe/tictactoe.rb
|
74
|
+
- data/smagacor/tictactoe/tictactoe.png
|
75
|
+
- data/smagacor/tictactoe/game.info
|
58
76
|
test_files: []
|
77
|
+
|
59
78
|
rdoc_options:
|
60
|
-
|
61
|
-
|
79
|
+
- --line-numbers
|
80
|
+
- -m
|
81
|
+
- README
|
62
82
|
extra_rdoc_files:
|
63
|
-
|
64
|
-
|
83
|
+
- README
|
84
|
+
- bin/smagacor
|
65
85
|
executables:
|
66
|
-
|
86
|
+
- smagacor
|
67
87
|
extensions: []
|
88
|
+
|
68
89
|
requirements: []
|
69
|
-
|
90
|
+
|
91
|
+
dependencies: []
|
92
|
+
|
data/install.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'rpa/install'
|
3
|
-
|
4
|
-
class Install_smagacor < RPA::Install::FullInstaller
|
5
|
-
name 'smagacor'
|
6
|
-
version '0.0.1-1'
|
7
|
-
classification Application
|
8
|
-
build do
|
9
|
-
installdocs %w[COPYING ChangeLog TODO]
|
10
|
-
installdocs 'docs'
|
11
|
-
installrdoc %w[README] + Dir['lib/**/*.rb']
|
12
|
-
installdata
|
13
|
-
end
|
14
|
-
description <<-EOF
|
15
|
-
A collection of small games in ruby
|
16
|
-
|
17
|
-
Smagacor is a collection of some small games,
|
18
|
-
like TicTacToe and Pong. Adding new games should not be to hard,
|
19
|
-
as Smagacor provides some useful classes for games.
|
20
|
-
EOF
|
21
|
-
end
|