| 1 | import test from "node:test"; |
| 2 | import assert from "node:assert/strict"; |
| 3 | import { itemDefinition, ItemId } from "../../shared/definitions/items.js"; |
| 4 | import { RangedItemId } from "../../shared/definitions/rangedItems.js"; |
| 5 | import { recipesForStation } from "../../shared/crafting/stationRecipes.js"; |
| 6 | import { CraftingStationId } from "../../shared/definitions/craftingStations.js"; |
| 7 | import { EquipmentKind } from "../../shared/definitions/equipmentKinds.js"; |
| 8 | import { AttackType } from "../../shared/definitions/attackTypes.js"; |
| 9 | import { mobDefinition, MobId } from "../../shared/definitions/mobs.js"; |
| 10 | |
| 11 | test("ranged items: bow is ranged weapon, arrows stack in offhand", () => |
| 12 | { |
| 13 | const bow = itemDefinition(RangedItemId.pineBow); |
| 14 | assert.equal(bow?.equipment?.attack?.mode, "ranged"); |
| 15 | assert.equal(bow?.equipment?.kind, EquipmentKind.bow); |
| 16 | assert.equal(bow?.iconKey, "bow"); |
| 17 | assert.equal(bow?.defaultState, "bow"); |
| 18 | assert.equal(bow?.dualTintFromTier, true); |
| 19 | assert.equal(bow?.clothTier, "cotton"); |
| 20 | assert.equal(bow?.tintFromTier, undefined); |
| 21 | |
| 22 | const unstrung = itemDefinition(RangedItemId.pineUnstrungBow); |
| 23 | assert.equal(unstrung?.iconKey, "bow"); |
| 24 | assert.equal(unstrung?.defaultState, "unstrung-bow"); |
| 25 | assert.equal(unstrung?.dualTintFromTier, true); |
| 26 | assert.equal(unstrung?.clothTier, undefined); |
| 27 | |
| 28 | const bowstring = itemDefinition(RangedItemId.cottonBowstring); |
| 29 | assert.equal(bowstring?.iconKey, "bow"); |
| 30 | assert.equal(bowstring?.defaultState, "bowstring"); |
| 31 | assert.equal(bowstring?.tintFromTier, true); |
| 32 | |
| 33 | const feather = itemDefinition(RangedItemId.feather); |
| 34 | assert.equal(feather?.iconKey, "feather"); |
| 35 | assert.equal(feather?.defaultState, "feather"); |
| 36 | |
| 37 | const arrow = itemDefinition(RangedItemId.bronzeArrow); |
| 38 | assert.equal(arrow?.equipment?.kind, EquipmentKind.arrowAmmo); |
| 39 | assert.equal(arrow?.defaultState, "full-arrow"); |
| 40 | assert.equal(arrow?.dualTintFromTier, true); |
| 41 | assert.equal(arrow?.maxStackSize, 999); |
| 42 | assert.equal(arrow?.equipment?.hideEquipSprite, true); |
| 43 | }); |
| 44 | |
| 45 | test("ranged recipes load on crafting stations", () => |
| 46 | { |
| 47 | const bench = recipesForStation(CraftingStationId.craftingBench); |
| 48 | const woodworking = recipesForStation(CraftingStationId.woodworkingBench); |
| 49 | const anvil = recipesForStation(CraftingStationId.anvil); |
| 50 | assert.ok(bench.some((r) => r.recipeId?.includes("arrow"))); |
| 51 | assert.ok(woodworking.some((r) => r.recipeId?.includes("arrow-shaft"))); |
| 52 | assert.ok(anvil.some((r) => r.recipeId?.includes("arrow-tip"))); |
| 53 | assert.ok(woodworking.some((r) => r.recipeId?.includes("unstrung-bow"))); |
| 54 | }); |
| 55 | |
| 56 | test("chicken drops feathers", () => |
| 57 | { |
| 58 | const chicken = mobDefinition(MobId.chicken); |
| 59 | const feather = chicken?.drops?.find((drop) => drop.itemId === RangedItemId.feather); |
| 60 | assert.ok(feather); |
| 61 | assert.equal(feather.chance, 1); |
| 62 | assert.equal(feather.quantityMin, 1); |
| 63 | assert.equal(feather.quantityMax, 3); |
| 64 | const egg = chicken?.drops?.find((drop) => drop.itemId === ItemId.egg); |
| 65 | assert.ok(egg); |
| 66 | assert.equal(egg.chance, 0.2); |
| 67 | }); |