@linxin666/dsh-pet 0.4.7 → 0.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.i18n.yaml +2 -2
- package/README.md +8 -2
- package/README.zh.md +8 -2
- package/contracts/voice-pack-v1.schema.json +27 -0
- package/lib/client.js +144 -68
- package/lib/client.js.map +1 -1
- package/lib/index.js +160 -28
- package/lib/types/affinity.d.ts +26 -3
- package/lib/types/affinity.d.ts.map +1 -1
- package/lib/types/affinity.js +27 -4
- package/lib/types/client/PetDockEntry.d.ts +5 -0
- package/lib/types/client/PetDockEntry.d.ts.map +1 -1
- package/lib/types/client/PetDockEntry.js +1 -1
- package/lib/types/client/PetSprite.d.ts +11 -4
- package/lib/types/client/PetSprite.d.ts.map +1 -1
- package/lib/types/client/PetSprite.js +120 -58
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/index.js +15 -1
- package/lib/types/client/sequences.d.ts +9 -2
- package/lib/types/client/sequences.d.ts.map +1 -1
- package/lib/types/client/sequences.js +25 -14
- package/lib/types/client/spritesheet.d.ts +22 -1
- package/lib/types/client/spritesheet.d.ts.map +1 -1
- package/lib/types/client/spritesheet.js +26 -2
- package/lib/types/index.d.ts +1 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/ledger.d.ts +10 -1
- package/lib/types/ledger.d.ts.map +1 -1
- package/lib/types/ledger.js +11 -1
- package/lib/types/pair-access.d.ts.map +1 -1
- package/lib/types/pair-access.js +26 -3
- package/lib/types/service.d.ts +14 -12
- package/lib/types/service.d.ts.map +1 -1
- package/lib/types/service.js +22 -17
- package/lib/types/voice-pack.d.ts +20 -1
- package/lib/types/voice-pack.d.ts.map +1 -1
- package/lib/types/voice-pack.js +86 -3
- package/package.json +24 -24
- package/src/affinity.test.ts +42 -0
- package/src/affinity.ts +46 -3
- package/src/client/PetDockEntry.tsx +6 -0
- package/src/client/PetSprite.test.tsx +304 -26
- package/src/client/PetSprite.tsx +123 -58
- package/src/client/index.test.tsx +4 -0
- package/src/client/index.ts +15 -1
- package/src/client/pet-css.test.ts +12 -0
- package/src/client/pet.module.css +9 -3
- package/src/client/sequences.test.ts +37 -1
- package/src/client/sequences.ts +42 -16
- package/src/client/spritesheet.test.ts +81 -0
- package/src/client/spritesheet.ts +27 -2
- package/src/index.ts +2 -0
- package/src/ledger.test.ts +19 -0
- package/src/ledger.ts +15 -1
- package/src/pair-access.ts +26 -3
- package/src/registry.test.ts +2 -1
- package/src/service.test.ts +61 -0
- package/src/service.ts +27 -18
- package/src/voice-pack.test.ts +112 -0
- package/src/voice-pack.ts +101 -3
|
@@ -14,7 +14,7 @@ import { createPortal } from 'react-dom';
|
|
|
14
14
|
import clsx from 'clsx';
|
|
15
15
|
import { bubbleScaleFor } from "../persist.js";
|
|
16
16
|
import { announcementFresh } from "../announce.js";
|
|
17
|
-
import { framePosition, rowOfTrack, trimTrack } from "./spritesheet.js";
|
|
17
|
+
import { framePosition, rowOfTrack, scaledCellSize, trimTrack } from "./spritesheet.js";
|
|
18
18
|
import { createSequenceTimeline } from "./sequences.js";
|
|
19
19
|
import { animationForPhase } from "../state.js";
|
|
20
20
|
import styles from './pet.module.css';
|
|
@@ -132,10 +132,12 @@ function UsageAnnouncementBubble(props) {
|
|
|
132
132
|
return (_jsxs("div", { className: clsx(styles.bubble, styles.bubbleUsage, tone), role: "status", "aria-live": "polite", "data-dsh-pet-announcement": announcement.source, children: [_jsxs("span", { className: styles.bubbleUsageHead, children: [_jsx("span", { className: styles.bubbleUsageTitle, children: announcement.title }), (announcement.kind === 'balance' || announcement.kind === 'cost') && announcement.amount !== undefined && (_jsx("span", { className: styles.bubbleUsageValue, children: announcement.amount })), announcement.kind === 'plan' && announcement.percent !== undefined && (_jsx("span", { className: styles.bubbleUsageValue, children: Math.round(announcement.percent) + '%' }))] }), announcement.kind === 'plan' && announcement.percent !== undefined && (_jsx("span", { className: styles.bubbleUsageMeter, children: _jsx("span", { className: styles.bubbleUsageMeterFill, style: { width: Math.min(100, Math.max(0, announcement.percent)) + '%' } }) })), announcement.note !== undefined && (_jsx("span", { className: styles.bubbleUsageNote, children: announcement.note }))] }));
|
|
133
133
|
}
|
|
134
134
|
/**
|
|
135
|
-
* The floating pet. The spritesheet frame advances on
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
135
|
+
* The floating pet. The spritesheet frame advances on a timer scheduled for the
|
|
136
|
+
* current frame's remaining time (per-frame durations come from the
|
|
137
|
+
* definition's tracks), so the loop wakes once per frame change instead of once
|
|
138
|
+
* per screen refresh; the atlas image is loaded once and the background
|
|
139
|
+
* position is written straight to the sprite element (no per-frame React
|
|
140
|
+
* state). Roaming writes the sprite's position the same way (issue #17).
|
|
139
141
|
*/
|
|
140
142
|
export function PetSprite(props) {
|
|
141
143
|
const { snapshot, definition, display, feedback } = props;
|
|
@@ -182,6 +184,22 @@ export function PetSprite(props) {
|
|
|
182
184
|
// formats carry {rank}/{n}/{points} placeholders the host validated.
|
|
183
185
|
const panel = definition.panel;
|
|
184
186
|
const panelLabel = (slot, i18n) => panel?.labels?.[slot] ?? i18n;
|
|
187
|
+
// The active rank name is display-only: a pet-declared ladder may carry an
|
|
188
|
+
// English variant, while built-in names still resolve through the i18n
|
|
189
|
+
// dictionary. `lang` is handed down by the mount; the document language is
|
|
190
|
+
// the direct-mount/test fallback.
|
|
191
|
+
const englishUi = (props.lang ?? (typeof document === 'undefined' ? 'zh' : document.documentElement.lang))
|
|
192
|
+
.toLowerCase()
|
|
193
|
+
.startsWith('en');
|
|
194
|
+
const rankNameOf = () => {
|
|
195
|
+
const rawRank = snapshot?.affinity.rank ?? '?';
|
|
196
|
+
const rankEn = snapshot?.affinity.rankEn;
|
|
197
|
+
if (englishUi && rankEn !== undefined)
|
|
198
|
+
return rankEn;
|
|
199
|
+
const rankKey = `pet.rank.name.${rawRank}`;
|
|
200
|
+
const localized = props.t(rankKey);
|
|
201
|
+
return localized !== rankKey ? localized : rawRank;
|
|
202
|
+
};
|
|
185
203
|
const panelStat = (slot, i18nKey, values) => {
|
|
186
204
|
const format = panel?.stats?.[slot] ?? props.t(i18nKey, values);
|
|
187
205
|
if (panel?.stats?.[slot] === undefined)
|
|
@@ -189,8 +207,10 @@ export function PetSprite(props) {
|
|
|
189
207
|
// The host whitelists {rank}/{n}/{points} in every stat slot, so a pack
|
|
190
208
|
// format may reference any of them; substitute all three live values
|
|
191
209
|
// (the slot's own value plus the siblings) instead of only the slot's.
|
|
210
|
+
// {rank} carries the effective name, so a pet ladder's English variant
|
|
211
|
+
// also reaches a custom stat format.
|
|
192
212
|
const all = {
|
|
193
|
-
rank:
|
|
213
|
+
rank: values.rank !== undefined ? values.rank : rankNameOf(),
|
|
194
214
|
n: snapshot?.treats.stocked ?? 0,
|
|
195
215
|
points: snapshot?.affinity.points ?? 0,
|
|
196
216
|
};
|
|
@@ -252,6 +272,10 @@ export function PetSprite(props) {
|
|
|
252
272
|
const animation = snapshot?.animation ?? 'idle';
|
|
253
273
|
const scaleRef = useRef(spriteScale);
|
|
254
274
|
scaleRef.current = spriteScale;
|
|
275
|
+
// The frame the loop painted last. A settled non-looping track leaves the
|
|
276
|
+
// loop stopped, so a later scale change repaints it from here instead of
|
|
277
|
+
// waking the loop.
|
|
278
|
+
const paintedRef = useRef(null);
|
|
255
279
|
useEffect(() => {
|
|
256
280
|
if (props.visual !== undefined)
|
|
257
281
|
return;
|
|
@@ -273,36 +297,48 @@ export function PetSprite(props) {
|
|
|
273
297
|
const leadAnimation = sequence?.[0] ?? animation;
|
|
274
298
|
const row = rowOfTrack(leadAnimation);
|
|
275
299
|
const track = trimTrack(tracks[leadAnimation], rows[row] ?? tracks[leadAnimation].frames.length);
|
|
300
|
+
// Write one frame's offset to the sprite element, skipping the assignment
|
|
301
|
+
// when the coordinates did not change. lastPosStr is the cache the whole
|
|
302
|
+
// loop shares, so a tick that changes nothing costs no style write.
|
|
303
|
+
let lastPosStr = '';
|
|
304
|
+
const paint = (frameRow, col) => {
|
|
305
|
+
paintedRef.current = { row: frameRow, col };
|
|
306
|
+
const pos = framePosition(cell, frameRow, col, scaleRef.current);
|
|
307
|
+
const posStr = pos.x + 'px ' + pos.y + 'px';
|
|
308
|
+
if (posStr === lastPosStr)
|
|
309
|
+
return;
|
|
310
|
+
lastPosStr = posStr;
|
|
311
|
+
if (spriteRef.current !== null) {
|
|
312
|
+
spriteRef.current.style.backgroundPosition = posStr;
|
|
313
|
+
}
|
|
314
|
+
};
|
|
276
315
|
// Paint one static sprite frame up front either way, so the pet is never
|
|
277
316
|
// blank while the loop heat-up runs.
|
|
278
|
-
|
|
279
|
-
const lead = framePosition(cell, row, leadCol, scaleRef.current);
|
|
280
|
-
let lastPosStr = lead.x + 'px ' + lead.y + 'px';
|
|
281
|
-
if (spriteRef.current !== null) {
|
|
282
|
-
spriteRef.current.style.backgroundPosition = lastPosStr;
|
|
283
|
-
}
|
|
317
|
+
paint(row, track.frames[0]);
|
|
284
318
|
if (reduceMotion)
|
|
285
319
|
return;
|
|
286
|
-
let
|
|
320
|
+
let timer = 0;
|
|
287
321
|
let last = performance.now();
|
|
288
322
|
let sequenceElapsed = 0;
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
323
|
+
// Sleep to the next frame boundary instead of waking on every screen
|
|
324
|
+
// refresh: track durations are 300-700 ms, so a 60 Hz loop spent the vast
|
|
325
|
+
// majority of its ticks proving that nothing had changed -- the same rule
|
|
326
|
+
// StatusOrnament already follows. A late wake (throttled tab, jank) still
|
|
327
|
+
// catches up every due frame, so the track keeps its own clock.
|
|
328
|
+
const schedule = (delay) => {
|
|
329
|
+
timer = window.setTimeout(tick, Math.max(1, delay));
|
|
330
|
+
};
|
|
331
|
+
const tick = () => {
|
|
332
|
+
timer = 0;
|
|
333
|
+
const now = performance.now();
|
|
334
|
+
const delta = now - last;
|
|
335
|
+
last = now;
|
|
292
336
|
if (timeline !== undefined && sequenceItems !== undefined) {
|
|
293
337
|
sequenceElapsed += delta;
|
|
294
338
|
const current = timeline.frameAt(sequenceElapsed);
|
|
295
339
|
const item = sequenceItems.get(current.animation);
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
const posStr = pos.x + 'px ' + pos.y + 'px';
|
|
299
|
-
if (posStr !== lastPosStr) {
|
|
300
|
-
lastPosStr = posStr;
|
|
301
|
-
if (spriteRef.current !== null) {
|
|
302
|
-
spriteRef.current.style.backgroundPosition = posStr;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
raf = requestAnimationFrame(tick);
|
|
340
|
+
paint(item.row, item.track.frames[current.frameIndex]);
|
|
341
|
+
schedule(timeline.remainingAt(sequenceElapsed));
|
|
306
342
|
return;
|
|
307
343
|
}
|
|
308
344
|
// row/track come from the effect scope: they were computed once above
|
|
@@ -321,28 +357,32 @@ export function PetSprite(props) {
|
|
|
321
357
|
st.index += 1;
|
|
322
358
|
}
|
|
323
359
|
if (st.elapsed >= (track.durations[st.index] ?? 0)) {
|
|
324
|
-
if (track.loop) {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
const col = track.frames[st.index];
|
|
333
|
-
const pos = framePosition(cell, row, col, scaleRef.current);
|
|
334
|
-
const posStr = pos.x + 'px ' + pos.y + 'px';
|
|
335
|
-
if (posStr !== lastPosStr) {
|
|
336
|
-
lastPosStr = posStr;
|
|
337
|
-
if (spriteRef.current !== null) {
|
|
338
|
-
spriteRef.current.style.backgroundPosition = posStr;
|
|
360
|
+
if (!track.loop) {
|
|
361
|
+
// Hold the final frame; the host owns the switch to the fallback, so
|
|
362
|
+
// stop scheduling instead of re-painting the same frame forever.
|
|
363
|
+
st.index = maxIndex;
|
|
364
|
+
paint(row, track.frames[st.index]);
|
|
365
|
+
return;
|
|
339
366
|
}
|
|
367
|
+
st.elapsed = 0;
|
|
368
|
+
st.index = 0;
|
|
340
369
|
}
|
|
341
|
-
|
|
370
|
+
paint(row, track.frames[st.index]);
|
|
371
|
+
schedule((track.durations[st.index] ?? 0) - st.elapsed);
|
|
342
372
|
};
|
|
343
|
-
|
|
344
|
-
return () =>
|
|
373
|
+
schedule(0);
|
|
374
|
+
return () => window.clearTimeout(timer);
|
|
345
375
|
}, [animation, phase, cell, columns, rows, tracks, sequences, props.visual]);
|
|
376
|
+
// A stopped loop is woken by nothing, so a sprite scale change repaints the
|
|
377
|
+
// frame it settled on: without this a resized pet would keep the old scale's
|
|
378
|
+
// cell offsets and show a neighbouring cell until the track changed.
|
|
379
|
+
useLayoutEffect(() => {
|
|
380
|
+
const painted = paintedRef.current;
|
|
381
|
+
if (props.visual !== undefined || painted === null || spriteRef.current === null)
|
|
382
|
+
return;
|
|
383
|
+
const pos = framePosition(cell, painted.row, painted.col, spriteScale);
|
|
384
|
+
spriteRef.current.style.backgroundPosition = pos.x + 'px ' + pos.y + 'px';
|
|
385
|
+
}, [spriteScale, cell, props.visual]);
|
|
346
386
|
// Auto-clear the feedback bubble after its CSS animation. The callback
|
|
347
387
|
// rides a ref so re-renders never reset the timer: the 2s poll rebuilds
|
|
348
388
|
// `props` every tick, and depending on it would starve the timeout.
|
|
@@ -371,10 +411,13 @@ export function PetSprite(props) {
|
|
|
371
411
|
const onPointerDown = (e) => {
|
|
372
412
|
if (props.dragDisabled === true)
|
|
373
413
|
return;
|
|
414
|
+
// Read the live position before ending a walk: the walk keeps it in a ref
|
|
415
|
+
// rather than React state, so a drag grabbed mid-walk starts where the pet
|
|
416
|
+
// actually is instead of snapping back to where the walk began.
|
|
417
|
+
const current = walkTargetRef.current ?? dragPosRef.current ?? { right: display.right, bottom: display.bottom };
|
|
374
418
|
endWalk(false);
|
|
375
419
|
e.preventDefault();
|
|
376
420
|
e.target.setPointerCapture?.(e.pointerId);
|
|
377
|
-
const current = dragPos ?? { right: display.right, bottom: display.bottom };
|
|
378
421
|
dragRef.current = { startX: e.clientX, startY: e.clientY, ...current };
|
|
379
422
|
draggedRef.current = false;
|
|
380
423
|
setHovered(false);
|
|
@@ -403,9 +446,6 @@ export function PetSprite(props) {
|
|
|
403
446
|
if (dragPos !== null)
|
|
404
447
|
props.onDragEnd(dragPos.right, dragPos.bottom);
|
|
405
448
|
};
|
|
406
|
-
const pos = dragPos ?? { right: display.right, bottom: display.bottom };
|
|
407
|
-
const spriteWidth = Math.round(cell.width * spriteScale);
|
|
408
|
-
const spriteHeight = Math.round(cell.height * spriteScale);
|
|
409
449
|
// --- roaming ---------------------------------------------------------
|
|
410
450
|
// The gameplay HUD rolls when the pet may wander; this side owns the motion
|
|
411
451
|
// (clamped to the viewport), the walk art's facing and the persisted resting
|
|
@@ -414,9 +454,22 @@ export function PetSprite(props) {
|
|
|
414
454
|
// the side view); every other track stays unmirrored.
|
|
415
455
|
const [facingRight, setFacingRight] = useState(false);
|
|
416
456
|
const walkRafRef = useRef(0);
|
|
457
|
+
// Live position while a walk is in flight. The walk writes the element's
|
|
458
|
+
// right/bottom directly and mirrors them here instead of calling setState:
|
|
459
|
+
// a walk is 1-3 s of 60 fps motion, and each frame used to re-render the
|
|
460
|
+
// whole sprite tree (bubble stack, dock panel) for a position the DOM already
|
|
461
|
+
// knew. Keeping it in a ref means a render that lands mid-walk (a poll, a
|
|
462
|
+
// hover) still sees where the sprite actually is (issue #17).
|
|
417
463
|
const walkTargetRef = useRef(null);
|
|
418
464
|
const dragPosRef = useRef(dragPos);
|
|
419
465
|
dragPosRef.current = dragPos;
|
|
466
|
+
const pos = walkTargetRef.current ?? dragPos ?? { right: display.right, bottom: display.bottom };
|
|
467
|
+
// One integral cell size for the sprite box, the atlas grid and every frame
|
|
468
|
+
// offset: background-size is this size times the column/row count, so the
|
|
469
|
+
// scaled atlas shares a pixel grid with the box that shows one cell (#17).
|
|
470
|
+
const scaled = scaledCellSize(cell, spriteScale);
|
|
471
|
+
const spriteWidth = scaled.width;
|
|
472
|
+
const spriteHeight = scaled.height;
|
|
420
473
|
/** Stop an active walk; `persist` lands the pet on the spot it reached. */
|
|
421
474
|
const endWalk = (persist) => {
|
|
422
475
|
if (walkRafRef.current === 0)
|
|
@@ -426,7 +479,13 @@ export function PetSprite(props) {
|
|
|
426
479
|
setFacingRight(false);
|
|
427
480
|
const settled = walkTargetRef.current;
|
|
428
481
|
walkTargetRef.current = null;
|
|
429
|
-
if (
|
|
482
|
+
if (settled === null)
|
|
483
|
+
return;
|
|
484
|
+
// Hand the reached spot back to React state: the walk's own frames never
|
|
485
|
+
// updated it, and a render (or a drag that starts here) would otherwise
|
|
486
|
+
// put the sprite back where the walk began.
|
|
487
|
+
setDragPos(settled);
|
|
488
|
+
if (persist)
|
|
430
489
|
props.onDragEnd(settled.right, settled.bottom);
|
|
431
490
|
};
|
|
432
491
|
useEffect(() => {
|
|
@@ -474,7 +533,15 @@ export function PetSprite(props) {
|
|
|
474
533
|
bottom: current.bottom + (target.bottom - current.bottom) * t,
|
|
475
534
|
};
|
|
476
535
|
walkTargetRef.current = next;
|
|
477
|
-
|
|
536
|
+
// The position goes straight to the element: a walk is the one motion
|
|
537
|
+
// that moved every frame, and a setState here re-rendered the bubble
|
|
538
|
+
// stack and the dock panel for a value the DOM already knew (issue
|
|
539
|
+
// #17). React state takes over once, on the landing frame.
|
|
540
|
+
const el = floatRef.current;
|
|
541
|
+
if (el !== null) {
|
|
542
|
+
el.style.right = next.right + 'px';
|
|
543
|
+
el.style.bottom = next.bottom + 'px';
|
|
544
|
+
}
|
|
478
545
|
if (t < 1) {
|
|
479
546
|
walkRafRef.current = window.requestAnimationFrame(step);
|
|
480
547
|
return;
|
|
@@ -482,6 +549,7 @@ export function PetSprite(props) {
|
|
|
482
549
|
walkRafRef.current = 0;
|
|
483
550
|
walkTargetRef.current = null;
|
|
484
551
|
setFacingRight(false);
|
|
552
|
+
setDragPos(next);
|
|
485
553
|
props.onDragEnd(next.right, next.bottom);
|
|
486
554
|
};
|
|
487
555
|
walkRafRef.current = window.requestAnimationFrame(step);
|
|
@@ -606,7 +674,7 @@ export function PetSprite(props) {
|
|
|
606
674
|
...(props.visual === undefined
|
|
607
675
|
? {
|
|
608
676
|
backgroundImage: imageReady ? 'url(' + definition.atlasUrl + ')' : undefined,
|
|
609
|
-
backgroundSize: (
|
|
677
|
+
backgroundSize: (scaled.width * columns) + 'px ' + (scaled.height * (definition.atlasRows ?? rows.length)) + 'px',
|
|
610
678
|
backgroundRepeat: 'no-repeat',
|
|
611
679
|
backgroundPosition: '0 0',
|
|
612
680
|
}
|
|
@@ -676,13 +744,7 @@ export function PetSprite(props) {
|
|
|
676
744
|
props.onRename(trimmed);
|
|
677
745
|
setRenaming(false);
|
|
678
746
|
}
|
|
679
|
-
}, children: panelLabel('confirm', props.t('pet.confirm')) })] })) : (_jsxs(_Fragment, { children: [_jsxs("div", { className: styles.rankRow, children: [_jsx("span", { className: styles.nameCell, children: displayName }), _jsx("span", { className: styles.statRank, children: (() => {
|
|
680
|
-
const rawRank = snapshot?.affinity.rank ?? '?';
|
|
681
|
-
const rankKey = `pet.rank.name.${rawRank}`;
|
|
682
|
-
const localized = props.t(rankKey);
|
|
683
|
-
const rankName = localized !== rankKey ? localized : rawRank;
|
|
684
|
-
return panelStat('rank', 'pet.rank', { rank: rankName });
|
|
685
|
-
})() })] }), _jsxs("div", { className: styles.rankRow, children: [_jsx("span", { className: styles.statTreats, children: panelStat('treats', 'pet.treats', { n: snapshot?.treats.stocked ?? 0 }) }), _jsx("span", { className: styles.statPoints, children: panelStat('points', 'pet.points', { points: snapshot?.affinity.points ?? 0 }) })] }), _jsxs("div", { className: styles.actions, children: [panelShows('feed') && (_jsx("button", { type: "button", className: styles.action, onClick: props.onFeed, children: panelLabel('feed', props.t('pet.feed')) })), panelShows('rename') && (_jsx("button", { type: "button", className: styles.action, onClick: () => {
|
|
747
|
+
}, children: panelLabel('confirm', props.t('pet.confirm')) })] })) : (_jsxs(_Fragment, { children: [_jsxs("div", { className: styles.rankRow, children: [_jsx("span", { className: styles.nameCell, children: displayName }), _jsx("span", { className: styles.statRank, children: panelStat('rank', 'pet.rank', { rank: rankNameOf() }) })] }), _jsxs("div", { className: styles.rankRow, children: [_jsx("span", { className: styles.statTreats, children: panelStat('treats', 'pet.treats', { n: snapshot?.treats.stocked ?? 0 }) }), _jsx("span", { className: styles.statPoints, children: panelStat('points', 'pet.points', { points: snapshot?.affinity.points ?? 0 }) })] }), _jsxs("div", { className: styles.actions, children: [panelShows('feed') && (_jsx("button", { type: "button", className: styles.action, onClick: props.onFeed, children: panelLabel('feed', props.t('pet.feed')) })), panelShows('rename') && (_jsx("button", { type: "button", className: styles.action, onClick: () => {
|
|
686
748
|
// Cancel any pending hide so the rename box cannot
|
|
687
749
|
// unmount right as the user starts typing (#303).
|
|
688
750
|
clearHideTimer();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGnE,OAAO,KAAK,EAAE,UAAU,EAAsB,MAAM,4CAA4C,CAAA;AAuFhG,wEAAwE;AACxE,eAAO,MAAM,MAAM,UAAwF,CAAA;AAE3G,qEAAqE;AACrE,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACxE,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACrD,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC7D,YAAY,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AACtF,YAAY,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AACpE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnD,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,OAAO;QACf;;;;WAIG;QACH,aAAa,CAAC,EAAE;YACd,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE;g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ACF;CACF;AAUD,mFAAmF;AACnF,eAAO,MAAM,eAAe,MAAM,CAAA;AA2NlC,wBAAgB,KAAK,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CA2W9C"}
|
|
@@ -589,7 +589,20 @@ export function apply(ctx) {
|
|
|
589
589
|
// the 'pet' namespace instead follows the active language, the English
|
|
590
590
|
// fallback, and every language pack that registers a dictionary for it
|
|
591
591
|
// (the settings section label already resolves through the same seat).
|
|
592
|
-
|
|
592
|
+
const renderPet = () => {
|
|
593
|
+
petRoot.render(createElement(PetDockEntry, {
|
|
594
|
+
...injected(),
|
|
595
|
+
t: ctx.locale.bind(NS),
|
|
596
|
+
// The active locale rides the same mount as the translate seat so a
|
|
597
|
+
// pet-declared English rank name follows the UI language.
|
|
598
|
+
lang: ctx.locale.getLocale().active,
|
|
599
|
+
portalTarget: container,
|
|
600
|
+
}));
|
|
601
|
+
};
|
|
602
|
+
renderPet();
|
|
603
|
+
// Re-render on a language switch instead of waiting for the next poll
|
|
604
|
+
// tick: the declared rank ladder's nameEn applies immediately.
|
|
605
|
+
const unsubscribeLocale = ctx.locale.subscribe(renderPet);
|
|
593
606
|
let uiGone = false;
|
|
594
607
|
disposeUi = () => {
|
|
595
608
|
if (uiGone)
|
|
@@ -597,6 +610,7 @@ export function apply(ctx) {
|
|
|
597
610
|
uiGone = true;
|
|
598
611
|
clearUiTeardown?.();
|
|
599
612
|
clearUiTeardown = undefined;
|
|
613
|
+
unsubscribeLocale();
|
|
600
614
|
petRoot.unmount();
|
|
601
615
|
container.remove();
|
|
602
616
|
disposePoll();
|
|
@@ -7,11 +7,18 @@ export interface SequenceFrame {
|
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Precomputed timeline for one looping sequence: the per-item duration table
|
|
10
|
-
* is built once instead of per query. The sprite frame loop asks
|
|
11
|
-
*
|
|
10
|
+
* is built once instead of per query. The sprite frame loop asks once per
|
|
11
|
+
* frame change, where the per-call map/reduce is pure waste.
|
|
12
12
|
*/
|
|
13
13
|
export interface SequenceTimeline {
|
|
14
14
|
frameAt(elapsedMs: number): SequenceFrame;
|
|
15
|
+
/**
|
|
16
|
+
* Milliseconds from `elapsedMs` until the frame it lands on ends. The sprite
|
|
17
|
+
* loop sleeps for exactly this long instead of polling at the screen refresh
|
|
18
|
+
* rate (issue #17); the floor of 1 ms keeps a zero-length frame from turning
|
|
19
|
+
* into a busy timer.
|
|
20
|
+
*/
|
|
21
|
+
remainingAt(elapsedMs: number): number;
|
|
15
22
|
}
|
|
16
23
|
/** Build a {@link SequenceTimeline} over one manifest sequence. */
|
|
17
24
|
export declare function createSequenceTimeline(sequence: readonly PetAnimation[], tracks: Record<PetAnimation, PetTrackDef>): SequenceTimeline;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sequences.d.ts","sourceRoot":"","sources":["../../../src/client/sequences.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAE1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,YAAY,CAAA;IACvB,UAAU,EAAE,MAAM,CAAA;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"sequences.d.ts","sourceRoot":"","sources":["../../../src/client/sequences.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAE1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,YAAY,CAAA;IACvB,UAAU,EAAE,MAAM,CAAA;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa,CAAA;IACzC;;;;;OAKG;IACH,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAA;CACvC;AAUD,mEAAmE;AACnE,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,SAAS,YAAY,EAAE,EACjC,MAAM,EAAE,MAAM,CAAC,YAAY,EAAE,WAAW,CAAC,GACxC,gBAAgB,CAgClB;AAED,2FAA2F;AAC3F,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,SAAS,YAAY,EAAE,EACjC,MAAM,EAAE,MAAM,CAAC,YAAY,EAAE,WAAW,CAAC,EACzC,SAAS,EAAE,MAAM,GAChB,aAAa,CAEf"}
|
|
@@ -3,22 +3,33 @@
|
|
|
3
3
|
export function createSequenceTimeline(sequence, tracks) {
|
|
4
4
|
const itemDurations = sequence.map(animation => tracks[animation].durations.reduce((sum, value) => sum + value, 0));
|
|
5
5
|
const sequenceDuration = itemDurations.reduce((sum, value) => sum + value, 0);
|
|
6
|
+
// One traversal serves both queries: frameAt needs the index it lands on and
|
|
7
|
+
// remainingAt needs how far into that frame it is, so resolving them
|
|
8
|
+
// separately would walk the same tables twice for one loop tick.
|
|
9
|
+
const locate = (elapsedMs) => {
|
|
10
|
+
let offset = sequenceDuration > 0 ? Math.max(0, elapsedMs) % sequenceDuration : 0;
|
|
11
|
+
let itemIndex = 0;
|
|
12
|
+
while (itemIndex < sequence.length - 1 && offset >= itemDurations[itemIndex]) {
|
|
13
|
+
offset -= itemDurations[itemIndex];
|
|
14
|
+
itemIndex += 1;
|
|
15
|
+
}
|
|
16
|
+
const animation = sequence[itemIndex];
|
|
17
|
+
const track = tracks[animation];
|
|
18
|
+
let frameIndex = 0;
|
|
19
|
+
while (frameIndex < track.frames.length - 1 && offset >= track.durations[frameIndex]) {
|
|
20
|
+
offset -= track.durations[frameIndex];
|
|
21
|
+
frameIndex += 1;
|
|
22
|
+
}
|
|
23
|
+
return { animation, track, frameIndex, offsetInFrame: offset };
|
|
24
|
+
};
|
|
6
25
|
return {
|
|
7
26
|
frameAt(elapsedMs) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const animation = sequence[itemIndex];
|
|
15
|
-
const track = tracks[animation];
|
|
16
|
-
let frameIndex = 0;
|
|
17
|
-
while (frameIndex < track.frames.length - 1 && offset >= track.durations[frameIndex]) {
|
|
18
|
-
offset -= track.durations[frameIndex];
|
|
19
|
-
frameIndex += 1;
|
|
20
|
-
}
|
|
21
|
-
return { animation, frameIndex };
|
|
27
|
+
const point = locate(elapsedMs);
|
|
28
|
+
return { animation: point.animation, frameIndex: point.frameIndex };
|
|
29
|
+
},
|
|
30
|
+
remainingAt(elapsedMs) {
|
|
31
|
+
const point = locate(elapsedMs);
|
|
32
|
+
return Math.max(1, (point.track.durations[point.frameIndex] ?? 0) - point.offsetInFrame);
|
|
22
33
|
},
|
|
23
34
|
};
|
|
24
35
|
}
|
|
@@ -12,12 +12,33 @@ import type { PetCell, PetTrackDef } from '../registry.ts';
|
|
|
12
12
|
export type TrackDef = PetTrackDef;
|
|
13
13
|
/** Row index of one animation track (the fixed 9-row contract). */
|
|
14
14
|
export declare function rowOfTrack(animation: PetAnimation): number;
|
|
15
|
+
/**
|
|
16
|
+
* Integer size of one cell after `scale`, in device-independent px.
|
|
17
|
+
*
|
|
18
|
+
* Rounding happens here, once, so the rendered atlas grid is integral end to
|
|
19
|
+
* end (issue #17): `background-size` is this size times the column/row count
|
|
20
|
+
* and every frame offset is an exact multiple of it. A fractional cell size
|
|
21
|
+
* leaves each frame on a sub-pixel boundary — 192px cells at `display.size`
|
|
22
|
+
* 160 scale to 147.69px — and the compositor then has to resample the whole
|
|
23
|
+
* scaled atlas on every frame change instead of translating an already-scaled
|
|
24
|
+
* bitmap by whole pixels. The pet advances a frame every 300-700 ms, so that
|
|
25
|
+
* resample was running continuously for a background surface the size of the
|
|
26
|
+
* sprite. A floor of 1px keeps a legally tiny display.size from collapsing the
|
|
27
|
+
* cell to zero and rendering nothing.
|
|
28
|
+
*/
|
|
29
|
+
export declare function scaledCellSize(cell: PetCell, scale: number): {
|
|
30
|
+
width: number;
|
|
31
|
+
height: number;
|
|
32
|
+
};
|
|
15
33
|
/**
|
|
16
34
|
* Background-position (px) of one frame cell within the scaled atlas.
|
|
17
35
|
* The background image is scaled by `scale` (element size ÷ cell size), and
|
|
18
36
|
* background-position offsets are applied in SCALED coordinates — using raw
|
|
19
37
|
* atlas coordinates here would drift each frame by the scale factor and
|
|
20
|
-
* render torn/overlapping frames.
|
|
38
|
+
* render torn/overlapping frames. The scaled cell is quantized by
|
|
39
|
+
* {@link scaledCellSize}, so the offset of frame N is exactly N whole cells:
|
|
40
|
+
* the atlas is snapped to the pixel grid and a frame change is a plain
|
|
41
|
+
* translate of the scaled bitmap.
|
|
21
42
|
*/
|
|
22
43
|
export declare function framePosition(cell: PetCell, row: number, col: number, scale?: number): {
|
|
23
44
|
x: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spritesheet.d.ts","sourceRoot":"","sources":["../../../src/client/spritesheet.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAS,KAAK,YAAY,EAAE,MAAM,aAAa,CAAA;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE1D,qDAAqD;AACrD,MAAM,MAAM,QAAQ,GAAG,WAAW,CAAA;AAElC,mEAAmE;AACnE,wBAAgB,UAAU,CAAC,SAAS,EAAE,YAAY,GAAG,MAAM,CAG1D;AAED
|
|
1
|
+
{"version":3,"file":"spritesheet.d.ts","sourceRoot":"","sources":["../../../src/client/spritesheet.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAS,KAAK,YAAY,EAAE,MAAM,aAAa,CAAA;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE1D,qDAAqD;AACrD,MAAM,MAAM,QAAQ,GAAG,WAAW,CAAA;AAElC,mEAAmE;AACnE,wBAAgB,UAAU,CAAC,SAAS,EAAE,YAAY,GAAG,MAAM,CAG1D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAK9F;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAG1G;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,GAAG,QAAQ,CAQvE"}
|
|
@@ -12,15 +12,39 @@ export function rowOfTrack(animation) {
|
|
|
12
12
|
// The table itself lives in state.ts (rowOf) — the single source of truth.
|
|
13
13
|
return rowOf(animation);
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Integer size of one cell after `scale`, in device-independent px.
|
|
17
|
+
*
|
|
18
|
+
* Rounding happens here, once, so the rendered atlas grid is integral end to
|
|
19
|
+
* end (issue #17): `background-size` is this size times the column/row count
|
|
20
|
+
* and every frame offset is an exact multiple of it. A fractional cell size
|
|
21
|
+
* leaves each frame on a sub-pixel boundary — 192px cells at `display.size`
|
|
22
|
+
* 160 scale to 147.69px — and the compositor then has to resample the whole
|
|
23
|
+
* scaled atlas on every frame change instead of translating an already-scaled
|
|
24
|
+
* bitmap by whole pixels. The pet advances a frame every 300-700 ms, so that
|
|
25
|
+
* resample was running continuously for a background surface the size of the
|
|
26
|
+
* sprite. A floor of 1px keeps a legally tiny display.size from collapsing the
|
|
27
|
+
* cell to zero and rendering nothing.
|
|
28
|
+
*/
|
|
29
|
+
export function scaledCellSize(cell, scale) {
|
|
30
|
+
return {
|
|
31
|
+
width: Math.max(1, Math.round(cell.width * scale)),
|
|
32
|
+
height: Math.max(1, Math.round(cell.height * scale)),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
15
35
|
/**
|
|
16
36
|
* Background-position (px) of one frame cell within the scaled atlas.
|
|
17
37
|
* The background image is scaled by `scale` (element size ÷ cell size), and
|
|
18
38
|
* background-position offsets are applied in SCALED coordinates — using raw
|
|
19
39
|
* atlas coordinates here would drift each frame by the scale factor and
|
|
20
|
-
* render torn/overlapping frames.
|
|
40
|
+
* render torn/overlapping frames. The scaled cell is quantized by
|
|
41
|
+
* {@link scaledCellSize}, so the offset of frame N is exactly N whole cells:
|
|
42
|
+
* the atlas is snapped to the pixel grid and a frame change is a plain
|
|
43
|
+
* translate of the scaled bitmap.
|
|
21
44
|
*/
|
|
22
45
|
export function framePosition(cell, row, col, scale = 1) {
|
|
23
|
-
|
|
46
|
+
const scaled = scaledCellSize(cell, scale);
|
|
47
|
+
return { x: -col * scaled.width, y: -row * scaled.height };
|
|
24
48
|
}
|
|
25
49
|
/**
|
|
26
50
|
* Trim a track to the actual frame count of its row (the manifest's per-row
|
package/lib/types/index.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export type { PetConfig, PetInteractResult, PetSettingsSection, PetSessionView,
|
|
|
19
19
|
export { MAX_PANEL_ACTIONS, PanelActionRegistry, normalizePanelAction } from './panel-actions.ts';
|
|
20
20
|
export type { PetPanelActionContext, PetPanelActionHandler, PetPanelActionRegistration, PetPanelActionView, } from './panel-actions.ts';
|
|
21
21
|
export { AFFINITY_MAX, AFFINITY_RANKS, applyInteraction, applyTurnReward, emptyAffinity, rankOf, } from './affinity.ts';
|
|
22
|
-
export type { AffinityConfig, AffinityState, InteractionOutcome, PetInteraction, } from './affinity.ts';
|
|
22
|
+
export type { AffinityConfig, AffinityRank, AffinityRankName, AffinityState, InteractionOutcome, PetInteraction, } from './affinity.ts';
|
|
23
23
|
export { animationForPhase, PetStateMachine, rowOf, } from './state.ts';
|
|
24
24
|
export type { ActivityPhase, PetAnimation, PetStateConfig, PetStateInput, PetStateSnapshot, } from './state.ts';
|
|
25
25
|
export { consumeTreat, defaultTreatConfig, emptyTreatLedger, settleTreatGrants, } from './treats.ts';
|
package/lib/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAI5D,OAAO,CAAC,MAAM,0BAA0B,CAAA;AACxC,OAAO,EAAyG,KAAK,SAAS,EAAE,KAAK,kBAAkB,EAAE,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAGvM,OAAO,EAA6G,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAG/J,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AACjI,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,mBAAmB,GACpB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AACjG,YAAY,EACV,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,MAAM,GACP,MAAM,eAAe,CAAA;AACtB,YAAY,EACV,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,cAAc,GACf,MAAM,eAAe,CAAA;AACtB,OAA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AK,kBAA6C,CAAA;AAE/D,4FAA4F;AAC5F,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,EAAE,SAAS,GAAG,mBAAmB,CAAC,GAAG,aAAa,CAAA;AAE9F,iBAAS,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,GAAE,eAAoB,GAAG,IAAI,CA+EnE;AAED,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,MAAM;QACd;;;;WAIG;QACH,wBAAwB,CAAC,KAAK,EAAE,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,GAAG,IAAI,CAAA;KACtE;CACF"}
|
package/lib/types/ledger.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* economic events: completed-turn rewards (official or legacy) and feeds.
|
|
7
7
|
* @module @linxin666/dsh-pet/ledger
|
|
8
8
|
*/
|
|
9
|
-
import { type AffinityConfig, type PetAffinityView, type PetInteraction } from './affinity.ts';
|
|
9
|
+
import { type AffinityConfig, type AffinityRankName, type PetAffinityView, type PetInteraction } from './affinity.ts';
|
|
10
10
|
import { type TreatConfig } from './treats.ts';
|
|
11
11
|
import { type PetRemarks } from './remarks.ts';
|
|
12
12
|
import type { PetDisplayConfig, PetPersist } from './persist.ts';
|
|
@@ -19,6 +19,8 @@ export interface LedgerConfig {
|
|
|
19
19
|
remarks?: PetRemarks;
|
|
20
20
|
/** Voice-pack fallback remark pools (global or pet voice pack). */
|
|
21
21
|
voiceRemarks?: PetRemarks;
|
|
22
|
+
/** Display-only rank ladder for the selected pet (voice.json panel.ranks). */
|
|
23
|
+
rankLadder?: readonly AffinityRankName[];
|
|
22
24
|
}
|
|
23
25
|
/** Result of one ledger interaction (the shape the pet RPC returns). */
|
|
24
26
|
export interface LedgerInteractionResult {
|
|
@@ -39,6 +41,8 @@ export declare class PetLedger {
|
|
|
39
41
|
private readonly treatConfig;
|
|
40
42
|
/** Round-robin reaction picker; rebuilt when the selected pet changes. */
|
|
41
43
|
private picker;
|
|
44
|
+
/** Declared rank ladder; undefined keeps the built-in whale ladder. */
|
|
45
|
+
private rankLadder;
|
|
42
46
|
private current;
|
|
43
47
|
/** Completed turns already rewarded, per session (turn numbers are per-session). */
|
|
44
48
|
private rewardedTurns;
|
|
@@ -79,6 +83,11 @@ export declare class PetLedger {
|
|
|
79
83
|
* selection). Slots the pet does not declare fall back to voice packs or built-ins.
|
|
80
84
|
*/
|
|
81
85
|
setRemarks(remarks?: PetRemarks, voiceRemarks?: PetRemarks): void;
|
|
86
|
+
/**
|
|
87
|
+
* Swap the display-only rank ladder to the selected pet's declared one
|
|
88
|
+
* (called on pet selection). Undefined restores the built-in ladder.
|
|
89
|
+
*/
|
|
90
|
+
setRankLadder(ladder?: readonly AffinityRankName[]): void;
|
|
82
91
|
/**
|
|
83
92
|
* Settle the treat economy (work + time output since the last settlement).
|
|
84
93
|
* A zero-gain first settlement still starts the time clock (anchor write),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ledger.d.ts","sourceRoot":"","sources":["../../src/ledger.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAKL,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,eAAe,CAAA;AACtB,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,cAAc,CAAA;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAErD,iDAAiD;AACjD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IAClC,MAAM,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;IAC7B,mFAAmF;IACnF,OAAO,CAAC,EAAE,UAAU,CAAA;IACpB,mEAAmE;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;IAC9E,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG;QAAE,EAAE,EAAE,OAAO,CAAA;KAAE;IAQ5C;;;;OAIG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IASnE,8EAA8E;IAC9E,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IASxC,OAAO,CAAC,eAAe;IASvB;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,GAAG,uBAAuB;IAwCtE,kDAAkD;IAClD,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe;CAG7C"}
|
package/lib/types/ledger.js
CHANGED
|
@@ -19,6 +19,8 @@ export class PetLedger {
|
|
|
19
19
|
treatConfig;
|
|
20
20
|
/** Round-robin reaction picker; rebuilt when the selected pet changes. */
|
|
21
21
|
picker;
|
|
22
|
+
/** Declared rank ladder; undefined keeps the built-in whale ladder. */
|
|
23
|
+
rankLadder;
|
|
22
24
|
current;
|
|
23
25
|
/** Completed turns already rewarded, per session (turn numbers are per-session). */
|
|
24
26
|
rewardedTurns = new Map();
|
|
@@ -28,6 +30,7 @@ export class PetLedger {
|
|
|
28
30
|
this.affinityConfig = { ...defaultAffinityConfig, ...(config.affinity ?? {}) };
|
|
29
31
|
this.treatConfig = { ...defaultTreatConfig, ...(config.treats ?? {}) };
|
|
30
32
|
this.picker = new RemarkPicker(config.remarks, config.voiceRemarks);
|
|
33
|
+
this.rankLadder = config.rankLadder;
|
|
31
34
|
this.current = persist;
|
|
32
35
|
}
|
|
33
36
|
/** Affinity cooldown/rank tuning (read-only). */
|
|
@@ -109,6 +112,13 @@ export class PetLedger {
|
|
|
109
112
|
setRemarks(remarks, voiceRemarks) {
|
|
110
113
|
this.picker = new RemarkPicker(remarks, voiceRemarks);
|
|
111
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Swap the display-only rank ladder to the selected pet's declared one
|
|
117
|
+
* (called on pet selection). Undefined restores the built-in ladder.
|
|
118
|
+
*/
|
|
119
|
+
setRankLadder(ladder) {
|
|
120
|
+
this.rankLadder = ladder;
|
|
121
|
+
}
|
|
112
122
|
/**
|
|
113
123
|
* Settle the treat economy (work + time output since the last settlement).
|
|
114
124
|
* A zero-gain first settlement still starts the time clock (anchor write),
|
|
@@ -229,6 +239,6 @@ export class PetLedger {
|
|
|
229
239
|
}
|
|
230
240
|
/** Current affinity view for the RPC snapshot. */
|
|
231
241
|
affinityView(nowMs) {
|
|
232
|
-
return affinityViewOf(this.current.affinity, nowMs, this.affinityConfig);
|
|
242
|
+
return affinityViewOf(this.current.affinity, nowMs, this.affinityConfig, this.rankLadder);
|
|
233
243
|
}
|
|
234
244
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pair-access.d.ts","sourceRoot":"","sources":["../../src/pair-access.ts"],"names":[],"mappings":"AACA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAGhD,0EAA0E;AAC1E,UAAU,aAAa;IACrB,cAAc,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAA;CAClD;AAED;;;;;GAKG;AACH,UAAU,SAAS;IACjB,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;IAC7C,kBAAkB,CAAC,EAAE,aAAa,CAAA;CACnC;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"pair-access.d.ts","sourceRoot":"","sources":["../../src/pair-access.ts"],"names":[],"mappings":"AACA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAGhD,0EAA0E;AAC1E,UAAU,aAAa;IACrB,cAAc,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAA;CAClD;AAED;;;;;GAKG;AACH,UAAU,SAAS;IACjB,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;IAC7C,kBAAkB,CAAC,EAAE,aAAa,CAAA;CACnC;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAG3F"}
|