mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 11:41:08 +01:00
FEAT: formatting code
FIX: fix fields used FEAT: add jsdoc
This commit is contained in:
parent
6c147a5c00
commit
f3942280b6
13 changed files with 96 additions and 114 deletions
|
|
@ -2,9 +2,8 @@ export default class DaggerheartAction extends foundry.abstract.DataModel {
|
||||||
static defineSchema() {
|
static defineSchema() {
|
||||||
const fields = foundry.data.fields;
|
const fields = foundry.data.fields;
|
||||||
return {
|
return {
|
||||||
id: new fields.StringField({}),
|
id: new fields.DocumentIdField(),
|
||||||
name: new fields.StringField({ initial: 'New Action' }),
|
name: new fields.StringField({ initial: 'New Action' }),
|
||||||
img: new fields.StringField({ initial: '' }),
|
|
||||||
damage: new fields.SchemaField({
|
damage: new fields.SchemaField({
|
||||||
type: new fields.StringField({ choices: SYSTEM.GENERAL.damageTypes, nullable: true, initial: null }),
|
type: new fields.StringField({ choices: SYSTEM.GENERAL.damageTypes, nullable: true, initial: null }),
|
||||||
value: new fields.StringField({})
|
value: new fields.StringField({})
|
||||||
|
|
@ -30,15 +29,6 @@ export default class DaggerheartAction extends foundry.abstract.DataModel {
|
||||||
initial: SYSTEM.ACTIONS.targetTypes.other.id
|
initial: SYSTEM.ACTIONS.targetTypes.other.id
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
// uses: new fields.SchemaField({
|
|
||||||
// nr: new fields.StringField({}),
|
|
||||||
// refreshType: new fields.StringField({ choices: SYSTEM.GENERAL.refreshTypes, initial: SYSTEM.GENERAL.refreshTypes.session.id }),
|
|
||||||
// refreshed: new fields.BooleanField({ initial: true }),
|
|
||||||
// }),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
use = async () => {
|
|
||||||
console.log('Test Use');
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
export { default as FormulaField } from "./formulaField.mjs";
|
export { default as FormulaField } from "./formulaField.mjs";
|
||||||
export {default as ForeignDocumentUUIDField} from "./foreignDocumentUUIDField.mjs";
|
export { default as ForeignDocumentUUIDField } from "./foreignDocumentUUIDField.mjs";
|
||||||
|
|
@ -3,6 +3,15 @@
|
||||||
* that resolves to either the document, the index(for items in compenidums) or the UUID string.
|
* that resolves to either the document, the index(for items in compenidums) or the UUID string.
|
||||||
*/
|
*/
|
||||||
export default class ForeignDocumentUUIDField extends foundry.data.fields.DocumentUUIDField {
|
export default class ForeignDocumentUUIDField extends foundry.data.fields.DocumentUUIDField {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {foundry.data.types.DocumentUUIDFieldOptions} [options] Options which configure the behavior of the field
|
||||||
|
* @param {foundry.data.types.DataFieldContext} [context] Additional context which describes the field
|
||||||
|
*/
|
||||||
|
constructor(options, context) {
|
||||||
|
super(options, context);
|
||||||
|
}
|
||||||
|
|
||||||
/** @inheritdoc */
|
/** @inheritdoc */
|
||||||
static get _defaults() {
|
static get _defaults() {
|
||||||
return foundry.utils.mergeObject(super._defaults, {
|
return foundry.utils.mergeObject(super._defaults, {
|
||||||
|
|
@ -25,6 +34,7 @@ export default class ForeignDocumentUUIDField extends foundry.data.fields.Docume
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**@override */
|
/**@override */
|
||||||
toObject(value) {
|
toObject(value) {
|
||||||
return value?.uuid ?? value;
|
return value?.uuid ?? value;
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,30 @@
|
||||||
/**
|
/**
|
||||||
* @typedef {StringFieldOptions} FormulaFieldOptions
|
* @typedef {foundry.data.types.StringFieldOptions} StringFieldOptions
|
||||||
* @property {boolean} [deterministic=false] Is this formula not allowed to have dice values?
|
* @typedef {foundry.data.types.DataFieldContext} DataFieldContext
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef _FormulaFieldOptions
|
||||||
|
* @property {boolean} [deterministic] - Is this formula not allowed to have dice values?
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {StringFieldOptions & _FormulaFieldOptions} FormulaFieldOptions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Special case StringField which represents a formula.
|
* Special case StringField which represents a formula.
|
||||||
*
|
|
||||||
* @param {FormulaFieldOptions} [options={}] Options which configure the behavior of the field.
|
|
||||||
* @property {boolean} deterministic=false Is this formula not allowed to have dice values?
|
|
||||||
*/
|
*/
|
||||||
export default class FormulaField extends foundry.data.fields.StringField {
|
export default class FormulaField extends foundry.data.fields.StringField {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {FormulaFieldOptions} [options] - Options which configure the behavior of the field
|
||||||
|
* @param {foundry.data.types.DataFieldContext} [context] - Additional context which describes the field
|
||||||
|
*/
|
||||||
|
constructor(options, context) {
|
||||||
|
super(options, context);
|
||||||
|
}
|
||||||
|
|
||||||
/** @inheritDoc */
|
/** @inheritDoc */
|
||||||
static get _defaults() {
|
static get _defaults() {
|
||||||
return foundry.utils.mergeObject(super._defaults, {
|
return foundry.utils.mergeObject(super._defaults, {
|
||||||
|
|
@ -24,7 +38,7 @@ export default class FormulaField extends foundry.data.fields.StringField {
|
||||||
_validateType(value) {
|
_validateType(value) {
|
||||||
const roll = new Roll(value.replace(/@([a-z.0-9_-]+)/gi, "1"));
|
const roll = new Roll(value.replace(/@([a-z.0-9_-]+)/gi, "1"));
|
||||||
roll.evaluateSync({ strict: false });
|
roll.evaluateSync({ strict: false });
|
||||||
if ( this.options.deterministic && !roll.isDeterministic ) throw new Error(`must not contain dice terms: ${value}`);
|
if (this.options.deterministic && !roll.isDeterministic) throw new Error(`must not contain dice terms: ${value}`);
|
||||||
super._validateType(value);
|
super._validateType(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -41,7 +55,7 @@ export default class FormulaField extends foundry.data.fields.StringField {
|
||||||
|
|
||||||
/** @override */
|
/** @override */
|
||||||
_applyChangeAdd(value, delta, model, change) {
|
_applyChangeAdd(value, delta, model, change) {
|
||||||
if ( !value ) return delta;
|
if (!value) return delta;
|
||||||
const operator = delta.startsWith("-") ? "-" : "+";
|
const operator = delta.startsWith("-") ? "-" : "+";
|
||||||
delta = delta.replace(/^[+-]/, "").trim();
|
delta = delta.replace(/^[+-]/, "").trim();
|
||||||
return `${value} ${operator} ${delta}`;
|
return `${value} ${operator} ${delta}`;
|
||||||
|
|
@ -51,9 +65,9 @@ export default class FormulaField extends foundry.data.fields.StringField {
|
||||||
|
|
||||||
/** @override */
|
/** @override */
|
||||||
_applyChangeMultiply(value, delta, model, change) {
|
_applyChangeMultiply(value, delta, model, change) {
|
||||||
if ( !value ) return delta;
|
if (!value) return delta;
|
||||||
const terms = new Roll(value).terms;
|
const terms = new Roll(value).terms;
|
||||||
if ( terms.length > 1 ) return `(${value}) * ${delta}`;
|
if (terms.length > 1) return `(${value}) * ${delta}`;
|
||||||
return `${value} * ${delta}`;
|
return `${value} * ${delta}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -61,9 +75,9 @@ export default class FormulaField extends foundry.data.fields.StringField {
|
||||||
|
|
||||||
/** @override */
|
/** @override */
|
||||||
_applyChangeUpgrade(value, delta, model, change) {
|
_applyChangeUpgrade(value, delta, model, change) {
|
||||||
if ( !value ) return delta;
|
if (!value) return delta;
|
||||||
const terms = new Roll(value).terms;
|
const terms = new Roll(value).terms;
|
||||||
if ( (terms.length === 1) && (terms[0].fn === "max") ) return value.replace(/\)$/, `, ${delta})`);
|
if ((terms.length === 1) && (terms[0].fn === "max")) return value.replace(/\)$/, `, ${delta})`);
|
||||||
return `max(${value}, ${delta})`;
|
return `max(${value}, ${delta})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -71,9 +85,9 @@ export default class FormulaField extends foundry.data.fields.StringField {
|
||||||
|
|
||||||
/** @override */
|
/** @override */
|
||||||
_applyChangeDowngrade(value, delta, model, change) {
|
_applyChangeDowngrade(value, delta, model, change) {
|
||||||
if ( !value ) return delta;
|
if (!value) return delta;
|
||||||
const terms = new Roll(value).terms;
|
const terms = new Roll(value).terms;
|
||||||
if ( (terms.length === 1) && (terms[0].fn === "min") ) return value.replace(/\)$/, `, ${delta})`);
|
if ((terms.length === 1) && (terms[0].fn === "min")) return value.replace(/\)$/, `, ${delta})`);
|
||||||
return `min(${value}, ${delta})`;
|
return `min(${value}, ${delta})`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -15,7 +15,7 @@ export default class DHAncestry extends BaseDataItem {
|
||||||
const fields = foundry.data.fields;
|
const fields = foundry.data.fields;
|
||||||
return {
|
return {
|
||||||
...super.defineSchema(),
|
...super.defineSchema(),
|
||||||
//use ForeignDocumentUUIDField for Abilities
|
//TODO: add features field
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,28 +33,4 @@ export default class DHArmor extends BaseDataItem {
|
||||||
get featureInfo() {
|
get featureInfo() {
|
||||||
return this.feature ? CONFIG.daggerheart.ITEM.armorFeatures[this.feature] : null;
|
return this.feature ? CONFIG.daggerheart.ITEM.armorFeatures[this.feature] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------- */
|
|
||||||
|
|
||||||
/** @inheritDoc */
|
|
||||||
prepareDerivedData() {
|
|
||||||
if (this.parent.parent) {
|
|
||||||
this.applyLevels();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Currently bugged as it double triggers. Should get fixed in an updated foundry version.
|
|
||||||
applyLevels() {
|
|
||||||
// let armorBonus = 0;
|
|
||||||
// for(var level in this.parent.parent.system.levelData.levelups){
|
|
||||||
// var levelData = this.parent.parent.system.levelData.levelups[level];
|
|
||||||
// for(var tier in levelData){
|
|
||||||
// var tierData = levelData[tier];
|
|
||||||
// if(tierData){
|
|
||||||
// armorBonus += Object.keys(tierData.armorOrEvasionSlot).filter(x => tierData.armorOrEvasionSlot[x] === 'armor').length;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// this.marks.max += armorBonus;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
/**
|
/**
|
||||||
* Describes metadata about the item data model type
|
* Describes metadata about the item data model type
|
||||||
* @typedef {Object} ItemDataModelMetadata
|
* @typedef {Object} ItemDataModelMetadata
|
||||||
* @property {string} type - The system type that this data model represents (e.g., "weapon", "armor", "consumable")
|
* @property {string} label - A localizable label used on application.
|
||||||
|
* @property {string} type - The system type that this data model represents.
|
||||||
* @property {boolean} hasDescription - Indicates whether items of this type have description field
|
* @property {boolean} hasDescription - Indicates whether items of this type have description field
|
||||||
* @property {boolean} isQuantifiable - Indicates whether items of this type have quantity field
|
* @property {boolean} isQuantifiable - Indicates whether items of this type have quantity field
|
||||||
*/
|
*/
|
||||||
|
|
@ -33,12 +34,20 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain a data object used to evaluate any dice rolls associated with this Item
|
* Convenient access to the item's actor, if it exists.
|
||||||
* @param {object} [options]
|
* @returns {foundry.documents.Actor | null}
|
||||||
|
*/
|
||||||
|
get actor() {
|
||||||
|
return this.parent.actor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain a data object used to evaluate any dice rolls associated with this Item Type
|
||||||
|
* @param {object} [options] - Options which modify the getRollData method.
|
||||||
* @returns {object}
|
* @returns {object}
|
||||||
*/
|
*/
|
||||||
getRollData(options = {}) {
|
getRollData(options = {}) {
|
||||||
const actorRollData = this.parent.actor?.getRollData() ?? {};
|
const actorRollData = this.actor?.getRollData() ?? {};
|
||||||
const data = { ...actorRollData, item: { ...this } };
|
const data = { ...actorRollData, item: { ...this } };
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,27 +19,15 @@ export default class DHClass extends BaseDataItem {
|
||||||
...super.defineSchema(),
|
...super.defineSchema(),
|
||||||
domains: new fields.ArrayField(new fields.StringField(), { max: 2 }),
|
domains: new fields.ArrayField(new fields.StringField(), { max: 2 }),
|
||||||
|
|
||||||
classItems: new fields.ArrayField(
|
classItems: new fields.ArrayField(new ForeignDocumentUUIDField({ type: "Item" })),
|
||||||
new ForeignDocumentUUIDField({ type:"Item" }),
|
|
||||||
),
|
|
||||||
evasion: new fields.NumberField({ initial: 0, integer: true }),
|
evasion: new fields.NumberField({ initial: 0, integer: true }),
|
||||||
features: new fields.ArrayField(
|
features: new fields.ArrayField(new ForeignDocumentUUIDField({ type: "Item" })),
|
||||||
new ForeignDocumentUUIDField({ type:"Item" }),
|
|
||||||
),
|
|
||||||
|
|
||||||
subclasses: new fields.ArrayField(
|
subclasses: new fields.ArrayField(new ForeignDocumentUUIDField({ type: "Item", required: false, nullable: true, initial: undefined })),
|
||||||
new ForeignDocumentUUIDField({ type:"Item", required: false, nullable: true, initial: undefined}),
|
|
||||||
),
|
|
||||||
inventory: new fields.SchemaField({
|
inventory: new fields.SchemaField({
|
||||||
take: new fields.ArrayField(
|
take: new fields.ArrayField(new ForeignDocumentUUIDField({ type: "Item", required: false, nullable: true, initial: undefined })),
|
||||||
new ForeignDocumentUUIDField({ type:"Item", required: false, nullable: true, initial: undefined}),
|
choiceA: new fields.ArrayField(new ForeignDocumentUUIDField({ type: "Item", required: false, nullable: true, initial: undefined })),
|
||||||
),
|
choiceB: new fields.ArrayField(new ForeignDocumentUUIDField({ type: "Item", required: false, nullable: true, initial: undefined })),
|
||||||
choiceA: new fields.ArrayField(
|
|
||||||
new ForeignDocumentUUIDField({ type:"Item", required: false, nullable: true, initial: undefined}),
|
|
||||||
),
|
|
||||||
choiceB: new fields.ArrayField(
|
|
||||||
new ForeignDocumentUUIDField({ type:"Item", required: false, nullable: true, initial: undefined}),
|
|
||||||
),
|
|
||||||
}),
|
}),
|
||||||
characterGuide: new fields.SchemaField({
|
characterGuide: new fields.SchemaField({
|
||||||
suggestedTraits: new fields.SchemaField({
|
suggestedTraits: new fields.SchemaField({
|
||||||
|
|
@ -50,9 +38,9 @@ export default class DHClass extends BaseDataItem {
|
||||||
presence: new fields.NumberField({ initial: 0, integer: true }),
|
presence: new fields.NumberField({ initial: 0, integer: true }),
|
||||||
knowledge: new fields.NumberField({ initial: 0, integer: true })
|
knowledge: new fields.NumberField({ initial: 0, integer: true })
|
||||||
}),
|
}),
|
||||||
suggestedPrimaryWeapon: new ForeignDocumentUUIDField({ type:"Item" }),
|
suggestedPrimaryWeapon: new ForeignDocumentUUIDField({ type: "Item" }),
|
||||||
suggestedSecondaryWeapon: new ForeignDocumentUUIDField({ type:"Item" }),
|
suggestedSecondaryWeapon: new ForeignDocumentUUIDField({ type: "Item" }),
|
||||||
suggestedArmor: new ForeignDocumentUUIDField({ type:"Item" }),
|
suggestedArmor: new ForeignDocumentUUIDField({ type: "Item" }),
|
||||||
}),
|
}),
|
||||||
multiclass: new fields.NumberField({ initial: null, nullable: true, integer: true }),
|
multiclass: new fields.NumberField({ initial: null, nullable: true, integer: true }),
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ export default class DHCommunity extends BaseDataItem {
|
||||||
const fields = foundry.data.fields;
|
const fields = foundry.data.fields;
|
||||||
return {
|
return {
|
||||||
...super.defineSchema(),
|
...super.defineSchema(),
|
||||||
//use ForeignDocumentUUIDField for Abilities
|
//TODO: add features field
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,16 +16,10 @@ export default class DHDomainCard extends BaseDataItem {
|
||||||
const fields = foundry.data.fields;
|
const fields = foundry.data.fields;
|
||||||
return {
|
return {
|
||||||
...super.defineSchema(),
|
...super.defineSchema(),
|
||||||
domain: new fields.StringField(
|
domain: new fields.StringField({ choices: SYSTEM.DOMAIN.domains, required: true, blank: true }),
|
||||||
{ choices: SYSTEM.DOMAIN.domains},
|
|
||||||
{ required: true, initial: [] }
|
|
||||||
),
|
|
||||||
level: new fields.NumberField({ initial: 1, integer: true }),
|
level: new fields.NumberField({ initial: 1, integer: true }),
|
||||||
recallCost: new fields.NumberField({ initial: 0, integer: true }),
|
recallCost: new fields.NumberField({ initial: 0, integer: true }),
|
||||||
type: new fields.StringField(
|
type: new fields.StringField({ choices: SYSTEM.DOMAIN.cardTypes, required: true, blank: true}),
|
||||||
{ choices: SYSTEM.DOMAIN.cardTypes},
|
|
||||||
{ required: true, initial: [] }
|
|
||||||
),
|
|
||||||
foundation: new fields.BooleanField({ initial: false }),
|
foundation: new fields.BooleanField({ initial: false }),
|
||||||
inVault: new fields.BooleanField({ initial: false }),
|
inVault: new fields.BooleanField({ initial: false }),
|
||||||
actions: new fields.ArrayField(new fields.EmbeddedDataField(DaggerheartAction))
|
actions: new fields.ArrayField(new fields.EmbeddedDataField(DaggerheartAction))
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,16 @@ export default class DHFeature extends BaseDataItem {
|
||||||
const fields = foundry.data.fields;
|
const fields = foundry.data.fields;
|
||||||
return {
|
return {
|
||||||
...super.defineSchema(),
|
...super.defineSchema(),
|
||||||
|
|
||||||
|
//A type of feature seems unnecessary
|
||||||
type: new fields.StringField({ choices: SYSTEM.ITEM.featureTypes }),
|
type: new fields.StringField({ choices: SYSTEM.ITEM.featureTypes }),
|
||||||
|
|
||||||
|
//TODO: remove actionType field
|
||||||
actionType: new fields.StringField({
|
actionType: new fields.StringField({
|
||||||
choices: SYSTEM.ITEM.actionTypes,
|
choices: SYSTEM.ITEM.actionTypes,
|
||||||
initial: SYSTEM.ITEM.actionTypes.passive.id
|
initial: SYSTEM.ITEM.actionTypes.passive.id
|
||||||
}),
|
}),
|
||||||
|
//TODO: remove featureType field
|
||||||
featureType: new fields.SchemaField({
|
featureType: new fields.SchemaField({
|
||||||
type: new fields.StringField({
|
type: new fields.StringField({
|
||||||
choices: SYSTEM.ITEM.valueTypes,
|
choices: SYSTEM.ITEM.valueTypes,
|
||||||
|
|
@ -46,12 +51,16 @@ export default class DHFeature extends BaseDataItem {
|
||||||
{
|
{
|
||||||
type: new fields.StringField({ choices: SYSTEM.GENERAL.refreshTypes }),
|
type: new fields.StringField({ choices: SYSTEM.GENERAL.refreshTypes }),
|
||||||
uses: new fields.NumberField({ initial: 1, integer: true }),
|
uses: new fields.NumberField({ initial: 1, integer: true }),
|
||||||
|
//TODO: remove refreshed field
|
||||||
refreshed: new fields.BooleanField({ initial: true })
|
refreshed: new fields.BooleanField({ initial: true })
|
||||||
},
|
},
|
||||||
{ nullable: true, initial: null }
|
{ nullable: true, initial: null }
|
||||||
),
|
),
|
||||||
|
//TODO: remove refreshed field
|
||||||
multiclass: new fields.NumberField({ initial: null, nullable: true, integer: true }),
|
multiclass: new fields.NumberField({ initial: null, nullable: true, integer: true }),
|
||||||
disabled: new fields.BooleanField({ initial: false }),
|
disabled: new fields.BooleanField({ initial: false }),
|
||||||
|
|
||||||
|
//TODO: re do it completely or just remove it
|
||||||
effects: new fields.TypedObjectField(
|
effects: new fields.TypedObjectField(
|
||||||
new fields.SchemaField({
|
new fields.SchemaField({
|
||||||
type: new fields.StringField({ choices: SYSTEM.EFFECTS.effectTypes }),
|
type: new fields.StringField({ choices: SYSTEM.EFFECTS.effectTypes }),
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ export default class DHWeapon extends BaseDataItem {
|
||||||
trait: new fields.StringField({ required: true, choices: SYSTEM.ACTOR.abilities, initial: 'agility' }),
|
trait: new fields.StringField({ required: true, choices: SYSTEM.ACTOR.abilities, initial: 'agility' }),
|
||||||
range: new fields.StringField({ required: true, choices: SYSTEM.GENERAL.range, initial: 'melee' }),
|
range: new fields.StringField({ required: true, choices: SYSTEM.GENERAL.range, initial: 'melee' }),
|
||||||
burden: new fields.StringField({ required: true, choices: SYSTEM.GENERAL.burden, initial: 'oneHanded' }),
|
burden: new fields.StringField({ required: true, choices: SYSTEM.GENERAL.burden, initial: 'oneHanded' }),
|
||||||
|
|
||||||
//DAMAGE
|
//DAMAGE
|
||||||
damage: new fields.SchemaField({
|
damage: new fields.SchemaField({
|
||||||
value: new FormulaField({ initial: 'd6' }),
|
value: new FormulaField({ initial: 'd6' }),
|
||||||
|
|
@ -38,31 +37,4 @@ export default class DHWeapon extends BaseDataItem {
|
||||||
feature: new fields.StringField({ choices: SYSTEM.ITEM.weaponFeatures, blank: true }),
|
feature: new fields.StringField({ choices: SYSTEM.ITEM.weaponFeatures, blank: true }),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
prepareDerivedData() {
|
|
||||||
if (this.parent.parent) {
|
|
||||||
this.applyEffects();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
applyEffects() {
|
|
||||||
const effects = this.parent.parent.system.effects;
|
|
||||||
for (const key in effects) {
|
|
||||||
console.log
|
|
||||||
const effectType = effects[key];
|
|
||||||
for (const effect of effectType) {
|
|
||||||
switch (key) {
|
|
||||||
case SYSTEM.EFFECTS.effectTypes.reach.id:
|
|
||||||
if (
|
|
||||||
SYSTEM.GENERAL.range[this.range].distance <
|
|
||||||
SYSTEM.GENERAL.range[effect.valueData.value].distance
|
|
||||||
) {
|
|
||||||
this.range = effect.valueData.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,26 @@ export default class DhpItem extends Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
* @param {object} options - Options which modify the getRollData method.
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getRollData(options = {}) {
|
||||||
|
let data;
|
||||||
|
if (this.system.getRollData) data = this.system.getRollData(options);
|
||||||
|
else {
|
||||||
|
const actorRollData = this.actor?.getRollData(options) ?? {};
|
||||||
|
data = { ...actorRollData, item: { ...this.system } };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data?.item) {
|
||||||
|
data.item.flags = { ...this.flags };
|
||||||
|
data.item.name = this.name;
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
isInventoryItem() {
|
isInventoryItem() {
|
||||||
return ['weapon', 'armor', 'miscellaneous', 'consumable'].includes(this.type);
|
return ['weapon', 'armor', 'miscellaneous', 'consumable'].includes(this.type);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue