Class: InformLibrary
Overview
The InformLibrary class. Inform 6 defines this as an Object.
Constant Summary
collapse
- REGISTRY =
Struct.new(:memo).new(defined?(Java) ? java.util.concurrent.ConcurrentHashMap.new : {})
Inform::Parser::ANIMA_PE, Inform::Parser::ASKSCOPE_PE, Inform::Parser::CANTSEE_PE, Inform::Parser::CommaWordPattern, Inform::Parser::ConversationStarterPattern, Inform::Parser::DEFART_PK, Inform::Parser::Darkness, Inform::Parser::DidScopeAction, Inform::Parser::EACH_TURN_REASON, Inform::Parser::EXCEPT_PE, Inform::Parser::ElementaryTokens, Inform::Parser::GPR_CREATURE, Inform::Parser::GPR_FAIL, Inform::Parser::GPR_HELD, Inform::Parser::GPR_MULTI, Inform::Parser::GPR_MULTIEXCEPT, Inform::Parser::GPR_MULTIHELD, Inform::Parser::GPR_MULTIINSIDE, Inform::Parser::GPR_MULTIPLE, Inform::Parser::GPR_NOUN, Inform::Parser::GPR_NUMBER, Inform::Parser::GPR_PREPOSITION, Inform::Parser::GPR_REPARSE, Inform::Parser::GPR_TEXT, Inform::Parser::INDEFART_PK, Inform::Parser::ITGONE_PE, Inform::Parser::InitalState, Inform::Parser::JUNKAFTER_PE, Inform::Parser::KnownNumberProperties, Inform::Parser::LIT_BIT, Inform::Parser::LOOPOVERSCOPE_REASON, Inform::Parser::LanguageCases, Inform::Parser::MATCH_LIST_SIZE, Inform::Parser::MAX_TIMERS, Inform::Parser::MMULTI_PE, Inform::Parser::MULTI_PE, Inform::Parser::MY_BIT, Inform::Parser::MethodWriterPattern, Inform::Parser::NOTHELD_PE, Inform::Parser::NOTHING_PE, Inform::Parser::NUMBER_PE, Inform::Parser::OTHER_BIT, Inform::Parser::PARSING_REASON, Inform::Parser::PLURAL_BIT, Inform::Parser::POSSESS_PK, Inform::Parser::PowersOfTwo_TB, Inform::Parser::PrefaceByArticle_COUNTER, Inform::Parser::REACT_AFTER_REASON, Inform::Parser::REACT_BEFORE_REASON, Inform::Parser::REPARSE_CODE, Inform::Parser::SCENERY_PE, Inform::Parser::SCORE__BESTLOC, Inform::Parser::SCORE__CHOOSEOBJ, Inform::Parser::SCORE__DIVISOR, Inform::Parser::SCORE__GNA, Inform::Parser::SCORE__IFGOOD, Inform::Parser::SCORE__NEXTBESTLOC, Inform::Parser::SCORE__NOTACTOR, Inform::Parser::SCORE__NOTCOMPASS, Inform::Parser::SCORE__NOTSCENERY, Inform::Parser::SCORE__UNCONCEALED, Inform::Parser::START_MOVE, Inform::Parser::STUCK_PE, Inform::Parser::SelfObj, Inform::Parser::StorageForShortName, Inform::Parser::TALKING_REASON, Inform::Parser::TESTSCOPE_REASON, Inform::Parser::THAT_BIT, Inform::Parser::TOOFEW_PE, Inform::Parser::TOOLIT_PE, Inform::Parser::UNLIT_BIT, Inform::Parser::UPTO_PE, Inform::Parser::VAGUE_PE, Inform::Parser::VERB_PE
Inform::Verbs::LibraryMessages, Inform::Verbs::MAKE__TS, Inform::Verbs::TASK_DONE, Inform::Verbs::TASK_SCORES
Inform::English::AGAIN1__WD, Inform::English::AGAIN2__WD, Inform::English::AGAIN3__WD, Inform::English::ALL1__WD, Inform::English::ALL2__WD, Inform::English::ALL3__WD, Inform::English::ALL4__WD, Inform::English::ALL5__WD, Inform::English::AMBIGUOUS, Inform::English::AMUSING__WD, Inform::English::AND1__WD, Inform::English::AND2__WD, Inform::English::AND3__WD, Inform::English::AND__TX, Inform::English::ANIMATE_EXPECTED, Inform::English::ARE2__TX, Inform::English::ARE__TX, Inform::English::BUT1__WD, Inform::English::BUT2__WD, Inform::English::BUT3__WD, Inform::English::CANNOT_UNDERSTAND, Inform::English::CANTGO__TX, Inform::English::CANT_SEE, Inform::English::CANT_TALK, Inform::English::COMMA__TX, Inform::English::Compass, Inform::English::DARKNESS__TX, Inform::English::DEFART_PK, Inform::English::ENGLISH_DIALECT, Inform::English::EXCEPTED_UNECESSARILY, Inform::English::FORMER__TX, Inform::English::FULLSCORE1__WD, Inform::English::FULLSCORE2__WD, Inform::English::INDEFART_PK, Inform::English::IS2__TX, Inform::English::IS__TX, Inform::English::LISTAND2__TX, Inform::English::LISTAND__TX, Inform::English::LanguageAnimateGender, Inform::English::LanguageArticles, Inform::English::LanguageContractionForms, Inform::English::LanguageDescriptors, Inform::English::LanguageGNAsToArticles, Inform::English::LanguageInanimateGender, Inform::English::LanguageNumbers, Inform::English::LanguagePronouns, Inform::English::MANUAL_PRONOUNS, Inform::English::ME1__WD, Inform::English::ME2__WD, Inform::English::ME3__WD, Inform::English::MOVES__TX, Inform::English::NKEY1__KY, Inform::English::NKEY2__KY, Inform::English::NKEY__TX, Inform::English::NO1__WD, Inform::English::NO2__WD, Inform::English::NO3__WD, Inform::English::NONSENSE, Inform::English::NOTHING, Inform::English::NOTHING_TO_REPEAT, Inform::English::NOTHING__TX, Inform::English::NOT_HELD, Inform::English::NO_MULTIPLES, Inform::English::NO_OBJECT, Inform::English::NUMBER_UNRECOGNIZED, Inform::English::NumbersLanguage, Inform::English::OF1__WD, Inform::English::OF2__WD, Inform::English::OF3__WD, Inform::English::OF4__WD, Inform::English::OOPS1__WD, Inform::English::OOPS2__WD, Inform::English::OOPS3__WD, Inform::English::OR__TX, Inform::English::OTHER1__WD, Inform::English::OTHER2__WD, Inform::English::OTHER3__WD, Inform::English::PARTIALLY_UNDERSTOOD, Inform::English::PKEY1__KY, Inform::English::PKEY2__KY, Inform::English::PKEY__TX, Inform::English::POSSESS_PK, Inform::English::Prepositions, Inform::English::QKEY1__KY, Inform::English::QKEY1__TX, Inform::English::QKEY2__KY, Inform::English::QKEY2__TX, Inform::English::QUIT1__WD, Inform::English::QUIT2__WD, Inform::English::REPEATED_ORDER, Inform::English::RESTART__WD, Inform::English::RESTORE__WD, Inform::English::RKEY__TX, Inform::English::SCENERY_IS_IRRELEVANT, Inform::English::SCORE__TX, Inform::English::SPEECH_THERAPY, Inform::English::THAT__TX, Inform::English::THEN1__WD, Inform::English::THEN2__WD, Inform::English::THEN3__WD, Inform::English::THOSET__TX, Inform::English::TIME__TX, Inform::English::TOOFEW, Inform::English::TOOLITTLE, Inform::English::TOOMANY, Inform::English::TREE_ERROR, Inform::English::UNDO1__WD, Inform::English::UNDO2__WD, Inform::English::UNDO3__WD, Inform::English::UNEXPECTED_COMMA, Inform::English::UNRECOGNIZED, Inform::English::VAGUE, Inform::English::WHICH__TX, Inform::English::WHOM__TX, Inform::English::YES1__WD, Inform::English::YES2__WD, Inform::English::YES3__WD, Inform::English::YOU2__TX, Inform::English::YOUR2__TX, Inform::English::YOURSELF__TX, Inform::English::YOUR__TX, Inform::English::YOU__TX
Inform::Rules::DefaultMoreParameters, Inform::Rules::SolicitedStates
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#ActionPrimitive(a = @action) ⇒ Object
-
#AdvanceWorldClock ⇒ Object
-
#AfterGameOver ⇒ Object
(also: #RRQL)
-
#AfterRoutines ⇒ Object
-
#BeforeRoutines(_a = @action) ⇒ Object
-
#begin_action(a, n, s, source) ⇒ Object
-
#end_turn_sequence ⇒ Object
-
#inflib ⇒ Object
-
#inform(text) ⇒ Object
-
#Initialise ⇒ Object
-
#initialize ⇒ InformLibrary
constructor
A new instance of InformLibrary.
-
#LoopOverScope(routine, act) ⇒ Object
-
#NoteObjectAcquisitions ⇒ Object
-
#OBIT_HEAD ⇒ Object
-
#parse(s) ⇒ Object
-
#parse_input ⇒ Object
-
#play ⇒ Object
-
#playing ⇒ Object
-
#PrintOrRun(obj, prop, flag = 0) ⇒ Object
-
#PrintOrRunVar(var, flag) ⇒ Object
-
#R_Process(a, i, j) ⇒ Object
-
#resume ⇒ Object
-
#RRQPL ⇒ Object
-
#RunEachTurnProperties ⇒ Object
-
#RunLife(a, j) ⇒ Object
-
#RunRoutines(obj, prop) ⇒ Object
-
#RunTimersAndDaemons ⇒ Object
-
#state ⇒ Object
-
#state=(state) ⇒ Object
-
#stop ⇒ Object
-
#TestScope(obj, act) ⇒ Object
—————————————————————————-.
-
#ValueOrRun(obj, prop) ⇒ Object
-
#ZRegion(z) ⇒ Object
#AddToScope, #Adjudicate, #AdjustLight, #AnalyseToken, #BestGrammar, #BestGuess, #CDefart, #CInDefArt, #CantSee, #Cap, #Centre, #ChangePlayer, #Conversation, #Conversation2, #CreatureTest, #DebugAction, #DebugAttribute, #DebugGrammarLine, #DebugToken, #Defart, #Descriptors, #DoOops, #DoScopeAction, #DontAccept, #DrawStatusLine, #FailToken, #FreshInput, #GetGNAOfObject, #GetGender, #HasLightSource, #HidesLightSource, #Identical, #Incomplete, #Indefart, #IsSeeThrough, #KeyCharPrimitive, #KeyDelay, #KeyTimerInterrupt, #Keyboard, #KeyboardPrimitive, #LanguageVerb, #LookForMore, #LowerCase, #MakeMatch, #MakeMatchByParseName, #MultiAdd, #MultiFilter, #MultiSub, #NextWord, #NextWordStopped, #NoWordsMatch, #NounDomain, #NounWord, #NumberWord, #OffersLight, #PSN__, #ParseToken, #Parser__parse, #PassToken, #PlaceInScope, #PrefaceByArticle, #PrepositionChain, #PrintCapitalised, #PrintCommand, #PrintVerb, #PronounNotice, #PronounValue, #PronounsSub, #Refers, #ResetDescriptors, #ResetVagueWords, #ReviseMulti, #ScopeCeiling, #ScopeWithin, #ScopeWithin_O, #ScoreMatchL, #ScreenWidth, #SearchScope, #SetPronoun, #ShowVerbSub, #ShowobjSub, #SingleBestGuess, #TraceAction, #TryGivenObject, #TryNumber, #UnpackGrammarLine, #UpperCase, #UserFilter, #VerbAccepted, #WhichOne, #WordAddress, #WordCount, #WordInProperty, #WordLength, initial_state, #initialize_state, #selfobj, #selfobj=, #thedark
#AllowPushDir, #AnswerSub, #ArrivalDir, #AskForSub, #AskSub, #AskToSub, #AttackSub, #AttemptToTakeObject, #Banner, #BlowSub, #BurnSub, #BuySub, #ClimbSub, #CloseSub, #CommonAncestor, #ConsultSub, #CutSub, #DigSub, #DisrobeSub, #DrinkSub, #DropSub, #EatSub, #EconomyVersion, #EmptySub, #EmptyTSub, #EnterSub, #ExamineSub, #ExitSub, #FillSub, #FindVisibilityLevels, #GetOffSub, #GiveRSub, #GiveSub, #GoInSub, #GoSub, #GonearSub, #GotoSub, #IndirectlyContains, #InsertSub, #InvSub, #InvTallSub, #InvWideSub, #JumpOverSub, #JumpSub, #KissSub, #LMode1Sub, #LMode2Sub, #LMode3Sub, #ListEqual, #ListenSub, #Locale, #LockSub, #LookSub, #LookUnderSub, #MildSub, #MoveFloatingObjects, #MovePlayer, #NextEntry, #NoSub, #NotSupportingThePlayer, #NoteArrival, #NotifyOffSub, #NotifyOnSub, #ObjectIsUntouchable, #ObjectScopedBySomething, #ObjectsSub, #OpenSub, #Places1Sub, #PlacesSub, #PlayerTo, #PraySub, #Print_ScL, #Print__Spaces, #PullSub, #PushDirSub, #PushSub, #PutOnSub, #QuitSub, #RMaybe, #RemoveSub, #RestartSub, #RestoreSub, #RubSub, #RunTimeError, #SMaybe, #SaveSub, #SayWhatsOn, #ScopeSub, #ScoreArrival, #SearchSub, #SetSub, #SetToSub, #ShowRSub, #ShowSub, #SingSub, #SleepSub, #SmellSub, #SorrySub, #SortOutList, #SortTogether, #SqueezeSub, #StrongSub, #SwimSub, #SwingSub, #SwitchoffSub, #SwitchonSub, #TakeSub, #TasteSub, #TellSub, #ThinkSub, #ThrowAtSub, #TieSub, #TouchSub, #TransferSub, #TurnSub, #UnlockSub, #VagueGoSub, #VerifySub, #VersionSub, #VisibleContents, #Vmaybe, #Vwrong, #WaitSub, #WakeOtherSub, #WakeSub, #WaveHandsSub, #WaveSub, #WearSub, #WillRecurs, #WriteAfterEntry, #WriteBeforeEntry, #WriteListFrom, #WriteListR, #XAbstractSub, #XObj, #XPurloinSub, #XTestMove, #XTreeSub, #YesOrNo, #YesSub, #task_done, #task_scores
#CThatorThose, #CTheyreorThats, #IsorAre, #ItorThem, #LanguageContraction, #LanguageDirection, #LanguageNumber, #LanguageTimeOfDay, #LanguageToInformese, #LanguageVerb, #LanguageVerbIsDebugging, #LanguageVerbLikesAdverb, #LanguageVerbMayBeName, #ThatorThose, #language_lm, #library_messages
#ask, #asked, #asked?, #complete, #completed, #completing, #completing?, #disambiguate, #disambiguated, #disambiguating, #disambiguating?, #more, #responded, #responded?, #solicit, #solicited, #solicited?, #yesorno, #yesorno?
Constructor Details
Returns a new instance of InformLibrary.
5184
5185
5186
5187
5188
5189
|
# File 'lib/inform/parserm.h.rb', line 5184
def initialize
super('(Inform Library)')
has :proper
initialize_state
self
end
|
Instance Attribute Details
#player ⇒ Object
Returns the value of attribute player.
5182
5183
5184
|
# File 'lib/inform/parserm.h.rb', line 5182
def player
@player
end
|
Instance Method Details
#ActionPrimitive(a = @action) ⇒ Object
5664
5665
5666
|
# File 'lib/inform/parserm.h.rb', line 5664
def ActionPrimitive(a = @action)
indirect(a)
end
|
#AdvanceWorldClock ⇒ Object
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
|
# File 'lib/inform/parserm.h.rb', line 5611
def AdvanceWorldClock
return unless defined? SINGLE_PLAYER
@turns += 1
if !@the_time.nil?
if @time_rate >= 0 then @the_time = @the_time + @time_rate
else
@time_step -= 1
if @time_step == 0
@the_time += 1
@time_step = -@time_rate
end
end
@the_time = @the_time % 1440
end
end
|
#AfterGameOver ⇒ Object
Also known as:
RRQL
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
|
# File 'lib/inform/parserm.h.rb', line 5673
def AfterGameOver
return unless defined? SINGLE_PLAYER
prompt
@temp_global = 0
i = @parse[1]
if [QUIT1__WD, QUIT2__WD].include?(i)
quit
end
if i == RESTART__WD
restart
end
if i == RESTORE__WD
RestoreSub()
return RRQPL()
end
if [FULLSCORE1__WD, FULLSCORE2__WD].include?(i) && TASKS_PROVIDED == 0
new_line; FullScoreSub()
return RRQPL()
end
if @deadflag == 2 && i == AMUSING__WD && AMUSING_PROVIDED == 0
new_line; Amusing()
return RRQPL()
end
L__M(:Miscellany, 8)
return RRQL()
end
|
#AfterRoutines ⇒ Object
5757
5758
5759
5760
5761
5762
5763
5764
|
# File 'lib/inform/parserm.h.rb', line 5757
def AfterRoutines
@scope_reason = scope_reason = REACT_AFTER_REASON; @parser_one = nil
SearchScope(ScopeCeiling(@player), @player, nil, scope_reason); @scope_reason = PARSING_REASON
return true if @parser_one
return true if !@location.nil? && RunRoutines(@location, :after)
return true if @inp1.object? && RunRoutines(@inp1, :after)
return GamePostRoutine()
end
|
#BeforeRoutines(_a = @action) ⇒ Object
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
|
# File 'lib/inform/parserm.h.rb', line 5745
def BeforeRoutines(_a = @action)
return true if GamePreRoutine()
return true if RunRoutines(@player, @orders)
@scope_reason = scope_reason = REACT_BEFORE_REASON; @parser_one = nil
SearchScope(ScopeCeiling(@player), @player, scope_reason)
@scope_reason = PARSING_REASON
return true if @parser_one
return true if !@location.nil? && RunRoutines(@location, :before)
return true if @inp1.object? && RunRoutines(@inp1, :before)
false
end
|
#begin_action(a, n, s, source) ⇒ Object
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
|
# File 'lib/inform/parserm.h.rb', line 5565
def begin_action(a, n, s, source)
sa = @action; sn = @noun; ss = @second
@action = a; @noun = @inp1 = n; @second = @inp2 = s
if defined?(DEBUG)
TraceAction(source, a) if (@debug_flag & 2) != 0
end
@source = 0
if defined?(DEBUG) && @parser_trace >= 10
println "Beginning #{@action}(noun=#{@noun}, second=#{@second})..."
end
contextualize
if (!@verb.nil? && @verb.meta?) || BeforeRoutines(a) == false
rv = ActionPrimitive(a)
end
return rv
ensure
@action = sa; @noun = sn; @second = ss
end
|
#end_turn_sequence ⇒ Object
#inflib ⇒ Object
5193
|
# File 'lib/inform/parserm.h.rb', line 5193
def inflib; self; end
|
5268
5269
5270
5271
5272
5273
5274
|
# File 'lib/inform/parserm.h.rb', line 5268
def inform(text)
@buffer = text
if respond_to?(:session) && !session.nil? && session.valid_state?(self)
return session.update self
end
:playing
end
|
#Initialise ⇒ Object
5191
|
# File 'lib/inform/parserm.h.rb', line 5191
def Initialise; true; end
|
#LoopOverScope(routine, act) ⇒ Object
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
|
# File 'lib/inform/parserm.h.rb', line 5734
def LoopOverScope(routine, act)
p1 = @parser_one; sr = @scope_reason; a = @actor; al = @actors_location
@parser_one = routine;
if act.nil? then @actor = act else @actor = player end
@actors_location = ScopeCeiling(@actor)
@scope_reason = scope_reason = LOOPOVERSCOPE_REASON
SearchScope(@actors_location, @actor, scope_reason)
ensure
@parser_one = p1; @scope_reason = sr; @actor = a; @actors_location = al
end
|
#NoteObjectAcquisitions ⇒ Object
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
|
# File 'lib/inform/parserm.h.rb', line 5707
def NoteObjectAcquisitions
return unless defined? SINGLE_PLAYER
player.objectloop.each do |i|
if i.hasnt?(:moved)
give i, :moved
if i.has?(:scored)
self.score = self.score + OBJECT_SCORE
self.things_score = self.things_score + OBJECT_SCORE
end
end
end
end
|
#OBIT_HEAD ⇒ Object
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
|
# File 'lib/inform/parserm.h.rb', line 5586
def OBIT_HEAD
print "\n\n "
style :bold
color :black_on_white
bgcolor :white
print "***"
L__M(:Miscellany, 3) if deadflag == true
L__M(:Miscellany, 4) if deadflag == 2
if deadflag != false && deadflag != true && deadflag != 2
print " "
DeathMessage()
print " "
end
print "***";
unbgcolor :white
uncolor :black_on_white
unstyle :bold
if defined? NO_SCORE
print "\n\n"
else
print "\n\n\n"
end false
end
|
#parse(s) ⇒ Object
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
|
# File 'lib/inform/parserm.h.rb', line 5280
def parse(s)
@input = s
return L__M(:Miscellany, 10) if @input.empty?
@results = [nil, 0, nil, nil]; @meta = false
2.times do catch :ReParse do
parse_input
return if deadflag && !@meta
end
@action = @results[0]
if @action == :Tell && noun == @player && @actor != @player
@noun = @actor; @actor = @player; @action = :Ask
end
if @action == :Ask || @action == :Tell || @action == :Answer
@special_word = @special_number1
end
@multiflag = false; @onotheld_mode = @notheld_mode; @notheld_mode = false
@inp1 = nil; @inp2 = nil; i = @results[1]
@inp1 = @results[2] if i >= 1
@inp2 = @results[3] if i >= 2
if @inp1 == 1 then @noun = @special_number1 else @noun = @inp1 end
if @inp2 == 1
if @inp1 == 1 then @second = @special_number2
else @second = @special_number1
end
else @second = @inp2
end
if (i == 0) ||
(i == 1 && @inp1 != 0) ||
(i == 2 && @inp1 != 0 && @inp2 != 0) ||
(i == @parameters && @inp1 != 0 && @inp2 != 0)
result = self.begin_action(@action, @noun, @second, 0)
else
@multiflag = true
if @multiple_object.empty?
return L__M(:Miscellany, 2)
end
if @toomany_flag
@toomany_flag = false
print L__M(:Miscellany, 1)
end
i = @location
for l in @multiple_object
return if deadflag
return L__M(:Miscellany, 51) if @location != i
PronounNotice(l)
@second = @results[3]
print "#{l}: "
if @inp1 == 0
@inp1 = l; zmsnp self.begin_action(@action, l, @second, 0); @inp1 = 0
else
@inp2 = l; zmsnp self.begin_action(@action, @noun, l, 0); @inp2 = 0
end
end
end
if @notheld_mode
NoteObjectAcquisitions()
println(result, should_prompt: false)
return true if result == false
next
end
return result if @meta
if defined? SINGLE_PLAYER
self.end_turn_sequence() unless deadflag
end
println(result) if result.is_a?(String)
return true
end
rescue RepeatedOrder
return L__M(:Miscellany, REPEATED_ORDER)
rescue NothingToRepeat
return L__M(:Miscellany, NOTHING_TO_REPEAT)
rescue InanimateAddressee
return L__M(:Miscellany, CANT_TALK, noun)
rescue SpeechImpediment
return L__M(:Miscellany, SPEECH_THERAPY)
rescue CannotUnderstandSentence
return L__M(:Miscellany, CANNOT_UNDERSTAND)
rescue PartiallyUnderstood
L__M(:Miscellany, PARTIALLY_UNDERSTOOD)
@pattern = @pattern2.dup
@pcount = @pcount2
PrintCommand(0)
return L__M(:Miscellany, 56)
rescue NumberUnrecognized
return L__M(:Miscellany, NUMBER_UNRECOGNIZED)
rescue CantSeeError
@oops_from = @saved_oops
return L__M(:Miscellany, CANT_SEE)
rescue TooLittle
return L__M(:Miscellany, TOOLITTLE)
rescue NotHeld
@oops_from = @saved_oops
return L__M(:Miscellany, NOT_HELD)
rescue UnexpectedMultiple
return L__M(:Miscellany, NO_MULTIPLES)
rescue MultipleMultiples
return L__M(:Miscellany, MULITPLES_ONLY_ONCE)
rescue Vague
return L__M(:Miscellany, VAGUE)
rescue ExceptedUnnecessarily
return L__M(:Miscellany, EXCEPTED_UNECESSARILY)
rescue AnimateExpected
return L__M(:Miscellany, ANIMATE_EXPECTED)
rescue VerbUnrecognized
return L__M(:Miscellany, UNRECOGNIZED)
rescue SceneryIsIrrelevant
return L__M(:Miscellany, SCENERY_IS_IRRELEVANT)
rescue ItGone
if @pronoun_obj then L__M(:Miscellany, 40)
else L__M(:Miscellany, 35)
end
rescue JunkAfter
return L__M(:Miscellany, 41)
rescue TooFew
return L__M(:Miscellany, TOOFEW, number)
rescue NothingMatched
if @results[0] == :Remove && results[3].object?
@noun = results[3] if noun.has?(:animate) then L__M(:Take, 6, noun)
elsif noun.hasnt?(:container, :supporter) then L__M(:Insert, 2, noun)
elsif noun.has?(:container) && noun.hasnt?(:open) then L__M(:Take, 9, noun)
elsif noun.empty? then L__M(:Search, 6, noun)
else @results[0] = nil
end
end
if @results[0] != :Remove
if @multi_wanted == 100 then L__M(:Miscellany, 43)
else L__M(:Miscellany, 44)
end
end
rescue AskScope
@scope_stage = 3
if indirect(@scope_error) == false
@best_etype = @nextbest_etype
raise @best_etype
end
rescue IncompleteSentence => e
ambiguity = e
return Incomplete(ambiguity)
rescue Ambiguous => e
ambiguity = e
return WhichOne(ambiguity)
rescue NoSuchObject
return L__M(:Miscellany, NO_OBJECT)
rescue CycleError
return L__M(:Miscellany, TREE_ERROR)
rescue NoVerbRoutine, NotImplemented
return "Sorry, that action is not yet implemented."
rescue NoMethodError => e
log.error "Error parsing user command: #{e.class}: #{e}"
e.backtrace.each { |t| log.error t }
log.error "Parser was #{self.identity}"
log.error "Input was: #{@input}"
log.error "Actor was: #{@actor}"
log.error "Action was: #{@action}"
return "Sorry, something went wrong."
rescue TypeError => e
log.error "Error parsing user command: #{e.class}: #{e}"
e.backtrace.each { |t| log.error t }
log.error "Parser was #{self.identity}"
log.error "Input was: #{@input}"
log.error "Actor was: #{@actor}"
log.error "Action was: #{@action}"
return "Sorry, something went wrong."
rescue StandardError => e
log.error "Error parsing user command: #{e.class}: #{e}"
e.backtrace.each { |t| log.error t }
log.error "Parser was #{self.identity}"
log.error "Input was: #{@input}"
log.error "Actor was: #{@actor}"
log.error "Action was: #{@action}"
return "Sorry, something went seriously wrong."
end
|
5276
5277
5278
|
# File 'lib/inform/parserm.h.rb', line 5276
def parse_input
return Parser__parse()
end
|
#play ⇒ Object
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
|
# File 'lib/inform/parserm.h.rb', line 5204
def play
@real_location = thedark
@player = selfobj; @actor = @player
selfobj.capacity = MAX_CARRIED
new_line
LibraryExtensions.RunAll(:ext_initialise)
j = Initialise()
println j if j.is_a?(String)
move @player, @location
light_adjusted @player
@location = @location.parent until @location.parent.nil?
@real_location = @location
@actor = @player Banner() if j != 2
@lightflag = OffersLight(@player.parent)
if @lightflag == false
@real_location = @location
@location = @thedark
end
OBIT_HEAD() if deadflag
@player.mute if deadflag
invoke :Look
deadflag ? :death : :playing
end
|
#playing ⇒ Object
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
|
# File 'lib/inform/parserm.h.rb', line 5231
def playing
@player.unmute if @player.respond_to?(:unmute) && !deadflag
enqueue(command: @buffer.dup)
unless deadflag
return session.state if respond_to?(:session) && !session.nil?
return __method__
end
AfterLife() if deadflag != 2
return very__late__error if deadflag == 0
OBIT_HEAD()
ScoreSub()
DisplayStatus()
AfterGameOver()
log.debug "#{@player} is entering the death state" :death
end
|
#PrintOrRun(obj, prop, flag = 0) ⇒ Object
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
|
# File 'lib/inform/parserm.h.rb', line 5786
def PrintOrRun(obj, prop, flag = 0)
si = obj.inflib; obj.inflib = inflib
return RunRoutines(obj, prop) if obj.properties.include?(prop)
if obj.respond_to?(prop) && !obj.method(prop).nil?
result = obj.send(prop)
if result.is_a?(Class) || result.nil? || obj.linked?(prop)
return RunTimeError(2, obj, prop)
elsif result.is_a?(String)
print result.to_s
new_line if flag == 0
return true
else
return result
end
elsif obj.linked?(prop)
return RunTimeError(2, obj, prop)
end
ensure
obj.inflib = si
end
|
#PrintOrRunVar(var, flag) ⇒ Object
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
|
# File 'lib/inform/parserm.h.rb', line 5807
def PrintOrRunVar(var, flag)
if var.respond_to?(:name)
print var.name
elsif var.is_a?(String)
print var
new_line if flag == 0
elsif var.respond_to?(:call)
return var.call
else
print "(#{var})"
end
true
end
|
#R_Process(a, i, j) ⇒ Object
5701
5702
5703
5704
5705
|
# File 'lib/inform/parserm.h.rb', line 5701
def R_Process(a, i, j)
s1 = @inp1; s2 = @inp2
@inp1 = i; @inp2 = j; InformLibrary.begin_action(a, i, j, 1)
@inp1 = s1; @inp2 = s2
end
|
#resume ⇒ Object
5264
5265
5266
|
# File 'lib/inform/parserm.h.rb', line 5264
def resume
send(VerbRoutine(@action))
end
|
#RRQPL ⇒ Object
5668
5669
5670
5671
|
# File 'lib/inform/parserm.h.rb', line 5668
def RRQPL
L__M(:Miscellany, 5)
AfterGameOver()
end
|
#RunEachTurnProperties ⇒ Object
5656
5657
5658
5659
5660
5661
5662
|
# File 'lib/inform/parserm.h.rb', line 5656
def RunEachTurnProperties
return unless defined? SINGLE_PLAYER
@scope_reason = scope_reason = EACH_TURN_REASON; @verb_word = nil
DoScopeAction(@location, scope_reason)
SearchScope(ScopeCeiling(@player), @player, nil)
@scope_reason = PARSING_REASON
end
|
#RunLife(a, j) ⇒ Object
5766
5767
5768
5769
5770
5771
5772
5773
5774
|
# File 'lib/inform/parserm.h.rb', line 5766
def RunLife(a, j)
if defined?(DEBUG)
TraceAction(2, j) if @debug_flag & 2 != 0
end sv = @reason_code; @reason_code = j;
return RunRoutines(a, :life)
ensure
@reason_code = sv
end
|
#RunRoutines(obj, prop) ⇒ Object
5826
5827
5828
5829
5830
5831
|
# File 'lib/inform/parserm.h.rb', line 5826
def RunRoutines(obj, prop)
obj = @real_location if obj == thedark && prop.notin?(:initial, :short_name, :description, :life)
return false if prop.nil?
val = obj.&(prop); return val unless val.nil?
return reacts_to?(obj, prop)
end
|
#RunTimersAndDaemons ⇒ Object
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
|
# File 'lib/inform/parserm.h.rb', line 5627
def RunTimersAndDaemons
return if !defined?(SINGLE_PLAYER)
if defined?(DEBUG)
if (@debug_flag & 4) != 0
@active_timers.each do |the_timer|
next if the_timer.nil?
print name(the_timer & !WORD_HIGHBIT) + ": "
if (the_timer & WORD_HIGHBIT) != 0 then print "daemon"
else
print "timer with " + the_timer.time_left + " turns to go"
end
new_line
end
end
end
@active_timers.each do |the_timer|
break if deadflag != 0
next if the_timer.nil?
if (the_timer & WORD_HIGHBIT) != 0 then RunRoutines(the_timer & !WORD_HIGHBIT, daemon)
elsif the_timer.time_left == 0
StopTimer(the_timer)
RunRoutines(the_timer, time_out)
else
the_timer.time_left = the_timer.time_left - 1
end
end
end
|
#state ⇒ Object
5195
5196
5197
|
# File 'lib/inform/parserm.h.rb', line 5195
def state
@player.|(:game_state, (session ? session.state : :playing))
end
|
#state=(state) ⇒ Object
5199
5200
5201
5202
|
# File 'lib/inform/parserm.h.rb', line 5199
def state=(state)
@player.&(:game_state, state)
session.state = state if session
end
|
#stop ⇒ Object
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
|
# File 'lib/inform/parserm.h.rb', line 5251
def stop
session.state = session.default unless session.nil?
if @player.nil?
log.warn "The player object was missing when stopping the game"
return
end
@player.unsubscribe_all
InformLibrary.libraries.delete @player.identity
@player = @player.safe_refresh
@player.remove if !@player.nil? && @player.is_a?(Character)
@player = @actor = @selfobj = nil
end
|
#TestScope(obj, act) ⇒ Object
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
|
# File 'lib/inform/parserm.h.rb', line 5722
def TestScope(obj, act)
x = @parser_one; p2 = @parser_two;
@parser_one = obj; @parser_two = 0; a = @actor; al = @actors_location
sr = @scope_reason; @scope_reason = scope_reason = TESTSCOPE_REASON
if act.nil? then @actor = @player else @actor = act end
@actors_location = ScopeCeiling(actor)
SearchScope(@actors_location, @actor, scope_reason); @scope_reason = sr; @actor = a
return x
ensure
@parser_one = x; @parser_two = p2; @actor = a; @actors_location = al; @scope_reason = sr
end
|
#ValueOrRun(obj, prop) ⇒ Object
5821
5822
5823
5824
|
# File 'lib/inform/parserm.h.rb', line 5821
def ValueOrRun(obj, prop)
value = obj.respond_to?(prop) ? obj.send(prop) : RunRoutines(obj, prop)
return value.number? ? value.to_i : value
end
|
#ZRegion(z) ⇒ Object
5776
5777
5778
5779
5780
5781
5782
5783
5784
|
# File 'lib/inform/parserm.h.rb', line 5776
def ZRegion(z)
return 0 if z.nil?
case z.class when Object, Class then 1
when Symbol then 2
when String then 3
end
end
|