@@ -364,7 +364,7 @@ export class GameParserImpl implements GameParser {
364
364
break ;
365
365
case 'a' :
366
366
// This is a hyperlink, we only need the text.
367
- // Example: `<a href='https://drwiki .play.net'>Elanthipedia</a>`.
367
+ // Example: `<a href='https://elanthipedia .play.net'>Elanthipedia</a>`
368
368
// In this example, the text would be 'Elanthipedia'.
369
369
this . gameText += text ;
370
370
break ;
@@ -414,6 +414,9 @@ export class GameParserImpl implements GameParser {
414
414
} ) ;
415
415
416
416
switch ( tagName ) {
417
+ case 'a' : // <a href='https://elanthipedia.play.net'>Elanthipedia</a>
418
+ this . gameText += `<a href="${ attributes . href } " target="_blank">` ;
419
+ break ;
417
420
case 'pushBold' : // <pushBold/>
418
421
// If this is nested inside text then it is an inline text style.
419
422
// For example, emphasizing a person's name.
@@ -487,13 +490,6 @@ export class GameParserImpl implements GameParser {
487
490
case 'castTime' : // <castTime value='1703617016'/>
488
491
this . emitCastTimeGameEvent ( parseInt ( attributes . value ) ) ;
489
492
break ;
490
- case 'a' : // <a href='https://elanthipedia.play.net/'>Elanthipedia</a>
491
- // Links are often found within a line of text.
492
- // Emit any game text up to this point.
493
- if ( this . gameText . length > 0 ) {
494
- this . emitTextGameEvent ( this . consumeGameText ( ) ) ;
495
- }
496
- break ;
497
493
}
498
494
}
499
495
@@ -513,6 +509,11 @@ export class GameParserImpl implements GameParser {
513
509
} ) ;
514
510
515
511
switch ( tagName ) {
512
+ case 'a' :
513
+ // Close the hyperlink because we are at the end of the tag.
514
+ // Example: `<a href='https://elanthipedia.play.net'>Elanthipedia</a>`
515
+ this . gameText += `</a>` ;
516
+ break ;
516
517
case 'component' :
517
518
// Emit the room info because we are at the end of the tag.
518
519
// Example: `<component id='room desc'>The hustle...</component>`
@@ -560,14 +561,6 @@ export class GameParserImpl implements GameParser {
560
561
// Example: `<right>Empty</right>`
561
562
this . emitRightHandGameEvent ( this . consumeGameText ( ) ) ;
562
563
break ;
563
- case 'a' :
564
- // Emit the hyperlink because we are at the end of the tag.
565
- // Example: `<a href='https://elanthipedia.play.net/'>Elanthipedia</a>`
566
- this . emitUrlGameEvent ( {
567
- url : attributes . href ,
568
- text : this . consumeGameText ( ) ,
569
- } ) ;
570
- break ;
571
564
}
572
565
573
566
if ( this . activeTags . length > 0 ) {
@@ -826,16 +819,6 @@ export class GameParserImpl implements GameParser {
826
819
} ) ;
827
820
}
828
821
829
- protected emitUrlGameEvent ( options : { url : string ; text : string } ) : void {
830
- const { url, text } = options ;
831
- this . emitGameEvent ( {
832
- type : GameEventType . URL ,
833
- eventId : uuid ( ) ,
834
- url,
835
- text : unescapeEntities ( text ) ,
836
- } ) ;
837
- }
838
-
839
822
protected emitGameEvent ( gameEvent : GameEvent ) : void {
840
823
logger . trace ( 'emitting game event' , { gameEvent } ) ;
841
824
this . gameEventsSubject$ . next ( gameEvent ) ;
0 commit comments