@@ -288,6 +288,8 @@ export const LOBSTER_PET_CLAW_MULS: Record<LobsterPetClawSize, number> = {
288288const SPOT_ZONES = { left : [ 12 , 38 ] , right : [ 60 , 84 ] } as const ;
289289const ENTER_MS = 450 ;
290290const LEAVE_MS = 350 ;
291+ // One full ledge crossing for pass-through visitors.
292+ const PASSER_CROSS_MS = 11_000 ;
291293
292294export type LobsterPetAnchor = "ledge" | "bar" ;
293295
@@ -360,6 +362,40 @@ export function isLobsterTwinLoad(seed: number): boolean {
360362 return mulberry32 ( ( seed ^ 0x7715 ) >>> 0 ) ( ) < 0.04 ;
361363}
362364
365+ export type LobsterPasserKind = "stranger" | "crab" ;
366+
367+ export type LobsterPasserPlan = {
368+ kind : LobsterPasserKind ;
369+ atMs : number ;
370+ direction : 1 | - 1 ;
371+ } ;
372+
373+ // Once per load, someone else might just... walk through. Strangers are
374+ // other lobsters that never stop; the crab is not a lobster and refuses to
375+ // discuss it. Neither counts for the Lobsterdex.
376+ export function planLobsterPasser ( seed : number ) : LobsterPasserPlan | null {
377+ const rng = mulberry32 ( ( seed ^ 0xcab ) >>> 0 ) ;
378+ const roll = rng ( ) ;
379+ if ( roll >= 0.095 ) {
380+ return null ;
381+ }
382+ const kind : LobsterPasserKind = roll < 0.015 ? "crab" : "stranger" ;
383+ const atMs = Math . round ( 60_000 + rng ( ) * 840_000 ) ;
384+ const direction : 1 | - 1 = rng ( ) < 0.5 ? 1 : - 1 ;
385+ return { kind, atMs, direction } ;
386+ }
387+
388+ // A stranger wears a different palette than the resident pet.
389+ export function strangerLookFor ( seed : number , own : LobsterPetPaletteId ) : LobsterPetLook {
390+ for ( let offset = 1 ; offset <= 24 ; offset ++ ) {
391+ const look = createLobsterPetLook ( ( seed + offset * 7919 ) >>> 0 ) ;
392+ if ( look . palette . id !== own ) {
393+ return look ;
394+ }
395+ }
396+ return createLobsterPetLook ( ( seed + 1 ) >>> 0 ) ;
397+ }
398+
363399// Late-night visitors are always sleepy, whatever their daytime personality.
364400export function isLobsterNightTime ( now : Date = new Date ( ) ) : boolean {
365401 const hour = now . getHours ( ) ;
@@ -644,6 +680,45 @@ const ANTENNAE_SPRITES: Record<LobsterPetAntennae, TemplateResult> = {
644680 ` ,
645681} ;
646682
683+ // Not a lobster. Wide shell, eye stalks, walks sideways across the ledge,
684+ // and the Lobsterdex refuses to acknowledge it.
685+ export function renderCrabSvg ( ) {
686+ return svg `
687+ < svg
688+ class ="lobster-pet__svg "
689+ viewBox ="0 0 120 105 "
690+ preserveAspectRatio ="none "
691+ aria-hidden ="true "
692+ >
693+ < g stroke ="#a63a2e " stroke-width ="4 " stroke-linecap ="round " fill ="none ">
694+ < path d ="M22 78 L8 88 " />
695+ < path d ="M28 88 L16 99 " />
696+ < path d ="M98 78 L112 88 " />
697+ < path d ="M92 88 L104 99 " />
698+ </ g >
699+ < g stroke ="#c44536 " stroke-width ="3.5 " stroke-linecap ="round " fill ="none ">
700+ < path d ="M44 38 L40 24 " />
701+ < path d ="M76 38 L80 24 " />
702+ </ g >
703+ < circle cx ="40 " cy ="22 " r ="4.5 " fill ="#0a1014 " />
704+ < circle cx ="80 " cy ="22 " r ="4.5 " fill ="#0a1014 " />
705+ < circle cx ="41.5 " cy ="20.5 " r ="1.8 " fill ="#ffd166 " />
706+ < circle cx ="81.5 " cy ="20.5 " r ="1.8 " fill ="#ffd166 " />
707+ < ellipse cx ="60 " cy ="70 " rx ="46 " ry ="30 " fill ="#c44536 " />
708+ < ellipse cx ="48 " cy ="60 " rx ="16 " ry ="9 " fill ="#ffffff " opacity ="0.1 " />
709+ < path
710+ d ="M16 58 C2 52 -2 62 4 72 C10 82 20 76 24 66 C26 60 22 58 16 58 Z "
711+ fill ="#d95f4b "
712+ />
713+ < path
714+ d ="M104 58 C118 52 122 62 116 72 C110 82 100 76 96 66 C94 60 98 58 104 58 Z "
715+ fill ="#d95f4b "
716+ />
717+ < path d ="M48 82 Q60 90 72 82 " stroke ="#7e2a20 " stroke-width ="3 " stroke-linecap ="round " fill ="none " />
718+ </ svg >
719+ ` ;
720+ }
721+
647722// Same species as icons.lobster / the dreams-scene sleeper: smooth dome body
648723// with stubby legs, side claws, antennae, and teal-glint eyes.
649724export function renderLobsterSvg (
@@ -738,13 +813,16 @@ export class LobsterPet extends LitElement {
738813 @state ( ) private dismissed = false ;
739814 @state ( ) private grumpy = false ;
740815 @state ( ) private vigil = false ;
816+ @state ( ) private passer : LobsterPasserPlan | null = null ;
741817 @state ( ) private shellVisible = false ;
742818 private shellSpotPct = 50 ;
743819 private shellScale = 2 ;
744820 private molted = false ;
745821 private moltPlanned = false ;
746822 private twinPlanned = false ;
747823 private shellTimer : number | null = null ;
824+ private passerTimer : number | null = null ;
825+ private passerEndTimer : number | null = null ;
748826
749827 private look : LobsterPetLook | null = null ;
750828 private rng : ( ) => number = mulberry32 ( 0 ) ;
@@ -780,13 +858,15 @@ export class LobsterPet extends LitElement {
780858 window . clearTimeout ( this . shellTimer ) ;
781859 this . shellTimer = null ;
782860 }
783- for ( const timer of [ this . vigilTimer , this . holdTimer ] ) {
861+ for ( const timer of [ this . vigilTimer , this . holdTimer , this . passerTimer , this . passerEndTimer ] ) {
784862 if ( timer !== null ) {
785863 window . clearTimeout ( timer ) ;
786864 }
787865 }
788866 this . vigilTimer = null ;
789867 this . holdTimer = null ;
868+ this . passerTimer = null ;
869+ this . passerEndTimer = null ;
790870 document . removeEventListener ( "pointermove" , this . handleGaze ) ;
791871 super . disconnectedCallback ( ) ;
792872 }
@@ -823,6 +903,7 @@ export class LobsterPet extends LitElement {
823903 this . moltPlanned = isLobsterMoltLoad ( this . seed ) ;
824904 this . twinPlanned = isLobsterTwinLoad ( this . seed ) ;
825905 this . scheduleVisits ( ) ;
906+ this . schedulePasser ( ) ;
826907 // The first update takes this branch, so the mode-change branch below
827908 // never sees the initial mode: arm the vigil tracker here as well.
828909 this . vigil = false ;
@@ -1076,6 +1157,34 @@ export class LobsterPet extends LitElement {
10761157 } , stayMs ) ;
10771158 }
10781159
1160+ // ---- Pass-through visitors (strangers and the crab) ----
1161+
1162+ private schedulePasser ( ) {
1163+ for ( const timer of [ this . passerTimer , this . passerEndTimer ] ) {
1164+ if ( timer !== null ) {
1165+ window . clearTimeout ( timer ) ;
1166+ }
1167+ }
1168+ this . passerTimer = null ;
1169+ this . passerEndTimer = null ;
1170+ this . passer = null ;
1171+ const plan = planLobsterPasser ( this . seed ) ;
1172+ if ( ! plan || prefersReducedMotion ( ) ) {
1173+ return ;
1174+ }
1175+ this . passerTimer = window . setTimeout ( ( ) => {
1176+ this . passerTimer = null ;
1177+ if ( ! this . visitsEnabled || document . hidden ) {
1178+ return ;
1179+ }
1180+ this . passer = plan ;
1181+ this . passerEndTimer = window . setTimeout ( ( ) => {
1182+ this . passerEndTimer = null ;
1183+ this . passer = null ;
1184+ } , PASSER_CROSS_MS ) ;
1185+ } , plan . atMs ) ;
1186+ }
1187+
10791188 // Each arrival re-rolls where the pet shows up: the ledge above the footer
10801189 // divider or the free stretch inside the footer bar.
10811190 private rollPerch ( ) {
@@ -1292,13 +1401,44 @@ export class LobsterPet extends LitElement {
12921401 // The shell may outlive the visit while it fades, but dismissal and the
12931402 // visits setting silence it like everything else.
12941403 const showShell = this . shellVisible && this . visitsEnabled && ! this . dismissed ;
1295- if ( ! showSprites && ! showShell ) {
1404+ const showPasser = this . passer !== null && this . visitsEnabled ;
1405+ if ( ! showSprites && ! showShell && ! showPasser ) {
12961406 return nothing ;
12971407 }
12981408 return html `
12991409 ${ showShell ? this . renderShell ( look ) : nothing }
13001410 ${ showSprites ? this . renderSprite ( look , false ) : nothing }
13011411 ${ showSprites && this . twinPlanned ? this . renderSprite ( look , true ) : nothing }
1412+ ${ showPasser && this . passer ? this . renderPasser ( this . passer , look ) : nothing }
1413+ ` ;
1414+ }
1415+
1416+ // A pass-through visitor: crosses the ledge once and is gone. Strangers
1417+ // are other lobsters (never your palette); the crab is, allegedly, also a
1418+ // lobster. Neither perches, neither counts for the Lobsterdex.
1419+ private renderPasser ( passer : LobsterPasserPlan , own : LobsterPetLook ) {
1420+ const crab = passer . kind === "crab" ;
1421+ const look = crab ? own : strangerLookFor ( this . seed , own . palette . id ) ;
1422+ const classes = [
1423+ "lobster-pet" ,
1424+ "lobster-pet--passer" ,
1425+ crab ? "lobster-pet--crab" : `lobster-pet--palette-${ look . palette . id } ` ,
1426+ passer . direction === 1 ? "lobster-pet--passer-ltr" : "lobster-pet--passer-rtl" ,
1427+ ] . join ( " " ) ;
1428+ const style = crab
1429+ ? `--lob-scale:2;--lob-w:1;--lob-h:0.82;--lob-face:1`
1430+ : this . spriteStyle ( look , Math . min ( look . scale , 2 ) , 0 , passer . direction ) ;
1431+ return html `
1432+ < div
1433+ class =${ classes }
1434+ style =${ style }
1435+ aria-hidden="true"
1436+ title=${ crab ? "definitely a lobster" : "a stranger" }
1437+ >
1438+ < div class ="lobster-pet__body ">
1439+ ${ crab ? renderCrabSvg ( ) : renderLobsterSvg ( look , { standalone : true } ) }
1440+ </ div >
1441+ </ div >
13021442 ` ;
13031443 }
13041444}
0 commit comments