From a88090a0004180d12cf5aecfebef88ab8907bfbd Mon Sep 17 00:00:00 2001 From: Matt Dawson Date: Sat, 16 Jul 2022 22:24:49 -0400 Subject: [PATCH 1/5] Make method and variable names more explicit --- module/scripts/sheet.mjs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/module/scripts/sheet.mjs b/module/scripts/sheet.mjs index 5b83a05..8fb6578 100644 --- a/module/scripts/sheet.mjs +++ b/module/scripts/sheet.mjs @@ -87,7 +87,7 @@ export class ClockSheet extends ActorSheet { actor: this.actor }) ); - this.updateClock(oldClock.decrement()); + this.updateActorAndTokens(oldClock.decrement()); }); html.find("button[name=plus]").click(async (e) => { @@ -97,7 +97,7 @@ export class ClockSheet extends ActorSheet { actor: this.actor }) ); - this.updateClock(oldClock.increment()); + this.updateActorAndTokens(oldClock.increment()); }); html.find("button[name=reset]").click(async (e) => { @@ -112,7 +112,7 @@ export class ClockSheet extends ActorSheet { progress: 0, size: oldClock.size }); - this.updateClock(newClock); + this.updateActorAndTokens(newClock); }); } @@ -130,10 +130,10 @@ export class ClockSheet extends ActorSheet { size: form.size, theme: form.theme }); - await this.updateClock(newClock); + await this.updateActorAndTokens(newClock); } - async updateClock(clock) { + async updateActorAndTokens(clock) { const actor = this.actor; const tokens = actor.getActiveTokens(); const foundryVersion = getFoundryVersion(game); @@ -162,7 +162,7 @@ export class ClockSheet extends ActorSheet { } // Update the Actor - const persistObj = await this.system.persistClockToActor({ + const persistedObj = await this.system.persistClockToActor({ actor, clock }); const visualObj = { @@ -178,6 +178,6 @@ export class ClockSheet extends ActorSheet { ...DEFAULT_TOKEN } }; - await actor.update(mergeObject(visualObj, persistObj)); + await actor.update(mergeObject(visualObj, persistedObj)); } } From dd7dd286b16612194cff617a297689510fd3b178 Mon Sep 17 00:00:00 2001 From: Matt Dawson Date: Sat, 16 Jul 2022 22:25:00 -0400 Subject: [PATCH 2/5] Minor template tweaks --- module/templates/sheet.html | 116 +++++++++++++++++++----------------- 1 file changed, 60 insertions(+), 56 deletions(-) diff --git a/module/templates/sheet.html b/module/templates/sheet.html index c63fc15..a591d5a 100644 --- a/module/templates/sheet.html +++ b/module/templates/sheet.html @@ -1,63 +1,67 @@
- {{#if editable}} -
- -
- {{else}} -
- -
- {{/if}} - {{#if editable}} -
- {{#if (lte clock.progress 0)}} - + {{#if editable}} +
+ +
{{else}} - +
+ +
{{/if}} - - {{#if (gte clock.progress clock.size)}} - - {{else}} - + {{#if editable}} +
+ {{#if (lte clock.progress 0)}} + + {{else}} + + {{/if}} + + {{#if (gte clock.progress clock.size)}} + + {{else}} + + {{/if}} +
{{/if}} -
- {{/if}} -
- -
- {{#if editable}} -
-
- - +
+
-
- - + {{#if editable}} +
+
+ + {{#select clock.theme}} + + {{/select}} +
+
+ + {{#select clock.size}} + + {{/select}} +
-
- {{/if}} + {{/if}} From ae9a4925a136b0d12ac41f916d366e58de4f6700 Mon Sep 17 00:00:00 2001 From: Matt Dawson Date: Sat, 16 Jul 2022 22:30:48 -0400 Subject: [PATCH 3/5] Revert variable name change --- module/scripts/sheet.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/scripts/sheet.mjs b/module/scripts/sheet.mjs index 8fb6578..55d198d 100644 --- a/module/scripts/sheet.mjs +++ b/module/scripts/sheet.mjs @@ -162,7 +162,7 @@ export class ClockSheet extends ActorSheet { } // Update the Actor - const persistedObj = await this.system.persistClockToActor({ + const persistObj = await this.system.persistClockToActor({ actor, clock }); const visualObj = { @@ -178,6 +178,6 @@ export class ClockSheet extends ActorSheet { ...DEFAULT_TOKEN } }; - await actor.update(mergeObject(visualObj, persistedObj)); + await actor.update(mergeObject(visualObj, persistObj)); } } From 4acc1428f4398096df1b51b943f25880356784cd Mon Sep 17 00:00:00 2001 From: Matt Dawson Date: Sun, 17 Jul 2022 15:37:11 -0400 Subject: [PATCH 4/5] Remove unused code --- module/scripts/clock.mjs | 24 ------------------------ module/templates/buttons.html | 15 --------------- 2 files changed, 39 deletions(-) delete mode 100644 module/templates/buttons.html diff --git a/module/scripts/clock.mjs b/module/scripts/clock.mjs index 3205420..dccca5c 100644 --- a/module/scripts/clock.mjs +++ b/module/scripts/clock.mjs @@ -1,8 +1,3 @@ -const nextIndexInArray = (arr, el) => { - const idx = arr.indexOf(el); - return (idx < 0 || idx >= arr.length) ? 0 : idx + 1; -} - export class Clock { static sizes = [ 2, 3, 4, 5, 6, 8, 10, 12 @@ -48,14 +43,6 @@ export class Clock { }; } - cycleSize () { - return new Clock({ - size: Clock.sizes[nextIndexInArray(Clock.sizes, this.size)], - progress: this.progress, - theme: this.theme - }); - } - increment () { const old = this; return new Clock({ @@ -73,15 +60,4 @@ export class Clock { theme: old.theme }); } - - isEqual (clock) { - return clock - && clock.size === this.size - && clock.progress === this.progress - && clock.theme === this.theme; - } - - toString () { - return `${this.progress}/${this.size} • ${this.theme}`; - } } diff --git a/module/templates/buttons.html b/module/templates/buttons.html deleted file mode 100644 index fe7a4cd..0000000 --- a/module/templates/buttons.html +++ /dev/null @@ -1,15 +0,0 @@ -
- -
- - - -
- -
- -
- -
From d0823b2c3caada7a09d9886a3c7ee2d48c4deda1 Mon Sep 17 00:00:00 2001 From: Matt Dawson Date: Sun, 17 Jul 2022 15:40:05 -0400 Subject: [PATCH 5/5] Bump version --- module/module.json | 4 ++-- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/module/module.json b/module/module.json index c558b47..0dbcc1e 100644 --- a/module/module.json +++ b/module/module.json @@ -5,8 +5,8 @@ "author": "troygoode, Argonius-Angelus, mattd", "url": "https://github.com/mattd/foundryvtt-progress-clocks", "manifest": "https://raw.githubusercontent.com/mattd/foundryvtt-progress-clocks/main/module/module.json", - "download": "https://github.com/mattd/foundryvtt-progress-clocks/releases/download/v1.5.2/build.zip", - "version": "1.5.2", + "download": "https://github.com/mattd/foundryvtt-progress-clocks/releases/download/v1.5.3/build.zip", + "version": "1.5.3", "minimumCoreVersion": "0.7.0", "compatibleCoreVersion": "10", "compatibility": { diff --git a/package-lock.json b/package-lock.json index d1ffe73..a7cd8b0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "foundryvtt-progress-clocks", - "version": "1.5.2", + "version": "1.5.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "foundryvtt-progress-clocks", - "version": "1.5.2", + "version": "1.5.3", "license": "MIT", "devDependencies": { "ava": "^4.3.1" diff --git a/package.json b/package.json index c2a39db..a34b60a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "foundryvtt-progress-clocks", - "version": "1.5.2", + "version": "1.5.3", "description": "Brings Forged in the Dark style progress clocks to your FoundryVTT games.", "main": "module/scripts/init.mjs", "scripts": {