11import { expectDefined } from "@openclaw/normalization-core" ;
22import { html , nothing , svg } from "lit" ;
3+ import { fnv1aUtf16 } from "../lib/fnv1a.ts" ;
34import { lobsterHonorific } from "./lobster-dex.ts" ;
45import type {
56 LobsterPasserKind ,
@@ -16,30 +17,31 @@ import type {
1617} from "./lobster-pet-contract.ts" ;
1718import { lobsterPaletteName , lobsterRandomName } from "./lobster-pet-lore.ts" ;
1819import { moonPhaseFraction } from "./lobster-pet-moon.ts" ;
20+ import {
21+ CANONICAL_CHIMERA_PARTS ,
22+ LOBSTER_PALETTE_WEIGHTS ,
23+ chimeraBodyClaw ,
24+ rollChimeraParts ,
25+ } from "./lobster-pet-palettes.ts" ;
26+ import {
27+ ACTUAL_LOBSTER ,
28+ FLATPACK_LOBSTER ,
29+ LOADING_LOBSTER ,
30+ TINFOIL_PARTS ,
31+ } from "./lobster-pet-sprites-wild.ts" ;
1932import {
2033 ACCESSORY_SPRITES ,
2134 ANTENNAE_SPRITES ,
22- AURORA_BANDS ,
2335 BALLOON ,
2436 BINDLE ,
25- BLUEPRINT_MARKS ,
26- CALICO_SPOTS ,
2737 FRECKLE_SPOTS ,
28- GEODE_FACETS ,
29- GLASS_GLINTS ,
3038 GLITCH_GHOSTS ,
3139 GRUMPY_FACE ,
3240 HEADWEAR ,
33- LUMEN_SPOTS ,
34- MAGMA_SEAMS ,
35- MECHA_PLATES ,
36- NEBULA_STARS ,
37- OILSLICK_SHEEN ,
3841 PALETTE_OVERLAYS ,
3942 PASSER_SPRITES ,
4043 PASSER_TITLES ,
4144 PATTERNED_PALETTES ,
42- PHOSPHOR_SCANLINES ,
4345 PIXEL_LOBSTER ,
4446 RETRO_ANTENNAE ,
4547 RETRO_FACE ,
@@ -51,70 +53,18 @@ import {
5153 TAIL_FAN ,
5254} from "./lobster-pet-sprites.ts" ;
5355
54- // Rarity ladder loosely mirrors real lobster genetics: blue ~1 in 2 million,
55- // yellow ~1 in 30 million, tangerine orange ~1 in 30 million, calico ~1 in
56- // 30 million, split two-tone ~1 in 50 million, albino/ghost ~1 in 100 million,
57- // cotton candy ~1 in 100 million. Abyss and lumen are our deep-sea fantasies;
58- // the stranger technical variants are our terminal fantasies. Extra geometry
59- // and styling key off the palette id (see lobster-pet.css and renderLobsterSvg).
60- const PALETTES : Array < [ LobsterPetPalette , number ] > = [
61- [ { id : "crimson" , shell : "#ff4f40" , claw : "#ff775f" } , 26 ] ,
62- [ { id : "coral" , shell : "#d0836a" , claw : "#de9b80" } , 26 ] ,
63- [ { id : "teal" , shell : "#2fbfa7" , claw : "#5cd9c4" } , 10 ] ,
64- [ { id : "violet" , shell : "#9f7dfa" , claw : "#bba4fd" } , 10 ] ,
65- [ { id : "ink" , shell : "#5e6b7a" , claw : "#7b8996" } , 9 ] ,
66- [ { id : "blue" , shell : "#4a7dfc" , claw : "#7fa4ff" } , 7 ] ,
67- [ { id : "gold" , shell : "#f4b840" , claw : "#f9d47a" } , 5 ] ,
68- [ { id : "tangerine" , shell : "#ff8c2e" , claw : "#ffab5c" } , 4 ] ,
69- [ { id : "calico" , shell : "#d97a3d" , claw : "#e89a63" } , 3 ] ,
70- [ { id : "abyss" , shell : "#2c3b68" , claw : "#465b96" } , 2 ] ,
71- // Bioluminescent: photophore freckles that only really glow in the dark
72- // theme (see .lob-lumen in lobster-pet.css).
73- [ { id : "lumen" , shell : "#1d2f4e" , claw : "#2e4a77" } , 2 ] ,
74- [ { id : "magma" , shell : "#241214" , claw : "#3a1d18" } , 2 ] ,
75- [ { id : "oilslick" , shell : "#15171d" , claw : "#23262e" } , 2 ] ,
76- [ { id : "aurora" , shell : "#dce6f0" , claw : "#e9f0f7" } , 2 ] ,
77- [ { id : "nebula" , shell : "#34255c" , claw : "#4a3a7d" } , 2 ] ,
78- [ { id : "banana" , shell : "#f7e27d" , claw : "#f3d55b" } , 2 ] ,
79- // CSS custom properties are the palette color contract, so accent vars stay
80- // intact through every look renderer rather than being parsed as hex values.
81- [ { id : "mood" , shell : "var(--accent, #7f77dd)" , claw : "var(--accent-hover, #9a93e8)" } , 1.5 ] ,
82- [ { id : "bee" , shell : "#f4c531" , claw : "#2b2b23" } , 1.5 ] ,
83- [ { id : "rubberduck" , shell : "#ffd93b" , claw : "#ffb03b" } , 1.5 ] ,
84- [ { id : "clawtron" , shell : "#8d99a6" , claw : "#a2aeba" } , 1 ] ,
85- [ { id : "selene" , shell : "#c9ced8" , claw : "#d8dde5" } , 1 ] ,
86- [ { id : "geode" , shell : "#6b6474" , claw : "#7d7588" } , 1 ] ,
87- [ { id : "ghost" , shell : "#dce8f2" , claw : "#ecf3fa" } , 1 ] ,
88- [ { id : "glass" , shell : "#cfe4f4" , claw : "#e0eef8" } , 1 ] ,
89- [ { id : "split" , shell : "#ff4f40" , claw : "#ff775f" } , 1 ] ,
90- [ { id : "sourdough" , shell : "#d9a662" , claw : "#e6bc82" } , 1 ] ,
91- [ { id : "zombie" , shell : "#9db08a" , claw : "#86a17a" } , 1 ] ,
92- [ { id : "plush" , shell : "#e8967a" , claw : "#f2b09a" } , 1 ] ,
93- // Pastel pink/blue iridescence, after the famous Maine catches.
94- [ { id : "cottoncandy" , shell : "#f6a8c9" , claw : "#a5c6f0" } , 0.8 ] ,
95- [ { id : "disco" , shell : "#b8c4d8" , claw : "#cbd5e6" } , 0.8 ] ,
96- [ { id : "pixel" , shell : "#d84c3e" , claw : "#ef8f6a" } , 0.7 ] ,
97- [ { id : "blueprint" , shell : "#123a66" , claw : "#123a66" } , 0.7 ] ,
98- [ { id : "phosphor" , shell : "#0d2415" , claw : "#0f2b19" } , 0.7 ] ,
99- [ { id : "heisenbug" , shell : "#262a33" , claw : "#343945" } , 0.6 ] ,
100- // CSS values, rather than parsed colors, are the palette contract. Like
101- // mood's var() colors, translucent rgba() values must pass through intact.
102- [ { id : "invisible" , shell : "rgba(127,140,160,0.07)" , claw : "rgba(127,140,160,0.07)" } , 0.55 ] ,
103- // The grail: homage to the classic OpenClaw logo (big raised claw, smirk,
104- // angry brows, white sticker outline). ~0.5% of sessions.
105- [ { id : "retro" , shell : "#e8262c" , claw : "#f04a3e" } , 0.5 ] ,
106- [ { id : "goldenretro" , shell : "#e8b422" , claw : "#f6cf5a" } , 0.1 ] ,
107- ] ;
56+ export { LOBSTER_PET_PALETTES } from "./lobster-pet-palettes.ts" ;
10857
10958const RETRO_GEOMETRY_PALETTES : ReadonlySet < LobsterPetPaletteId > = new Set ( [ "retro" , "goldenretro" ] ) ;
11059
111- // Catalog order for collection UIs (Lobsterdex): common to grail.
112- export const LOBSTER_PET_PALETTES : readonly LobsterPetPalette [ ] = PALETTES . map (
113- ( [ palette ] ) => palette ,
114- ) ;
60+ const PALETTE_FRAME_CLASSES : Partial < Record < LobsterPetPaletteId , string > > = {
61+ heisenbug : "lob-heisenbug-frame" ,
62+ cryptid : "lob-cryptid-frame" ,
63+ } ;
11564
11665// A neutral look used to render catalog minis outside the pet lifecycle.
11766export function canonicalLobsterLook ( palette : LobsterPetPalette ) : LobsterPetLook {
67+ const paletteHash = fnv1aUtf16 ( palette . id ) ;
11868 return {
11969 palette,
12070 scale : 2 ,
@@ -124,14 +74,15 @@ export function canonicalLobsterLook(palette: LobsterPetPalette): LobsterPetLook
12474 spotPct : 0 ,
12575 facing : 1 ,
12676 personality : "friendly" ,
127- blinkDelayS : 0 ,
77+ blinkDelayS : ( paletteHash % 36 ) / 10 ,
12878 build : "round" ,
12979 clawSize : "regular" ,
13080 tailFan : false ,
13181 shiny : false ,
13282 crusherSide : null ,
13383 freckles : false ,
13484 glint : null ,
85+ chimeraParts : palette . id === "chimera" ? CANONICAL_CHIMERA_PARTS : null ,
13586 } ;
13687}
13788
@@ -199,7 +150,7 @@ const CLAW_SIZES: Array<[LobsterPetClawSize, number]> = [
199150// rare-variant geometry stay aligned for every silhouette.
200151const LOBSTER_PET_BUILD_MULS : Record < LobsterPetBuild , { w : number ; h : number } > = {
201152 round : { w : 1 , h : 1 } ,
202- squat : { w : 1.14 , h : 0.9 } ,
153+ squat : { w : 1.14 , h : 0.94 } ,
203154 slender : { w : 0.88 , h : 1.1 } ,
204155} ;
205156
@@ -257,7 +208,7 @@ const GLINT_TINTS = ["#ffd166", "#ff8ac2", "#b79bff"] as const;
257208
258209export function createLobsterPetLook ( seed : number , now : Date = new Date ( ) ) : LobsterPetLook {
259210 const rng = mulberry32 ( seed ) ;
260- const palette = pickWeighted ( rng , PALETTES ) ;
211+ const palette = pickWeighted ( rng , LOBSTER_PALETTE_WEIGHTS ) ;
261212 const scale = pickWeighted ( rng , SCALES ) ;
262213 const accessory = pickWeighted ( rng , [ ...ACCESSORIES , ...seasonalAccessories ( now ) ] ) ;
263214 const antennae : LobsterPetAntennae = rng ( ) < 0.6 ? "perky" : "droopy" ;
@@ -282,6 +233,10 @@ export function createLobsterPetLook(seed: number, now: Date = new Date()): Lobs
282233 const glintRoll = rng ( ) ;
283234 const glintPick = GLINT_TINTS [ Math . floor ( rng ( ) * GLINT_TINTS . length ) ] ?? null ;
284235 const glint = glintRoll < 0.3 ? glintPick : null ;
236+ // Append-only trait discipline: always burn all four distinct donor rolls,
237+ // then expose them only for Chimera so older seeded traits never shift.
238+ const rolledChimeraParts = rollChimeraParts ( rng ) ;
239+ const chimeraParts = palette . id === "chimera" ? rolledChimeraParts : null ;
285240 const look : LobsterPetLook = {
286241 palette,
287242 scale,
@@ -299,6 +254,7 @@ export function createLobsterPetLook(seed: number, now: Date = new Date()): Lobs
299254 crusherSide,
300255 freckles,
301256 glint,
257+ chimeraParts,
302258 } ;
303259 // The LED rides the perky antenna tip. Keep the original antenna roll above
304260 // so adding Clawtron does not shift any later seeded trait.
@@ -310,8 +266,13 @@ export function createLobsterPetLook(seed: number, now: Date = new Date()): Lobs
310266 }
311267 if ( isLobsterAnniversary ( now ) ) {
312268 // Birthday dress code: everyone is the classic logo, party hats on.
313- const retro = PALETTES . find ( ( [ entry ] ) => entry . id === "retro" ) ?. [ 0 ] ;
314- return { ...preparedLook , palette : retro ?? palette , accessory : "party" } ;
269+ const retro = LOBSTER_PALETTE_WEIGHTS . find ( ( [ entry ] ) => entry . id === "retro" ) ?. [ 0 ] ;
270+ return {
271+ ...preparedLook ,
272+ palette : retro ?? palette ,
273+ accessory : "party" ,
274+ chimeraParts : null ,
275+ } ;
315276 }
316277 return preparedLook ;
317278}
@@ -330,6 +291,9 @@ export function renderLobsterSvg(
330291 } = { } ,
331292) {
332293 const isPixel = look . palette . id === "pixel" ;
294+ const isFlatpack = look . palette . id === "flatpack" ;
295+ const isLoading = look . palette . id === "loading" ;
296+ const isActual = look . palette . id === "actual" ;
333297 const hasRetroGeometry = RETRO_GEOMETRY_PALETTES . has ( look . palette . id ) ;
334298 const openEyeStyle = options . shell || options . sleeping ? "display:none" : "" ;
335299 const closedEyeStyle =
@@ -342,11 +306,17 @@ export function renderLobsterSvg(
342306 preserveAspectRatio ="none "
343307 aria-hidden ="true "
344308 >
345- < g class =${ look . palette . id === "heisenbug" ? "lob-heisenbug-frame" : "" } >
309+ < g class =${ PALETTE_FRAME_CLASSES [ look . palette . id ] ?? "" } >
346310 ${
347- isPixel
348- ? PIXEL_LOBSTER ( openEyeStyle , closedEyeStyle )
349- : svg `
311+ isFlatpack
312+ ? FLATPACK_LOBSTER ( openEyeStyle , closedEyeStyle )
313+ : isLoading
314+ ? LOADING_LOBSTER ( openEyeStyle , closedEyeStyle )
315+ : isActual
316+ ? ACTUAL_LOBSTER ( openEyeStyle , closedEyeStyle )
317+ : isPixel
318+ ? PIXEL_LOBSTER ( openEyeStyle , closedEyeStyle )
319+ : svg `
350320 ${ hasRetroGeometry ? RETRO_ANTENNAE : ANTENNAE_SPRITES [ look . antennae ] }
351321 ${ look . tailFan ? TAIL_FAN : nothing }
352322 < g class ="lob-claw lob-claw--l ">
@@ -358,21 +328,15 @@ export function renderLobsterSvg(
358328 : svg `< g class ="lob-claw lob-claw--r "> < path d ="M100 42 C115 37 120 47 115 57 C110 67 100 62 95 52 C92 45 95 42 100 42 Z " fill ="var(--lob-claw) " /> </ g > `
359329 }
360330 ${ look . palette . id === "heisenbug" ? GLITCH_GHOSTS : nothing }
361- < path d ="M60 8 C32 8 16 32 16 52 C16 72 30 90 44 95 L44 104 L54 104 L54 96 C58 97.5 62 97.5 66 96 L66 104 L76 104 L76 95 C90 90 104 72 104 52 C104 32 88 8 60 8 Z " fill ="var(--lob-shell) " />
331+ < path class =" lob-standard-dome " d ="M60 8 C32 8 16 32 16 52 C16 72 30 90 44 95 L44 104 L54 104 L54 96 C58 97.5 62 97.5 66 96 L66 104 L76 104 L76 95 C90 90 104 72 104 52 C104 32 88 8 60 8 Z " fill ="var(--lob-shell) " />
362332 ${ look . palette . id === "split" || look . palette . id === "geode" ? SPLIT_HALF : nothing }
363- ${ look . palette . id === "calico" ? CALICO_SPOTS : nothing }
364- ${ look . palette . id === "lumen" ? LUMEN_SPOTS : nothing }
365- ${ look . palette . id === "magma" ? MAGMA_SEAMS : nothing }
366- ${ look . palette . id === "oilslick" ? OILSLICK_SHEEN : nothing }
367- ${ look . palette . id === "aurora" ? AURORA_BANDS : nothing }
368- ${ look . palette . id === "nebula" ? NEBULA_STARS : nothing }
369- ${ look . palette . id === "glass" ? GLASS_GLINTS : nothing }
370- ${ look . palette . id === "geode" ? GEODE_FACETS : nothing }
371- ${ look . palette . id === "phosphor" ? PHOSPHOR_SCANLINES : nothing }
372- ${ look . palette . id === "blueprint" ? BLUEPRINT_MARKS : nothing }
373- ${ look . palette . id === "clawtron" ? MECHA_PLATES : nothing }
374333 ${ look . palette . id === "selene" ? SELENE_MOON ( selenePhase ) : nothing }
375334 ${ PALETTE_OVERLAYS [ look . palette . id ] ?? nothing }
335+ ${
336+ look . palette . id === "tinfoil"
337+ ? TINFOIL_PARTS ( ! HEADWEAR . has ( look . accessory ) )
338+ : nothing
339+ }
376340 ${ look . freckles && ! PATTERNED_PALETTES . has ( look . palette . id ) ? FRECKLE_SPOTS : nothing }
377341 ${ look . palette . id === "invisible" ? nothing : svg `< ellipse cx ="48 " cy ="28 " rx ="20 " ry ="11 " fill ="#ffffff " opacity ="0.1 " /> ` }
378342 < g class ="lob-eye-open " style =${ openEyeStyle } >
@@ -399,13 +363,31 @@ export function renderLobsterSvg(
399363 `
400364 : nothing
401365 }
402- ${ options . grumpy && ! hasRetroGeometry ? GRUMPY_FACE : nothing }
403- ${ look . accessory === "none" || options . shell ? nothing : ACCESSORY_SPRITES [ look . accessory ] }
366+ ${
367+ options . grumpy && ! hasRetroGeometry && ! isFlatpack && ! isLoading && ! isActual
368+ ? GRUMPY_FACE
369+ : nothing
370+ }
371+ ${
372+ look . accessory === "none" || options . shell || isFlatpack
373+ ? nothing
374+ : ACCESSORY_SPRITES [ look . accessory ]
375+ }
404376 ${
405377 // The retro grail's mega claw owns the same shoulder; it moves light.
406- options . bindle && ! hasRetroGeometry ? BINDLE : nothing
378+ options . bindle && ! hasRetroGeometry && ! isFlatpack ? BINDLE : nothing
379+ }
380+ ${
381+ // The foil hat is palette identity; Mulder declines the navy-issued
382+ // sailor cap rather than stacking two hats on lobster days.
383+ options . sailorCap &&
384+ ! options . shell &&
385+ ! isFlatpack &&
386+ ! HEADWEAR . has ( look . accessory ) &&
387+ look . palette . id !== "tinfoil"
388+ ? SAILOR_CAP
389+ : nothing
407390 }
408- ${ options . sailorCap && ! options . shell && ! HEADWEAR . has ( look . accessory ) ? SAILOR_CAP : nothing }
409391 </ g >
410392 </ svg >
411393 ` ;
@@ -419,24 +401,39 @@ export const SPOT_ZONES = { left: [12, 38], right: [60, 84] } as const;
419401// offline overrides in lobster-pet.css still out-cascade it.
420402function lobsterLookStyleVars ( look : LobsterPetLook ) : string [ ] {
421403 const crusher = look . crusherSide ;
404+ const paletteHash = fnv1aUtf16 ( look . palette . id ) ;
405+ const breatheDelayS = ( ( paletteHash >>> 8 ) % 34 ) / 10 ;
406+ const bodyDonorClaw = look . chimeraParts ? chimeraBodyClaw ( look . chimeraParts . body ) : undefined ;
422407 const clawMul = ( side : "left" | "right" ) =>
423408 crusher === null
424409 ? LOBSTER_PET_CLAW_MULS [ look . clawSize ]
425410 : crusher === side
426411 ? LOBSTER_PET_CLAW_MULS . mighty
427412 : LOBSTER_PET_CLAW_MULS . dainty ;
428413 return [
429- `--lob-shell:${ look . palette . shell } ` ,
430- `--lob-claw:${ look . palette . claw } ` ,
414+ `--lob-shell:${ look . chimeraParts ?. body ?? look . palette . shell } ` ,
415+ `--lob-claw:${ bodyDonorClaw ?? look . palette . claw } ` ,
431416 `--lob-blink-delay:${ look . blinkDelayS } s` ,
417+ `--lob-breathe-delay:-${ breatheDelayS } s` ,
432418 `--lob-w:${ LOBSTER_PET_BUILD_MULS [ look . build ] . w } ` ,
433419 `--lob-h:${ LOBSTER_PET_BUILD_MULS [ look . build ] . h } ` ,
434420 `--lob-claw-l:${ clawMul ( "left" ) } ` ,
435421 `--lob-claw-r:${ clawMul ( "right" ) } ` ,
422+ ...( look . chimeraParts
423+ ? [
424+ `--lob-chimera-l:${ look . chimeraParts . clawLeft } ` ,
425+ `--lob-chimera-r:${ look . chimeraParts . clawRight } ` ,
426+ `--lob-antennae-color:${ look . chimeraParts . antennae } ` ,
427+ ]
428+ : [ ] ) ,
436429 ...( look . glint ? [ `--lob-glint-seed:${ look . glint } ` ] : [ ] ) ,
437430 ] ;
438431}
439432
433+ export function lobsterLookStyle ( look : LobsterPetLook ) : string {
434+ return lobsterLookStyleVars ( look ) . join ( ";" ) ;
435+ }
436+
440437function lobsterPetSpriteStyle (
441438 look : LobsterPetLook ,
442439 scale : number ,
0 commit comments