mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-13 04:01:06 +01:00
Merge branch 'development' into lazjen/fix-template-enricher-deprecation-break
This commit is contained in:
commit
c4fe4d1409
92 changed files with 3295 additions and 584 deletions
|
|
@ -2,7 +2,7 @@ import autocomplete from 'autocompleter';
|
|||
|
||||
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
|
||||
|
||||
export default class AttriubtionDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
export default class AttributionDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
constructor(item) {
|
||||
super({});
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@ export default class AdversarySheet extends DHBaseActorSheet {
|
|||
position: { width: 660, height: 766 },
|
||||
window: { resizable: true },
|
||||
actions: {
|
||||
reactionRoll: AdversarySheet.#reactionRoll
|
||||
reactionRoll: AdversarySheet.#reactionRoll,
|
||||
toggleResourceDice: AdversarySheet.#toggleResourceDice,
|
||||
handleResourceDice: AdversarySheet.#handleResourceDice
|
||||
},
|
||||
window: {
|
||||
resizable: true,
|
||||
|
|
@ -173,6 +175,40 @@ export default class AdversarySheet extends DHBaseActorSheet {
|
|||
this.actor.diceRoll(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle the used state of a resource dice.
|
||||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static async #toggleResourceDice(event, target) {
|
||||
const item = await getDocFromElement(target);
|
||||
|
||||
const { dice } = event.target.closest('.item-resource').dataset;
|
||||
const diceState = item.system.resource.diceStates[dice];
|
||||
|
||||
await item.update({
|
||||
[`system.resource.diceStates.${dice}.used`]: diceState ? !diceState.used : true
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the roll values of resource dice.
|
||||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static async #handleResourceDice(_, target) {
|
||||
const item = await getDocFromElement(target);
|
||||
if (!item) return;
|
||||
|
||||
const rollValues = await game.system.api.applications.dialogs.ResourceDiceDialog.create(item, this.document);
|
||||
if (!rollValues) return;
|
||||
|
||||
await item.update({
|
||||
'system.resource.diceStates': rollValues.reduce((acc, state, index) => {
|
||||
acc[index] = { value: state.value, used: state.used };
|
||||
return acc;
|
||||
}, {})
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* Application Listener Actions */
|
||||
/* -------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { getDocFromElement } from '../../../helpers/utils.mjs';
|
||||
import DHBaseActorSheet from '../api/base-actor.mjs';
|
||||
|
||||
/**@typedef {import('@client/applications/_types.mjs').ApplicationClickAction} ApplicationClickAction */
|
||||
|
|
@ -20,7 +21,10 @@ export default class DhpEnvironment extends DHBaseActorSheet {
|
|||
}
|
||||
]
|
||||
},
|
||||
actions: {},
|
||||
actions: {
|
||||
toggleResourceDice: DhpEnvironment.#toggleResourceDice,
|
||||
handleResourceDice: DhpEnvironment.#handleResourceDice
|
||||
},
|
||||
dragDrop: [{ dragSelector: '.action-section .inventory-item', dropSelector: null }]
|
||||
};
|
||||
|
||||
|
|
@ -134,4 +138,44 @@ export default class DhpEnvironment extends DHBaseActorSheet {
|
|||
event.dataTransfer.setDragImage(item, 60, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* Application Clicks Actions */
|
||||
/* -------------------------------------------- */
|
||||
|
||||
|
||||
/**
|
||||
* Toggle the used state of a resource dice.
|
||||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static async #toggleResourceDice(event, target) {
|
||||
const item = await getDocFromElement(target);
|
||||
|
||||
const { dice } = event.target.closest('.item-resource').dataset;
|
||||
const diceState = item.system.resource.diceStates[dice];
|
||||
|
||||
await item.update({
|
||||
[`system.resource.diceStates.${dice}.used`]: diceState ? !diceState.used : true
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the roll values of resource dice.
|
||||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static async #handleResourceDice(_, target) {
|
||||
const item = await getDocFromElement(target);
|
||||
if (!item) return;
|
||||
|
||||
const rollValues = await game.system.api.applications.dialogs.ResourceDiceDialog.create(item, this.document);
|
||||
if (!rollValues) return;
|
||||
|
||||
await item.update({
|
||||
'system.resource.diceStates': rollValues.reduce((acc, state, index) => {
|
||||
acc[index] = { value: state.value, used: state.used };
|
||||
return acc;
|
||||
}, {})
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -166,26 +166,26 @@ export const healingTypes = {
|
|||
|
||||
export const defeatedConditions = () => {
|
||||
const defeated = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation).defeated;
|
||||
return {
|
||||
defeated: {
|
||||
id: 'defeated',
|
||||
name: 'DAGGERHEART.CONFIG.Condition.defeated.name',
|
||||
img: defeated.defeatedIcon,
|
||||
description: 'DAGGERHEART.CONFIG.Condition.defeated.description'
|
||||
},
|
||||
unconscious: {
|
||||
id: 'unconscious',
|
||||
name: 'DAGGERHEART.CONFIG.Condition.unconscious.name',
|
||||
img: defeated.unconsciousIcon,
|
||||
description: 'DAGGERHEART.CONFIG.Condition.unconscious.description'
|
||||
},
|
||||
dead: {
|
||||
id: 'dead',
|
||||
name: 'DAGGERHEART.CONFIG.Condition.dead.name',
|
||||
img: defeated.deadIcon,
|
||||
description: 'DAGGERHEART.CONFIG.Condition.dead.description'
|
||||
}
|
||||
};
|
||||
return Object.values(defeatedConditionChoices).map(x => ({
|
||||
...x,
|
||||
img: defeated[`${x.id}Icon`],
|
||||
description: `DAGGERHEART.CONFIG.Condition.${x.id}.description`
|
||||
}));
|
||||
};
|
||||
|
||||
const defeatedConditionChoices = {
|
||||
defeated: {
|
||||
id: 'defeated',
|
||||
name: 'DAGGERHEART.CONFIG.Condition.defeated.name'
|
||||
},
|
||||
unconscious: {
|
||||
id: 'unconscious',
|
||||
name: 'DAGGERHEART.CONFIG.Condition.unconscious.name'
|
||||
},
|
||||
dead: {
|
||||
id: 'dead',
|
||||
name: 'DAGGERHEART.CONFIG.Condition.dead.name'
|
||||
}
|
||||
};
|
||||
|
||||
export const conditions = () => ({
|
||||
|
|
|
|||
|
|
@ -68,19 +68,19 @@ export default class DhAutomation extends foundry.abstract.DataModel {
|
|||
}),
|
||||
characterDefault: new fields.StringField({
|
||||
required: true,
|
||||
choices: () => CONFIG.DH.GENERAL.defeatedConditions(),
|
||||
choices: CONFIG.DH.GENERAL.defeatedConditionChoices,
|
||||
initial: 'unconscious',
|
||||
label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.defeated.characterDefault.label'
|
||||
}),
|
||||
adversaryDefault: new fields.StringField({
|
||||
required: true,
|
||||
choices: () => CONFIG.DH.GENERAL.defeatedConditions(),
|
||||
choices: CONFIG.DH.GENERAL.defeatedConditionChoices,
|
||||
initial: 'defeated',
|
||||
label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.defeated.adversaryDefault.label'
|
||||
}),
|
||||
companionDefault: new fields.StringField({
|
||||
required: true,
|
||||
choices: () => CONFIG.DH.GENERAL.defeatedConditions(),
|
||||
choices: CONFIG.DH.GENERAL.defeatedConditionChoices,
|
||||
initial: 'defeated',
|
||||
label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.defeated.companionDefault.label'
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
export async function runMigrations() {
|
||||
let lastMigrationVersion = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LastMigrationVersion);
|
||||
if (!lastMigrationVersion) lastMigrationVersion = '1.0.6';
|
||||
if (!lastMigrationVersion) lastMigrationVersion = game.system.version;
|
||||
|
||||
if (foundry.utils.isNewerVersion('1.1.0', lastMigrationVersion)) {
|
||||
const lockedPacks = [];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue