diff --git a/src/module/patch.js b/src/module/patch.js index 3df7301..6dbb3c1 100644 --- a/src/module/patch.js +++ b/src/module/patch.js @@ -126,7 +126,6 @@ function patchRollData() { ); } - export function applyPatches() { patchCompendiumImport(); patchResourceBars(); diff --git a/src/module/templates.js b/src/module/templates.js index fc38454..cb5cfd8 100644 --- a/src/module/templates.js +++ b/src/module/templates.js @@ -4,7 +4,6 @@ * @return {Promise} */ export const preloadHandlebarsTemplates = async function () { - const partials = [ // Actor Sheet Partials "modules/wjmais/templates/actors/parts/actor-features.hbs", @@ -12,8 +11,8 @@ export const preloadHandlebarsTemplates = async function () { ]; const paths = {}; - for ( const path of partials ) { - paths[path.replace(".hbs", ".html")] = path; + for (const path of partials) { + paths[path.replace(".hbs", ".html")] = path; paths[`wjmais.${path.split("/").pop().replace(".hbs", "")}`] = path; } diff --git a/src/module/wildjammer-sheet.js b/src/module/wildjammer-sheet.js index c488f20..c36eb42 100644 --- a/src/module/wildjammer-sheet.js +++ b/src/module/wildjammer-sheet.js @@ -58,7 +58,7 @@ async function isRoleChangeInvalid(role, ship, creature) { const creatureShipId = creature.flags?.wjmais?.shipId; if (creatureShipId && role != "unassigned") { const ship = game.actors.get(creature.flags.wjmais.shipId); - if (ship && (ship.id != creatureShipId)) { + if (ship && ship.id != creatureShipId) { ui.notifications.error( creature.name + game.i18n.localize("WJMAIS.ActorAlreadyAssigned") + @@ -419,7 +419,9 @@ export default class WildjammerSheet extends dnd5e.applications.actor _prepareEquippableItem(item, context) { const isActive = !!item.system.equipped; context.toggleClass = isActive ? "active" : ""; - context.toggleTitle = game.i18n.localize(isActive ? "DND5E.Equipped" : "DND5E.Unequipped"); + context.toggleTitle = game.i18n.localize( + isActive ? "DND5E.Equipped" : "DND5E.Unequipped" + ); context.canToggle = "equipped" in item.system; } @@ -467,7 +469,7 @@ export default class WildjammerSheet extends dnd5e.applications.actor _getCrewValue(item) { const crewProperties = Object.keys(CONFIG.WJMAIS.crewValues); const itemProperties = Array.from(item.system.properties); - const crewProperty = crewProperties.find(r => itemProperties.includes(r)); + const crewProperty = crewProperties.find((r) => itemProperties.includes(r)); return crewProperty ? CONFIG.WJMAIS.crewValues[crewProperty] : 0; } @@ -706,7 +708,7 @@ export default class WildjammerSheet extends dnd5e.applications.actor for (const item of context.items) { // Item details - const ctx = context.itemContext[item.id] ??= {}; + const ctx = (context.itemContext[item.id] ??= {}); this._prepareEquippableItem(item, ctx); item["rollable"] = this._isRollable(item); if (item.type === "weapon" && item.system?.properties.has("smw")) { @@ -748,10 +750,7 @@ export default class WildjammerSheet extends dnd5e.applications.actor context.roles = Object.values(roles); context.features = Object.values(features); context.cargo = Object.values(cargo); - context.encumbrance = this._computeEncumbrance( - totalWeight, - context - ); + context.encumbrance = this._computeEncumbrance(totalWeight, context); } /* -------------------------------------------- */ @@ -859,7 +858,9 @@ export default class WildjammerSheet extends dnd5e.applications.actor event.preventDefault(); const idx = Number(row.dataset.itemIndex); const type = row.classList.contains("crew") ? "crew" : "passengers"; - const cargoCollection = foundry.utils.deepClone(this.actor.system.cargo[type]).filter((_, i) => i !== idx); + const cargoCollection = foundry.utils + .deepClone(this.actor.system.cargo[type]) + .filter((_, i) => i !== idx); return this.actor.update({ [`system.cargo.${type}`]: cargoCollection }); } } diff --git a/src/module/wjmais.js b/src/module/wjmais.js index 312d5e3..c1c5e7b 100644 --- a/src/module/wjmais.js +++ b/src/module/wjmais.js @@ -14,10 +14,10 @@ Actors.registerSheet("wjmais", WildjammerSheet, { // Handlebars helper: has // check if a value is contained in a set -Handlebars.registerHelper("has", function( value, set, options ) { - // fallback... - set = ( set instanceof Set ) ? set : {set}; - return set.has(value) ? options.fn(this) : ""; +Handlebars.registerHelper("has", function (value, set, options) { + // fallback... + set = set instanceof Set ? set : { set }; + return set.has(value) ? options.fn(this) : ""; }); function localize(stringId, data = {}) { @@ -33,7 +33,9 @@ function translateObject(obj) { function translateProperties(obj) { /* translate in place */ - Object.keys(obj).forEach((key) => (obj[key].label = localize(obj[key].label))); + Object.keys(obj).forEach( + (key) => (obj[key].label = localize(obj[key].label)) + ); return obj; } @@ -44,10 +46,10 @@ function configProperties() { "Bulwark Points" ); -CONFIG.DND5E.armorClasses.wildjammer = { - label: localize("WJMAIS.Wildjammer"), - formula: "10 + @ship.ac.mod" -}; + CONFIG.DND5E.armorClasses.wildjammer = { + label: localize("WJMAIS.Wildjammer"), + formula: "10 + @ship.ac.mod", + }; mergeObject( globalThis.game.dnd5e.config.equipmentTypes, @@ -79,36 +81,41 @@ CONFIG.DND5E.armorClasses.wildjammer = { }); const wjWeaponProperties = { - bf1: {label: "WJMAIS.WeaponPropertyBackfire1"}, - bf2: {label: "WJMAIS.WeaponPropertyBackfire2"}, - bf3: {label: "WJMAIS.WeaponPropertyBackfire3"}, - bf4: {label: "WJMAIS.WeaponPropertyBackfire4"}, - clb: {label: "WJMAIS.WeaponPropertyClimbing"}, - dpl: {label: "WJMAIS.WeaponPropertyDeployable"}, - cr1: {label: "WJMAIS.WeaponPropertyCrew1"}, - cr2: {label: "WJMAIS.WeaponPropertyCrew2"}, - cr3: {label: "WJMAIS.WeaponPropertyCrew3"}, - cr4: {label: "WJMAIS.WeaponPropertyCrew4"}, - cr5: {label: "WJMAIS.WeaponPropertyCrew5"}, - cr6: {label: "WJMAIS.WeaponPropertyCrew6"}, - cr7: {label: "WJMAIS.WeaponPropertyCrew7"}, - cr8: {label: "WJMAIS.WeaponPropertyCrew8"}, - fmm: {label: "WJMAIS.WeaponPropertyForeMantleModule"}, - fxd: {label: "WJMAIS.WeaponPropertyFixed"}, - hlm: {label: "WJMAIS.WeaponPropertyHelmsman"}, - hps: {label: "WJMAIS.WeaponPropertyHardpointSmall"}, - hpm: {label: "WJMAIS.WeaponPropertyHardpointMedium"}, - hpl: {label: "WJMAIS.WeaponPropertyHardpointLarge"}, - ovh: {label: "WJMAIS.WeaponPropertyOverheat"}, - sc1d12: {label: "WJMAIS.WeaponPropertyScatter112"}, - sc2d6: {label: "WJMAIS.WeaponPropertyScatter26"}, - sc2d10: {label: "WJMAIS.WeaponPropertyScatter210"}, - smw: {label: "WJMAIS.WeaponPropertyShipWeapon"}, - ram: {label: "WJMAIS.WeaponPropertyRam"}, + bf1: { label: "WJMAIS.WeaponPropertyBackfire1" }, + bf2: { label: "WJMAIS.WeaponPropertyBackfire2" }, + bf3: { label: "WJMAIS.WeaponPropertyBackfire3" }, + bf4: { label: "WJMAIS.WeaponPropertyBackfire4" }, + clb: { label: "WJMAIS.WeaponPropertyClimbing" }, + dpl: { label: "WJMAIS.WeaponPropertyDeployable" }, + cr1: { label: "WJMAIS.WeaponPropertyCrew1" }, + cr2: { label: "WJMAIS.WeaponPropertyCrew2" }, + cr3: { label: "WJMAIS.WeaponPropertyCrew3" }, + cr4: { label: "WJMAIS.WeaponPropertyCrew4" }, + cr5: { label: "WJMAIS.WeaponPropertyCrew5" }, + cr6: { label: "WJMAIS.WeaponPropertyCrew6" }, + cr7: { label: "WJMAIS.WeaponPropertyCrew7" }, + cr8: { label: "WJMAIS.WeaponPropertyCrew8" }, + fmm: { label: "WJMAIS.WeaponPropertyForeMantleModule" }, + fxd: { label: "WJMAIS.WeaponPropertyFixed" }, + hlm: { label: "WJMAIS.WeaponPropertyHelmsman" }, + hps: { label: "WJMAIS.WeaponPropertyHardpointSmall" }, + hpm: { label: "WJMAIS.WeaponPropertyHardpointMedium" }, + hpl: { label: "WJMAIS.WeaponPropertyHardpointLarge" }, + ovh: { label: "WJMAIS.WeaponPropertyOverheat" }, + sc1d12: { label: "WJMAIS.WeaponPropertyScatter112" }, + sc2d6: { label: "WJMAIS.WeaponPropertyScatter26" }, + sc2d10: { label: "WJMAIS.WeaponPropertyScatter210" }, + smw: { label: "WJMAIS.WeaponPropertyShipWeapon" }, + ram: { label: "WJMAIS.WeaponPropertyRam" }, }; - mergeObject(CONFIG.DND5E.itemProperties, translateProperties(wjWeaponProperties)); - Object.keys(wjWeaponProperties).forEach((key) => CONFIG.DND5E.validProperties.weapon.add(key)); + mergeObject( + CONFIG.DND5E.itemProperties, + translateProperties(wjWeaponProperties) + ); + Object.keys(wjWeaponProperties).forEach((key) => + CONFIG.DND5E.validProperties.weapon.add(key) + ); } async function openQuickReference() {