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