Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial v12 Support #409

Merged
merged 11 commits into from
Jul 1, 2024
Merged
4 changes: 2 additions & 2 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ jobs:

strategy:
matrix:
node-version: [17.x]
node-version: [20.x]

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
Expand Down
7 changes: 6 additions & 1 deletion module/__mocks__/foundry.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,11 @@ global.ui = {
* Global helper functions function
*/

// Namespace for Foundry helper functions
global.foundry = {
utils: {}
}

// Foundry's implementation of getType
global.getType = function (token) {
const tof = typeof token
Expand Down Expand Up @@ -322,7 +327,7 @@ global.duplicate = function (original) {
}

// Foundry's implementation of mergeObject
global.mergeObject = function (original, other = {}, {
global.foundry.utils.mergeObject = function (original, other = {}, {
insertKeys = true,
insertValues = true,
overwrite = true,
Expand Down
1 change: 1 addition & 0 deletions module/__mocks__/roll.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const Roll = jest.fn((formula, data = {}) => {
dice: [{ results: [10], options: {} }],
toMessage: global.rollToMessageMock,
evaluate: global.rollEvaluateMock,
evaluateSync: global.rollEvaluateMock,
roll: global.rollEvaluateMock
}
}).mockName('Roll')
Expand Down
2 changes: 1 addition & 1 deletion module/__tests__/actor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ test('roll luck die', async () => {
expect(actorUpdateMock).toHaveBeenCalledTimes(1)
expect(actorUpdateMock).toHaveBeenCalledWith(
{
'data.abilities.lck.value': 17
'system.abilities.lck.value': 17
}
)
})
Expand Down
6 changes: 3 additions & 3 deletions module/actor-sheet.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global ActorSheet, CONFIG, duplicate, Dialog, TextEditor, game, mergeObject, expandObject, $, CONST */
/* global ActorSheet, CONFIG, duplicate, Dialog, TextEditor, game, foundry, expandObject, $, CONST */

import DCCActorConfig from './actor-config.js'
import EntityImages from './entity-images.js'
Expand All @@ -10,7 +10,7 @@ import EntityImages from './entity-images.js'
class DCCActorSheet extends ActorSheet {
/** @override */
static get defaultOptions () {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ['dcc', 'sheet', 'actor'],
template: 'systems/dcc/templates/actor-sheet-zero-level.html',
width: 600,
Expand All @@ -31,7 +31,7 @@ class DCCActorSheet extends ActorSheet {
const buttons = super._getHeaderButtons()

// Header buttons shown only with Owner permission
if (this.actor.permission === CONST.DOCUMENT_PERMISSION_LEVELS.OWNER) {
if (this.actor.permission === CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER) {
buttons.unshift(
{
label: game.i18n.localize('DCC.ConfigureSheet'),
Expand Down
77 changes: 43 additions & 34 deletions module/actor-sheets-dcc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global game */
/* global TextEditor, game */

/**
* DCC specific character sheet overrides
Expand All @@ -16,13 +16,14 @@ class DCCActorSheetCleric extends DCCActorSheet {
const data = await super.getData(options)
this.options.template = 'systems/dcc/templates/actor-sheet-cleric.html'
data.system.class.className = game.i18n.localize('DCC.Cleric')
data.system.class.classLink = await TextEditor.enrichHTML(game.i18n.localize('DCC.ClericClassLink'))

if (data.system.details.sheetClass !== 'Cleric') {
this.actor.update({
'data.class.className': game.i18n.localize('DCC.Cleric'),
'data.details.sheetClass': 'Cleric',
'data.class.spellCheckAbility': 'per',
'data.details.critRange': 20
'system.class.className': game.i18n.localize('DCC.Cleric'),
'system.details.sheetClass': 'Cleric',
'system.class.spellCheckAbility': 'per',
'system.details.critRange': 20
})
}

Expand All @@ -40,14 +41,15 @@ class DCCActorSheetThief extends DCCActorSheet {
const data = await super.getData(options)
this.options.template = 'systems/dcc/templates/actor-sheet-thief.html'
data.system.class.className = game.i18n.localize('DCC.Thief')
data.system.class.classLink = await TextEditor.enrichHTML(game.i18n.localize('DCC.ThiefClassLink'))

if (data.system.details.sheetClass !== 'Thief') {
this.actor.update({
'data.class.className': game.i18n.localize('DCC.Thief'),
'data.details.sheetClass': 'Thief',
'data.details.critRange': 20,
'data.class.disapproval': 1,
'data.details.showBackstab': true
'system.class.className': game.i18n.localize('DCC.Thief'),
'system.details.sheetClass': 'Thief',
'system.details.critRange': 20,
'system.class.disapproval': 1,
'system.details.showBackstab': true
})
}

Expand All @@ -65,13 +67,14 @@ class DCCActorSheetHalfling extends DCCActorSheet {
const data = await super.getData(options)
this.options.template = 'systems/dcc/templates/actor-sheet-halfling.html'
data.system.class.className = game.i18n.localize('DCC.Halfling')
data.system.class.classLink = await TextEditor.enrichHTML(game.i18n.localize('DCC.HalflingClassLink'))

if (data.system.details.sheetClass !== 'Halfling') {
this.actor.update({
'data.class.className': game.i18n.localize('DCC.Halfling'),
'data.details.sheetClass': 'Halfling',
'data.details.critRange': 20,
'data.class.disapproval': 1
'system.class.className': game.i18n.localize('DCC.Halfling'),
'system.details.sheetClass': 'Halfling',
'system.details.critRange': 20,
'system.class.disapproval': 1
})
}

Expand All @@ -89,13 +92,15 @@ class DCCActorSheetWarrior extends DCCActorSheet {
const data = await super.getData(options)
this.options.template = 'systems/dcc/templates/actor-sheet-warrior.html'
data.system.class.className = game.i18n.localize('DCC.Warrior')
data.system.class.classLink = await TextEditor.enrichHTML(game.i18n.localize('DCC.WarriorClassLink'))
data.system.class.mightyDeedsLink = await TextEditor.enrichHTML(game.i18n.localize('DCC.MightyDeedsLink'))

if (data.system.details.sheetClass !== 'Warrior') {
this.actor.update({
'data.class.className': game.i18n.localize('DCC.Warrior'),
'data.details.sheetClass': 'Warrior',
'data.class.disapproval': 1,
'data.config.attackBonusMode': 'manual'
'system.class.className': game.i18n.localize('DCC.Warrior'),
'system.details.sheetClass': 'Warrior',
'system.class.disapproval': 1,
'system.config.attackBonusMode': 'manual'
})
}

Expand All @@ -113,14 +118,15 @@ class DCCActorSheetWizard extends DCCActorSheet {
const data = await super.getData(options)
this.options.template = 'systems/dcc/templates/actor-sheet-wizard.html'
data.system.class.className = game.i18n.localize('DCC.Wizard')
data.system.class.classLink = await TextEditor.enrichHTML(game.i18n.localize('DCC.WizardClassLink'))

if (data.system.details.sheetClass !== 'Wizard') {
this.actor.update({
'data.class.className': game.i18n.localize('DCC.Wizard'),
'data.details.sheetClass': 'Wizard',
'data.class.spellCheckAbility': 'int',
'data.details.critRange': 20,
'data.class.disapproval': 1
'system.class.className': game.i18n.localize('DCC.Wizard'),
'system.details.sheetClass': 'Wizard',
'system.class.spellCheckAbility': 'int',
'system.details.critRange': 20,
'system.class.disapproval': 1
})
}

Expand All @@ -138,14 +144,16 @@ class DCCActorSheetDwarf extends DCCActorSheet {
const data = await super.getData(options)
this.options.template = 'systems/dcc/templates/actor-sheet-dwarf.html'
data.system.class.className = game.i18n.localize('DCC.Dwarf')
data.system.class.classLink = await TextEditor.enrichHTML(game.i18n.localize('DCC.DwarfClassLink'))
data.system.class.mightyDeedsLink = await TextEditor.enrichHTML(game.i18n.localize('DCC.MightyDeedsLink'))

if (data.system.details.sheetClass !== 'Dwarf') {
this.actor.update({
'data.class.className': game.i18n.localize('DCC.Dwarf'),
'data.details.sheetClass': 'Dwarf',
'data.class.disapproval': 1,
'data.config.attackBonusMode': 'manual',
'data.skills.shieldBash.useDeed': true
'system.class.className': game.i18n.localize('DCC.Dwarf'),
'system.details.sheetClass': 'Dwarf',
'system.class.disapproval': 1,
'system.config.attackBonusMode': 'manual',
'system.skills.shieldBash.useDeed': true
})
}

Expand All @@ -163,14 +171,15 @@ class DCCActorSheetElf extends DCCActorSheet {
const data = await super.getData(options)
this.options.template = 'systems/dcc/templates/actor-sheet-elf.html'
data.system.class.className = game.i18n.localize('DCC.Elf')
data.system.class.classLink = await TextEditor.enrichHTML(game.i18n.localize('DCC.ElfClassLink'))

if (data.system.details.sheetClass !== 'Elf') {
this.actor.update({
'data.class.className': game.i18n.localize('DCC.Elf'),
'data.details.sheetClass': 'Elf',
'data.class.spellCheckAbility': 'int',
'data.details.critRange': 20,
'data.class.disapproval': 1
'system.class.className': game.i18n.localize('DCC.Elf'),
'system.details.sheetClass': 'Elf',
'system.class.spellCheckAbility': 'int',
'system.details.critRange': 20,
'system.class.disapproval': 1
})
}

Expand All @@ -190,7 +199,7 @@ class DCCActorSheetGeneric extends DCCActorSheet {
data.system.class.className = game.i18n.localize('DCC.Generic')

this.actor.update({
'data.class.className': game.i18n.localize('DCC.Generic')
'system.class.className': game.i18n.localize('DCC.Generic')
})

return data
Expand Down
Loading