scottkit 1.2.0 → 1.3.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 +4 -4
- data/ChangeLog.md +7 -0
- data/VERSION +1 -1
- data/bin/scottkit +5 -0
- data/lib/scottkit/compile.rb +25 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e80e01217ac415c8a5f61c8f76e79b143bb9634c
|
4
|
+
data.tar.gz: bd464ca8f5bd0f4db93aae2e85c2405b87d78efe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a2c8559a16971027c380eb6f8ebf0b013bc6e74192bef684cac5fbe6d80cea2a7dbec2e763d8065ff9a2d9b8dcc0dbeedb07aeb98beeb093518253f976500cf
|
7
|
+
data.tar.gz: df62ce26c9a33c8d22b8db3617b1802f02a0bb60f31410ee717380949cd828ddf3f3403a2c1eb6f685c39c38675b159bbe7920616501454f4998937e9f2fc838
|
data/ChangeLog.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Revision history for Ruby gem ScottKit
|
2
2
|
|
3
|
+
## 1.3.0 (Mon Oct 16 20:27:43 BST 2017)
|
4
|
+
|
5
|
+
* Support `--lint` (`-L`) command-line option. Fixes issue 1.
|
6
|
+
Argument is a string of characters:
|
7
|
+
* `e` -- check for rooms with no exits (traps)
|
8
|
+
* `E` -- check for rooms with only one exit (dead ends)
|
9
|
+
|
3
10
|
## 1.2.0 (Mon Oct 16 15:11:44 BST 2017)
|
4
11
|
|
5
12
|
* Create initial tutorial, exactly equivalent to that of Games::ScottAdams.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.3.0
|
data/bin/scottkit
CHANGED
@@ -59,6 +59,11 @@ opts = OptionParser.new do |x|
|
|
59
59
|
x.on("-s", "--random-seed VAL", "Set random seed for repeatability") { |val|
|
60
60
|
options[:random_seed] = Integer(val)
|
61
61
|
}
|
62
|
+
x.on("-L", "--lint STR", "Lint options: a string of the following:
|
63
|
+
e Ensure rooms all have at least one way out (no traps)
|
64
|
+
E Ensure rooms all have at least two ways in/out (no dead ends)") { |val|
|
65
|
+
options[:lint] = val;
|
66
|
+
}
|
62
67
|
x.on("-b", "--bug-tolerant", "Copy with out-of-range locations, etc.") {
|
63
68
|
options[:bug_tolerant] = true
|
64
69
|
}
|
data/lib/scottkit/compile.rb
CHANGED
@@ -209,6 +209,7 @@ module ScottKit
|
|
209
209
|
|
210
210
|
|
211
211
|
def generate_code(tree)
|
212
|
+
lintOptions = @game.options[:lint]
|
212
213
|
@had_errors = false
|
213
214
|
rooms = tree.rooms
|
214
215
|
items = tree.items
|
@@ -237,6 +238,26 @@ module ScottKit
|
|
237
238
|
gerror "#{caption} room '#{loc}' does not exist"
|
238
239
|
}
|
239
240
|
|
241
|
+
begin # lint
|
242
|
+
no_exits = []
|
243
|
+
dead_ends = []
|
244
|
+
rooms.each.with_index do |room, index|
|
245
|
+
next if index == 0
|
246
|
+
next if
|
247
|
+
if room.exits.length == 0
|
248
|
+
no_exits.push room.name
|
249
|
+
elsif room.exits.length == 1
|
250
|
+
dead_ends.push room.name
|
251
|
+
end
|
252
|
+
end
|
253
|
+
if lintOptions.match('e') && no_exits.length > 0
|
254
|
+
gwarning "#{no_exits.length} rooms with no exits: " + no_exits.map { |x| "'#{x}'" }.join(', ')
|
255
|
+
end
|
256
|
+
if lintOptions.match('E') && dead_ends.length > 0
|
257
|
+
gwarning "#{dead_ends.length} rooms that are dead ends: " + dead_ends.map { |x| "'#{x}'" }.join(', ')
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
240
261
|
# Resolve room names in exits
|
241
262
|
rooms.each do |room|
|
242
263
|
room.exits.each do |dir, dest|
|
@@ -510,6 +531,10 @@ module ScottKit
|
|
510
531
|
0
|
511
532
|
end
|
512
533
|
|
534
|
+
def gwarning(str)
|
535
|
+
$stderr.puts "warning: #{str}"
|
536
|
+
0
|
537
|
+
end
|
513
538
|
|
514
539
|
public :compile_to_stdout # Must be visible to Game.compile()
|
515
540
|
public :parse # Used by test_compile.rb
|