mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 19:51:08 +01:00
REFACTOR: rename folder data/items -> data/item
REFACTOR: rename folder `data/messages` -> `data/chat-message`.
This commit is contained in:
parent
a6acbe750a
commit
08a21dcb2f
19 changed files with 25 additions and 16 deletions
36
module/data/item/_module.mjs
Normal file
36
module/data/item/_module.mjs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import DHAncestry from './ancestry.mjs';
|
||||
import DHArmor from './armor.mjs';
|
||||
import DHClass from './class.mjs';
|
||||
import DHCommunity from './community.mjs';
|
||||
import DHConsumable from './consumable.mjs';
|
||||
import DHDomainCard from './domainCard.mjs';
|
||||
import DHFeature from './feature.mjs';
|
||||
import DHMiscellaneous from './miscellaneous.mjs';
|
||||
import DHSubclass from './subclass.mjs';
|
||||
import DHWeapon from './weapon.mjs';
|
||||
|
||||
export {
|
||||
DHAncestry,
|
||||
DHArmor,
|
||||
DHClass,
|
||||
DHCommunity,
|
||||
DHConsumable,
|
||||
DHDomainCard,
|
||||
DHFeature,
|
||||
DHMiscellaneous,
|
||||
DHSubclass,
|
||||
DHWeapon,
|
||||
}
|
||||
|
||||
export const config = {
|
||||
ancestry: DHAncestry,
|
||||
armor: DHArmor,
|
||||
class: DHClass,
|
||||
community: DHCommunity,
|
||||
consumable: DHConsumable,
|
||||
domainCard: DHDomainCard,
|
||||
feature: DHFeature,
|
||||
miscellaneous: DHMiscellaneous,
|
||||
subclass: DHSubclass,
|
||||
weapon: DHWeapon,
|
||||
};
|
||||
21
module/data/item/ancestry.mjs
Normal file
21
module/data/item/ancestry.mjs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import BaseDataItem from './base.mjs';
|
||||
|
||||
export default class DHAncestry extends BaseDataItem {
|
||||
/** @inheritDoc */
|
||||
static get metadata() {
|
||||
return foundry.utils.mergeObject(super.metadata, {
|
||||
label: "TYPES.Item.ancestry",
|
||||
type: "ancestry",
|
||||
hasDescription: true,
|
||||
});
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return {
|
||||
...super.defineSchema(),
|
||||
//use ForeignDocumentUUIDField for Abilities
|
||||
};
|
||||
}
|
||||
}
|
||||
60
module/data/item/armor.mjs
Normal file
60
module/data/item/armor.mjs
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
import BaseDataItem from './base.mjs';
|
||||
|
||||
export default class DHArmor extends BaseDataItem {
|
||||
/** @inheritDoc */
|
||||
static get metadata() {
|
||||
return foundry.utils.mergeObject(super.metadata, {
|
||||
label: "TYPES.Item.armor",
|
||||
type: "armor",
|
||||
hasDescription: true,
|
||||
isQuantifiable: true,
|
||||
});
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return {
|
||||
...super.defineSchema(),
|
||||
equipped: new fields.BooleanField({ initial: false }),
|
||||
baseScore: new fields.NumberField({ integer: true, initial: 0 }),
|
||||
feature: new fields.StringField({ choices: SYSTEM.ITEM.armorFeatures, blank: true }),
|
||||
marks: new fields.SchemaField({
|
||||
max: new fields.NumberField({ initial: 6, integer: true }),
|
||||
value: new fields.NumberField({ initial: 0, integer: true })
|
||||
}),
|
||||
baseThresholds: new fields.SchemaField({
|
||||
major: new fields.NumberField({ integer: true, initial: 0 }),
|
||||
severe: new fields.NumberField({ integer: true, initial: 0 })
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
get featureInfo() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
43
module/data/item/base.mjs
Normal file
43
module/data/item/base.mjs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/**
|
||||
* @typedef {Object} ItemDataModelMetadata
|
||||
* @property {String} type - System type that this type data model represents
|
||||
* @property {Boolean} hasDescription
|
||||
*/
|
||||
|
||||
const fields = foundry.data.fields;
|
||||
|
||||
export default class BaseDataItem extends foundry.abstract.TypeDataModel {
|
||||
/** @returns {ItemDataModelMetadata}*/
|
||||
static get metadata() {
|
||||
return {
|
||||
label: "Base Item",
|
||||
type: "base",
|
||||
hasDescription: false,
|
||||
isQuantifiable: false
|
||||
};
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
static defineSchema() {
|
||||
const schema = {};
|
||||
|
||||
if (this.metadata.hasDescription)
|
||||
schema.description = new fields.HTMLField({ required: true, nullable: true });
|
||||
|
||||
if (this.metadata.isQuantifiable)
|
||||
schema.quantity = new fields.NumberField({ integer: true, initial: 1, min: 0, required: true });
|
||||
|
||||
return schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain a data object used to evaluate any dice rolls associated with this Item
|
||||
* @param {object} [options]
|
||||
* @returns {object}
|
||||
*/
|
||||
getRollData(options = {}) {
|
||||
const actorRollData = this.parent.actor?.getRollData() ?? {};
|
||||
const data = { ...actorRollData, item: { ...this } };
|
||||
return data;
|
||||
}
|
||||
}
|
||||
64
module/data/item/class.mjs
Normal file
64
module/data/item/class.mjs
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
import { getTier } from '../../helpers/utils.mjs';
|
||||
import BaseDataItem from './base.mjs';
|
||||
import ForeignDocumentUUIDField from '../fields/foreignDocumentUUIDField.mjs';
|
||||
|
||||
export default class DHClass extends BaseDataItem {
|
||||
/** @inheritDoc */
|
||||
static get metadata() {
|
||||
return foundry.utils.mergeObject(super.metadata, {
|
||||
label: "TYPES.Item.class",
|
||||
type: "class",
|
||||
hasDescription: true,
|
||||
});
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return {
|
||||
...super.defineSchema(),
|
||||
domains: new fields.ArrayField(new fields.StringField(), { max: 2 }),
|
||||
|
||||
classItems: new fields.ArrayField(
|
||||
new ForeignDocumentUUIDField({ type:"Item" }),
|
||||
),
|
||||
evasion: new fields.NumberField({ initial: 0, integer: true }),
|
||||
features: new fields.ArrayField(
|
||||
new ForeignDocumentUUIDField({ type:"Item" }),
|
||||
),
|
||||
|
||||
subclasses: new fields.ArrayField(
|
||||
new ForeignDocumentUUIDField({ type:"Item", required: false, nullable: true, initial: undefined}),
|
||||
),
|
||||
inventory: new fields.SchemaField({
|
||||
take: 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({
|
||||
suggestedTraits: new fields.SchemaField({
|
||||
agility: new fields.NumberField({ initial: 0, integer: true }),
|
||||
strength: new fields.NumberField({ initial: 0, integer: true }),
|
||||
finesse: new fields.NumberField({ initial: 0, integer: true }),
|
||||
instinct: new fields.NumberField({ initial: 0, integer: true }),
|
||||
presence: new fields.NumberField({ initial: 0, integer: true }),
|
||||
knowledge: new fields.NumberField({ initial: 0, integer: true })
|
||||
}),
|
||||
suggestedPrimaryWeapon: new ForeignDocumentUUIDField({ type:"Item" }),
|
||||
suggestedSecondaryWeapon: new ForeignDocumentUUIDField({ type:"Item" }),
|
||||
suggestedArmor: new ForeignDocumentUUIDField({ type:"Item" }),
|
||||
}),
|
||||
multiclass: new fields.NumberField({ initial: null, nullable: true, integer: true }),
|
||||
};
|
||||
}
|
||||
|
||||
get multiclassTier() {
|
||||
return getTier(this.multiclass, true);
|
||||
}
|
||||
}
|
||||
22
module/data/item/community.mjs
Normal file
22
module/data/item/community.mjs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import BaseDataItem from './base.mjs';
|
||||
|
||||
export default class DHCommunity extends BaseDataItem {
|
||||
/** @inheritDoc */
|
||||
static get metadata() {
|
||||
return foundry.utils.mergeObject(super.metadata, {
|
||||
label: "TYPES.Item.community",
|
||||
type: "community",
|
||||
hasDescription: true,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/** @inheritDoc */
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return {
|
||||
...super.defineSchema(),
|
||||
//use ForeignDocumentUUIDField for Abilities
|
||||
};
|
||||
}
|
||||
}
|
||||
22
module/data/item/consumable.mjs
Normal file
22
module/data/item/consumable.mjs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import BaseDataItem from "./base.mjs";
|
||||
|
||||
export default class DHConsumable extends BaseDataItem {
|
||||
/** @inheritDoc */
|
||||
static get metadata() {
|
||||
return foundry.utils.mergeObject(super.metadata, {
|
||||
label: "TYPES.Item.consumable",
|
||||
type: "consumable",
|
||||
hasDescription: true,
|
||||
isQuantifiable: true,
|
||||
});
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return {
|
||||
...super.defineSchema(),
|
||||
consumeOnUse: new fields.BooleanField({ initial: false })
|
||||
};
|
||||
}
|
||||
}
|
||||
34
module/data/item/domainCard.mjs
Normal file
34
module/data/item/domainCard.mjs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import DaggerheartAction from "../action.mjs";
|
||||
import BaseDataItem from "./base.mjs";
|
||||
|
||||
export default class DHDomainCard extends BaseDataItem {
|
||||
/** @inheritDoc */
|
||||
static get metadata() {
|
||||
return foundry.utils.mergeObject(super.metadata, {
|
||||
label: "TYPES.Item.domainCard",
|
||||
type: "domainCard",
|
||||
hasDescription: true,
|
||||
});
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return {
|
||||
...super.defineSchema(),
|
||||
domain: new fields.StringField(
|
||||
{ choices: SYSTEM.DOMAIN.domains},
|
||||
{ required: true, initial: [] }
|
||||
),
|
||||
level: new fields.NumberField({ initial: 1, integer: true }),
|
||||
recallCost: new fields.NumberField({ initial: 0, integer: true }),
|
||||
type: new fields.StringField(
|
||||
{ choices: SYSTEM.DOMAIN.cardTypes},
|
||||
{ required: true, initial: [] }
|
||||
),
|
||||
foundation: new fields.BooleanField({ initial: false }),
|
||||
inVault: new fields.BooleanField({ initial: false }),
|
||||
actions: new fields.ArrayField(new fields.EmbeddedDataField(DaggerheartAction))
|
||||
};
|
||||
}
|
||||
}
|
||||
141
module/data/item/feature.mjs
Normal file
141
module/data/item/feature.mjs
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
import { getTier } from '../../helpers/utils.mjs';
|
||||
import DaggerheartAction from '../action.mjs';
|
||||
import BaseDataItem from './base.mjs';
|
||||
|
||||
export default class DHFeature extends BaseDataItem {
|
||||
/** @inheritDoc */
|
||||
static get metadata() {
|
||||
return foundry.utils.mergeObject(super.metadata, {
|
||||
label: "TYPES.Item.feature",
|
||||
type: "feature",
|
||||
hasDescription: true,
|
||||
});
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return {
|
||||
...super.defineSchema(),
|
||||
type: new fields.StringField({ choices: SYSTEM.ITEM.featureTypes }),
|
||||
actionType: new fields.StringField({
|
||||
choices: SYSTEM.ITEM.actionTypes,
|
||||
initial: SYSTEM.ITEM.actionTypes.passive.id
|
||||
}),
|
||||
featureType: new fields.SchemaField({
|
||||
type: new fields.StringField({
|
||||
choices: SYSTEM.ITEM.valueTypes,
|
||||
initial: Object.keys(SYSTEM.ITEM.valueTypes).find(x => x === 'normal')
|
||||
}),
|
||||
data: new fields.SchemaField({
|
||||
value: new fields.StringField({}),
|
||||
property: new fields.StringField({
|
||||
choices: SYSTEM.ACTOR.featureProperties,
|
||||
initial: Object.keys(SYSTEM.ACTOR.featureProperties).find(x => x === 'spellcastingTrait')
|
||||
}),
|
||||
max: new fields.NumberField({ initial: 1, integer: true }),
|
||||
numbers: new fields.TypedObjectField(
|
||||
new fields.SchemaField({
|
||||
value: new fields.NumberField({ integer: true }),
|
||||
used: new fields.BooleanField({ initial: false })
|
||||
})
|
||||
)
|
||||
})
|
||||
}),
|
||||
refreshData: new fields.SchemaField(
|
||||
{
|
||||
type: new fields.StringField({ choices: SYSTEM.GENERAL.refreshTypes }),
|
||||
uses: new fields.NumberField({ initial: 1, integer: true }),
|
||||
refreshed: new fields.BooleanField({ initial: true })
|
||||
},
|
||||
{ nullable: true, initial: null }
|
||||
),
|
||||
multiclass: new fields.NumberField({ initial: null, nullable: true, integer: true }),
|
||||
disabled: new fields.BooleanField({ initial: false }),
|
||||
effects: new fields.TypedObjectField(
|
||||
new fields.SchemaField({
|
||||
type: new fields.StringField({ choices: SYSTEM.EFFECTS.effectTypes }),
|
||||
valueType: new fields.StringField({ choices: SYSTEM.EFFECTS.valueTypes }),
|
||||
parseType: new fields.StringField({ choices: SYSTEM.EFFECTS.parseTypes }),
|
||||
initiallySelected: new fields.BooleanField({ initial: true }),
|
||||
options: new fields.ArrayField(
|
||||
new fields.SchemaField({
|
||||
name: new fields.StringField({}),
|
||||
value: new fields.StringField({})
|
||||
}),
|
||||
{ nullable: true, initial: null }
|
||||
),
|
||||
dataField: new fields.StringField({}),
|
||||
appliesOn: new fields.StringField({
|
||||
choices: SYSTEM.EFFECTS.applyLocations,
|
||||
},
|
||||
{ nullable: true, initial: null }
|
||||
),
|
||||
applyLocationChoices: new fields.TypedObjectField(new fields.StringField({}), {
|
||||
nullable: true,
|
||||
initial: null
|
||||
}),
|
||||
valueData: new fields.SchemaField({
|
||||
value: new fields.StringField({}),
|
||||
fromValue: new fields.StringField({ initial: null, nullable: true }),
|
||||
type: new fields.StringField({ initial: null, nullable: true }),
|
||||
hopeIncrease: new fields.StringField({ initial: null, nullable: true })
|
||||
})
|
||||
})
|
||||
),
|
||||
actions: new fields.ArrayField(new fields.EmbeddedDataField(DaggerheartAction))
|
||||
};
|
||||
}
|
||||
|
||||
get multiclassTier() {
|
||||
return getTier(this.multiclass);
|
||||
}
|
||||
|
||||
async refresh() {
|
||||
if (this.refreshData) {
|
||||
if (this.featureType.type === SYSTEM.ITEM.valueTypes.dice.id) {
|
||||
const update = { 'system.refreshData.refreshed': true };
|
||||
Object.keys(this.featureType.data.numbers).forEach(
|
||||
x => (update[`system.featureType.data.numbers.-=${x}`] = null)
|
||||
);
|
||||
await this.parent.update(update);
|
||||
} else {
|
||||
await this.parent.update({ 'system.refreshData.refreshed': true });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
get effectData() {
|
||||
const effectValues = Object.values(this.effects);
|
||||
const effectCategories = Object.keys(SYSTEM.EFFECTS.effectTypes).reduce((acc, effectType) => {
|
||||
acc[effectType] = effectValues.reduce((acc, effect) => {
|
||||
if (effect.type === effectType) {
|
||||
acc.push({ ...effect, valueData: this.#parseValues(effect.parseType, effect.valueData) });
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
return effectCategories;
|
||||
}
|
||||
|
||||
#parseValues(parseType, values) {
|
||||
return Object.keys(values).reduce((acc, prop) => {
|
||||
acc[prop] = this.#parseValue(parseType, values[prop]);
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
}
|
||||
|
||||
#parseValue(parseType, value) {
|
||||
switch (parseType) {
|
||||
case SYSTEM.EFFECTS.parseTypes.number.id:
|
||||
return Number.parseInt(value);
|
||||
default:
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
21
module/data/item/miscellaneous.mjs
Normal file
21
module/data/item/miscellaneous.mjs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import BaseDataItem from './base.mjs';
|
||||
|
||||
export default class DHMiscellaneous extends BaseDataItem {
|
||||
/** @inheritDoc */
|
||||
static get metadata() {
|
||||
return foundry.utils.mergeObject(super.metadata, {
|
||||
label: "TYPES.Item.miscellaneous",
|
||||
type: "miscellaneous",
|
||||
hasDescription: true,
|
||||
isQuantifiable: true,
|
||||
});
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return {
|
||||
...super.defineSchema(),
|
||||
};
|
||||
}
|
||||
}
|
||||
66
module/data/item/subclass.mjs
Normal file
66
module/data/item/subclass.mjs
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
import { getTier } from '../../helpers/utils.mjs';
|
||||
import BaseDataItem from './base.mjs';
|
||||
|
||||
export default class DHSubclass extends BaseDataItem {
|
||||
/** @inheritDoc */
|
||||
static get metadata() {
|
||||
return foundry.utils.mergeObject(super.metadata, {
|
||||
label: "TYPES.Item.subclass",
|
||||
type: "subclass",
|
||||
hasDescription: true,
|
||||
});
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return {
|
||||
...super.defineSchema(),
|
||||
spellcastingTrait: new fields.StringField({
|
||||
choices: SYSTEM.ACTOR.abilities,
|
||||
integer: false,
|
||||
nullable: true,
|
||||
initial: null
|
||||
}),
|
||||
foundationFeature: new fields.SchemaField({
|
||||
description: new fields.HTMLField({}),
|
||||
abilities: new fields.ArrayField(
|
||||
new fields.SchemaField({
|
||||
name: new fields.StringField({}),
|
||||
img: new fields.StringField({}),
|
||||
uuid: new fields.StringField({})
|
||||
})
|
||||
)
|
||||
}),
|
||||
specializationFeature: new fields.SchemaField({
|
||||
unlocked: new fields.BooleanField({ initial: false }),
|
||||
tier: new fields.NumberField({ initial: null, nullable: true, integer: true }),
|
||||
description: new fields.HTMLField({}),
|
||||
abilities: new fields.ArrayField(
|
||||
new fields.SchemaField({
|
||||
name: new fields.StringField({}),
|
||||
img: new fields.StringField({}),
|
||||
uuid: new fields.StringField({})
|
||||
})
|
||||
)
|
||||
}),
|
||||
masteryFeature: new fields.SchemaField({
|
||||
unlocked: new fields.BooleanField({ initial: false }),
|
||||
tier: new fields.NumberField({ initial: null, nullable: true, integer: true }),
|
||||
description: new fields.HTMLField({}),
|
||||
abilities: new fields.ArrayField(
|
||||
new fields.SchemaField({
|
||||
name: new fields.StringField({}),
|
||||
img: new fields.StringField({}),
|
||||
uuid: new fields.StringField({})
|
||||
})
|
||||
)
|
||||
}),
|
||||
multiclass: new fields.NumberField({ initial: null, nullable: true, integer: true })
|
||||
};
|
||||
}
|
||||
|
||||
get multiclassTier() {
|
||||
return getTier(this.multiclass);
|
||||
}
|
||||
}
|
||||
68
module/data/item/weapon.mjs
Normal file
68
module/data/item/weapon.mjs
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
import BaseDataItem from "./base.mjs";
|
||||
import FormulaField from "../fields/formulaField.mjs";
|
||||
|
||||
export default class DHWeapon extends BaseDataItem {
|
||||
/** @inheritDoc */
|
||||
static get metadata() {
|
||||
return foundry.utils.mergeObject(super.metadata, {
|
||||
label: "TYPES.Item.weapon",
|
||||
type: "weapon",
|
||||
hasDescription: true,
|
||||
isQuantifiable: true,
|
||||
});
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return {
|
||||
...super.defineSchema(),
|
||||
equipped: new fields.BooleanField({ initial: false }),
|
||||
|
||||
//SETTINGS
|
||||
secondary: new fields.BooleanField({ initial: false }),
|
||||
trait: new fields.StringField({ required: true, choices: SYSTEM.ACTOR.abilities, initial: 'agility' }),
|
||||
range: new fields.StringField({ required: true, choices: SYSTEM.GENERAL.range, initial: 'melee' }),
|
||||
burden: new fields.StringField({ required: true, choices: SYSTEM.GENERAL.burden, initial: 'oneHanded' }),
|
||||
|
||||
//DAMAGE
|
||||
damage: new fields.SchemaField({
|
||||
value: new FormulaField({ initial: 'd6' }),
|
||||
type: new fields.StringField({
|
||||
required: true,
|
||||
choices: SYSTEM.GENERAL.damageTypes,
|
||||
initial: 'physical'
|
||||
})
|
||||
}),
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue