mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-06-06 04:44:16 +02:00
Initial
This commit is contained in:
parent
1cece731ee
commit
dbb08fec8c
7 changed files with 113 additions and 12 deletions
|
|
@ -62,6 +62,10 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
|
|||
id: 'configuration',
|
||||
template: 'systems/daggerheart/templates/sheets-settings/action-settings/configuration.hbs'
|
||||
},
|
||||
configuration: {
|
||||
id: 'range',
|
||||
template: 'systems/daggerheart/templates/sheets-settings/action-settings/range.hbs'
|
||||
},
|
||||
effect: {
|
||||
id: 'effect',
|
||||
template: 'systems/daggerheart/templates/sheets-settings/action-settings/effect.hbs'
|
||||
|
|
@ -89,6 +93,14 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
|
|||
icon: null,
|
||||
label: 'DAGGERHEART.GENERAL.Tabs.configuration'
|
||||
},
|
||||
range: {
|
||||
active: false,
|
||||
cssClass: '',
|
||||
group: 'primary',
|
||||
id: 'range',
|
||||
icon: null,
|
||||
label: 'DAGGERHEART.GENERAL.Tabs.range'
|
||||
},
|
||||
effect: {
|
||||
active: false,
|
||||
cssClass: '',
|
||||
|
|
@ -107,6 +119,25 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
|
|||
}
|
||||
};
|
||||
|
||||
static OUTCOME_TABS = {
|
||||
successWithHope: {
|
||||
active: true,
|
||||
cssClass: '',
|
||||
group: 'outcomes',
|
||||
id: 'successWithHope',
|
||||
icon: null,
|
||||
label: 'Success With Hope'
|
||||
},
|
||||
successWithFear: {
|
||||
active: false,
|
||||
cssClass: '',
|
||||
group: 'outcomes',
|
||||
id: 'successWithFear',
|
||||
icon: null,
|
||||
label: 'Success With Fear'
|
||||
},
|
||||
};
|
||||
|
||||
static CLEAN_ARRAYS = ['cost', 'effects', 'summon'];
|
||||
|
||||
_getTabs(tabs) {
|
||||
|
|
@ -155,6 +186,10 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
|
|||
|
||||
context.openSection = this.openSection;
|
||||
context.tabs = this._getTabs(this.constructor.TABS);
|
||||
|
||||
context.outcomeTabs = this._getTabs(this.constructor.OUTCOME_TABS);
|
||||
context.outcomeData = context.outcomeTabs.successWithHope.active ? context.source.damage : context.source.damage.altOutcomes.successWithFear;
|
||||
|
||||
context.config = CONFIG.DH;
|
||||
if (this.action.damage) {
|
||||
context.allDamageTypesUsed = !getUnusedDamageTypes(this.action.damage.parts).length;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,15 @@ import IterableTypedObjectField from '../iterableTypedObjectField.mjs';
|
|||
|
||||
const fields = foundry.data.fields;
|
||||
|
||||
const getDamageBaseFields = () => ({
|
||||
parts: new IterableTypedObjectField(DHDamageData),
|
||||
includeBase: new fields.BooleanField({
|
||||
initial: false,
|
||||
label: 'DAGGERHEART.ACTIONS.Settings.includeBase.label'
|
||||
}),
|
||||
direct: new fields.BooleanField({ initial: false, label: 'DAGGERHEART.CONFIG.DamageType.direct.name' }),
|
||||
});
|
||||
|
||||
export default class DamageField extends fields.SchemaField {
|
||||
/**
|
||||
* Action Workflow order
|
||||
|
|
@ -13,12 +22,13 @@ export default class DamageField extends fields.SchemaField {
|
|||
/** @inheritDoc */
|
||||
constructor(options, context = {}) {
|
||||
const damageFields = {
|
||||
parts: new IterableTypedObjectField(DHDamageData),
|
||||
includeBase: new fields.BooleanField({
|
||||
initial: false,
|
||||
label: 'DAGGERHEART.ACTIONS.Settings.includeBase.label'
|
||||
...getDamageBaseFields(),
|
||||
altOutcomes: new fields.SchemaField({
|
||||
successFear: new fields.EmbeddedDataField(AltDamageOutcome, { nullable: true, initial: null }),
|
||||
failureHope: new fields.EmbeddedDataField(AltDamageOutcome, { nullable: true, initial: null }),
|
||||
failureFear: new fields.EmbeddedDataField(AltDamageOutcome, { nullable: true, initial: null }),
|
||||
critical: new fields.EmbeddedDataField(AltDamageOutcome, { nullable: true, initial: null })
|
||||
}),
|
||||
direct: new fields.BooleanField({ initial: false, label: 'DAGGERHEART.CONFIG.DamageType.direct.name' }),
|
||||
groupAttack: new fields.StringField({
|
||||
choices: CONFIG.DH.GENERAL.groupAttackRange,
|
||||
blank: true,
|
||||
|
|
@ -28,6 +38,12 @@ export default class DamageField extends fields.SchemaField {
|
|||
super(damageFields, options, context);
|
||||
}
|
||||
|
||||
getDamageData(outcome) {
|
||||
if (outcome === 'successHope') return this;
|
||||
|
||||
return this.altOutcomes[outcome].data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Roll Damage/Healing Action Workflow part.
|
||||
* Must be called within Action context or similar.
|
||||
|
|
@ -326,3 +342,17 @@ export class DHDamageData extends DHResourceData {
|
|||
};
|
||||
}
|
||||
}
|
||||
|
||||
class AltDamageOutcome extends foundry.abstract.DataModel {
|
||||
static defineSchema() {
|
||||
return {
|
||||
copyStandard: new fields.BooleanField({ required: true, initial: true }),
|
||||
...getDamageBaseFields(),
|
||||
/* Stuff */
|
||||
}
|
||||
}
|
||||
|
||||
get data() {
|
||||
return this.copyStandard ? this.parent : {}; // If not copying, return data from the this alternate outcome
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue