BlueGit

timfa questward

Merge branch 'feature/content-manifest-all-items'

timfa Tim Falken · pushed by timfa

Authored 2026-09-08 · 2 months ago

Hash
d5b670e487980fc95e6cb04e17c68ef86b3462c6
11 files changed +235 −66
client/src/editor/tileConfigModal.js +77 −41
@@ -8,7 +8,8 @@ import
8 8 MobId,
9 9 isHumanoidMob,
10 10 isCentralExchangeSpawner,
11 spawnerEquipmentSlot
11 spawnerEquipmentSlot,
12 mobDefinition
12 13 } from "/shared/definitions/mobs.js";
13 14 import { spellCastSuccessChancePercent } from "/shared/combat/magic.js";
14 15 import { SPELL_DEFINITIONS, spellMinMagicLevel } from "/shared/definitions/spells.js";
@@ -687,12 +688,13 @@ export function initTileConfigModal ({
687 688 }
688 689 }
689 690
690 function renderHumanoidFields (config)
691 function renderCommonSpawnerFields (config)
691 692 {
692 693 const wrap = document.createElement("div");
693 wrap.className = "spawner-humanoid-fields";
694 wrap.dataset.humanoid = "1";
694 wrap.className = "spawner-common-fields";
695 wrap.dataset.commonSpawner = "1";
695 696 const exchange = isCentralExchangeSpawner(config);
697
696 698 if (exchange)
697 699 {
698 700 const note = document.createElement("p");
@@ -702,45 +704,17 @@ export function initTileConfigModal ({
702 704 }
703 705 else
704 706 {
707 const def = mobDefinition(config.mobTypeId);
708 const placeholder = def?.displayName || "Name";
705 709 wrap.append(
706 field("Display name", textInput("displayName", config.displayName || "Shopkeeper")),
707 field("Sex", sexSelect("sex", config.sex))
710 field("Display name", textInput("displayName", config.displayName || ""))
708 711 );
712 const nameHint = document.createElement("p");
713 nameHint.className = "hint";
714 nameHint.textContent = `Optional. Empty uses the mob default (${placeholder}).`;
715 wrap.append(nameHint);
709 716 }
710 717
711 const aggressiveLabel = document.createElement("label");
712 aggressiveLabel.className = "spawner-buys-row";
713 const aggressive = document.createElement("input");
714 aggressive.type = "checkbox";
715 aggressive.name = "aggressive";
716 aggressive.checked = !!config.aggressive;
717 aggressive.addEventListener("change", () => syncBountyForAggressive());
718 aggressiveLabel.append(aggressive, document.createTextNode(" Aggressive (attacks players in range)"));
719 wrap.append(aggressiveLabel);
720 const aggressiveHint = document.createElement("p");
721 aggressiveHint.className = "hint";
722 aggressiveHint.textContent = "When Aggressive is on, Bounty is forced to 0.";
723 wrap.append(aggressiveHint);
724
725 wrap.append(field("Dialogue", dialogueSelect("dialogueId", config.dialogueId ?? "", dialogueOptions)));
726
727 const equipHeader = document.createElement("div");
728 equipHeader.className = "spawner-sells-header";
729 const equipTitle = document.createElement("strong");
730 equipTitle.textContent = "Equipment";
731 equipHeader.append(equipTitle);
732 wrap.append(equipHeader);
733
734 const equipList = document.createElement("div");
735 equipList.className = "spawner-equip-list";
736 equipList.dataset.equipmentList = "1";
737 wrap.append(equipList);
738
739 equipmentDraft = {};
740 for (const slot of EQUIPMENT_SLOTS)
741 { equipmentDraft[slot] = equipDraftFromConfig(config.equipment?.[slot]); }
742 queueMicrotask(() => renderEquipmentRows());
743
744 718 const dropsHeader = document.createElement("div");
745 719 dropsHeader.className = "spawner-sells-header";
746 720 const dropsTitle = document.createElement("strong");
@@ -760,7 +734,7 @@ export function initTileConfigModal ({
760 734
761 735 const dropsHint = document.createElement("p");
762 736 dropsHint.className = "hint";
763 dropsHint.textContent = "On death each line rolls its chance; if it hits, quantity is random between min and max (inclusive).";
737 dropsHint.textContent = "Configured drops replace the mob's default loot table. Leave empty to keep defaults. Each line rolls its chance; quantity is random between min and max (inclusive).";
764 738 wrap.append(dropsHint);
765 739
766 740 dropsDraft = (config.drops ?? []).map((line) =>
@@ -790,6 +764,52 @@ export function initTileConfigModal ({
790 764 }).filter(Boolean);
791 765
792 766 queueMicrotask(() => renderDropsList());
767 return wrap;
768 }
769
770 function renderHumanoidFields (config)
771 {
772 const wrap = document.createElement("div");
773 wrap.className = "spawner-humanoid-fields";
774 wrap.dataset.humanoid = "1";
775 const exchange = isCentralExchangeSpawner(config);
776 if (!exchange)
777 {
778 wrap.append(field("Sex", sexSelect("sex", config.sex)));
779 }
780
781 const aggressiveLabel = document.createElement("label");
782 aggressiveLabel.className = "spawner-buys-row";
783 const aggressive = document.createElement("input");
784 aggressive.type = "checkbox";
785 aggressive.name = "aggressive";
786 aggressive.checked = !!config.aggressive;
787 aggressive.addEventListener("change", () => syncBountyForAggressive());
788 aggressiveLabel.append(aggressive, document.createTextNode(" Aggressive (attacks players in range)"));
789 wrap.append(aggressiveLabel);
790 const aggressiveHint = document.createElement("p");
791 aggressiveHint.className = "hint";
792 aggressiveHint.textContent = "When Aggressive is on, Bounty is forced to 0.";
793 wrap.append(aggressiveHint);
794
795 wrap.append(field("Dialogue", dialogueSelect("dialogueId", config.dialogueId ?? "", dialogueOptions)));
796
797 const equipHeader = document.createElement("div");
798 equipHeader.className = "spawner-sells-header";
799 const equipTitle = document.createElement("strong");
800 equipTitle.textContent = "Equipment";
801 equipHeader.append(equipTitle);
802 wrap.append(equipHeader);
803
804 const equipList = document.createElement("div");
805 equipList.className = "spawner-equip-list";
806 equipList.dataset.equipmentList = "1";
807 wrap.append(equipList);
808
809 equipmentDraft = {};
810 for (const slot of EQUIPMENT_SLOTS)
811 { equipmentDraft[slot] = equipDraftFromConfig(config.equipment?.[slot]); }
812 queueMicrotask(() => renderEquipmentRows());
793 813
794 814 if (!exchange)
795 815 {
@@ -840,6 +860,21 @@ export function initTileConfigModal ({
840 860 return wrap;
841 861 }
842 862
863 function syncCommonSpawnerSection (config)
864 {
865 form.querySelector("[data-common-spawner]")?.remove();
866 const mobTypeId = form.querySelector('[name="mobTypeId"]')?.value
867 || config?.mobTypeId
868 || MobId.deer;
869 const normalized = config ?? normalizeSpawnerConfig({ mobTypeId }, "spawner");
870 const anchor = form.querySelector("[data-humanoid]") || form.querySelector("[data-spells]");
871 const section = renderCommonSpawnerFields(normalized);
872 if (anchor)
873 { form.insertBefore(section, anchor); }
874 else
875 { form.append(section); }
876 }
877
843 878 function syncHumanoidSection (config)
844 879 {
845 880 form.querySelector("[data-humanoid]")?.remove();
@@ -847,7 +882,6 @@ export function initTileConfigModal ({
847 882 if (!isHumanoidMob(mobTypeId))
848 883 {
849 884 sellsDraft = [];
850 dropsDraft = [];
851 885 equipmentDraft = {};
852 886 return;
853 887 }
@@ -1041,6 +1075,7 @@ export function initTileConfigModal ({
1041 1075 form.querySelector('[name="level"]').value = String(defaults.level ?? 1);
1042 1076 form.querySelector('[name="bounty"]').value = String(defaults.bounty ?? 0);
1043 1077 syncWanderMin();
1078 syncCommonSpawnerSection(defaults);
1044 1079 syncHumanoidSection(defaults);
1045 1080 syncSpellsSection(defaults);
1046 1081 syncBountyForAggressive();
@@ -1048,6 +1083,7 @@ export function initTileConfigModal ({
1048 1083 spellsDraft = (config.spells ?? []).map((line) => ({
1049 1084 spellId: String(line.spellId ?? "")
1050 1085 })).filter((line) => line.spellId);
1086 syncCommonSpawnerSection(config);
1051 1087 syncHumanoidSection(config);
1052 1088 syncSpellsSection(config);
1053 1089 syncBountyForAggressive();
@@ -8,7 +8,8 @@ import
8 MobId,
8 MobId,
9 isHumanoidMob,
9 isHumanoidMob,
10 isCentralExchangeSpawner,
10 isCentralExchangeSpawner,
11 spawnerEquipmentSlot
11 spawnerEquipmentSlot,
12 mobDefinition
12} from "/shared/definitions/mobs.js";
13} from "/shared/definitions/mobs.js";
13import { spellCastSuccessChancePercent } from "/shared/combat/magic.js";
14import { spellCastSuccessChancePercent } from "/shared/combat/magic.js";
14import { SPELL_DEFINITIONS, spellMinMagicLevel } from "/shared/definitions/spells.js";
15import { SPELL_DEFINITIONS, spellMinMagicLevel } from "/shared/definitions/spells.js";
@@ -687,12 +688,13 @@ export function initTileConfigModal ({
687 }
688 }
688 }
689 }
689
690
690 function renderHumanoidFields (config)
691 function renderCommonSpawnerFields (config)
691 {
692 {
692 const wrap = document.createElement("div");
693 const wrap = document.createElement("div");
693 wrap.className = "spawner-humanoid-fields";
694 wrap.className = "spawner-common-fields";
694 wrap.dataset.humanoid = "1";
695 wrap.dataset.commonSpawner = "1";
695 const exchange = isCentralExchangeSpawner(config);
696 const exchange = isCentralExchangeSpawner(config);
697
696 if (exchange)
698 if (exchange)
697 {
699 {
698 const note = document.createElement("p");
700 const note = document.createElement("p");
@@ -702,45 +704,17 @@ export function initTileConfigModal ({
702 }
704 }
703 else
705 else
704 {
706 {
707 const def = mobDefinition(config.mobTypeId);
708 const placeholder = def?.displayName || "Name";
705 wrap.append(
709 wrap.append(
706 field("Display name", textInput("displayName", config.displayName || "Shopkeeper")),
710 field("Display name", textInput("displayName", config.displayName || ""))
707 field("Sex", sexSelect("sex", config.sex))
708 );
711 );
712 const nameHint = document.createElement("p");
713 nameHint.className = "hint";
714 nameHint.textContent = `Optional. Empty uses the mob default (${placeholder}).`;
715 wrap.append(nameHint);
709 }
716 }
710
717
711 const aggressiveLabel = document.createElement("label");
712 aggressiveLabel.className = "spawner-buys-row";
713 const aggressive = document.createElement("input");
714 aggressive.type = "checkbox";
715 aggressive.name = "aggressive";
716 aggressive.checked = !!config.aggressive;
717 aggressive.addEventListener("change", () => syncBountyForAggressive());
718 aggressiveLabel.append(aggressive, document.createTextNode(" Aggressive (attacks players in range)"));
719 wrap.append(aggressiveLabel);
720 const aggressiveHint = document.createElement("p");
721 aggressiveHint.className = "hint";
722 aggressiveHint.textContent = "When Aggressive is on, Bounty is forced to 0.";
723 wrap.append(aggressiveHint);
724
725 wrap.append(field("Dialogue", dialogueSelect("dialogueId", config.dialogueId ?? "", dialogueOptions)));
726
727 const equipHeader = document.createElement("div");
728 equipHeader.className = "spawner-sells-header";
729 const equipTitle = document.createElement("strong");
730 equipTitle.textContent = "Equipment";
731 equipHeader.append(equipTitle);
732 wrap.append(equipHeader);
733
734 const equipList = document.createElement("div");
735 equipList.className = "spawner-equip-list";
736 equipList.dataset.equipmentList = "1";
737 wrap.append(equipList);
738
739 equipmentDraft = {};
740 for (const slot of EQUIPMENT_SLOTS)
741 { equipmentDraft[slot] = equipDraftFromConfig(config.equipment?.[slot]); }
742 queueMicrotask(() => renderEquipmentRows());
743
744 const dropsHeader = document.createElement("div");
718 const dropsHeader = document.createElement("div");
745 dropsHeader.className = "spawner-sells-header";
719 dropsHeader.className = "spawner-sells-header";
746 const dropsTitle = document.createElement("strong");
720 const dropsTitle = document.createElement("strong");
@@ -760,7 +734,7 @@ export function initTileConfigModal ({
760
734
761 const dropsHint = document.createElement("p");
735 const dropsHint = document.createElement("p");
762 dropsHint.className = "hint";
736 dropsHint.className = "hint";
763 dropsHint.textContent = "On death each line rolls its chance; if it hits, quantity is random between min and max (inclusive).";
737 dropsHint.textContent = "Configured drops replace the mob's default loot table. Leave empty to keep defaults. Each line rolls its chance; quantity is random between min and max (inclusive).";
764 wrap.append(dropsHint);
738 wrap.append(dropsHint);
765
739
766 dropsDraft = (config.drops ?? []).map((line) =>
740 dropsDraft = (config.drops ?? []).map((line) =>
@@ -790,6 +764,52 @@ export function initTileConfigModal ({
790 }).filter(Boolean);
764 }).filter(Boolean);
791
765
792 queueMicrotask(() => renderDropsList());
766 queueMicrotask(() => renderDropsList());
767 return wrap;
768 }
769
770 function renderHumanoidFields (config)
771 {
772 const wrap = document.createElement("div");
773 wrap.className = "spawner-humanoid-fields";
774 wrap.dataset.humanoid = "1";
775 const exchange = isCentralExchangeSpawner(config);
776 if (!exchange)
777 {
778 wrap.append(field("Sex", sexSelect("sex", config.sex)));
779 }
780
781 const aggressiveLabel = document.createElement("label");
782 aggressiveLabel.className = "spawner-buys-row";
783 const aggressive = document.createElement("input");
784 aggressive.type = "checkbox";
785 aggressive.name = "aggressive";
786 aggressive.checked = !!config.aggressive;
787 aggressive.addEventListener("change", () => syncBountyForAggressive());
788 aggressiveLabel.append(aggressive, document.createTextNode(" Aggressive (attacks players in range)"));
789 wrap.append(aggressiveLabel);
790 const aggressiveHint = document.createElement("p");
791 aggressiveHint.className = "hint";
792 aggressiveHint.textContent = "When Aggressive is on, Bounty is forced to 0.";
793 wrap.append(aggressiveHint);
794
795 wrap.append(field("Dialogue", dialogueSelect("dialogueId", config.dialogueId ?? "", dialogueOptions)));
796
797 const equipHeader = document.createElement("div");
798 equipHeader.className = "spawner-sells-header";
799 const equipTitle = document.createElement("strong");
800 equipTitle.textContent = "Equipment";
801 equipHeader.append(equipTitle);
802 wrap.append(equipHeader);
803
804 const equipList = document.createElement("div");
805 equipList.className = "spawner-equip-list";
806 equipList.dataset.equipmentList = "1";
807 wrap.append(equipList);
808
809 equipmentDraft = {};
810 for (const slot of EQUIPMENT_SLOTS)
811 { equipmentDraft[slot] = equipDraftFromConfig(config.equipment?.[slot]); }
812 queueMicrotask(() => renderEquipmentRows());
793
813
794 if (!exchange)
814 if (!exchange)
795 {
815 {
@@ -840,6 +860,21 @@ export function initTileConfigModal ({
840 return wrap;
860 return wrap;
841 }
861 }
842
862
863 function syncCommonSpawnerSection (config)
864 {
865 form.querySelector("[data-common-spawner]")?.remove();
866 const mobTypeId = form.querySelector('[name="mobTypeId"]')?.value
867 || config?.mobTypeId
868 || MobId.deer;
869 const normalized = config ?? normalizeSpawnerConfig({ mobTypeId }, "spawner");
870 const anchor = form.querySelector("[data-humanoid]") || form.querySelector("[data-spells]");
871 const section = renderCommonSpawnerFields(normalized);
872 if (anchor)
873 { form.insertBefore(section, anchor); }
874 else
875 { form.append(section); }
876 }
877
843 function syncHumanoidSection (config)
878 function syncHumanoidSection (config)
844 {
879 {
845 form.querySelector("[data-humanoid]")?.remove();
880 form.querySelector("[data-humanoid]")?.remove();
@@ -847,7 +882,6 @@ export function initTileConfigModal ({
847 if (!isHumanoidMob(mobTypeId))
882 if (!isHumanoidMob(mobTypeId))
848 {
883 {
849 sellsDraft = [];
884 sellsDraft = [];
850 dropsDraft = [];
851 equipmentDraft = {};
885 equipmentDraft = {};
852 return;
886 return;
853 }
887 }
@@ -1041,6 +1075,7 @@ export function initTileConfigModal ({
1041 form.querySelector('[name="level"]').value = String(defaults.level ?? 1);
1075 form.querySelector('[name="level"]').value = String(defaults.level ?? 1);
1042 form.querySelector('[name="bounty"]').value = String(defaults.bounty ?? 0);
1076 form.querySelector('[name="bounty"]').value = String(defaults.bounty ?? 0);
1043 syncWanderMin();
1077 syncWanderMin();
1078 syncCommonSpawnerSection(defaults);
1044 syncHumanoidSection(defaults);
1079 syncHumanoidSection(defaults);
1045 syncSpellsSection(defaults);
1080 syncSpellsSection(defaults);
1046 syncBountyForAggressive();
1081 syncBountyForAggressive();
@@ -1048,6 +1083,7 @@ export function initTileConfigModal ({
1048 spellsDraft = (config.spells ?? []).map((line) => ({
1083 spellsDraft = (config.spells ?? []).map((line) => ({
1049 spellId: String(line.spellId ?? "")
1084 spellId: String(line.spellId ?? "")
1050 })).filter((line) => line.spellId);
1085 })).filter((line) => line.spellId);
1086 syncCommonSpawnerSection(config);
1051 syncHumanoidSection(config);
1087 syncHumanoidSection(config);
1052 syncSpellsSection(config);
1088 syncSpellsSection(config);
1053 syncBountyForAggressive();
1089 syncBountyForAggressive();
scripts/content-manifest.mjs +24 −3
@@ -25,7 +25,8 @@ import
25 25 tierMineSkillLevel,
26 26 associatedBarTier,
27 27 isGemstoneMaterial,
28 metalTierForCloth
28 metalTierForCloth,
29 metalTierForHerbTier
29 30 } from "../shared/definitions/materialTiers.js";
30 31 import
31 32 {
@@ -37,7 +38,7 @@ import { CRAFT_RECIPES } from "../shared/crafting/stationRecipes.js";
37 38 import { ALCHEMY_POTION_DEFINITIONS } from "../shared/definitions/alchemy.js";
38 39 import { formatAlchemyStep, alchemyItemLabel } from "../shared/alchemy/recipes.js";
39 40 import { MOB_DEFINITIONS, defaultSpawnerConfig } from "../shared/definitions/mobs.js";
40 import { itemDefinition } from "../shared/definitions/items.js";
41 import { ITEM_DEFINITIONS, itemDefinition } from "../shared/definitions/items.js";
41 42 import { ARMOUR_CRAFT_PIECES } from "../shared/definitions/armourItems.js";
42 43 import { LEATHER_ARMOUR_PIECES } from "../shared/definitions/leatherArmourItems.js";
43 44 import { WIZARD_PIECES } from "../shared/definitions/wizardItems.js";
@@ -347,11 +348,12 @@ function buildMarkdown ()
347 348 const rows = HERB_ORDER.map((herbId) =>
348 349 {
349 350 const herb = HERB_DEFINITIONS[herbId];
351 const metal = metalTierForHerbTier(herb.tier);
350 352 return [
351 353 herb.displayName,
352 354 String(herb.tier),
353 355 String(herbGatherSkillLevel(herb.tier)),
354 "Plant clippers (any equippable tier)"
356 `${toolLabel(metal, "plant clippers")} or better`
355 357 ];
356 358 });
357 359 lines.push(mdTable(["Herb", "Herb tier", "Herbalism level", "Tool"], rows));
@@ -558,6 +560,25 @@ function buildMarkdown ()
558 560 }
559 561 lines.push("");
560 562
563 // --- All items ---
564 lines.push("## All items");
565 lines.push("");
566 {
567 const rows = Object.values(ITEM_DEFINITIONS)
568 .filter((def) => def?.itemId != null)
569 .slice()
570 .sort((a, b) => String(a.displayName ?? "").localeCompare(String(b.displayName ?? ""))
571 || ((a.itemId | 0) - (b.itemId | 0)))
572 .map((def) => [
573 def.displayName ?? String(def.itemId),
574 String(def.itemId),
575 def.key ?? "—",
576 def.description ?? "—"
577 ]);
578 lines.push(mdTable(["Name", "Id", "Key", "Description"], rows));
579 }
580 lines.push("");
581
561 582 return `${lines.join("\n")}\n`;
562 583 }
563 584
@@ -25,7 +25,8 @@ import
25 tierMineSkillLevel,
25 tierMineSkillLevel,
26 associatedBarTier,
26 associatedBarTier,
27 isGemstoneMaterial,
27 isGemstoneMaterial,
28 metalTierForCloth
28 metalTierForCloth,
29 metalTierForHerbTier
29} from "../shared/definitions/materialTiers.js";
30} from "../shared/definitions/materialTiers.js";
30import
31import
31{
32{
@@ -37,7 +38,7 @@ import { CRAFT_RECIPES } from "../shared/crafting/stationRecipes.js";
37import { ALCHEMY_POTION_DEFINITIONS } from "../shared/definitions/alchemy.js";
38import { ALCHEMY_POTION_DEFINITIONS } from "../shared/definitions/alchemy.js";
38import { formatAlchemyStep, alchemyItemLabel } from "../shared/alchemy/recipes.js";
39import { formatAlchemyStep, alchemyItemLabel } from "../shared/alchemy/recipes.js";
39import { MOB_DEFINITIONS, defaultSpawnerConfig } from "../shared/definitions/mobs.js";
40import { MOB_DEFINITIONS, defaultSpawnerConfig } from "../shared/definitions/mobs.js";
40import { itemDefinition } from "../shared/definitions/items.js";
41import { ITEM_DEFINITIONS, itemDefinition } from "../shared/definitions/items.js";
41import { ARMOUR_CRAFT_PIECES } from "../shared/definitions/armourItems.js";
42import { ARMOUR_CRAFT_PIECES } from "../shared/definitions/armourItems.js";
42import { LEATHER_ARMOUR_PIECES } from "../shared/definitions/leatherArmourItems.js";
43import { LEATHER_ARMOUR_PIECES } from "../shared/definitions/leatherArmourItems.js";
43import { WIZARD_PIECES } from "../shared/definitions/wizardItems.js";
44import { WIZARD_PIECES } from "../shared/definitions/wizardItems.js";
@@ -347,11 +348,12 @@ function buildMarkdown ()
347 const rows = HERB_ORDER.map((herbId) =>
348 const rows = HERB_ORDER.map((herbId) =>
348 {
349 {
349 const herb = HERB_DEFINITIONS[herbId];
350 const herb = HERB_DEFINITIONS[herbId];
351 const metal = metalTierForHerbTier(herb.tier);
350 return [
352 return [
351 herb.displayName,
353 herb.displayName,
352 String(herb.tier),
354 String(herb.tier),
353 String(herbGatherSkillLevel(herb.tier)),
355 String(herbGatherSkillLevel(herb.tier)),
354 "Plant clippers (any equippable tier)"
356 `${toolLabel(metal, "plant clippers")} or better`
355 ];
357 ];
356 });
358 });
357 lines.push(mdTable(["Herb", "Herb tier", "Herbalism level", "Tool"], rows));
359 lines.push(mdTable(["Herb", "Herb tier", "Herbalism level", "Tool"], rows));
@@ -558,6 +560,25 @@ function buildMarkdown ()
558 }
560 }
559 lines.push("");
561 lines.push("");
560
562
563 // --- All items ---
564 lines.push("## All items");
565 lines.push("");
566 {
567 const rows = Object.values(ITEM_DEFINITIONS)
568 .filter((def) => def?.itemId != null)
569 .slice()
570 .sort((a, b) => String(a.displayName ?? "").localeCompare(String(b.displayName ?? ""))
571 || ((a.itemId | 0) - (b.itemId | 0)))
572 .map((def) => [
573 def.displayName ?? String(def.itemId),
574 String(def.itemId),
575 def.key ?? "—",
576 def.description ?? "—"
577 ]);
578 lines.push(mdTable(["Name", "Id", "Key", "Description"], rows));
579 }
580 lines.push("");
581
561 return `${lines.join("\n")}\n`;
582 return `${lines.join("\n")}\n`;
562}
583}
563
584
server/src/combat/service.js +3 −2
@@ -707,9 +707,10 @@ function spawnMobDrops (world, targetHandle, tileX, tileY, now, attackerId = nul
707 707 const origin = lootOrigin(mobName, killerName);
708 708 const events = [];
709 709 const spawnOrigin = world.ecs.get(targetHandle, Component.spawnOrigin);
710 const customDrops = Array.isArray(spawnOrigin?.drops) ? spawnOrigin.drops : [];
711 /** Spawner loot picker replaces the mob's default table when any lines are set. */
710 712 const dropTable = [
711 ...(def?.drops ?? []),
712 ...(Array.isArray(spawnOrigin?.drops) ? spawnOrigin.drops : [])
713 ...(customDrops.length > 0 ? customDrops : (def?.drops ?? []))
713 714 ];
714 715 if (creature.element && (def?.essenceDropChance ?? 0) > 0)
715 716 {
@@ -707,9 +707,10 @@ function spawnMobDrops (world, targetHandle, tileX, tileY, now, attackerId = nul
707 const origin = lootOrigin(mobName, killerName);
707 const origin = lootOrigin(mobName, killerName);
708 const events = [];
708 const events = [];
709 const spawnOrigin = world.ecs.get(targetHandle, Component.spawnOrigin);
709 const spawnOrigin = world.ecs.get(targetHandle, Component.spawnOrigin);
710 const customDrops = Array.isArray(spawnOrigin?.drops) ? spawnOrigin.drops : [];
711 /** Spawner loot picker replaces the mob's default table when any lines are set. */
710 const dropTable = [
712 const dropTable = [
711 ...(def?.drops ?? []),
713 ...(customDrops.length > 0 ? customDrops : (def?.drops ?? []))
712 ...(Array.isArray(spawnOrigin?.drops) ? spawnOrigin.drops : [])
713 ];
714 ];
714 if (creature.element && (def?.essenceDropChance ?? 0) > 0)
715 if (creature.element && (def?.essenceDropChance ?? 0) > 0)
715 {
716 {
server/src/gathering/service.js +14 −10
@@ -24,7 +24,7 @@ import {
24 24 PLANT_EXHAUST_MS
25 25 } from "../../../shared/definitions/gathering.js";
26 26 import { rawClothItemId } from "../../../shared/definitions/clothItems.js";
27 import { ClothTier } from "../../../shared/definitions/materialTiers.js";
27 import { ClothTier, metalTierForHerbTier } from "../../../shared/definitions/materialTiers.js";
28 28 import {
29 29 flowerItemInstance,
30 30 flowerColorIdFromBlockState,
@@ -623,18 +623,10 @@ export function startPick (world, sessionId, characterId, tileX, tileY, now)
623 623 const inventory = world.ecs.get(handle, Component.inventory);
624 624 const equipment = world.ecs.get(handle, Component.equipment);
625 625 const skills = world.ecs.get(handle, Component.skills);
626 const clippers = resolvePlantClippers({
627 inventorySlots: inventory?.slots,
628 equipmentSlots: equipment?.slots,
629 skills,
630 requireTool: !!plant.requiresClippers,
631 minClothTier: plant.minClothTier ?? null
632 });
633 if (!clippers.ok)
634 { throw userError(clippers.reason); }
635 626
636 627 let herbId = null;
637 628 let herbTier = null;
629 let minMetalTier = null;
638 630 if (plant.kind === "herb")
639 631 {
640 632 const gate = resolveHerbGather({ herbId: block.state, skills });
@@ -642,8 +634,20 @@ export function startPick (world, sessionId, characterId, tileX, tileY, now)
642 634 { throw userError(gate.reason); }
643 635 herbId = gate.herb.herbId;
644 636 herbTier = gate.herb.tier;
637 minMetalTier = metalTierForHerbTier(gate.herb.tier);
645 638 }
646 639
640 const clippers = resolvePlantClippers({
641 inventorySlots: inventory?.slots,
642 equipmentSlots: equipment?.slots,
643 skills,
644 requireTool: !!plant.requiresClippers,
645 minClothTier: plant.minClothTier ?? null,
646 minMetalTier
647 });
648 if (!clippers.ok)
649 { throw userError(clippers.reason); }
650
647 651 const toolTier = clippers.tool?.tier ?? null;
648 652 const durationMs = Math.max(
649 653 1,
@@ -24,7 +24,7 @@ import {
24 PLANT_EXHAUST_MS
24 PLANT_EXHAUST_MS
25} from "../../../shared/definitions/gathering.js";
25} from "../../../shared/definitions/gathering.js";
26import { rawClothItemId } from "../../../shared/definitions/clothItems.js";
26import { rawClothItemId } from "../../../shared/definitions/clothItems.js";
27import { ClothTier } from "../../../shared/definitions/materialTiers.js";
27import { ClothTier, metalTierForHerbTier } from "../../../shared/definitions/materialTiers.js";
28import {
28import {
29 flowerItemInstance,
29 flowerItemInstance,
30 flowerColorIdFromBlockState,
30 flowerColorIdFromBlockState,
@@ -623,18 +623,10 @@ export function startPick (world, sessionId, characterId, tileX, tileY, now)
623 const inventory = world.ecs.get(handle, Component.inventory);
623 const inventory = world.ecs.get(handle, Component.inventory);
624 const equipment = world.ecs.get(handle, Component.equipment);
624 const equipment = world.ecs.get(handle, Component.equipment);
625 const skills = world.ecs.get(handle, Component.skills);
625 const skills = world.ecs.get(handle, Component.skills);
626 const clippers = resolvePlantClippers({
627 inventorySlots: inventory?.slots,
628 equipmentSlots: equipment?.slots,
629 skills,
630 requireTool: !!plant.requiresClippers,
631 minClothTier: plant.minClothTier ?? null
632 });
633 if (!clippers.ok)
634 { throw userError(clippers.reason); }
635
626
636 let herbId = null;
627 let herbId = null;
637 let herbTier = null;
628 let herbTier = null;
629 let minMetalTier = null;
638 if (plant.kind === "herb")
630 if (plant.kind === "herb")
639 {
631 {
640 const gate = resolveHerbGather({ herbId: block.state, skills });
632 const gate = resolveHerbGather({ herbId: block.state, skills });
@@ -642,8 +634,20 @@ export function startPick (world, sessionId, characterId, tileX, tileY, now)
642 { throw userError(gate.reason); }
634 { throw userError(gate.reason); }
643 herbId = gate.herb.herbId;
635 herbId = gate.herb.herbId;
644 herbTier = gate.herb.tier;
636 herbTier = gate.herb.tier;
637 minMetalTier = metalTierForHerbTier(gate.herb.tier);
645 }
638 }
646
639
640 const clippers = resolvePlantClippers({
641 inventorySlots: inventory?.slots,
642 equipmentSlots: equipment?.slots,
643 skills,
644 requireTool: !!plant.requiresClippers,
645 minClothTier: plant.minClothTier ?? null,
646 minMetalTier
647 });
648 if (!clippers.ok)
649 { throw userError(clippers.reason); }
650
647 const toolTier = clippers.tool?.tier ?? null;
651 const toolTier = clippers.tool?.tier ?? null;
648 const durationMs = Math.max(
652 const durationMs = Math.max(
649 1,
653 1,
server/src/simulation/spawners.js +2 −1
@@ -268,7 +268,8 @@ export function mobComponents (request)
268 268 const tint = magicElementTint(element);
269 269 appearance.tint = { r: tint.r, g: tint.g, b: tint.b };
270 270 appearance.bloomBody = !!def.bloomBody;
271 if (def.mobTypeId === MobId.sprite || def.randomElementOnSpawn)
271 if ((def.mobTypeId === MobId.sprite || def.randomElementOnSpawn)
272 && !String(request.displayName || "").trim())
272 273 {
273 274 const label = essenceElementDisplayName(element);
274 275 appearance.firstName = `${label} Sprite`;
@@ -268,7 +268,8 @@ export function mobComponents (request)
268 const tint = magicElementTint(element);
268 const tint = magicElementTint(element);
269 appearance.tint = { r: tint.r, g: tint.g, b: tint.b };
269 appearance.tint = { r: tint.r, g: tint.g, b: tint.b };
270 appearance.bloomBody = !!def.bloomBody;
270 appearance.bloomBody = !!def.bloomBody;
271 if (def.mobTypeId === MobId.sprite || def.randomElementOnSpawn)
271 if ((def.mobTypeId === MobId.sprite || def.randomElementOnSpawn)
272 && !String(request.displayName || "").trim())
272 {
273 {
273 const label = essenceElementDisplayName(element);
274 const label = essenceElementDisplayName(element);
274 appearance.firstName = `${label} Sprite`;
275 appearance.firstName = `${label} Sprite`;
server/tests/herbalism.test.js +40 −3
@@ -37,7 +37,7 @@ function countItem (slots, itemId)
37 37 .reduce((sum, slot) => sum + (slot.quantity | 0), 0);
38 38 }
39 39
40 test("sage herb plant yields sage with clippers", () =>
40 test("sage herb plant yields sage with matching-tier clippers", () =>
41 41 {
42 42 const harness = makeSimulation({ workerCount: 1 });
43 43 try
@@ -48,7 +48,7 @@ test("sage herb plant yields sage with clippers", () =>
48 48 const entityId = harness.simulation.spawnCharacter(1, character);
49 49 const bag = harness.simulation.bagOf(entityId);
50 50 bag.inventory = emptySlots();
51 bag.inventory[0] = { itemId: ItemId.bronzePlantClippers, quantity: 1 };
51 bag.inventory[0] = { itemId: ItemId.ironPlantClippers, quantity: 1 };
52 52 bag.equipment = emptyEquipment();
53 53 harness.simulation.applyBag(entityId, bag);
54 54
@@ -56,7 +56,8 @@ test("sage herb plant yields sage with clippers", () =>
56 56 const worker = harness.simulation.workers[record.workerId];
57 57 const handle = worker.world.ecs.handleOf(entityId);
58 58 const skills = worker.world.ecs.get(handle, Component.skills);
59 skills.xp[SkillId.herbalism] = totalXpForLevel(5);
59 /** Iron clippers need herbalism 10 to equip (sage gather gate is only 5). */
60 skills.xp[SkillId.herbalism] = totalXpForLevel(10);
60 61
61 62 harness.simulation.enqueue(1, {
62 63 type: "pick",
@@ -73,6 +74,42 @@ test("sage herb plant yields sage with clippers", () =>
73 74 { harness.close(); }
74 75 });
75 76
77 test("sage herb plant rejects under-tier clippers", () =>
78 {
79 const harness = makeSimulation({ workerCount: 1 });
80 try
81 {
82 placeBlock(harness.worldDb, 8, 8, BlockType.herbPlant, HerbId.sage);
83 harness.simulation.reloadWorld();
84 const character = makeCharacter(harness.stateDb, { tileX: 8, tileY: 9 });
85 const entityId = harness.simulation.spawnCharacter(1, character);
86 const bag = harness.simulation.bagOf(entityId);
87 bag.inventory = emptySlots();
88 bag.inventory[0] = { itemId: ItemId.bronzePlantClippers, quantity: 1 };
89 bag.equipment = emptyEquipment();
90 harness.simulation.applyBag(entityId, bag);
91
92 const record = harness.simulation.entityRecord(entityId);
93 const worker = harness.simulation.workers[record.workerId];
94 const handle = worker.world.ecs.handleOf(entityId);
95 const skills = worker.world.ecs.get(handle, Component.skills);
96 skills.xp[SkillId.herbalism] = totalXpForLevel(10);
97
98 harness.simulation.enqueue(1, {
99 type: "pick",
100 characterId: character.character_id,
101 tileX: 8,
102 tileY: 8
103 });
104 const result = harness.simulation.step();
105 const error = result.events.find((event) => event.type === "command-error");
106 assert.ok(error);
107 assert.match(error.message, /Iron plant clippers/i);
108 }
109 finally
110 { harness.close(); }
111 });
112
76 113 test("aconite herb plant rejects low herbalism", () =>
77 114 {
78 115 const harness = makeSimulation({ workerCount: 1 });
@@ -37,7 +37,7 @@ function countItem (slots, itemId)
37 .reduce((sum, slot) => sum + (slot.quantity | 0), 0);
37 .reduce((sum, slot) => sum + (slot.quantity | 0), 0);
38}
38}
39
39
40test("sage herb plant yields sage with clippers", () =>
40test("sage herb plant yields sage with matching-tier clippers", () =>
41{
41{
42 const harness = makeSimulation({ workerCount: 1 });
42 const harness = makeSimulation({ workerCount: 1 });
43 try
43 try
@@ -48,7 +48,7 @@ test("sage herb plant yields sage with clippers", () =>
48 const entityId = harness.simulation.spawnCharacter(1, character);
48 const entityId = harness.simulation.spawnCharacter(1, character);
49 const bag = harness.simulation.bagOf(entityId);
49 const bag = harness.simulation.bagOf(entityId);
50 bag.inventory = emptySlots();
50 bag.inventory = emptySlots();
51 bag.inventory[0] = { itemId: ItemId.bronzePlantClippers, quantity: 1 };
51 bag.inventory[0] = { itemId: ItemId.ironPlantClippers, quantity: 1 };
52 bag.equipment = emptyEquipment();
52 bag.equipment = emptyEquipment();
53 harness.simulation.applyBag(entityId, bag);
53 harness.simulation.applyBag(entityId, bag);
54
54
@@ -56,7 +56,8 @@ test("sage herb plant yields sage with clippers", () =>
56 const worker = harness.simulation.workers[record.workerId];
56 const worker = harness.simulation.workers[record.workerId];
57 const handle = worker.world.ecs.handleOf(entityId);
57 const handle = worker.world.ecs.handleOf(entityId);
58 const skills = worker.world.ecs.get(handle, Component.skills);
58 const skills = worker.world.ecs.get(handle, Component.skills);
59 skills.xp[SkillId.herbalism] = totalXpForLevel(5);
59 /** Iron clippers need herbalism 10 to equip (sage gather gate is only 5). */
60 skills.xp[SkillId.herbalism] = totalXpForLevel(10);
60
61
61 harness.simulation.enqueue(1, {
62 harness.simulation.enqueue(1, {
62 type: "pick",
63 type: "pick",
@@ -73,6 +74,42 @@ test("sage herb plant yields sage with clippers", () =>
73 { harness.close(); }
74 { harness.close(); }
74});
75});
75
76
77test("sage herb plant rejects under-tier clippers", () =>
78{
79 const harness = makeSimulation({ workerCount: 1 });
80 try
81 {
82 placeBlock(harness.worldDb, 8, 8, BlockType.herbPlant, HerbId.sage);
83 harness.simulation.reloadWorld();
84 const character = makeCharacter(harness.stateDb, { tileX: 8, tileY: 9 });
85 const entityId = harness.simulation.spawnCharacter(1, character);
86 const bag = harness.simulation.bagOf(entityId);
87 bag.inventory = emptySlots();
88 bag.inventory[0] = { itemId: ItemId.bronzePlantClippers, quantity: 1 };
89 bag.equipment = emptyEquipment();
90 harness.simulation.applyBag(entityId, bag);
91
92 const record = harness.simulation.entityRecord(entityId);
93 const worker = harness.simulation.workers[record.workerId];
94 const handle = worker.world.ecs.handleOf(entityId);
95 const skills = worker.world.ecs.get(handle, Component.skills);
96 skills.xp[SkillId.herbalism] = totalXpForLevel(10);
97
98 harness.simulation.enqueue(1, {
99 type: "pick",
100 characterId: character.character_id,
101 tileX: 8,
102 tileY: 8
103 });
104 const result = harness.simulation.step();
105 const error = result.events.find((event) => event.type === "command-error");
106 assert.ok(error);
107 assert.match(error.message, /Iron plant clippers/i);
108 }
109 finally
110 { harness.close(); }
111});
112
76test("aconite herb plant rejects low herbalism", () =>
113test("aconite herb plant rejects low herbalism", () =>
77{
114{
78 const harness = makeSimulation({ workerCount: 1 });
115 const harness = makeSimulation({ workerCount: 1 });
server/tests/shearing.test.js +23 −0
@@ -10,6 +10,7 @@ import {
10 10 ClothTier,
11 11 MaterialTier,
12 12 metalTierForCloth,
13 metalTierForHerbTier,
13 14 clothExhaustDurationMs,
14 15 tierRank
15 16 } from "../../shared/definitions/materialTiers.js";
@@ -188,6 +189,28 @@ test("silk cocoons need adamantium-or-better clippers", () =>
188 189 assert.equal(plant.minClothTier, "silk");
189 190 });
190 191
192 test("herb clippers require matching metal tier (sage → iron+)", () =>
193 {
194 assert.equal(metalTierForHerbTier(2), MaterialTier.iron);
195 assert.equal(metalTierForHerbTier(7), MaterialTier.dragon);
196 const skills = normalizePlayerSkills(null);
197 skills.xp[SkillId.herbalism] = totalXpForLevel(10);
198 const bronze = resolvePlantClippers({
199 inventorySlots: [{ itemId: MetalItemId.bronzePlantClippers, quantity: 1 }],
200 equipmentSlots: emptyEquipment().slots,
201 skills,
202 minMetalTier: metalTierForHerbTier(2)
203 });
204 assert.equal(bronze.ok, false);
205 const iron = resolvePlantClippers({
206 inventorySlots: [{ itemId: MetalItemId.ironPlantClippers, quantity: 1 }],
207 equipmentSlots: emptyEquipment().slots,
208 skills,
209 minMetalTier: metalTierForHerbTier(2)
210 });
211 assert.equal(iron.ok, true);
212 });
213
191 214 test("shearing a sheep grants wool and sets shorn state", () =>
192 215 {
193 216 const harness = makeSimulation({ workerCount: 1 });
@@ -10,6 +10,7 @@ import {
10 ClothTier,
10 ClothTier,
11 MaterialTier,
11 MaterialTier,
12 metalTierForCloth,
12 metalTierForCloth,
13 metalTierForHerbTier,
13 clothExhaustDurationMs,
14 clothExhaustDurationMs,
14 tierRank
15 tierRank
15} from "../../shared/definitions/materialTiers.js";
16} from "../../shared/definitions/materialTiers.js";
@@ -188,6 +189,28 @@ test("silk cocoons need adamantium-or-better clippers", () =>
188 assert.equal(plant.minClothTier, "silk");
189 assert.equal(plant.minClothTier, "silk");
189});
190});
190
191
192test("herb clippers require matching metal tier (sage → iron+)", () =>
193{
194 assert.equal(metalTierForHerbTier(2), MaterialTier.iron);
195 assert.equal(metalTierForHerbTier(7), MaterialTier.dragon);
196 const skills = normalizePlayerSkills(null);
197 skills.xp[SkillId.herbalism] = totalXpForLevel(10);
198 const bronze = resolvePlantClippers({
199 inventorySlots: [{ itemId: MetalItemId.bronzePlantClippers, quantity: 1 }],
200 equipmentSlots: emptyEquipment().slots,
201 skills,
202 minMetalTier: metalTierForHerbTier(2)
203 });
204 assert.equal(bronze.ok, false);
205 const iron = resolvePlantClippers({
206 inventorySlots: [{ itemId: MetalItemId.ironPlantClippers, quantity: 1 }],
207 equipmentSlots: emptyEquipment().slots,
208 skills,
209 minMetalTier: metalTierForHerbTier(2)
210 });
211 assert.equal(iron.ok, true);
212});
213
191test("shearing a sheep grants wool and sets shorn state", () =>
214test("shearing a sheep grants wool and sets shorn state", () =>
192{
215{
193 const harness = makeSimulation({ workerCount: 1 });
216 const harness = makeSimulation({ workerCount: 1 });
server/tests/spawner-bounty.test.js +35 −0
@@ -52,6 +52,41 @@ test("shade spawner defaults level 28", () =>
52 52 assert.equal(config.level, 28);
53 53 });
54 54
55 test("wildlife spawners keep display name and custom drops", () =>
56 {
57 const config = normalizeSpawnerConfig({
58 mobTypeId: MobId.deer,
59 displayName: "Stag",
60 drops: [{ itemId: ItemId.bones, chance: 0.5, quantityMin: 1, quantityMax: 2 }]
61 }, "deer-named");
62 assert.equal(config.displayName, "Stag");
63 assert.equal(config.drops.length, 1);
64 assert.equal(config.drops[0].itemId, ItemId.bones);
65 assert.equal(config.drops[0].chance, 0.5);
66
67 const components = mobComponents({
68 ...config,
69 tileX: 4,
70 tileY: 4,
71 spawnerId: config.spawnerId,
72 wanderRangeTiles: config.maxWanderRangeTiles
73 });
74 assert.equal(components.appearance.firstName, "Stag");
75 assert.deepEqual(components.spawnOrigin.drops, config.drops);
76 });
77
78 test("central exchange spawners clear authored display names", () =>
79 {
80 const config = normalizeSpawnerConfig({
81 mobTypeId: MobId.centralExchange,
82 displayName: "Should Not Stick",
83 drops: [{ itemId: ItemId.coins, chance: 1, quantityMin: 1, quantityMax: 1 }]
84 }, "ce-1");
85 assert.equal(config.displayName, "");
86 assert.equal(config.centralExchange, true);
87 assert.equal(config.drops.length, 1);
88 });
89
55 90 test("goblin spawns with slashing melee profile from mob definition", () =>
56 91 {
57 92 const harness = makeSimulation({ workerCount: 1 });
@@ -52,6 +52,41 @@ test("shade spawner defaults level 28", () =>
52 assert.equal(config.level, 28);
52 assert.equal(config.level, 28);
53});
53});
54
54
55test("wildlife spawners keep display name and custom drops", () =>
56{
57 const config = normalizeSpawnerConfig({
58 mobTypeId: MobId.deer,
59 displayName: "Stag",
60 drops: [{ itemId: ItemId.bones, chance: 0.5, quantityMin: 1, quantityMax: 2 }]
61 }, "deer-named");
62 assert.equal(config.displayName, "Stag");
63 assert.equal(config.drops.length, 1);
64 assert.equal(config.drops[0].itemId, ItemId.bones);
65 assert.equal(config.drops[0].chance, 0.5);
66
67 const components = mobComponents({
68 ...config,
69 tileX: 4,
70 tileY: 4,
71 spawnerId: config.spawnerId,
72 wanderRangeTiles: config.maxWanderRangeTiles
73 });
74 assert.equal(components.appearance.firstName, "Stag");
75 assert.deepEqual(components.spawnOrigin.drops, config.drops);
76});
77
78test("central exchange spawners clear authored display names", () =>
79{
80 const config = normalizeSpawnerConfig({
81 mobTypeId: MobId.centralExchange,
82 displayName: "Should Not Stick",
83 drops: [{ itemId: ItemId.coins, chance: 1, quantityMin: 1, quantityMax: 1 }]
84 }, "ce-1");
85 assert.equal(config.displayName, "");
86 assert.equal(config.centralExchange, true);
87 assert.equal(config.drops.length, 1);
88});
89
55test("goblin spawns with slashing melee profile from mob definition", () =>
90test("goblin spawns with slashing melee profile from mob definition", () =>
56{
91{
57 const harness = makeSimulation({ workerCount: 1 });
92 const harness = makeSimulation({ workerCount: 1 });
shared/definitions/gathering.js +6 −4
@@ -324,7 +324,7 @@ export function resolveFishingTool ({ inventorySlots, equipmentSlots, skills })
324 324
325 325 /**
326 326 * Best plant clippers for herbalism nodes.
327 * @param {{ inventorySlots: object[], equipmentSlots: object, skills: object, requireTool?: boolean, minClothTier?: string|null }} args
327 * @param {{ inventorySlots: object[], equipmentSlots: object, skills: object, requireTool?: boolean, minClothTier?: string|null, minMetalTier?: string|null }} args
328 328 * @returns {{ ok: true, tool: object|null } | { ok: false, reason: string }}
329 329 */
330 330 export function resolvePlantClippers ({
@@ -332,7 +332,8 @@ export function resolvePlantClippers ({
332 332 equipmentSlots,
333 333 skills,
334 334 requireTool = true,
335 minClothTier = null
335 minClothTier = null,
336 minMetalTier = null
336 337 })
337 338 {
338 339 if (!requireTool)
@@ -342,9 +343,10 @@ export function resolvePlantClippers ({
342 343 .sort((a, b) => tierRank(b.tier) - tierRank(a.tier));
343 344 if (!tools.length)
344 345 { return { ok: false, reason: "You need plant clippers to gather this!" }; }
345 if (minClothTier)
346 const needMetal = minMetalTier
347 ?? (minClothTier ? metalTierForCloth(minClothTier) : null);
348 if (needMetal)
346 349 {
347 const needMetal = metalTierForCloth(minClothTier);
348 350 const usable = tools.filter((tool) => tierRank(tool.tier) >= tierRank(needMetal));
349 351 if (!usable.length)
350 352 {
@@ -324,7 +324,7 @@ export function resolveFishingTool ({ inventorySlots, equipmentSlots, skills })
324
324
325/**
325/**
326 * Best plant clippers for herbalism nodes.
326 * Best plant clippers for herbalism nodes.
327 * @param {{ inventorySlots: object[], equipmentSlots: object, skills: object, requireTool?: boolean, minClothTier?: string|null }} args
327 * @param {{ inventorySlots: object[], equipmentSlots: object, skills: object, requireTool?: boolean, minClothTier?: string|null, minMetalTier?: string|null }} args
328 * @returns {{ ok: true, tool: object|null } | { ok: false, reason: string }}
328 * @returns {{ ok: true, tool: object|null } | { ok: false, reason: string }}
329 */
329 */
330export function resolvePlantClippers ({
330export function resolvePlantClippers ({
@@ -332,7 +332,8 @@ export function resolvePlantClippers ({
332 equipmentSlots,
332 equipmentSlots,
333 skills,
333 skills,
334 requireTool = true,
334 requireTool = true,
335 minClothTier = null
335 minClothTier = null,
336 minMetalTier = null
336})
337})
337{
338{
338 if (!requireTool)
339 if (!requireTool)
@@ -342,9 +343,10 @@ export function resolvePlantClippers ({
342 .sort((a, b) => tierRank(b.tier) - tierRank(a.tier));
343 .sort((a, b) => tierRank(b.tier) - tierRank(a.tier));
343 if (!tools.length)
344 if (!tools.length)
344 { return { ok: false, reason: "You need plant clippers to gather this!" }; }
345 { return { ok: false, reason: "You need plant clippers to gather this!" }; }
345 if (minClothTier)
346 const needMetal = minMetalTier
347 ?? (minClothTier ? metalTierForCloth(minClothTier) : null);
348 if (needMetal)
346 {
349 {
347 const needMetal = metalTierForCloth(minClothTier);
348 const usable = tools.filter((tool) => tierRank(tool.tier) >= tierRank(needMetal));
350 const usable = tools.filter((tool) => tierRank(tool.tier) >= tierRank(needMetal));
349 if (!usable.length)
351 if (!usable.length)
350 {
352 {
shared/definitions/materialTiers.js +7 −0
@@ -607,6 +607,13 @@ export function metalTierForCloth (clothTier)
607 607 return MATERIAL_TIER_ORDER[idx >= 0 ? idx : 0] ?? MaterialTier.bronze;
608 608 }
609 609
610 /** Matching metal tier for a folklore herb tier (1→bronze … 7→dragon). */
611 export function metalTierForHerbTier (herbTier)
612 {
613 const idx = Math.max(1, herbTier | 0) - 1;
614 return MATERIAL_TIER_ORDER[idx] ?? MaterialTier.bronze;
615 }
616
610 617 /** Matching leather tier for a cloth tier (cotton↔soft … dragonweave↔dragonhide). */
611 618 export function leatherTierForCloth (clothTier)
612 619 {
@@ -607,6 +607,13 @@ export function metalTierForCloth (clothTier)
607 return MATERIAL_TIER_ORDER[idx >= 0 ? idx : 0] ?? MaterialTier.bronze;
607 return MATERIAL_TIER_ORDER[idx >= 0 ? idx : 0] ?? MaterialTier.bronze;
608}
608}
609
609
610/** Matching metal tier for a folklore herb tier (1→bronze … 7→dragon). */
611export function metalTierForHerbTier (herbTier)
612{
613 const idx = Math.max(1, herbTier | 0) - 1;
614 return MATERIAL_TIER_ORDER[idx] ?? MaterialTier.bronze;
615}
616
610/** Matching leather tier for a cloth tier (cotton↔soft … dragonweave↔dragonhide). */
617/** Matching leather tier for a cloth tier (cotton↔soft … dragonweave↔dragonhide). */
611export function leatherTierForCloth (clothTier)
618export function leatherTierForCloth (clothTier)
612{
619{
shared/definitions/mobs.js +4 −2
@@ -722,7 +722,9 @@ export function normalizeSpawnerConfig (config, spawnerId = "spawner")
722 722 );
723 723 const sex = merged.sex === "female" ? "female" : "male";
724 724 const hiddenDiscount = Math.min(1, Math.max(0.01, Number(merged.hiddenDiscount) || base.hiddenDiscount));
725 const displayName = String(merged.displayName ?? "").trim().slice(0, 48);
725 const displayName = centralExchange
726 ? ""
727 : String(merged.displayName ?? "").trim().slice(0, 48);
726 728 const staffCap = centralExchangeStaffCount();
727 729 const level = Math.max(1, Math.min(99, Number(merged.level) || base.level || 1)) | 0;
728 730 const bodyNpc = isHumanoidMob(effectiveMob) || centralExchange || townGuard;
@@ -756,7 +758,7 @@ export function normalizeSpawnerConfig (config, spawnerId = "spawner")
756 758 displayName,
757 759 equipment: normalizeEquipment(merged.equipment),
758 760 sells: centralExchange ? [] : normalizeSells(merged.sells),
759 drops: bodyNpc ? normalizeDrops(merged.drops) : [],
761 drops: normalizeDrops(merged.drops),
760 762 spells: normalizeSpells(merged.spells),
761 763 buysItems: centralExchange ? false : !!merged.buysItems,
762 764 hiddenDiscount,
@@ -722,7 +722,9 @@ export function normalizeSpawnerConfig (config, spawnerId = "spawner")
722 );
722 );
723 const sex = merged.sex === "female" ? "female" : "male";
723 const sex = merged.sex === "female" ? "female" : "male";
724 const hiddenDiscount = Math.min(1, Math.max(0.01, Number(merged.hiddenDiscount) || base.hiddenDiscount));
724 const hiddenDiscount = Math.min(1, Math.max(0.01, Number(merged.hiddenDiscount) || base.hiddenDiscount));
725 const displayName = String(merged.displayName ?? "").trim().slice(0, 48);
725 const displayName = centralExchange
726 ? ""
727 : String(merged.displayName ?? "").trim().slice(0, 48);
726 const staffCap = centralExchangeStaffCount();
728 const staffCap = centralExchangeStaffCount();
727 const level = Math.max(1, Math.min(99, Number(merged.level) || base.level || 1)) | 0;
729 const level = Math.max(1, Math.min(99, Number(merged.level) || base.level || 1)) | 0;
728 const bodyNpc = isHumanoidMob(effectiveMob) || centralExchange || townGuard;
730 const bodyNpc = isHumanoidMob(effectiveMob) || centralExchange || townGuard;
@@ -756,7 +758,7 @@ export function normalizeSpawnerConfig (config, spawnerId = "spawner")
756 displayName,
758 displayName,
757 equipment: normalizeEquipment(merged.equipment),
759 equipment: normalizeEquipment(merged.equipment),
758 sells: centralExchange ? [] : normalizeSells(merged.sells),
760 sells: centralExchange ? [] : normalizeSells(merged.sells),
759 drops: bodyNpc ? normalizeDrops(merged.drops) : [],
761 drops: normalizeDrops(merged.drops),
760 spells: normalizeSpells(merged.spells),
762 spells: normalizeSpells(merged.spells),
761 buysItems: centralExchange ? false : !!merged.buysItems,
763 buysItems: centralExchange ? false : !!merged.buysItems,
762 hiddenDiscount,
764 hiddenDiscount,