inform6lib 0.1.1 → 0.1.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.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/lib/inform/parserm.h.rb +1 -195
- data/lib/inform/verblibm.h.rb +1 -6
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eb96a12c00fe171072a37b734b09ace326c78f5c2b7e5f64a8a288d0c44d5c3c
|
|
4
|
+
data.tar.gz: 18602dac5e23311f3b3f314c9c3f4a3fcc4599d2ed6c6047ff48957d6399f5a7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 66f4af9e13875301a235819e59da8d7597408c350d35f5c9a5858445d154d9bf02c0d3636bfc9620b4e767f5cff215dd9e0546bfad683a18dbe8435f1897e9cf
|
|
7
|
+
data.tar.gz: c0c89127eaf9083c65becbfb55580322ac2d74a7dfa192745e52a8528fdbd0c19dc6b8407182583161f525ec1fdb02b166933a34f54b95e4ad7a2bc8e338d326
|
data/Rakefile
CHANGED
data/lib/inform/parserm.h.rb
CHANGED
|
@@ -516,7 +516,7 @@ module Parser
|
|
|
516
516
|
|
|
517
517
|
# If you want to use the third-person of the narrative voice, you will
|
|
518
518
|
# need to replace this selfobj with your own.
|
|
519
|
-
SelfObj = Object("(self object)") {
|
|
519
|
+
SelfObj = Inform::Ephemeral::Object.new("(self object)") {
|
|
520
520
|
with {
|
|
521
521
|
def short_name; return L__M(:Miscellany, 18); end
|
|
522
522
|
def description; return L__M(:Miscellany, 19); end
|
|
@@ -4980,203 +4980,9 @@ class NoVerbRoutine < StandardError; end
|
|
|
4980
4980
|
|
|
4981
4981
|
class CycleError < StandardError; end
|
|
4982
4982
|
|
|
4983
|
-
# The Inform module
|
|
4984
|
-
module Inform
|
|
4985
|
-
# The Rules module defines functional additions to the Session state
|
|
4986
|
-
# machine. The additional functionality supports user interface patterns
|
|
4987
|
-
# commonly found in interactive fiction games, specifically those created
|
|
4988
|
-
# using Inform. Supporting the principle of least surprise mandates that
|
|
4989
|
-
# the expectations held by the users of such games should be satisfied.
|
|
4990
|
-
# TODO: Perhaps this should go in the mudlib
|
|
4991
|
-
module Rules
|
|
4992
|
-
def ask(s = nil)
|
|
4993
|
-
println s if s.is_a?(String)
|
|
4994
|
-
if session
|
|
4995
|
-
@previous ||= session.state
|
|
4996
|
-
session.state = :asked
|
|
4997
|
-
end
|
|
4998
|
-
# true
|
|
4999
|
-
session.state
|
|
5000
|
-
end
|
|
5001
|
-
|
|
5002
|
-
def yesorno(s = nil)
|
|
5003
|
-
print s.to_s unless s.nil?
|
|
5004
|
-
unless session.nil?
|
|
5005
|
-
@previous ||= session.state
|
|
5006
|
-
session.state = :asked
|
|
5007
|
-
end
|
|
5008
|
-
session&.state || false
|
|
5009
|
-
end
|
|
5010
|
-
|
|
5011
|
-
def asked
|
|
5012
|
-
yesorno?
|
|
5013
|
-
end
|
|
5014
|
-
|
|
5015
|
-
def yesorno?
|
|
5016
|
-
reset_io # TODO: Remove this. Why is the buffer getting a newline character added to it?
|
|
5017
|
-
case @buffer.split.first
|
|
5018
|
-
when /^(y|yes)$/i
|
|
5019
|
-
println(resume)
|
|
5020
|
-
responded
|
|
5021
|
-
when /^(n|no)$/i
|
|
5022
|
-
prompt
|
|
5023
|
-
responded
|
|
5024
|
-
else
|
|
5025
|
-
L__M(:Quit, 1); print "> "
|
|
5026
|
-
session&.state
|
|
5027
|
-
end
|
|
5028
|
-
end
|
|
5029
|
-
|
|
5030
|
-
def disambiguate
|
|
5031
|
-
session.state = :disambiguating unless session.nil?
|
|
5032
|
-
false
|
|
5033
|
-
end
|
|
5034
|
-
|
|
5035
|
-
def disambiguating
|
|
5036
|
-
WhichOne() if @ambiguity
|
|
5037
|
-
session.state = :playing unless session.nil?
|
|
5038
|
-
end
|
|
5039
|
-
|
|
5040
|
-
def complete
|
|
5041
|
-
session.state = :completing unless session.nil?
|
|
5042
|
-
false
|
|
5043
|
-
end
|
|
5044
|
-
|
|
5045
|
-
def completing
|
|
5046
|
-
Incomplete() if @ambiguity
|
|
5047
|
-
session.state = :playing unless session.nil?
|
|
5048
|
-
end
|
|
5049
|
-
|
|
5050
|
-
SolicitedStates = %i[asked yesorno? solicited].freeze
|
|
5051
|
-
def solicit(s = nil)
|
|
5052
|
-
if !session.nil? && !SolicitedStates.include?(session.state)
|
|
5053
|
-
prompt s if s.is_a?(String)
|
|
5054
|
-
@previous ||= session.state
|
|
5055
|
-
end
|
|
5056
|
-
session.state = :solicited unless session.nil?
|
|
5057
|
-
end
|
|
5058
|
-
|
|
5059
|
-
def disambiguated
|
|
5060
|
-
session.state = :playing unless session.nil?
|
|
5061
|
-
queue @input
|
|
5062
|
-
end
|
|
5063
|
-
|
|
5064
|
-
def completed
|
|
5065
|
-
session.state = :playing unless session.nil?
|
|
5066
|
-
queue @input
|
|
5067
|
-
end
|
|
5068
|
-
|
|
5069
|
-
def solicited
|
|
5070
|
-
responded? @input
|
|
5071
|
-
end
|
|
5072
|
-
|
|
5073
|
-
def responded
|
|
5074
|
-
session&.state = previous_state = @previous
|
|
5075
|
-
@previous = nil
|
|
5076
|
-
session&.state || previous_state
|
|
5077
|
-
end
|
|
5078
|
-
|
|
5079
|
-
def asked?
|
|
5080
|
-
session&.state == :asked
|
|
5081
|
-
end
|
|
5082
|
-
|
|
5083
|
-
def disambiguating?
|
|
5084
|
-
session&.state == :disambiguating
|
|
5085
|
-
end
|
|
5086
|
-
|
|
5087
|
-
def completing?
|
|
5088
|
-
session&.state == :completing
|
|
5089
|
-
end
|
|
5090
|
-
|
|
5091
|
-
def solicited?
|
|
5092
|
-
session&.state == :solicited
|
|
5093
|
-
end
|
|
5094
|
-
|
|
5095
|
-
def responded?(_s)
|
|
5096
|
-
reset_io # TODO: Remove this. Why is the buffer getting a newline character added to it?
|
|
5097
|
-
if @buffer.empty?
|
|
5098
|
-
prompt
|
|
5099
|
-
else
|
|
5100
|
-
responded
|
|
5101
|
-
@consult_words = @input = @buffer.dup
|
|
5102
|
-
result = resume
|
|
5103
|
-
println(result)
|
|
5104
|
-
if result == :playing
|
|
5105
|
-
reset_prompt
|
|
5106
|
-
prompt
|
|
5107
|
-
end
|
|
5108
|
-
end
|
|
5109
|
-
session&.state
|
|
5110
|
-
end
|
|
5111
|
-
|
|
5112
|
-
More = Struct.new(:text, :page_index)
|
|
5113
|
-
|
|
5114
|
-
DefaultMoreParameters = {
|
|
5115
|
-
page_index: 0, limit: 10, help: nil, done: :playing
|
|
5116
|
-
}.freeze
|
|
5117
|
-
|
|
5118
|
-
# This method supports the MoreSub verb implementation.
|
|
5119
|
-
def more(text = nil, params = {})
|
|
5120
|
-
params = DefaultMoreParameters.merge(params)
|
|
5121
|
-
unless session
|
|
5122
|
-
println text
|
|
5123
|
-
return params[:done]
|
|
5124
|
-
end
|
|
5125
|
-
input = @buffer.dup
|
|
5126
|
-
@more ||= More.new([], params[:page_index])
|
|
5127
|
-
|
|
5128
|
-
if text
|
|
5129
|
-
@more.text = text
|
|
5130
|
-
else
|
|
5131
|
-
text = @more.text
|
|
5132
|
-
end
|
|
5133
|
-
|
|
5134
|
-
case input
|
|
5135
|
-
when /\?/
|
|
5136
|
-
println params[:help] || "<Help for More goes here>"
|
|
5137
|
-
when /^(q|quit)$/
|
|
5138
|
-
@more = nil
|
|
5139
|
-
@prompt = nil
|
|
5140
|
-
prompt
|
|
5141
|
-
return session.state = params[:done]
|
|
5142
|
-
else
|
|
5143
|
-
text = @more.text.split('\n') if @more.text.is_a? String
|
|
5144
|
-
unless text.is_a?(Array)
|
|
5145
|
-
println "[Error: Format problem using the more command -- cannot handle given text.]"
|
|
5146
|
-
return session.state = params[:done]
|
|
5147
|
-
end
|
|
5148
|
-
|
|
5149
|
-
println text[@more.page_index, params[:limit]].join("\n")
|
|
5150
|
-
|
|
5151
|
-
@more.page_index += params[:limit]
|
|
5152
|
-
end
|
|
5153
|
-
|
|
5154
|
-
percent_complete = [100, (100 * (@more.page_index.to_f / text.length)).floor].min
|
|
5155
|
-
@more = nil unless @more.page_index < @more.text.length
|
|
5156
|
-
|
|
5157
|
-
new_line
|
|
5158
|
-
print "--More--(#{percent_complete}%)"
|
|
5159
|
-
|
|
5160
|
-
if percent_complete < 100
|
|
5161
|
-
prompt " [?]: "
|
|
5162
|
-
session.state = :more
|
|
5163
|
-
else
|
|
5164
|
-
new_line
|
|
5165
|
-
prompt nil
|
|
5166
|
-
session.state = params[:done]
|
|
5167
|
-
end
|
|
5168
|
-
end
|
|
5169
|
-
# def more
|
|
5170
|
-
end
|
|
5171
|
-
# module Rules
|
|
5172
|
-
end
|
|
5173
|
-
# module Inform
|
|
5174
|
-
|
|
5175
4983
|
# The InformLibrary class.
|
|
5176
4984
|
# Inform 6 defines this as an Object.
|
|
5177
4985
|
class InformLibrary < Inform::Ephemeral::Object
|
|
5178
|
-
REGISTRY = Struct.new(:memo).new(defined?(Java) ? java.util.concurrent.ConcurrentHashMap.new : {})
|
|
5179
|
-
include Inform::Rules
|
|
5180
4986
|
include Inform::Parser
|
|
5181
4987
|
|
|
5182
4988
|
attr_accessor :player
|
data/lib/inform/verblibm.h.rb
CHANGED
|
@@ -101,7 +101,7 @@ module Verbs
|
|
|
101
101
|
|
|
102
102
|
def RunTimeError(n, p1 = nil, p2 = nil)
|
|
103
103
|
if defined? DEBUG
|
|
104
|
-
print "** Library error #{n} (p1
|
|
104
|
+
print "** Library error #{n} (#{p1},#{p2}) **\n** "
|
|
105
105
|
case n
|
|
106
106
|
when 1 then print "preposition not found (this should not occur)"
|
|
107
107
|
when 2 then print "Property value not routine or string: \"#{p2}\" of \"#{p1}\"" +
|
|
@@ -1927,7 +1927,6 @@ module Verbs
|
|
|
1927
1927
|
end
|
|
1928
1928
|
|
|
1929
1929
|
L__M(:Look, 3, @player) if @print_player_flag
|
|
1930
|
-
L__M(:Look, 9, @player) if @player.respond_to?(:builder?) && @player.builder?
|
|
1931
1930
|
new_line
|
|
1932
1931
|
|
|
1933
1932
|
# TODO: FIXME
|
|
@@ -2399,7 +2398,6 @@ module Verbs
|
|
|
2399
2398
|
end
|
|
2400
2399
|
|
|
2401
2400
|
def XTreeSub
|
|
2402
|
-
raise Parser::VerbUnrecognized unless @player.builder?
|
|
2403
2401
|
return XObj(noun, 1) unless noun.nil?
|
|
2404
2402
|
objectloop { |i|
|
|
2405
2403
|
XObj(i) if i.object? && parent(i).nil?
|
|
@@ -2407,7 +2405,6 @@ module Verbs
|
|
|
2407
2405
|
end
|
|
2408
2406
|
|
|
2409
2407
|
def GotoSub
|
|
2410
|
-
raise Parser::VerbUnrecognized unless @player.builder?
|
|
2411
2408
|
log.debug "<Goto noun> #=> #{noun}"
|
|
2412
2409
|
if !noun.is_a?(Inform::Object)
|
|
2413
2410
|
"[Not a safe place.]"
|
|
@@ -2419,7 +2416,6 @@ module Verbs
|
|
|
2419
2416
|
end
|
|
2420
2417
|
|
|
2421
2418
|
def GonearSub
|
|
2422
|
-
raise Parser::VerbUnrecognized unless @player.builder?
|
|
2423
2419
|
x = noun
|
|
2424
2420
|
loop do
|
|
2425
2421
|
break if parent(x).nil?
|
|
@@ -2431,7 +2427,6 @@ module Verbs
|
|
|
2431
2427
|
def Print_ScL(obj); println (@x_scope_count += 1) + ": " + a(obj) + " (" + obj.id + ")"; end
|
|
2432
2428
|
|
|
2433
2429
|
def ScopeSub
|
|
2434
|
-
raise Parser::VerbUnrecognized unless @player.admin?
|
|
2435
2430
|
@x_scope_count = 0
|
|
2436
2431
|
LoopOverScope(method(:Print_ScL), noun)
|
|
2437
2432
|
"Nothing is in scope." if @x_scope_count == 0
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: inform6lib
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nels Nelson
|
|
@@ -50,7 +50,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
50
50
|
- !ruby/object:Gem::Version
|
|
51
51
|
version: '0'
|
|
52
52
|
requirements: []
|
|
53
|
-
rubygems_version:
|
|
53
|
+
rubygems_version: 4.0.11
|
|
54
54
|
specification_version: 4
|
|
55
55
|
summary: The Inform6 Library Ruby Port is a faithful port of the Inform6 interactive
|
|
56
56
|
fiction standard library in Ruby.
|