mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-13 04:01:06 +01:00
Feature/116-implementation-of-pseudo-documents (#125)
* FEAT: add baseDataModel logic * FEAT: new PseudoDocumentsField FIX: BasePseudoDocument 's getEmbeddedDocument * FEAT: PseudoDocument class * FEAT: add TypedPseudoDocument REFACTOR: PreudoDocument FIX: Typos Bug * FIX: CONFIG types * FEAT: basic PseudoDocumentSheet * FIX: remove schema ADD: input of example --------- Co-authored-by: Joaquin Pereyra <joaquinpereyra98@users.noreply.github.com> Co-authored-by: WBHarry <williambjrklund@gmail.com>
This commit is contained in:
parent
3a0a4673ad
commit
f840dc2553
41 changed files with 844 additions and 190 deletions
|
|
@ -1,4 +1,14 @@
|
|||
import { DHAttackAction, DHBaseAction, DHDamageAction, DHEffectAction, DHHealingAction, DHMacroAction, DHResourceAction, DHSpellCastAction, DHSummonAction } from "./action.mjs";
|
||||
import {
|
||||
DHAttackAction,
|
||||
DHBaseAction,
|
||||
DHDamageAction,
|
||||
DHEffectAction,
|
||||
DHHealingAction,
|
||||
DHMacroAction,
|
||||
DHResourceAction,
|
||||
DHSpellCastAction,
|
||||
DHSummonAction
|
||||
} from './action.mjs';
|
||||
|
||||
export const actionsTypes = {
|
||||
base: DHBaseAction,
|
||||
|
|
@ -10,4 +20,4 @@ export const actionsTypes = {
|
|||
summon: DHSummonAction,
|
||||
effect: DHEffectAction,
|
||||
macro: DHMacroAction
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -334,8 +334,14 @@ export class DHResourceAction extends DHBaseAction {
|
|||
...extraDefineSchema('target'),
|
||||
...extraDefineSchema('effects'),
|
||||
resource: new fields.SchemaField({
|
||||
type: new fields.StringField({ choices: [], blank: true, required: false, initial: "", label: "Resource" }),
|
||||
value: new fields.NumberField({ initial: 0, label: "Value" })
|
||||
type: new fields.StringField({
|
||||
choices: [],
|
||||
blank: true,
|
||||
required: false,
|
||||
initial: '',
|
||||
label: 'Resource'
|
||||
}),
|
||||
value: new fields.NumberField({ initial: 0, label: 'Value' })
|
||||
})
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import FormulaField from "../fields/formulaField.mjs";
|
||||
import FormulaField from '../fields/formulaField.mjs';
|
||||
|
||||
const fields = foundry.data.fields;
|
||||
|
||||
|
|
@ -6,27 +6,33 @@ export class DHActionDiceData extends foundry.abstract.DataModel {
|
|||
/** @override */
|
||||
static defineSchema() {
|
||||
return {
|
||||
multiplier: new fields.StringField({ choices: SYSTEM.GENERAL.multiplierTypes, initial: 'proficiency', label: 'Multiplier' }),
|
||||
multiplier: new fields.StringField({
|
||||
choices: SYSTEM.GENERAL.multiplierTypes,
|
||||
initial: 'proficiency',
|
||||
label: 'Multiplier'
|
||||
}),
|
||||
dice: new fields.StringField({ choices: SYSTEM.GENERAL.diceTypes, initial: 'd6', label: 'Formula' }),
|
||||
bonus: new fields.NumberField({ nullable: true, initial: null, label: 'Bonus' }),
|
||||
custom: new fields.SchemaField({
|
||||
enabled: new fields.BooleanField({ label: 'Custom Formula' }),
|
||||
formula: new FormulaField( { label: 'Formula' } )
|
||||
formula: new FormulaField({ label: 'Formula' })
|
||||
})
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
getFormula(actor) {
|
||||
return this.custom.enabled ? this.custom.formula : `${(actor.system[this.multiplier] ?? 1)}${this.dice}${this.bonus ? (this.bonus < 0 ? ` - ${Math.abs(this.bonus)}` : ` + ${this.bonus}`) : ''}`;
|
||||
return this.custom.enabled
|
||||
? this.custom.formula
|
||||
: `${actor.system[this.multiplier] ?? 1}${this.dice}${this.bonus ? (this.bonus < 0 ? ` - ${Math.abs(this.bonus)}` : ` + ${this.bonus}`) : ''}`;
|
||||
}
|
||||
}
|
||||
|
||||
export class DHDamageField extends fields.SchemaField {
|
||||
constructor(hasBase, options, context={}) {
|
||||
constructor(hasBase, options, context = {}) {
|
||||
const damageFields = {
|
||||
parts: new fields.ArrayField(new fields.EmbeddedDataField(DHDamageData))
|
||||
}
|
||||
if(hasBase) damageFields.includeBase = new fields.BooleanField({ initial: true })
|
||||
};
|
||||
if (hasBase) damageFields.includeBase = new fields.BooleanField({ initial: true });
|
||||
super(damageFields, options, context);
|
||||
}
|
||||
}
|
||||
|
|
@ -44,6 +50,6 @@ export class DHDamageData extends DHActionDiceData {
|
|||
nullable: false,
|
||||
required: true
|
||||
})
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue