level-up/src/shared/util.ts
2024-12-26 18:54:19 +01:00

12 lines
No EOL
563 B
TypeScript

import type { Interaction } from "./script/types"
export const cSet = <T>(...values: T[]) => new Set(values)
export const cMap = <K extends string | number | symbol, V>(object: Record<K, V>) => new Map(Object.entries(object))
export function getInteractionQueueItemId(interaction: Interaction) {
let id: string
if (interaction.type === "use") id = `use-${interaction.objectId}`
else if (interaction.type === "combine") id = `combine-${[...interaction.objectIds].sort().join("_")}`
else throw new Error("Unknown interaction type")
return id
}