-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
340 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
pf2e-macro-helper-library.lock | ||
foundry/client | ||
jsconfig.json | ||
foundry/common | ||
foundry/common | ||
styles/*.css | ||
styles/*.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
- fix token settings on dropHeldTorch | ||
- brushup the group initiative skills dialog macro | ||
- implement current column | ||
- account for lores known by all selected | ||
- finish localization | ||
- foundry package release api | ||
- npm package setup, run link dev | ||
- or just a standalone script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export * from './fascinatingPerformance.mjs'; | ||
export * from './dropHeldTorch.mjs'; | ||
export * from './lashingCurrents.mjs'; | ||
export * from './recoverOldLashingCurrents.mjs'; | ||
export * from './updateInitiativeSkills.mjs' | ||
export * from "./fascinatingPerformance.mjs"; | ||
export * from "./dropHeldTorch.mjs"; | ||
export * from "./lashingCurrents.mjs"; | ||
export * from "./recoverOldLashingCurrents.mjs"; | ||
export * from "./updateInitiativeSkills.mjs"; | ||
export * from "./updateInitiativeStatistics.mjs"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
import { anyTokens } from "../helpers/tokenHelpers.mjs"; | ||
import { MHLDialog } from "../classes/MHLDialog.mjs"; | ||
import { MODULE, fu } from "../constants.mjs"; | ||
import { MHLError, mhlog } from "../helpers/errorHelpers.mjs"; | ||
import { localize } from "../helpers/stringHelpers.mjs"; | ||
|
||
export async function updateInitiativeStatistics() { | ||
const PREFIX = "MHL.Macro.UpdateInitiativeStatistics"; | ||
const func = "updateInitiativeStatistics"; | ||
const tokens = anyTokens().filter( | ||
(t) => ["character", "npc"].includes(t.actor.type) && !t.actor.traits.intersects(new Set(["minion", "eidolon"])) | ||
); | ||
if (!tokens.length) throw MHLError(`${PREFIX}.Error.NoValidTokens`, null, { func }); | ||
|
||
const renderCallback = (html) => { | ||
const allSelect = html.querySelector("select[name=all]"); | ||
const actorSelects = Array.from(html.querySelectorAll("select:not([name=all])")); | ||
allSelect.addEventListener("change", (ev) => { | ||
let disabled = false; | ||
if (ev.target.value) disabled = true; | ||
for (const select of actorSelects) { | ||
select.disabled = disabled; | ||
select.dataset.tooltip = disabled ? localize(`${PREFIX}.DisabledTooltip`) : ""; | ||
} | ||
}); | ||
}; | ||
|
||
const universalSkills = fu.deepClone(CONFIG.PF2E.skillList); | ||
delete universalSkills.lore; //remove the generic Lore entry | ||
const lores = {}; | ||
|
||
const actorsData = tokens.reduce((actoracc, t) => { | ||
// handle the rare case of more than one linked token of the same actor | ||
if (actoracc.find((a) => a.uiid === t.actor.uuid)) return actoracc; | ||
actoracc.push({ | ||
name: t.name, | ||
uuid: t.actor.uuid, | ||
skills: [["perception", { label: "PF2E.PerceptionLabel" }]] | ||
.concat(Object.entries(t.actor.skills).sort(([aslug, _], [bslug, __]) => aslug.localeCompare(bslug))) //do the sorting here so perception stays on top | ||
.map(([slug, statistic]) => [slug, statistic.label]) | ||
.reduce((acc, [slug, label]) => { | ||
if (!(slug in universalSkills)) { | ||
lores[slug] ??= { | ||
label, | ||
count: 0, | ||
}; | ||
lores[slug].count++; | ||
} | ||
acc[slug] = label; | ||
return acc; | ||
}, {}), | ||
current: t.actor.initiative.statistic.label, | ||
}); | ||
return actoracc; | ||
}, []); | ||
|
||
const sharedLores = Object.entries(lores).reduce((acc, [slug, data]) => { | ||
if (data.count === tokens.length) { | ||
acc.push([slug, data.label]); | ||
} | ||
return acc; | ||
}, []); | ||
|
||
const allSharedSkills = Object.fromEntries( | ||
[["perception", "PF2E.PerceptionLabel"]].concat( | ||
Object.entries(universalSkills) | ||
.concat(sharedLores) | ||
.sort(([aslug, _], [bslug, __]) => aslug.localeCompare(bslug)) | ||
) | ||
); | ||
|
||
const contentData = { | ||
allSharedSkills, | ||
actorsData, | ||
}; | ||
const dialogData = { | ||
contentData, | ||
title: `Set Initiative Statistics`, | ||
content: `modules/${MODULE}/templates/updateInitiativeStatistics.hbs`, | ||
buttons: { | ||
yes: { | ||
icon: "<i class='fas fa-check'></i>", | ||
label: `Apply Changes`, | ||
callback: MHLDialog.getFormData, | ||
}, | ||
no: { | ||
icon: "<i class='fas fa-times'></i>", | ||
label: `Cancel Changes`, | ||
}, | ||
}, | ||
default: "yes", | ||
render: renderCallback, | ||
}; | ||
const dialogOptions = { | ||
classes: ["update-initiative-statistics"], | ||
width: "auto", | ||
}; | ||
const { all, ...data } = await MHLDialog.wait(dialogData, dialogOptions); | ||
const actorUpdates = []; | ||
const synthUpdates = []; | ||
for (const actorData of actorsData) { | ||
const actor = fromUuidSync(actorData.uuid); | ||
const newStat = all || data[actorData.uuid]; | ||
if (!newStat) continue; | ||
if (actorData.uuid.startsWith("Scene")) { | ||
synthUpdates.push(actor.update({ "system.initiative.statistic": newStat })); | ||
} else { | ||
actorUpdates.push({ _id: actor._id, "system.initiative.statistic": newStat }); | ||
} | ||
} | ||
await Actor.updateDocuments(actorUpdates); | ||
await Promise.all(synthUpdates); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
.mhldialog.pick-a-thing { | ||
img { | ||
max-width: 40px; | ||
max-height: 40px; | ||
width: 40px; | ||
height: 40px; | ||
margin: auto 2px auto 2px; | ||
} | ||
|
||
.dialog-buttons { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 5px; | ||
} | ||
|
||
button { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: left; | ||
padding: 0px; | ||
margin: 0px; | ||
|
||
span.item-name { | ||
text-align: left; | ||
margin: auto auto auto 2%; | ||
} | ||
|
||
span.dupe-id { | ||
font-size: 0.7em; | ||
text-align: right; | ||
margin: auto; | ||
margin-right: 2%; | ||
color: var(--color-cool-3, #573fc0); | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.