@@ -322,6 +322,8 @@ export class GameParserImpl implements GameParser {
322
322
protected processText ( text : string ) : void {
323
323
const { id : tagId = '' , name : tagName = '' } = this . getActiveTag ( ) ?? { } ;
324
324
325
+ logger . debug ( 'processing text' , { tagId, tagName, text } ) ;
326
+
325
327
// There are no tags so just keep collecting up the text.
326
328
if ( this . activeTags . length === 0 ) {
327
329
this . gameText += text ;
@@ -386,6 +388,8 @@ export class GameParserImpl implements GameParser {
386
388
tagName : string ,
387
389
attributes : Record < string , string >
388
390
) : void {
391
+ logger . debug ( 'processing tag start' , { tagName, attributes } ) ;
392
+
389
393
this . activeTags . push ( {
390
394
id : attributes . id ,
391
395
name : tagName ,
@@ -445,6 +449,8 @@ export class GameParserImpl implements GameParser {
445
449
protected processTagEnd ( ) : void {
446
450
const { id : tagId = '' , name : tagName = '' } = this . getActiveTag ( ) ?? { } ;
447
451
452
+ logger . debug ( 'processing tag end' , { tagId, tagName } ) ;
453
+
448
454
switch ( tagName ) {
449
455
case 'compDef' :
450
456
case 'component' :
@@ -552,33 +558,33 @@ export class GameParserImpl implements GameParser {
552
558
}
553
559
554
560
protected emitTextGameEvent ( text : string ) : void {
555
- this . gameEventsSubject$ . next ( {
561
+ this . emitGameEvent ( {
556
562
type : GameEventType . TEXT ,
557
563
text : unescapeEntities ( text ) ,
558
564
} ) ;
559
565
}
560
566
561
567
protected emitPushBoldGameEvent ( ) : void {
562
- this . gameEventsSubject$ . next ( {
568
+ this . emitGameEvent ( {
563
569
type : GameEventType . PUSH_BOLD ,
564
570
} ) ;
565
571
}
566
572
567
573
protected emitPopBoldGameEvent ( ) : void {
568
- this . gameEventsSubject$ . next ( {
574
+ this . emitGameEvent ( {
569
575
type : GameEventType . POP_BOLD ,
570
576
} ) ;
571
577
}
572
578
573
579
protected emitTextOutputClassGameEvent ( className : string ) : void {
574
- this . gameEventsSubject$ . next ( {
580
+ this . emitGameEvent ( {
575
581
type : GameEventType . TEXT_OUTPUT_CLASS ,
576
582
textOutputClass : className ,
577
583
} ) ;
578
584
}
579
585
580
586
protected emitTextStylePresetGameEvent ( presetName : string ) : void {
581
- this . gameEventsSubject$ . next ( {
587
+ this . emitGameEvent ( {
582
588
type : GameEventType . TEXT_STYLE_PRESET ,
583
589
textStylePreset : presetName ,
584
590
} ) ;
@@ -591,7 +597,7 @@ export class GameParserImpl implements GameParser {
591
597
const { tagId, active } = options ;
592
598
const indicator = INDICATOR_ID_TO_TYPE_MAP [ tagId ] ;
593
599
if ( indicator ) {
594
- this . gameEventsSubject$ . next ( {
600
+ this . emitGameEvent ( {
595
601
type : GameEventType . INDICATOR ,
596
602
indicator,
597
603
active,
@@ -600,48 +606,48 @@ export class GameParserImpl implements GameParser {
600
606
}
601
607
602
608
protected emitSpellGameEvent ( spell : string ) : void {
603
- this . gameEventsSubject$ . next ( {
609
+ this . emitGameEvent ( {
604
610
type : GameEventType . SPELL ,
605
611
spell : unescapeEntities ( spell ) ,
606
612
} ) ;
607
613
}
608
614
609
615
protected emitLeftHandGameEvent ( item : string ) : void {
610
- this . gameEventsSubject$ . next ( {
616
+ this . emitGameEvent ( {
611
617
type : GameEventType . LEFT_HAND ,
612
618
item : unescapeEntities ( item ) ,
613
619
} ) ;
614
620
}
615
621
616
622
protected emitRightHandGameEvent ( item : string ) : void {
617
- this . gameEventsSubject$ . next ( {
623
+ this . emitGameEvent ( {
618
624
type : GameEventType . RIGHT_HAND ,
619
625
item : unescapeEntities ( item ) ,
620
626
} ) ;
621
627
}
622
628
623
629
protected emitClearStreamGameEvent ( streamId : string ) : void {
624
- this . gameEventsSubject$ . next ( {
630
+ this . emitGameEvent ( {
625
631
type : GameEventType . CLEAR_STREAM ,
626
632
streamId : streamId ,
627
633
} ) ;
628
634
}
629
635
630
636
protected emitPushStreamGameEvent ( streamId : string ) : void {
631
- this . gameEventsSubject$ . next ( {
637
+ this . emitGameEvent ( {
632
638
type : GameEventType . PUSH_STREAM ,
633
639
streamId : streamId ,
634
640
} ) ;
635
641
}
636
642
637
643
protected emitPopStreamGameEvent ( ) : void {
638
- this . gameEventsSubject$ . next ( {
644
+ this . emitGameEvent ( {
639
645
type : GameEventType . POP_STREAM ,
640
646
} ) ;
641
647
}
642
648
643
649
protected emitCompassGameEvent ( directions : Array < string > ) : void {
644
- this . gameEventsSubject$ . next ( {
650
+ this . emitGameEvent ( {
645
651
type : GameEventType . COMPASS ,
646
652
directions,
647
653
} ) ;
@@ -652,7 +658,7 @@ export class GameParserImpl implements GameParser {
652
658
value : number ;
653
659
} ) : void {
654
660
const { vitalId, value } = options ;
655
- this . gameEventsSubject$ . next ( {
661
+ this . emitGameEvent ( {
656
662
type : GameEventType . VITALS ,
657
663
vitalId,
658
664
value,
@@ -666,7 +672,7 @@ export class GameParserImpl implements GameParser {
666
672
mindState : string ;
667
673
} ) : void {
668
674
const { skill, rank, percent, mindState } = options ;
669
- this . gameEventsSubject$ . next ( {
675
+ this . emitGameEvent ( {
670
676
type : GameEventType . EXPERIENCE ,
671
677
skill,
672
678
rank,
@@ -682,24 +688,29 @@ export class GameParserImpl implements GameParser {
682
688
const { tagId, roomText } = options ;
683
689
const roomProperty = ROOM_ID_TO_EVENT_PROPERTY_MAP [ tagId ] ;
684
690
if ( roomProperty ) {
685
- this . gameEventsSubject$ . next ( {
691
+ this . emitGameEvent ( {
686
692
type : GameEventType . ROOM ,
687
693
[ roomProperty ] : unescapeEntities ( roomText ) ,
688
694
} ) ;
689
695
}
690
696
}
691
697
692
698
protected emitServerTimeGameEvent ( time : number ) : void {
693
- this . gameEventsSubject$ . next ( {
699
+ this . emitGameEvent ( {
694
700
type : GameEventType . SERVER_TIME ,
695
701
time,
696
702
} ) ;
697
703
}
698
704
699
705
protected emitRoundTimeGameEvent ( time : number ) : void {
700
- this . gameEventsSubject$ . next ( {
706
+ this . emitGameEvent ( {
701
707
type : GameEventType . ROUND_TIME ,
702
708
time,
703
709
} ) ;
704
710
}
711
+
712
+ protected emitGameEvent ( gameEvent : GameEvent ) : void {
713
+ logger . debug ( 'emitting game event' , { gameEvent } ) ;
714
+ this . gameEventsSubject$ . next ( gameEvent ) ;
715
+ }
705
716
}
0 commit comments