mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-18 07:59:03 +01:00
Fix conflict
This commit is contained in:
commit
dbb07008f0
677 changed files with 67498 additions and 579 deletions
|
|
@ -7,6 +7,7 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
this.roll = roll;
|
||||
this.config = config;
|
||||
this.config.experiences = [];
|
||||
this.reactionOverride = config.roll.type === 'reaction';
|
||||
|
||||
if (config.source?.action) {
|
||||
this.item = config.data.parent.items.get(config.source.item) ?? config.data.parent;
|
||||
|
|
@ -30,6 +31,7 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
actions: {
|
||||
updateIsAdvantage: this.updateIsAdvantage,
|
||||
selectExperience: this.selectExperience,
|
||||
toggleReaction: this.toggleReaction,
|
||||
submitRoll: this.submitRoll
|
||||
},
|
||||
form: {
|
||||
|
|
@ -103,6 +105,9 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
context.isLite = this.config.roll?.lite;
|
||||
context.extraFormula = this.config.extraFormula;
|
||||
context.formula = this.roll.constructFormula(this.config);
|
||||
|
||||
context.showReaction = !context.rollConfig.type && context.rollType === 'DualityRoll';
|
||||
context.reactionOverride = this.reactionOverride;
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
|
@ -141,7 +146,19 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
this.render();
|
||||
}
|
||||
|
||||
static toggleReaction() {
|
||||
if (this.config.roll) {
|
||||
this.reactionOverride = !this.reactionOverride;
|
||||
this.render();
|
||||
}
|
||||
}
|
||||
|
||||
static async submitRoll() {
|
||||
this.config.roll.type = this.reactionOverride
|
||||
? CONFIG.DH.ITEM.actionTypes.reaction.id
|
||||
: this.config.roll.type === CONFIG.DH.ITEM.actionTypes.reaction.id
|
||||
? null
|
||||
: this.config.roll.type;
|
||||
await this.close({ submitted: true });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap
|
|||
await super.close({});
|
||||
}
|
||||
|
||||
static async armorStackQuery({ actorId, damage, type }) {
|
||||
static async armorSlotQuery({ actorId, damage, type }) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const actor = await fromUuid(actorId);
|
||||
if (!actor || !actor?.isOwner) reject();
|
||||
|
|
|
|||
|
|
@ -108,9 +108,11 @@ export default class DHActionConfig extends DaggerheartSheet(ApplicationV2) {
|
|||
context.hasBaseDamage = !!this.action.parent.attack;
|
||||
context.getEffectDetails = this.getEffectDetails.bind(this);
|
||||
context.costOptions = this.getCostOptions();
|
||||
context.getRollTypeOptions = this.getRollTypeOptions();
|
||||
context.disableOption = this.disableOption.bind(this);
|
||||
context.isNPC = this.action.actor?.isNPC;
|
||||
context.baseSaveDifficulty = this.action.actor?.baseSaveDifficulty;
|
||||
context.baseAttackBonus = this.action.actor?.system.attack?.roll.bonus;
|
||||
context.hasRoll = this.action.hasRoll;
|
||||
|
||||
const settingsTiers = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LevelTiers).tiers;
|
||||
|
|
@ -131,14 +133,23 @@ export default class DHActionConfig extends DaggerheartSheet(ApplicationV2) {
|
|||
const resource = this.action.parent.resource;
|
||||
if (resource) {
|
||||
options[this.action.parent.parent.id] = {
|
||||
label: this.action.parent.parent.name,
|
||||
group: 'TYPES.Actor.character'
|
||||
label: 'DAGGERHEART.GENERAL.itemResource',
|
||||
group: 'Global'
|
||||
};
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
getRollTypeOptions() {
|
||||
const types = foundry.utils.deepClone(CONFIG.DH.GENERAL.rollTypes);
|
||||
if (!this.action.actor) return types;
|
||||
Object.values(types).forEach(t => {
|
||||
if (this.action.actor.type !== 'character' && t.playerOnly) delete types[t.id];
|
||||
});
|
||||
return types;
|
||||
}
|
||||
|
||||
disableOption(index, costOptions, choices) {
|
||||
const filtered = foundry.utils.deepClone(costOptions);
|
||||
Object.keys(filtered).forEach(o => {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ export default class DhActiveEffectConfig extends foundry.applications.sheets.Ac
|
|||
header: { template: 'systems/daggerheart/templates/sheets/activeEffect/header.hbs' },
|
||||
tabs: { template: 'templates/generic/tab-navigation.hbs' },
|
||||
details: { template: 'systems/daggerheart/templates/sheets/activeEffect/details.hbs', scrollable: [''] },
|
||||
duration: { template: 'systems/daggerheart/templates/sheets/activeEffect/duration.hbs' },
|
||||
settings: { template: 'systems/daggerheart/templates/sheets/activeEffect/settings.hbs' },
|
||||
changes: {
|
||||
template: 'systems/daggerheart/templates/sheets/activeEffect/changes.hbs',
|
||||
scrollable: ['ol[data-changes]']
|
||||
|
|
@ -39,7 +39,7 @@ export default class DhActiveEffectConfig extends foundry.applications.sheets.Ac
|
|||
sheet: {
|
||||
tabs: [
|
||||
{ id: 'details', icon: 'fa-solid fa-book' },
|
||||
{ id: 'duration', icon: 'fa-solid fa-clock' },
|
||||
{ id: 'settings', icon: 'fa-solid fa-bars', label: 'DAGGERHEART.GENERAL.Tabs.settings' },
|
||||
{ id: 'changes', icon: 'fa-solid fa-gears' }
|
||||
],
|
||||
initial: 'details',
|
||||
|
|
|
|||
|
|
@ -43,25 +43,6 @@ export const actionTypes = {
|
|||
}
|
||||
};
|
||||
|
||||
export const targetTypes = {
|
||||
self: {
|
||||
id: 'self',
|
||||
label: 'Self'
|
||||
},
|
||||
friendly: {
|
||||
id: 'friendly',
|
||||
label: 'Friendly'
|
||||
},
|
||||
hostile: {
|
||||
id: 'hostile',
|
||||
label: 'Hostile'
|
||||
},
|
||||
any: {
|
||||
id: 'any',
|
||||
label: 'Any'
|
||||
}
|
||||
};
|
||||
|
||||
export const damageOnSave = {
|
||||
none: {
|
||||
id: 'none',
|
||||
|
|
|
|||
|
|
@ -43,6 +43,40 @@ export const range = {
|
|||
}
|
||||
};
|
||||
|
||||
export const rangeInclusion = {
|
||||
withinRange: {
|
||||
id: 'withinRange',
|
||||
label: 'DAGGERHEART.CONFIG.RangeInclusion.withinRange'
|
||||
},
|
||||
outsideRange: {
|
||||
id: 'outsideRange',
|
||||
label: 'DAGGERHEART.CONFIG.RangeInclusion.outsideRange'
|
||||
}
|
||||
};
|
||||
|
||||
export const otherTargetTypes = {
|
||||
friendly: {
|
||||
id: 'friendly',
|
||||
label: 'Friendly'
|
||||
},
|
||||
hostile: {
|
||||
id: 'hostile',
|
||||
label: 'Hostile'
|
||||
},
|
||||
any: {
|
||||
id: 'any',
|
||||
label: 'Any'
|
||||
}
|
||||
};
|
||||
|
||||
export const targetTypes = {
|
||||
self: {
|
||||
id: 'self',
|
||||
label: 'Self'
|
||||
},
|
||||
...otherTargetTypes
|
||||
};
|
||||
|
||||
export const burden = {
|
||||
oneHanded: {
|
||||
value: 'oneHanded',
|
||||
|
|
@ -85,10 +119,10 @@ export const healingTypes = {
|
|||
label: 'DAGGERHEART.CONFIG.HealingType.hope.name',
|
||||
abbreviation: 'DAGGERHEART.CONFIG.HealingType.hope.abbreviation'
|
||||
},
|
||||
armorStack: {
|
||||
id: 'armorStack',
|
||||
label: 'DAGGERHEART.CONFIG.HealingType.armorStack.name',
|
||||
abbreviation: 'DAGGERHEART.CONFIG.HealingType.armorStack.abbreviation'
|
||||
armorSlot: {
|
||||
id: 'armorSlot',
|
||||
label: 'DAGGERHEART.CONFIG.HealingType.armorSlot.name',
|
||||
abbreviation: 'DAGGERHEART.CONFIG.HealingType.armorSlot.abbreviation'
|
||||
},
|
||||
fear: {
|
||||
id: 'fear',
|
||||
|
|
@ -199,7 +233,7 @@ export const defaultRestOptions = {
|
|||
actionType: 'action',
|
||||
chatDisplay: false,
|
||||
healing: {
|
||||
applyTo: healingTypes.armorStack.id,
|
||||
applyTo: healingTypes.armorSlot.id,
|
||||
value: {
|
||||
custom: {
|
||||
enabled: true,
|
||||
|
|
@ -287,7 +321,7 @@ export const defaultRestOptions = {
|
|||
actionType: 'action',
|
||||
chatDisplay: false,
|
||||
healing: {
|
||||
applyTo: healingTypes.armorStack.id,
|
||||
applyTo: healingTypes.armorSlot.id,
|
||||
value: {
|
||||
custom: {
|
||||
enabled: true,
|
||||
|
|
@ -425,8 +459,8 @@ export const refreshTypes = {
|
|||
};
|
||||
|
||||
export const abilityCosts = {
|
||||
hp: {
|
||||
id: 'hp',
|
||||
hitPoints: {
|
||||
id: 'hitPoints',
|
||||
label: 'DAGGERHEART.CONFIG.HealingType.hitPoints.name',
|
||||
group: 'Global'
|
||||
},
|
||||
|
|
@ -473,11 +507,13 @@ export const rollTypes = {
|
|||
},
|
||||
spellcast: {
|
||||
id: 'spellcast',
|
||||
label: 'DAGGERHEART.CONFIG.RollTypes.spellcast.name'
|
||||
label: 'DAGGERHEART.CONFIG.RollTypes.spellcast.name',
|
||||
playerOnly: true
|
||||
},
|
||||
trait: {
|
||||
id: 'trait',
|
||||
label: 'DAGGERHEART.CONFIG.RollTypes.trait.name'
|
||||
label: 'DAGGERHEART.CONFIG.RollTypes.trait.name',
|
||||
playerOnly: true
|
||||
},
|
||||
diceSet: {
|
||||
id: 'diceSet',
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -181,13 +181,11 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
|||
|
||||
prepareRoll() {
|
||||
const roll = {
|
||||
modifiers: this.modifiers,
|
||||
trait: this.roll?.trait,
|
||||
baseModifiers: this.roll.getModifier(),
|
||||
label: 'Attack',
|
||||
type: this.actionType,
|
||||
difficulty: this.roll?.difficulty,
|
||||
formula: this.roll.getFormula(),
|
||||
bonus: this.roll.bonus,
|
||||
advantage: CONFIG.DH.ACTIONS.advantageState[this.roll.advState].value
|
||||
};
|
||||
if (this.roll?.type === 'diceSet') roll.lite = true;
|
||||
|
|
@ -201,6 +199,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
|||
|
||||
async consume(config) {
|
||||
const usefulResources = foundry.utils.deepClone(this.actor.system.resources);
|
||||
|
||||
for (var cost of config.costs) {
|
||||
if (cost.keyIsID) {
|
||||
usefulResources[cost.key] = {
|
||||
|
|
@ -223,17 +222,13 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
|||
});
|
||||
|
||||
await this.actor.modifyResource(resources);
|
||||
if (config.uses?.enabled) {
|
||||
const newActions = foundry.utils.getProperty(this.item.system, this.systemPath).map(x => x.toObject());
|
||||
newActions[this.index].uses.value++;
|
||||
await this.item.update({ [`system.${this.systemPath}`]: newActions });
|
||||
}
|
||||
if (config.uses?.enabled) this.update({ 'uses.value': this.uses.value + 1 });
|
||||
}
|
||||
/* */
|
||||
|
||||
/* ROLL */
|
||||
get hasRoll() {
|
||||
return !!this.roll?.type || !!this.roll?.bonus;
|
||||
return !!this.roll?.type;
|
||||
}
|
||||
|
||||
get modifiers() {
|
||||
|
|
@ -297,17 +292,16 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
|||
/* SAVE */
|
||||
async rollSave(actor, event, message) {
|
||||
if (!actor) return;
|
||||
return actor
|
||||
.diceRoll({
|
||||
event,
|
||||
title: 'Roll Save',
|
||||
roll: {
|
||||
trait: this.save.trait,
|
||||
difficulty: this.save.difficulty ?? this.actor?.baseSaveDifficulty,
|
||||
type: 'reaction'
|
||||
},
|
||||
data: actor.getRollData()
|
||||
});
|
||||
return actor.diceRoll({
|
||||
event,
|
||||
title: 'Roll Save',
|
||||
roll: {
|
||||
trait: this.save.trait,
|
||||
difficulty: this.save.difficulty ?? this.actor?.baseSaveDifficulty,
|
||||
type: 'reaction'
|
||||
},
|
||||
data: actor.getRollData()
|
||||
});
|
||||
}
|
||||
|
||||
updateSaveMessage(result, message, targetId) {
|
||||
|
|
@ -320,7 +314,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
|||
else updateMsg();
|
||||
}
|
||||
|
||||
static rollSaveQuery({ actionId, actorId, event, message }) {
|
||||
static rollSaveQuery({ actionId, actorId, event, message }) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const actor = await fromUuid(actorId),
|
||||
action = await fromUuid(actionId);
|
||||
|
|
|
|||
|
|
@ -4,15 +4,25 @@ import DHBaseAction from './baseAction.mjs';
|
|||
export default class DhBeastformAction extends DHBaseAction {
|
||||
static extraSchemas = [...super.extraSchemas, 'beastform'];
|
||||
|
||||
async use(_event, ...args) {
|
||||
async use(event, ...args) {
|
||||
const beastformConfig = this.prepareBeastformConfig();
|
||||
|
||||
const abort = await this.handleActiveTransformations();
|
||||
if (abort) return;
|
||||
|
||||
const calcCosts = game.system.api.fields.ActionFields.CostField.calcCosts.call(this, this.cost);
|
||||
const hasCost = game.system.api.fields.ActionFields.CostField.hasCost.call(this, calcCosts);
|
||||
if (!hasCost) {
|
||||
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.insufficientResources'));
|
||||
return;
|
||||
}
|
||||
|
||||
const { selected, evolved, hybrid } = await BeastformDialog.configure(beastformConfig, this.item);
|
||||
if (!selected) return;
|
||||
|
||||
const result = await super.use(event, args);
|
||||
if (!result) return;
|
||||
|
||||
await this.transform(selected, evolved, hybrid);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
import BaseEffect from './baseEffect.mjs';
|
||||
import BeastformEffect from './beastformEffect.mjs';
|
||||
|
||||
export { BeastformEffect };
|
||||
export { BaseEffect, BeastformEffect };
|
||||
|
||||
export const config = {
|
||||
base: BaseEffect,
|
||||
beastform: BeastformEffect
|
||||
};
|
||||
|
|
|
|||
33
module/data/activeEffect/baseEffect.mjs
Normal file
33
module/data/activeEffect/baseEffect.mjs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
export default class BaseEffect extends foundry.abstract.TypeDataModel {
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
|
||||
return {
|
||||
rangeDependence: new fields.SchemaField({
|
||||
enabled: new fields.BooleanField({
|
||||
required: true,
|
||||
initial: false,
|
||||
label: 'DAGGERHEART.GENERAL.enabled'
|
||||
}),
|
||||
type: new fields.StringField({
|
||||
required: true,
|
||||
choices: CONFIG.DH.GENERAL.rangeInclusion,
|
||||
initial: CONFIG.DH.GENERAL.rangeInclusion.withinRange.id,
|
||||
label: 'DAGGERHEART.GENERAL.type'
|
||||
}),
|
||||
target: new fields.StringField({
|
||||
required: true,
|
||||
choices: CONFIG.DH.GENERAL.otherTargetTypes,
|
||||
initial: CONFIG.DH.GENERAL.otherTargetTypes.hostile.id,
|
||||
label: 'DAGGERHEART.GENERAL.Target.single'
|
||||
}),
|
||||
range: new fields.StringField({
|
||||
required: true,
|
||||
choices: CONFIG.DH.GENERAL.range,
|
||||
initial: CONFIG.DH.GENERAL.range.melee.id,
|
||||
label: 'DAGGERHEART.GENERAL.range'
|
||||
})
|
||||
})
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
import { updateActorTokens } from '../../helpers/utils.mjs';
|
||||
import BaseEffect from './baseEffect.mjs';
|
||||
|
||||
export default class BeastformEffect extends foundry.abstract.TypeDataModel {
|
||||
export default class BeastformEffect extends BaseEffect {
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -397,14 +397,16 @@ export default class DhCharacter extends BaseDataActor {
|
|||
} else if (item.system.originItemType === CONFIG.DH.ITEM.featureTypes.class.id) {
|
||||
classFeatures.push(item);
|
||||
} else if (item.system.originItemType === CONFIG.DH.ITEM.featureTypes.subclass.id) {
|
||||
const subclassState = this.class.subclass.system.featureState;
|
||||
const subType = item.system.subType;
|
||||
if (
|
||||
subType === CONFIG.DH.ITEM.featureSubTypes.foundation ||
|
||||
(subType === CONFIG.DH.ITEM.featureSubTypes.specialization && subclassState >= 2) ||
|
||||
(subType === CONFIG.DH.ITEM.featureSubTypes.mastery && subclassState >= 3)
|
||||
) {
|
||||
subclassFeatures.push(item);
|
||||
if (this.class.subclass) {
|
||||
const subclassState = this.class.subclass.system.featureState;
|
||||
const subType = item.system.subType;
|
||||
if (
|
||||
subType === CONFIG.DH.ITEM.featureSubTypes.foundation ||
|
||||
(subType === CONFIG.DH.ITEM.featureSubTypes.specialization && subclassState >= 2) ||
|
||||
(subType === CONFIG.DH.ITEM.featureSubTypes.mastery && subclassState >= 3)
|
||||
) {
|
||||
subclassFeatures.push(item);
|
||||
}
|
||||
}
|
||||
} else if (item.system.originItemType === CONFIG.DH.ITEM.featureTypes.companion.id) {
|
||||
companionFeatures.push(item);
|
||||
|
|
@ -563,6 +565,12 @@ export default class DhCharacter extends BaseDataActor {
|
|||
this.resources.hope.value = Math.min(baseHope, this.resources.hope.max);
|
||||
this.attack.roll.trait = this.rules.attack.roll.trait ?? this.attack.roll.trait;
|
||||
|
||||
this.resources.armor = {
|
||||
value: this.armor.system.marks.value,
|
||||
max: this.armorScore,
|
||||
isReversed: true
|
||||
};
|
||||
|
||||
this.attack.damage.parts[0].value.custom.formula = `@prof${this.basicAttackDamageDice}${this.rules.attack.damage.bonus ? ` + ${this.rules.attack.damage.bonus}` : ''}`;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,11 +26,20 @@ export default class CostField extends fields.ArrayField {
|
|||
}
|
||||
|
||||
static calcCosts(costs) {
|
||||
console.log(costs, CostField.getResources.call(this, costs));
|
||||
const resources = CostField.getResources.call(this, costs);
|
||||
return costs.map(c => {
|
||||
c.scale = c.scale ?? 1;
|
||||
c.step = c.step ?? 1;
|
||||
c.total = c.value * c.scale * c.step;
|
||||
c.total = c.value + (c.scale - 1) * c.step;
|
||||
c.enabled = c.hasOwnProperty('enabled') ? c.enabled : true;
|
||||
c.max =
|
||||
c.key === 'fear'
|
||||
? game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Resources.Fear)
|
||||
: resources[c.key].isReversed
|
||||
? resources[c.key].max
|
||||
: resources[c.key].value;
|
||||
if (c.scalable) c.maxStep = Math.floor(c.max / c.step);
|
||||
return c;
|
||||
});
|
||||
}
|
||||
|
|
@ -51,9 +60,11 @@ export default class CostField extends fields.ArrayField {
|
|||
const resources = CostField.getResources.call(this, realCosts);
|
||||
return realCosts.reduce(
|
||||
(a, c) =>
|
||||
a && resources[c.key].isReversed
|
||||
? resources[c.key].value + (c.total ?? c.value) <= resources[c.key].max
|
||||
: resources[c.key]?.value >= (c.total ?? c.value),
|
||||
!resources[c.key]
|
||||
? a
|
||||
: a && resources[c.key].isReversed
|
||||
? resources[c.key].value + (c.total ?? c.value) <= resources[c.key].max
|
||||
: resources[c.key]?.value >= (c.total ?? c.value),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
|
@ -61,10 +72,11 @@ export default class CostField extends fields.ArrayField {
|
|||
static getResources(costs) {
|
||||
const actorResources = this.actor.system.resources;
|
||||
const itemResources = {};
|
||||
for (var itemResource of costs) {
|
||||
for (let itemResource of costs) {
|
||||
if (itemResource.keyIsID) {
|
||||
itemResources[itemResource.key] = {
|
||||
value: this.parent.resource.value ?? 0
|
||||
value: this.parent.resource.value ?? 0,
|
||||
max: CostField.formatMax.call(this, this.parent?.resource?.max)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -79,4 +91,13 @@ export default class CostField extends fields.ArrayField {
|
|||
const realCosts = costs?.length ? costs.filter(c => c.enabled) : [];
|
||||
return realCosts;
|
||||
}
|
||||
|
||||
static formatMax(max) {
|
||||
max ??= 0;
|
||||
if (isNaN(max)) {
|
||||
const roll = Roll.replaceFormulaData(max, this.getRollData());
|
||||
max = roll.total;
|
||||
}
|
||||
return Number(max);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,6 +66,43 @@ export class DHActionRollData extends foundry.abstract.DataModel {
|
|||
}
|
||||
return formula;
|
||||
}
|
||||
|
||||
getModifier() {
|
||||
const modifiers = [];
|
||||
if (!this.parent?.actor) return modifiers;
|
||||
switch (this.parent.actor.type) {
|
||||
case 'character':
|
||||
const trait =
|
||||
this.useDefault || !this.trait
|
||||
? (this.parent.item.system.attack.roll.trait ?? 'agility')
|
||||
: this.trait;
|
||||
if (
|
||||
this.type === CONFIG.DH.GENERAL.rollTypes.attack.id ||
|
||||
this.type === CONFIG.DH.GENERAL.rollTypes.trait.id
|
||||
)
|
||||
modifiers.push({
|
||||
label: `DAGGERHEART.CONFIG.Traits.${trait}.name`,
|
||||
value: this.parent.actor.system.traits[trait].value
|
||||
});
|
||||
else if (this.type === CONFIG.DH.GENERAL.rollTypes.spellcast.id)
|
||||
modifiers.push({
|
||||
label: `DAGGERHEART.CONFIG.RollTypes.spellcast.name`,
|
||||
value: this.parent.actor.system.spellcastModifier
|
||||
});
|
||||
break;
|
||||
case 'companion':
|
||||
case 'adversary':
|
||||
if (this.type === CONFIG.DH.GENERAL.rollTypes.attack.id)
|
||||
modifiers.push({
|
||||
label: 'Bonus to Hit',
|
||||
value: this.bonus ?? this.parent.actor.system.attack.roll.bonus
|
||||
});
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return modifiers;
|
||||
}
|
||||
}
|
||||
|
||||
export default class RollField extends fields.EmbeddedDataField {
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ export default class TargetField extends fields.SchemaField {
|
|||
constructor(options = {}, context = {}) {
|
||||
const targetFields = {
|
||||
type: new fields.StringField({
|
||||
choices: CONFIG.DH.ACTIONS.targetTypes,
|
||||
initial: CONFIG.DH.ACTIONS.targetTypes.any.id,
|
||||
choices: CONFIG.DH.GENERAL.targetTypes,
|
||||
initial: CONFIG.DH.GENERAL.targetTypes.any.id,
|
||||
nullable: true
|
||||
}),
|
||||
amount: new fields.NumberField({ nullable: true, initial: null, integer: true, min: 0 })
|
||||
|
|
@ -16,11 +16,11 @@ export default class TargetField extends fields.SchemaField {
|
|||
static prepareConfig(config) {
|
||||
if (!this.target?.type) return [];
|
||||
let targets;
|
||||
if (this.target?.type === CONFIG.DH.ACTIONS.targetTypes.self.id)
|
||||
if (this.target?.type === CONFIG.DH.GENERAL.targetTypes.self.id)
|
||||
targets = [this.actor.token ?? this.actor.prototypeToken];
|
||||
else {
|
||||
targets = Array.from(game.user.targets);
|
||||
if (this.target.type !== CONFIG.DH.ACTIONS.targetTypes.any.id) {
|
||||
if (this.target.type !== CONFIG.DH.GENERAL.targetTypes.any.id) {
|
||||
targets = targets.filter(t => TargetField.isTargetFriendly.call(this, t));
|
||||
if (this.target.amount && targets.length > this.target.amount) targets = [];
|
||||
}
|
||||
|
|
@ -43,9 +43,9 @@ export default class TargetField extends fields.SchemaField {
|
|||
: this.actor.prototypeToken.disposition,
|
||||
targetDisposition = target.document.disposition;
|
||||
return (
|
||||
(this.target.type === CONFIG.DH.ACTIONS.targetTypes.friendly.id &&
|
||||
(this.target.type === CONFIG.DH.GENERAL.targetTypes.friendly.id &&
|
||||
actorDisposition === targetDisposition) ||
|
||||
(this.target.type === CONFIG.DH.ACTIONS.targetTypes.hostile.id &&
|
||||
(this.target.type === CONFIG.DH.GENERAL.targetTypes.hostile.id &&
|
||||
actorDisposition + targetDisposition === 0)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
import FormulaField from '../formulaField.mjs';
|
||||
|
||||
const fields = foundry.data.fields;
|
||||
|
||||
export default class UsesField extends fields.SchemaField {
|
||||
constructor(options = {}, context = {}) {
|
||||
const usesFields = {
|
||||
value: new fields.NumberField({ nullable: true, initial: null }),
|
||||
max: new fields.NumberField({ nullable: true, initial: null }),
|
||||
max: new FormulaField({ nullable: true, initial: null, deterministic: true }),
|
||||
recovery: new fields.StringField({
|
||||
choices: CONFIG.DH.GENERAL.refreshTypes,
|
||||
initial: null,
|
||||
|
|
@ -33,6 +35,11 @@ export default class UsesField extends fields.SchemaField {
|
|||
|
||||
static hasUses(uses) {
|
||||
if (!uses) return true;
|
||||
return (uses.hasOwnProperty('enabled') && !uses.enabled) || uses.value + 1 <= uses.max;
|
||||
let max = uses.max ?? 0;
|
||||
if (isNaN(max)) {
|
||||
const roll = new Roll(Roll.replaceFormulaData(uses.max, this.getRollData())).evaluateSync();
|
||||
max = roll.total;
|
||||
}
|
||||
return (uses.hasOwnProperty('enabled') && !uses.enabled) || uses.value + 1 <= max;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,13 +71,14 @@ export default class DHArmor extends AttachableItem {
|
|||
for (var feature of added) {
|
||||
const featureData = armorFeatures[feature.value];
|
||||
if (featureData.effects?.length > 0) {
|
||||
const embeddedItems = await this.parent.createEmbeddedDocuments('ActiveEffect', [
|
||||
{
|
||||
name: game.i18n.localize(featureData.label),
|
||||
description: game.i18n.localize(featureData.description),
|
||||
changes: featureData.effects.flatMap(x => x.changes)
|
||||
}
|
||||
]);
|
||||
const embeddedItems = await this.parent.createEmbeddedDocuments(
|
||||
'ActiveEffect',
|
||||
featureData.effects.map(effect => ({
|
||||
...effect,
|
||||
name: game.i18n.localize(effect.name),
|
||||
description: game.i18n.localize(effect.description)
|
||||
}))
|
||||
);
|
||||
feature.effectIds = embeddedItems.map(x => x.id);
|
||||
}
|
||||
|
||||
|
|
@ -93,6 +94,7 @@ export default class DHArmor extends AttachableItem {
|
|||
description: game.i18n.localize(effect.description)
|
||||
}))
|
||||
);
|
||||
feature.effectIds = [...(feature.effectIds ?? []), ...embeddedEffects.map(x => x.id)];
|
||||
|
||||
const cls = game.system.api.models.actions.actionsTypes[action.type];
|
||||
const actionId = foundry.utils.randomID();
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
import { addLinkedItemsDiff, updateLinkedItemApps } from '../../helpers/utils.mjs';
|
||||
import { ActionsField } from '../fields/actionField.mjs';
|
||||
import FormulaField from '../fields/formulaField.mjs';
|
||||
|
||||
const fields = foundry.data.fields;
|
||||
|
||||
|
|
@ -48,7 +49,7 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
|
|||
initial: CONFIG.DH.ITEM.itemResourceTypes.simple
|
||||
}),
|
||||
value: new fields.NumberField({ integer: true, min: 0, initial: 0 }),
|
||||
max: new fields.StringField({ nullable: true, initial: null }),
|
||||
max: new FormulaField({ nullable: true, initial: null, deterministic: true }),
|
||||
icon: new fields.StringField(),
|
||||
recovery: new fields.StringField({
|
||||
choices: CONFIG.DH.GENERAL.refreshTypes,
|
||||
|
|
@ -122,26 +123,21 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
|
|||
|
||||
this.updateSource({ actions: [action] });
|
||||
}
|
||||
}
|
||||
|
||||
_onCreate(data, _, userId) {
|
||||
if (userId !== game.user.id) return;
|
||||
|
||||
if (!this.actor || this.actor.type !== 'character' || !this.features) return;
|
||||
|
||||
this.actor.createEmbeddedDocuments(
|
||||
'Item',
|
||||
this.features.map(feature => ({
|
||||
...(feature.item ?? feature),
|
||||
system: {
|
||||
...(feature.item?.system ?? feature.system),
|
||||
originItemType: this.parent.type,
|
||||
originId: data._id,
|
||||
identifier: feature.identifier,
|
||||
subType: feature.item ? feature.type : undefined
|
||||
}
|
||||
}))
|
||||
);
|
||||
if (this.actor && this.actor.type === 'character' && this.features) {
|
||||
for (let f of this.features) {
|
||||
const feature = f.item ?? f;
|
||||
const createData = foundry.utils.mergeObject(feature.toObject(), {
|
||||
system: {
|
||||
originItemType: this.parent.type,
|
||||
originId: data._id,
|
||||
identifier: feature.identifier,
|
||||
subType: feature.item ? feature.type : undefined
|
||||
}
|
||||
}, { inplace: false });
|
||||
await this.actor.createEmbeddedDocuments('Item', [createData]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async _preDelete() {
|
||||
|
|
|
|||
|
|
@ -118,13 +118,14 @@ export default class DHWeapon extends AttachableItem {
|
|||
for (let weaponFeature of added) {
|
||||
const featureData = CONFIG.DH.ITEM.weaponFeatures[weaponFeature.value];
|
||||
if (featureData.effects?.length > 0) {
|
||||
const embeddedItems = await this.parent.createEmbeddedDocuments('ActiveEffect', [
|
||||
{
|
||||
name: game.i18n.localize(featureData.label),
|
||||
description: game.i18n.localize(featureData.description),
|
||||
changes: featureData.effects.flatMap(x => x.changes)
|
||||
}
|
||||
]);
|
||||
const embeddedItems = await this.parent.createEmbeddedDocuments(
|
||||
'ActiveEffect',
|
||||
featureData.effects.map(effect => ({
|
||||
...effect,
|
||||
name: game.i18n.localize(effect.name),
|
||||
description: game.i18n.localize(effect.description)
|
||||
}))
|
||||
);
|
||||
weaponFeature.effectIds = embeddedItems.map(x => x.id);
|
||||
}
|
||||
|
||||
|
|
@ -140,6 +141,10 @@ export default class DHWeapon extends AttachableItem {
|
|||
description: game.i18n.localize(effect.description)
|
||||
}))
|
||||
);
|
||||
weaponFeature.effectIds = [
|
||||
...(weaponFeature.effectIds ?? []),
|
||||
...embeddedEffects.map(x => x.id)
|
||||
];
|
||||
|
||||
const cls = game.system.api.models.actions.actionsTypes[action.type];
|
||||
const actionId = foundry.utils.randomID();
|
||||
|
|
|
|||
|
|
@ -23,6 +23,12 @@ export default class DhAutomation extends foundry.abstract.DataModel {
|
|||
required: true,
|
||||
initial: true,
|
||||
label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.hordeDamage.label'
|
||||
}),
|
||||
effects: new fields.SchemaField({
|
||||
rangeDependent: new fields.BooleanField({
|
||||
initial: true,
|
||||
label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.effects.rangeDependent.label'
|
||||
})
|
||||
})
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,13 +130,7 @@ export default class D20Roll extends DHRoll {
|
|||
}
|
||||
|
||||
applyBaseBonus() {
|
||||
const modifiers = [];
|
||||
|
||||
if (this.options.roll.bonus)
|
||||
modifiers.push({
|
||||
label: 'Bonus to Hit',
|
||||
value: this.options.roll.bonus
|
||||
});
|
||||
const modifiers = foundry.utils.deepClone(this.options.roll.baseModifiers) ?? [];
|
||||
|
||||
modifiers.push(...this.getBonus(`roll.${this.options.type}`, `${this.options.type?.capitalize()} Bonus`));
|
||||
modifiers.push(
|
||||
|
|
|
|||
|
|
@ -85,9 +85,9 @@ export default class DamageRoll extends DHRoll {
|
|||
const modifiers = [],
|
||||
type = this.options.messageType ?? (this.options.isHealing ? 'healing' : 'damage'),
|
||||
options = part ?? this.options;
|
||||
|
||||
|
||||
modifiers.push(...this.getBonus(`${type}`, `${type.capitalize()} Bonus`));
|
||||
if(!this.options.isHealing) {
|
||||
if (!this.options.isHealing) {
|
||||
options.damageTypes?.forEach(t => {
|
||||
modifiers.push(...this.getBonus(`${type}.${t}`, `${t.capitalize()} ${type.capitalize()} Bonus`));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ export default class DHRoll extends Roll {
|
|||
|
||||
static postEvaluate(roll, config = {}) {
|
||||
return {
|
||||
type: config.roll.type,
|
||||
total: roll.total,
|
||||
formula: roll.formula,
|
||||
dice: roll.dice.map(d => ({
|
||||
|
|
@ -202,11 +203,12 @@ export const registerRollDiceHooks = () => {
|
|||
if (config.roll.result.duality === -1) updates.push({ key: 'fear', value: 1 });
|
||||
|
||||
if (config.rerolledRoll) {
|
||||
if (config.rerolledRoll.isCritical || config.rerolledRoll.result.duality === 1) updates.push({ key: 'hope', value: -1 });
|
||||
if (config.rerolledRoll.isCritical || config.rerolledRoll.result.duality === 1)
|
||||
updates.push({ key: 'hope', value: -1 });
|
||||
if (config.rerolledRoll.isCritical) updates.push({ key: 'stress', value: 1 });
|
||||
if (config.rerolledRoll.result.duality === -1) updates.push({ key: 'fear', value: -1 });
|
||||
}
|
||||
|
||||
|
||||
if (updates.length) {
|
||||
const target = actor.system.partner ?? actor;
|
||||
if (!['dead', 'unconcious'].some(x => actor.statuses.has(x))) {
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ export default class DualityRoll extends D20Roll {
|
|||
}
|
||||
|
||||
setRallyChoices() {
|
||||
return this.data?.parent?.effects.reduce((a, c) => {
|
||||
return this.data?.parent?.appliedEffects.reduce((a, c) => {
|
||||
const change = c.changes.find(ch => ch.key === 'system.bonuses.rally');
|
||||
if (change) a.push({ value: c.id, label: change.value });
|
||||
return a;
|
||||
|
|
|
|||
|
|
@ -481,7 +481,9 @@ export default class DhpActor extends Actor {
|
|||
this.system.armor &&
|
||||
this.#canReduceDamage(hpDamage.value, hpDamage.damageTypes)
|
||||
) {
|
||||
const armorStackResult = await this.owner.query('armorStack', {
|
||||
const armorSlotResult = await this.owner.query(
|
||||
'armorSlot',
|
||||
{
|
||||
actorId: this.uuid,
|
||||
damage: hpDamage.value,
|
||||
type: [...hpDamage.damageTypes]
|
||||
|
|
@ -490,11 +492,11 @@ export default class DhpActor extends Actor {
|
|||
timeout: 30000
|
||||
}
|
||||
);
|
||||
if (armorStackResult) {
|
||||
const { modifiedDamage, armorSpent, stressSpent } = armorStackResult;
|
||||
if (armorSlotResult) {
|
||||
const { modifiedDamage, armorSpent, stressSpent } = armorSlotResult;
|
||||
updates.find(u => u.key === 'hitPoints').value = modifiedDamage;
|
||||
updates.push(
|
||||
...(armorSpent ? [{ value: armorSpent, key: 'armorStack' }] : []),
|
||||
...(armorSpent ? [{ value: armorSpent, key: 'armor' }] : []),
|
||||
...(stressSpent ? [{ value: stressSpent, key: 'stress' }] : [])
|
||||
);
|
||||
}
|
||||
|
|
@ -569,6 +571,7 @@ export default class DhpActor extends Actor {
|
|||
armor: { target: this.system.armor, resources: {} },
|
||||
items: {}
|
||||
};
|
||||
|
||||
resources.forEach(r => {
|
||||
if (r.keyIsID) {
|
||||
updates.items[r.key] = {
|
||||
|
|
@ -584,7 +587,7 @@ export default class DhpActor extends Actor {
|
|||
game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Resources.Fear) + r.value
|
||||
);
|
||||
break;
|
||||
case 'armorStack':
|
||||
case 'armor':
|
||||
updates.armor.resources['system.marks.value'] = Math.max(
|
||||
Math.min(this.system.armor.system.marks.value + r.value, this.system.armorScore),
|
||||
0
|
||||
|
|
|
|||
|
|
@ -52,7 +52,8 @@ export default class DHToken extends TokenDocument {
|
|||
for (const [name, field] of Object.entries(schema.fields)) {
|
||||
const p = _path.concat([name]);
|
||||
if (field instanceof foundry.data.fields.NumberField) attributes.value.push(p);
|
||||
if (field instanceof foundry.data.fields.BooleanField && field.options.isAttributeChoice) attributes.value.push(p);
|
||||
if (field instanceof foundry.data.fields.BooleanField && field.options.isAttributeChoice)
|
||||
attributes.value.push(p);
|
||||
if (field instanceof foundry.data.fields.StringField) attributes.value.push(p);
|
||||
if (field instanceof foundry.data.fields.ArrayField) attributes.value.push(p);
|
||||
const isSchema = field instanceof foundry.data.fields.SchemaField;
|
||||
|
|
|
|||
|
|
@ -2,22 +2,23 @@ import { abilities } from '../config/actorConfig.mjs';
|
|||
import { getCommandTarget, rollCommandToJSON } from '../helpers/utils.mjs';
|
||||
|
||||
export default function DhDualityRollEnricher(match, _options) {
|
||||
const roll = rollCommandToJSON(match[1]);
|
||||
const roll = rollCommandToJSON(match[1], match[0]);
|
||||
if (!roll) return match[0];
|
||||
|
||||
return getDualityMessage(roll);
|
||||
return getDualityMessage(roll.result, roll.flavor);
|
||||
}
|
||||
|
||||
function getDualityMessage(roll) {
|
||||
const traitLabel =
|
||||
roll.trait && abilities[roll.trait]
|
||||
? game.i18n.format('DAGGERHEART.GENERAL.check', {
|
||||
check: game.i18n.localize(abilities[roll.trait].label)
|
||||
})
|
||||
: null;
|
||||
function getDualityMessage(roll, flavor) {
|
||||
const trait = roll.trait && abilities[roll.trait] ? game.i18n.localize(abilities[roll.trait].label) : null;
|
||||
const label =
|
||||
flavor ??
|
||||
(roll.trait
|
||||
? game.i18n.format('DAGGERHEART.GENERAL.rollWith', { roll: trait })
|
||||
: roll.reaction
|
||||
? game.i18n.localize('DAGGERHEART.GENERAL.reactionRoll')
|
||||
: game.i18n.localize('DAGGERHEART.GENERAL.duality'));
|
||||
|
||||
const label = traitLabel ?? game.i18n.localize('DAGGERHEART.GENERAL.duality');
|
||||
const dataLabel = traitLabel
|
||||
const dataLabel = trait
|
||||
? game.i18n.localize(abilities[roll.trait].label)
|
||||
: game.i18n.localize('DAGGERHEART.GENERAL.duality');
|
||||
|
||||
|
|
@ -38,6 +39,7 @@ function getDualityMessage(roll) {
|
|||
<button class="duality-roll-button"
|
||||
data-title="${label}"
|
||||
data-label="${dataLabel}"
|
||||
data-reaction="${roll.reaction ? 'true' : 'false'}"
|
||||
data-hope="${roll.hope ?? 'd12'}"
|
||||
data-fear="${roll.fear ?? 'd12'}"
|
||||
${advantage ? `data-advantage="${advantage}"` : ''}
|
||||
|
|
@ -46,9 +48,9 @@ function getDualityMessage(roll) {
|
|||
${roll.advantage ? 'data-advantage="true"' : ''}
|
||||
${roll.disadvantage ? 'data-disadvantage="true"' : ''}
|
||||
>
|
||||
<i class="fa-solid fa-circle-half-stroke"></i>
|
||||
${roll.reaction ? '<i class="fa-solid fa-reply"></i>' : '<i class="fa-solid fa-circle-half-stroke"></i>'}
|
||||
${label}
|
||||
${roll.difficulty || advantageLabel ? `(${[roll.difficulty, advantageLabel ? game.i18n.localize(`DAGGERHEART.GENERAL.${advantageLabel}.short`) : null].filter(x => x).join(' ')})` : ''}
|
||||
${!flavor && (roll.difficulty || advantageLabel) ? `(${[roll.difficulty, advantageLabel ? game.i18n.localize(`DAGGERHEART.GENERAL.${advantageLabel}.short`) : null].filter(x => x).join(' ')})` : ''}
|
||||
</button>
|
||||
`;
|
||||
|
||||
|
|
@ -57,6 +59,7 @@ function getDualityMessage(roll) {
|
|||
|
||||
export const renderDualityButton = async event => {
|
||||
const button = event.currentTarget,
|
||||
reaction = button.dataset.reaction === 'true',
|
||||
traitValue = button.dataset.trait?.toLowerCase(),
|
||||
target = getCommandTarget({ allowNull: true }),
|
||||
difficulty = button.dataset.difficulty,
|
||||
|
|
@ -64,12 +67,12 @@ export const renderDualityButton = async event => {
|
|||
|
||||
await enrichedDualityRoll(
|
||||
{
|
||||
reaction,
|
||||
traitValue,
|
||||
target,
|
||||
difficulty,
|
||||
title: button.dataset.title,
|
||||
label: button.dataset.label,
|
||||
actionType: button.dataset.actionType,
|
||||
advantage
|
||||
},
|
||||
event
|
||||
|
|
@ -77,7 +80,7 @@ export const renderDualityButton = async event => {
|
|||
};
|
||||
|
||||
export const enrichedDualityRoll = async (
|
||||
{ traitValue, target, difficulty, title, label, actionType, advantage },
|
||||
{ reaction, traitValue, target, difficulty, title, label, advantage },
|
||||
event
|
||||
) => {
|
||||
const config = {
|
||||
|
|
@ -88,7 +91,7 @@ export const enrichedDualityRoll = async (
|
|||
label: label,
|
||||
difficulty: difficulty,
|
||||
advantage,
|
||||
type: actionType ?? null // Need check,
|
||||
type: reaction ? 'reaction' : null
|
||||
},
|
||||
chatMessage: {
|
||||
template: 'systems/daggerheart/templates/ui/chat/duality-roll.hbs'
|
||||
|
|
|
|||
|
|
@ -7,19 +7,19 @@ export { DhDamageEnricher, DhDualityRollEnricher, DhEffectEnricher, DhTemplateEn
|
|||
|
||||
export const enricherConfig = [
|
||||
{
|
||||
pattern: /^@Damage\[(.*)\]$/g,
|
||||
pattern: /^@Damage\[(.*)\]({.*})?$/g,
|
||||
enricher: DhDamageEnricher
|
||||
},
|
||||
{
|
||||
pattern: /\[\[\/dr\s?(.*?)\]\]/g,
|
||||
pattern: /\[\[\/dr\s?(.*?)\]\]({.*})?/g,
|
||||
enricher: DhDualityRollEnricher
|
||||
},
|
||||
{
|
||||
pattern: /^@Effect\[(.*)\]$/g,
|
||||
pattern: /^@Effect\[(.*)\]({.*})?$/g,
|
||||
enricher: DhEffectEnricher
|
||||
},
|
||||
{
|
||||
pattern: /^@Template\[(.*)\]$/g,
|
||||
pattern: /^@Template\[(.*)\]({.*})?$/g,
|
||||
enricher: DhTemplateEnricher
|
||||
}
|
||||
];
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ export default class RegisterHandlebarsHelpers {
|
|||
includes: this.includes,
|
||||
times: this.times,
|
||||
damageFormula: this.damageFormula,
|
||||
formulaValue: this.formulaValue,
|
||||
damageSymbols: this.damageSymbols,
|
||||
rollParsed: this.rollParsed,
|
||||
hasProperty: foundry.utils.hasProperty,
|
||||
|
|
@ -39,6 +40,15 @@ export default class RegisterHandlebarsHelpers {
|
|||
return instances.join(traitTotal > 0 ? ' + ' : ' - ');
|
||||
}
|
||||
|
||||
static formulaValue(formula, item) {
|
||||
if (isNaN(formula)) {
|
||||
const data = item.getRollData.bind(item)(),
|
||||
roll = new Roll(Roll.replaceFormulaData(formula, data)).evaluateSync();
|
||||
formula = roll.total;
|
||||
}
|
||||
return formula;
|
||||
}
|
||||
|
||||
static damageSymbols(damageParts) {
|
||||
const symbols = [...new Set(damageParts.reduce((a, c) => a.concat([...c.type]), []))].map(
|
||||
p => CONFIG.DH.GENERAL.damageTypes[p].icon
|
||||
|
|
|
|||
|
|
@ -5,9 +5,12 @@ export const capitalize = string => {
|
|||
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||
};
|
||||
|
||||
export function rollCommandToJSON(text) {
|
||||
export function rollCommandToJSON(text, raw) {
|
||||
if (!text) return {};
|
||||
|
||||
const flavorMatch = raw?.match(/{(.*)}$/);
|
||||
const flavor = flavorMatch ? flavorMatch[1] : null;
|
||||
|
||||
// Match key="quoted string" OR key=unquotedValue
|
||||
const PAIR_RE = /(\w+)=("(?:[^"\\]|\\.)*"|\S+)/g;
|
||||
const result = {};
|
||||
|
|
@ -28,7 +31,7 @@ export function rollCommandToJSON(text) {
|
|||
}
|
||||
result[key] = value;
|
||||
}
|
||||
return Object.keys(result).length > 0 ? result : null;
|
||||
return Object.keys(result).length > 0 ? { result, flavor } : null;
|
||||
}
|
||||
|
||||
export const getCommandTarget = (options = {}) => {
|
||||
|
|
@ -307,8 +310,8 @@ export function updateLinkedItemApps(options, sheet) {
|
|||
export const itemAbleRollParse = (value, actor, item) => {
|
||||
if (!value) return value;
|
||||
|
||||
const isItemTarget = value.toLowerCase().startsWith('item.');
|
||||
const slicedValue = isItemTarget ? value.slice(5) : value;
|
||||
const isItemTarget = value.toLowerCase().includes('item.@');
|
||||
const slicedValue = isItemTarget ? value.replaceAll(/item\.@/gi, '@') : value;
|
||||
try {
|
||||
return Roll.replaceFormulaData(slicedValue, isItemTarget ? item : actor);
|
||||
} catch (_) {
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ export const registerSocketHooks = () => {
|
|||
case GMUpdateEvent.UpdateSaveMessage:
|
||||
const action = await fromUuid(data.update.action),
|
||||
message = game.messages.get(data.update.message);
|
||||
if(!action || !message) return;
|
||||
if (!action || !message) return;
|
||||
action.updateSaveMessage(data.update.result, message, data.update.token);
|
||||
break;
|
||||
}
|
||||
|
|
@ -77,9 +77,9 @@ export const registerSocketHooks = () => {
|
|||
};
|
||||
|
||||
export const registerUserQueries = () => {
|
||||
CONFIG.queries.armorStack = DamageReductionDialog.armorStackQuery;
|
||||
CONFIG.queries.armorSlot = DamageReductionDialog.armorSlotQuery;
|
||||
CONFIG.queries.reactionRoll = game.system.api.models.actions.actionsTypes.base.rollSaveQuery;
|
||||
}
|
||||
};
|
||||
|
||||
export const emitAsGM = async (eventName, callback, update, uuid = null) => {
|
||||
if (!game.user.isGM) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue