mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-13 04:01:06 +01:00
* Create new actions classes * actions types - attack roll * fixes before merge * First PR * Add daggerheart.css to gitignore * Update ToDo * Remove console log * Fixed chat /dr roll * Remove jQuery * Fixed so the different chat themes work again * Fixed duality roll buttons * Fix to advantage/disadvantage shortcut * Extand action to other item types * Roll fixes * Fixes to adversary rolls * resources * Fixed adversary dice --------- Co-authored-by: WBHarry <williambjrklund@gmail.com>
41 lines
No EOL
1.2 KiB
JavaScript
41 lines
No EOL
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);
|
|
}
|
|
} |