⚙️ ${game.i18n.localize("MGNE.Notification.RollUsageDiceReminder")}
- ${lines}
import { ASCII, SYSTEM, SYSTEM_ID, localizeSystemConfig } from "./module/config/system.mjs" import * as models from "./module/models/_module.mjs" import * as documents from "./module/documents/_module.mjs" import * as applications from "./module/applications/_module.mjs" import MGNERoll from "./module/documents/roll.mjs" Hooks.once("init", () => { console.info(ASCII) console.info(`${SYSTEM_ID} | Initializing system`) game.mgne = { SYSTEM, applications, documents, models, } CONFIG.Actor.documentClass = documents.MGNEActor CONFIG.Actor.dataModels = { character: models.MGNECharacter, creature: models.MGNECreature, companion: models.MGNECompanion, party: models.MGNEParty, } CONFIG.Combat.documentClass = documents.MGNECombat CONFIG.Item.documentClass = documents.MGNEItem CONFIG.Item.dataModels = { weapon: models.MGNEWeapon, armor: models.MGNEArmor, shield: models.MGNEShield, equipment: models.MGNEEquipment, "resonance-core": models.MGNEResonanceCore, artifact: models.MGNEArtifact, feature: models.MGNEFeature, "creature-trait": models.MGNECreatureTrait, } foundry.applications.sheets.ActorSheetV2 && foundry.documents.collections.Actors.unregisterSheet( "core", foundry.applications.sheets.ActorSheetV2, { types: Object.keys(CONFIG.Actor.dataModels) } ) foundry.appv1?.sheets?.ActorSheet && foundry.documents.collections.Actors.unregisterSheet("core", foundry.appv1.sheets.ActorSheet) foundry.documents.collections.Actors.registerSheet(SYSTEM_ID, applications.MGNECharacterSheet, { types: ["character"], makeDefault: true, label: SYSTEM.actorTypes.character.label }) foundry.documents.collections.Actors.registerSheet(SYSTEM_ID, applications.MGNECreatureSheet, { types: ["creature"], makeDefault: true, label: SYSTEM.actorTypes.creature.label }) foundry.documents.collections.Actors.registerSheet(SYSTEM_ID, applications.MGNECompanionSheet, { types: ["companion"], makeDefault: true, label: SYSTEM.actorTypes.companion.label }) foundry.documents.collections.Actors.registerSheet(SYSTEM_ID, applications.MGNEPartySheet, { types: ["party"], makeDefault: true, label: SYSTEM.actorTypes.party.label }) foundry.applications.sheets.ItemSheetV2 && foundry.documents.collections.Items.unregisterSheet( "core", foundry.applications.sheets.ItemSheetV2, { types: Object.keys(CONFIG.Item.dataModels) } ) foundry.appv1?.sheets?.ItemSheet && foundry.documents.collections.Items.unregisterSheet("core", foundry.appv1.sheets.ItemSheet) foundry.documents.collections.Items.registerSheet(SYSTEM_ID, applications.MGNEWeaponSheet, { types: ["weapon"], makeDefault: true, label: SYSTEM.itemTypes.weapon.label }) foundry.documents.collections.Items.registerSheet(SYSTEM_ID, applications.MGNEArmorSheet, { types: ["armor"], makeDefault: true, label: SYSTEM.itemTypes.armor.label }) foundry.documents.collections.Items.registerSheet(SYSTEM_ID, applications.MGNEShieldSheet, { types: ["shield"], makeDefault: true, label: SYSTEM.itemTypes.shield.label }) foundry.documents.collections.Items.registerSheet(SYSTEM_ID, applications.MGNEEquipmentSheet, { types: ["equipment"], makeDefault: true, label: SYSTEM.itemTypes.equipment.label }) foundry.documents.collections.Items.registerSheet(SYSTEM_ID, applications.MGNEResonanceCoreSheet, { types: ["resonance-core"], makeDefault: true, label: SYSTEM.itemTypes["resonance-core"].label }) foundry.documents.collections.Items.registerSheet(SYSTEM_ID, applications.MGNEArtifactSheet, { types: ["artifact"], makeDefault: true, label: SYSTEM.itemTypes.artifact.label }) foundry.documents.collections.Items.registerSheet(SYSTEM_ID, applications.MGNEFeatureSheet, { types: ["feature"], makeDefault: true, label: SYSTEM.itemTypes.feature.label }) foundry.documents.collections.Items.registerSheet(SYSTEM_ID, applications.MGNECreatureTraitSheet, { types: ["creature-trait"], makeDefault: true, label: SYSTEM.itemTypes["creature-trait"].label }) Handlebars.registerHelper("isEqual", (left, right) => left === right) Handlebars.registerHelper("includes", (collection, value) => { if (!collection) return false if (collection instanceof Set) return collection.has(value) if (Array.isArray(collection)) return collection.includes(value) return false }) }) Hooks.once("setup", () => { localizeSystemConfig() // Strip phantom null-_id entries from all compendium indices. // Foundry V14 LevelDatabase creates !items!null entries on open under Node24. if (typeof CompendiumCollection !== "undefined") { const orig = CompendiumCollection.prototype.getIndex; CompendiumCollection.prototype.getIndex = async function(opts) { const r = await orig.call(this, opts); for (const k of [...this.index.keys()]) { if (!k) this.index.delete(k); } return r; }; } }); Hooks.once("ready", async () => { console.info(`${SYSTEM_ID} | Ready`) // Clean anything already in the index before we patched for (const pack of game.packs) { for (const k of [...pack.index.keys()]) { if (!k) pack.index.delete(k); } } if (!game.user.isGM) return if (game.scenes.getName("Map")) return const pack = game.packs.get("fvtt-machine-gods-noxian-expanse.scenes") if (!pack) { console.warn(`${SYSTEM_ID} | Scenes compendium not found`) return } const index = await pack.getIndex() const entry = index.find(s => s.name === "Map") if (!entry) { console.warn(`${SYSTEM_ID} | Map scene not found in compendium`) return } const doc = await pack.getDocument(entry._id) if (doc) { const scene = await Scene.create(doc.toObject(), { keepId: false }) if (scene) { await scene.activate() } } }) Hooks.on("deleteCombat", (combat) => { if (!game.user.isGM) return const pcActors = [...new Set( combat.combatants .filter(c => c.actor?.hasPlayerOwner) .map(c => c.actor) )] const cores = pcActors.flatMap(actor => actor.items.filter(item => item.type === "resonance-core" && !item.system.burnedOut && item.system.usageDie !== "depleted") ) if (!cores.length) return const lines = cores.map(c => `
⚙️ ${game.i18n.localize("MGNE.Notification.RollUsageDiceReminder")}
${game.i18n.format("MGNE.RollDialog.OmenReducePrompt", { name: targetActor.name, omens: targetOmens })}
${reduceMsg}