Skip to content

Commit

Permalink
Lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
surged20 committed Jun 6, 2024
1 parent de5ecb9 commit 04b7deb
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 50 deletions.
1 change: 0 additions & 1 deletion src/module/patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ function patchRollData() {
);
}


export function applyPatches() {
patchCompendiumImport();
patchResourceBars();
Expand Down
5 changes: 2 additions & 3 deletions src/module/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@
* @return {Promise}
*/
export const preloadHandlebarsTemplates = async function () {

const partials = [
// Actor Sheet Partials
"modules/wjmais/templates/actors/parts/actor-features.hbs",
"modules/wjmais/templates/actors/parts/bridge-crew-roles.hbs",
];

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;
}

Expand Down
19 changes: 10 additions & 9 deletions src/module/wildjammer-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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") +
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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")) {
Expand Down Expand Up @@ -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);
}

/* -------------------------------------------- */
Expand Down Expand Up @@ -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 });
}
}
Expand Down
81 changes: 44 additions & 37 deletions src/module/wjmais.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}) {
Expand All @@ -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;
}
Expand All @@ -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,
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 04b7deb

Please sign in to comment.