From 48f43ba39810d10d82b9b04f074c57e4a915f634 Mon Sep 17 00:00:00 2001
From: Paul Fox
Date: Tue, 20 Sep 2022 21:39:31 +1000
Subject: [PATCH 1/2] Fixed actor selection issue in V10
---
scripts/main.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/main.js b/scripts/main.js
index 8333c52..d2bf30a 100644
--- a/scripts/main.js
+++ b/scripts/main.js
@@ -489,7 +489,7 @@ Hooks.once('ready', () => {
icon: "fas fa-book",
onclick: async (event) => {
const clickedElement = $(event.currentTarget);
- const actorID = clickedElement.parents('[id]')?.attr("id")?.replace("actor-", "")
+ const actorID = clickedElement.parents('[id]')?.attr("id")?.split("-").pop()
const actor = game.actors.get(actorID)
const previousChoice = VSpellPointsData.getPointsEnabled(actor)
const selectedAttribute = `selected="selected"`
From 991ab507c51412bfe14c7c38fc7f16472e3229ed Mon Sep 17 00:00:00 2001
From: Paul Fox
Date: Tue, 20 Sep 2022 23:12:25 +1000
Subject: [PATCH 2/2] Fixed issues with the template in V10
---
scripts/main.js | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/scripts/main.js b/scripts/main.js
index d2bf30a..8c14065 100644
--- a/scripts/main.js
+++ b/scripts/main.js
@@ -88,6 +88,10 @@ class VSpellPoints {
})
return unsupported;
}
+
+ static isV10() {
+ return !foundry.utils.isNewerVersion(10, game.version ?? game?.data?.version);
+ }
}
class VSpellPointsData {
@@ -681,11 +685,14 @@ Hooks.once('ready', () => {
if (!VSpellPointsData.isCharacter(actor) || !VSpellPointsData.isSpellcaster(actor)) return;
// only apply on spells that cost resources
+ let preparation = item?.system?.preparation;
+ if (!preparation) preparation = item?.data?.data?.preparation;
+
if (item?.data?.type !== "spell"
|| item?.labels?.level === "Cantrip"
- || item?.data?.data?.preparation?.mode === "atwill"
- || item?.data?.data?.preparation?.mode === "innate"
- || html.find("#ability-use-form").find(".form-group").find("select[name=level]").length === 0){
+ || preparation?.mode === "atwill"
+ || preparation?.mode === "innate"
+ || html.find("#ability-use-form").find(".form-group").find(VSpellPoints.isV10() ? "select[name=consumeSpellLevel]" : "select[name=level]").length === 0){
VSpellPoints.log("not using a resource spell")
return;
}
@@ -701,11 +708,11 @@ Hooks.once('ready', () => {
// change consume spell slot text
let consumeText = $(html)
.find("#ability-use-form")
- .find("input[name='consumeSlot']")
+ .find(VSpellPoints.isV10() ? "input[name='consumeSpellSlot']" : "input[name='consumeSlot']")
.parent()
.contents().filter(function () {
// get only text elements
- return this.nodeType === 3;
+ return (this.nodeType === 3 && (this.textContent?.trim().length > 0));
});
if (VSpellPointsData.isWarlock(actor))
@@ -716,7 +723,7 @@ Hooks.once('ready', () => {
// modify the "cast at level" list
$(html)
.find("#ability-use-form")
- .find("select[name='level']")
+ .find(VSpellPoints.isV10() ? "select[name=consumeSpellLevel]" : "select[name=level]")
.find("option")
.each(function (i) {
let spellValue = $(this).attr("value")