dh-ikonis/scripts/ikonis-data.js

79 lines
3.3 KiB
JavaScript

export const DEFAULT_AUGMENTS = [
{ id: "force", name: "Kinetic Amplifier", effect: "+1 Damage on Melee attacks", cost: "2 Iron", precompile: 1 },
{ id: "fire", name: "Thermal Core", effect: "Deals Fire damage instead of Physical", cost: "1 Blaze Glass", precompile: 1 },
{ id: "shock", name: "Static Coil", effect: "Targets hit are Dazed", cost: "3 Copper", precompile: 2 },
{ id: "shield", name: "Reactive Plating", effect: "+1 Armor while equipped", cost: "2 Steel", precompile: 1 },
{ id: "range", name: "Long-Range Optics", effect: "Increases Range by 1 step", cost: "1 Lens", precompile: 2 },
{ id: "crit", name: "Precision Chip", effect: "+1 to Crit range", cost: "1 Gold", precompile: 3 },
{ id: "multi", name: "Burst Module", effect: "Can target 2 enemies (Half damage)", cost: "2 Gears", precompile: 4 },
{ id: "drain", name: "Siphon Link", effect: "Recover 1 Hope on kill", cost: "1 Soul Gem", precompile: 4 },
{ id: "weight", name: "Gravity Plate", effect: "Weapon is Heavy (more damage)", cost: "4 Lead", precompile: 2 }
];
// Global caches for resolved features to keep getters fast
const _featureCache = new Map();
/**
* Scans the Daggerheart system config for any weapon features starting with "Ikonis:".
* These are treated as available augments for our slot system.
*/
export function getAugments() {
// We get the resolved features from CONFIG.DH.ITEM which includes system + homebrew
const allFeatures = CONFIG.DH.ITEM.allWeaponFeatures() || {};
const augments = [];
for (const [id, feature] of Object.entries(allFeatures)) {
const name = feature.label || feature.name || "";
if (name.startsWith("Ikonis:")) {
const desc = feature.description ? feature.description.replace(/<[^>]*>?/gm, '').trim() : "";
const lines = desc.split(/\n|\r/).map(l => l.trim()).filter(l => l.length > 0);
const costLine = lines.find(l => l.toLowerCase().startsWith("cost:"));
const effectLine = lines.find(l => !l.toLowerCase().startsWith("cost:"));
augments.push({
id: id,
name: name.replace("Ikonis:", "").trim(),
fullName: name,
effect: effectLine || "Native Feature",
cost: costLine || ""
});
}
}
return augments;
}
export function getSlotCount(item) {
const flags = item.getFlag('dh-ikonis') || {};
if (typeof flags.slotOverride === "number") return flags.slotOverride;
let tier = item.system?.tier?.value;
if (tier === undefined) tier = item.system?.tier;
const tierNum = parseInt(tier) || 1;
const settingKey = `slotsTier${tierNum}`;
try {
return game.settings.get('dh-ikonis', settingKey);
} catch (e) {
return tierNum >= 2 ? 3 : 2;
}
}
/**
* Patches the system's weapon data preparation to handle slot counts.
*/
export function patchIkonisLogic() {
// Current slot logic is handled via getSlotCount in the sheet context
}
/**
* Placeholder for character patching - no longer needed for virtual items
*/
export function patchDhCharacter(DhCharacter) {
// Injection is deprecated in favor of native weapon features
}
export function patchDHWeapon() {
// Future: Add damage type override logic here
}