5180 fichiers 38.5 Mo 0 téléchargements 482 vues mis à jour il y a 7 heures ui
nitro-v36-with-renderer-v36 / src / components / room / widgets / furniture / chestFurniGrouping.ts
chestFurniGrouping.ts 2 Ko Télécharger le fichier
import { IChestFurniStoredItem } from '@octane/renderer';

/** Matches official {@code FurniChestView.itemTypeKey}. */
export const chestFurniTypeKey = (item: IChestFurniStoredItem): string =>
    `${item.wallItem ? 1 : 0}-${item.baseItemId}-${item.legacyPosterId ?? ''}`;

/** Group key: LTD items stay separate; rarity (specialType 19) splits by level. */
export const chestFurniGroupKey = (item: IChestFurniStoredItem): string => {
    if ((item.stuffData?.uniqueNumber ?? 0) > 0) return `ltd-${item.inventoryId}`;

    if (item.specialType === 19) {
        return `${chestFurniTypeKey(item)}-r${item.stuffData?.rarityLevel ?? 0}`;
    }

    return chestFurniTypeKey(item);
};

export interface ChestFurniGroup {
    key: string;
    wallItem: boolean;
    baseItemId: number;
    legacyPosterId: string;
    specialType: number;
    quantity: number;
    sample: IChestFurniStoredItem;
}

export const groupStoredFurni = (items: IChestFurniStoredItem[]): ChestFurniGroup[] => {
    const map = new Map<string, ChestFurniGroup>();

    for (const item of items) {
        const key = chestFurniGroupKey(item);
        const existing = map.get(key);

        if (existing) {
            existing.quantity += 1;
        } else {
            map.set(key, {
                key,
                wallItem: item.wallItem,
                baseItemId: item.baseItemId,
                legacyPosterId: item.legacyPosterId ?? '',
                specialType: item.specialType,
                quantity: 1,
                sample: item,
            });
        }
    }

    return Array.from(map.values());
};

export const chestFurniDisplayName = (group: ChestFurniGroup, localize: (key: string) => string, getFloorName: (id: number) => string, getWallName: (id: number) => string): string => {
    if (group.wallItem && group.specialType === 6 && group.legacyPosterId) {
        return localize(`poster_${group.legacyPosterId}_name`);
    }

    return group.wallItem ? getWallName(group.baseItemId) : getFloorName(group.baseItemId);
};
15Sujets
1Dépôts
20Membres
3En ligne
Profile
Inscrit
Dernière visite
Messages
0
Votes positifs
0
Votes négatifs
0

Nous utilisons des cookies pour assurer le bon fonctionnement du site et améliorer votre expérience. en savoir plus

Autoriser