189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
|
# File 'documented/gemstone/infomon/parser.rb', line 189
def self.parse(line)
return :noop unless line =~ Pattern::All
begin
case line
when Pattern::CharRaceProf
@stat_hold = []
Infomon.mutex_lock
match = Regexp.last_match
@stat_hold.push(['stat.race', match[:race].to_s],
['stat.profession', match[:profession].to_s]) unless Effects::Spells.active?(1212)
:ok
when Pattern::CharGenderAgeExpLevel
match = Regexp.last_match
@stat_hold.push(['stat.gender', match[:gender].to_s],
['stat.age', match[:age].delete(',').to_i]) unless Effects::Spells.active?(1212)
@stat_hold.push(['stat.experience', match[:experience].delete(',').to_i])
:ok
when Pattern::Stat
match = Regexp.last_match
@stat_hold.push(['stat.%s' % match[:stat], match[:value].to_i],
['stat.%s_bonus' % match[:stat], match[:bonus].to_i],
['stat.%s.enhanced' % match[:stat], match[:enhanced_value].to_i],
['stat.%s.enhanced_bonus' % match[:stat], match[:enhanced_bonus].to_i])
:ok
when Pattern::StatEnd
match = Regexp.last_match
@stat_hold.push(['currency.silver', match[:silver].delete(',').to_i])
Infomon.upsert_batch(@stat_hold)
Infomon.mutex_unlock
:ok
when Pattern::Fame @expr_hold = []
Infomon.mutex_lock
match = Regexp.last_match
@expr_hold.push(['experience.fame', match[:fame].delete(',').to_i])
:ok
when Pattern::RealExp
match = Regexp.last_match
@expr_hold.push(['experience.field_experience_current', match[:fxp_current].delete(',').to_i],
['experience.field_experience_max', match[:fxp_max].delete(',').to_i])
:ok
when Pattern::AscExp
match = Regexp.last_match
@expr_hold.push(['experience.ascension_experience', match[:ascension_experience].delete(',').to_i])
:ok
when Pattern::TotalExp
match = Regexp.last_match
@expr_hold.push(['experience.total_experience', match[:total_experience].delete(',').to_i],
['experience.deaths_sting', match[:deaths_sting]])
:ok
when Pattern::LTE
match = Regexp.last_match
@expr_hold.push(['experience.long_term_experience', match[:long_term_experience].delete(',').to_i],
['experience.deeds', match[:deeds].to_i])
:ok
when Pattern::ExprEnd
Infomon.upsert_batch(@expr_hold)
Infomon.mutex_unlock
:ok
when Pattern::SkillStart
@skills_hold = []
Infomon.mutex_lock
:ok
when Pattern::Skill
if Infomon.mutex.owned?
match = Regexp.last_match
@skills_hold.push(['skill.%s' % match[:name].downcase, match[:ranks].to_i],
['skill.%s_bonus' % match[:name], match[:bonus].to_i])
:ok
else
:noop
end
when Pattern::SpellRanks
if Infomon.mutex.owned?
match = Regexp.last_match
@skills_hold.push(['spell.%s' % match[:name].downcase, match[:rank].to_i])
:ok
else
:noop
end
when Pattern::SkillEnd
if Infomon.mutex.owned?
Infomon.upsert_batch(@skills_hold)
Infomon.mutex_unlock
:ok
else
:noop
end
when Pattern::GoalsDetected
State.set(State::Goals)
:ok
when Pattern::GoalsEnded
if State.get.eql?(State::Goals)
State.set(State::Ready)
respond
_respond Lich::Messaging.monsterbold('You just trained your character. Lich will gather your updated skills.')
respond
respond "[infomon_sync]#{$SEND_CHARACTER}skills"
Game._puts("#{$cmd_prefix}skills")
:ok
else
:noop
end
when Pattern::PSMStart
match = Regexp.last_match
@psm_hold = []
@psm_cat = find_cat(match[:cat])
Infomon.mutex_lock
:ok
when Pattern::PSM
match = Regexp.last_match
@psm_hold.push(["#{@psm_cat.downcase}.%s" % match[:command], match[:ranks].to_i])
:ok
when Pattern::PSMEnd
Infomon.upsert_batch(@psm_hold)
Infomon.mutex_unlock
:ok
when Pattern::NoWarcries
Infomon.upsert_batch([['warcry.bertrandts_bellow', 0],
['warcry.yerties_yowlp', 0],
['warcry.gerrelles_growl', 0],
['warcry.seanettes_shout', 0],
['warcry.carns_cry', 0],
['warcry.horlands_holler', 0]])
:ok
when Pattern::Warcries
match = Regexp.last_match
Infomon.set('warcry.%s' % match[:name].split(' ')[1], 1)
:ok
when Pattern::Levelup
match = Regexp.last_match
Infomon.upsert_batch([['stat.%s' % match[:stat], match[:value].to_i],
['stat.%s_bonus' % match[:stat], match[:bonus].to_i]])
:ok
when Pattern::SpellsSolo
match = Regexp.last_match
Infomon.set('spell.%s' % match[:name].downcase, match[:rank].to_i)
:ok
when Pattern::Citizenship
Infomon.set('citizenship', Regexp.last_match[:town].to_s)
:ok
when Pattern::NoCitizenship
Infomon.set('citizenship', 'None')
:ok
when Pattern::Society
match = Regexp.last_match
Infomon.set('society.status', match[:society].to_s)
Infomon.set('society.rank', match[:rank].to_i)
case match[:standing] when 'Master'
if /Voln/.match?(match[:society])
Infomon.set('society.rank', 26)
elsif /Council of Light|Guardians of Sunfist/.match?(match[:society])
Infomon.set('society.rank', 20)
end
end
:ok
when Pattern::NoSociety
Infomon.set('society.status', 'None')
Infomon.set('society.rank', 0)
:ok
when Pattern::SocietyJoin
match = Regexp.last_match.to_s
case match[/Order|Council|Guardians/]
when 'Order'
Infomon.set('society.status', 'Order of Voln')
Infomon.set('society.rank', 1)
when 'Guardians'
Infomon.set('society.status', "Guardians of Sunfist")
Infomon.set('society.rank', 0)
when 'Lodge'
Infomon.set('society.status', 'Council of Light')
Infomon.set('society.rank', 1)
end
:ok
when Pattern::SocietyStep
Infomon.set('society.rank', Infomon.get('society.rank') + 1)
:ok
when Pattern::SocietyResign
Infomon.set('society.status', 'None')
Infomon.set('society.rank', 0)
:ok
when Pattern::LearnPSM, Pattern::LearnTechnique
match = Regexp.last_match
@psm_cat = find_cat(match[:cat])
seek_name = PSMS.name_normal(match[:psm])
db_name = PSMS.find_name(seek_name, @psm_cat)
Infomon.set("#{@psm_cat.downcase}.#{db_name[:short_name]}", match[:rank].to_i)
:ok
when Pattern::UnlearnPSM, Pattern::UnlearnTechnique
match = Regexp.last_match
@psm_cat = find_cat(match[:cat])
seek_name = PSMS.name_normal(match[:psm])
no_decrement = (match.string =~ /have decreased to/)
db_name = PSMS.find_name(seek_name, @psm_cat)
Infomon.set("#{@psm_cat.downcase}.#{db_name[:short_name]}", (no_decrement ? match[:rank].to_i : match[:rank].to_i - 1))
:ok
when Pattern::LostTechnique
match = Regexp.last_match
@psm_cat = find_cat(match[:cat])
seek_name = PSMS.name_normal(match[:psm])
db_name = PSMS.find_name(seek_name, @psm_cat)
Infomon.set("#{@psm_cat.downcase}.#{db_name[:short_name]}", 0)
:ok
when Pattern::Resource
match = Regexp.last_match
Infomon.set('resources.weekly', match[:weekly].delete(',').to_i)
Infomon.set('resources.total', match[:total].delete(',').to_i)
:ok
when Pattern::Suffused
match = Regexp.last_match
Infomon.set('resources.type', match[:type].to_s)
Infomon.set('resources.suffused', match[:suffused].delete(',').to_i)
:ok
when Pattern::VolnFavor
match = Regexp.last_match
Infomon.set('resources.voln_favor', match[:favor].delete(',').to_i)
:ok
when Pattern::CovertArtsCharges
match = Regexp.last_match
Infomon.set('resources.covert_arts_charges', match[:charges].delete(',').to_i)
:ok
when Pattern::ShadowEssence
match = Regexp.last_match
Infomon.set('resources.shadow_essence', match[:essence].to_i.clamp(0, 5))
:ok
when Pattern::ShadowEssenceGain
Infomon.set('resources.shadow_essence', (Lich::Resources.shadow_essence.to_i + 1).clamp(0, 5))
:ok
when Pattern::ShadowEssenceCap
Infomon.set('resources.shadow_essence', 5)
:ok
when Pattern::SacrificeMana
match = Regexp.last_match
effective_mana_ranks = [Skills.elemental_mana_control, Skills.spirit_mana_control].max + [Skills.elemental_mana_control, Skills.spirit_mana_control].min / 2
base_mana = Char.level + 20
mana_per_essence = (base_mana * (0.5 + effective_mana_ranks.clamp(0, 60) / 120))
essences_used = (((match[:amount].to_i - mana_per_essence) / (base_mana * 0.5))).round.clamp(1, 5)
Infomon.set('resources.shadow_essence', (Lich::Resources.shadow_essence.to_i - essences_used).clamp(0, 5))
:ok
when Pattern::SacrificeChannel, Pattern::SacrificeInfest, Pattern::SacrificeFate, Pattern::SacrificeShift
Infomon.set('resources.shadow_essence', (Lich::Resources.shadow_essence.to_i - 1).clamp(0, 5))
:ok
when Pattern::GigasArtifactFragments
match = Regexp.last_match
Infomon.set('currency.gigas_artifact_fragments', match[:gigas_artifact_fragments].delete(',').to_i)
:ok
when Pattern::RedsteelMarks
match = Regexp.last_match
Infomon.set('currency.redsteel_marks', match[:redsteel_marks].delete(',').to_i)
:ok
when Pattern::GemstoneDust
match = Regexp.last_match
Infomon.set('currency.gemstone_dust', match[:gemstone_dust].delete(',').to_i)
:ok
when Pattern::TicketGeneral
match = Regexp.last_match
Infomon.set('currency.tickets', match[:tickets].delete(',').to_i)
:ok
when Pattern::TicketBlackscrip
match = Regexp.last_match
Infomon.set('currency.blackscrip', match[:blackscrip].delete(',').to_i)
:ok
when Pattern::TicketBloodscrip
match = Regexp.last_match
Infomon.set('currency.bloodscrip', match[:bloodscrip].delete(',').to_i)
:ok
when Pattern::TicketEtherealScrip
match = Regexp.last_match
Infomon.set('currency.ethereal_scrip', match[:ethereal_scrip].delete(',').to_i)
:ok
when Pattern::TicketSoulShards
match = Regexp.last_match
Infomon.set('currency.soul_shards', match[:soul_shards].delete(',').to_i)
:ok
when Pattern::TicketGold
match = Regexp.last_match
Infomon.set('currency.gold', match[:gold].delete(',').to_i)
:ok
when Pattern::TicketRaikhen
match = Regexp.last_match
Infomon.set('currency.raikhen', match[:raikhen].delete(',').to_i)
:ok
when Pattern::WealthSilver
match = Regexp.last_match
case match[:silver]
when 'no'
Infomon.set('currency.silver', 0)
when 'but one'
Infomon.set('currency.silver', 1)
else
Infomon.set('currency.silver', match[:silver].delete(',').to_i)
end
:ok
when Pattern::WealthSilverContainer
match = Regexp.last_match
Infomon.set('currency.silver_container', match[:silver].delete(',').to_i)
:ok
when Pattern::AccountName
if Account.name.nil?
match = Regexp.last_match
Account.name = match[:name].upcase
:ok
else
:noop
end
when Pattern::AccountSubscription
if Account.subscription
match = Regexp.last_match
Account.subscription = match[:subscription].gsub('Standard', 'Normal').gsub('F2P', 'Free').gsub('Platinum', 'Premium').upcase
Infomon.set('account.type', match[:subscription].gsub('Standard', 'Normal').gsub('F2P', 'Free').upcase)
:ok
else
:noop
end
when Pattern::ProfileStart
State.set(State::Profile)
:ok
when Pattern::ProfileName
match = Regexp.last_match
if State.get.eql?(State::Profile) && !match[:name].split(' ').include?(Char.name)
State.set(State::Ready)
:ok
else
:noop
end
when Pattern::ProfileHouseCHE
if State.get.eql?(State::Profile)
match = Regexp.last_match
Infomon.set('che', (match[:none] ? 'none' : Lich::Util.normalize_name(match[:house])))
State.set(State::Ready)
:ok
else
:noop
end
when Pattern::ResignCHE
match = Regexp.last_match
Infomon.set('che', (match[:none] ? 'none' : Lich::Util.normalize_name(match[:house])))
:ok
when Pattern::ResignConfirmCHE
Infomon.set('che', 'none')
:ok
when Pattern::ThornPoisonStart, Pattern::ThornPoisonProgression, Pattern::ThornPoisonDeprogression
Infomon.set('status.thorned', true)
:ok
when Pattern::ThornPoisonEnd
Infomon.set('status.thorned', false)
:ok
when Pattern::SleepActive
Infomon.set('status.sleeping', true)
:ok
when Pattern::SleepNoActive
Infomon.set('status.sleeping', false)
:ok
when Pattern::BindActive
Infomon.set('status.bound', true)
:ok
when Pattern::BindNoActive
Infomon.set('status.bound', false)
:ok
when Pattern::SilenceActive
Infomon.set('status.silenced', true)
:ok
when Pattern::SilenceNoActive
Infomon.set('status.silenced', false)
:ok
when Pattern::CalmActive
Infomon.set('status.calmed', true)
:ok
when Pattern::CalmNoActive
Infomon.set('status.calmed', false)
:ok
when Pattern::CutthroatActive
Infomon.set('status.cutthroat', true)
:ok
when Pattern::CutthroatNoActive
Infomon.set('status.cutthroat', false)
:ok
when Pattern::SpellUpMsgs
spell = Spell.list.find do |s|
line =~ /^#{s.msgup}$/
end
spell.putup unless spell.active?
Spells.require_cooldown(spell)
:ok
when Pattern::SpellDnMsgs
spell = Spell.list.find do |s|
line =~ /^#{s.msgdn}$/
end
spell.putdown if spell.active?
:ok
when Pattern::SpellsongRenewed
Spellsong.renewed
:ok
when Pattern::EnhanciveStart
@enhancive_hold = []
State.set(State::EnhanciveStats)
Infomon.mutex_lock
Lich::Gemstone::Enhancive.reset_all
:ok
when Pattern::EnhanciveStat
if State.get == State::EnhanciveStats
match = Regexp.last_match
stat_key = Lich::Gemstone::Enhancive::STAT_ABBREV[match[:abbr]]
@enhancive_hold.push(["enhancive.stat.#{stat_key}", match[:value].to_i])
:ok
else
:noop
end
when Pattern::EnhanciveSkillsSection
State.set(State::EnhanciveSkills) if State.get == State::EnhanciveStats
:ok
when Pattern::EnhanciveSkillRanks
if State.get == State::EnhanciveSkills
match = Regexp.last_match
skill_key = Lich::Gemstone::Enhancive::SKILL_NAME_MAP[match[:name].strip]
@enhancive_hold.push(["enhancive.skill.#{skill_key}.ranks", match[:value].to_i]) if skill_key
:ok
else
:noop
end
when Pattern::EnhanciveSkillBonus
if State.get == State::EnhanciveSkills
match = Regexp.last_match
skill_key = Lich::Gemstone::Enhancive::SKILL_NAME_MAP[match[:name].strip]
@enhancive_hold.push(["enhancive.skill.#{skill_key}.bonus", match[:value].to_i]) if skill_key
:ok
else
:noop
end
when Pattern::EnhanciveResourcesSection
State.set(State::EnhanciveResources) if State.get == State::EnhanciveSkills
:ok
when Pattern::EnhanciveResource
if State.get == State::EnhanciveResources
match = Regexp.last_match
resource_key = Lich::Gemstone::Enhancive::RESOURCE_NAME_MAP[match[:name].strip]
@enhancive_hold.push(["enhancive.resource.#{resource_key}", match[:value].to_i]) if resource_key
:ok
else
:noop
end
when Pattern::EnhanciveSpellsSection
State.set(State::EnhanciveSpells) if State.get == State::EnhanciveResources
:ok
when Pattern::EnhanciveSpells
if State.get == State::EnhanciveSpells
match = Regexp.last_match
spell_nums = match[:spells].split(',').map { |s| s.strip.to_i }
@enhancive_hold.push(["enhancive.spells", spell_nums.join(',')])
:ok
else
:noop
end
when Pattern::EnhanciveStatisticsSection
State.set(State::EnhanciveStatistics) if State.get == State::EnhanciveSpells
:ok
when Pattern::EnhanciveStatistic
if State.get == State::EnhanciveStatistics
match = Regexp.last_match
case match[:name]
when 'Enhancive Items'
@enhancive_hold.push(['enhancive.stats.item_count', match[:value].to_i])
when 'Enhancive Properties'
@enhancive_hold.push(['enhancive.stats.property_count', match[:value].to_i])
when 'Total Enhancive Amount'
@enhancive_hold.push(['enhancive.stats.total_amount', match[:value].to_i])
end
:ok
else
:noop
end
when Pattern::EnhanciveEnd
if State.enhancive_state?
Infomon.upsert_batch(@enhancive_hold)
Infomon.mutex_unlock
State.set(State::Ready)
:ok
else
:noop
end
when Pattern::EnhanciveNone
Lich::Gemstone::Enhancive.reset_all
:ok
when Pattern::EnhanciveOn
Infomon.set('enhancive.active', true)
:ok
when Pattern::EnhanciveOff
Infomon.set('enhancive.active', false)
:ok
when Pattern::EnhancivePauses
match = Regexp.last_match
Infomon.set('enhancive.pauses', match[:pauses].to_i)
:ok
else
:noop
end
rescue StandardError
respond "--- Lich: error: Infomon::Parser.parse: #{$!}"
respond "--- Lich: error: line: #{line}"
Lich.log "error: Infomon::Parser.parse: #{$!}\n\t#{$!.backtrace.join("\n\t")}"
Lich.log "error: line: #{line}\n\t"
end
end
|