Files
HaBit/lib/avatar-display.ts
pricewowen 61f98866e8 avatar to main merge
I have completed the character creation screen on the avatar branch and am preparing to merge it into main.
2026-05-23 23:24:36 -06:00

38 lines
938 B
TypeScript

import type { LayerVariantState } from "@/lib/character/types";
import { parseShopStyleItem, parseVariantId } from "@/lib/shop-catalog";
/** Apply equipped shop styles (variant ids like head-1) onto saved customization. */
export function applyEquippedItemsToVariants(
variants: LayerVariantState,
equippedItems: string[],
): LayerVariantState {
const next = { ...variants };
for (const itemId of equippedItems) {
const style = parseVariantId(itemId);
if (style) {
next[style.layerId] = style.variantId;
}
}
return next;
}
export function applyEquippedShopRecordsToVariants(
variants: LayerVariantState,
equippedItems: Array<{ id: string; type: string }>,
): LayerVariantState {
const next = { ...variants };
for (const item of equippedItems) {
const style = parseShopStyleItem(item.id, item.type);
if (style) {
next[style.layerId] = style.variantId;
}
}
return next;
}