scottkit 0.4.0 → 1.0.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 26ccefb089e59a1db6c06ff509373ed0c9f97ee1
4
+ data.tar.gz: ff2d2488c57754958e723dfa49274cbcb102aff6
5
+ SHA512:
6
+ metadata.gz: 988ec02e55c50a140b2347b3134e5be8d7abe69a3e6f6837c04be2ef32a792d6146f352663ffd90523c0c9d61af565911db52696615021ac7a99f4106088d6ea
7
+ data.tar.gz: f9bdc3f3aded8deb5f67cdef493f40294cb8ba90796ff612a0d39db5f1efa7f51453e1f50f01ad4950ce948d0327da8c2210ae5065657d5d57bc25e7ec8c835d
data/.yardopts CHANGED
@@ -1 +1 @@
1
- --no-private bin/scottkit lib/**/.rb - Changes GPL-2 notes/Definition notes/Definition.saved-game
1
+ --no-private bin/scottkit lib/**/.rb - ChangeLog.md GPL-2.txt notes/Definition.txt notes/Definition-saved-game.txt manual/reference.md
data/ChangeLog.md ADDED
@@ -0,0 +1,50 @@
1
+ Revision history for Ruby gem ScottKit
2
+ ======================================
3
+
4
+ 1.0.0 (IN PROGRESS)
5
+ -------------------
6
+ * Finish translating reference guide from POD to MarkDown.
7
+ * Update reference guide to describe ScottKit format rather then Games::ScottAdams format.
8
+ * Fix handling of darkness when playing games.
9
+ * Support unquoted "carried" and "at" in conditions
10
+
11
+ 0.4.0 (Mon Mar 1 22:20:09 GMT 2010)
12
+ ------------------------------------
13
+ * Move towards using YARD for documentation instead of Rdoc. This
14
+ includes changes to things like the format of the Changes file. Far
15
+ from perfect so far: for example, plain-text documentation like
16
+ `doc/Definition` gets mangled.
17
+
18
+ 0.3.0 (February 28, 2010)
19
+ -------------------------
20
+ * Move ScottKit out of its sub-siubdirectory in the 9Gb `mike`
21
+ git module into its own git module.
22
+ * Move repository hosting to github.
23
+ * Arrange for formatted documentation to appear at
24
+ [http://rdoc.info/projects/MikeTaylor/scottkit](http://rdoc.info/projects/MikeTaylor/scottkit)
25
+
26
+ 0.2.0 (February 28, 2010)
27
+ -------------------------
28
+ * Add `-z` option to sleep after finishing - useful when running in a
29
+ DOS Shell under Windows, so that error messages can be seen.
30
+ * Add facility to load a game while playing, using `#load`
31
+
32
+ 0.1.0 (February 28, 2010)
33
+ -------------------------
34
+ * Add `-p` option to compile and play a game from source.
35
+
36
+ 0.0.0 (February 28, 2010)
37
+ -------------------------
38
+ * Initial release.
39
+
40
+
41
+ Still to do
42
+ ===========
43
+
44
+ * Tweak compiler to break actions when they need too many arguments as
45
+ well as when they need too many instructions.
46
+ * Write tutorial scaffolding.
47
+ * Ensure that the right files are built by `YARD`
48
+ * Write blog entry about ScottKit
49
+ * Maybe modify to run against GLK using the Glkx driver
50
+ * File inclusion
File without changes
data/README.md ADDED
@@ -0,0 +1,100 @@
1
+ ScottKit - a toolkit for Scott Adams-style adventure games
2
+ ==========================================================
3
+
4
+ **Homepage**: [http://rdoc.info/projects/MikeTaylor/scottkit](http://rdoc.info/projects/MikeTaylor/scottkit)
5
+ **Git**: [http://github.com/MikeTaylor/scottkit](http://github.com/MikeTaylor/scottkit)
6
+ **Author**: Mike Taylor <mike@miketaylor.org.uk>
7
+ **Copyright**: 2009-2010
8
+ **License**: GNU GPL, version 2 - see file GPL-2
9
+
10
+
11
+ Synopsis
12
+ --------
13
+
14
+ This is a Ruby program to compile, decompile and run adventure games
15
+ in Scott Adams format, including those created by the great man
16
+ himself. ScottKit's good for nostalgia freaks wanting to relive the
17
+ classic games of the 1980s, but also as a tool for creating small,
18
+ concise, new games.
19
+
20
+ It was intially written as an exercise in Ruby rather than with any
21
+ great expectation that it would be useful, but it turns out to work
22
+ pretty well as a tight, clean environment for games programming: if
23
+ Inform 7 is like the Ruby of adventure games, ScottKit is like C. For
24
+ a big project, you definitely want Inform 7; but I've found that there
25
+ is a distinctive appeal to ScottKit. Apart from anything else, it
26
+ makes a good domain-specific "little language" for teaching my sons
27
+ how to program.
28
+
29
+
30
+ Running ScottKit
31
+ ----------------
32
+
33
+ The main three modes of running are:
34
+
35
+ $ scottkit -c game.sck > game.sao # compile
36
+ $ scottkit game.sao # play the game; or use scottfree game.sao
37
+ $ scottkit -d game.sao # decompile - useful for cheating
38
+
39
+ And there's a handy short-cut combining compilation and play:
40
+
41
+ $ scottkit -p game.sck # compile to memory, and play immediately
42
+
43
+ Other command-line arguments enable wizard commands, load saved games,
44
+ set random seeds and enable various kinds of debugging output: run
45
+ `scottkit -h` for details.
46
+
47
+
48
+ Testing
49
+ -------
50
+
51
+ Unit testing can be done as follows:
52
+
53
+ $ ruby -I lib -rrake/rake_test_loader test/test_*
54
+ Loaded suite test/test_canonicalise
55
+ Started
56
+ ...........
57
+ Finished in 0.769568 seconds.
58
+
59
+ 11 tests, 37 assertions, 0 failures, 0 errors, 0 skips
60
+
61
+
62
+ Game format
63
+ -----------
64
+
65
+ The file `notes/Definition-scottfree-1.14.txt` is taken from the
66
+ ScottFree package, which contains another interpreter for Scott Adams
67
+ games. I got this file from release 1.14-9 of ScottFree.
68
+ `notes/Definition.txt` is my modified version of this file, since the
69
+ original had several mistakes. `notes/Definition-saved-game.txt` is
70
+ my own analysis of the format of saved games from ScottFree. (Saved
71
+ games from ScottFree and ScottKit can be freely interchanged.)
72
+
73
+
74
+ Games
75
+ -----
76
+
77
+ The directory `data` contains game files:
78
+
79
+ * `adams` - Scott Adams's classic games (see Makefile for details)
80
+ * `howarth` - Brian Howarth's games (see Makefile for details)
81
+ * `test` - games files used by unit-test suite
82
+ * `tutorial` - tiny game used in ScottKit tutorial
83
+ * `crystal` - Crystal of Chaos, a game written to exercise ScottKit
84
+ * `dan-and-matt.sck` - game written by my two eldest sons
85
+
86
+ I have verified that ScottKit can be used to play and win Scott
87
+ Adams's games #1, 2, and 4: *Adventureland*, *Pirate Adventure* and
88
+ *Voodoo Castle*. I welcome reports of its being used to play and win
89
+ other games, or failing that, reports of how it fails.
90
+
91
+
92
+
93
+ Bug tolerance
94
+ -------------
95
+
96
+ The `-b` (`--bug-tolerant`) option is needed for Scott Adams Adventure
97
+ 14b (*Buckaroo Banzai*), which places one item (the jug of jet fuel)
98
+ in room 50 of 36. None of Scott's own games is so sloppy.
99
+
100
+
data/Rakefile CHANGED
@@ -5,8 +5,9 @@ begin
5
5
  require 'jeweler'
6
6
  Jeweler::Tasks.new do |gem|
7
7
  gem.name = "scottkit"
8
- gem.summary = "ScottKit is a toolkit for compiling, decompiling and playing adventure games in the Scott Adams format."
9
- gem.description = gem.summary
8
+ gem.license = 'GPL-2.0'
9
+ gem.summary = "Toolkit for Scott Adams-format adventure games"
10
+ gem.description = "ScottKit is a toolkit for compiling, decompiling and playing adventure games in the Scott Adams format."
10
11
  gem.email = "mike@miketaylor.org.uk"
11
12
  gem.homepage = "http://github.com/MikeTaylor/scottkit"
12
13
  gem.author = "Mike Taylor"
@@ -42,7 +43,7 @@ task :test => :check_dependencies
42
43
 
43
44
  task :default => :test
44
45
 
45
- require 'rake/rdoctask'
46
+ require 'rdoc/task'
46
47
  Rake::RDocTask.new do |rdoc|
47
48
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
49
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 1.0.0
data/bin/scottkit CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/local/bin/ruby1.9 -w
1
+ #!/usr/local/bin/ruby -w
2
2
 
3
3
  # Command-line driver for the ScottKit toolkit, allowing Scott
4
4
  # Adams-format adventure games to be compiled, decompiled and played.
@@ -31,7 +31,6 @@ end
31
31
 
32
32
  mode = :play
33
33
  options = {}
34
- compile, decompile, play_from_source = false, false, false
35
34
  sleep_at_end = false
36
35
 
37
36
  opts = OptionParser.new do |x|
@@ -33,6 +33,9 @@ get plywood
33
33
  south
34
34
  get balsa
35
35
  south
36
+ climb tree
37
+ get honey
38
+ down
36
39
  drop oak
37
40
  drop plywood
38
41
  drop balsa
@@ -45,6 +48,7 @@ get lamp
45
48
  west
46
49
  south
47
50
  south
51
+ follow path
48
52
  give honey
49
53
  follow path
50
54
  get vase
data/data/test/Makefile CHANGED
@@ -1,7 +1,7 @@
1
1
  # This rebuilds the files used for regression testing
2
2
  # Do this ONLY WHEN SURE that the software is correct
3
3
 
4
- RUN = ruby1.9 -I ../../lib ../../bin/scottkit
4
+ RUN = ruby -I ../../lib ../../bin/scottkit
5
5
 
6
6
  **default**:
7
7
  @echo "Use 'make rebuild' if you are SURE that the software is correct"
@@ -1,7 +1,7 @@
1
1
  # This rebuilds the files used for regression testing
2
2
  # Do this ONLY WHEN SURE that the software is correct
3
3
 
4
- RUN = ruby1.9 -I ../../../lib ../../../bin/scottkit
4
+ RUN = ruby -I ../../../lib ../../../bin/scottkit
5
5
 
6
6
  **default**:
7
7
  @echo "Use 'make rebuild' if you are SURE that the software is correct"
@@ -291,7 +291,7 @@ action SAV GAM
291
291
  action LOO:
292
292
  look
293
293
 
294
- occur when "at" forest2
294
+ occur when at forest2
295
295
  set_dark
296
296
 
297
297
  occur when !at forest2
@@ -316,11 +316,11 @@ occur 0%
316
316
  print "a bronze sceptre, a zinc goblet and a tin stoat."
317
317
  comment "cont"
318
318
 
319
- occur when "at" "west" and !flag 6
319
+ occur when at "west" and !flag 6
320
320
  set_flag 6
321
321
  print "Oh, there they are. That wasn't as hard as I expected."
322
322
 
323
- occur when "at" hut
323
+ occur when at hut
324
324
  set_flag 7
325
325
 
326
326
  occur when !here chain
@@ -342,31 +342,31 @@ occur when flag 7 and !flag 8
342
342
  set_flag 8
343
343
  print "Ah, looks like I'm still missing the stoat."
344
344
 
345
- occur when "at" level
345
+ occur when at level
346
346
  set_flag 5
347
347
 
348
- occur when "at" "north"
348
+ occur when at "north"
349
349
  set_flag 5
350
350
 
351
- occur when "at" north1
351
+ occur when at north1
352
352
  set_flag 5
353
353
 
354
- occur when "at" "south"
354
+ occur when at "south"
355
355
  set_flag 5
356
356
 
357
- occur when "at" south1
357
+ occur when at south1
358
358
  set_flag 5
359
359
 
360
- occur when "at" forest1
360
+ occur when at forest1
361
361
  clear_flag 5
362
362
 
363
- occur when "at" wall
363
+ occur when at wall
364
364
  clear_flag 5
365
365
 
366
- occur when "at" vase
366
+ occur when at vase
367
367
  clear_flag 5
368
368
 
369
- occur when "at" again
369
+ occur when at again
370
370
  clear_flag 5
371
371
 
372
372
  occur when counter_eq 1
@@ -403,7 +403,7 @@ occur 0%
403
403
  set_flag 4
404
404
  comment "cont"
405
405
 
406
- occur when flag 4 and "at" glade
406
+ occur when flag 4 and at glade
407
407
  destroy bees
408
408
  put bees1 tree
409
409
 
@@ -533,7 +533,7 @@ action GO ENT when here north2
533
533
  goto "room"
534
534
  look2
535
535
 
536
- action LIG PLY when "carried" Plywood
536
+ action LIG PLY when carried Plywood
537
537
  print "Not while I'm carrying it!"
538
538
 
539
539
  action LIG PLY when here Plywood
@@ -546,10 +546,10 @@ action LIG OAK when here Oak
546
546
  print "My match goes out."
547
547
  destroy match
548
548
 
549
- action LIG OAK when "carried" Oak
549
+ action LIG OAK when carried Oak
550
550
  print "Not while I'm carrying it!"
551
551
 
552
- action LIG BAL when "carried" wood
552
+ action LIG BAL when carried wood
553
553
  print "Not while I'm carrying it!"
554
554
 
555
555
  action LIG BAL when here wood
@@ -566,7 +566,7 @@ occur 0%
566
566
  action GO PAT when here bear
567
567
  print "Bear won't let me"
568
568
 
569
- action GO PAT when "at" forest
569
+ action GO PAT when at forest
570
570
  goto forest2
571
571
  look2
572
572
 
@@ -584,11 +584,11 @@ action GO VAS when here vase
584
584
  goto vase
585
585
  look2
586
586
 
587
- action LEA VAS when "at" vase
587
+ action LEA VAS when at vase
588
588
  swap_specific_room 1
589
589
  look2
590
590
 
591
- action TAK OUT when "at" vase
591
+ action TAK OUT when at vase
592
592
  swap_specific_room 1
593
593
  look2
594
594
 
@@ -607,7 +607,7 @@ action GO INF when here "south"
607
607
  goto "north"
608
608
  look2
609
609
 
610
- action KNO DOO when "at" cells
610
+ action KNO DOO when at cells
611
611
  print "Which door? Use `knock iron` or `knock bronze`."
612
612
 
613
613
  action KNO IRO when here south1
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Test with: cd /usr/local/src/mike/scott/scottkit && ruby1.9 -I lib bin/scottkit -c data/tutorial/t7.sck
2
+ # Test with: cd /usr/local/src/mike/scott/scottkit && ruby -I lib bin/scottkit -c data/tutorial/t7.sck
3
3
 
4
4
  require 'pp'
5
5
 
@@ -147,7 +147,7 @@ module ScottKit
147
147
  conds = []
148
148
  while peek == :when || peek == :and
149
149
  skip
150
- op = match :symbol
150
+ op = match([:symbol, :carried, :at])
151
151
  type = Condition::OPStotype[op] or
152
152
  error "unknown condition op '#{op}'"
153
153
  case type
@@ -634,7 +634,12 @@ module ScottKit
634
634
  def match(expected, estr = nil)
635
635
  token = peek
636
636
  @lookahead = nil
637
- if token != expected
637
+ if (expected.kind_of?(Array))
638
+ ok = expected.any? {|x| token == x}
639
+ else
640
+ ok = token == expected
641
+ end
642
+ if (!ok)
638
643
  error("expected #{estr || expected}, got #{render(token)}" +
639
644
  " (before `#{@buffer.lstrip}')")
640
645
  end
@@ -5,7 +5,7 @@ module ScottKit
5
5
  def quote(token) #:nodoc:
6
6
  if ((token !~ /^([!a-z_0-9-]+)$/i || token =~ /\n/) ||
7
7
  Compiler::Lexer::TOKENMAP[token])
8
- "\"#{token.gsub(/[""]/, '\'')}\""
8
+ "\"#{token.gsub('"', '\'')}\""
9
9
  else
10
10
  token
11
11
  end
@@ -127,7 +127,7 @@ module ScottKit
127
127
 
128
128
  def render
129
129
  type = OPS[@cond][1]
130
- res = quote(OPS[@cond][0])
130
+ res = OPS[@cond][0]
131
131
  res += " " +
132
132
  quote(type == :room ? @game.roomname(@value) :
133
133
  type == :item ? @game.itemname(@value) :
data/lib/scottkit/game.rb CHANGED
@@ -248,7 +248,7 @@ module ScottKit
248
248
  0.upto(NFLAGS-1) do |i|
249
249
  @counters[i], @saved_rooms[i] = f.gets.chomp.split.map(&:to_i)
250
250
  end
251
- tmp, dark_flag, @loc, @counter, @saved_room, @lampleft =
251
+ tmp, _UNUSED_dark_flag, @loc, @counter, @saved_room, @lampleft =
252
252
  f.gets.chomp.split.map(&:to_i)
253
253
  0.upto(NFLAGS-1) do |i|
254
254
  @flags[i] = (tmp & 1 << i) != 0
data/lib/scottkit/play.rb CHANGED
@@ -13,7 +13,6 @@ module ScottKit
13
13
  @saved_room = 0
14
14
  @loc = defined?(@startloc) ? @startloc : 1
15
15
  @lampleft = defined?(@lamptime) ? @lamptime : 0
16
- dark_flag = false
17
16
 
18
17
  puts "ScottKit, a Scott Adams game toolkit in Ruby."
19
18
  puts "Release 1.0, (C) 2010 Mike Taylor <mike@miketaylor.org.uk>"
@@ -134,7 +133,7 @@ module ScottKit
134
133
  look
135
134
  # When moving from a light place to a dark one or vice
136
135
  # versa, this look should not happen, because we'll get a
137
- # correct version of the display after to flag gets set.
136
+ # correct version of the display after the flag gets set.
138
137
  # I'm not sure what can be done about this. ### Think
139
138
  elsif is_dark
140
139
  puts "I fell down and broke my neck."
@@ -323,10 +322,10 @@ module ScottKit
323
322
  end
324
323
 
325
324
  def is_dark
326
- return dark_flag if @items.size <= ITEM_LAMP
325
+ return @flags[15] if @items.size <= ITEM_LAMP
327
326
  loc = @items[ITEM_LAMP].loc
328
- #puts "dark_flag=#{dark_flag}, lamp(#{ITEM_LAMP}) at #{loc}"
329
- dark_flag && loc != ROOM_CARRIED && loc != @loc
327
+ #puts "dark_flag=#{@flags[15]}, lamp(#{ITEM_LAMP}) at #{loc}"
328
+ @flags[15] && loc != ROOM_CARRIED && loc != @loc
330
329
  end
331
330
 
332
331
  public :play # Must be visible to driver program
@@ -391,13 +390,13 @@ module ScottKit
391
390
  when 53 then @game.items[args.shift].loc = @game.loc
392
391
  when 54 then @game.loc = args.shift
393
392
  when 55 then @game.items[args.shift].loc = ROOM_NOWHERE
394
- when 56 then @game.dark_flag = true
395
- when 57 then @game.dark_flag = false
393
+ when 56 then @game.flags[15] = true
394
+ when 57 then @game.flags[15] = false
396
395
  when 58 then @game.flags[args.shift] = true
397
396
  when 59 then @game.items[args.shift].loc = ROOM_NOWHERE
398
397
  when 60 then @game.flags[args.shift] = false
399
398
  when 61 then
400
- puts "I am dead."; @game.dark_flag = false;
399
+ puts "I am dead."; @game.flags[15] = false;
401
400
  @game.loc = @game.rooms.size-1; @game.look
402
401
  when 62 then i = args.shift; @game.items[i].loc = args.shift
403
402
  when 63 then @game.finished(0)