Skip to content

Commit

Permalink
Merge branch 'release/v1.5.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
mattd committed Jul 27, 2022
2 parents 14085d4 + 8488eb0 commit b7f0cde
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 40 deletions.
4 changes: 2 additions & 2 deletions module/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.3/build.zip",
"version": "1.5.3",
"download": "https://github.com/mattd/foundryvtt-progress-clocks/releases/download/v1.5.4/build.zip",
"version": "1.5.4",
"minimumCoreVersion": "0.7.0",
"compatibleCoreVersion": "10",
"compatibility": {
Expand Down
10 changes: 0 additions & 10 deletions module/scripts/clock.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,6 @@ export class Clock {
this.theme = theme || 'wallflower_green';
}

get flags () {
return {
clocks: {
size: this.size,
progress: this.progress,
theme: this.theme
}
};
}

increment () {
const old = this;
return new Clock({
Expand Down
26 changes: 10 additions & 16 deletions module/scripts/sheet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -140,24 +140,18 @@ export class ClockSheet extends ActorSheet {

// Update the tokens
for (const token of tokens) {
const tokenData = {
name: actor.name,
img: (
`/${Clock.themes[clock.theme]}` +
`/${clock.size}clock_${clock.progress}.png`
),
actorLink: true
};
if (foundryVersion.major >= 8) {
await token.document.update({
name: actor.name,
img: (
`/${Clock.themes[clock.theme]}` +
`/${clock.size}clock_${clock.progress}.png`
),
actorLink: true
});
await token.document.update(tokenData);
} else {
await token.update({
name: actor.name,
img: (
`/${Clock.themes[clock.theme]}` +
`/${clock.size}clock_${clock.progress}.png`
),
actorLink: true
});
await token.update(tokenData);
};
}

Expand Down
10 changes: 1 addition & 9 deletions module/scripts/systems/dnd5e.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
export default {
registerSheetOptions: { types: ["npc"] },

loadClockFromActor: ({ actor }) => {
return {
progress: actor.getFlag("clocks", "progress"),
size: actor.getFlag("clocks", "size"),
theme: actor.getFlag("clocks", "theme")
};
},

persistClockToActor: ({ clock }) => {
return {
data: {
Expand All @@ -20,7 +12,7 @@ export default {
}
},
flags: {
clocks: {
"progress-clocks": {
progress: clock.progress,
size: clock.size,
theme: clock.theme,
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "foundryvtt-progress-clocks",
"version": "1.5.3",
"version": "1.5.4",
"description": "Brings Forged in the Dark style progress clocks to your FoundryVTT games.",
"main": "module/scripts/init.mjs",
"scripts": {
Expand Down
41 changes: 41 additions & 0 deletions test/clock/constructor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,44 @@ test("sets a default theme when none is provided", t => {
const clock = new Clock();
t.assert(clock.theme);
});

test("sets size to a supported size if supplied an unsupported size", t => {
const size = 1;
const clock = new Clock({
size: size
});
t.assert(Clock.sizes.indexOf(parseInt(size)) == -1);
t.assert(Clock.sizes.indexOf(parseInt(clock.size)) >= 0);
});

test("sets a default size when none is provided", t=> {
const clock = new Clock();
t.assert(clock.size);
});

test("sets the correct progress when provided", t => {
const clock = new Clock({
progress: 2
});
t.is(clock.progress, 2);
});

test("sets progress equal to size if progress is larger than size", t=> {
const clock = new Clock({
size: 8,
progress: 9
});
t.is(clock.progress, 8);
})

test("sets progress to zero if no progress is provided", t => {
const clock = new Clock();
t.is(clock.progress, 0);
})

test("sets progress to zero if provided progress is less than zero", t => {
const clock = new Clock({
progress: -1
});
t.is(clock.progress, 0);
});
38 changes: 38 additions & 0 deletions test/clock/decrement.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import test from 'ava';

import { Clock } from "../../module/scripts/clock.mjs";

test("returns a new Clock object", t => {
const oldClock = new Clock({
progress: 1
});
const newClock = oldClock.decrement();
t.assert(newClock instanceof Clock);
t.not(newClock, oldClock);
});

test("decrements the previous progress by 1", t => {
const oldClock = new Clock({
progress: 1
});
const newClock = oldClock.decrement();
t.is(newClock.progress, 0);
});

test("does not alter the previous size", t => {
const oldClock = new Clock({
size: 4,
progress: 1
});
const newClock = oldClock.decrement();
t.is(newClock.size, 4);
});

test("does not alter the previous theme", t => {
const oldClock = new Clock({
theme: 'gms_red',
progress: 1
});
const newClock = oldClock.decrement();
t.is(newClock.theme, 'gms_red');
});
38 changes: 38 additions & 0 deletions test/clock/increment.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import test from 'ava';

import { Clock } from "../../module/scripts/clock.mjs";

test("returns a new Clock object", t => {
const oldClock = new Clock({
progress: 1
});
const newClock = oldClock.increment();
t.assert(newClock instanceof Clock);
t.not(newClock, oldClock);
});

test("increments the previous progress by 1", t => {
const oldClock = new Clock({
progress: 1
});
const newClock = oldClock.increment();
t.is(newClock.progress, 2);
});

test("does not alter the previous size", t => {
const oldClock = new Clock({
size: 4,
progress: 1
});
const newClock = oldClock.increment();
t.is(newClock.size, 4);
});

test("does not alter the previous theme", t => {
const oldClock = new Clock({
theme: 'gms_red',
progress: 1
});
const newClock = oldClock.increment();
t.is(newClock.theme, 'gms_red');
});

0 comments on commit b7f0cde

Please sign in to comment.