mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-03-07 22:46:12 +01:00
Merge branch 'main' into refactor/275-actor-sheets-simplification
This commit is contained in:
commit
17a9630736
44 changed files with 358 additions and 251 deletions
|
|
@ -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
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,14 +10,10 @@ const fields = foundry.data.fields;
|
|||
|
||||
/*
|
||||
ToDo
|
||||
- Add setting and/or checkbox for cost and damage like
|
||||
- Target Check / Target Picker
|
||||
- Range Check
|
||||
- Area of effect and measurement placement
|
||||
- Summon Action create method
|
||||
|
||||
Other
|
||||
- Auto use action <= Into Roll
|
||||
*/
|
||||
|
||||
export default class DHBaseAction extends foundry.abstract.DataModel {
|
||||
|
|
@ -160,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;
|
||||
}
|
||||
|
|
@ -200,28 +201,23 @@ export default class DHBaseAction extends foundry.abstract.DataModel {
|
|||
const isFastForward = event.shiftKey || (!this.hasRoll && !this.hasSave);
|
||||
// Prepare base Config
|
||||
const initConfig = this.initActionConfig(event);
|
||||
// let config = this.initActionConfig(event);
|
||||
|
||||
// Prepare Targets
|
||||
const targetConfig = this.prepareTarget();
|
||||
if (isFastForward && !targetConfig) return ui.notifications.warn('Too many targets selected for that actions.');
|
||||
// config = this.prepareTarget(config);
|
||||
|
||||
// Prepare Range
|
||||
const rangeConfig = this.prepareRange();
|
||||
// config = this.prepareRange(config);
|
||||
|
||||
// Prepare Costs
|
||||
const costsConfig = this.prepareCost();
|
||||
if (isFastForward && !this.hasCost(costsConfig))
|
||||
return ui.notifications.warn("You don't have the resources to use that action.");
|
||||
// config = this.prepareUseCost(config)
|
||||
|
||||
// Prepare Uses
|
||||
const usesConfig = this.prepareUse();
|
||||
if (isFastForward && !this.hasUses(usesConfig))
|
||||
return ui.notifications.warn("That action doesn't have remaining uses.");
|
||||
// config = this.prepareUseCost(config)
|
||||
|
||||
// Prepare Roll Data
|
||||
const actorData = this.getRollData();
|
||||
|
|
@ -238,8 +234,9 @@ export default class DHBaseAction extends foundry.abstract.DataModel {
|
|||
if (Hooks.call(`${CONFIG.DH.id}.preUseAction`, this, config) === false) return;
|
||||
|
||||
// Display configuration window if necessary
|
||||
if (config.dialog?.configure && this.requireConfigurationDialog(config)) {
|
||||
config = await D20RollDialog.configure(config);
|
||||
// if (config.dialog?.configure && this.requireConfigurationDialog(config)) {
|
||||
if (this.requireConfigurationDialog(config)) {
|
||||
config = await D20RollDialog.configure(null, config);
|
||||
if (!config) return;
|
||||
}
|
||||
|
||||
|
|
@ -250,37 +247,6 @@ export default class DHBaseAction extends foundry.abstract.DataModel {
|
|||
if (!config) return;
|
||||
}
|
||||
|
||||
if (this.hasSave) {
|
||||
/* config.targets.forEach((t) => {
|
||||
if(t.hit) {
|
||||
const target = game.canvas.tokens.get(t.id),
|
||||
actor = target?.actor;
|
||||
if(!actor) return;
|
||||
actor.saveRoll({
|
||||
event,
|
||||
title: 'Roll Save',
|
||||
roll: {
|
||||
trait: this.save.trait,
|
||||
difficulty: this.save.difficulty
|
||||
},
|
||||
dialog: {
|
||||
configure: false
|
||||
},
|
||||
data: actor.getRollData()
|
||||
}).then(async (result) => {
|
||||
t.saved = result;
|
||||
setTimeout(async () => {
|
||||
const message = ui.chat.collection.get(config.message.id),
|
||||
msgTargets = message.system.targets,
|
||||
msgTarget = msgTargets.find(mt => mt.id === t.id);
|
||||
msgTarget.saved = result;
|
||||
await message.update({'system.targets': msgTargets});
|
||||
},100)
|
||||
})
|
||||
}
|
||||
}) */
|
||||
}
|
||||
|
||||
if (this.doFollowUp()) {
|
||||
if (this.rollDamage) await this.rollDamage(event, config);
|
||||
if (this.rollHealing) await this.rollHealing(event, config);
|
||||
|
|
@ -329,12 +295,12 @@ export default class DHBaseAction extends foundry.abstract.DataModel {
|
|||
}
|
||||
|
||||
prepareTarget() {
|
||||
if(!this.target?.type) return [];
|
||||
let targets;
|
||||
if (this.target?.type === CONFIG.DH.ACTIONS.targetTypes.self.id)
|
||||
targets = this.constructor.formatTarget(this.actor.token ?? this.actor.prototypeToken);
|
||||
targets = Array.from(game.user.targets);
|
||||
// foundry.CONST.TOKEN_DISPOSITIONS.FRIENDLY
|
||||
if (this.target?.type && this.target.type !== CONFIG.DH.ACTIONS.targetTypes.any.id) {
|
||||
if (this.target.type !== CONFIG.DH.ACTIONS.targetTypes.any.id) {
|
||||
targets = targets.filter(t => this.isTargetFriendly(t));
|
||||
if (this.target.amount && targets.length > this.target.amount) targets = [];
|
||||
}
|
||||
|
|
@ -540,6 +506,7 @@ export default class DHBaseAction extends foundry.abstract.DataModel {
|
|||
});
|
||||
});
|
||||
}
|
||||
/* SAVE */
|
||||
|
||||
async updateChatMessage(message, targetId, changes, chain = true) {
|
||||
setTimeout(async () => {
|
||||
|
|
@ -558,7 +525,6 @@ export default class DHBaseAction extends foundry.abstract.DataModel {
|
|||
});
|
||||
}
|
||||
}
|
||||
/* SAVE */
|
||||
|
||||
async toChat(origin) {
|
||||
const cls = getDocumentClass('ChatMessage');
|
||||
|
|
|
|||
|
|
@ -3,38 +3,16 @@ import DHBaseAction from './baseAction.mjs';
|
|||
export default class DHEffectAction extends DHBaseAction {
|
||||
static extraSchemas = ['effects', 'target'];
|
||||
|
||||
async use(event, ...args) {
|
||||
const config = await super.use(event, args);
|
||||
if (['error', 'warning'].includes(config.type)) return;
|
||||
return await this.chatApplyEffects(event, config);
|
||||
}
|
||||
async trigger(event, data) {
|
||||
if(this.effects.length) {
|
||||
const cls = getDocumentClass('ChatMessage'),
|
||||
msg = {
|
||||
type: 'applyEffect',
|
||||
user: game.user.id,
|
||||
system: data
|
||||
};
|
||||
|
||||
async chatApplyEffects(event, data) {
|
||||
const cls = getDocumentClass('ChatMessage'),
|
||||
systemData = {
|
||||
title: game.i18n.format('DAGGERHEART.UI.Chat.applyEffect.title', { name: this.name }),
|
||||
origin: this.actor._id,
|
||||
description: '',
|
||||
targets: data.targets.map(x => ({ id: x.id, name: x.name, img: x.img, hit: true })),
|
||||
action: {
|
||||
itemId: this.item._id,
|
||||
actionId: this._id
|
||||
}
|
||||
},
|
||||
msg = new cls({
|
||||
type: 'applyEffect',
|
||||
user: game.user.id,
|
||||
system: systemData,
|
||||
content: await foundry.applications.handlebars.renderTemplate(
|
||||
'systems/daggerheart/templates/ui/chat/apply-effects.hbs',
|
||||
systemData
|
||||
)
|
||||
});
|
||||
|
||||
cls.create(msg.toObject());
|
||||
}
|
||||
|
||||
get chatTemplate() {
|
||||
return 'systems/daggerheart/templates/ui/chat/apply-effects.hbs';
|
||||
return await cls.create(msg);
|
||||
} else this.toChat(this.id);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,9 @@ export default class DhpAdversary extends BaseDataActor {
|
|||
damage: {
|
||||
parts: [
|
||||
{
|
||||
multiplier: 'flat'
|
||||
value: {
|
||||
multiplier: 'flat'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import DHBaseAction from "../action/baseAction.mjs";
|
||||
|
||||
export default class DHApplyEffect extends foundry.abstract.TypeDataModel {
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
|
||||
return {
|
||||
title: new fields.StringField(),
|
||||
origin: new fields.StringField({}),
|
||||
description: new fields.StringField({}),
|
||||
targets: new fields.ArrayField(
|
||||
new fields.SchemaField({
|
||||
id: new fields.StringField({ required: true }),
|
||||
|
|
@ -14,10 +14,24 @@ export default class DHApplyEffect extends foundry.abstract.TypeDataModel {
|
|||
hit: new fields.BooleanField({ initial: false })
|
||||
})
|
||||
),
|
||||
action: new fields.SchemaField({
|
||||
itemId: new fields.StringField(),
|
||||
actionId: new fields.StringField()
|
||||
targetSelection: new fields.BooleanField({ initial: true }),
|
||||
source: new fields.SchemaField({
|
||||
actor: new fields.StringField(),
|
||||
item: new fields.StringField(),
|
||||
action: new fields.StringField()
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
prepareDerivedData() {
|
||||
this.hasHitTarget = this.targets.filter(t => t.hit === true).length > 0;
|
||||
this.currentTargets =
|
||||
this.targetSelection !== true
|
||||
? Array.from(game.user.targets).map(t => DHBaseAction.formatTarget(t))
|
||||
: this.targets;
|
||||
}
|
||||
|
||||
get messageTemplate() {
|
||||
return 'systems/daggerheart/templates/ui/chat/apply-effects.hbs';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
import { actionsTypes } from '../action/_module.mjs';
|
||||
|
||||
// Temporary Solution
|
||||
export default class ActionField extends foundry.data.fields.ObjectField {
|
||||
getModel(value) {
|
||||
return actionsTypes[value.type] ?? actionsTypes.attack;
|
||||
return game.system.api.models.actions.actionsTypes[value.type] ?? game.system.api.models.actions.actionsTypes.attack;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -47,6 +47,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;
|
||||
|
|
|
|||
|
|
@ -4,9 +4,21 @@ export default class DhAutomation extends foundry.abstract.DataModel {
|
|||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return {
|
||||
hope: new fields.BooleanField({ required: true, initial: false }),
|
||||
actionPoints: new fields.BooleanField({ required: true, initial: false }),
|
||||
countdowns: new fields.BooleanField({ requireD: true, initial: false })
|
||||
hope: new fields.BooleanField({
|
||||
required: true,
|
||||
initial: false,
|
||||
label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.hope.label'
|
||||
}), // Label need to be updated into something like "Duality Roll Auto Gain" + a hint
|
||||
actionPoints: new fields.BooleanField({
|
||||
required: true,
|
||||
initial: false,
|
||||
label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.actionPoints.label'
|
||||
}),
|
||||
countdowns: new fields.BooleanField({
|
||||
requireD: true,
|
||||
initial: false,
|
||||
label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.countdowns.label'
|
||||
})
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue