mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 11:41:08 +01:00
* cleanup * test * Step 1 * #2 * Fix Effect Action & Add Hope tumation settings to hook * remove circular dependency * Snuck in some localization fixes I noticed * Remove success condition for duality roll gain * Changed config.roll.type logic --------- Co-authored-by: WBHarry <williambjrklund@gmail.com>
37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
export default class ActionField extends foundry.data.fields.ObjectField {
|
|
getModel(value) {
|
|
return game.system.api.models.actions.actionsTypes[value.type] ?? game.system.api.models.actions.actionsTypes.attack;
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/** @override */
|
|
_cleanType(value, options) {
|
|
if (!(typeof value === 'object')) value = {};
|
|
|
|
const cls = this.getModel(value);
|
|
if (cls) return cls.cleanData(value, options);
|
|
return value;
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/** @override */
|
|
initialize(value, model, options = {}) {
|
|
const cls = this.getModel(value);
|
|
if (cls) return new cls(value, { parent: model, ...options });
|
|
return foundry.utils.deepClone(value);
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/**
|
|
* Migrate this field's candidate source data.
|
|
* @param {object} sourceData Candidate source data of the root model.
|
|
* @param {any} fieldData The value of this field within the source data.
|
|
*/
|
|
migrateSource(sourceData, fieldData) {
|
|
const cls = this.getModel(fieldData);
|
|
if (cls) cls.migrateDataSafe(fieldData);
|
|
}
|
|
}
|