mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Fix async/await roll postEvaluate (#417)
* Fix async/await roll postEvaluate * Fixed DualityReroll DiceSoNice * Add chatDisplay: false to actors base attack * Add chatDisplay: false to downtime actions * Add Action Type Select item name in header --------- Co-authored-by: WBHarry <williambjrklund@gmail.com>
This commit is contained in:
parent
01f5173aa4
commit
e6bfe08d83
9 changed files with 36 additions and 20 deletions
|
|
@ -144,6 +144,7 @@ export const defaultRestOptions = {
|
|||
name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.tendToWounds.name'),
|
||||
img: 'icons/magic/life/cross-worn-green.webp',
|
||||
actionType: 'action',
|
||||
chatDisplay: false,
|
||||
healing: {
|
||||
applyTo: healingTypes.hitPoints.id,
|
||||
value: {
|
||||
|
|
@ -168,6 +169,7 @@ export const defaultRestOptions = {
|
|||
name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.clearStress.name'),
|
||||
img: 'icons/magic/perception/eye-ringed-green.webp',
|
||||
actionType: 'action',
|
||||
chatDisplay: false,
|
||||
healing: {
|
||||
applyTo: healingTypes.stress.id,
|
||||
value: {
|
||||
|
|
@ -192,6 +194,7 @@ export const defaultRestOptions = {
|
|||
name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.shortRest.repairArmor.name'),
|
||||
img: 'icons/skills/trades/smithing-anvil-silver-red.webp',
|
||||
actionType: 'action',
|
||||
chatDisplay: false,
|
||||
healing: {
|
||||
applyTo: healingTypes.armorStack.id,
|
||||
value: {
|
||||
|
|
@ -226,6 +229,7 @@ export const defaultRestOptions = {
|
|||
name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.longRest.tendToWounds.name'),
|
||||
img: 'icons/magic/life/cross-worn-green.webp',
|
||||
actionType: 'action',
|
||||
chatDisplay: false,
|
||||
healing: {
|
||||
applyTo: healingTypes.hitPoints.id,
|
||||
value: {
|
||||
|
|
@ -250,6 +254,7 @@ export const defaultRestOptions = {
|
|||
name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.longRest.clearStress.name'),
|
||||
img: 'icons/magic/perception/eye-ringed-green.webp',
|
||||
actionType: 'action',
|
||||
chatDisplay: false,
|
||||
healing: {
|
||||
applyTo: healingTypes.stress.id,
|
||||
value: {
|
||||
|
|
@ -274,6 +279,7 @@ export const defaultRestOptions = {
|
|||
name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Downtime.longRest.repairArmor.name'),
|
||||
img: 'icons/skills/trades/smithing-anvil-silver-red.webp',
|
||||
actionType: 'action',
|
||||
chatDisplay: false,
|
||||
healing: {
|
||||
applyTo: healingTypes.armorStack.id,
|
||||
value: {
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ export default class DhpAdversary extends BaseDataActor {
|
|||
img: 'icons/skills/melee/blood-slash-foam-red.webp',
|
||||
_id: foundry.utils.randomID(),
|
||||
systemPath: 'attack',
|
||||
chatDisplay: false,
|
||||
type: 'attack',
|
||||
range: 'melee',
|
||||
target: {
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ export default class DhCharacter extends BaseDataActor {
|
|||
img: 'icons/skills/melee/unarmed-punch-fist-yellow-red.webp',
|
||||
_id: foundry.utils.randomID(),
|
||||
systemPath: 'attack',
|
||||
chatDisplay: false,
|
||||
type: 'attack',
|
||||
range: 'melee',
|
||||
target: {
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ export default class DhCompanion extends BaseDataActor {
|
|||
img: 'icons/creatures/claws/claw-bear-paw-swipe-brown.webp',
|
||||
_id: foundry.utils.randomID(),
|
||||
systemPath: 'attack',
|
||||
chatDisplay: false,
|
||||
type: 'attack',
|
||||
range: 'melee',
|
||||
target: {
|
||||
|
|
|
|||
|
|
@ -175,7 +175,10 @@ export function ActionMixin(Base) {
|
|||
classes: ['daggerheart', 'dh-style'],
|
||||
content: await foundry.applications.handlebars.renderTemplate(
|
||||
'systems/daggerheart/templates/actionTypes/actionType.hbs',
|
||||
{ types: CONFIG.DH.ACTIONS.actionTypes }
|
||||
{
|
||||
types: CONFIG.DH.ACTIONS.actionTypes,
|
||||
itemName: parent.parent?.name
|
||||
}
|
||||
),
|
||||
ok: {
|
||||
label: game.i18n.format('DOCUMENT.Create', {
|
||||
|
|
|
|||
|
|
@ -140,8 +140,8 @@ export default class D20Roll extends DHRoll {
|
|||
return modifiers;
|
||||
}
|
||||
|
||||
static async postEvaluate(roll, config = {}) {
|
||||
const data = await super.postEvaluate(roll, config);
|
||||
static postEvaluate(roll, config = {}) {
|
||||
const data = super.postEvaluate(roll, config);
|
||||
if (config.targets?.length) {
|
||||
config.targets.forEach(target => {
|
||||
const difficulty = config.roll.difficulty ?? target.difficulty ?? target.evasion;
|
||||
|
|
@ -184,7 +184,7 @@ export default class D20Roll extends DHRoll {
|
|||
static async reroll(rollString, _target, message) {
|
||||
let parsedRoll = game.system.api.dice.D20Roll.fromData(rollString);
|
||||
parsedRoll = await parsedRoll.reroll();
|
||||
const newRoll = await game.system.api.dice.D20Roll.postEvaluate(parsedRoll, {
|
||||
const newRoll = game.system.api.dice.D20Roll.postEvaluate(parsedRoll, {
|
||||
targets: message.system.targets,
|
||||
roll: {
|
||||
advantage: message.system.roll.advantage?.type,
|
||||
|
|
|
|||
|
|
@ -25,10 +25,10 @@ export default class DamageRoll extends DHRoll {
|
|||
config.roll = this.unifyDamageRoll(parts);
|
||||
}
|
||||
|
||||
static async postEvaluate(roll, config = {}) {
|
||||
static postEvaluate(roll, config = {}) {
|
||||
return {
|
||||
...roll,
|
||||
...(await super.postEvaluate(roll.roll, config)),
|
||||
...super.postEvaluate(roll.roll, config),
|
||||
damageTypes: [...(roll.damageTypes ?? [])],
|
||||
roll: roll.roll,
|
||||
type: config.type,
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ export default class DHRoll extends Roll {
|
|||
|
||||
static async buildEvaluate(roll, config = {}, message = {}) {
|
||||
if (config.evaluate !== false) await roll.evaluate();
|
||||
config.roll = await this.postEvaluate(roll, config);
|
||||
config.roll = this.postEvaluate(roll, config);
|
||||
}
|
||||
|
||||
static async buildPost(roll, config, message) {
|
||||
|
|
@ -67,7 +67,7 @@ export default class DHRoll extends Roll {
|
|||
} else config.message = await this.toMessage(roll, config);
|
||||
}
|
||||
|
||||
static async postEvaluate(roll, config = {}) {
|
||||
static postEvaluate(roll, config = {}) {
|
||||
return {
|
||||
total: roll.total,
|
||||
formula: roll.formula,
|
||||
|
|
|
|||
|
|
@ -166,8 +166,20 @@ export default class DualityRoll extends D20Roll {
|
|||
return modifiers;
|
||||
}
|
||||
|
||||
static async postEvaluate(roll, config = {}) {
|
||||
const data = await super.postEvaluate(roll, config);
|
||||
static async buildEvaluate(roll, config = {}, message = {}) {
|
||||
await super.buildEvaluate(roll, config, message);
|
||||
|
||||
await setDiceSoNiceForDualityRoll(
|
||||
roll,
|
||||
config.roll.advantage.type,
|
||||
config.roll.hope.dice,
|
||||
config.roll.fear.dice,
|
||||
config.roll.advantage.dice
|
||||
);
|
||||
}
|
||||
|
||||
static postEvaluate(roll, config = {}) {
|
||||
const data = super.postEvaluate(roll, config);
|
||||
|
||||
data.hope = {
|
||||
dice: roll.dHope.denomination,
|
||||
|
|
@ -198,14 +210,6 @@ export default class DualityRoll extends D20Roll {
|
|||
if (roll._rallyIndex && roll.data?.parent)
|
||||
roll.data.parent.deleteEmbeddedDocuments('ActiveEffect', [roll._rallyIndex]);
|
||||
|
||||
await setDiceSoNiceForDualityRoll(
|
||||
roll,
|
||||
data.advantage.type,
|
||||
data.hope.dice,
|
||||
data.fear.dice,
|
||||
data.advantage.dice
|
||||
);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
|
@ -226,7 +230,7 @@ export default class DualityRoll extends D20Roll {
|
|||
options: { appearance: {} }
|
||||
};
|
||||
|
||||
const diceSoNicePresets = await getDiceSoNicePresets();
|
||||
const diceSoNicePresets = await getDiceSoNicePresets(`d${term._faces}`, `d${term._faces}`);
|
||||
const type = target.dataset.type;
|
||||
if (diceSoNicePresets[type]) {
|
||||
diceSoNiceRoll.dice[0].options = diceSoNicePresets[type];
|
||||
|
|
@ -237,7 +241,7 @@ export default class DualityRoll extends D20Roll {
|
|||
|
||||
await parsedRoll.evaluate();
|
||||
|
||||
const newRoll = await game.system.api.dice.DualityRoll.postEvaluate(parsedRoll, {
|
||||
const newRoll = game.system.api.dice.DualityRoll.postEvaluate(parsedRoll, {
|
||||
targets: message.system.targets,
|
||||
roll: {
|
||||
advantage: message.system.roll.advantage?.type,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue