| 1 | import { ItemCategory } from "./itemCategories.js"; |
| 2 | import |
| 3 | { |
| 4 | MagicElement, |
| 5 | MAGIC_ELEMENT_ORDER, |
| 6 | MAGIC_ELEMENT_TINT, |
| 7 | ASH_WOOD_FOR_ELEMENT |
| 8 | } from "./attackTypes.js"; |
| 9 | import { MATERIAL_DISPLAY_NAME } from "./materialTiers.js"; |
| 10 | |
| 11 | /** |
| 12 | * Elemental essences dropped by sprites (100%). Share the ash sprite, tinted per element. |
| 13 | */ |
| 14 | export const EssenceItemId = Object.freeze({ |
| 15 | [MagicElement.fire]: 424, |
| 16 | [MagicElement.water]: 425, |
| 17 | [MagicElement.air]: 426, |
| 18 | [MagicElement.earth]: 427, |
| 19 | [MagicElement.light]: 428, |
| 20 | [MagicElement.dark]: 429, |
| 21 | [MagicElement.poison]: 430 |
| 22 | }); |
| 23 | |
| 24 | const ELEMENT_DISPLAY = Object.freeze({ |
| 25 | [MagicElement.fire]: "Fire", |
| 26 | [MagicElement.water]: "Water", |
| 27 | [MagicElement.air]: "Air", |
| 28 | [MagicElement.earth]: "Earth", |
| 29 | [MagicElement.light]: "Light", |
| 30 | [MagicElement.dark]: "Dark", |
| 31 | [MagicElement.poison]: "Poison" |
| 32 | }); |
| 33 | |
| 34 | function buildEssenceDefinitions () |
| 35 | { |
| 36 | const defs = {}; |
| 37 | for (const element of MAGIC_ELEMENT_ORDER) |
| 38 | { |
| 39 | const itemId = EssenceItemId[element]; |
| 40 | const name = ELEMENT_DISPLAY[element] ?? element; |
| 41 | const tint = MAGIC_ELEMENT_TINT[element]; |
| 42 | defs[itemId] = Object.freeze({ |
| 43 | itemId, |
| 44 | key: `${element}-essence`, |
| 45 | displayName: `${name} essence`, |
| 46 | description: `A condensed mote of ${name.toLowerCase()}, shed by an ethereal creature.`, |
| 47 | seedValue: 8, |
| 48 | stackable: true, |
| 49 | maxStackSize: 99, |
| 50 | uniqueInstance: false, |
| 51 | category: ItemCategory.ingredient, |
| 52 | iconKey: "ash", |
| 53 | defaultState: "ash", |
| 54 | essenceElement: element, |
| 55 | tint: Object.freeze({ r: tint.r, g: tint.g, b: tint.b }) |
| 56 | }); |
| 57 | } |
| 58 | return defs; |
| 59 | } |
| 60 | |
| 61 | export const ESSENCE_ITEM_DEFINITIONS = Object.freeze(buildEssenceDefinitions()); |
| 62 | |
| 63 | export function essenceItemIdForElement (element) |
| 64 | { |
| 65 | return EssenceItemId[element] ?? null; |
| 66 | } |
| 67 | |
| 68 | export function essenceElementDisplayName (element) |
| 69 | { |
| 70 | return ELEMENT_DISPLAY[element] ?? element; |
| 71 | } |
| 72 | |
| 73 | /** Ash wood tier used when brewing the coating for this element. */ |
| 74 | export function ashWoodForCoatingElement (element) |
| 75 | { |
| 76 | return ASH_WOOD_FOR_ELEMENT[element] ?? null; |
| 77 | } |
| 78 | |
| 79 | export function coatingDisplayName (element) |
| 80 | { |
| 81 | const name = ELEMENT_DISPLAY[element] ?? element; |
| 82 | return `${name} arrow coating`; |
| 83 | } |
| 84 | |
| 85 | export function coatingAshDisplayName (element) |
| 86 | { |
| 87 | const wood = ashWoodForCoatingElement(element); |
| 88 | return wood ? (MATERIAL_DISPLAY_NAME[wood] ?? wood) : "wood"; |
| 89 | } |