Skip to content

Commit 4b117eb

Browse files
committed
Fix sf2e compatibility
1 parent 6fa2c3e commit 4b117eb

31 files changed

Lines changed: 298 additions & 205 deletions

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Version 2.20.1
2+
- Moved settings.js to the top of module.json esmodules.
3+
- Fixed sf2e compatibility.
4+
15
# Version 2.20.0
26
- Added SF2e Compatibility to the module.json
37
- Reworked how the module is built to make it easier to contribute. (Thanks @ChasarooniZ!)

build/macros/Action Counter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ if (args?.length === 0) {
88
return ui.notifications.error(message)
99
}
1010

11-
const ITEM_UUID = "Compendium.pf2e-jb2a-macros.Actions.slQlwROqkytVGKKk" // Action Counter
11+
const ITEM_UUID = `Compendium.pf2e-jb2a-macros.${game.system.id}-actions.slQlwROqkytVGKKk` // Action Counter
1212
const source = (await fromUuid(ITEM_UUID)).toObject()
1313
source.flags = mergeObject(source.flags ?? {}, {
1414
core: { sourceId: ITEM_UUID },

build/macros/Dancing Lights.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if (!game.modules.get("foundry-summons")?.active) {
77
}
88

99
const dancingLight = await fromUuid(
10-
"Compendium.pf2e-jb2a-macros.Actors.teCoIt8sjArsIl4D"
10+
`Compendium.pf2e-jb2a-macros.${game.system.id}-actors.teCoIt8sjArsIl4D`
1111
)
1212
const dancingLightObj = { ...dancingLight.toObject(), uuid: dancingLight.uuid }
1313

build/macros/Humanoid Form.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,11 @@ if (args[0] !== "off") {
133133
.play();
134134

135135
// Store original data on the token for later use
136-
tokenD.document.setFlag("pf2e", "originalData", originalData);
136+
tokenD.document.setFlag(game.system.id, "originalData", originalData);
137137

138138
} else if (args[0] === "off") {
139139
// Retrieve original token data
140-
const originalData = tokenD.document.getFlag("pf2e", "originalData");
140+
const originalData = tokenD.document.getFlag(game.system.id, "originalData");
141141

142142
Sequencer.EffectManager.endEffects({
143143
origin: "Humanoid Form",
@@ -158,6 +158,6 @@ if (args[0] !== "off") {
158158
});
159159

160160
// Remove the flag after reverting
161-
tokenD.document.unsetFlag("pf2e", "originalData");
161+
tokenD.document.unsetFlag(game.system.id, "originalData");
162162
}
163163
}

build/macros/Mirror Image.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ if (args.length === 0) {
1010
return ui.notifications.error(message)
1111
}
1212

13-
const ITEM_UUID = "Compendium.pf2e-jb2a-macros.Actions.15XurJzUEax6FhA7" // Mirror Image
13+
const ITEM_UUID = `Compendium.pf2e-jb2a-macros.${game.system.id}-actions.15XurJzUEax6FhA7` // Mirror Image
1414
const source = (await fromUuid(ITEM_UUID)).toObject()
1515
source.flags = mergeObject(source.flags ?? {}, {
1616
core: { sourceId: ITEM_UUID },

build/macros/Scorching Ray.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if (!tokenD) {
1717
let targetDialogue = []
1818
let rayCount = []
1919

20-
if (game.system.id === "pf2e") {
20+
if (game.system.id === "pf2e" || game.system.id === "sf2e") {
2121
for (let i of targets.keys()) {
2222
rayCount.push(1)
2323
}

module.json

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@
5656
"verified": "13"
5757
},
5858
"esmodules": [
59+
"module/settings.js",
5960
"module/pf2e-animations.js",
6061
"module/sequencer-extensions.js",
61-
"module/settings.js",
6262
"module/updateMenu.js",
6363
"module/blacklistMenu.js",
6464
"module/modifiers-matter.js"
@@ -74,38 +74,57 @@
7474
"color": "#6f1c17",
7575
"packs": [
7676
"Macros",
77-
"Actors",
78-
"Actions"
77+
"pf2e-actors",
78+
"pf2e-actions",
79+
"sf2e-Actors",
80+
"sf2e-Actions"
7981
]
8082
}
8183
],
8284
"packs": [
8385
{
8486
"label": "PF2e Animation Macros",
8587
"name": "Macros",
86-
"path": "packs/macros.db",
87-
"system": "pf2e",
88+
"path": "packs/macros",
8889
"type": "Macro",
8990
"private": false,
9091
"flags": {}
9192
},
9293
{
9394
"label": "PF2e Animation Actors",
94-
"name": "Actors",
95-
"path": "packs/actors.db",
95+
"name": "pf2e-actors",
96+
"path": "packs/actors",
9697
"system": "pf2e",
9798
"type": "Actor",
9899
"private": false,
99100
"flags": {}
100101
},
101102
{
102103
"label": "PF2e Animation Items",
103-
"name": "Actions",
104-
"path": "packs/actions.db",
104+
"name": "pf2e-actions",
105+
"path": "packs/actions",
105106
"system": "pf2e",
106107
"type": "Item",
107108
"private": false,
108109
"flags": {}
110+
},
111+
{
112+
"label": "SF2e Animation Actors",
113+
"name": "sf2e-actors",
114+
"path": "packs/sf2e-actors",
115+
"system": "sf2e",
116+
"type": "Actor",
117+
"private": false,
118+
"flags": {}
119+
},
120+
{
121+
"label": "SF2e Animation Items",
122+
"name": "sf2e-actions",
123+
"path": "packs/sf2e-actions",
124+
"system": "sf2e",
125+
"type": "Item",
126+
"private": false,
127+
"flags": {}
109128
}
110129
],
111130
"relationships": {

module/pf2e-animations.js

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ pf2eAnimations.hooks = {};
66
pf2eAnimations.hooks.ready = Hooks.once("ready", () => {
77
console.log(
88
"PF2e Animations v" +
9-
game.modules.get("pf2e-jb2a-macros").version +
10-
" loaded."
9+
game.modules.get("pf2e-jb2a-macros").version +
10+
" loaded."
1111
);
1212
// Warn if no JB2A is found.
1313
if (
@@ -104,15 +104,15 @@ pf2eAnimations.hooks.ready = Hooks.once("ready", () => {
104104
${game.i18n.localize("pf2e-jb2a-macros.welcomeMessage.settingsButton")}
105105
</button>
106106
<p style="text-align: center; margin: 0; margin-top: 5px;"><i>${game.i18n.localize(
107-
"pf2e-jb2a-macros.welcomeMessage.footer"
108-
)}</i></p>
107+
"pf2e-jb2a-macros.welcomeMessage.footer"
108+
)}</i></p>
109109
</div>`,
110110
});
111111
}
112112

113113
// GM-Only stuff.
114114
if (!game.user.isGM) return;
115-
if (game.settings.get("pf2e", "tokens.autoscale"))
115+
if (game.settings.get(game.system.id, "tokens.autoscale"))
116116
game.settings.set("pf2e-jb2a-macros", "smallTokenScale", 0.8);
117117
if (!game.modules.get("tokenmagic")?.active)
118118
game.settings.set("pf2e-jb2a-macros", "tmfx", false);
@@ -137,7 +137,7 @@ pf2eAnimations.hooks.createChatMessage = Hooks.on(
137137
async (data) => {
138138
if (game.user.id !== data.author.id) return;
139139
let targets =
140-
data?.flags?.pf2e?.target?.token ?? Array.from(game.user.targets);
140+
data?.flags?.pf2e?.target?.token ?? data?.flags?.sf2e?.target?.token ?? Array.from(game.user.targets);
141141
targets = [targets].flat();
142142
let token = data.token ?? canvas.tokens.controlled[0];
143143
let flavor = data.flavor ?? null;
@@ -168,12 +168,13 @@ pf2eAnimations.hooks.createChatMessage = Hooks.on(
168168
}
169169
// Attack Matches
170170
if (
171-
data.flags.pf2e?.context?.type === "attack-roll" &&
171+
(data.flags.pf2e?.context?.type === "attack-roll" ||
172+
data.flags.sf2e?.context?.type === "attack-roll") &&
172173
!game.settings.get("pf2e-jb2a-macros", "disableHitAnims")
173174
) {
174175
const degreeOfSuccess =
175176
pf2eAnimations.degreeOfSuccessWithRerollHandling(data);
176-
const pack = game.packs.get("pf2e-jb2a-macros.Actions");
177+
const pack = game.packs.get(`pf2e-jb2a-macros.${game.system.id}-actions`);
177178
if (!pack)
178179
ui.notifications.error(
179180
`PF2e Animations | ${pf2eAnimations.localize(
@@ -278,8 +279,8 @@ pf2eAnimations.hooks.updateItem = Hooks.on("updateItem", (data, changes) => {
278279
const status = data.isInvested
279280
? "invested"
280281
: data.isEquipped
281-
? "equipped"
282-
: false;
282+
? "equipped"
283+
: false;
283284
Hooks.call("pf2eAnimations.equipOrInvestItem", status, data);
284285
});
285286

@@ -288,12 +289,11 @@ pf2eAnimations.hooks.renderActorDirectory = Hooks.on(
288289
"renderActorDirectory",
289290
(app, html, data) => {
290291
if (!(game.user.isGM && game.settings.get("pf2e-jb2a-macros", "debug"))) {
291-
const $html = html instanceof jQuery ? html : $(html);
292+
const $html = html instanceof jQuery ? html : $(html);
292293
const folder = $html.find(
293-
`.folder[data-folder-id="${
294-
game.folders.get(
295-
game.settings.get("pf2e-jb2a-macros", "dummyNPCId-folder")
296-
)?.id
294+
`.folder[data-folder-id="${game.folders.get(
295+
game.settings.get("pf2e-jb2a-macros", "dummyNPCId-folder")
296+
)?.id
297297
}"]`
298298
);
299299
folder.remove();
@@ -426,8 +426,7 @@ pf2eAnimations.hooks.AutomatedAnimations.metaData = Hooks.on(
426426
);
427427
} else if (metaData.name === "PF2e Animations") {
428428
ui.notifications.notify(
429-
`${metaData.name} (v${metaData.moduleVersion}) | Animation Version: ${
430-
metaData.version
429+
`${metaData.name} (v${metaData.moduleVersion}) | Animation Version: ${metaData.version
431430
}<hr>${pf2eAnimations.localize(
432431
"pf2e-jb2a-macros.notifications.metaData"
433432
)}`
@@ -519,12 +518,11 @@ pf2eAnimations.hooks.foundrySummonsWrapper = Hooks.on(
519518
}
520519

521520
getLamp(color, isThumb) {
522-
return `modules/${
523-
game.modules.get("jb2a_patreon") ? "jb2a_patreon" : "JB2A_DnD5e"
524-
}/Library/Cantrip/Dancing_Lights/DancingLights_01_${color.replaceAll(
525-
"-",
526-
""
527-
)}_${isThumb ? "Thumb.webp" : "200x200.webm"}`;
521+
return `modules/${game.modules.get("jb2a_patreon") ? "jb2a_patreon" : "JB2A_DnD5e"
522+
}/Library/Cantrip/Dancing_Lights/DancingLights_01_${color.replaceAll(
523+
"-",
524+
""
525+
)}_${isThumb ? "Thumb.webp" : "200x200.webm"}`;
528526
}
529527

530528
async loadDocument() {
@@ -596,10 +594,10 @@ pf2eAnimations.runMacro = async function runJB2Apf2eMacro(
596594
} else {
597595
ui.notifications.error(
598596
"PF2e Animations | Macro " +
599-
macroName +
600-
" not found in " +
601-
compendiumName +
602-
"."
597+
macroName +
598+
" not found in " +
599+
compendiumName +
600+
"."
603601
);
604602
}
605603
} else {
@@ -612,7 +610,7 @@ pf2eAnimations.runMacro = async function runJB2Apf2eMacro(
612610
// As above @ xdy.
613611
pf2eAnimations.degreeOfSuccessWithRerollHandling =
614612
function degreeOfSuccessWithRerollHandling(message) {
615-
const flags = message.flags.pf2e;
613+
const flags = message.flags.pf2e || message.flags.sf2e;
616614
let degreeOfSuccess = flags.context?.outcome ?? "";
617615
if (flags?.context?.isReroll) {
618616
const match = message.flavor?.match('Result: <span .*? class="(.*?)"');
@@ -630,7 +628,7 @@ pf2eAnimations.degreeOfSuccessWithRerollHandling =
630628
*/
631629
pf2eAnimations.macroHelpers = function vauxsMacroHelpers(
632630
args = [],
633-
_callback = () => {}
631+
_callback = () => { }
634632
) {
635633
pf2eAnimations.debug("Vaux's Macro Helpers | Args", args);
636634
let token = args[1]?.sourceToken ?? canvas.tokens.controlled[0];
@@ -721,14 +719,14 @@ pf2eAnimations.alignmentStringToTraits = function alignmentStringToTraits(
721719
a === "L"
722720
? "C"
723721
: a === "C"
724-
? "L"
725-
: a === "G"
726-
? "E"
727-
: a === "E"
728-
? "G"
729-
: a === "N"
730-
? ""
731-
: a
722+
? "L"
723+
: a === "G"
724+
? "E"
725+
: a === "E"
726+
? "G"
727+
: a === "N"
728+
? ""
729+
: a
732730
)
733731
.join("");
734732
}
@@ -769,7 +767,7 @@ pf2eAnimations.crosshairs = async function crosshairs(
769767
if (!CONST.WALL_RESTRICTION_TYPES.includes(opts.noCollisionType)) {
770768
throw new Error(
771769
"A valid wall restriction type is required for testCollision. Passed " +
772-
opts.noCollisionType
770+
opts.noCollisionType
773771
);
774772
}
775773

@@ -840,7 +838,7 @@ pf2eAnimations.crosshairs = async function crosshairs(
840838
distance > opts.range ||
841839
(opts.noCollision
842840
? canvas.walls.checkCollision(ray, { type: opts.noCollisionType })
843-
.length
841+
.length
844842
: false)
845843
) {
846844
crosshairs.icon = "icons/svg/hazard.svg";
@@ -904,7 +902,7 @@ pf2eAnimations.crosshairs = async function crosshairs(
904902
if (location.flags["pf2e-jb2a-macros"]?.outOfRange === "outOfRange") {
905903
ui.notifications.error(
906904
"PF2e Animations | " +
907-
pf2eAnimations.localize("pf2e-jb2a-macros.notifications.outOfRange")
905+
pf2eAnimations.localize("pf2e-jb2a-macros.notifications.outOfRange")
908906
);
909907
location = { cancelled: true };
910908
}

0 commit comments

Comments
 (0)