mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
* Restructured all the files * Moved build/daggerheart.js to ./daggerheart.js. Changed rollup to use the css file instead of the less * Restored build/ folder * Mvoed config out form under application * Moved roll.mjs to module/dice and renamed to dhRolls.mjs * Update module/canvas/placeables/_module.mjs Co-authored-by: joaquinpereyra98 <24190917+joaquinpereyra98@users.noreply.github.com> * Le massive export update * Removed unncessary import --------- Co-authored-by: joaquinpereyra98 <24190917+joaquinpereyra98@users.noreply.github.com>
40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
import { actionsTypes } from '../action/_module.mjs';
|
|
|
|
// Temporary Solution
|
|
export default class ActionField extends foundry.data.fields.ObjectField {
|
|
getModel(value) {
|
|
return actionsTypes[value.type] ?? 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);
|
|
}
|
|
}
|