Skip to content

Commit 6d45719

Browse files
committed
Fixes for foundry v12.
1 parent 13574a6 commit 6d45719

33 files changed

+263
-148
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 4.0.0
2+
3+
- Foundry v12 compatibility.
4+
15
# 3.0.1
26

37
- Fix hub sheet defense rating not populating from frame.

module/actor/actor.js

+12-15
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,8 @@ import AddItemDialog from "../dialog/add-item-dialog.js";
33
import AttackDialog from "../dialog/attack-dialog.js";
44
import { diceSound, showDice } from "../dice.js";
55
import { regenerateCharacter, regenerateNpc } from "../generator.js";
6-
import {
7-
ITEMS_PACK,
8-
TABLES_PACK,
9-
documentFromPack,
10-
simpleData,
11-
tableFromPack,
12-
} from "../packutils.js";
6+
import { ITEMS_PACK, TABLES_PACK } from "../packs.js";
7+
import { documentFromPack, simpleData } from "../packutils.js";
138

149
/**
1510
* @extends {Actor}
@@ -41,7 +36,9 @@ export class DISActor extends Actor {
4136
vision: true,
4237
};
4338
}
44-
mergeObject(data.prototypeToken, defaults, { overwrite: false });
39+
foundry.utils.mergeObject(data.prototypeToken, defaults, {
40+
overwrite: false,
41+
});
4542
return super.create(data, options);
4643
}
4744

@@ -167,7 +164,7 @@ export class DISActor extends Actor {
167164
`${d20Formula} + @abilities.${ability}.value`,
168165
this.getRollData()
169166
);
170-
abilityRoll.evaluate({ async: false });
167+
await abilityRoll.evaluate();
171168
await showDice(abilityRoll);
172169

173170
const targetDR = 12;
@@ -296,7 +293,7 @@ export class DISActor extends Actor {
296293
`${d20Formula} + @abilities.${attackAbility}.value`,
297294
rollData
298295
);
299-
attackRoll.evaluate({ async: false });
296+
await attackRoll.evaluate();
300297
await showDice(attackRoll);
301298

302299
// use the active die result, in case of advantage/disadvantage
@@ -326,10 +323,10 @@ export class DISActor extends Actor {
326323
}
327324
damageText = `Damage: ${damageFormula}`;
328325
damageRoll = new Roll(damageFormula);
329-
damageRoll.evaluate({ async: false });
326+
await damageRoll.evaluate();
330327
// TODO: including crit die in max formula means crits are less likely to reduce target condition
331328
const maxDamageRoll = new Roll(damageFormula);
332-
maxDamageRoll.evaluate({ async: false, maximize: true });
329+
await maxDamageRoll.evaluate({ maximize: true });
333330
const isMaxDamage = damageRoll.total == maxDamageRoll.total;
334331
if (isMaxDamage) {
335332
maxDamageOutcome = game.i18n.localize("DIS.MaxDamageOutcome");
@@ -403,7 +400,7 @@ export class DISActor extends Actor {
403400
"Morale"
404401
)}`;
405402
const moraleRoll = new Roll("2d6");
406-
moraleRoll.evaluate({ async: false });
403+
await moraleRoll.evaluate();
407404
await showDice(moraleRoll);
408405
let moraleOutcome;
409406
if (moraleRoll.total > this.system.morale) {
@@ -433,7 +430,7 @@ export class DISActor extends Actor {
433430
const cardTitle = `${game.i18n.localize("Reaction")}`;
434431
const reactionText = "2D6";
435432
const reactionRoll = new Roll("2d6");
436-
reactionRoll.evaluate({ async: false });
433+
await reactionRoll.evaluate();
437434
await showDice(reactionRoll);
438435
let reactionOutcome;
439436
if (reactionRoll.total === 2) {
@@ -499,7 +496,7 @@ export class DISActor extends Actor {
499496
flavor: `${game.i18n.localize("DIS.VoidCorruption")}?`,
500497
});
501498
if (roll.total <= this.system.voidPoints.value) {
502-
const table = await tableFromPack(TABLES_PACK, "Void Corruption");
499+
const table = await documentFromPack(TABLES_PACK, "Void Corruption");
503500
await table.draw();
504501
}
505502
}

module/actor/sheet/character-sheet.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import DISActorSheet from "./actor-sheet.js";
66
export class DISCharacterSheet extends DISActorSheet {
77
/** @override */
88
static get defaultOptions() {
9-
return mergeObject(super.defaultOptions, {
9+
return foundry.utils.mergeObject(super.defaultOptions, {
1010
classes: ["deathinspace", "sheet", "actor", "character"],
1111
template: "systems/deathinspace/templates/actor/character-sheet.html",
1212
width: 730,
@@ -33,8 +33,8 @@ export class DISCharacterSheet extends DISActorSheet {
3333
}
3434

3535
/** @override */
36-
getData() {
37-
const superData = super.getData();
36+
async getData() {
37+
const superData = await super.getData();
3838
const data = superData.data;
3939
data.config = CONFIG.DIS;
4040
this.prepareCharacterItems(data);

module/actor/sheet/hub-sheet.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import DISActorSheet from "./actor-sheet.js";
66
export class DISHubSheet extends DISActorSheet {
77
/** @override */
88
static get defaultOptions() {
9-
return mergeObject(super.defaultOptions, {
9+
return foundry.utils.mergeObject(super.defaultOptions, {
1010
classes: ["deathinspace", "sheet", "actor", "hub"],
1111
template: "systems/deathinspace/templates/actor/hub-sheet.html",
1212
width: 730,
@@ -28,8 +28,8 @@ export class DISHubSheet extends DISActorSheet {
2828
}
2929

3030
/** @override */
31-
getData() {
32-
const superData = super.getData();
31+
async getData() {
32+
const superData = await super.getData();
3333
const data = superData.data;
3434
const byName = (a, b) => (a.name > b.name ? 1 : b.name > a.name ? -1 : 0);
3535
data.system.frame = data.items

module/actor/sheet/npc-sheet.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import DISActorSheet from "./actor-sheet.js";
66
export class DISNpcSheet extends DISActorSheet {
77
/** @override */
88
static get defaultOptions() {
9-
return mergeObject(super.defaultOptions, {
9+
return foundry.utils.mergeObject(super.defaultOptions, {
1010
classes: ["deathinspace", "sheet", "actor", "npc"],
1111
template: "systems/deathinspace/templates/actor/npc-sheet.html",
1212
width: 730,
@@ -37,8 +37,8 @@ export class DISNpcSheet extends DISActorSheet {
3737
}
3838

3939
/** @override */
40-
getData() {
41-
const superData = super.getData();
40+
async getData() {
41+
const superData = await super.getData();
4242
const data = superData.data;
4343
data.config = CONFIG.DIS;
4444
this.prepareNpcItems(data);

module/dice.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
/**
22
* Add a show-dice promise to the given array if Dice So Nice is available.
33
*/
4-
export const addShowDicePromise = (promises, roll) => {
4+
export function addShowDicePromise(promises, roll) {
55
if (game.dice3d) {
66
// we pass synchronize=true so DSN dice appear on all players' screens
77
promises.push(game.dice3d.showForRoll(roll, game.user, true, null, false));
88
}
9-
};
9+
}
1010

1111
/**
1212
* Show roll in Dice So Nice if it's available.
1313
*/
14-
export const showDice = async (roll) => {
14+
export async function showDice(roll) {
1515
if (game.dice3d) {
1616
// we pass synchronize=true so DSN dice appear on all players' screens
1717
await game.dice3d.showForRoll(roll, game.user, true, null, false);
1818
}
19-
};
19+
}
2020

2121
/**
2222
* Dice sound to use for ChatMessage.
2323
* False if Dice So Nice is available.
2424
*/
25-
export const diceSound = () => {
25+
export function diceSound() {
2626
if (game.dice3d) {
2727
// let Dice So Nice do it
2828
return null;
2929
} else {
3030
return CONFIG.sounds.dice;
3131
}
32-
};
32+
}

0 commit comments

Comments
 (0)