inform6lib 0.1.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9f1deb9cf509ad1583e444225fae2d0e94aeee6a150844e83b39818ffae1792
4
- data.tar.gz: cf1bf259e26d5496ed8bd6d1e2daeeebdc8df95915e61d66a90a6646def02c68
3
+ metadata.gz: eb96a12c00fe171072a37b734b09ace326c78f5c2b7e5f64a8a288d0c44d5c3c
4
+ data.tar.gz: 18602dac5e23311f3b3f314c9c3f4a3fcc4599d2ed6c6047ff48957d6399f5a7
5
5
  SHA512:
6
- metadata.gz: 32ee527e72c9648a864e2f4f0d06a750d92e8835c3954118d7a5283c636ec7e701ac81d13768f04c602753fb12cc27d2df0f4980f98a0e0abb1ea17b4eb6ff70
7
- data.tar.gz: 615afb3f2854063b9964289e720290124c9196bd692c5b576de3cd8542ce7c501117407106426d895a5efbea48de49647f62d42f302bec7a372fd37225900499
6
+ metadata.gz: 66f4af9e13875301a235819e59da8d7597408c350d35f5c9a5858445d154d9bf02c0d3636bfc9620b4e767f5cff215dd9e0546bfad683a18dbe8435f1897e9cf
7
+ data.tar.gz: c0c89127eaf9083c65becbfb55580322ac2d74a7dfa192745e52a8528fdbd0c19dc6b8407182583161f525ec1fdb02b166933a34f54b95e4ad7a2bc8e338d326
data/Rakefile CHANGED
@@ -47,7 +47,7 @@ task :verify do
47
47
  system('bundle', 'exec', 'rspec', 'spec/verify_gem_spec.rb') or abort
48
48
  system('bundle', 'exec', 'rake', 'clean')
49
49
  end
50
- task verify: :explode
50
+ task verify: %i[package explode]
51
51
 
52
52
  desc 'Host dev gem'
53
53
  task :devhost do
@@ -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
@@ -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,p2) **\n** "
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}\"" +
@@ -1359,7 +1359,6 @@ module Verbs
1359
1359
 
1360
1360
  # Transfer the item.
1361
1361
 
1362
- @player.publish L__M(:Take, 15, noun)
1363
1362
  move item, @player
1364
1363
 
1365
1364
  # Send "after" message to the object letting go of the item, if any.
@@ -1413,7 +1412,6 @@ module Verbs
1413
1412
  move noun, @player.parent
1414
1413
  return true if AfterRoutines()
1415
1414
  return true if @keep_silent
1416
- @player.publish L__M(:Drop, 5, noun)
1417
1415
  return L__M(:Drop, 4, noun)
1418
1416
  end
1419
1417
 
@@ -1453,7 +1451,6 @@ module Verbs
1453
1451
  @action = :PutOn
1454
1452
  end
1455
1453
  return if @keep_silent
1456
- @player.publish L__M(:PutOn, 9, noun)
1457
1454
  return L__M(:PutOn, 7) if @multiflag
1458
1455
  L__M(:PutOn, 8, noun)
1459
1456
  end
@@ -1496,7 +1493,6 @@ module Verbs
1496
1493
  @action = :Insert
1497
1494
  end
1498
1495
  return true if @keep_silent
1499
- @player.publish L__M(:Insert, 10, noun)
1500
1496
  return L__M(:Insert, 8, noun) if @multiflag
1501
1497
  L__M(:Insert, 9, noun)
1502
1498
  end
@@ -1556,7 +1552,6 @@ module Verbs
1556
1552
  def GiveSub
1557
1553
  return L__M(:Give, 1, noun) if parent(noun) != @player
1558
1554
  if second == @player
1559
- @player.publish A(player) + " juggles " + a(noun) + " for a second or two."
1560
1555
  return L__M(:Give, 2, noun)
1561
1556
  end
1562
1557
  return false if RunLife(second, :Give)
@@ -1619,7 +1614,6 @@ module Verbs
1619
1614
  return true if AfterRoutines()
1620
1615
  return true if @keep_silent
1621
1616
  Locale(noun)
1622
- @player.publish L__M(:Enter, 8, noun)
1623
1617
  L__M(:Enter, 5, noun)
1624
1618
  end
1625
1619
 
@@ -1644,7 +1638,6 @@ module Verbs
1644
1638
 
1645
1639
  return true if AfterRoutines()
1646
1640
  return true if @keep_silent
1647
- @player.publish L__M(:Exit, 5, parent_obj)
1648
1641
  L__M(:Exit, 3, parent_obj)
1649
1642
  LookSub(true)
1650
1643
  end
@@ -1704,7 +1697,6 @@ module Verbs
1704
1697
  end
1705
1698
 
1706
1699
  orig_loc = @real_location
1707
- @player.publish L__M(:Go, 7, noun) unless @keep_silent
1708
1700
 
1709
1701
  if movewith.nil? then move @player, j else move movewith, j end
1710
1702
 
@@ -1729,8 +1721,6 @@ module Verbs
1729
1721
  @location = thedark; @lightflag = false
1730
1722
  end
1731
1723
 
1732
- @player.publish L__M(:Go, 8, ArrivalDir(j, orig_loc)) unless @keep_silent
1733
-
1734
1724
  return true if AfterRoutines()
1735
1725
  return true if @keep_silent
1736
1726
  LookSub(true)
@@ -1937,7 +1927,6 @@ module Verbs
1937
1927
  end
1938
1928
 
1939
1929
  L__M(:Look, 3, @player) if @print_player_flag
1940
- L__M(:Look, 9, @player) if @player.respond_to?(:builder?) && @player.builder?
1941
1930
  new_line
1942
1931
 
1943
1932
  # TODO: FIXME
@@ -2012,17 +2001,6 @@ module Verbs
2012
2001
  unless @keep_silent
2013
2002
  if noun.has? :animate
2014
2003
  @action = :LookAt
2015
- if noun.in?(@player)
2016
- @player.publish A(@player) + " looks at " + hisorher(@player, noun) + "."
2017
- elsif noun != @player
2018
- @player.publish A(@player) + " looks over at " + a(noun) + "."
2019
- end
2020
- else
2021
- if noun.in?(@player)
2022
- @player.publish A(@player) + " examines " + hisorher(@player, noun) + "."
2023
- else
2024
- @player.publish A(@player) + " examines " + a(noun) + "."
2025
- end
2026
2004
  end
2027
2005
  end
2028
2006
  i = noun.description
@@ -2039,7 +2017,6 @@ module Verbs
2039
2017
 
2040
2018
  def LookUnderSub
2041
2019
  return L__M(:LookUnder, 1) if @location == thedark
2042
- @player.publish L__M(:LookUnder, 3, noun)
2043
2020
  L__M(:LookUnder, 2)
2044
2021
  end
2045
2022
 
@@ -2052,7 +2029,6 @@ module Verbs
2052
2029
  return if ObjectIsUntouchable(noun)
2053
2030
  f = VisibleContents(noun)
2054
2031
  if noun.has? :supporter
2055
- @player.publish L__M(:Search, 8, noun) unless @keep_silent
2056
2032
  return L__M(:Search, 2, noun) if f == 0
2057
2033
  return L__M(:Search, 3, noun)
2058
2034
  end
@@ -2060,7 +2036,6 @@ module Verbs
2060
2036
  return L__M(:Search, 5, noun) if noun.hasnt?(:transparent) && noun.hasnt?(:open)
2061
2037
  return true if AfterRoutines()
2062
2038
 
2063
- @player.publish L__M(:Search, 8, noun) unless @keep_silent
2064
2039
  return L__M(:Search, 6, noun) if f == 0
2065
2040
  L__M(:Search, 7, noun)
2066
2041
  end
@@ -2077,7 +2052,6 @@ module Verbs
2077
2052
  take noun, :locked
2078
2053
  return true if AfterRoutines()
2079
2054
  return true if @keep_silent
2080
- @player.publish L__M(:Unlock, 5, noun)
2081
2055
  L__M(:Unlock, 4, noun)
2082
2056
  end
2083
2057
 
@@ -2090,7 +2064,6 @@ module Verbs
2090
2064
  give noun, :locked
2091
2065
  return true if AfterRoutines()
2092
2066
  return true if @keep_silent
2093
- @player.publish L__M(:Lock, 6, noun)
2094
2067
  L__M(:Lock, 5, noun)
2095
2068
  end
2096
2069
 
@@ -2101,7 +2074,6 @@ module Verbs
2101
2074
  give noun, :on
2102
2075
  return true if AfterRoutines()
2103
2076
  return true if @keep_silent
2104
- @player.publish L__M(:SwitchOn, 4, noun)
2105
2077
  L__M(:SwitchOn, 3, noun)
2106
2078
  end
2107
2079
 
@@ -2112,7 +2084,6 @@ module Verbs
2112
2084
  take noun, :on
2113
2085
  return true if AfterRoutines()
2114
2086
  return true if @keep_silent
2115
- @player.publish L__M(:SwitchOff, 4, noun)
2116
2087
  L__M(:SwitchOff, 3, noun)
2117
2088
  end
2118
2089
 
@@ -2124,7 +2095,6 @@ module Verbs
2124
2095
  give noun, :open
2125
2096
  return true if AfterRoutines()
2126
2097
  return true if @keep_silent
2127
- @player.publish L__M(:Open, 6, noun)
2128
2098
  if noun.has?(:container) && noun.hasnt?(:transparent) &&
2129
2099
  @location != thedark &&
2130
2100
  VisibleContents(noun) != 0 && IndirectlyContains(noun, @player)
@@ -2140,7 +2110,6 @@ module Verbs
2140
2110
  take noun, :open
2141
2111
  return true if AfterRoutines()
2142
2112
  return true if @keep_silent
2143
- @player.publish L__M(:Close, 4, noun)
2144
2113
  L__M(:Close, 3, noun)
2145
2114
  end
2146
2115
 
@@ -2150,7 +2119,6 @@ module Verbs
2150
2119
  take noun, :worn
2151
2120
  return true if AfterRoutines()
2152
2121
  return true if @keep_silent
2153
- @player.publish L__M(:Disrobe, 3, noun)
2154
2122
  L__M(:Disrobe, 2, noun)
2155
2123
  end
2156
2124
 
@@ -2162,7 +2130,6 @@ module Verbs
2162
2130
  give noun, :worn
2163
2131
  return true if AfterRoutines()
2164
2132
  return true if @keep_silent
2165
- @player.publish L__M(:Wear, 5, noun)
2166
2133
  L__M(:Wear, 4, noun)
2167
2134
  end
2168
2135
 
@@ -2177,7 +2144,6 @@ module Verbs
2177
2144
  noun.destroy
2178
2145
  return true if AfterRoutines()
2179
2146
  return true if @keep_silent
2180
- @player.publish L__M(:Eat, 3, noun)
2181
2147
  L__M(:Eat, 2, noun)
2182
2148
  end
2183
2149
 
@@ -2285,19 +2251,19 @@ module Verbs
2285
2251
  L__M(:PushDir, 1, noun)
2286
2252
  end
2287
2253
 
2288
- def RubSub; @player.publish L__M(:Rub, 2, noun); L__M(:Rub, 1, noun); end
2254
+ def RubSub; L__M(:Rub, 1, noun); end
2289
2255
 
2290
2256
  def SetSub; L__M(:Set, 1, noun); end
2291
2257
 
2292
2258
  def SetToSub; L__M(:SetTo, 1, noun); end
2293
2259
 
2294
- def SingSub; @player.publish L__M(:Sing, 2, noun); L__M(:Sing, 1, noun); end
2260
+ def SingSub; L__M(:Sing, 1, noun); end
2295
2261
 
2296
- def SleepSub; @player.publish L__M(:Sleep, 2, noun); L__M(:Sleep, 1, noun); end
2262
+ def SleepSub; L__M(:Sleep, 1, noun); end
2297
2263
 
2298
- def SmellSub; @player.publish L__M(:Smell, 2, noun); L__M(:Smell, 1, noun); end
2264
+ def SmellSub; L__M(:Smell, 1, noun); end
2299
2265
 
2300
- def SorrySub; @player.publish L__M(:Sorry, 2, noun); L__M(:Sorry, 1, noun); end
2266
+ def SorrySub; L__M(:Sorry, 1, noun); end
2301
2267
 
2302
2268
  def SqueezeSub
2303
2269
  return if ObjectIsUntouchable(noun)
@@ -2321,7 +2287,6 @@ module Verbs
2321
2287
  end
2322
2288
 
2323
2289
  def ThinkSub
2324
- @player.publish L__M(:Think, 2, noun)
2325
2290
  L__M(:Think, 1, noun)
2326
2291
  end
2327
2292
 
@@ -2350,7 +2315,6 @@ module Verbs
2350
2315
  return L__M(:Touch, 3, noun) if noun == @player
2351
2316
  return if ObjectIsUntouchable(noun)
2352
2317
  return L__M(:Touch, 1, noun) if noun.has? :animate
2353
- @player.publish L__M(:Touch,4,noun)
2354
2318
  L__M(:Touch,2,noun)
2355
2319
  end
2356
2320
 
@@ -2363,7 +2327,6 @@ module Verbs
2363
2327
  end
2364
2328
 
2365
2329
  def WaitSub
2366
- @player.publish L__M(:Wait, 2, noun)
2367
2330
  return true if AfterRoutines()
2368
2331
  L__M(:Wait, 1, noun)
2369
2332
  end
@@ -2378,16 +2341,13 @@ module Verbs
2378
2341
 
2379
2342
  def WaveSub
2380
2343
  return L__M(:Wave, 1, noun) if !noun.nil? && (noun.has?(:clothing, :worn) || noun.notin?(@player))
2381
- @player.publish L__M(:Wave, 3, noun)
2382
2344
  L__M(:Wave, 2, noun)
2383
2345
  end
2384
2346
 
2385
2347
  def WaveHandsSub
2386
2348
  if noun
2387
- @player.publish L__M(:WaveHands, 4, noun)
2388
2349
  L__M(:WaveHands, 3, noun)
2389
2350
  else
2390
- @player.publish L__M(:WaveHands, 2, noun)
2391
2351
  L__M(:WaveHands, 1, noun)
2392
2352
  end
2393
2353
  end
@@ -2438,7 +2398,6 @@ module Verbs
2438
2398
  end
2439
2399
 
2440
2400
  def XTreeSub
2441
- raise Parser::VerbUnrecognized unless @player.builder?
2442
2401
  return XObj(noun, 1) unless noun.nil?
2443
2402
  objectloop { |i|
2444
2403
  XObj(i) if i.object? && parent(i).nil?
@@ -2446,7 +2405,6 @@ module Verbs
2446
2405
  end
2447
2406
 
2448
2407
  def GotoSub
2449
- raise Parser::VerbUnrecognized unless @player.builder?
2450
2408
  log.debug "<Goto noun> #=> #{noun}"
2451
2409
  if !noun.is_a?(Inform::Object)
2452
2410
  "[Not a safe place.]"
@@ -2458,7 +2416,6 @@ module Verbs
2458
2416
  end
2459
2417
 
2460
2418
  def GonearSub
2461
- raise Parser::VerbUnrecognized unless @player.builder?
2462
2419
  x = noun
2463
2420
  loop do
2464
2421
  break if parent(x).nil?
@@ -2470,7 +2427,6 @@ module Verbs
2470
2427
  def Print_ScL(obj); println (@x_scope_count += 1) + ": " + a(obj) + " (" + obj.id + ")"; end
2471
2428
 
2472
2429
  def ScopeSub
2473
- raise Parser::VerbUnrecognized unless @player.admin?
2474
2430
  @x_scope_count = 0
2475
2431
  LoopOverScope(method(:Print_ScL), noun)
2476
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.0
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: 3.7.2
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.