Skip to content

Commit f2029c4

Browse files
authored
Merge pull request #517 from arcos/v12compat
v12 compatibility fixes
2 parents 339b156 + a28863d commit f2029c4

25 files changed

+65
-46
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
node_modules
22
foundryconfig.json
3+
foundryconfig_*.json
4+
ose-dev.lock
35
dist
46
.DS_Store
57
.env

src/module/actor/__tests__/data-model-character.test.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,22 @@ export default ({ describe, it, expect, after, before }: QuenchMethods) => {
1919
const dataModel = new OseDataModelCharacter();
2020
const ascendingACSetting = game.settings.get(game.system.id, "ascendingAC");
2121
const initiativeSetting = game.settings.get(game.system.id, "initiative");
22+
const encumbranceSetting = game.settings.get(
23+
game.system.id,
24+
"encumbranceOption"
25+
);
2226

2327
after(() => {
2428
game.settings.set(game.system.id, "ascendingAC", ascendingACSetting);
2529
game.settings.set(game.system.id, "initiative", initiativeSetting);
30+
game.settings.set(game.system.id, "encumbranceOption", encumbranceSetting);
2631
cleanUpActorsByKey(key);
2732
});
2833

2934
// @todo: Can this be tested without creating an actor?
3035
describe("prepareDerivedData()", () => {
3136
before(async () => {
37+
await game.settings.set(game.system.id, "encumbranceOption", "detailed");
3238
await createMockActor();
3339
});
3440

@@ -60,9 +66,9 @@ export default ({ describe, it, expect, after, before }: QuenchMethods) => {
6066
expect(actor?.system.encumbrance.steps).not.undefined;
6167
expect(actor?.system.encumbrance.value).not.undefined;
6268
expect(actor?.system.encumbrance.max).not.undefined;
63-
expect(actor?.system.encumbrance.atHalfEncumbered).not.undefined;
64-
expect(actor?.system.encumbrance.atQuarterEncumbered).not.undefined;
65-
expect(actor?.system.encumbrance.atEighthEncumbered).not.undefined;
69+
expect(actor?.system.encumbrance.steps).not.undefined;
70+
//expect(actor?.system.encumbrance.atQuarterEncumbered).not.undefined;
71+
//expect(actor?.system.encumbrance.atEighthEncumbered).not.undefined;
6672
});
6773

6874
it("has movement", async () => {

src/module/actor/character-sheet.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export default class OseActorSheetCharacter extends OseActorSheet {
8080
*/
8181
async getData() {
8282
const data = super.getData();
83+
8384
// Prepare owned items
8485
this._prepareItems(data);
8586

@@ -241,6 +242,7 @@ export default class OseActorSheetCharacter extends OseActorSheet {
241242
equipped: !item.system.equipped,
242243
},
243244
});
245+
244246
});
245247

246248
html.find("a[data-action='generate-scores']").click((ev) => {

src/module/actor/data-model-character.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const getItemsOfActorOfType = (actor, filterType, filterFn = null) =>
1111
.filter(({ type }) => type === filterType)
1212
.filter(filterFn || (() => true));
1313

14-
export default class OseDataModelCharacter extends foundry.abstract.DataModel {
14+
export default class OseDataModelCharacter extends foundry.abstract.TypeDataModel {
1515
prepareDerivedData() {
1616
this.scores = new OseDataModelCharacterScores(this.scores);
1717

src/module/actor/data-model-classes/__tests__/data-model-character-encumbrance.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const options = {
1515
};
1616

1717
const toPct = (value: number, max: number) =>
18-
Math.clamped((100 * value) / max, 0, 100);
18+
Math.clamp((100 * value) / max, 0, 100);
1919
const createMockItem = (
2020
type: string,
2121
weight: number,

src/module/actor/data-model-classes/data-model-character-encumbrance-item-based.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export default class OseDataModelCharacterEncumbranceItemBased
6161

6262
#packedWeight;
6363

64+
// eslint-disable-next-line sonarjs/cognitive-complexity, @typescript-eslint/no-unused-vars
6465
constructor(max = 16, items: Item[] = []) {
6566
super(OseDataModelCharacterEncumbranceItemBased.type, max);
6667

@@ -90,22 +91,13 @@ export default class OseDataModelCharacterEncumbranceItemBased
9091
0
9192
)
9293
);
93-
this.#weight = this.usingEquippedEncumbrance
94-
? this.#equippedWeight
95-
: this.#packedWeight;
96-
97-
this.#max = this.usingEquippedEncumbrance
98-
? this.#equippedMax
99-
: this.#packedMax;
100-
10194
this.#atFiveEighths = this.#weight > this.#max * (OseDataModelCharacterEncumbranceItemBased.packedEncumbranceSteps.fiveEighths / 100);
10295
this.#atThreeQuarters = this.#weight > this.#max * (OseDataModelCharacterEncumbranceItemBased.packedEncumbranceSteps.threeQuarters / 100);
10396
this.#atSevenEights = this.#weight > this.#max * (OseDataModelCharacterEncumbranceItemBased.packedEncumbranceSteps.sevenEighths / 100);
104-
97+
10598
this.#atOneThird = this.#weight > this.#max * (OseDataModelCharacterEncumbranceItemBased.equippedEncumbranceSteps.oneThird / 100);
10699
this.#atFiveNinths = this.#weight > this.#max * (OseDataModelCharacterEncumbranceItemBased.equippedEncumbranceSteps.fiveNinths / 100);
107100
this.#atSevenNinths = this.#weight > this.#max * (OseDataModelCharacterEncumbranceItemBased.equippedEncumbranceSteps.sevenNinths / 100);
108-
109101
}
110102

111103
// eslint-disable-next-line class-methods-use-this
@@ -130,9 +122,9 @@ export default class OseDataModelCharacterEncumbranceItemBased
130122
(step) => step > (this.#equippedWeight / this.#equippedMax) * 100
131123
);
132124
equippedIndex = equippedIndex === -1 ? 4 : equippedIndex;
125+
133126
let packedIndex = packedValues.findIndex(
134-
(step) => step > (this.#packedWeight / this.#packedMax) * 100
135-
);
127+
(step) => step > (this.#packedWeight / this.#packedMax) * 100);
136128
packedIndex = packedIndex === -1 ? 4 : packedIndex;
137129
return !!(equippedIndex >= packedIndex);
138130
}

src/module/actor/data-model-classes/data-model-character-encumbrance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export default class OseDataModelCharacterEncumbrance
5959
}
6060

6161
get pct() {
62-
return Math.clamped((100 * this.value) / this.max, 0, 100);
62+
return Math.clamp((100 * this.value) / this.max, 0, 100);
6363
}
6464

6565
get encumbered() {

src/module/actor/data-model-monster.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const getItemsOfActorOfType = (actor, filterType, filterFn = null) =>
1111
.filter(({ type }) => type === filterType)
1212
.filter(filterFn || (() => true));
1313

14-
export default class OseDataModelMonster extends foundry.abstract.DataModel {
14+
export default class OseDataModelMonster extends foundry.abstract.TypeDataModel {
1515
prepareDerivedData() {
1616
this.encumbrance = new OseDataModelCharacterEncumbranceDisabled();
1717
this.spells = new OseDataModelCharacterSpells(this.spells, this.#spellList);

src/module/actor/entity.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ export default class OseActor extends Actor {
4242
"system.thac0.bba": bbaValue,
4343
"system.thac0.value": thac0Value,
4444
} = newData;
45-
4645
// Compute AAC from AC
4746
if (acValue) {
4847
newData["system.aac.value"] = 19 - acValue;
@@ -317,6 +316,7 @@ export default class OseActor extends Actor {
317316

318317
const label = game.i18n.localize(`OSE.roll.hd`);
319318
const rollParts = [actorData.hp.hd];
319+
320320
if (actorType === "character") {
321321
rollParts.push(actorData.scores.con.mod * actorData.details.level);
322322
}
@@ -550,7 +550,7 @@ export default class OseActor extends Actor {
550550

551551
// Update the Actor
552552
return this.update({
553-
"system.hp.value": Math.clamped(value - amount, 0, max),
553+
"system.hp.value": Math.clamp(value - amount, 0, max),
554554
});
555555
}
556556
}

src/module/actor/monster-sheet.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export default class OseActorSheetMonster extends OseActorSheet {
6969
);
7070
data.isNew = this.actor.isNew();
7171

72-
if (isNewerVersion(game.version, "10.264")) {
72+
if (foundry.utils.isNewerVersion(game.version, "10.264")) {
7373
data.enrichedBiography = await TextEditor.enrichHTML(
7474
this.object.system.details.biography,
7575
{ async: true }

0 commit comments

Comments
 (0)