mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Feature/253 weapon attack action (#290)
* Step #1 * Add Attack to Weapon & Override settings to Roll
This commit is contained in:
parent
52be430eff
commit
7d7fb88035
23 changed files with 168 additions and 91 deletions
|
|
@ -108,7 +108,7 @@ export default class DHActionConfig extends DaggerheartSheet(ApplicationV2) {
|
|||
context.config = CONFIG.DH;
|
||||
if (!!this.action.effects) context.effects = this.action.effects.map(e => this.action.item.effects.get(e._id));
|
||||
if (this.action.damage?.hasOwnProperty('includeBase') && this.action.type === 'attack')
|
||||
context.hasBaseDamage = !!this.action.parent.damage;
|
||||
context.hasBaseDamage = !!this.action.parent.attack;
|
||||
context.getRealIndex = this.getRealIndex.bind(this);
|
||||
context.getEffectDetails = this.getEffectDetails.bind(this);
|
||||
context.disableOption = this.disableOption.bind(this);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
|
|||
/** @inheritdoc */
|
||||
static TABS = {
|
||||
primary: {
|
||||
tabs: [{ id: 'description' }, { id: 'actions' }, { id: 'settings' }],
|
||||
tabs: [{ id: 'description' }, { id: 'settings' }, { id: 'actions' }],
|
||||
initial: 'description',
|
||||
labelPrefix: 'DAGGERHEART.GENERAL.Tabs'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,13 +31,12 @@ export default class WeaponSheet extends DHBaseItemSheet {
|
|||
/**@inheritdoc */
|
||||
async _preparePartContext(partId, context) {
|
||||
super._preparePartContext(partId, context);
|
||||
|
||||
switch (partId) {
|
||||
case 'settings':
|
||||
context.features = this.document.system.features.map(x => x.value);
|
||||
context.systemFields.attack.fields = this.document.system.attack.schema.fields;
|
||||
break;
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,9 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
|||
action =
|
||||
actor.system.attack?._id === actionId
|
||||
? actor.system.attack
|
||||
: item?.system?.actions?.find(a => a._id === actionId);
|
||||
: item.system.attack?._id === actionId
|
||||
? item.system.attack
|
||||
: item?.system?.actions?.find(a => a._id === actionId);
|
||||
return action;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,12 +58,14 @@ export const damageTypes = {
|
|||
physical: {
|
||||
id: 'physical',
|
||||
label: 'DAGGERHEART.CONFIG.DamageType.physical.name',
|
||||
abbreviation: 'DAGGERHEART.CONFIG.DamageType.physical.abbreviation'
|
||||
abbreviation: 'DAGGERHEART.CONFIG.DamageType.physical.abbreviation',
|
||||
icon: ["fa-hand-fist"]
|
||||
},
|
||||
magical: {
|
||||
id: 'magical',
|
||||
label: 'DAGGERHEART.CONFIG.DamageType.magical.name',
|
||||
abbreviation: 'DAGGERHEART.CONFIG.DamageType.magical.abbreviation'
|
||||
abbreviation: 'DAGGERHEART.CONFIG.DamageType.magical.abbreviation',
|
||||
icon: ["fa-wand-sparkles"]
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -344,26 +346,26 @@ export const refreshTypes = {
|
|||
};
|
||||
|
||||
export const abilityCosts = {
|
||||
hp: {
|
||||
id: 'hp',
|
||||
label: 'DAGGERHEART.CONFIG.HealingType.hitPoints.name',
|
||||
group: 'Global'
|
||||
},
|
||||
stress: {
|
||||
id: 'stress',
|
||||
label: 'DAGGERHEART.CONFIG.HealingType.stress.name',
|
||||
group: 'Global'
|
||||
},
|
||||
hope: {
|
||||
id: 'hope',
|
||||
label: 'Hope',
|
||||
group: 'TYPES.Actor.character'
|
||||
},
|
||||
stress: {
|
||||
id: 'stress',
|
||||
label: 'DAGGERHEART.CONFIG.HealingType.Stress.Name',
|
||||
group: 'TYPES.Actor.character'
|
||||
},
|
||||
armor: {
|
||||
id: 'armor',
|
||||
label: 'Armor Stack',
|
||||
group: 'TYPES.Actor.character'
|
||||
},
|
||||
hp: {
|
||||
id: 'hp',
|
||||
label: 'DAGGERHEART.CONFIG.HealingType.HitPoints.Name',
|
||||
group: 'TYPES.Actor.character'
|
||||
},
|
||||
prayer: {
|
||||
id: 'prayer',
|
||||
label: 'Prayer Dice',
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ export class DHActionRollData extends foundry.abstract.DataModel {
|
|||
label: 'Should be'
|
||||
}),
|
||||
treshold: new fields.NumberField({ initial: 1, integer: true, min: 1, label: 'Treshold' })
|
||||
})
|
||||
}),
|
||||
useDefault: new fields.BooleanField({ initial: false })
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -47,7 +48,6 @@ export class DHActionRollData extends foundry.abstract.DataModel {
|
|||
formula = `${multiplier}${this.diceRolling.dice}cs${CONFIG.DH.ACTIONS.diceCompare[this.diceRolling.compare].operator}${this.diceRolling.treshold}`;
|
||||
break;
|
||||
default:
|
||||
// formula = `${(!!this.parent?.actor?.system?.attack ? `@attackBonus` : `@traits.${this.trait}.total`)}`;
|
||||
formula = '';
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,9 +14,15 @@ export default class DHAttackAction extends DHDamageAction {
|
|||
|
||||
prepareData() {
|
||||
super.prepareData();
|
||||
if (this.damage.includeBase && !!this.item?.system?.damage) {
|
||||
const baseDamage = this.getParentDamage();
|
||||
this.damage.parts.unshift(new DHDamageData(baseDamage));
|
||||
if(!!this.item?.system?.attack) {
|
||||
if (this.damage.includeBase) {
|
||||
const baseDamage = this.getParentDamage();
|
||||
this.damage.parts.unshift(new DHDamageData(baseDamage));
|
||||
}
|
||||
if(this.roll.useDefault) {
|
||||
this.roll.trait = this.item.system.attack.roll.trait;
|
||||
this.roll.type = 'weapon';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -24,10 +30,10 @@ export default class DHAttackAction extends DHDamageAction {
|
|||
return {
|
||||
value: {
|
||||
multiplier: 'prof',
|
||||
dice: this.item?.system?.damage.dice,
|
||||
bonus: this.item?.system?.damage.bonus ?? 0
|
||||
dice: this.item?.system?.attack.damage.parts[0].value.dice,
|
||||
bonus: this.item?.system?.attack.damage.parts[0].value.bonus ?? 0
|
||||
},
|
||||
type: this.item?.system?.damage.type,
|
||||
type: this.item?.system?.attack.damage.parts[0].type,
|
||||
base: true
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,17 +156,22 @@ export default class DHBaseAction extends foundry.abstract.DataModel {
|
|||
static getSourceConfig(parent) {
|
||||
const updateSource = {};
|
||||
updateSource.img ??= parent?.img ?? parent?.system?.img;
|
||||
if (parent?.system?.trait) {
|
||||
updateSource['roll'] = {
|
||||
type: this.getRollType(parent),
|
||||
trait: parent.system.trait
|
||||
};
|
||||
}
|
||||
if (parent?.type === 'weapon' && !!this.schema.fields.damage) {
|
||||
if (parent?.type === 'weapon') {
|
||||
updateSource['damage'] = { includeBase: true };
|
||||
}
|
||||
if (parent?.system?.range) {
|
||||
updateSource['range'] = parent?.system?.range;
|
||||
updateSource['range'] = parent?.system?.attack?.range;
|
||||
updateSource['roll'] = {
|
||||
useDefault: true
|
||||
}
|
||||
} else {
|
||||
if (parent?.system?.trait) {
|
||||
updateSource['roll'] = {
|
||||
type: this.getRollType(parent),
|
||||
trait: parent.system.trait
|
||||
};
|
||||
}
|
||||
if (parent?.system?.range) {
|
||||
updateSource['range'] = parent?.system?.range;
|
||||
}
|
||||
}
|
||||
return updateSource;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,9 @@ export default class DhpAdversary extends BaseDataActor {
|
|||
damage: {
|
||||
parts: [
|
||||
{
|
||||
multiplier: 'flat'
|
||||
value: {
|
||||
multiplier: 'flat'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,10 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
|
|||
return this.parent.actor;
|
||||
}
|
||||
|
||||
get actionsList() {
|
||||
return this.actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain a data object used to evaluate any dice rolls associated with this Item Type
|
||||
* @param {object} [options] - Options which modify the getRollData method.
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export default class DHWeapon extends BaseDataItem {
|
|||
hasDescription: true,
|
||||
isQuantifiable: true,
|
||||
isInventoryItem: true,
|
||||
hasInitialAction: true
|
||||
// hasInitialAction: true
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -25,19 +25,8 @@ export default class DHWeapon extends BaseDataItem {
|
|||
|
||||
//SETTINGS
|
||||
secondary: new fields.BooleanField({ initial: false }),
|
||||
trait: new fields.StringField({ required: true, choices: CONFIG.DH.ACTOR.abilities, initial: 'agility' }),
|
||||
range: new fields.StringField({ required: true, choices: CONFIG.DH.GENERAL.range, initial: 'melee' }),
|
||||
burden: new fields.StringField({ required: true, choices: CONFIG.DH.GENERAL.burden, initial: 'oneHanded' }),
|
||||
//DAMAGE
|
||||
damage: new fields.SchemaField({
|
||||
dice: new fields.StringField({ choices: CONFIG.DH.GENERAL.diceTypes, initial: 'd6' }),
|
||||
bonus: new fields.NumberField({ nullable: true, initial: null }),
|
||||
type: new fields.StringField({
|
||||
required: true,
|
||||
choices: CONFIG.DH.GENERAL.damageTypes,
|
||||
initial: 'physical'
|
||||
})
|
||||
}),
|
||||
|
||||
features: new fields.ArrayField(
|
||||
new fields.SchemaField({
|
||||
value: new fields.StringField({
|
||||
|
|
@ -49,10 +38,42 @@ export default class DHWeapon extends BaseDataItem {
|
|||
actionIds: new fields.ArrayField(new fields.StringField({ required: true }))
|
||||
})
|
||||
),
|
||||
attack: new ActionField({
|
||||
initial: {
|
||||
name: 'Attack',
|
||||
img: 'icons/skills/melee/blood-slash-foam-red.webp',
|
||||
_id: foundry.utils.randomID(),
|
||||
systemPath: 'attack',
|
||||
type: 'attack',
|
||||
range: 'melee',
|
||||
target: {
|
||||
type: 'any',
|
||||
amount: 1
|
||||
},
|
||||
roll: {
|
||||
trait: 'agility',
|
||||
type: 'weapon'
|
||||
},
|
||||
damage: {
|
||||
parts: [
|
||||
{
|
||||
value: {
|
||||
multiplier: 'prof',
|
||||
dice: "d8"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}),
|
||||
actions: new fields.ArrayField(new ActionField())
|
||||
};
|
||||
}
|
||||
|
||||
get actionsList() {
|
||||
return [this.attack, ...this.actions];
|
||||
}
|
||||
|
||||
async _preUpdate(changes, options, user) {
|
||||
const allowed = await super._preUpdate(changes, options, user);
|
||||
if (allowed === false) return false;
|
||||
|
|
|
|||
|
|
@ -77,10 +77,10 @@ export default class DHItem extends foundry.documents.Item {
|
|||
});
|
||||
}
|
||||
|
||||
async selectActionDialog() {
|
||||
async selectActionDialog(prevEvent) {
|
||||
const content = await foundry.applications.handlebars.renderTemplate(
|
||||
'systems/daggerheart/templates/dialogs/actionSelect.hbs',
|
||||
{ actions: this.system.actions }
|
||||
{ actions: this.system.actionsList }
|
||||
),
|
||||
title = 'Select Action';
|
||||
|
||||
|
|
@ -89,19 +89,23 @@ export default class DHItem extends foundry.documents.Item {
|
|||
content,
|
||||
ok: {
|
||||
label: title,
|
||||
callback: (event, button, dialog) =>
|
||||
this.system.actions.find(a => a._id === button.form.elements.actionId.value)
|
||||
callback: (event, button, dialog) => {
|
||||
Object.defineProperty(prevEvent, "shiftKey", {
|
||||
get() { return event.shiftKey; },
|
||||
});
|
||||
return this.system.actionsList.find(a => a._id === button.form.elements.actionId.value)
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async use(event) {
|
||||
const actions = this.system.actions;
|
||||
const actions = this.system.actionsList;
|
||||
if (actions?.length) {
|
||||
let action = actions[0];
|
||||
if (actions.length > 1 && !event?.shiftKey) {
|
||||
// Actions Choice Dialog
|
||||
action = await this.selectActionDialog();
|
||||
action = await this.selectActionDialog(event);
|
||||
}
|
||||
if (action) return action.use(event);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue