diff --git a/module/BladesActor.js b/module/BladesActor.js index 3f8fba43..eec973c4 100644 --- a/module/BladesActor.js +++ b/module/BladesActor.js @@ -43,12 +43,12 @@ class BladesActor extends Actor { if (U.isDocID(actorRef)) { return BladesActor.All.get(actorRef); } - return BladesActor.All.find(a => a.system.world_name === actorRef) - || BladesActor.All.find(a => a.name === actorRef); + return BladesActor.All.find((a) => a.system.world_name === actorRef) + || BladesActor.All.find((a) => a.name === actorRef); } static GetTypeWithTags(docType, ...tags) { - return BladesActor.All.filter(actor => actor.type === docType) - .filter(actor => actor.hasTag(...tags)); + return BladesActor.All.filter((actor) => actor.type === docType) + .filter((actor) => actor.hasTag(...tags)); } static IsType(doc, ...types) { const typeSet = new Set(types); @@ -56,11 +56,11 @@ class BladesActor extends Actor { } get tags() { return this.system.tags ?? []; } hasTag(...tags) { - return tags.every(tag => this.tags.includes(tag)); + return tags.every((tag) => this.tags.includes(tag)); } async addTag(...tags) { const curTags = this.tags; - tags.forEach(tag => { + tags.forEach((tag) => { if (curTags.includes(tag)) { return; } @@ -70,7 +70,7 @@ class BladesActor extends Actor { await this.update({ "system.tags": curTags }); } async remTag(...tags) { - const curTags = this.tags.filter(tag => !tags.includes(tag)); + const curTags = this.tags.filter((tag) => !tags.includes(tag)); eLog.checkLog2("actor", "BladesActor.remTag(...tags)", { tags, curTags }); await this.update({ "system.tags": curTags }); } @@ -107,14 +107,14 @@ class BladesActor extends Actor { } get subActors() { return Object.keys(this.system.subactors) - .map(id => this.getSubActor(id)) + .map((id) => this.getSubActor(id)) .filter((subActor) => Boolean(subActor)); } get activeSubActors() { - return this.subActors.filter(subActor => !subActor.hasTag(Tag.System.Archived)); + return this.subActors.filter((subActor) => !subActor.hasTag(Tag.System.Archived)); } get archivedSubActors() { - return this.subActors.filter(subActor => subActor.hasTag(Tag.System.Archived)); + return this.subActors.filter((subActor) => subActor.hasTag(Tag.System.Archived)); } checkActorPrereqs(actor) { @@ -123,8 +123,8 @@ class BladesActor extends Actor { processEmbeddedActorMatches(globalActors) { return globalActors .filter(this.checkActorPrereqs) - .filter(gActor => !this.activeSubActors.some(aActor => aActor.id === gActor.id)) - .map(gActor => this.getSubActor(gActor) || gActor) + .filter((gActor) => !this.activeSubActors.some((aActor) => aActor.id === gActor.id)) + .map((gActor) => this.getSubActor(gActor) || gActor) .sort((a, b) => { if (a.name === b.name) { return 0; @@ -203,13 +203,13 @@ class BladesActor extends Actor { if (!focusSubActor) { return; } - const uniqueTags = focusSubActor.tags.filter(tag => tag in BladesActorUniqueTags); + const uniqueTags = focusSubActor.tags.filter((tag) => tag in BladesActorUniqueTags); if (uniqueTags.length > 0) { - uniqueTags.forEach(uTag => this.activeSubActors + uniqueTags.forEach((uTag) => this.activeSubActors .filter((subActor) => Boolean(focusSubActor?.id && subActor.id !== focusSubActor.id && subActor.hasTag(uTag))) - .map(subActor => this.remSubActor(subActor.id))); + .map((subActor) => this.remSubActor(subActor.id))); } } getSubActor(actorRef) { @@ -258,7 +258,7 @@ class BladesActor extends Actor { await this.update({ "system.subactors": mergeObject(this.system.subactors, { [`-=${subActor.id}`]: null }) }, undefined, true); } async clearSubActors(isReRendering = true) { - this.subActors.forEach(subActor => { + this.subActors.forEach((subActor) => { if (subActor.parentActor?.id === this.id) { subActor.clearParentActor(isReRendering); } @@ -280,8 +280,8 @@ class BladesActor extends Actor { } get subItems() { return Array.from(this.items); } - get activeSubItems() { return this.items.filter(item => !item.hasTag(Tag.System.Archived)); } - get archivedSubItems() { return this.items.filter(item => item.hasTag(Tag.System.Archived)); } + get activeSubItems() { return this.items.filter((item) => !item.hasTag(Tag.System.Archived)); } + get archivedSubItems() { return this.items.filter((item) => item.hasTag(Tag.System.Archived)); } _checkItemPrereqs(item) { if (!item.system.prereqs) { return true; @@ -321,8 +321,8 @@ class BladesActor extends Actor { } _processActiveItemPrereq(pString, hitRecord, pType) { const thisItem = this.activeSubItems - .filter(i => !hitRecord[pType]?.includes(i.id)) - .find(i => i.system.world_name === pString); + .filter((i) => !hitRecord[pType]?.includes(i.id)) + .find((i) => i.system.world_name === pString); if (thisItem) { hitRecord[pType]?.push(thisItem.id); return true; @@ -333,8 +333,8 @@ class BladesActor extends Actor { } _processActiveItemsByTagPrereq(pString, hitRecord, pType) { const thisItem = this.activeSubItems - .filter(i => !hitRecord[pType]?.includes(i.id)) - .find(i => i.hasTag(pString)); + .filter((i) => !hitRecord[pType]?.includes(i.id)) + .find((i) => i.hasTag(pString)); if (thisItem) { hitRecord[pType]?.push(thisItem.id); return true; @@ -354,11 +354,11 @@ class BladesActor extends Actor { } _processEmbeddedItemMatches(globalItems) { return globalItems - .filter(item => this._checkItemPrereqs(item)) - .filter(gItem => gItem.hasTag(Tag.System.MultiplesOK) + .filter((item) => this._checkItemPrereqs(item)) + .filter((gItem) => gItem.hasTag(Tag.System.MultiplesOK) || (gItem.system.max_per_score ?? 1) - > this.activeSubItems.filter(sItem => sItem.system.world_name === gItem.system.world_name).length) - .map(gItem => { + > this.activeSubItems.filter((sItem) => sItem.system.world_name === gItem.system.world_name).length) + .map((gItem) => { const matchingSubItems = this.archivedSubItems.filter((sItem) => sItem.system.world_name === gItem.system.world_name); if (matchingSubItems.length > 0) { return matchingSubItems; @@ -368,7 +368,7 @@ class BladesActor extends Actor { } }) .flat() - .map(sItem => { + .map((sItem) => { sItem.dialogCSSClasses = ""; const cssClasses = []; if (sItem.isEmbedded) { @@ -471,7 +471,7 @@ class BladesActor extends Actor { else if (category === SelectionCategory.Playbook) { if (this.type === BladesActorType.pc) { dialogData.Basic = this._processEmbeddedItemMatches(BladesItem.GetTypeWithTags(BladesItemType.playbook) - .filter(item => !item.hasTag(Tag.Gear.Advanced))); + .filter((item) => !item.hasTag(Tag.Gear.Advanced))); dialogData.Advanced = this._processEmbeddedItemMatches(BladesItem.GetTypeWithTags(BladesItemType.playbook, Tag.Gear.Advanced)); } else if (this.type === BladesActorType.crew) { @@ -493,11 +493,11 @@ class BladesActor extends Actor { ...BladesItem.GetTypeWithTags(BladesItemType.gear, playbookName), ...BladesItem.GetTypeWithTags(BladesItemType.gear, Tag.Gear.General) ]) - .filter(item => self.remainingLoad >= item.system.load); - dialogData[playbookName] = gearItems.filter(item => item.hasTag(playbookName)); + .filter((item) => self.remainingLoad >= item.system.load); + dialogData[playbookName] = gearItems.filter((item) => item.hasTag(playbookName)); dialogData.General = gearItems - .filter(item => item.hasTag(Tag.Gear.General)) - .map(item => { + .filter((item) => item.hasTag(Tag.Gear.General)) + .map((item) => { if (item.dialogCSSClasses) { item.dialogCSSClasses = item.dialogCSSClasses.replace(/featured-item\s?/g, ""); } @@ -520,8 +520,8 @@ class BladesActor extends Actor { } dialogData[playbookName] = this._processEmbeddedItemMatches(BladesItem.GetTypeWithTags(BladesItemType.ability, playbookName)); dialogData.Veteran = this._processEmbeddedItemMatches(BladesItem.GetTypeWithTags(BladesItemType.ability)) - .filter(item => !item.hasTag(playbookName)) - .map(item => { + .filter((item) => !item.hasTag(playbookName)) + .map((item) => { if (item.dialogCSSClasses) { item.dialogCSSClasses = item.dialogCSSClasses.replace(/featured-item\s?/g, ""); } @@ -563,8 +563,8 @@ class BladesActor extends Actor { if (!globalItem) { return undefined; } - return this.items.find(item => item.name === globalItem.name && activeCheck(item)) - ?? this.items.find(item => item.system.world_name === globalItem.system.world_name && activeCheck(item)); + return this.items.find((item) => item.name === globalItem.name && activeCheck(item)) + ?? this.items.find((item) => item.system.world_name === globalItem.system.world_name && activeCheck(item)); } } hasSubItemOf(itemRef) { @@ -572,14 +572,14 @@ class BladesActor extends Actor { if (!item) { return false; } - return Boolean(this.items.find(i => i.system.world_name === item.system.world_name)); + return Boolean(this.items.find((i) => i.system.world_name === item.system.world_name)); } hasActiveSubItemOf(itemRef) { const item = BladesItem.Get(itemRef); if (!item) { return false; } - return Boolean(this.items.find(i => !i.hasTag(Tag.System.Archived) + return Boolean(this.items.find((i) => !i.hasTag(Tag.System.Archived) && i.system.world_name === item.system.world_name)); } async addSubItem(itemRef) { @@ -611,7 +611,7 @@ class BladesActor extends Actor { } if (focusItem && isBladesItemUniqueTypes(focusItem.type)) { await Promise.all(this.activeSubItems - .filter(subItem => subItem.type === focusItem?.type + .filter((subItem) => subItem.type === focusItem?.type && subItem.system.world_name !== focusItem?.system.world_name && !subItem.hasTag(Tag.System.Archived)) .map(this.remSubItem.bind(this))); @@ -675,13 +675,13 @@ class BladesActor extends Actor { const pointsUpgrade = this.system.advancement_points?.[AdvancementPoint.Upgrade] ?? 0; const pointsUpgradeOrAbility = this.system.advancement_points?.[AdvancementPoint.UpgradeOrAbility] ?? 0; const spentAbility = U.sum(this.items - .filter(item => BladesItem.IsType(item, BladesItemType.ability, BladesItemType.crew_ability)) - .map(abil => abil.system.price ?? 1)); + .filter((item) => BladesItem.IsType(item, BladesItemType.ability, BladesItemType.crew_ability)) + .map((abil) => abil.system.price ?? 1)); const spentCohortType = U.sum(this.cohorts - .map(cohort => Math.max(0, U.unique(Object.values(cohort.system.subtypes)).length - 1))); + .map((cohort) => Math.max(0, U.unique(Object.values(cohort.system.subtypes)).length - 1))); const spentUpgrade = U.sum(this.items - .filter(item => BladesItem.IsType(item, BladesItemType.crew_upgrade)) - .map(upgrade => upgrade.system.price ?? 1)); + .filter((item) => BladesItem.IsType(item, BladesItemType.crew_upgrade)) + .map((upgrade) => upgrade.system.price ?? 1)); const excessUpgrade = Math.max(0, spentUpgrade - pointsUpgrade); const excessCohortType = Math.max(0, spentCohortType - pointsCohortType); const excessAbility = Math.max(0, spentAbility - pointsAbility); @@ -720,7 +720,7 @@ class BladesActor extends Actor { } if (BladesActor.IsType(this, BladesActorType.crew)) { BladesPushAlert.Get().pushToAll("GM", `${this.name} Advances their Playbook!`, "Select new Upgrades and/or Abilities on your Crew Sheet."); - this.members.forEach(member => { + this.members.forEach((member) => { const coinGained = this.system.tier.value + 2; BladesPushAlert.Get().pushToAll("GM", `${member.name} Gains ${coinGained} Stash (Crew Advancement)`, undefined); member.addStash(coinGained); @@ -730,7 +730,7 @@ class BladesActor extends Actor { } async advanceAttribute(attribute) { await this.update({ [`system.experience.${attribute}.value`]: 0 }); - const actions = C.Action[attribute].map(action => `${U.tCase(action)}`); + const actions = C.Action[attribute].map((action) => `${U.tCase(action)}`); BladesPushAlert.Get().pushToAll("GM", `${this.name} Advances their ${U.uCase(attribute)}!`, `${this.name}, add a dot to one of ${U.oxfordize(actions, true, "or")}.`); } parentActor; @@ -796,7 +796,7 @@ class BladesActor extends Actor { return 0; } return Object.values(this.playbook.system.turfs) - .filter(claim => claim.isTurf && claim.value).length; + .filter((claim) => claim.isTurf && claim.value).length; } get upgrades() { if (!BladesActor.IsType(this, BladesActorType.crew) || !this.playbook) { @@ -829,14 +829,14 @@ class BladesActor extends Actor { system.experience.clues = [ ...system.experience.clues, ...Object.values(this.playbook.system.experience_clues) - .filter(clue => Boolean(clue.trim())) + .filter((clue) => Boolean(clue.trim())) ]; } if (this.playbook) { system.gather_info = [ ...system.gather_info, ...Object.values(this.playbook.system.gather_info_questions) - .filter(question => Boolean(question.trim())) + .filter((question) => Boolean(question.trim())) ]; } } @@ -848,7 +848,7 @@ class BladesActor extends Actor { system.experience.clues = [ ...system.experience.clues, ...Object.values(this.playbook.system.experience_clues) - .filter(clue => Boolean(clue.trim())) + .filter((clue) => Boolean(clue.trim())) ]; system.turfs = this.playbook.system.turfs; } @@ -858,17 +858,17 @@ class BladesActor extends Actor { await Promise.all(docs.map(async (doc) => { if (BladesItem.IsType(doc, BladesItemType.playbook, BladesItemType.crew_playbook)) { await Promise.all(this.activeSubItems - .filter(aItem => aItem.type === doc.type && aItem.system.world_name !== doc.system.world_name) - .map(aItem => this.remSubItem(aItem))); + .filter((aItem) => aItem.type === doc.type && aItem.system.world_name !== doc.system.world_name) + .map((aItem) => this.remSubItem(aItem))); } })); await super._onCreateDescendantDocuments(parent, collection, docs, data, options, userId); eLog.checkLog("actorTrigger", "_onCreateDescendantDocuments", { parent, collection, docs, data, options, userId }); - docs.forEach(doc => { + docs.forEach((doc) => { if (BladesItem.IsType(doc, BladesItemType.vice) && BladesActor.IsType(this, BladesActorType.pc)) { this.activeSubActors - .filter(subActor => subActor.hasTag(Tag.NPC.VicePurveyor) && !subActor.hasTag(doc.name)) - .forEach(subActor => { this.remSubActor(subActor); }); + .filter((subActor) => subActor.hasTag(Tag.NPC.VicePurveyor) && !subActor.hasTag(doc.name)) + .forEach((subActor) => { this.remSubActor(subActor); }); } }); } @@ -931,7 +931,7 @@ class BladesActor extends Actor { const suffixChance = 0.01; const { persona, secret, random } = this.system; function sampleArray(arr, ...curVals) { - arr = arr.filter(elem => !curVals.includes(elem)); + arr = arr.filter((elem) => !curVals.includes(elem)); if (!arr.length) { return ""; } @@ -952,7 +952,7 @@ class BladesActor extends Actor { Math.random() <= suffixChance ? sampleArray(Randomizers.NPC.name_suffix) : "" - ].filter(val => Boolean(val)).join(" "); + ].filter((val) => Boolean(val)).join(" "); }, background: () => sampleArray(Randomizers.NPC.background, random.background.value), heritage: () => sampleArray(Randomizers.NPC.heritage, random.heritage.value), @@ -971,14 +971,14 @@ class BladesActor extends Actor { }; const gender = persona.gender.isLocked ? persona.gender.value : randomGen.gender(); const updateKeys = [ - ...Object.keys(persona).filter(key => !persona[key]?.isLocked), - ...Object.keys(random).filter(key => !random[key]?.isLocked), - ...Object.keys(secret).filter(key => !secret[key]?.isLocked) - .map(secretKey => `secret-${secretKey}`) + ...Object.keys(persona).filter((key) => !persona[key]?.isLocked), + ...Object.keys(random).filter((key) => !random[key]?.isLocked), + ...Object.keys(secret).filter((key) => !secret[key]?.isLocked) + .map((secretKey) => `secret-${secretKey}`) ]; eLog.checkLog("Update Keys", { updateKeys }); const updateData = {}; - updateKeys.forEach(key => { + updateKeys.forEach((key) => { switch (key) { case "name": case "heritage": diff --git a/module/BladesItem.js b/module/BladesItem.js index 6437fa2d..7ff70c87 100644 --- a/module/BladesItem.js +++ b/module/BladesItem.js @@ -29,17 +29,17 @@ class BladesItem extends Item { if (U.isDocID(itemRef)) { return BladesItem.All.get(itemRef); } - return BladesItem.All.find(a => a.system.world_name === itemRef) - || BladesItem.All.find(a => a.name === itemRef); + return BladesItem.All.find((a) => a.system.world_name === itemRef) + || BladesItem.All.find((a) => a.name === itemRef); } static GetTypeWithTags(docType, ...tags) { if (Array.isArray(docType)) { return docType - .map(dType => BladesItem.All.filter((item) => item.type === dType)) + .map((dType) => BladesItem.All.filter((item) => item.type === dType)) .flat(); } return BladesItem.All.filter((item) => item.type === docType) - .filter(item => item.hasTag(...tags)); + .filter((item) => item.hasTag(...tags)); } static IsType(doc, ...types) { const typeSet = new Set(types); @@ -47,11 +47,11 @@ class BladesItem extends Item { } get tags() { return this.system.tags ?? []; } hasTag(...tags) { - return tags.every(tag => this.tags.includes(tag)); + return tags.every((tag) => this.tags.includes(tag)); } async addTag(...tags) { const curTags = this.tags; - tags.forEach(tag => { + tags.forEach((tag) => { if (curTags.includes(tag)) { return; } @@ -60,7 +60,7 @@ class BladesItem extends Item { await this.update({ "system.tags": curTags }); } async remTag(...tags) { - const curTags = this.tags.filter(tag => !tags.includes(tag)); + const curTags = this.tags.filter((tag) => !tags.includes(tag)); await this.update({ "system.tags": curTags }); } get tooltip() { @@ -217,23 +217,23 @@ class BladesItem extends Item { } system.tier.name = "Quality"; const subtypes = U.unique(Object.values(system.subtypes) - .map(subtype => subtype.trim()) - .filter(subtype => /[A-Za-z]/.test(subtype))); + .map((subtype) => subtype.trim()) + .filter((subtype) => /[A-Za-z]/.test(subtype))); const eliteSubtypes = U.unique([ ...Object.values(system.elite_subtypes), ...(this.parent?.upgrades ?? []) - .filter(upgrade => (upgrade.name ?? "").startsWith("Elite")) - .map(upgrade => (upgrade.name ?? "").trim().replace(/^Elite /, "")) + .filter((upgrade) => (upgrade.name ?? "").startsWith("Elite")) + .map((upgrade) => (upgrade.name ?? "").trim().replace(/^Elite /, "")) ] - .map(subtype => subtype.trim()) - .filter(subtype => /[A-Za-z]/.test(subtype) && subtypes.includes(subtype))); + .map((subtype) => subtype.trim()) + .filter((subtype) => /[A-Za-z]/.test(subtype) && subtypes.includes(subtype))); system.subtypes = Object.fromEntries(subtypes.map((subtype, i) => [`${i + 1}`, subtype])); system.elite_subtypes = Object.fromEntries(eliteSubtypes.map((subtype, i) => [`${i + 1}`, subtype])); system.edges = Object.fromEntries(Object.values(system.edges ?? []) - .filter(edge => /[A-Za-z]/.test(edge)) + .filter((edge) => /[A-Za-z]/.test(edge)) .map((edge, i) => [`${i + 1}`, edge.trim()])); system.flaws = Object.fromEntries(Object.values(system.flaws ?? []) - .filter(flaw => /[A-Za-z]/.test(flaw)) + .filter((flaw) => /[A-Za-z]/.test(flaw)) .map((flaw, i) => [`${i + 1}`, flaw.trim()])); system.quality = this.getFactorTotal(Factor.quality); if (BladesItem.IsType(this, BladesItemType.cohort_gang)) { @@ -262,8 +262,8 @@ class BladesItem extends Item { } else { system.subtitle += ` ${U.oxfordize([ - ...subtypes.filter(subtype => !eliteSubtypes.includes(subtype)), - ...eliteSubtypes.map(subtype => `Elite ${subtype}`) + ...subtypes.filter((subtype) => !eliteSubtypes.includes(subtype)), + ...eliteSubtypes.map((subtype) => `Elite ${subtype}`) ], false, "&")}`; } } @@ -279,12 +279,12 @@ class BladesItem extends Item { return; } const expClueData = {}; - [...Object.values(system.experience_clues).filter(clue => /[A-Za-z]/.test(clue)), " "].forEach((clue, i) => { expClueData[(i + 1).toString()] = clue; }); + [...Object.values(system.experience_clues).filter((clue) => /[A-Za-z]/.test(clue)), " "].forEach((clue, i) => { expClueData[(i + 1).toString()] = clue; }); system.experience_clues = expClueData; eLog.checkLog3("experienceClues", { expClueData }); if (BladesItem.IsType(this, BladesItemType.playbook)) { const gatherInfoData = {}; - [...Object.values(system.gather_info_questions).filter(question => /[A-Za-z]/.test(question)), " "].forEach((question, i) => { gatherInfoData[(i + 1).toString()] = question; }); + [...Object.values(system.gather_info_questions).filter((question) => /[A-Za-z]/.test(question)), " "].forEach((question, i) => { gatherInfoData[(i + 1).toString()] = question; }); system.gather_info_questions = gatherInfoData; eLog.checkLog3("gatherInfoQuestions", { gatherInfoData }); } diff --git a/module/BladesPushAlert.js b/module/BladesPushAlert.js index 0eebcc6d..cc04f809 100644 --- a/module/BladesPushAlert.js +++ b/module/BladesPushAlert.js @@ -86,7 +86,7 @@ export default class BladesPushAlert { return; } const pushArgs = args.slice(0, 3); - socketlib.system.executeForUsers("pushNotice", users.map(user => user.id), "", ...pushArgs); + socketlib.system.executeForUsers("pushNotice", users.map((user) => user.id), "", ...pushArgs); } pushToGM(...args) { socketlib.system.executeForAllGMs("pushNotice", "to-gm-notice", ...args); diff --git a/module/BladesRoll.js b/module/BladesRoll.js index ae82062b..6e877f99 100644 --- a/module/BladesRoll.js +++ b/module/BladesRoll.js @@ -57,20 +57,20 @@ class BladesRollMod { return []; } return roll_mods - .filter(elem => typeof elem === "string") - .map(modString => { + .filter((elem) => typeof elem === "string") + .map((modString) => { const pStrings = modString.split(/@/); - const nameString = U.pullElement(pStrings, v => typeof v === "string" && /^na/i.test(v)); + const nameString = U.pullElement(pStrings, (v) => typeof v === "string" && /^na/i.test(v)); const nameVal = (typeof nameString === "string" && nameString.replace(/^.*:/, "")); if (!nameVal) { throw new Error(`RollMod Missing Name: '${modString}'`); } - const catString = U.pullElement(pStrings, v => typeof v === "string" && /^cat/i.test(v)); + const catString = U.pullElement(pStrings, (v) => typeof v === "string" && /^cat/i.test(v)); const catVal = (typeof catString === "string" && catString.replace(/^.*:/, "")); if (!catVal || !(catVal in RollModSection)) { throw new Error(`RollMod Missing Category: '${modString}'`); } - const posNegString = (U.pullElement(pStrings, v => typeof v === "string" && /^p/i.test(v)) || "posNeg:positive"); + const posNegString = (U.pullElement(pStrings, (v) => typeof v === "string" && /^p/i.test(v)) || "posNeg:positive"); const posNegVal = posNegString.replace(/^.*:/, ""); const rollModData = { id: `${nameVal}-${posNegVal}-${catVal}`, @@ -82,7 +82,7 @@ class BladesRollMod { posNeg: posNegVal, tooltip: "" }; - pStrings.forEach(pString => { + pStrings.forEach((pString) => { const [keyString, valString] = pString.split(/:/); let val = /\|/.test(valString) ? valString.split(/\|/) : valString; let key; @@ -209,16 +209,16 @@ class BladesRollMod { } get isPush() { return Boolean(U.lCase(this.name) === "push" - || this.effectKeys.find(eKey => eKey === "Is-Push")); + || this.effectKeys.find((eKey) => eKey === "Is-Push")); } get isBasicPush() { return U.lCase(this.name) === "push"; } get stressCost() { - const costKeys = this.effectKeys.filter(key => key.startsWith("Cost-Stress")); + const costKeys = this.effectKeys.filter((key) => key.startsWith("Cost-Stress")); if (costKeys.length === 0) { return 0; } let stressCost = 0; - costKeys.forEach(key => { + costKeys.forEach((key) => { const [thisParam] = (key.split(/-/) ?? []).slice(1); const [_, valStr] = (/([A-Za-z]+)(\d*)/.exec(thisParam) ?? []).slice(1); stressCost += U.pInt(valStr); @@ -290,7 +290,7 @@ class BladesRollMod { return false; } setAutoStatus() { - const holdKeys = this.effectKeys.filter(key => key.startsWith("Auto")); + const holdKeys = this.effectKeys.filter((key) => key.startsWith("Auto")); if (holdKeys.length === 0) { return false; } @@ -303,12 +303,12 @@ class BladesRollMod { return true; } setRelevancyStatus() { - const holdKeys = this.effectKeys.filter(key => /^Negate|^Increase/.test(key)); + const holdKeys = this.effectKeys.filter((key) => /^Negate|^Increase/.test(key)); if (holdKeys.length === 0) { return false; } const relevantKeys = holdKeys - .filter(key => { + .filter((key) => { const [thisKey, thisParam] = key.split(/-/) ?? []; const negateOperations = { PushCost: () => this.rollInstance.isPushed(), @@ -350,12 +350,12 @@ class BladesRollMod { return false; } setPayableStatus() { - const holdKeys = this.effectKeys.filter(key => key.startsWith("Cost")); + const holdKeys = this.effectKeys.filter((key) => key.startsWith("Cost")); if (holdKeys.length === 0) { return false; } const payableKeys = holdKeys - .filter(key => { + .filter((key) => { const [thisParam] = (key.split(/-/) ?? []).slice(1); const [traitStr, valStr] = (/([A-Za-z]+)(\d*)/.exec(thisParam) ?? []).slice(1); const { rollPrimaryDoc } = this.rollInstance.rollPrimary ?? {}; @@ -386,18 +386,18 @@ class BladesRollMod { if (!this.isActive) { return; } - const holdKeys = this.effectKeys.filter(key => /^Negate|^Increase/.test(key)); + const holdKeys = this.effectKeys.filter((key) => /^Negate|^Increase/.test(key)); if (holdKeys.length === 0) { return; } - holdKeys.forEach(key => { + holdKeys.forEach((key) => { const [thisKey, thisParam] = key.split(/-/) ?? []; const negateOperations = { PushCost: () => { const costlyPushMod = this.rollInstance.getActiveRollMods() - .find(mod => mod.isPush && mod.stressCost > 0); + .find((mod) => mod.isPush && mod.stressCost > 0); if (costlyPushMod) { - U.pullElement(costlyPushMod.effectKeys, k => k.startsWith("Cost-Stress")); + U.pullElement(costlyPushMod.effectKeys, (k) => k.startsWith("Cost-Stress")); } }, Consequence: () => { @@ -495,11 +495,11 @@ class BladesRollMod { if (!this.isActive) { return undefined; } - const holdKeys = this.effectKeys.filter(key => key.startsWith("Cost")); + const holdKeys = this.effectKeys.filter((key) => key.startsWith("Cost")); if (holdKeys.length === 0) { return undefined; } - return holdKeys.map(key => { + return holdKeys.map((key) => { const [thisParam] = (key.split(/-/) ?? []).slice(1); const [traitStr, valStr] = (/([A-Za-z]+)(\d*)/.exec(thisParam) ?? []).slice(1); let label = this.name; @@ -1148,13 +1148,13 @@ class BladesRoll extends DocumentSheet { } static GetUserPermissions(config) { - const GMUserID = game.users.find(user => user.isGM)?.id; + const GMUserID = game.users.find((user) => user.isGM)?.id; if (!GMUserID) { throw new Error("[BladesRoll.GetUserPermissions()] No GM found!"); } const playerUserIDs = game.users - .filter(user => BladesPC.IsType(user.character) && !user.isGM && typeof user.id === "string") - .map(user => user.id); + .filter((user) => BladesPC.IsType(user.character) && !user.isGM && typeof user.id === "string") + .map((user) => user.id); const userIDs = { [RollPermissions.GM]: [GMUserID], [RollPermissions.Primary]: [], @@ -1186,11 +1186,11 @@ class BladesRoll extends DocumentSheet { userIDs[RollPermissions.Participant].push(...getParticipantDocUserIDs(config.rollParticipantData, playerUserIDs)); } userIDs[RollPermissions.Observer] = playerUserIDs - .filter(uID => !userIDs[RollPermissions.Participant].includes(uID)); + .filter((uID) => !userIDs[RollPermissions.Participant].includes(uID)); return userIDs; function getParticipantDocs(participantData) { return Object.values(flattenObject(participantData)) - .map(pData => { + .map((pData) => { if (BladesRollParticipant.IsDoc(pData)) { return pData; } @@ -1210,7 +1210,7 @@ class BladesRoll extends DocumentSheet { } function getParticipantDocUserIDs(participantData, unassignedIDs) { return getParticipantDocs(participantData) - .map(pDoc => { + .map((pDoc) => { if (BladesPC.IsType(pDoc) && typeof pDoc.primaryUser?.id === "string") { return pDoc.primaryUser.id; } @@ -1221,7 +1221,7 @@ class BladesRoll extends DocumentSheet { return null; }) .flat() - .filter(pUser => pUser !== null && !userIDs[RollPermissions.Primary].includes(pUser)); + .filter((pUser) => pUser !== null && !userIDs[RollPermissions.Primary].includes(pUser)); } } static async PrepareActionRoll(rollID, config) { @@ -1299,7 +1299,7 @@ class BladesRoll extends DocumentSheet { const { rollPrimaryDoc } = config.rollPrimaryData; if (BladesPC.IsType(rollPrimaryDoc)) { const minAttrVal = Math.min(...Object.values(rollPrimaryDoc.attributes)); - config.rollTrait = U.sample(Object.values(AttributeTrait).filter(attr => rollPrimaryDoc.attributes[attr] === minAttrVal))[0]; + config.rollTrait = U.sample(Object.values(AttributeTrait).filter((attr) => rollPrimaryDoc.attributes[attr] === minAttrVal))[0]; } if (!(U.isInt(config.rollTrait) || U.lCase(config.rollTrait) in AttributeTrait)) { throw new Error(`[PrepareIndulgeViceRoll()] Bad RollTrait for Indulge Vice Roll: ${config.rollTrait}`); @@ -1509,11 +1509,11 @@ class BladesRoll extends DocumentSheet { RollModSection.roll, RollModSection.position, RollModSection.effect - ].forEach(rollSection => { + ].forEach((rollSection) => { const sectionFlagData = participantFlagData[rollSection]; if (sectionFlagData) { const sectionParticipants = {}; - (Object.keys(sectionFlagData)).forEach(participantType => { + (Object.keys(sectionFlagData)).forEach((participantType) => { const subSectionFlagData = sectionFlagData[participantType]; if (subSectionFlagData) { sectionParticipants[participantType] = @@ -1576,14 +1576,14 @@ class BladesRoll extends DocumentSheet { if (BladesActor.IsType(this.rollPrimaryDoc, BladesActorType.pc)) { if (isAction(this.rollTrait)) { return Object.values(ActionTrait) - .map(action => ({ + .map((action) => ({ name: U.uCase(action), value: action })); } if (isAttribute(this.rollTrait)) { return Object.values(AttributeTrait) - .map(attribute => ({ + .map((attribute) => ({ name: U.uCase(attribute), value: attribute })); @@ -1591,7 +1591,7 @@ class BladesRoll extends DocumentSheet { } if (U.isInt(this.rollTrait)) { return [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] - .map(num => ({ + .map((num) => ({ name: `+${num}`, value: num })); @@ -1803,15 +1803,15 @@ class BladesRoll extends DocumentSheet { this.rollTraitValOverride = undefined; this.rollFactorPenaltiesNegated = {}; this.tempGMBoosts = {}; - this.rollMods = modsData.map(modData => new BladesRollMod(modData, this)); + this.rollMods = modsData.map((modData) => new BladesRollMod(modData, this)); const initReport = {}; - this.rollMods = this.rollMods.filter(rollMod => rollMod.isValidForRollType()); + this.rollMods = this.rollMods.filter((rollMod) => rollMod.isValidForRollType()); this.rollMods - .filter(rollMod => !rollMod.setConditionalStatus()) - .filter(rollMod => !rollMod.setAutoStatus()) - .forEach(rollMod => { rollMod.setPayableStatus(); }); + .filter((rollMod) => !rollMod.setConditionalStatus()) + .filter((rollMod) => !rollMod.setAutoStatus()) + .forEach((rollMod) => { rollMod.setPayableStatus(); }); const parseForceOnKeys = (mod) => { - const holdKeys = mod.effectKeys.filter(key => key.startsWith("ForceOn")); + const holdKeys = mod.effectKeys.filter((key) => key.startsWith("ForceOn")); if (holdKeys.length === 0) { return; } @@ -1831,9 +1831,9 @@ class BladesRoll extends DocumentSheet { ?? this.getRollModByName(targetName, targetCat ?? mod.section); if (!targetMod && targetName === "Push") { [targetMod] = [ - ...this.getActiveBasicPushMods(targetCat ?? mod.section, "negative").filter(m => m.status === RollModStatus.ToggledOn), - ...this.getActiveBasicPushMods(targetCat ?? mod.section, "positive").filter(m => m.status === RollModStatus.ToggledOn), - ...this.getInactiveBasicPushMods(targetCat ?? mod.section, "positive").filter(m => m.status === RollModStatus.ToggledOff) + ...this.getActiveBasicPushMods(targetCat ?? mod.section, "negative").filter((m) => m.status === RollModStatus.ToggledOn), + ...this.getActiveBasicPushMods(targetCat ?? mod.section, "positive").filter((m) => m.status === RollModStatus.ToggledOn), + ...this.getInactiveBasicPushMods(targetCat ?? mod.section, "positive").filter((m) => m.status === RollModStatus.ToggledOff) ]; } targetMod ??= this.getRollModByName(targetName, targetCat ?? mod.section, targetPosNeg ?? mod.posNeg); @@ -1850,14 +1850,14 @@ class BladesRoll extends DocumentSheet { } } }; - this.getActiveRollMods().forEach(rollMod => parseForceOnKeys(rollMod)); + this.getActiveRollMods().forEach((rollMod) => parseForceOnKeys(rollMod)); if (this.isForcePushed()) { this.getInactivePushMods() - .filter(mod => !mod.isBasicPush) - .forEach(mod => { mod.heldStatus = RollModStatus.ForcedOff; }); + .filter((mod) => !mod.isBasicPush) + .forEach((mod) => { mod.heldStatus = RollModStatus.ForcedOff; }); } - [RollModSection.roll, RollModSection.effect].forEach(cat => { + [RollModSection.roll, RollModSection.effect].forEach((cat) => { if (this.isPushed(cat)) { if (cat === RollModSection.roll && this.isPushed(cat, "positive")) { const bargainMod = this.getRollModByID("Bargain-positive-roll"); @@ -1868,19 +1868,19 @@ class BladesRoll extends DocumentSheet { } else { this.getInactivePushMods(cat) - .filter(mod => !mod.isBasicPush) - .forEach(mod => { mod.heldStatus = RollModStatus.Hidden; }); + .filter((mod) => !mod.isBasicPush) + .forEach((mod) => { mod.heldStatus = RollModStatus.Hidden; }); } }); this.getVisibleRollMods() - .forEach(mod => { mod.setRelevancyStatus(); }); + .forEach((mod) => { mod.setRelevancyStatus(); }); - const activeArmorCostMod = this.getActiveRollMods().find(mod => mod.effectKeys.includes("Cost-SpecialArmor")); + const activeArmorCostMod = this.getActiveRollMods().find((mod) => mod.effectKeys.includes("Cost-SpecialArmor")); if (activeArmorCostMod) { this.getVisibleRollMods() - .filter(mod => !mod.isActive && mod.effectKeys.includes("Cost-SpecialArmor")) - .forEach(mod => { mod.heldStatus = RollModStatus.ForcedOff; }); + .filter((mod) => !mod.isActive && mod.effectKeys.includes("Cost-SpecialArmor")) + .forEach((mod) => { mod.heldStatus = RollModStatus.ForcedOff; }); } eLog.checkLog2("rollMods", "*** initRollMods() PASS ***", initReport); } @@ -1911,7 +1911,7 @@ class BladesRoll extends DocumentSheet { const rollPush = this.getRollModByID("Push-positive-roll"); const effectPush = this.getRollModByID("Push-positive-effect"); const negatePushCostMods = this.getActiveRollMods(RollModSection.after, "positive") - .filter(mod => mod.effectKeys.includes("Negate-PushCost")); + .filter((mod) => mod.effectKeys.includes("Negate-PushCost")); return ((harmPush?.isActive && harmPush?.stressCost) || 0) + ((rollPush?.isActive && rollPush?.stressCost) || 0) + ((effectPush?.isActive && effectPush?.stressCost) || 0) @@ -1919,11 +1919,11 @@ class BladesRoll extends DocumentSheet { } get rollCostData() { return this.getActiveRollMods() - .map(rollMod => rollMod.costs ?? []) + .map((rollMod) => rollMod.costs ?? []) .flat(); } getRollModByName(name, cat, posNeg) { - const modMatches = this.rollMods.filter(rollMod => { + const modMatches = this.rollMods.filter((rollMod) => { if (U.lCase(rollMod.name) !== U.lCase(name)) { return false; } @@ -1943,52 +1943,52 @@ class BladesRoll extends DocumentSheet { } return modMatches[0]; } - getRollModByID(id) { return this.rollMods.find(rollMod => rollMod.id === id); } + getRollModByID(id) { return this.rollMods.find((rollMod) => rollMod.id === id); } getRollMods(cat, posNeg) { - return this.rollMods.filter(rollMod => (!cat || rollMod.section === cat) + return this.rollMods.filter((rollMod) => (!cat || rollMod.section === cat) && (!posNeg || rollMod.posNeg === posNeg)); } getVisibleRollMods(cat, posNeg) { - return this.getRollMods(cat, posNeg).filter(rollMod => rollMod.isVisible); + return this.getRollMods(cat, posNeg).filter((rollMod) => rollMod.isVisible); } getActiveRollMods(cat, posNeg) { - return this.getRollMods(cat, posNeg).filter(rollMod => rollMod.isActive); + return this.getRollMods(cat, posNeg).filter((rollMod) => rollMod.isActive); } getVisibleInactiveRollMods(cat, posNeg) { - return this.getVisibleRollMods(cat, posNeg).filter(rollMod => !rollMod.isActive); + return this.getVisibleRollMods(cat, posNeg).filter((rollMod) => !rollMod.isActive); } getPushMods(cat, posNeg) { - return this.getRollMods(cat, posNeg).filter(rollMod => rollMod.isPush); + return this.getRollMods(cat, posNeg).filter((rollMod) => rollMod.isPush); } getVisiblePushMods(cat, posNeg) { - return this.getPushMods(cat, posNeg).filter(rollMod => rollMod.isVisible); + return this.getPushMods(cat, posNeg).filter((rollMod) => rollMod.isVisible); } getActivePushMods(cat, posNeg) { - return this.getVisiblePushMods(cat, posNeg).filter(rollMod => rollMod.isActive); + return this.getVisiblePushMods(cat, posNeg).filter((rollMod) => rollMod.isActive); } getActiveBasicPushMods(cat, posNeg) { - return this.getActivePushMods(cat, posNeg).filter(rollMod => rollMod.isBasicPush); + return this.getActivePushMods(cat, posNeg).filter((rollMod) => rollMod.isBasicPush); } getInactivePushMods(cat, posNeg) { - return this.getVisiblePushMods(cat, posNeg).filter(rollMod => !rollMod.isActive); + return this.getVisiblePushMods(cat, posNeg).filter((rollMod) => !rollMod.isActive); } getInactiveBasicPushMods(cat, posNeg) { - return this.getInactivePushMods(cat, posNeg).filter(rollMod => rollMod.isBasicPush); + return this.getInactivePushMods(cat, posNeg).filter((rollMod) => rollMod.isBasicPush); } getForcedPushMods(cat, posNeg) { return this.getActivePushMods(cat, posNeg) - .filter(rollMod => rollMod.isBasicPush + .filter((rollMod) => rollMod.isBasicPush && rollMod.status === RollModStatus.ForcedOn); } getOpenPushMods(cat, posNeg) { return this.getActivePushMods(cat, posNeg) - .filter(rollMod => rollMod.isBasicPush + .filter((rollMod) => rollMod.isBasicPush && rollMod.status === RollModStatus.ToggledOn); } getModsDelta = (cat) => { return U.sum([ - ...this.getActiveRollMods(cat, "positive").map(mod => mod.value), - ...this.getActiveRollMods(cat, "negative").map(mod => -mod.value) + ...this.getActiveRollMods(cat, "positive").map((mod) => mod.value), + ...this.getActiveRollMods(cat, "negative").map((mod) => -mod.value) ]); }; _rollMods; @@ -2036,7 +2036,7 @@ class BladesRoll extends DocumentSheet { return []; } return C.Consequences[this.finalPosition][this.rollResult] - .map(cType => ({ value: cType, display: cType })); + .map((cType) => ({ value: cType, display: cType })); } _consequenceAI; async manageConsequenceAI(sData) { @@ -2047,7 +2047,7 @@ class BladesRoll extends DocumentSheet { if (!this._consequenceAI) { this._consequenceAI = new BladesAI(AGENTS.ConsequenceAdjuster); } - await Promise.all(Object.values(consequenceData).map(cData => { + await Promise.all(Object.values(consequenceData).map((cData) => { if (!cData.resistOptions) { if (!this._consequenceAI?.hasQueried(cData.name)) { this._consequenceAI?.query(cData.name, cData.name); @@ -2065,7 +2065,7 @@ class BladesRoll extends DocumentSheet { async getData() { const context = super.getData(); this.initRollMods(this.getRollModsData()); - this.rollMods.forEach(rollMod => rollMod.applyRollModEffectKeys()); + this.rollMods.forEach((rollMod) => rollMod.applyRollModEffectKeys()); const sheetData = this.getSheetData(this.getIsGM(), this.getRollCosts()); if (game.user.isGM && this.rollConsequences) { this.manageConsequenceAI(sheetData); @@ -2090,18 +2090,18 @@ class BladesRoll extends DocumentSheet { } getRollCosts() { return this.getActiveRollMods() - .map(rollMod => rollMod.costs) + .map((rollMod) => rollMod.costs) .flat() .filter((costData) => costData !== undefined); } getStressCosts(rollCosts) { - return rollCosts.filter(costData => costData.costType === "Stress"); + return rollCosts.filter((costData) => costData.costType === "Stress"); } getTotalStressCost(stressCosts) { - return U.sum(stressCosts.map(costData => costData.costAmount)); + return U.sum(stressCosts.map((costData) => costData.costAmount)); } getSpecArmorCost(rollCosts) { - return rollCosts.find(costData => costData.costType === "SpecialArmor"); + return rollCosts.find((costData) => costData.costType === "SpecialArmor"); } getSheetData(isGM, rollCosts) { const { flagData: rData, rollPrimary, rollTraitData, rollTraitOptions, finalDicePool, finalPosition, finalEffect, finalResult, rollMods, rollFactors, consequenceTypeOptions } = this; @@ -2123,14 +2123,14 @@ class BladesRoll extends DocumentSheet { rollParticipants: this.rollParticipants, rollEffects: Object.values(Effect), teamworkDocs: game.actors - .filter(actor => actor.hasTag(Tag.PC.ActivePC)) - .map(actor => ({ value: actor.id, display: actor.name })), + .filter((actor) => actor.hasTag(Tag.PC.ActivePC)) + .map((actor) => ({ value: actor.id, display: actor.name })), rollTraitValOverride: this.rollTraitValOverride, rollFactorPenaltiesNegated: this.rollFactorPenaltiesNegated, posRollMods: Object.fromEntries(Object.values(RollModSection) - .map(cat => [cat, this.getRollMods(cat, "positive")])), + .map((cat) => [cat, this.getRollMods(cat, "positive")])), negRollMods: Object.fromEntries(Object.values(RollModSection) - .map(cat => [cat, this.getRollMods(cat, "negative")])), + .map((cat) => [cat, this.getRollMods(cat, "negative")])), hasInactiveConditionals: this.calculateHasInactiveConditionalsData(), rollFactors, ...this.calculateOddsHTML(finalDicePool, finalResult), @@ -2288,7 +2288,7 @@ class BladesRoll extends DocumentSheet { calculateHasInactiveConditionalsData() { const hasInactive = {}; for (const section of Object.values(RollModSection)) { - hasInactive[section] = this.getRollMods(section).filter(mod => mod.isInInactiveBlock).length > 0; + hasInactive[section] = this.getRollMods(section).filter((mod) => mod.isInInactiveBlock).length > 0; } return hasInactive; } @@ -2319,13 +2319,13 @@ class BladesRoll extends DocumentSheet { specArmorCost && totalStressCost ? "and" : null, specArmorCost ? "your Special Armor" : null, ")" - ].filter(line => Boolean(line)).join(" "), + ].filter((line) => Boolean(line)).join(" "), tooltip: [ "

Roll Costs

" - ].filter(line => Boolean(line)).join("") + ].filter((line) => Boolean(line)).join("") }; } return undefined; @@ -2344,10 +2344,10 @@ class BladesRoll extends DocumentSheet { footerLabel: footerLabelStrings.join(" "), tooltip: [ "

Roll Costs

" - ].filter(line => Boolean(line)).join("") + ].filter((line) => Boolean(line)).join("") }; } parseFortuneRollCostsHTML() { @@ -2360,7 +2360,7 @@ class BladesRoll extends DocumentSheet { _dieVals; get dieVals() { this._dieVals ??= this.roll.terms[0].results - .map(result => result.result) + .map((result) => result.result) .sort() .reverse(); return this._dieVals; @@ -2409,13 +2409,13 @@ class BladesRoll extends DocumentSheet { const dieVals = this.isRollingZero ? [[...this.dieVals].pop()] : this.dieVals; - if (dieVals.filter(val => val === 6).length >= 2) { + if (dieVals.filter((val) => val === 6).length >= 2) { return RollResult.critical; } - if (dieVals.find(val => val === 6)) { + if (dieVals.find((val) => val === 6)) { return RollResult.success; } - if (dieVals.find(val => val && val >= 4)) { + if (dieVals.find((val) => val && val >= 4)) { return RollResult.partial; } return RollResult.fail; @@ -2588,8 +2588,8 @@ class BladesRoll extends DocumentSheet { case "isPrimary": { if (value === true) { Object.values(Factor) - .filter(factor => factor !== thisFactor) - .forEach(factor => { + .filter((factor) => factor !== thisFactor) + .forEach((factor) => { if (factorToggleData[thisSource][factor]?.[thisToggle] === true) { factorToggleData[thisSource][factor] = { ...factorToggleData[thisSource][factor], @@ -2647,7 +2647,7 @@ class BladesRoll extends DocumentSheet { click: this._toggleRollModClick.bind(this) }); html.find("[data-action='tradePosition']").on({ - click: event => { + click: (event) => { const curVal = `${$(event.currentTarget).data("value")}`; if (curVal === "false") { this.document.setFlag(C.SYSTEM_ID, "rollCollab.rollPosEffectTrade", "effect").then(() => socketlib.system.executeForEveryone("renderRollCollab", this.rollID)); @@ -2658,7 +2658,7 @@ class BladesRoll extends DocumentSheet { } }); html.find("[data-action='tradeEffect']").on({ - click: event => { + click: (event) => { const curVal = `${$(event.currentTarget).data("value")}`; if (curVal === "false") { this.document.setFlag(C.SYSTEM_ID, "rollCollab.rollPosEffectTrade", "position").then(() => socketlib.system.executeForEveryone("renderRollCollab", this.rollID)); @@ -2678,7 +2678,7 @@ class BladesRoll extends DocumentSheet { focusin: () => { BladesRoll.Active = this; } }); html.find(".controls-toggle").on({ - click: event => { + click: (event) => { event.preventDefault(); $(event.currentTarget).parents(".controls-panel").toggleClass("active"); } diff --git a/module/blades.js b/module/blades.js index f8493cca..67dcd7bf 100644 --- a/module/blades.js +++ b/module/blades.js @@ -47,7 +47,7 @@ class GlobalGetter { } const conf = { rollType: RollType.Resistance, - rollUserID: game.users.find(user => user.character?.name === "Alistair")?.id, + rollUserID: game.users.find((user) => user.character?.name === "Alistair")?.id, rollPrimaryData: { rollPrimaryID: pc.id, rollPrimaryDoc: pc, @@ -163,9 +163,9 @@ Hooks.once("diceSoNiceReady", (dice3d) => { dice3d.addSystem({ id: "eunos-blades", name: "Euno's Blades" }, "preferred"); dice3d.addDicePreset({ type: "d6", - labels: [1, 2, 3, 4, 5, 6].map(num => `systems/eunos-blades/assets/dice/faces/${num}.webp`), + labels: [1, 2, 3, 4, 5, 6].map((num) => `systems/eunos-blades/assets/dice/faces/${num}.webp`), system: "eunos-blades", - bumpMaps: [1, 2, 3, 4, 5, 6].map(num => `systems/eunos-blades/assets/dice/bump-maps/${num}.webp`), + bumpMaps: [1, 2, 3, 4, 5, 6].map((num) => `systems/eunos-blades/assets/dice/bump-maps/${num}.webp`), emissiveMaps: [undefined, undefined, undefined, undefined, undefined, "systems/eunos-blades/assets/dice/emission-maps/6.webp"], emissive: "#d89300" }); diff --git a/module/core/gsap.js b/module/core/gsap.js index 53910407..af73c320 100644 --- a/module/core/gsap.js +++ b/module/core/gsap.js @@ -44,7 +44,7 @@ const gsapEffects = { } }, slideUp: { - effect: targets => U.gsap.to(targets, { + effect: (targets) => U.gsap.to(targets, { height: 0, duration: 0.5, ease: "power3" @@ -161,7 +161,7 @@ export function ApplyTooltipListeners(html) { return; } $(el).data("hoverTimeline", U.gsap.effects.hoverTooltip(tooltipElem, { - scalingElems: [...$(el).find(".tooltip-scaling-elem")].filter(elem => Boolean(elem)), + scalingElems: [...$(el).find(".tooltip-scaling-elem")].filter((elem) => Boolean(elem)), xMotion: $(tooltipElem).hasClass("tooltip-left") ? "-=250" : "+=200", tooltipScale: $(tooltipElem).hasClass("tooltip-small") ? 1 : 1.2 })); diff --git a/module/core/tags.js b/module/core/tags.js index 298bf4ed..b736ecea 100644 --- a/module/core/tags.js +++ b/module/core/tags.js @@ -78,7 +78,7 @@ const Tags = { "data-group": findDataGroup(tag) })), true, true); - setTimeout(() => elem.addEventListener("change", event => { _onTagifyChange(event, doc, targetKey); }), 1000); + setTimeout(() => elem.addEventListener("change", (event) => { _onTagifyChange(event, doc, targetKey); }), 1000); } const systemTags = { "System Tags": Object.values(Tag.System), @@ -101,7 +101,7 @@ const Tags = { }; const factionTags = { Factions: game.actors .filter((actor) => actor.type === BladesActorType.faction && actor.name !== null) - .map(faction => faction.name) }; + .map((faction) => faction.name) }; $(html).find(".tags-gm").each((_, e) => makeTagInput(e, systemTags)); $(html).find(".tags-district").each((_, e) => makeTagInput(e, districtTags)); $(html).find(".tags-faction").each((_, e) => makeTagInput(e, factionTags)); diff --git a/module/core/utilities.js b/module/core/utilities.js index cef230e0..b56e03f3 100644 --- a/module/core/utilities.js +++ b/module/core/utilities.js @@ -9,10 +9,10 @@ import C from "./constants.js"; import { gsap } from "/scripts/greensock/esm/all.js"; const _noCapWords = "a|above|after|an|and|at|below|but|by|down|for|for|from|in|nor|of|off|on|onto|or|out|so|the|to|under|up|with|yet" .split("|") - .map(word => new RegExp(`\\b${word}\\b`, "gui")); + .map((word) => new RegExp(`\\b${word}\\b`, "gui")); const _capWords = [ "I", /[^a-z]{3,}|[.0-9]/gu -].map(word => (/RegExp/.test(Object.prototype.toString.call(word)) ? word : new RegExp(`\\b${word}\\b`, "gui"))); +].map((word) => (/RegExp/.test(Object.prototype.toString.call(word)) ? word : new RegExp(`\\b${word}\\b`, "gui"))); const _loremIpsumText = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse ultricies nibh sed massa euismod lacinia. Aliquam nec est ac nunc ultricies scelerisque porta vulputate odio. Integer gravida mattis odio, semper volutpat tellus. Ut elit leo, auctor eget fermentum hendrerit, @@ -131,7 +131,7 @@ const _romanNumerals = { }; const UUIDLOG = []; -const GMID = () => game?.user?.find(user => user.isGM)?.id ?? false; +const GMID = () => game?.user?.find((user) => user.isGM)?.id ?? false; const isNumber = (ref) => typeof ref === "number" && !isNaN(ref); const isArray = (ref) => Array.isArray(ref); const isSimpleObj = (ref) => ref === Object(ref) && !isArray(ref); @@ -271,7 +271,7 @@ const sCase = (str) => { let [first, ...rest] = `${str ?? ""}`.split(/\s+/); first = testRegExp(first, _capWords) ? first : `${uCase(first.charAt(0))}${lCase(first.slice(1))}`; if (hasItems(rest)) { - rest = rest.map(word => (testRegExp(word, _capWords) ? word : lCase(word))); + rest = rest.map((word) => (testRegExp(word, _capWords) ? word : lCase(word))); } return [first, ...rest].join(" ").trim(); }; @@ -279,12 +279,12 @@ const tCase = (str) => String(str).split(/\s/) .map((word, i) => (i && testRegExp(word, _noCapWords) ? lCase(word) : sCase(word))) .join(" ").trim(); const testRegExp = (str, patterns = [], flags = "gui", isTestingAll = false) => patterns - .map(pattern => (pattern instanceof RegExp + .map((pattern) => (pattern instanceof RegExp ? pattern - : new RegExp(`\\b${pattern}\\b`, flags)))[isTestingAll ? "every" : "some"](pattern => pattern.test(`${str}`)); + : new RegExp(`\\b${pattern}\\b`, flags)))[isTestingAll ? "every" : "some"]((pattern) => pattern.test(`${str}`)); const regExtract = (ref, pattern, flags) => { const splitFlags = []; - [...(flags ?? "").replace(/g/g, ""), "u"].forEach(flag => { + [...(flags ?? "").replace(/g/g, ""), "u"].forEach((flag) => { if (flag && !splitFlags.includes(flag)) { splitFlags.push(flag); } @@ -418,7 +418,7 @@ const verbalizeNum = (num) => { if (pInt(trio) === 0) { return ""; } - const digits = `${trio}`.split("").map(digit => pInt(digit)); + const digits = `${trio}`.split("").map((digit) => pInt(digit)); let result = ""; if (digits.length === 3) { const hundreds = digits.shift(); @@ -447,7 +447,7 @@ const verbalizeNum = (num) => { const [integers, decimals] = num.replace(/[,\s-]/g, "").split("."); const intArray = [...integers.split("")].reverse().join("") .match(/.{1,3}/g) - ?.map(v => [...v.split("")].reverse().join("")) ?? []; + ?.map((v) => [...v.split("")].reverse().join("")) ?? []; const intStrings = []; while (intArray.length) { const thisTrio = intArray.pop(); @@ -514,7 +514,7 @@ const loremIpsum = (numWords = 200) => { return `${sCase(words.join(" ")).trim().replace(/[^a-z\s]*$/ui, "")}.`; }; const randString = (length = 5) => Array.from({ length }) - .map(() => String.fromCharCode(randInt(...["a", "z"].map(char => char.charCodeAt(0))))) + .map(() => String.fromCharCode(randInt(...["a", "z"].map((char) => char.charCodeAt(0))))) .join(""); const randWord = (numWords = 1, wordList = _randomWords) => Array.from({ length: numWords }).map(() => randElem([...wordList])).join(" "); const getUID = (id) => { @@ -526,7 +526,7 @@ const getUID = (id) => { return uuid; }; const fuzzyMatch = (val1, val2) => { - const [str1, str2] = [val1, val2].map(val => lCase(String(val).replace(/[^a-zA-Z0-9.+-]/g, "").trim())); + const [str1, str2] = [val1, val2].map((val) => lCase(String(val).replace(/[^a-zA-Z0-9.+-]/g, "").trim())); return str1.length > 0 && str1 === str2; }; const isIn = (needle, haystack = [], fuzziness = 0) => { @@ -544,7 +544,7 @@ const isIn = (needle, haystack = [], fuzziness = 0) => { SearchTests.push(...fuzzyTests); if (fuzziness >= 2) { SearchTests.push(...fuzzyTests - .map(func => (ndl, item) => func(`${ndl}`.replace(/\W/g, ""), `${item}`.replace(/\W/gu, "")))); + .map((func) => (ndl, item) => func(`${ndl}`.replace(/\W/g, ""), `${item}`.replace(/\W/gu, "")))); if (fuzziness >= 3) { SearchTests.push(() => false); } @@ -574,7 +574,7 @@ const isIn = (needle, haystack = [], fuzziness = 0) => { if (!testFunc) { return false; } - matchIndex = searchStack.findIndex(item => testFunc(searchNeedle, `${item}`)); + matchIndex = searchStack.findIndex((item) => testFunc(searchNeedle, `${item}`)); } if (isPosInt(matchIndex)) { return isList(haystack) ? Object.values(haystack)[matchIndex] : haystack[matchIndex]; @@ -626,14 +626,14 @@ function getLast(array) { } const unique = (array) => { const returnArray = []; - array.forEach(item => { if (!returnArray.includes(item)) { + array.forEach((item) => { if (!returnArray.includes(item)) { returnArray.push(item); } }); return returnArray; }; const group = (array, key) => { const returnObj = {}; - array.forEach(item => { + array.forEach((item) => { const returnKey = item[key]; let returnVal = returnObj[returnKey]; if (!returnVal) { @@ -656,7 +656,7 @@ const sample = (array, numElems = 1, isUniqueOnly = true, uniqueTestFunc = (e, a } return elems; }; -const removeFirst = (array, element) => array.splice(array.findIndex(v => v === element)); +const removeFirst = (array, element) => array.splice(array.findIndex((v) => v === element)); function pullElement(array, checkFunc) { let testFunction; if (typeof checkFunc !== "function") { @@ -710,7 +710,7 @@ const checkVal = ({ k, v }, checkTest) => { }; const remove = (obj, checkTest) => { if (isArray(obj)) { - const index = obj.findIndex(v => checkVal({ v }, checkTest)); + const index = obj.findIndex((v) => checkVal({ v }, checkTest)); if (index >= 0) { return removeElementFromArray(obj, index); } @@ -743,13 +743,13 @@ const removeElementFromList = (list, key) => { const replace = (obj, checkTest, repVal) => { let repKey; if (isList(obj)) { - [repKey] = Object.entries(obj).find(v => checkVal({ v }, checkTest)) || [false]; + [repKey] = Object.entries(obj).find((v) => checkVal({ v }, checkTest)) || [false]; if (repKey === false) { return false; } } else if (isArray(obj)) { - repKey = obj.findIndex(v => checkVal({ v }, checkTest)); + repKey = obj.findIndex((v) => checkVal({ v }, checkTest)); if (repKey === -1) { return false; } @@ -766,13 +766,13 @@ const replace = (obj, checkTest, repVal) => { return true; }; const objClean = (data, remVals = [undefined, null, "", {}, []]) => { - const remStrings = remVals.map(rVal => JSON.stringify(rVal)); + const remStrings = remVals.map((rVal) => JSON.stringify(rVal)); if (remStrings.includes(JSON.stringify(data)) || remVals.includes(data)) { return "KILL"; } if (Array.isArray(data)) { - const newData = data.map(elem => objClean(elem, remVals)) - .filter(elem => elem !== "KILL"); + const newData = data.map((elem) => objClean(elem, remVals)) + .filter((elem) => elem !== "KILL"); return Array.isArray(newData) && newData.length ? newData : "KILL"; } if (data && typeof data === "object" && JSON.stringify(data).startsWith("{")) { @@ -786,7 +786,7 @@ const objClean = (data, remVals = [undefined, null, "", {}, []]) => { export function toDict(items, key) { const dict = {}; const mappedItems = items - .map(data => { + .map((data) => { let { iData } = data; if (!iData) { iData = data; @@ -836,7 +836,7 @@ function objMap(obj, keyFunc, valFunc) { return [keyFuncTyped(key, val), valFuncTyped(val, key)]; })); } -const objSize = (obj) => Object.values(obj).filter(val => val !== undefined && val !== null).length; +const objSize = (obj) => Object.values(obj).filter((val) => val !== undefined && val !== null).length; function objFindKey(obj, keyFunc, valFunc) { if (!valFunc) { valFunc = keyFunc; @@ -936,8 +936,8 @@ function objMerge(target, source, { isMutatingOk = false, isStrictlySafe = false } function objDiff(obj1, obj2) { const diff = {}; - const bothObj1AndObj2Keys = Object.keys(obj2).filter(key => Object.hasOwn(obj2, key) && Object.hasOwn(obj1, key)); - const onlyObj2Keys = Object.keys(obj2).filter(key => Object.hasOwn(obj2, key) && !Object.hasOwn(obj1, key)); + const bothObj1AndObj2Keys = Object.keys(obj2).filter((key) => Object.hasOwn(obj2, key) && Object.hasOwn(obj1, key)); + const onlyObj2Keys = Object.keys(obj2).filter((key) => Object.hasOwn(obj2, key) && !Object.hasOwn(obj1, key)); for (const key of bothObj1AndObj2Keys) { if (typeof obj1[key] === "object" && typeof obj2[key] === "object" && !Array.isArray(obj1[key]) && !Array.isArray(obj2[key])) { const nestedDiff = objDiff(obj1[key], obj2[key]); @@ -1010,7 +1010,7 @@ function objNullify(obj) { }); return obj; } - Object.keys(obj).forEach(objKey => { + Object.keys(obj).forEach((objKey) => { obj[objKey] = null; }); return obj; @@ -1063,7 +1063,7 @@ function get(target, property, unit) { const getGSAngleDelta = (startAngle, endAngle) => signNum(roundNum(getAngleDelta(startAngle, endAngle), 2)).replace(/^(.)/, "$1="); const getRawCirclePath = (r, { x: xO, y: yO } = { x: 0, y: 0 }) => { - [r, xO, yO] = [r, xO, yO].map(val => roundNum(val, 2)); + [r, xO, yO] = [r, xO, yO].map((val) => roundNum(val, 2)); const [b1, b2] = [0.4475 * r, (1 - 0.4475) * r]; const [xT, yT] = [xO, yO - r]; return [[ @@ -1092,7 +1092,7 @@ const getColorVals = (red, green, blue, alpha) => { [red, green, blue, alpha] = red .replace(/[^\d.,]/g, "") .split(/,/) - .map(color => (isUndefined(color) ? undefined : parseFloat(color))); + .map((color) => (isUndefined(color) ? undefined : parseFloat(color))); } if (isHexColor(red)) { if ([4, 5].includes(red.length)) { @@ -1100,11 +1100,11 @@ const getColorVals = (red, green, blue, alpha) => { } [red, green, blue, alpha] = red .match(/[^#]{2}/g) - ?.map(val => parseInt(val, 16)) ?? []; + ?.map((val) => parseInt(val, 16)) ?? []; } - if ([red, green, blue].every(color => /^\d+$/.test(`${color}`))) { + if ([red, green, blue].every((color) => /^\d+$/.test(`${color}`))) { return [red, green, blue, alpha] - .filter(color => /^[\d.]+$/.test(`${color}`)); + .filter((color) => /^[\d.]+$/.test(`${color}`)); } return null; }; @@ -1112,7 +1112,7 @@ const getRGBString = (red, green, blue, alpha) => { if (isRGBColor(red) || isHexColor(red)) { [red, green, blue, alpha] = getColorVals(red) ?? []; } - if ([red, green, blue].every(color => /^[.\d]+$/.test(`${color}`))) { + if ([red, green, blue].every((color) => /^[.\d]+$/.test(`${color}`))) { let colorString = "rgb"; const colors = [red, green, blue]; if (/^[.\d]+$/.test(`${alpha}`)) { @@ -1134,7 +1134,7 @@ const getHEXString = (red, green, blue) => { if (isRGBColor(red)) { [red, green, blue] = getColorVals(red) ?? []; } - if (isDefined(red) && isDefined(green) && isDefined(blue) && [red, green, blue].every(color => /^[.\d]+$/.test(`${color}`))) { + if (isDefined(red) && isDefined(green) && isDefined(blue) && [red, green, blue].every((color) => /^[.\d]+$/.test(`${color}`))) { return `#${componentToHex(red ?? 0)}${componentToHex(green ?? 0)}${componentToHex(blue ?? 0)}`; } return null; @@ -1154,7 +1154,7 @@ const getSiblings = (elem) => { if (!elem.parentNode) { return siblings; } - Array.from(elem.parentNode.children).forEach(sibling => { + Array.from(elem.parentNode.children).forEach((sibling) => { if (sibling !== elem) { siblings.push(sibling); } @@ -1170,7 +1170,7 @@ const escapeHTML = (str) => (typeof str === "string" .replace(/[`']/g, "'") : str); -const sleep = (duration) => new Promise(resolve => { setTimeout(resolve, duration >= 100 ? duration : duration * 1000); }); +const sleep = (duration) => new Promise((resolve) => { setTimeout(resolve, duration >= 100 ? duration : duration * 1000); }); const isDocID = (docRef, isUUIDok = true) => { return typeof docRef === "string" && (isUUIDok ? /^(.*\.)?[A-Za-z0-9]{16}$/.test(docRef) @@ -1193,7 +1193,7 @@ function getTemplatePath(subFolder, fileName) { if (typeof fileName === "string") { return `${C.TEMPLATE_ROOT}/${subFolder}/${fileName.replace(/\..*$/, "")}.hbs`; } - return fileName.map(fName => getTemplatePath(subFolder, fName)); + return fileName.map((fName) => getTemplatePath(subFolder, fName)); } function displayImageSelector(callback, pathRoot = `systems/${C.SYSTEM_ID}/assets`, position = { top: 200, left: 200 }) { const fp = new FilePicker({ diff --git a/module/documents/actors/BladesCrew.js b/module/documents/actors/BladesCrew.js index 689e4f35..d208a1bc 100644 --- a/module/documents/actors/BladesCrew.js +++ b/module/documents/actors/BladesCrew.js @@ -35,7 +35,7 @@ class BladesCrew extends BladesActor { return []; } return this.activeSubItems - .filter(item => [BladesItemType.ability, BladesItemType.crew_ability].includes(item.type)); + .filter((item) => [BladesItemType.ability, BladesItemType.crew_ability].includes(item.type)); } get playbookName() { return this.playbook?.name; diff --git a/module/documents/actors/BladesPC.js b/module/documents/actors/BladesPC.js index 52f28a18..b52d2564 100644 --- a/module/documents/actors/BladesPC.js +++ b/module/documents/actors/BladesPC.js @@ -31,23 +31,23 @@ class BladesPC extends BladesActor { } get primaryUser() { - return game.users?.find(user => user.character?.id === this?.id) || null; + return game.users?.find((user) => user.character?.id === this?.id) || null; } async clearLoadout() { await this.update({ "system.loadout.selected": "" }); this.updateEmbeddedDocuments("Item", [ ...this.activeSubItems - .filter(item => BladesItem.IsType(item, BladesItemType.gear) + .filter((item) => BladesItem.IsType(item, BladesItemType.gear) && !item.hasTag(Tag.System.Archived)) - .map(item => ({ + .map((item) => ({ _id: item.id, "system.tags": [...item.tags, Tag.System.Archived], "system.uses_per_score.value": 0 })), ...this.activeSubItems - .filter(item => BladesItem.IsType(item, BladesItemType.ability) + .filter((item) => BladesItem.IsType(item, BladesItemType.ability) && item.system.uses_per_score.max) - .map(item => ({ + .map((item) => ({ _id: item.id, "system.uses_per_score.value": 0 })) @@ -100,7 +100,7 @@ class BladesPC extends BladesActor { if (this.type !== BladesActorType.pc) { return undefined; } - return this.activeSubItems.find(item => item.type === BladesItemType.vice); + return this.activeSubItems.find((item) => item.type === BladesItemType.vice); } get crew() { return this.activeSubActors @@ -111,7 +111,7 @@ class BladesPC extends BladesActor { return []; } return this.activeSubItems - .filter(item => [BladesItemType.ability, BladesItemType.crew_ability].includes(item.type)); + .filter((item) => [BladesItemType.ability, BladesItemType.crew_ability].includes(item.type)); } get playbookName() { return this.playbook?.name; @@ -160,13 +160,13 @@ class BladesPC extends BladesActor { return 0; } return Object.keys(this.system.trauma.checked) - .filter(traumaName => + .filter((traumaName) => this.system.trauma.active[traumaName] && this.system.trauma.checked[traumaName]) .length; } get traumaList() { return BladesActor.IsType(this, BladesActorType.pc) - ? Object.keys(this.system.trauma.active).filter(key => this.system.trauma.active[key]) + ? Object.keys(this.system.trauma.active).filter((key) => this.system.trauma.active[key]) : []; } get activeTraumaConditions() { @@ -181,7 +181,7 @@ class BladesPC extends BladesActor { if (!BladesActor.IsType(this, BladesActorType.pc)) { return 0; } - const activeLoadItems = this.activeSubItems.filter(item => item.type === BladesItemType.gear); + const activeLoadItems = this.activeSubItems.filter((item) => item.type === BladesItemType.gear); return U.gsap.utils.clamp(0, 10, activeLoadItems.reduce((tot, i) => tot + U.pInt(i.system.load), 0)); } get remainingLoad() { @@ -209,7 +209,7 @@ class BladesPC extends BladesActor { [/Less Effect/, RollModSection.effect] ].forEach(([effectPat, effectCat]) => { const { one: harmConditionOne, two: harmConditionTwo } = Object.values(this.system.harm) - .find(harmData => effectPat.test(harmData.effect)) ?? {}; + .find((harmData) => effectPat.test(harmData.effect)) ?? {}; const harmString = U.objCompact([harmConditionOne, harmConditionTwo === "" ? null : harmConditionTwo]).join(" & "); if (harmString.length > 0) { rollModsData.push({ @@ -231,7 +231,7 @@ class BladesPC extends BladesActor { } }); const { one: harmCondition } = Object.values(this.system.harm) - .find(harmData => /Need Help/.test(harmData.effect)) ?? {}; + .find((harmData) => /Need Help/.test(harmData.effect)) ?? {}; if (harmCondition && harmCondition.trim() !== "") { rollModsData.push({ id: "Push-negative-roll", @@ -264,8 +264,8 @@ class BladesPC extends BladesActor { get rollTraitPCTooltipActions() { const tooltipStrings = [""]; const actionRatings = this.actions; - Object.values(AttributeTrait).forEach(attribute => { - C.Action[attribute].forEach(action => { + Object.values(AttributeTrait).forEach((attribute) => { + C.Action[attribute].forEach((action) => { tooltipStrings.push([ "", ``, @@ -281,7 +281,7 @@ class BladesPC extends BladesActor { get rollTraitPCTooltipAttributes() { const tooltipStrings = ["
${U.uCase(action)}
"]; const attributeRatings = this.attributes; - Object.values(AttributeTrait).forEach(attribute => { + Object.values(AttributeTrait).forEach((attribute) => { tooltipStrings.push([ "", ``, diff --git a/module/sheets/actor/BladesActorSheet.js b/module/sheets/actor/BladesActorSheet.js index 417faf90..8f8a1723 100644 --- a/module/sheets/actor/BladesActorSheet.js +++ b/module/sheets/actor/BladesActorSheet.js @@ -36,21 +36,21 @@ class BladesActorSheet extends ActorSheet { cohorts: { gang: this.actor.activeSubItems .filter((item) => item.type === BladesItemType.cohort_gang) - .map(item => { + .map((item) => { const subtypes = U.unique(Object.values(item.system.subtypes) - .map(subtype => subtype.trim()) - .filter(subtype => /[A-Za-z]/.test(subtype))); + .map((subtype) => subtype.trim()) + .filter((subtype) => /[A-Za-z]/.test(subtype))); const eliteSubtypes = U.unique([ ...Object.values(item.system.elite_subtypes), ...(item.parent?.upgrades ?? []) - .map(upgrade => (upgrade.name ?? "").trim().replace(/^Elite /, "")) + .map((upgrade) => (upgrade.name ?? "").trim().replace(/^Elite /, "")) ] - .map(subtype => subtype.trim()) - .filter(subtype => /[A-Za-z]/ + .map((subtype) => subtype.trim()) + .filter((subtype) => /[A-Za-z]/ .test(subtype) && subtypes.includes(subtype))); const imgTypes = [...eliteSubtypes]; if (imgTypes.length < 2) { - imgTypes.push(...subtypes.filter(subtype => !imgTypes.includes(subtype))); + imgTypes.push(...subtypes.filter((subtype) => !imgTypes.includes(subtype))); } if (U.unique(imgTypes).length === 1) { item.system.image = Object.values(item.system.elite_subtypes).includes(imgTypes[0]) ? `elite-${U.lCase(imgTypes[0])}.svg` : `${U.lCase(imgTypes[0])}.svg`; @@ -66,28 +66,28 @@ class BladesActorSheet extends ActorSheet { { mode: "untrained", label: "Untrained", color: "transparent", tooltip: "

Roll Untrained

" } ], edgeData: Object.fromEntries(Object.values(item.system.edges ?? []) - .filter(edge => /[A-Za-z]/.test(edge)) - .map(edge => [edge.trim(), C.EdgeTooltips[edge]])), + .filter((edge) => /[A-Za-z]/.test(edge)) + .map((edge) => [edge.trim(), C.EdgeTooltips[edge]])), flawData: Object.fromEntries(Object.values(item.system.flaws ?? []) - .filter(flaw => /[A-Za-z]/.test(flaw)) - .map(flaw => [flaw.trim(), C.FlawTooltips[flaw]])) + .filter((flaw) => /[A-Za-z]/.test(flaw)) + .map((flaw) => [flaw.trim(), C.FlawTooltips[flaw]])) }); return item; }), expert: this.actor.activeSubItems .filter((item) => item.type === BladesItemType.cohort_expert) - .map(item => { + .map((item) => { Object.assign(item.system, { tierTotal: item.getFactorTotal(Factor.tier) > 0 ? U.romanizeNum(item.getFactorTotal(Factor.tier)) : "0", cohortRollData: [ { mode: "untrained", label: "Untrained", tooltip: "

Roll Untrained

" } ], edgeData: Object.fromEntries(Object.values(item.system.edges ?? []) - .filter(edge => /[A-Za-z]/.test(edge)) - .map(edge => [edge.trim(), C.EdgeTooltips[edge]])), + .filter((edge) => /[A-Za-z]/.test(edge)) + .map((edge) => [edge.trim(), C.EdgeTooltips[edge]])), flawData: Object.fromEntries(Object.values(item.system.flaws ?? []) - .filter(flaw => /[A-Za-z]/.test(flaw)) - .map(flaw => [flaw.trim(), C.FlawTooltips[flaw]])) + .filter((flaw) => /[A-Za-z]/.test(flaw)) + .map((flaw) => [flaw.trim(), C.FlawTooltips[flaw]])) }); return item; }) @@ -110,7 +110,7 @@ class BladesActorSheet extends ActorSheet { sheetData.playbookData.tooltip = (new Handlebars.SafeString([ "

At the End of the Session, Gain XP If ...

", "" ].join(""))).toString(); } diff --git a/module/sheets/item/BladesGMTrackerSheet.js b/module/sheets/item/BladesGMTrackerSheet.js index 3b020df3..9591ffab 100644 --- a/module/sheets/item/BladesGMTrackerSheet.js +++ b/module/sheets/item/BladesGMTrackerSheet.js @@ -63,7 +63,8 @@ class BladesGMTrackerSheet extends BladesItemSheet { game.eunoblades ??= {}; Items.registerSheet("blades", BladesGMTrackerSheet, { types: ["gm_tracker"], makeDefault: true }); Hooks.once("ready", async () => { - let tracker = game.items.find((item) => BladesItem.IsType(item, BladesItemType.gm_tracker)); + let tracker = game.items + .find((item) => BladesItem.IsType(item, BladesItemType.gm_tracker)); if (!tracker) { tracker = (await BladesGMTracker.create({ name: "GM Tracker", @@ -96,7 +97,7 @@ class BladesGMTrackerSheet extends BladesItemSheet { case BladesPhase.Score: { isForcingRender = false; game.actors.filter((actor) => BladesActor.IsType(actor, BladesActorType.pc)) - .forEach(actor => actor.clearLoadout()); + .forEach((actor) => actor.clearLoadout()); break; } case BladesPhase.Downtime: { @@ -121,10 +122,11 @@ class BladesGMTrackerSheet extends BladesItemSheet { } } if (isForcingRender) { - game.actors.filter(actor => actor.type === BladesActorType.pc) - .forEach(actor => actor.sheet?.render()); + game.actors.filter((actor) => actor.type === BladesActorType.pc) + .forEach((actor) => actor.sheet?.render()); } return submitData; } } -export default BladesGMTrackerSheet; \ No newline at end of file +export default BladesGMTrackerSheet; +export { BladesTipGenerator }; \ No newline at end of file diff --git a/module/sheets/item/BladesItemSheet.js b/module/sheets/item/BladesItemSheet.js index f66ac6c6..64a0ca61 100644 --- a/module/sheets/item/BladesItemSheet.js +++ b/module/sheets/item/BladesItemSheet.js @@ -37,7 +37,7 @@ class BladesItemSheet extends ItemSheet { return this._getTypedItemData[this.item.type]({ ...context, ...sheetData }); } _getTypedItemData = { - [BladesItemType.ability]: context => { + [BladesItemType.ability]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.ability)) { return undefined; } @@ -47,7 +47,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.background]: context => { + [BladesItemType.background]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.background)) { return undefined; } @@ -57,7 +57,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.clock_keeper]: context => { + [BladesItemType.clock_keeper]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.clock_keeper)) { return undefined; } @@ -69,7 +69,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.cohort_gang]: context => { + [BladesItemType.cohort_gang]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.cohort_gang, BladesItemType.cohort_expert)) { return undefined; } @@ -90,18 +90,18 @@ class BladesItemSheet extends ItemSheet { } }; sheetData.edgeData = Object.fromEntries(Object.values(context.system.edges ?? []) - .filter(edge => /[A-Za-z]/.test(edge)) - .map(edge => [edge.trim(), C.EdgeTooltips[edge]])); + .filter((edge) => /[A-Za-z]/.test(edge)) + .map((edge) => [edge.trim(), C.EdgeTooltips[edge]])); sheetData.flawData = Object.fromEntries(Object.values(context.system.flaws ?? []) - .filter(flaw => /[A-Za-z]/.test(flaw)) - .map(flaw => [flaw.trim(), C.FlawTooltips[flaw]])); + .filter((flaw) => /[A-Za-z]/.test(flaw)) + .map((flaw) => [flaw.trim(), C.FlawTooltips[flaw]])); return { ...context, ...sheetData }; }, - [BladesItemType.cohort_expert]: context => this._getTypedItemData[BladesItemType.cohort_gang](context), - [BladesItemType.crew_ability]: context => { + [BladesItemType.cohort_expert]: (context) => this._getTypedItemData[BladesItemType.cohort_gang](context), + [BladesItemType.crew_ability]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.crew_ability)) { return undefined; } @@ -111,7 +111,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.crew_reputation]: context => { + [BladesItemType.crew_reputation]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.crew_reputation)) { return undefined; } @@ -121,13 +121,13 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.crew_playbook]: context => { + [BladesItemType.crew_playbook]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.crew_playbook)) { return undefined; } if (context.isGM) { const expClueData = {}; - [...Object.values(context.system.experience_clues ?? []).filter(clue => /[A-Za-z]/.test(clue)), " "].forEach((clue, i) => { expClueData[(i + 1).toString()] = clue; }); + [...Object.values(context.system.experience_clues ?? []).filter((clue) => /[A-Za-z]/.test(clue)), " "].forEach((clue, i) => { expClueData[(i + 1).toString()] = clue; }); context.system.experience_clues = expClueData; } const sheetData = {}; @@ -136,7 +136,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.crew_upgrade]: context => { + [BladesItemType.crew_upgrade]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.crew_upgrade)) { return undefined; } @@ -146,7 +146,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.feature]: context => { + [BladesItemType.feature]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.feature)) { return undefined; } @@ -156,7 +156,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.gm_tracker]: context => { + [BladesItemType.gm_tracker]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.gm_tracker)) { return undefined; } @@ -166,7 +166,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.heritage]: context => { + [BladesItemType.heritage]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.heritage)) { return undefined; } @@ -176,7 +176,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.gear]: context => { + [BladesItemType.gear]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.gear)) { return undefined; } @@ -200,16 +200,16 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.playbook]: context => { + [BladesItemType.playbook]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.playbook)) { return undefined; } if (context.isGM) { const expClueData = {}; - [...Object.values(context.system.experience_clues ?? []).filter(clue => /[A-Za-z]/.test(clue)), " "].forEach((clue, i) => { expClueData[(i + 1).toString()] = clue; }); + [...Object.values(context.system.experience_clues ?? []).filter((clue) => /[A-Za-z]/.test(clue)), " "].forEach((clue, i) => { expClueData[(i + 1).toString()] = clue; }); context.system.experience_clues = expClueData; const gatherInfoData = {}; - [...Object.values(context.system.gather_info_questions ?? []).filter(question => /[A-Za-z]/.test(question)), " "].forEach((question, i) => { gatherInfoData[(i + 1).toString()] = question; }); + [...Object.values(context.system.gather_info_questions ?? []).filter((question) => /[A-Za-z]/.test(question)), " "].forEach((question, i) => { gatherInfoData[(i + 1).toString()] = question; }); context.system.gather_info_questions = gatherInfoData; } const sheetData = {}; @@ -218,7 +218,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.preferred_op]: context => { + [BladesItemType.preferred_op]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.preferred_op)) { return undefined; } @@ -228,7 +228,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.stricture]: context => { + [BladesItemType.stricture]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.stricture)) { return undefined; } @@ -238,7 +238,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.vice]: context => { + [BladesItemType.vice]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.vice)) { return undefined; } @@ -248,7 +248,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.project]: context => { + [BladesItemType.project]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.project)) { return undefined; } @@ -258,7 +258,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.ritual]: context => { + [BladesItemType.ritual]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.ritual)) { return undefined; } @@ -268,7 +268,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.design]: context => { + [BladesItemType.design]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.design)) { return undefined; } @@ -278,7 +278,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.location]: context => { + [BladesItemType.location]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.location)) { return undefined; } @@ -288,7 +288,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.score]: context => { + [BladesItemType.score]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.score)) { return undefined; } @@ -353,14 +353,14 @@ class BladesItemSheet extends ItemSheet { }); if (BladesItem.IsType(this.item, BladesItemType.cohort_expert, BladesItemType.cohort_gang)) { html.find("[data-harm-click]").on({ - click: event => { + click: (event) => { event.preventDefault(); const harmLevel = U.pInt($(event.currentTarget).data("harmClick")); if (this.item.system.harm?.value !== harmLevel) { this.item.update({ "system.harm.value": harmLevel }); } }, - contextmenu: event => { + contextmenu: (event) => { event.preventDefault(); const harmLevel = Math.max(0, U.pInt($(event.currentTarget).data("harmClick")) - 1); if (this.item.system.harm?.value !== harmLevel) { @@ -372,7 +372,7 @@ class BladesItemSheet extends ItemSheet { if (this.options.submitOnChange) { html.on("change", "textarea", this._onChangeInput.bind(this)); } - html.find(".effect-control").on("click", ev => { + html.find(".effect-control").on("click", (ev) => { if (self.item.isOwned) { ui.notifications?.warn(game.i18n.localize("BITD.EffectWarning")); return; diff --git a/module/sheets/item/BladesScoreSheet.js b/module/sheets/item/BladesScoreSheet.js index d372ee41..df997456 100644 --- a/module/sheets/item/BladesScoreSheet.js +++ b/module/sheets/item/BladesScoreSheet.js @@ -55,36 +55,37 @@ class BladesScoreSheet extends BladesItemSheet { async generateRandomizerData(category) { const randomData = { Bargains: Object.fromEntries(Object.entries(U.sample(Randomizers.GM.Bargains - .filter(bData => !Object.values(this.document.system.randomizers.Bargains) - .some(_bData => _bData.name === bData.name || _bData.effect === bData.effect)), 3, true, (e, a) => a - .filter(_e => e.category === _e.category).length === 0)) + .filter((bData) => !Object.values(this.document.system.randomizers.Bargains) + .some((_bData) => _bData.name === bData.name || _bData.effect === bData.effect)), 3, true, (e, a) => a + .filter((_e) => e.category === _e.category).length === 0)) .map(([k, v]) => { k = `${k}`; Object.assign(v, { notes: "" }); return [k, v]; })), Obstacles: Object.fromEntries(Object.entries(U.sample(Randomizers.GM.Obstacles - .filter(bData => !Object.values(this.document.system.randomizers.Obstacles) - .some(_bData => _bData.name === bData.name || _bData.desc === bData.desc)), 3, true, (e, a) => a - .filter(_e => e.category === _e.category).length === 0)) + .filter((bData) => !Object.values(this.document.system.randomizers.Obstacles) + .some((_bData) => _bData.name === bData.name || _bData.desc === bData.desc)), 3, true, (e, a) => a + .filter((_e) => e.category === _e.category).length === 0)) .map(([k, v]) => { k = `${k}`; Object.assign(v, { notes: "" }); return [k, v]; })), NPCs: Object.fromEntries(Object.entries(U.sample(Randomizers.GM.NPCs - .filter(bData => !Object.values(this.document.system.randomizers.NPCs) - .some(_bData => _bData.name === bData.name || _bData.description === bData.description)), 3, true, (e, a) => a - .filter(_e => e.arena === _e.arena).length === 0)) + .filter((bData) => !Object.values(this.document.system.randomizers.NPCs) + .some((_bData) => _bData.name === bData.name + || _bData.description === bData.description)), 3, true, (e, a) => a + .filter((_e) => e.arena === _e.arena).length === 0)) .map(([k, v]) => { k = `${k}`; Object.assign(v, { notes: "" }); return [k, v]; })), Scores: Object.fromEntries(Object.entries(U.sample(Randomizers.GM.Scores - .filter(bData => !Object.values(this.document.system.randomizers.Scores) - .some(_bData => _bData.name === bData.name || _bData.desc === bData.desc)), 3, true, (e, a) => a - .filter(_e => e.category === _e.category).length === 0)) + .filter((bData) => !Object.values(this.document.system.randomizers.Scores) + .some((_bData) => _bData.name === bData.name || _bData.desc === bData.desc)), 3, true, (e, a) => a + .filter((_e) => e.category === _e.category).length === 0)) .map(([k, v]) => { k = `${k}`; Object.assign(v, { notes: "" }); @@ -93,7 +94,7 @@ class BladesScoreSheet extends BladesItemSheet { }; if (category) { Object.keys(randomData) - .filter(cat => cat !== category) + .filter((cat) => cat !== category) .forEach((cat) => { const _cat = cat; randomData[_cat] = this.document.system.randomizers[_cat]; @@ -107,7 +108,7 @@ class BladesScoreSheet extends BladesItemSheet { }; Object.keys(randomData).forEach((cat) => { const _cat = cat; - Object.keys(randomData[_cat]).forEach(index => { + Object.keys(randomData[_cat]).forEach((index) => { if (this.document.system.randomizers?.[_cat][index].isLocked) { finalRandomData[_cat][index] = this.document.system.randomizers[_cat][index]; } @@ -122,7 +123,7 @@ class BladesScoreSheet extends BladesItemSheet { const context = super.getData(); const sheetData = {}; sheetData.playerCharacters = BladesActor.GetTypeWithTags(BladesActorType.pc, Tag.PC.ActivePC) - .map(pc => { + .map((pc) => { return Object.assign(pc, { actionData: Object.fromEntries(Object.entries(pc.system.attributes) .map(([attrName, attrData]) => { @@ -183,7 +184,7 @@ class BladesScoreSheet extends BladesItemSheet { })); } _addImage() { - U.displayImageSelector(path => { + U.displayImageSelector((path) => { const imgIndex = U.objSize(this.document.system.images); return this.document.update({ [`system.images.${imgIndex}`]: path }); }, "systems/eunos-blades/assets", this.position); @@ -257,7 +258,7 @@ class BladesScoreSheet extends BladesItemSheet { case BladesPhase.Score: { isForcingRender = false; game.actors.filter((actor) => BladesActor.IsType(actor, BladesActorType.pc)) - .forEach(actor => actor.clearLoadout()); + .forEach((actor) => actor.clearLoadout()); break; } case BladesPhase.Downtime: { @@ -280,8 +281,8 @@ class BladesScoreSheet extends BladesItemSheet { } } if (isForcingRender) { - game.actors.filter(actor => actor.type === BladesActorType.pc) - .forEach(actor => actor.sheet?.render()); + game.actors.filter((actor) => actor.type === BladesActorType.pc) + .forEach((actor) => actor.sheet?.render()); } return submitData; } diff --git a/ts/BladesActor.ts b/ts/BladesActor.ts index c2a45292..0d512b75 100644 --- a/ts/BladesActor.ts +++ b/ts/BladesActor.ts @@ -56,13 +56,13 @@ class BladesActor extends Actor implements BladesDocument { static Get(actorRef: ActorRef): BladesActor | undefined { if (actorRef instanceof BladesActor) { return actorRef; } if (U.isDocID(actorRef)) { return BladesActor.All.get(actorRef); } - return BladesActor.All.find(a => a.system.world_name === actorRef) - || BladesActor.All.find(a => a.name === actorRef); + return BladesActor.All.find((a) => a.system.world_name === actorRef) + || BladesActor.All.find((a) => a.name === actorRef); } static GetTypeWithTags(docType: T, ...tags: BladesTag[]): Array> { - return BladesActor.All.filter(actor => actor.type === docType) - .filter(actor => actor.hasTag(...tags)) as Array>; + return BladesActor.All.filter((actor) => actor.type === docType) + .filter((actor) => actor.hasTag(...tags)) as Array>; } static IsType(doc: unknown, ...types: T[]): doc is BladesActorOfType { @@ -73,12 +73,12 @@ class BladesActor extends Actor implements BladesDocument { get tags(): BladesTag[] { return this.system.tags ?? []; } hasTag(...tags: BladesTag[]): boolean { - return tags.every(tag => this.tags.includes(tag)); + return tags.every((tag) => this.tags.includes(tag)); } async addTag(...tags: BladesTag[]) { const curTags = this.tags; - tags.forEach(tag => { + tags.forEach((tag) => { if (curTags.includes(tag)) { return; } curTags.push(tag); }); @@ -87,7 +87,7 @@ class BladesActor extends Actor implements BladesDocument { } async remTag(...tags: BladesTag[]) { - const curTags = this.tags.filter(tag => !tags.includes(tag)); + const curTags = this.tags.filter((tag) => !tags.includes(tag)); eLog.checkLog2("actor", "BladesActor.remTag(...tags)", {tags, curTags}); await this.update({"system.tags": curTags}); } @@ -131,16 +131,16 @@ class BladesActor extends Actor implements BladesDocument { get subActors(): BladesActor[] { return Object.keys(this.system.subactors) - .map(id => this.getSubActor(id)) + .map((id) => this.getSubActor(id)) .filter((subActor): subActor is BladesActor => Boolean(subActor)); } get activeSubActors(): BladesActor[] { - return this.subActors.filter(subActor => !subActor.hasTag(Tag.System.Archived)); + return this.subActors.filter((subActor) => !subActor.hasTag(Tag.System.Archived)); } get archivedSubActors(): BladesActor[] { - return this.subActors.filter(subActor => subActor.hasTag(Tag.System.Archived)); + return this.subActors.filter((subActor) => subActor.hasTag(Tag.System.Archived)); } checkActorPrereqs(actor: BladesActor): boolean { @@ -156,9 +156,9 @@ class BladesActor extends Actor implements BladesDocument { // Step 1: Filter out globals that fail prereqs. .filter(this.checkActorPrereqs) // Step 2: Filter out actors that are already active subActors - .filter(gActor => !this.activeSubActors.some(aActor => aActor.id === gActor.id)) + .filter((gActor) => !this.activeSubActors.some((aActor) => aActor.id === gActor.id)) // Step 3: Merge subactor data onto matching global actors - .map(gActor => this.getSubActor(gActor) || gActor) + .map((gActor) => this.getSubActor(gActor) || gActor) // Step 4: Sort by name .sort((a, b) => { if (a.name === b.name) { return 0; } @@ -236,16 +236,16 @@ class BladesActor extends Actor implements BladesDocument { if (!focusSubActor) { return; } // Does this Actor contain any tags limiting it to one per actor? - const uniqueTags = focusSubActor.tags.filter(tag => tag in BladesActorUniqueTags); + const uniqueTags = focusSubActor.tags.filter((tag) => tag in BladesActorUniqueTags); if (uniqueTags.length > 0) { // ... then archive all other versions. - uniqueTags.forEach(uTag => this.activeSubActors + uniqueTags.forEach((uTag) => this.activeSubActors .filter((subActor): subActor is BladesActor => Boolean(focusSubActor?.id && subActor.id !== focusSubActor.id && subActor.hasTag(uTag)) ) - .map(subActor => this.remSubActor(subActor.id))); + .map((subActor) => this.remSubActor(subActor.id))); } } @@ -302,7 +302,7 @@ class BladesActor extends Actor implements BladesDocument { } async clearSubActors(isReRendering = true): Promise { - this.subActors.forEach(subActor => { + this.subActors.forEach((subActor) => { if (subActor.parentActor?.id === this.id) { subActor.clearParentActor(isReRendering); } }); await this.sheet?.render(); @@ -325,9 +325,9 @@ class BladesActor extends Actor implements BladesDocument { get subItems() { return Array.from(this.items); } - get activeSubItems() { return this.items.filter(item => !item.hasTag(Tag.System.Archived)); } + get activeSubItems() { return this.items.filter((item) => !item.hasTag(Tag.System.Archived)); } - get archivedSubItems() { return this.items.filter(item => item.hasTag(Tag.System.Archived)); } + get archivedSubItems() { return this.items.filter((item) => item.hasTag(Tag.System.Archived)); } private _checkItemPrereqs(item: BladesItem): boolean { if (!item.system.prereqs) { return true; } @@ -383,8 +383,8 @@ class BladesActor extends Actor implements BladesDocument { pType: PrereqType ): boolean { const thisItem = this.activeSubItems - .filter(i => !hitRecord[pType]?.includes(i.id)) - .find(i => i.system.world_name === pString); + .filter((i) => !hitRecord[pType]?.includes(i.id)) + .find((i) => i.system.world_name === pString); if (thisItem) { hitRecord[pType]?.push(thisItem.id); return true; @@ -399,8 +399,8 @@ class BladesActor extends Actor implements BladesDocument { pType: PrereqType ): boolean { const thisItem = this.activeSubItems - .filter(i => !hitRecord[pType]?.includes(i.id)) - .find(i => i.hasTag(pString as BladesTag)); + .filter((i) => !hitRecord[pType]?.includes(i.id)) + .find((i) => i.hasTag(pString as BladesTag)); if (thisItem) { hitRecord[pType]?.push(thisItem.id); return true; @@ -424,15 +424,15 @@ class BladesActor extends Actor implements BladesDocument { return globalItems // Step 1: Filter out globals that fail prereqs. - .filter(item => this._checkItemPrereqs(item)) + .filter((item) => this._checkItemPrereqs(item)) // Step 2: Filter out already-active items based on max_per_score (unless MultiplesOk) - .filter(gItem => gItem.hasTag(Tag.System.MultiplesOK) + .filter((gItem) => gItem.hasTag(Tag.System.MultiplesOK) || (gItem.system.max_per_score ?? 1) - > this.activeSubItems.filter(sItem => sItem.system.world_name === gItem.system.world_name).length) + > this.activeSubItems.filter((sItem) => sItem.system.world_name === gItem.system.world_name).length) // Step 3: Replace with matching Archived, Embedded subItems - .map(gItem => { + .map((gItem) => { const matchingSubItems = this.archivedSubItems.filter((sItem): sItem is BladesItemOfType => sItem.system.world_name === gItem.system.world_name); if (matchingSubItems.length > 0) { @@ -444,7 +444,7 @@ class BladesActor extends Actor implements BladesDocument { .flat() // Step 4: Apply CSS classes - .map(sItem => { + .map((sItem) => { sItem.dialogCSSClasses = ""; const cssClasses: string[] = []; if (sItem.isEmbedded) { @@ -519,7 +519,7 @@ class BladesActor extends Actor implements BladesDocument { if (this.type === BladesActorType.pc) { dialogData.Basic = this._processEmbeddedItemMatches( BladesItem.GetTypeWithTags(BladesItemType.playbook) - .filter(item => !item.hasTag(Tag.Gear.Advanced)) + .filter((item) => !item.hasTag(Tag.Gear.Advanced)) ); dialogData.Advanced = this._processEmbeddedItemMatches( BladesItem.GetTypeWithTags(BladesItemType.playbook, Tag.Gear.Advanced) @@ -540,14 +540,14 @@ class BladesActor extends Actor implements BladesDocument { ...BladesItem.GetTypeWithTags(BladesItemType.gear, playbookName), ...BladesItem.GetTypeWithTags(BladesItemType.gear, Tag.Gear.General) ]) - .filter(item => self.remainingLoad >= item.system.load); + .filter((item) => self.remainingLoad >= item.system.load); // Two tabs, one for playbook and the other for general items - dialogData[playbookName] = gearItems.filter(item => item.hasTag(playbookName)); + dialogData[playbookName] = gearItems.filter((item) => item.hasTag(playbookName)); dialogData.General = gearItems - .filter(item => item.hasTag(Tag.Gear.General)) + .filter((item) => item.hasTag(Tag.Gear.General)) // Remove featured class from General items - .map(item => { + .map((item) => { if (item.dialogCSSClasses) { item.dialogCSSClasses = item.dialogCSSClasses.replace(/featured-item\s?/g, ""); } @@ -566,9 +566,9 @@ class BladesActor extends Actor implements BladesDocument { BladesItem.GetTypeWithTags(BladesItemType.ability, playbookName) ); dialogData.Veteran = this._processEmbeddedItemMatches(BladesItem.GetTypeWithTags(BladesItemType.ability)) - .filter(item => !item.hasTag(playbookName)) + .filter((item) => !item.hasTag(playbookName)) // Remove featured class from Veteran items - .map(item => { + .map((item) => { if (item.dialogCSSClasses) { item.dialogCSSClasses = item.dialogCSSClasses.replace(/featured-item\s?/g, ""); } @@ -609,21 +609,21 @@ class BladesActor extends Actor implements BladesDocument { } else { const globalItem = BladesItem.Get(itemRef); if (!globalItem) { return undefined; } - return this.items.find(item => item.name === globalItem.name && activeCheck(item)) - ?? this.items.find(item => item.system.world_name === globalItem.system.world_name && activeCheck(item)); + return this.items.find((item) => item.name === globalItem.name && activeCheck(item)) + ?? this.items.find((item) => item.system.world_name === globalItem.system.world_name && activeCheck(item)); } } hasSubItemOf(itemRef: ItemRef): boolean { const item = BladesItem.Get(itemRef); if (!item) { return false; } - return Boolean(this.items.find(i => i.system.world_name === item.system.world_name)); + return Boolean(this.items.find((i) => i.system.world_name === item.system.world_name)); } hasActiveSubItemOf(itemRef: ItemRef): boolean { const item = BladesItem.Get(itemRef); if (!item) { return false; } - return Boolean(this.items.find(i => !i.hasTag(Tag.System.Archived) + return Boolean(this.items.find((i) => !i.hasTag(Tag.System.Archived) && i.system.world_name === item.system.world_name)); } @@ -681,7 +681,7 @@ class BladesActor extends Actor implements BladesDocument { if (focusItem && isBladesItemUniqueTypes(focusItem.type)) { // ... then archive all other versions. await Promise.all(this.activeSubItems - .filter(subItem => subItem.type === focusItem?.type + .filter((subItem) => subItem.type === focusItem?.type && subItem.system.world_name !== focusItem?.system.world_name && !subItem.hasTag(Tag.System.Archived)) .map(this.remSubItem.bind(this))); @@ -768,14 +768,14 @@ class BladesActor extends Actor implements BladesDocument { const pointsUpgradeOrAbility = this.system.advancement_points?.[AdvancementPoint.UpgradeOrAbility] ?? 0; const spentAbility = U.sum(this.items - .filter(item => BladesItem.IsType(item, BladesItemType.ability, BladesItemType.crew_ability)) - .map(abil => abil.system.price ?? 1)); + .filter((item) => BladesItem.IsType(item, BladesItemType.ability, BladesItemType.crew_ability)) + .map((abil) => abil.system.price ?? 1)); const spentCohortType = U.sum(this.cohorts - .map(cohort => Math.max(0, U.unique(Object.values(cohort.system.subtypes)).length - 1)) + .map((cohort) => Math.max(0, U.unique(Object.values(cohort.system.subtypes)).length - 1)) ); const spentUpgrade = U.sum(this.items - .filter(item => BladesItem.IsType(item, BladesItemType.crew_upgrade)) - .map(upgrade => upgrade.system.price ?? 1)); + .filter((item) => BladesItem.IsType(item, BladesItemType.crew_upgrade)) + .map((upgrade) => upgrade.system.price ?? 1)); const excessUpgrade = Math.max(0, spentUpgrade - pointsUpgrade); const excessCohortType = Math.max(0, spentCohortType - pointsCohortType); @@ -828,7 +828,7 @@ class BladesActor extends Actor implements BladesDocument { } if (BladesActor.IsType(this, BladesActorType.crew)) { BladesPushAlert.Get().pushToAll("GM", `${this.name} Advances their Playbook!`, "Select new Upgrades and/or Abilities on your Crew Sheet."); - this.members.forEach(member => { + this.members.forEach((member) => { const coinGained = this.system.tier.value + 2; BladesPushAlert.Get().pushToAll("GM", `${member.name} Gains ${coinGained} Stash (Crew Advancement)`, undefined); member.addStash(coinGained); @@ -839,7 +839,7 @@ class BladesActor extends Actor implements BladesDocument { async advanceAttribute(attribute: AttributeTrait) { await this.update({[`system.experience.${attribute}.value`]: 0}); - const actions = C.Action[attribute].map(action => `${U.tCase(action)}`); + const actions = C.Action[attribute].map((action) => `${U.tCase(action)}`); BladesPushAlert.Get().pushToAll("GM", `${this.name} Advances their ${U.uCase(attribute)}!`, `${this.name}, add a dot to one of ${U.oxfordize(actions, true, "or")}.`); } @@ -921,7 +921,7 @@ class BladesActor extends Actor implements BladesDocument { get turfCount(): number { if (!BladesActor.IsType(this, BladesActorType.crew) || !this.playbook) { return 0; } return Object.values(this.playbook.system.turfs) - .filter(claim => claim.isTurf && claim.value).length; + .filter((claim) => claim.isTurf && claim.value).length; } get upgrades(): Array> { @@ -957,7 +957,7 @@ class BladesActor extends Actor implements BladesDocument { system.experience.clues = [ ...system.experience.clues, ...Object.values(this.playbook.system.experience_clues) - .filter(clue => Boolean(clue.trim())) + .filter((clue) => Boolean(clue.trim())) ]; } // Extract gather information questions from playbook item, if any @@ -965,7 +965,7 @@ class BladesActor extends Actor implements BladesDocument { system.gather_info = [ ...system.gather_info, ...Object.values(this.playbook.system.gather_info_questions) - .filter(question => Boolean(question.trim())) + .filter((question) => Boolean(question.trim())) ]; } } @@ -978,7 +978,7 @@ class BladesActor extends Actor implements BladesDocument { system.experience.clues = [ ...system.experience.clues, ...Object.values(this.playbook.system.experience_clues) - .filter(clue => Boolean(clue.trim())) + .filter((clue) => Boolean(clue.trim())) ]; system.turfs = this.playbook.system.turfs; } @@ -989,11 +989,11 @@ class BladesActor extends Actor implements BladesDocument { // #region OVERRIDES: _onCreateDescendantDocuments, update ~ // @ts-expect-error New method not defined in @league VTT types. override async _onCreateDescendantDocuments(parent: BladesActor, collection: "items"|"effects", docs: BladesItem[]|BladesActiveEffect[], data: BladesItem[]|BladesActiveEffect[], options: Record, userId: string) { - await Promise.all(docs.map(async doc => { + await Promise.all(docs.map(async (doc) => { if (BladesItem.IsType(doc, BladesItemType.playbook, BladesItemType.crew_playbook)) { await Promise.all(this.activeSubItems - .filter(aItem => aItem.type === doc.type && aItem.system.world_name !== doc.system.world_name) - .map(aItem => this.remSubItem(aItem))); + .filter((aItem) => aItem.type === doc.type && aItem.system.world_name !== doc.system.world_name) + .map((aItem) => this.remSubItem(aItem))); } })); @@ -1002,11 +1002,11 @@ class BladesActor extends Actor implements BladesDocument { eLog.checkLog("actorTrigger", "_onCreateDescendantDocuments", {parent, collection, docs, data, options, userId}); - docs.forEach(doc => { + docs.forEach((doc) => { if (BladesItem.IsType(doc, BladesItemType.vice) && BladesActor.IsType(this, BladesActorType.pc)) { this.activeSubActors - .filter(subActor => subActor.hasTag(Tag.NPC.VicePurveyor) && !subActor.hasTag(doc.name as Vice)) - .forEach(subActor => { this.remSubActor(subActor); }); + .filter((subActor) => subActor.hasTag(Tag.NPC.VicePurveyor) && !subActor.hasTag(doc.name as Vice)) + .forEach((subActor) => { this.remSubActor(subActor); }); } }); } @@ -1104,7 +1104,7 @@ class BladesActor extends Actor implements BladesDocument { * @param {...string} curVals The values to exclude from the sample. */ function sampleArray(arr: string[], ...curVals: string[]): string { - arr = arr.filter(elem => !curVals.includes(elem)); + arr = arr.filter((elem) => !curVals.includes(elem)); if (!arr.length) { return ""; } return arr[Math.floor(Math.random() * arr.length)]; } @@ -1123,7 +1123,7 @@ class BladesActor extends Actor implements BladesDocument { Math.random() <= suffixChance ? sampleArray(Randomizers.NPC.name_suffix) : "" - ].filter(val => Boolean(val)).join(" "); + ].filter((val) => Boolean(val)).join(" "); }, background: () => sampleArray(Randomizers.NPC.background, random.background.value), heritage: () => sampleArray(Randomizers.NPC.heritage, random.heritage.value), @@ -1149,16 +1149,16 @@ class BladesActor extends Actor implements BladesDocument { const gender = persona.gender.isLocked ? persona.gender.value : randomGen.gender(); const updateKeys = [ - ...Object.keys(persona).filter(key => !persona[key as KeyOf]?.isLocked), - ...Object.keys(random).filter(key => !random[key as KeyOf]?.isLocked), - ...Object.keys(secret).filter(key => !secret[key as KeyOf]?.isLocked) - .map(secretKey => `secret-${secretKey}`) + ...Object.keys(persona).filter((key) => !persona[key as KeyOf]?.isLocked), + ...Object.keys(random).filter((key) => !random[key as KeyOf]?.isLocked), + ...Object.keys(secret).filter((key) => !secret[key as KeyOf]?.isLocked) + .map((secretKey) => `secret-${secretKey}`) ]; eLog.checkLog("Update Keys", {updateKeys}); const updateData: Record = {}; - updateKeys.forEach(key => { + updateKeys.forEach((key) => { switch (key) { case "name": case "heritage": diff --git a/ts/BladesItem.ts b/ts/BladesItem.ts index db1d7782..0e1cc378 100644 --- a/ts/BladesItem.ts +++ b/ts/BladesItem.ts @@ -47,18 +47,18 @@ class BladesItem extends Item implements BladesDocument, static Get(itemRef: ItemRef): BladesItem|undefined { if (itemRef instanceof BladesItem) { return itemRef; } if (U.isDocID(itemRef)) { return BladesItem.All.get(itemRef); } - return BladesItem.All.find(a => a.system.world_name === itemRef) - || BladesItem.All.find(a => a.name === itemRef); + return BladesItem.All.find((a) => a.system.world_name === itemRef) + || BladesItem.All.find((a) => a.name === itemRef); } static GetTypeWithTags(docType: T|T[], ...tags: BladesTag[]): Array> { if (Array.isArray(docType)) { return docType - .map(dType => BladesItem.All.filter((item): item is BladesItemOfType => item.type === dType)) + .map((dType) => BladesItem.All.filter((item): item is BladesItemOfType => item.type === dType)) .flat(); } return BladesItem.All.filter((item): item is BladesItemOfType => item.type === docType) - .filter(item => item.hasTag(...tags)); + .filter((item) => item.hasTag(...tags)); } static IsType(doc: unknown, ...types: T[]): doc is BladesItemOfType { @@ -69,12 +69,12 @@ class BladesItem extends Item implements BladesDocument, get tags(): BladesTag[] { return this.system.tags ?? []; } hasTag(...tags: BladesTag[]): boolean { - return tags.every(tag => this.tags.includes(tag)); + return tags.every((tag) => this.tags.includes(tag)); } async addTag(...tags: BladesTag[]) { const curTags = this.tags; - tags.forEach(tag => { + tags.forEach((tag) => { if (curTags.includes(tag)) { return; } curTags.push(tag); }); @@ -82,7 +82,7 @@ class BladesItem extends Item implements BladesDocument, } async remTag(...tags: BladesTag[]) { - const curTags = this.tags.filter(tag => !tags.includes(tag)); + const curTags = this.tags.filter((tag) => !tags.includes(tag)); await this.update({"system.tags": curTags}); } @@ -277,24 +277,24 @@ class BladesItem extends Item implements BladesDocument, system.tier.name = "Quality"; const subtypes = U.unique(Object.values(system.subtypes) - .map(subtype => subtype.trim()) - .filter(subtype => /[A-Za-z]/.test(subtype))); + .map((subtype) => subtype.trim()) + .filter((subtype) => /[A-Za-z]/.test(subtype))); const eliteSubtypes = U.unique([ ...Object.values(system.elite_subtypes), ...(this.parent?.upgrades ?? []) - .filter(upgrade => (upgrade.name ?? "").startsWith("Elite")) - .map(upgrade => (upgrade.name ?? "").trim().replace(/^Elite /, "")) + .filter((upgrade) => (upgrade.name ?? "").startsWith("Elite")) + .map((upgrade) => (upgrade.name ?? "").trim().replace(/^Elite /, "")) ] - .map(subtype => subtype.trim()) - .filter(subtype => /[A-Za-z]/.test(subtype) && subtypes.includes(subtype))); + .map((subtype) => subtype.trim()) + .filter((subtype) => /[A-Za-z]/.test(subtype) && subtypes.includes(subtype))); system.subtypes = Object.fromEntries(subtypes.map((subtype, i) => [`${i + 1}`, subtype])); system.elite_subtypes = Object.fromEntries(eliteSubtypes.map((subtype, i) => [`${i + 1}`, subtype])); system.edges = Object.fromEntries(Object.values(system.edges ?? []) - .filter(edge => /[A-Za-z]/.test(edge)) + .filter((edge) => /[A-Za-z]/.test(edge)) .map((edge, i) => [`${i + 1}`, edge.trim()])); system.flaws = Object.fromEntries(Object.values(system.flaws ?? []) - .filter(flaw => /[A-Za-z]/.test(flaw)) + .filter((flaw) => /[A-Za-z]/.test(flaw)) .map((flaw, i) => [`${i + 1}`, flaw.trim()])); system.quality = this.getFactorTotal(Factor.quality); @@ -323,8 +323,8 @@ class BladesItem extends Item implements BladesDocument, system.subtitle = C.VehicleDescriptors[Math.min(6, this.getFactorTotal(Factor.tier))]; } else { system.subtitle += ` ${U.oxfordize([ - ...subtypes.filter(subtype => !eliteSubtypes.includes(subtype)), - ...eliteSubtypes.map(subtype => `Elite ${subtype}`) + ...subtypes.filter((subtype) => !eliteSubtypes.includes(subtype)), + ...eliteSubtypes.map((subtype) => `Elite ${subtype}`) ], false, "&")}`; } } @@ -338,13 +338,13 @@ class BladesItem extends Item implements BladesDocument, _preparePlaybookData(system: ExtractBladesItemSystem) { if (!BladesItem.IsType(this, BladesItemType.playbook, BladesItemType.crew_playbook)) { return; } const expClueData: Record = {}; - [...Object.values(system.experience_clues).filter(clue => /[A-Za-z]/.test(clue)), " "].forEach((clue, i) => { expClueData[(i + 1).toString()] = clue; }); + [...Object.values(system.experience_clues).filter((clue) => /[A-Za-z]/.test(clue)), " "].forEach((clue, i) => { expClueData[(i + 1).toString()] = clue; }); system.experience_clues = expClueData; eLog.checkLog3("experienceClues", {expClueData}); if (BladesItem.IsType(this, BladesItemType.playbook)) { const gatherInfoData: Record = {}; - [...Object.values(system.gather_info_questions).filter(question => /[A-Za-z]/.test(question)), " "].forEach((question, i) => { gatherInfoData[(i + 1).toString()] = question; }); + [...Object.values(system.gather_info_questions).filter((question) => /[A-Za-z]/.test(question)), " "].forEach((question, i) => { gatherInfoData[(i + 1).toString()] = question; }); system.gather_info_questions = gatherInfoData; eLog.checkLog3("gatherInfoQuestions", {gatherInfoData}); diff --git a/ts/BladesPushAlert.ts b/ts/BladesPushAlert.ts index d22b459f..482e0ec8 100644 --- a/ts/BladesPushAlert.ts +++ b/ts/BladesPushAlert.ts @@ -97,7 +97,7 @@ export default class BladesPushAlert { .filter((user): user is User & {id: string} => Boolean(user?.id)); if (!users || users.length === 0) { return; } const pushArgs = args.slice(0, 3) as [string, string, string|undefined]; - socketlib.system.executeForUsers("pushNotice", users.map(user => user.id), "", ...pushArgs); + socketlib.system.executeForUsers("pushNotice", users.map((user) => user.id), "", ...pushArgs); } pushToGM(...args: [string, string, string|undefined]) { diff --git a/ts/BladesRoll.ts b/ts/BladesRoll.ts index 21323346..fa7b6a1f 100644 --- a/ts/BladesRoll.ts +++ b/ts/BladesRoll.ts @@ -96,16 +96,16 @@ class BladesRollMod { if (!roll_mods || roll_mods.length === 0) { return []; } return (roll_mods - .filter(elem => typeof elem === "string") as string[]) - .map(modString => { + .filter((elem) => typeof elem === "string") as string[]) + .map((modString) => { const pStrings = modString.split(/@/); - const nameString = U.pullElement(pStrings, v => typeof v === "string" && /^na/i.test(v)); + const nameString = U.pullElement(pStrings, (v) => typeof v === "string" && /^na/i.test(v)); const nameVal = (typeof nameString === "string" && nameString.replace(/^.*:/, "")); if (!nameVal) { throw new Error(`RollMod Missing Name: '${modString}'`); } - const catString = U.pullElement(pStrings, v => typeof v === "string" && /^cat/i.test(v)); + const catString = U.pullElement(pStrings, (v) => typeof v === "string" && /^cat/i.test(v)); const catVal = (typeof catString === "string" && catString.replace(/^.*:/, "")) as RollModSection|false; if (!catVal || !(catVal in RollModSection)) { throw new Error(`RollMod Missing Category: '${modString}'`); } - const posNegString = (U.pullElement(pStrings, v => typeof v === "string" && /^p/i.test(v)) || "posNeg:positive"); + const posNegString = (U.pullElement(pStrings, (v) => typeof v === "string" && /^p/i.test(v)) || "posNeg:positive"); const posNegVal = posNegString.replace(/^.*:/, "") as "positive"|"negative"; const rollModData: BladesRoll.RollModData = { @@ -119,7 +119,7 @@ class BladesRollMod { tooltip: "" }; - pStrings.forEach(pString => { + pStrings.forEach((pString) => { const [keyString, valString] = pString.split(/:/) as [string, string]; let val: string|string[] = /\|/.test(valString) ? valString.split(/\|/) : valString; let key: KeyOf; @@ -232,16 +232,16 @@ class BladesRollMod { get isPush(): boolean { return Boolean(U.lCase(this.name) === "push" - || this.effectKeys.find(eKey => eKey === "Is-Push")); + || this.effectKeys.find((eKey) => eKey === "Is-Push")); } get isBasicPush(): boolean { return U.lCase(this.name) === "push"; } get stressCost(): number { - const costKeys = this.effectKeys.filter(key => key.startsWith("Cost-Stress")); + const costKeys = this.effectKeys.filter((key) => key.startsWith("Cost-Stress")); if (costKeys.length === 0) { return 0; } let stressCost = 0; - costKeys.forEach(key => { + costKeys.forEach((key) => { const [thisParam] = (key.split(/-/) ?? []).slice(1); const [_, valStr] = (/([A-Za-z]+)(\d*)/.exec(thisParam) ?? []).slice(1); stressCost += U.pInt(valStr); @@ -347,7 +347,7 @@ class BladesRollMod { setAutoStatus(): boolean { // Check for AutoRevealOn and AutoEnableOn - const holdKeys = this.effectKeys.filter(key => key.startsWith("Auto")); + const holdKeys = this.effectKeys.filter((key) => key.startsWith("Auto")); if (holdKeys.length === 0) { return false; } for (const key of holdKeys) { @@ -361,11 +361,11 @@ class BladesRollMod { } setRelevancyStatus(): boolean { - const holdKeys = this.effectKeys.filter(key => /^Negate|^Increase/.test(key)); + const holdKeys = this.effectKeys.filter((key) => /^Negate|^Increase/.test(key)); if (holdKeys.length === 0) { return false; } const relevantKeys = holdKeys - .filter(key => { + .filter((key) => { const [thisKey, thisParam] = key.split(/-/) ?? []; const negateOperations: Record boolean> = { @@ -407,11 +407,11 @@ class BladesRollMod { } setPayableStatus(): boolean { - const holdKeys = this.effectKeys.filter(key => key.startsWith("Cost")); + const holdKeys = this.effectKeys.filter((key) => key.startsWith("Cost")); if (holdKeys.length === 0) { return false; } const payableKeys = holdKeys - .filter(key => { + .filter((key) => { const [thisParam] = (key.split(/-/) ?? []).slice(1); const [traitStr, valStr] = (/([A-Za-z]+)(\d*)/.exec(thisParam) ?? []).slice(1); const {rollPrimaryDoc} = this.rollInstance.rollPrimary ?? {}; @@ -441,10 +441,10 @@ class BladesRollMod { applyRollModEffectKeys() { if (!this.isActive) { return; } - const holdKeys = this.effectKeys.filter(key => /^Negate|^Increase/.test(key)); + const holdKeys = this.effectKeys.filter((key) => /^Negate|^Increase/.test(key)); if (holdKeys.length === 0) { return; } - holdKeys.forEach(key => { + holdKeys.forEach((key) => { // Console.log({key, split: key.split(/-/)}) const [thisKey, thisParam] = key.split(/-/) ?? []; @@ -452,9 +452,9 @@ class BladesRollMod { const negateOperations = { PushCost: () => { const costlyPushMod = this.rollInstance.getActiveRollMods() - .find(mod => mod.isPush && mod.stressCost > 0); + .find((mod) => mod.isPush && mod.stressCost > 0); if (costlyPushMod) { - U.pullElement(costlyPushMod.effectKeys, k => k.startsWith("Cost-Stress")); + U.pullElement(costlyPushMod.effectKeys, (k) => k.startsWith("Cost-Stress")); } }, // PushCost0: negateOperations.PushCost, @@ -562,10 +562,10 @@ class BladesRollMod { get costs(): BladesRoll.CostData[] | undefined { if (!this.isActive) { return undefined; } - const holdKeys = this.effectKeys.filter(key => key.startsWith("Cost")); + const holdKeys = this.effectKeys.filter((key) => key.startsWith("Cost")); if (holdKeys.length === 0) { return undefined; } - return holdKeys.map(key => { + return holdKeys.map((key) => { const [thisParam] = (key.split(/-/) ?? []).slice(1); const [traitStr, valStr] = (/([A-Za-z]+)(\d*)/.exec(thisParam) ?? []).slice(1); @@ -1347,15 +1347,15 @@ class BladesRoll extends DocumentSheet { // === ONE === GET USER IDS // Get user ID of GM - const GMUserID = game.users.find(user => user.isGM)?.id; + const GMUserID = game.users.find((user) => user.isGM)?.id; if (!GMUserID) { throw new Error("[BladesRoll.GetUserPermissions()] No GM found!"); } // Get user IDs of players const playerUserIDs = game.users - .filter(user => BladesPC.IsType(user.character) && !user.isGM && typeof user.id === "string") - .map(user => user.id as string); + .filter((user) => BladesPC.IsType(user.character) && !user.isGM && typeof user.id === "string") + .map((user) => user.id as string); // Prepare user ID permissions object const userIDs: Record = { @@ -1403,7 +1403,7 @@ class BladesRoll extends DocumentSheet { // Finally, add remaining players as observers. userIDs[RollPermissions.Observer] = playerUserIDs - .filter(uID => !userIDs[RollPermissions.Participant].includes(uID)); + .filter((uID) => !userIDs[RollPermissions.Participant].includes(uID)); return userIDs; @@ -1413,7 +1413,7 @@ class BladesRoll extends DocumentSheet { */ function getParticipantDocs(participantData: BladesRoll.RollParticipantData) { return Object.values(flattenObject(participantData)) - .map(pData => { + .map((pData) => { if (BladesRollParticipant.IsDoc(pData)) { return pData; } @@ -1441,7 +1441,7 @@ class BladesRoll extends DocumentSheet { unassignedIDs: string[] ): string[] { return getParticipantDocs(participantData) - .map(pDoc => { + .map((pDoc) => { if ( BladesPC.IsType(pDoc) && typeof pDoc.primaryUser?.id === "string" ) { @@ -1455,7 +1455,7 @@ class BladesRoll extends DocumentSheet { return null as never; }) .flat() - .filter(pUser => pUser !== null && !userIDs[RollPermissions.Primary].includes(pUser)); + .filter((pUser) => pUser !== null && !userIDs[RollPermissions.Primary].includes(pUser)); } } @@ -1574,7 +1574,7 @@ class BladesRoll extends DocumentSheet { if (BladesPC.IsType(rollPrimaryDoc)) { const minAttrVal = Math.min(...Object.values(rollPrimaryDoc.attributes)); config.rollTrait = U.sample( - Object.values(AttributeTrait).filter(attr => rollPrimaryDoc.attributes[attr] === minAttrVal) + Object.values(AttributeTrait).filter((attr) => rollPrimaryDoc.attributes[attr] === minAttrVal) )[0]; } if (!(U.isInt(config.rollTrait) || U.lCase(config.rollTrait) in AttributeTrait)) { @@ -1888,14 +1888,14 @@ class BladesRoll extends DocumentSheet { RollModSection.roll, RollModSection.position, RollModSection.effect - ] as Array>).forEach(rollSection => { + ] as Array>).forEach((rollSection) => { const sectionFlagData = participantFlagData[rollSection]; if (sectionFlagData) { const sectionParticipants: Partial> = {}; - (Object.keys(sectionFlagData)).forEach(participantType => { + (Object.keys(sectionFlagData)).forEach((participantType) => { const subSectionFlagData = sectionFlagData[participantType as KeyOf]; if (subSectionFlagData) { sectionParticipants[participantType as BladesRoll.RollParticipantSubSection] = @@ -1970,14 +1970,14 @@ class BladesRoll extends DocumentSheet { if (BladesActor.IsType(this.rollPrimaryDoc, BladesActorType.pc)) { if (isAction(this.rollTrait)) { return Object.values(ActionTrait) - .map(action => ({ + .map((action) => ({ name: U.uCase(action), value: action })); } if (isAttribute(this.rollTrait)) { return Object.values(AttributeTrait) - .map(attribute => ({ + .map((attribute) => ({ name: U.uCase(attribute), value: attribute })); @@ -1985,7 +1985,7 @@ class BladesRoll extends DocumentSheet { } if (U.isInt(this.rollTrait)) { return [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] - .map(num => ({ + .map((num) => ({ name: `+${num}`, value: num })); @@ -2252,25 +2252,25 @@ class BladesRoll extends DocumentSheet { this.rollFactorPenaltiesNegated = {}; this.tempGMBoosts = {}; - this.rollMods = modsData.map(modData => new BladesRollMod(modData, this)); + this.rollMods = modsData.map((modData) => new BladesRollMod(modData, this)); const initReport: Record = {}; /* *** PASS ZERO: ROLLTYPE VALIDATION PASS *** */ - this.rollMods = this.rollMods.filter(rollMod => rollMod.isValidForRollType()); + this.rollMods = this.rollMods.filter((rollMod) => rollMod.isValidForRollType()); /* *** PASS ONE: DISABLE PASS *** */ this.rollMods // ... Conditional Status Pass - .filter(rollMod => !rollMod.setConditionalStatus()) + .filter((rollMod) => !rollMod.setConditionalStatus()) // ... AutoReveal/AutoEnable Pass - .filter(rollMod => !rollMod.setAutoStatus()) + .filter((rollMod) => !rollMod.setAutoStatus()) // ... Payable Pass - .forEach(rollMod => { rollMod.setPayableStatus(); }); + .forEach((rollMod) => { rollMod.setPayableStatus(); }); /* *** PASS TWO: FORCE-ON PASS *** */ const parseForceOnKeys = (mod: BladesRollMod) => { - const holdKeys = mod.effectKeys.filter(key => key.startsWith("ForceOn")); + const holdKeys = mod.effectKeys.filter((key) => key.startsWith("ForceOn")); if (holdKeys.length === 0) { return; } while (holdKeys.length) { @@ -2286,9 +2286,9 @@ class BladesRoll extends DocumentSheet { ?? this.getRollModByName(targetName, targetCat ?? mod.section); if (!targetMod && targetName === "Push") { [targetMod] = [ - ...this.getActiveBasicPushMods(targetCat ?? mod.section, "negative").filter(m => m.status === RollModStatus.ToggledOn), - ...this.getActiveBasicPushMods(targetCat ?? mod.section, "positive").filter(m => m.status === RollModStatus.ToggledOn), - ...this.getInactiveBasicPushMods(targetCat ?? mod.section, "positive").filter(m => m.status === RollModStatus.ToggledOff) + ...this.getActiveBasicPushMods(targetCat ?? mod.section, "negative").filter((m) => m.status === RollModStatus.ToggledOn), + ...this.getActiveBasicPushMods(targetCat ?? mod.section, "positive").filter((m) => m.status === RollModStatus.ToggledOn), + ...this.getInactiveBasicPushMods(targetCat ?? mod.section, "positive").filter((m) => m.status === RollModStatus.ToggledOff) ]; } targetMod ??= this.getRollModByName(targetName, targetCat ?? mod.section, targetPosNeg ?? mod.posNeg); @@ -2302,7 +2302,7 @@ class BladesRoll extends DocumentSheet { } } }; - this.getActiveRollMods().forEach(rollMod => parseForceOnKeys(rollMod)); + this.getActiveRollMods().forEach((rollMod) => parseForceOnKeys(rollMod)); /* *** PASS THREE: PUSH-CHECK PASS *** */ @@ -2310,12 +2310,12 @@ class BladesRoll extends DocumentSheet { if (this.isForcePushed()) { // ... Force Off _ALL_ visible, inactive "Is-Push" mods. this.getInactivePushMods() - .filter(mod => !mod.isBasicPush) - .forEach(mod => { mod.heldStatus = RollModStatus.ForcedOff; }); + .filter((mod) => !mod.isBasicPush) + .forEach((mod) => { mod.heldStatus = RollModStatus.ForcedOff; }); } // ... BY CATEGORY ... - [RollModSection.roll, RollModSection.effect].forEach(cat => { + [RollModSection.roll, RollModSection.effect].forEach((cat) => { if (this.isPushed(cat)) { // ... if pushed by positive mod, Force Off any visible Bargain if (cat === RollModSection.roll && this.isPushed(cat, "positive")) { @@ -2327,24 +2327,24 @@ class BladesRoll extends DocumentSheet { } else { // Otherwise, hide all Is-Push mods this.getInactivePushMods(cat) - .filter(mod => !mod.isBasicPush) - .forEach(mod => { mod.heldStatus = RollModStatus.Hidden;}); + .filter((mod) => !mod.isBasicPush) + .forEach((mod) => { mod.heldStatus = RollModStatus.Hidden;}); } }); /* *** PASS FOUR: Relevancy Pass *** */ this.getVisibleRollMods() - .forEach(mod => { mod.setRelevancyStatus(); }); + .forEach((mod) => { mod.setRelevancyStatus(); }); /* *** PASS FIVE: Overpayment Pass *** */ // ... If 'Cost-SpecialArmor' active, ForceOff other visible Cost-SpecialArmor mods - const activeArmorCostMod = this.getActiveRollMods().find(mod => mod.effectKeys.includes("Cost-SpecialArmor")); + const activeArmorCostMod = this.getActiveRollMods().find((mod) => mod.effectKeys.includes("Cost-SpecialArmor")); if (activeArmorCostMod) { this.getVisibleRollMods() - .filter(mod => !mod.isActive && mod.effectKeys.includes("Cost-SpecialArmor")) - .forEach(mod => { mod.heldStatus = RollModStatus.ForcedOff; }); + .filter((mod) => !mod.isActive && mod.effectKeys.includes("Cost-SpecialArmor")) + .forEach((mod) => { mod.heldStatus = RollModStatus.ForcedOff; }); } eLog.checkLog2("rollMods", "*** initRollMods() PASS ***", initReport); @@ -2384,7 +2384,7 @@ class BladesRoll extends DocumentSheet { const rollPush = this.getRollModByID("Push-positive-roll"); const effectPush = this.getRollModByID("Push-positive-effect"); const negatePushCostMods = this.getActiveRollMods(RollModSection.after, "positive") - .filter(mod => mod.effectKeys.includes("Negate-PushCost")); + .filter((mod) => mod.effectKeys.includes("Negate-PushCost")); return ((harmPush?.isActive && harmPush?.stressCost) || 0) + ((rollPush?.isActive && rollPush?.stressCost) || 0) + ((effectPush?.isActive && effectPush?.stressCost) || 0) @@ -2393,12 +2393,12 @@ class BladesRoll extends DocumentSheet { get rollCostData(): BladesRoll.CostData[] { return this.getActiveRollMods() - .map(rollMod => rollMod.costs ?? []) + .map((rollMod) => rollMod.costs ?? []) .flat(); } getRollModByName(name: string, cat?: RollModSection, posNeg?: "positive" | "negative"): BladesRollMod | undefined { - const modMatches = this.rollMods.filter(rollMod => { + const modMatches = this.rollMods.filter((rollMod) => { if (U.lCase(rollMod.name) !== U.lCase(name)) { return false; } @@ -2417,67 +2417,67 @@ class BladesRoll extends DocumentSheet { return modMatches[0]; } - getRollModByID(id: string) { return this.rollMods.find(rollMod => rollMod.id === id); } + getRollModByID(id: string) { return this.rollMods.find((rollMod) => rollMod.id === id); } getRollMods(cat?: RollModSection, posNeg?: "positive" | "negative") { - return this.rollMods.filter(rollMod => + return this.rollMods.filter((rollMod) => (!cat || rollMod.section === cat) && (!posNeg || rollMod.posNeg === posNeg)); } getVisibleRollMods(cat?: RollModSection, posNeg?: "positive" | "negative") { - return this.getRollMods(cat, posNeg).filter(rollMod => rollMod.isVisible); + return this.getRollMods(cat, posNeg).filter((rollMod) => rollMod.isVisible); } getActiveRollMods(cat?: RollModSection, posNeg?: "positive" | "negative") { - return this.getRollMods(cat, posNeg).filter(rollMod => rollMod.isActive); + return this.getRollMods(cat, posNeg).filter((rollMod) => rollMod.isActive); } getVisibleInactiveRollMods(cat?: RollModSection, posNeg?: "positive" | "negative") { - return this.getVisibleRollMods(cat, posNeg).filter(rollMod => !rollMod.isActive); + return this.getVisibleRollMods(cat, posNeg).filter((rollMod) => !rollMod.isActive); } getPushMods(cat?: RollModSection, posNeg?: "positive" | "negative") { - return this.getRollMods(cat, posNeg).filter(rollMod => rollMod.isPush); + return this.getRollMods(cat, posNeg).filter((rollMod) => rollMod.isPush); } getVisiblePushMods(cat?: RollModSection, posNeg?: "positive" | "negative") { - return this.getPushMods(cat, posNeg).filter(rollMod => rollMod.isVisible); + return this.getPushMods(cat, posNeg).filter((rollMod) => rollMod.isVisible); } getActivePushMods(cat?: RollModSection, posNeg?: "positive" | "negative") { - return this.getVisiblePushMods(cat, posNeg).filter(rollMod => rollMod.isActive); + return this.getVisiblePushMods(cat, posNeg).filter((rollMod) => rollMod.isActive); } getActiveBasicPushMods(cat?: RollModSection, posNeg?: "positive" | "negative") { - return this.getActivePushMods(cat, posNeg).filter(rollMod => rollMod.isBasicPush); + return this.getActivePushMods(cat, posNeg).filter((rollMod) => rollMod.isBasicPush); } getInactivePushMods(cat?: RollModSection, posNeg?: "positive" | "negative") { - return this.getVisiblePushMods(cat, posNeg).filter(rollMod => !rollMod.isActive); + return this.getVisiblePushMods(cat, posNeg).filter((rollMod) => !rollMod.isActive); } getInactiveBasicPushMods(cat?: RollModSection, posNeg?: "positive" | "negative") { - return this.getInactivePushMods(cat, posNeg).filter(rollMod => rollMod.isBasicPush); + return this.getInactivePushMods(cat, posNeg).filter((rollMod) => rollMod.isBasicPush); } getForcedPushMods(cat?: RollModSection, posNeg?: "positive" | "negative") { return this.getActivePushMods(cat, posNeg) - .filter(rollMod => rollMod.isBasicPush + .filter((rollMod) => rollMod.isBasicPush && rollMod.status === RollModStatus.ForcedOn); } getOpenPushMods(cat?: RollModSection, posNeg?: "positive" | "negative") { return this.getActivePushMods(cat, posNeg) - .filter(rollMod => rollMod.isBasicPush + .filter((rollMod) => rollMod.isBasicPush && rollMod.status === RollModStatus.ToggledOn); } getModsDelta = (cat: RollModSection) => { return U.sum([ - ...this.getActiveRollMods(cat, "positive").map(mod => mod.value), - ...this.getActiveRollMods(cat, "negative").map(mod => -mod.value) + ...this.getActiveRollMods(cat, "positive").map((mod) => mod.value), + ...this.getActiveRollMods(cat, "negative").map((mod) => -mod.value) ]); }; @@ -2532,7 +2532,7 @@ class BladesRoll extends DocumentSheet { if (this.rollResult === RollResult.critical || this.rollResult === RollResult.success) { return []; } return C.Consequences[this.finalPosition][this.rollResult] - .map(cType => ({value: cType, display: cType})); + .map((cType) => ({value: cType, display: cType})); } private _consequenceAI?: BladesAI; @@ -2546,7 +2546,7 @@ class BladesRoll extends DocumentSheet { this._consequenceAI = new BladesAI(AGENTS.ConsequenceAdjuster); } - await Promise.all(Object.values(consequenceData).map(cData => { + await Promise.all(Object.values(consequenceData).map((cData) => { // For each consequence, if there are no resistOptions ... if (!cData.resistOptions) { // Check for a pending AI prompt: create a new one if not found. @@ -2572,7 +2572,7 @@ class BladesRoll extends DocumentSheet { const context = super.getData(); this.initRollMods(this.getRollModsData()); - this.rollMods.forEach(rollMod => rollMod.applyRollModEffectKeys()); + this.rollMods.forEach((rollMod) => rollMod.applyRollModEffectKeys()); const sheetData = this.getSheetData( this.getIsGM(), @@ -2618,7 +2618,7 @@ class BladesRoll extends DocumentSheet { */ private getRollCosts(): BladesRoll.CostData[] { return this.getActiveRollMods() - .map(rollMod => rollMod.costs) + .map((rollMod) => rollMod.costs) .flat() .filter((costData): costData is BladesRoll.CostData => costData !== undefined); } @@ -2629,7 +2629,7 @@ class BladesRoll extends DocumentSheet { * @returns {BladesRoll.CostData[]} The stress costs. */ private getStressCosts(rollCosts: BladesRoll.CostData[]): BladesRoll.CostData[] { - return rollCosts.filter(costData => costData.costType === "Stress"); + return rollCosts.filter((costData) => costData.costType === "Stress"); } /** @@ -2638,7 +2638,7 @@ class BladesRoll extends DocumentSheet { * @returns {number} The total stress cost. */ private getTotalStressCost(stressCosts: BladesRoll.CostData[]): number { - return U.sum(stressCosts.map(costData => costData.costAmount)); + return U.sum(stressCosts.map((costData) => costData.costAmount)); } @@ -2648,7 +2648,7 @@ class BladesRoll extends DocumentSheet { * @returns {BladesRoll.CostData[]} The stress costs. */ private getSpecArmorCost(rollCosts: BladesRoll.CostData[]): BladesRoll.CostData|undefined { - return rollCosts.find(costData => costData.costType === "SpecialArmor"); + return rollCosts.find((costData) => costData.costType === "SpecialArmor"); } /** @@ -2695,16 +2695,16 @@ class BladesRoll extends DocumentSheet { rollParticipants: this.rollParticipants, rollEffects: Object.values(Effect), teamworkDocs: game.actors - .filter(actor => actor.hasTag(Tag.PC.ActivePC)) - .map(actor => ({value: actor.id, display: actor.name})), + .filter((actor) => actor.hasTag(Tag.PC.ActivePC)) + .map((actor) => ({value: actor.id, display: actor.name})), rollTraitValOverride: this.rollTraitValOverride, rollFactorPenaltiesNegated: this.rollFactorPenaltiesNegated, posRollMods: Object.fromEntries(Object.values(RollModSection) - .map(cat => [cat, this.getRollMods(cat, "positive")])) as Record, + .map((cat) => [cat, this.getRollMods(cat, "positive")])) as Record, negRollMods: Object.fromEntries(Object.values(RollModSection) - .map(cat => [cat, this.getRollMods(cat, "negative")])) as Record, + .map((cat) => [cat, this.getRollMods(cat, "negative")])) as Record, hasInactiveConditionals: this.calculateHasInactiveConditionalsData(), rollFactors, @@ -2926,7 +2926,7 @@ class BladesRoll extends DocumentSheet { private calculateHasInactiveConditionalsData(): Record { const hasInactive = {} as Record; for (const section of Object.values(RollModSection)) { - hasInactive[section] = this.getRollMods(section).filter(mod => mod.isInInactiveBlock).length > 0; + hasInactive[section] = this.getRollMods(section).filter((mod) => mod.isInInactiveBlock).length > 0; } return hasInactive; } @@ -2975,13 +2975,13 @@ class BladesRoll extends DocumentSheet { specArmorCost && totalStressCost ? "and" : null, specArmorCost ? "your Special Armor" : null, ")" - ].filter(line => Boolean(line)).join(" "), + ].filter((line) => Boolean(line)).join(" "), tooltip: [ "

Roll Costs

    ", - ...stressCosts.map(costData => `
  • ${costData.label}: ${costData.costAmount} Stress
  • `), + ...stressCosts.map((costData) => `
  • ${costData.label}: ${costData.costAmount} Stress
  • `), specArmorCost ? `
  • ${specArmorCost.label}: Special Armor
  • ` : null, "
" - ].filter(line => Boolean(line)).join("") + ].filter((line) => Boolean(line)).join("") }; } return undefined; @@ -3003,10 +3003,10 @@ class BladesRoll extends DocumentSheet { footerLabel: footerLabelStrings.join(" "), tooltip: [ "

Roll Costs

    ", - ...stressCosts.map(costData => `
  • ${costData.label}: ${costData.costAmount} Stress
  • `), + ...stressCosts.map((costData) => `
  • ${costData.label}: ${costData.costAmount} Stress
  • `), specArmorCost ? `
  • ${specArmorCost.label}: Special Armor
  • ` : null, "
" - ].filter(line => Boolean(line)).join("") + ].filter((line) => Boolean(line)).join("") }; } @@ -3026,7 +3026,7 @@ class BladesRoll extends DocumentSheet { get dieVals(): number[] { this._dieVals ??= (this.roll.terms as DiceTerm[])[0].results - .map(result => result.result) + .map((result) => result.result) .sort() .reverse(); return this._dieVals; @@ -3085,13 +3085,13 @@ class BladesRoll extends DocumentSheet { : this.dieVals; // Is this a critical success? - if (dieVals.filter(val => val === 6).length >= 2) { return RollResult.critical; } + if (dieVals.filter((val) => val === 6).length >= 2) { return RollResult.critical; } // A full success? - if (dieVals.find(val => val === 6)) { return RollResult.success; } + if (dieVals.find((val) => val === 6)) { return RollResult.success; } // A partial? - if (dieVals.find(val => val && val >= 4)) { return RollResult.partial; } + if (dieVals.find((val) => val && val >= 4)) { return RollResult.partial; } return RollResult.fail; @@ -3302,8 +3302,8 @@ class BladesRoll extends DocumentSheet { // If one is being activated, must toggle off the others. if (value === true) { Object.values(Factor) - .filter(factor => factor !== thisFactor) - .forEach(factor => { + .filter((factor) => factor !== thisFactor) + .forEach((factor) => { if (factorToggleData[thisSource][factor]?.[thisToggle] === true) { factorToggleData[thisSource][factor] = { ...factorToggleData[thisSource][factor], @@ -3365,7 +3365,7 @@ class BladesRoll extends DocumentSheet { }); html.find("[data-action='tradePosition']").on({ - click: event => { + click: (event) => { const curVal = `${$(event.currentTarget).data("value")}`; if (curVal === "false") { this.document.setFlag(C.SYSTEM_ID, "rollCollab.rollPosEffectTrade", "effect").then(() => socketlib.system.executeForEveryone("renderRollCollab", this.rollID)); @@ -3375,7 +3375,7 @@ class BladesRoll extends DocumentSheet { } }); html.find("[data-action='tradeEffect']").on({ - click: event => { + click: (event) => { const curVal = `${$(event.currentTarget).data("value")}`; if (curVal === "false") { this.document.setFlag(C.SYSTEM_ID, "rollCollab.rollPosEffectTrade", "position").then(() => socketlib.system.executeForEveryone("renderRollCollab", this.rollID)); @@ -3399,7 +3399,7 @@ class BladesRoll extends DocumentSheet { * Handles setting of rollMod status via GM pop-out controls */ html.find(".controls-toggle").on({ - click: event => { + click: (event) => { event.preventDefault(); $(event.currentTarget).parents(".controls-panel").toggleClass("active"); } diff --git a/ts/blades.ts b/ts/blades.ts index 2740c0e9..c4fd2d75 100644 --- a/ts/blades.ts +++ b/ts/blades.ts @@ -56,7 +56,7 @@ class GlobalGetter { if (!pc) { return; } const conf = { rollType: RollType.Resistance, - rollUserID: game.users.find(user => user.character?.name === "Alistair")?.id as string, + rollUserID: game.users.find((user) => user.character?.name === "Alistair")?.id as string, rollPrimaryData: { rollPrimaryID: pc.id, rollPrimaryDoc: pc, @@ -226,9 +226,9 @@ Hooks.once("diceSoNiceReady", (dice3d: Dice3DController) => { dice3d.addSystem({id: "eunos-blades", name: "Euno's Blades"}, "preferred"); dice3d.addDicePreset({ type: "d6", - labels: [1, 2, 3, 4, 5, 6].map(num => `systems/eunos-blades/assets/dice/faces/${num}.webp`), + labels: [1, 2, 3, 4, 5, 6].map((num) => `systems/eunos-blades/assets/dice/faces/${num}.webp`), system: "eunos-blades", - bumpMaps: [1, 2, 3, 4, 5, 6].map(num => `systems/eunos-blades/assets/dice/bump-maps/${num}.webp`), + bumpMaps: [1, 2, 3, 4, 5, 6].map((num) => `systems/eunos-blades/assets/dice/bump-maps/${num}.webp`), emissiveMaps: [undefined, undefined, undefined, undefined, undefined, "systems/eunos-blades/assets/dice/emission-maps/6.webp"], emissive: "#d89300" }); diff --git a/ts/core/gsap.ts b/ts/core/gsap.ts index cfb323ae..f8351057 100644 --- a/ts/core/gsap.ts +++ b/ts/core/gsap.ts @@ -62,7 +62,7 @@ const gsapEffects: Record = { } }, slideUp: { - effect: targets => U.gsap.to( + effect: (targets) => U.gsap.to( targets, { height: 0, @@ -216,7 +216,7 @@ export function ApplyTooltipListeners(html: JQuery) { $(el).data("hoverTimeline", U.gsap.effects.hoverTooltip( tooltipElem, { - scalingElems: [...$(el).find(".tooltip-scaling-elem")].filter(elem => Boolean(elem)), + scalingElems: [...$(el).find(".tooltip-scaling-elem")].filter((elem) => Boolean(elem)), xMotion: $(tooltipElem).hasClass("tooltip-left") ? "-=250" : "+=200", tooltipScale: $(tooltipElem).hasClass("tooltip-small") ? 1 : 1.2 } diff --git a/ts/core/tags.ts b/ts/core/tags.ts index da023e7b..388ad1cc 100644 --- a/ts/core/tags.ts +++ b/ts/core/tags.ts @@ -119,7 +119,7 @@ const Tags = { // Add event listener for tag changes, setting defined target // Wait briefly, so other tag elements' tags can be set before listener initializes - setTimeout(() => elem.addEventListener("change", event => { _onTagifyChange(event, doc, targetKey); }), 1000); + setTimeout(() => elem.addEventListener("change", (event) => { _onTagifyChange(event, doc, targetKey); }), 1000); } const systemTags = { @@ -144,7 +144,7 @@ const Tags = { const factionTags = {Factions: game.actors .filter((actor): actor is BladesActorOfType & {name: string} => actor.type === BladesActorType.faction && actor.name !== null) - .map(faction => faction.name)}; + .map((faction) => faction.name)}; $(html).find(".tags-gm").each((_, e) => makeTagInput(e, systemTags)); diff --git a/ts/core/utilities.ts b/ts/core/utilities.ts index 4005f070..b3338e36 100644 --- a/ts/core/utilities.ts +++ b/ts/core/utilities.ts @@ -9,12 +9,12 @@ import {gsap} from "gsap/all"; // _noCapWords -- Patterns matching words that should NOT be capitalized when converting to TITLE case. const _noCapWords = "a|above|after|an|and|at|below|but|by|down|for|for|from|in|nor|of|off|on|onto|or|out|so|the|to|under|up|with|yet" .split("|") - .map(word => new RegExp(`\\b${word}\\b`, "gui")); + .map((word) => new RegExp(`\\b${word}\\b`, "gui")); // _capWords -- Patterns matching words that should ALWAYS be capitalized when converting to SENTENCE case. const _capWords = [ "I", /[^a-z]{3,}|[.0-9]/gu -].map(word => (/RegExp/.test(Object.prototype.toString.call(word)) ? word : new RegExp(`\\b${word}\\b`, "gui"))) as RegExp[]; +].map((word) => (/RegExp/.test(Object.prototype.toString.call(word)) ? word : new RegExp(`\\b${word}\\b`, "gui"))) as RegExp[]; // _loremIpsumText -- Boilerplate lorem ipsum const _loremIpsumText = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse ultricies @@ -141,7 +141,7 @@ const UUIDLOG: Array<[string, string, number]> = []; // #region ████████ GETTERS: Basic Data Lookup & Retrieval ████████ ~ // @ts-expect-error Leauge of foundry developers is wrong about user not being on game. -const GMID = (): string | false => game?.user?.find(user => user.isGM)?.id ?? false; +const GMID = (): string | false => game?.user?.find((user) => user.isGM)?.id ?? false; // #endregion ▄▄▄▄▄ GETTERS ▄▄▄▄▄ // #region ████████ TYPES: Type Checking, Validation, Conversion, Casting ████████ ~ @@ -320,7 +320,7 @@ const sCase = (str: T): Capitalize => { let [first, ...rest] = `${str ?? ""}`.split(/\s+/); first = testRegExp(first, _capWords) ? first : `${uCase(first.charAt(0))}${lCase(first.slice(1))}`; if (hasItems(rest)) { - rest = rest.map(word => (testRegExp(word, _capWords) ? word : lCase(word))); + rest = rest.map((word) => (testRegExp(word, _capWords) ? word : lCase(word))); } return [first, ...rest].join(" ").trim() as Capitalize; }; @@ -330,15 +330,15 @@ const tCase = (str: T): tCase => String(str).split(/\s/) // #endregion ░░░░[Case Conversion]░░░░ // #region ░░░░░░░[RegExp]░░░░ Regular Expressions ░░░░░░░ ~ const testRegExp = (str: unknown, patterns: Array = [], flags = "gui", isTestingAll = false) => patterns - .map(pattern => (pattern instanceof RegExp + .map((pattern) => (pattern instanceof RegExp ? pattern - : new RegExp(`\\b${pattern}\\b`, flags)))[isTestingAll ? "every" : "some"](pattern => pattern.test(`${str}`)); + : new RegExp(`\\b${pattern}\\b`, flags)))[isTestingAll ? "every" : "some"]((pattern) => pattern.test(`${str}`)); const regExtract = (ref: unknown, pattern: string | RegExp, flags?: string) => { /* Wrapper around String.match() that removes the need to worry about match()'s different handling of the 'g' flag. - IF your pattern contains unescaped parentheses -> Returns Array of all matching groups. - OTHERWISE -> Returns string that matches the provided pattern. */ const splitFlags: string[] = []; - [...(flags ?? "").replace(/g/g, ""), "u"].forEach(flag => { + [...(flags ?? "").replace(/g/g, ""), "u"].forEach((flag) => { if (flag && !splitFlags.includes(flag)) { splitFlags.push(flag); } @@ -465,7 +465,7 @@ const verbalizeNum = (num: number | string) => { }; const parseThreeDigits = (trio: string) => { if (pInt(trio) === 0) {return "";} - const digits = `${trio}`.split("").map(digit => pInt(digit)); + const digits = `${trio}`.split("").map((digit) => pInt(digit)); let result = ""; if (digits.length === 3) { const hundreds = digits.shift(); @@ -493,7 +493,7 @@ const verbalizeNum = (num: number | string) => { const [integers, decimals] = num.replace(/[,\s-]/g, "").split("."); const intArray = [...integers.split("")].reverse().join("") .match(/.{1,3}/g) - ?.map(v => [...v.split("")].reverse().join("")) ?? []; + ?.map((v) => [...v.split("")].reverse().join("")) ?? []; const intStrings = []; while (intArray.length) { const thisTrio = intArray.pop(); @@ -560,7 +560,7 @@ const loremIpsum = (numWords = 200) => { return `${sCase(words.join(" ")).trim().replace(/[^a-z\s]*$/ui, "")}.`; }; const randString = (length = 5) => Array.from({length}) - .map(() => String.fromCharCode(randInt(...["a", "z"].map(char => char.charCodeAt(0)) as [number, number]))) + .map(() => String.fromCharCode(randInt(...["a", "z"].map((char) => char.charCodeAt(0)) as [number, number]))) .join(""); const randWord = (numWords = 1, wordList = _randomWords) => Array.from({length: numWords}).map(() => randElem([...wordList])).join(" "); const getUID = (id: string): string => { @@ -579,7 +579,7 @@ const getUID = (id: string): string => { // #region ████████ SEARCHING: Searching Various Data Types w/ Fuzzy Matching ████████ ~ const fuzzyMatch = (val1: unknown, val2: unknown): boolean => { - const [str1, str2] = [val1, val2].map(val => lCase(String(val).replace(/[^a-zA-Z0-9.+-]/g, "").trim())); + const [str1, str2] = [val1, val2].map((val) => lCase(String(val).replace(/[^a-zA-Z0-9.+-]/g, "").trim())); return str1.length > 0 && str1 === str2; }; const isIn = (needle: unknown, haystack: unknown[] = [], fuzziness = 0) => { @@ -600,7 +600,7 @@ const isIn = (needle: unknown, haystack: unknown[] = [], fuzziness = 0) => { SearchTests.push(...fuzzyTests); if (fuzziness >= 2) { SearchTests.push(...fuzzyTests - .map(func => (ndl: unknown, item: unknown) => func(`${ndl}`.replace(/\W/g, ""), `${item}`.replace(/\W/gu, "")))); + .map((func) => (ndl: unknown, item: unknown) => func(`${ndl}`.replace(/\W/g, ""), `${item}`.replace(/\W/gu, "")))); if (fuzziness >= 3) { SearchTests.push(() => false); // Have to implement Fuse matching } @@ -631,7 +631,7 @@ const isIn = (needle: unknown, haystack: unknown[] = [], fuzziness = 0) => { if (!testFunc) { return false; } - matchIndex = searchStack.findIndex(item => testFunc(searchNeedle, `${item}`)); + matchIndex = searchStack.findIndex((item) => testFunc(searchNeedle, `${item}`)); } if (isPosInt(matchIndex)) { return isList(haystack) ? Object.values(haystack)[matchIndex] : haystack[matchIndex]; @@ -706,7 +706,7 @@ function getLast(array: Index): Type | undefined { // Const getLast = (array: Type[]): typeof array extends [] ? undefined : Type => ; const unique = (array: Type[]): Type[] => { const returnArray: Type[] = []; - array.forEach(item => {if (!returnArray.includes(item)) {returnArray.push(item);} }); + array.forEach((item) => {if (!returnArray.includes(item)) {returnArray.push(item);} }); return returnArray; }; const group = >( @@ -714,7 +714,7 @@ const group = >( key: KeyOf ): Partial, Type[]>> => { const returnObj: Partial, Type[]>> = {}; - array.forEach(item => { + array.forEach((item) => { const returnKey = item[key] as string & ValOf; let returnVal = returnObj[returnKey]; if (!returnVal) { @@ -742,7 +742,7 @@ const sample = ( } return elems; }; -const removeFirst = (array: unknown[], element: unknown) => array.splice(array.findIndex(v => v === element)); +const removeFirst = (array: unknown[], element: unknown) => array.splice(array.findIndex((v) => v === element)); /** @@ -828,7 +828,7 @@ const checkVal = ({k, v}: {k?: unknown, v?: unknown}, checkTest: checkTest) => { */ const remove = (obj: Index, checkTest: testFunc | number | string) => { if (isArray(obj)) { - const index = obj.findIndex(v => checkVal({v}, checkTest)); + const index = obj.findIndex((v) => checkVal({v}, checkTest)); if (index >= 0) { return removeElementFromArray(obj, index); } @@ -875,10 +875,10 @@ const replace = (obj: Index, checkTest: checkTest, repVal: unknown) => // Returns true/false to indicate whether the replace action succeeded. let repKey; if (isList(obj)) { - [repKey] = Object.entries(obj).find(v => checkVal({v}, checkTest)) || [false]; + [repKey] = Object.entries(obj).find((v) => checkVal({v}, checkTest)) || [false]; if (repKey === false) {return false;} } else if (isArray(obj)) { - repKey = obj.findIndex(v => checkVal({v}, checkTest)); + repKey = obj.findIndex((v) => checkVal({v}, checkTest)); if (repKey === -1) {return false;} } if (typeof repKey !== "number") { @@ -902,11 +902,11 @@ const replace = (obj: Index, checkTest: checkTest, repVal: unknown) => * @returns {T | Partial | "KILL"} - The cleaned version of the input object or value. If marked for removal, returns "KILL". */ const objClean = (data: T, remVals: UncleanValues[] = [undefined, null, "", {}, []]): T | Partial | "KILL" => { - const remStrings = remVals.map(rVal => JSON.stringify(rVal)); + const remStrings = remVals.map((rVal) => JSON.stringify(rVal)); if (remStrings.includes(JSON.stringify(data)) || remVals.includes(data as ValOf)) {return "KILL";} if (Array.isArray(data)) { - const newData = data.map(elem => objClean(elem, remVals)) - .filter(elem => elem !== "KILL") as T; + const newData = data.map((elem) => objClean(elem, remVals)) + .filter((elem) => elem !== "KILL") as T; return Array.isArray(newData) && newData.length ? newData : "KILL"; } if (data && typeof data === "object" && JSON.stringify(data).startsWith("{")) { @@ -927,7 +927,7 @@ const objClean = (data: T, remVals: UncleanValues[] = [undefined, null, "", { export function toDict, V extends ValOf>(items: T[], key: K): V extends key ? Record : never { const dict = {} as Record; const mappedItems = items - .map(data => { + .map((data) => { let {iData} = data; if (!iData) {iData = data;} const prefix = iData.linkName || iData.sourceItem?.name ? `>${iData.type.charAt(0)}>` : ""; @@ -992,7 +992,7 @@ function objMap(obj: Index, keyFunc: mapFunc | mapFunc)(key, val), valFuncTyped(val, key)]; })); } -const objSize = (obj: Index) => Object.values(obj).filter(val => val !== undefined && val !== null).length; +const objSize = (obj: Index) => Object.values(obj).filter((val) => val !== undefined && val !== null).length; /** @@ -1151,8 +1151,8 @@ function objMerge(target: Tx, source: Ty, {isMutatingOk = false, isStric */ function objDiff, Ty extends Record>(obj1: Tx, obj2: Ty): Record { const diff: Record = {}; - const bothObj1AndObj2Keys = Object.keys(obj2).filter(key => Object.hasOwn(obj2, key) && Object.hasOwn(obj1, key)); - const onlyObj2Keys = Object.keys(obj2).filter(key => Object.hasOwn(obj2, key) && !Object.hasOwn(obj1, key)); + const bothObj1AndObj2Keys = Object.keys(obj2).filter((key) => Object.hasOwn(obj2, key) && Object.hasOwn(obj1, key)); + const onlyObj2Keys = Object.keys(obj2).filter((key) => Object.hasOwn(obj2, key) && !Object.hasOwn(obj1, key)); for (const key of bothObj1AndObj2Keys) { // If both values are non-array objects, recursively compare them @@ -1250,7 +1250,7 @@ function objNullify(obj: T): Record, null> | null[] | T { } // If the input is an object, nullify all its properties - Object.keys(obj).forEach(objKey => { + Object.keys(obj).forEach((objKey) => { (obj as Record, null>)[objKey as KeyOf] = null; }); @@ -1335,7 +1335,7 @@ const getGSAngleDelta = (startAngle: number, endAngle: number) => signNum(roundN // #region ░░░░░░░[SVG]░░░░ SVG Generation & Manipulation ░░░░░░░ ~ const getRawCirclePath = (r: number, {x: xO, y: yO}: Point = {x: 0, y: 0}): Array> => { - [r, xO, yO] = [r, xO, yO].map(val => roundNum(val, 2)); + [r, xO, yO] = [r, xO, yO].map((val) => roundNum(val, 2)); const [b1, b2] = [0.4475 * r, (1 - 0.4475) * r]; const [xT, yT] = [xO, yO - r]; return [[ @@ -1364,7 +1364,7 @@ const getColorVals = (red?: string | number | number[], green?: number, blue?: n [red, green, blue, alpha] = red .replace(/[^\d.,]/g, "") .split(/,/) - .map(color => (isUndefined(color) ? undefined : parseFloat(color))); + .map((color) => (isUndefined(color) ? undefined : parseFloat(color))); } if (isHexColor(red)) { if ([4, 5].includes(red.length)) { @@ -1372,11 +1372,11 @@ const getColorVals = (red?: string | number | number[], green?: number, blue?: n } [red, green, blue, alpha] = red .match(/[^#]{2}/g) - ?.map(val => parseInt(val, 16)) ?? []; + ?.map((val) => parseInt(val, 16)) ?? []; } - if ([red, green, blue].every(color => /^\d+$/.test(`${color}`))) { + if ([red, green, blue].every((color) => /^\d+$/.test(`${color}`))) { return [red, green, blue, alpha] - .filter(color => /^[\d.]+$/.test(`${color}`)) as number[]; + .filter((color) => /^[\d.]+$/.test(`${color}`)) as number[]; } return null; }; @@ -1384,7 +1384,7 @@ const getRGBString = (red: string | number, green?: number, blue?: number, alpha if (isRGBColor(red) || isHexColor(red)) { [red, green, blue, alpha] = getColorVals(red) ?? []; } - if ([red, green, blue].every(color => /^[.\d]+$/.test(`${color}`))) { + if ([red, green, blue].every((color) => /^[.\d]+$/.test(`${color}`))) { let colorString = "rgb"; const colors = [red, green, blue]; if (/^[.\d]+$/.test(`${alpha}`)) { @@ -1408,7 +1408,7 @@ const getHEXString = (red: string | number, green?: number, blue?: number): HEXC if (isRGBColor(red)) { [red, green, blue] = getColorVals(red) ?? []; } - if (isDefined(red) && isDefined(green) && isDefined(blue) && [red, green, blue].every(color => /^[.\d]+$/.test(`${color}`))) { + if (isDefined(red) && isDefined(green) && isDefined(blue) && [red, green, blue].every((color) => /^[.\d]+$/.test(`${color}`))) { return `#${componentToHex(red ?? 0)}${componentToHex(green ?? 0)}${componentToHex(blue ?? 0)}`; } return null; @@ -1430,7 +1430,7 @@ const getSiblings = (elem: Node) => { // If no parent, return no sibling if (!elem.parentNode) {return siblings;} - Array.from(elem.parentNode.children).forEach(sibling => { + Array.from(elem.parentNode.children).forEach((sibling) => { if (sibling !== elem) { siblings.push(sibling as HTMLElement); } @@ -1452,7 +1452,7 @@ const escapeHTML = (str: T): T => (typeof str === "string" // #endregion ▄▄▄▄▄ HTML ▄▄▄▄▄ // #region ████████ ASYNC: Async Functions, Asynchronous Flow Control ████████ ~ -const sleep = (duration: number): Promise => new Promise(resolve => {setTimeout(resolve, duration >= 100 ? duration : duration * 1000);}); +const sleep = (duration: number): Promise => new Promise((resolve) => {setTimeout(resolve, duration >= 100 ? duration : duration * 1000);}); // #endregion ▄▄▄▄▄ ASYNC ▄▄▄▄▄ // #region ████████ FOUNDRY: Requires Configuration of System ID in constants.ts ████████ ~ @@ -1489,7 +1489,7 @@ function getTemplatePath(subFolder: string, fileName: string | string[]) { if (typeof fileName === "string") { return `${C.TEMPLATE_ROOT}/${subFolder}/${fileName.replace(/\..*$/, "")}.hbs`; } - return fileName.map(fName => getTemplatePath(subFolder, fName)); + return fileName.map((fName) => getTemplatePath(subFolder, fName)); } // DisplayImageSelector: Displays a file selector in tiles mode at the indicated path root. diff --git a/ts/documents/actors/BladesCrew.ts b/ts/documents/actors/BladesCrew.ts index 11a26058..e792953e 100644 --- a/ts/documents/actors/BladesCrew.ts +++ b/ts/documents/actors/BladesCrew.ts @@ -59,7 +59,7 @@ class BladesCrew extends BladesActor implements BladesActorSubClass.Crew, get abilities(): BladesItem[] { if (!this.playbook) {return [];} return this.activeSubItems - .filter(item => [BladesItemType.ability, BladesItemType.crew_ability].includes(item.type)); + .filter((item) => [BladesItemType.ability, BladesItemType.crew_ability].includes(item.type)); } get playbookName() { diff --git a/ts/documents/actors/BladesPC.ts b/ts/documents/actors/BladesPC.ts index 8b4fb828..798af7dc 100644 --- a/ts/documents/actors/BladesPC.ts +++ b/ts/documents/actors/BladesPC.ts @@ -44,7 +44,7 @@ class BladesPC extends BladesActor implements BladesActorSubClass.Scoundrel, // #region BladesPrimaryActor Implementation ~ get primaryUser(): User | null { - return game.users?.find(user => user.character?.id === this?.id) || null; + return game.users?.find((user) => user.character?.id === this?.id) || null; } async clearLoadout() { @@ -53,17 +53,17 @@ class BladesPC extends BladesActor implements BladesActorSubClass.Scoundrel, "Item", [ ...this.activeSubItems - .filter(item => BladesItem.IsType(item, BladesItemType.gear) + .filter((item) => BladesItem.IsType(item, BladesItemType.gear) && !item.hasTag(Tag.System.Archived)) - .map(item => ({ + .map((item) => ({ _id: item.id, "system.tags": [...item.tags, Tag.System.Archived], "system.uses_per_score.value": 0 })), ...this.activeSubItems - .filter(item => BladesItem.IsType(item, BladesItemType.ability) + .filter((item) => BladesItem.IsType(item, BladesItemType.ability) && item.system.uses_per_score.max) - .map(item => ({ + .map((item) => ({ _id: item.id, "system.uses_per_score.value": 0 })) @@ -115,7 +115,7 @@ class BladesPC extends BladesActor implements BladesActorSubClass.Scoundrel, get vice(): BladesItem | undefined { if (this.type !== BladesActorType.pc) { return undefined; } - return this.activeSubItems.find(item => item.type === BladesItemType.vice); + return this.activeSubItems.find((item) => item.type === BladesItemType.vice); } get crew(): BladesCrew | undefined { @@ -126,7 +126,7 @@ class BladesPC extends BladesActor implements BladesActorSubClass.Scoundrel, get abilities(): BladesItem[] { if (!this.playbook) { return []; } return this.activeSubItems - .filter(item => [BladesItemType.ability, BladesItemType.crew_ability].includes(item.type)); + .filter((item) => [BladesItemType.ability, BladesItemType.crew_ability].includes(item.type)); } get playbookName() { @@ -173,7 +173,7 @@ class BladesPC extends BladesActor implements BladesActorSubClass.Scoundrel, get trauma(): number { if (!BladesActor.IsType(this, BladesActorType.pc)) { return 0; } return Object.keys(this.system.trauma.checked) - .filter(traumaName => + .filter((traumaName) => // @ts-ignore Compiler linter mismatch. this.system.trauma.active[traumaName] && this.system.trauma.checked[traumaName]) .length; @@ -182,7 +182,7 @@ class BladesPC extends BladesActor implements BladesActorSubClass.Scoundrel, get traumaList(): string[] { // @ts-ignore Compiler linter mismatch. return BladesActor.IsType(this, BladesActorType.pc) - ? Object.keys(this.system.trauma.active).filter(key => this.system.trauma.active[key]) + ? Object.keys(this.system.trauma.active).filter((key) => this.system.trauma.active[key]) : []; } @@ -200,7 +200,7 @@ class BladesPC extends BladesActor implements BladesActorSubClass.Scoundrel, get currentLoad(): number { if (!BladesActor.IsType(this, BladesActorType.pc)) { return 0; } - const activeLoadItems = this.activeSubItems.filter(item => item.type === BladesItemType.gear); + const activeLoadItems = this.activeSubItems.filter((item) => item.type === BladesItemType.gear); return U.gsap.utils.clamp(0, 10, activeLoadItems.reduce((tot, i) => tot + U.pInt(i.system.load), 0)); } @@ -231,7 +231,7 @@ class BladesPC extends BladesActor implements BladesActorSubClass.Scoundrel, [/Less Effect/, RollModSection.effect] as const ].forEach(([effectPat, effectCat]) => { const {one: harmConditionOne, two: harmConditionTwo} = Object.values(this.system.harm) - .find(harmData => effectPat.test(harmData.effect)) ?? {}; + .find((harmData) => effectPat.test(harmData.effect)) ?? {}; const harmString = U.objCompact([harmConditionOne, harmConditionTwo === "" ? null : harmConditionTwo]).join(" & "); if (harmString.length > 0) { rollModsData.push({ @@ -253,7 +253,7 @@ class BladesPC extends BladesActor implements BladesActorSubClass.Scoundrel, } }); const {one: harmCondition} = Object.values(this.system.harm) - .find(harmData => /Need Help/.test(harmData.effect)) ?? {}; + .find((harmData) => /Need Help/.test(harmData.effect)) ?? {}; if (harmCondition && harmCondition.trim() !== "") { rollModsData.push({ id: "Push-negative-roll", @@ -297,8 +297,8 @@ class BladesPC extends BladesActor implements BladesActorSubClass.Scoundrel, get rollTraitPCTooltipActions(): string { const tooltipStrings: string[] = ["
${U.uCase(attribute)}
"]; const actionRatings = this.actions; - Object.values(AttributeTrait).forEach(attribute => { - C.Action[attribute].forEach(action => { + Object.values(AttributeTrait).forEach((attribute) => { + C.Action[attribute].forEach((action) => { tooltipStrings.push([ "", ``, @@ -315,7 +315,7 @@ class BladesPC extends BladesActor implements BladesActorSubClass.Scoundrel, get rollTraitPCTooltipAttributes(): string { const tooltipStrings: string[] = ["
${U.uCase(action)}
"]; const attributeRatings = this.attributes; - Object.values(AttributeTrait).forEach(attribute => { + Object.values(AttributeTrait).forEach((attribute) => { tooltipStrings.push([ "", ``, diff --git a/ts/sheets/actor/BladesActorSheet.ts b/ts/sheets/actor/BladesActorSheet.ts index 1f58175f..05f0d823 100644 --- a/ts/sheets/actor/BladesActorSheet.ts +++ b/ts/sheets/actor/BladesActorSheet.ts @@ -65,18 +65,18 @@ class BladesActorSheet extends ActorSheet { gang: this.actor.activeSubItems .filter((item): item is BladesItemOfType => item.type === BladesItemType.cohort_gang) - .map(item => { + .map((item) => { // Prepare gang cohort items. const subtypes = U.unique(Object.values(item.system.subtypes) - .map(subtype => subtype.trim()) - .filter(subtype => /[A-Za-z]/.test(subtype))) as Tag.GangType[]; + .map((subtype) => subtype.trim()) + .filter((subtype) => /[A-Za-z]/.test(subtype))) as Tag.GangType[]; const eliteSubtypes = U.unique([ ...Object.values(item.system.elite_subtypes), ...(item.parent?.upgrades ?? []) - .map(upgrade => (upgrade.name ?? "").trim().replace(/^Elite /, "")) + .map((upgrade) => (upgrade.name ?? "").trim().replace(/^Elite /, "")) ] - .map(subtype => subtype.trim()) - .filter(subtype => /[A-Za-z]/ + .map((subtype) => subtype.trim()) + .filter((subtype) => /[A-Za-z]/ .test(subtype) && subtypes.includes(subtype as Tag.GangType) ) ) as Tag.GangType[]; @@ -84,7 +84,7 @@ class BladesActorSheet extends ActorSheet { // Prepare images for gang cohort items. const imgTypes = [...eliteSubtypes]; if (imgTypes.length < 2) { - imgTypes.push(...subtypes.filter(subtype => !imgTypes.includes(subtype))); + imgTypes.push(...subtypes.filter((subtype) => !imgTypes.includes(subtype))); } if (U.unique(imgTypes).length === 1) { item.system.image = Object.values(item.system.elite_subtypes).includes(imgTypes[0]) ? `elite-${U.lCase(imgTypes[0])}.svg` : `${U.lCase(imgTypes[0])}.svg`; @@ -103,11 +103,11 @@ class BladesActorSheet extends ActorSheet { {mode: "untrained", label: "Untrained", color: "transparent", tooltip: "

Roll Untrained

"} ], edgeData: Object.fromEntries(Object.values(item.system.edges ?? []) - .filter(edge => /[A-Za-z]/.test(edge)) - .map(edge => [edge.trim(), C.EdgeTooltips[edge as KeyOf]])), + .filter((edge) => /[A-Za-z]/.test(edge)) + .map((edge) => [edge.trim(), C.EdgeTooltips[edge as KeyOf]])), flawData: Object.fromEntries(Object.values(item.system.flaws ?? []) - .filter(flaw => /[A-Za-z]/.test(flaw)) - .map(flaw => [flaw.trim(), C.FlawTooltips[flaw as KeyOf]])) + .filter((flaw) => /[A-Za-z]/.test(flaw)) + .map((flaw) => [flaw.trim(), C.FlawTooltips[flaw as KeyOf]])) } ); return item; @@ -115,7 +115,7 @@ class BladesActorSheet extends ActorSheet { expert: this.actor.activeSubItems .filter((item): item is BladesItemOfType => item.type === BladesItemType.cohort_expert) - .map(item => { + .map((item) => { // Prepare expert cohort items. Object.assign( item.system, @@ -125,11 +125,11 @@ class BladesActorSheet extends ActorSheet { {mode: "untrained", label: "Untrained", tooltip: "

Roll Untrained

"} ], edgeData: Object.fromEntries(Object.values(item.system.edges ?? []) - .filter(edge => /[A-Za-z]/.test(edge)) - .map(edge => [edge.trim(), C.EdgeTooltips[edge as KeyOf]])), + .filter((edge) => /[A-Za-z]/.test(edge)) + .map((edge) => [edge.trim(), C.EdgeTooltips[edge as KeyOf]])), flawData: Object.fromEntries(Object.values(item.system.flaws ?? []) - .filter(flaw => /[A-Za-z]/.test(flaw)) - .map(flaw => [flaw.trim(), C.FlawTooltips[flaw as KeyOf]])) + .filter((flaw) => /[A-Za-z]/.test(flaw)) + .map((flaw) => [flaw.trim(), C.FlawTooltips[flaw as KeyOf]])) } ); return item; @@ -155,7 +155,7 @@ class BladesActorSheet extends ActorSheet { sheetData.playbookData.tooltip = (new Handlebars.SafeString([ "

At the End of the Session, Gain XP If ...

", "
    ", - ...Object.values(this.actor.system.experience.clues ?? []).map(line => `
  • ${line.replace(/^Y/, "... y")}
  • `) ?? [], + ...Object.values(this.actor.system.experience.clues ?? []).map((line) => `
  • ${line.replace(/^Y/, "... y")}
  • `) ?? [], "
" ].join(""))).toString(); } diff --git a/ts/sheets/item/BladesGMTrackerSheet.ts b/ts/sheets/item/BladesGMTrackerSheet.ts index ebb27a55..6334e8a1 100644 --- a/ts/sheets/item/BladesGMTrackerSheet.ts +++ b/ts/sheets/item/BladesGMTrackerSheet.ts @@ -7,6 +7,7 @@ import BladesActor from "../../BladesActor"; import BladesPC from "../../documents/actors/BladesPC"; +// eslint-disable-next-line no-shadow export enum BladesTipContext { DiceRoll = "DiceRoll", Combat = "Combat", @@ -75,7 +76,8 @@ class BladesGMTrackerSheet extends BladesItemSheet { game.eunoblades ??= {}; Items.registerSheet("blades", BladesGMTrackerSheet, {types: ["gm_tracker"], makeDefault: true}); Hooks.once("ready", async () => { - let tracker: BladesGMTracker|undefined = game.items.find((item): item is BladesGMTracker => BladesItem.IsType(item, BladesItemType.gm_tracker)); + let tracker: BladesGMTracker|undefined = game.items + .find((item): item is BladesGMTracker => BladesItem.IsType(item, BladesItemType.gm_tracker)); if (!tracker) { tracker = (await BladesGMTracker.create({ name: "GM Tracker", @@ -113,7 +115,7 @@ class BladesGMTrackerSheet extends BladesItemSheet { case BladesPhase.Score: { isForcingRender = false; game.actors.filter((actor): actor is BladesPC => BladesActor.IsType(actor, BladesActorType.pc)) - .forEach(actor => actor.clearLoadout()); + .forEach((actor) => actor.clearLoadout()); break; } case BladesPhase.Downtime: { @@ -143,8 +145,8 @@ class BladesGMTrackerSheet extends BladesItemSheet { } } if (isForcingRender) { - game.actors.filter(actor => actor.type === BladesActorType.pc) - .forEach(actor => actor.sheet?.render()); + game.actors.filter((actor) => actor.type === BladesActorType.pc) + .forEach((actor) => actor.sheet?.render()); } return submitData; } @@ -152,3 +154,4 @@ class BladesGMTrackerSheet extends BladesItemSheet { } export default BladesGMTrackerSheet; +export {BladesTipGenerator}; diff --git a/ts/sheets/item/BladesItemSheet.ts b/ts/sheets/item/BladesItemSheet.ts index c7f9d742..5f0a79a6 100644 --- a/ts/sheets/item/BladesItemSheet.ts +++ b/ts/sheets/item/BladesItemSheet.ts @@ -45,7 +45,7 @@ class BladesItemSheet extends ItemSheet { } _getTypedItemData: Record BladesItemSheetData> = { - [BladesItemType.ability]: context => { + [BladesItemType.ability]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.ability)) { return undefined as never; } const sheetData: BladesItemDataOfType = {}; return { @@ -53,7 +53,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.background]: context => { + [BladesItemType.background]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.background)) { return undefined as never; } const sheetData: BladesItemDataOfType = { }; @@ -62,7 +62,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.clock_keeper]: context => { + [BladesItemType.clock_keeper]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.clock_keeper)) { return undefined as never; } const sheetData: BladesItemDataOfType = { phases: Object.values(BladesPhase) @@ -72,8 +72,10 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.cohort_gang]: context => { - if (!BladesItem.IsType(this.item, BladesItemType.cohort_gang, BladesItemType.cohort_expert)) { return undefined as never; } + [BladesItemType.cohort_gang]: (context) => { + if (!BladesItem.IsType(this.item, BladesItemType.cohort_gang, BladesItemType.cohort_expert)) { + return undefined as never; + } context.tierTotal = this.item.system.quality > 0 ? U.romanizeNum(this.item.system.quality) : "0"; context.system.subtypes ??= {}; context.system.elite_subtypes ??= {}; @@ -92,19 +94,19 @@ class BladesItemSheet extends ItemSheet { }; sheetData.edgeData = Object.fromEntries(Object.values(context.system.edges ?? []) - .filter(edge => /[A-Za-z]/.test(edge)) - .map(edge => [edge.trim(), C.EdgeTooltips[edge as KeyOf]])); + .filter((edge) => /[A-Za-z]/.test(edge)) + .map((edge) => [edge.trim(), C.EdgeTooltips[edge as KeyOf]])); sheetData.flawData = Object.fromEntries(Object.values(context.system.flaws ?? []) - .filter(flaw => /[A-Za-z]/.test(flaw)) - .map(flaw => [flaw.trim(), C.FlawTooltips[flaw as KeyOf]])); + .filter((flaw) => /[A-Za-z]/.test(flaw)) + .map((flaw) => [flaw.trim(), C.FlawTooltips[flaw as KeyOf]])); return { ...context, ...sheetData }; }, - [BladesItemType.cohort_expert]: context => this._getTypedItemData[BladesItemType.cohort_gang](context), - [BladesItemType.crew_ability]: context => { + [BladesItemType.cohort_expert]: (context) => this._getTypedItemData[BladesItemType.cohort_gang](context), + [BladesItemType.crew_ability]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.crew_ability)) { return undefined as never; } const sheetData: BladesItemDataOfType = { }; @@ -113,7 +115,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.crew_reputation]: context => { + [BladesItemType.crew_reputation]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.crew_reputation)) { return undefined as never; } const sheetData: BladesItemDataOfType = { }; @@ -122,11 +124,11 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.crew_playbook]: context => { + [BladesItemType.crew_playbook]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.crew_playbook)) { return undefined as never; } if (context.isGM) { const expClueData: Record = {}; - [...Object.values(context.system.experience_clues ?? []).filter(clue => /[A-Za-z]/.test(clue)), " "].forEach((clue, i) => { expClueData[(i + 1).toString()] = clue; }); + [...Object.values(context.system.experience_clues ?? []).filter((clue) => /[A-Za-z]/.test(clue)), " "].forEach((clue, i) => { expClueData[(i + 1).toString()] = clue; }); context.system.experience_clues = expClueData; } const sheetData: BladesItemDataOfType = { @@ -136,7 +138,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.crew_upgrade]: context => { + [BladesItemType.crew_upgrade]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.crew_upgrade)) { return undefined as never; } const sheetData: BladesItemDataOfType = { }; @@ -145,7 +147,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.feature]: context => { + [BladesItemType.feature]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.feature)) { return undefined as never; } const sheetData: BladesItemDataOfType = { }; @@ -154,7 +156,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.gm_tracker]: context => { + [BladesItemType.gm_tracker]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.gm_tracker)) { return undefined as never; } const sheetData: BladesItemDataOfType = { }; @@ -163,7 +165,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.heritage]: context => { + [BladesItemType.heritage]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.heritage)) { return undefined as never; } const sheetData: BladesItemDataOfType = { }; @@ -172,7 +174,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.gear]: context => { + [BladesItemType.gear]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.gear)) { return undefined as never; } const sheetData: BladesItemDataOfType = { tierData: { @@ -195,14 +197,14 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.playbook]: context => { + [BladesItemType.playbook]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.playbook)) { return undefined as never; } if (context.isGM) { const expClueData: Record = {}; - [...Object.values(context.system.experience_clues ?? []).filter(clue => /[A-Za-z]/.test(clue)), " "].forEach((clue, i) => { expClueData[(i + 1).toString()] = clue; }); + [...Object.values(context.system.experience_clues ?? []).filter((clue) => /[A-Za-z]/.test(clue)), " "].forEach((clue, i) => { expClueData[(i + 1).toString()] = clue; }); context.system.experience_clues = expClueData; const gatherInfoData: Record = {}; - [...Object.values(context.system.gather_info_questions ?? []).filter(question => /[A-Za-z]/.test(question)), " "].forEach((question, i) => { gatherInfoData[(i + 1).toString()] = question; }); + [...Object.values(context.system.gather_info_questions ?? []).filter((question) => /[A-Za-z]/.test(question)), " "].forEach((question, i) => { gatherInfoData[(i + 1).toString()] = question; }); context.system.gather_info_questions = gatherInfoData; } const sheetData: BladesItemDataOfType = {}; @@ -211,7 +213,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.preferred_op]: context => { + [BladesItemType.preferred_op]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.preferred_op)) { return undefined as never; } const sheetData: BladesItemDataOfType = { }; @@ -220,7 +222,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.stricture]: context => { + [BladesItemType.stricture]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.stricture)) { return undefined as never; } const sheetData: BladesItemDataOfType = { }; @@ -229,7 +231,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.vice]: context => { + [BladesItemType.vice]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.vice)) { return undefined as never; } const sheetData: BladesItemDataOfType = { }; @@ -238,7 +240,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.project]: context => { + [BladesItemType.project]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.project)) { return undefined as never; } const sheetData: BladesItemDataOfType = { }; @@ -247,7 +249,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.ritual]: context => { + [BladesItemType.ritual]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.ritual)) { return undefined as never; } const sheetData: BladesItemDataOfType = { }; @@ -256,7 +258,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.design]: context => { + [BladesItemType.design]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.design)) { return undefined as never; } const sheetData: BladesItemDataOfType = { }; @@ -265,7 +267,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.location]: context => { + [BladesItemType.location]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.location)) { return undefined as never; } const sheetData: BladesItemDataOfType = { }; @@ -274,7 +276,7 @@ class BladesItemSheet extends ItemSheet { ...sheetData }; }, - [BladesItemType.score]: context => { + [BladesItemType.score]: (context) => { if (!BladesItem.IsType(this.item, BladesItemType.score)) { return undefined as never; } return context; } @@ -346,14 +348,14 @@ class BladesItemSheet extends ItemSheet { // Harm Bar Functionality for Cohorts if (BladesItem.IsType(this.item, BladesItemType.cohort_expert, BladesItemType.cohort_gang)) { html.find("[data-harm-click]").on({ - click: event => { + click: (event) => { event.preventDefault(); const harmLevel = U.pInt($(event.currentTarget).data("harmClick")); if (this.item.system.harm?.value !== harmLevel) { this.item.update({"system.harm.value": harmLevel}); } }, - contextmenu: event => { + contextmenu: (event) => { event.preventDefault(); const harmLevel = Math.max(0, U.pInt($(event.currentTarget).data("harmClick")) - 1); if (this.item.system.harm?.value !== harmLevel) { @@ -368,7 +370,7 @@ class BladesItemSheet extends ItemSheet { html.on("change", "textarea", this._onChangeInput.bind(this)); // Use delegated listener on the form } - html.find(".effect-control").on("click", ev => { + html.find(".effect-control").on("click", (ev) => { if ( self.item.isOwned ) { ui.notifications?.warn(game.i18n.localize("BITD.EffectWarning")); return; diff --git a/ts/sheets/item/BladesScoreSheet.ts b/ts/sheets/item/BladesScoreSheet.ts index f6dc6a80..ae6471d3 100644 --- a/ts/sheets/item/BladesScoreSheet.ts +++ b/ts/sheets/item/BladesScoreSheet.ts @@ -64,36 +64,44 @@ class BladesScoreSheet extends BladesItemSheet { // Generate full set of random data. const randomData: Record>> = { Bargains: Object.fromEntries(Object.entries(U.sample(Randomizers.GM.Bargains - .filter(bData => !Object.values(this.document.system.randomizers.Bargains) - .some(_bData => _bData.name === bData.name || _bData.effect === bData.effect)), 3, true, (e, a) => a - .filter(_e => e.category === _e.category).length === 0)) + .filter((bData) => !Object.values(this.document.system.randomizers.Bargains) + .some((_bData) => _bData.name === bData.name || _bData.effect === bData.effect)), 3, true, (e, a) => a + .filter((_e) => e.category === _e.category).length === 0)) .map(([k, v]) => { k = `${k}`; Object.assign(v, {notes: ""}); return [k, v]; })), Obstacles: Object.fromEntries(Object.entries(U.sample(Randomizers.GM.Obstacles - .filter(bData => !Object.values(this.document.system.randomizers.Obstacles) - .some(_bData => _bData.name === bData.name || _bData.desc === bData.desc)), 3, true, (e, a) => a - .filter(_e => e.category === _e.category).length === 0)) + .filter((bData) => !Object.values(this.document.system.randomizers.Obstacles) + .some((_bData) => _bData.name === bData.name || _bData.desc === bData.desc)), 3, true, (e, a) => a + .filter((_e) => e.category === _e.category).length === 0)) .map(([k, v]) => { k = `${k}`; Object.assign(v, {notes: ""}); return [k, v]; })), - NPCs: Object.fromEntries(Object.entries(U.sample(Randomizers.GM.NPCs - .filter(bData => !Object.values(this.document.system.randomizers.NPCs) - .some(_bData => _bData.name === bData.name || _bData.description === bData.description)), 3, true, (e, a) => a - .filter(_e => e.arena === _e.arena).length === 0)) + NPCs: Object.fromEntries(Object.entries(U.sample( + Randomizers.GM.NPCs + .filter((bData) => !Object.values(this.document.system.randomizers.NPCs) + .some((_bData) => _bData.name === bData.name + || _bData.description === bData.description) + ) + , + 3, + true, + (e, a) => a + .filter((_e) => e.arena === _e.arena).length === 0 + )) .map(([k, v]) => { k = `${k}`; Object.assign(v, {notes: ""}); return [k, v]; })), Scores: Object.fromEntries(Object.entries(U.sample(Randomizers.GM.Scores - .filter(bData => !Object.values(this.document.system.randomizers.Scores) - .some(_bData => _bData.name === bData.name || _bData.desc === bData.desc)), 3, true, (e, a) => a - .filter(_e => e.category === _e.category).length === 0)) + .filter((bData) => !Object.values(this.document.system.randomizers.Scores) + .some((_bData) => _bData.name === bData.name || _bData.desc === bData.desc)), 3, true, (e, a) => a + .filter((_e) => e.category === _e.category).length === 0)) .map(([k, v]) => { k = `${k}`; Object.assign(v, {notes: ""}); @@ -104,7 +112,7 @@ class BladesScoreSheet extends BladesItemSheet { // If category specified, replace all other categories with stored data if (category) { Object.keys(randomData) - .filter(cat => cat !== category) + .filter((cat) => cat !== category) .forEach((cat: string) => { const _cat = cat as RandomCat; randomData[_cat] = this.document.system.randomizers[_cat]; @@ -122,7 +130,7 @@ class BladesScoreSheet extends BladesItemSheet { // Iterate through all randomizer categories. If system entry isLocked, use that, or use newly-generated data Object.keys(randomData).forEach((cat: string) => { const _cat = cat as RandomCat; - Object.keys(randomData[_cat]).forEach(index => { + Object.keys(randomData[_cat]).forEach((index) => { if (this.document.system.randomizers?.[_cat][index].isLocked) { finalRandomData[_cat][index] = this.document.system.randomizers[_cat][index]; } else { @@ -142,7 +150,7 @@ class BladesScoreSheet extends BladesItemSheet { // Get player characters, assign simplified actionData that I probably should have coded them with from the start sheetData.playerCharacters = BladesActor.GetTypeWithTags(BladesActorType.pc, Tag.PC.ActivePC) - .map(pc => { + .map((pc) => { return Object.assign( pc, { @@ -213,7 +221,7 @@ class BladesScoreSheet extends BladesItemSheet { _addImage() { U.displayImageSelector( - path => { + (path) => { const imgIndex = U.objSize(this.document.system.images); return this.document.update({[`system.images.${imgIndex}`]: path}); }, @@ -302,7 +310,7 @@ class BladesScoreSheet extends BladesItemSheet { case BladesPhase.Score: { isForcingRender = false; game.actors.filter((actor): actor is BladesPC => BladesActor.IsType(actor, BladesActorType.pc)) - .forEach(actor => actor.clearLoadout()); + .forEach((actor) => actor.clearLoadout()); break; } case BladesPhase.Downtime: { @@ -332,8 +340,8 @@ class BladesScoreSheet extends BladesItemSheet { } } if (isForcingRender) { - game.actors.filter(actor => actor.type === BladesActorType.pc) - .forEach(actor => actor.sheet?.render()); + game.actors.filter((actor) => actor.type === BladesActorType.pc) + .forEach((actor) => actor.sheet?.render()); } return submitData; }
${U.uCase(attribute)}