feat: rare values panel + fortune wheel UI + prize editor

Toolbar buttons, FortuneWheelView (animated wheel, prize icons, recent winners),
RareValuesView (diamond price guide + staff prize-editor tab), furni infostand
value line, useFortuneWheel/useRareValues hooks, it/en text examples.
This commit is contained in:
medievalshell
2026-05-28 02:39:02 +02:00
parent 00fbdc6f6d
commit 61aceaa422
13 changed files with 602 additions and 2 deletions
+31
View File
@@ -0,0 +1,31 @@
import { IRareValue, RareValuesEvent, RequestRareValuesComposer } from '@nitrots/nitro-renderer';
import { useCallback, useEffect, useState } from 'react';
import { useBetween } from 'use-between';
import { SendMessageComposer } from '../../api';
import { useMessageEvent } from '../events';
// spriteId -> catalog value, fetched once from the server (RareValuesComposer).
// Shared across all consumers via useBetween so the request fires a single time.
// Read by both the furni infostand and the toolbar "Valore Rari" panel.
const useRareValuesState = () =>
{
const [ values, setValues ] = useState<Map<number, IRareValue>>(() => new Map());
const [ loaded, setLoaded ] = useState(false);
useMessageEvent<RareValuesEvent>(RareValuesEvent, event =>
{
setValues(event.getParser().values);
setLoaded(true);
});
useEffect(() =>
{
SendMessageComposer(new RequestRareValuesComposer());
}, []);
const getValue = useCallback((spriteId: number): IRareValue => (values.get(spriteId) ?? null), [ values ]);
return { values, loaded, getValue };
};
export const useRareValues = () => useBetween(useRareValuesState);