mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-17 15:39:02 +01:00
.
This commit is contained in:
parent
57548b4cc4
commit
16d839a881
6 changed files with 34 additions and 59 deletions
|
|
@ -10,7 +10,7 @@ import { enricherConfig, enricherRenderSetup } from './module/enrichers/_module.
|
|||
import { getCommandTarget, rollCommandToJSON } from './module/helpers/utils.mjs';
|
||||
import { BaseRoll, DHRoll, DualityRoll, D20Roll, DamageRoll, FateRoll } from './module/dice/_module.mjs';
|
||||
import { enrichedDualityRoll } from './module/enrichers/DualityRollEnricher.mjs';
|
||||
import { enrichedFateRoll, getFateType } from './module/enrichers/FateRollEnricher.mjs';
|
||||
import { enrichedFateRoll, getFateTypeData } from './module/enrichers/FateRollEnricher.mjs';
|
||||
import {
|
||||
handlebarsRegistration,
|
||||
runMigrations,
|
||||
|
|
@ -322,29 +322,26 @@ Hooks.on('chatMessage', (_, message) => {
|
|||
if (message.startsWith('/fr')) {
|
||||
const result =
|
||||
message.trim().toLowerCase() === '/fr' ? { result: {} } : rollCommandToJSON(message.replace(/\/fr\s?/, ''));
|
||||
|
||||
if (!result) {
|
||||
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.fateParsing'));
|
||||
return false;
|
||||
}
|
||||
|
||||
const { result: rollCommand, flavor } = result;
|
||||
const fateTypeData = getFateTypeData(rollCommand?.type);
|
||||
|
||||
const fateTypeFromRollCommand = getFateType(rollCommand?.type);
|
||||
|
||||
if (fateTypeFromRollCommand == 'BAD') {
|
||||
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.fateTypeParsing'));
|
||||
return false;
|
||||
}
|
||||
|
||||
const fateType = fateTypeFromRollCommand;
|
||||
if (!fateTypeData)
|
||||
return ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.fateTypeParsing'));
|
||||
|
||||
const { value: fateType, label: fateTypeLabel } = fateTypeData;
|
||||
const target = getCommandTarget({ allowNull: true });
|
||||
const title = fateType + ' Fate Roll';
|
||||
const title = flavor ?? game.i18n.localize('DAGGERHEART.GENERAL.fateRoll');
|
||||
|
||||
enrichedFateRoll({
|
||||
target,
|
||||
title,
|
||||
label: 'test',
|
||||
label: fateTypeLabel,
|
||||
fateType
|
||||
});
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -2679,7 +2679,7 @@
|
|||
"riskItAllFailure": "The fear die rolled higher. You have crossed through the veil of death.",
|
||||
"blazeOfGlory": "Blaze of Glory Effect Added!",
|
||||
"riskItAllDialogButton": "Clear Stress And Hit Points.",
|
||||
"riskItAllSuccessWithEnoughHope": "Hope roll value is more than the marked Stress and Hit Points. Both are cleared fully.",
|
||||
"riskItAllSuccessWithEnoughHope": "The Hope value is more than the marked Stress and Hit Points. Both are cleared fully.",
|
||||
"riskItAllSuccess": "The hope die rolled higher, clear up to {hope} Stress And Hit Points."
|
||||
},
|
||||
"dicePool": {
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
context.formula = this.roll.constructFormula(this.config);
|
||||
if (this.actor?.system?.traits) context.abilities = this.getTraitModifiers();
|
||||
|
||||
context.showReaction = !this.config.roll?.type || context.rollType === 'DualityRoll';
|
||||
context.showReaction = !this.config.skips?.reaction && context.rollType === 'DualityRoll';
|
||||
context.reactionOverride = this.reactionOverride;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ export default class DhDeathMove extends HandlebarsApplicationMixin(ApplicationV
|
|||
label: game.i18n.localize('DAGGERHEART.GENERAL.dualityDice'),
|
||||
actionType: null,
|
||||
advantage: null,
|
||||
customConfig: { skips: { resources: true } }
|
||||
customConfig: { skips: { resources: true, reaction: true } }
|
||||
});
|
||||
|
||||
if (!config.roll.result) return;
|
||||
|
|
|
|||
|
|
@ -4,56 +4,35 @@ export default function DhFateRollEnricher(match, _options) {
|
|||
const roll = rollCommandToJSON(match[1], match[0]);
|
||||
if (!roll) return match[0];
|
||||
|
||||
const fateTypeFromRoll = getFateType(roll?.type);
|
||||
|
||||
if (fateTypeFromRoll == 'BAD') {
|
||||
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.fateTypeParsing'));
|
||||
return;
|
||||
}
|
||||
|
||||
return getFateMessage(roll.result, roll?.flavor);
|
||||
}
|
||||
|
||||
export function getFateType(fateTypeValue) {
|
||||
const fateTypeFromValue = fateTypeValue
|
||||
? fateTypeValue.toLowerCase() == 'fear'
|
||||
? 'Fear'
|
||||
: fateTypeValue.toLowerCase() == 'hope'
|
||||
? 'Hope'
|
||||
: 'BAD'
|
||||
: 'Hope';
|
||||
|
||||
return fateTypeFromValue;
|
||||
export function getFateTypeData(fateTypeValue) {
|
||||
const value = fateTypeValue ? fateTypeValue.capitalize() : 'Hope';
|
||||
const lowercased = fateTypeValue?.toLowerCase?.() ?? 'hope';
|
||||
switch (lowercased) {
|
||||
case 'hope':
|
||||
case 'fear':
|
||||
return { value, label: game.i18n.localize(`DAGGERHEART.GENERAL.${lowercased}`) };
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function getFateMessage(roll, flavor) {
|
||||
const fateType = getFateType(roll?.type);
|
||||
const fateTypeData = getFateTypeData(roll?.type);
|
||||
|
||||
if (fateType == 'BAD') {
|
||||
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.fateTypeParsing'));
|
||||
return '';
|
||||
}
|
||||
if (!fateTypeData)
|
||||
return ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.fateTypeParsing'));
|
||||
|
||||
const fateTypeLocalized =
|
||||
fateType === 'Hope'
|
||||
? game.i18n.localize('DAGGERHEART.GENERAL.hope')
|
||||
: game.i18n.localize('DAGGERHEART.GENERAL.fear');
|
||||
|
||||
const title =
|
||||
flavor ??
|
||||
fateTypeLocalized +
|
||||
' ' +
|
||||
game.i18n.localize('DAGGERHEART.GENERAL.fate') +
|
||||
' ' +
|
||||
game.i18n.localize('DAGGERHEART.GENERAL.roll');
|
||||
|
||||
const dataLabel = game.i18n.localize('DAGGERHEART.GENERAL.fate');
|
||||
const { value: fateType, label: fateTypeLabel } = fateTypeData;
|
||||
const title = flavor ?? game.i18n.localize('DAGGERHEART.GENERAL.fateRoll');
|
||||
|
||||
const fateElement = document.createElement('span');
|
||||
fateElement.innerHTML = `
|
||||
<button type="button" class="fate-roll-button${roll?.inline ? ' inline' : ''}"
|
||||
data-title="${title}"
|
||||
data-label="${dataLabel}"
|
||||
data-label="${fateTypeLabel}"
|
||||
data-fateType="${fateType}"
|
||||
>
|
||||
${title}
|
||||
|
|
@ -68,19 +47,17 @@ export const renderFateButton = async event => {
|
|||
target = getCommandTarget({ allowNull: true });
|
||||
console.log('button', button);
|
||||
|
||||
const fateTypeFromButton = getFateType(button.dataset?.fatetype);
|
||||
const fateTypeData = getFateTypeData(button.dataset?.fatetype);
|
||||
|
||||
if (fateTypeFromButton == 'BAD') {
|
||||
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.fateTypeParsing'));
|
||||
return;
|
||||
}
|
||||
if (!fateTypeData) ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.fateTypeParsing'));
|
||||
const { value: fateType, label: fateTypeLabel } = fateTypeData;
|
||||
|
||||
await enrichedFateRoll(
|
||||
{
|
||||
target,
|
||||
title: button.dataset.title,
|
||||
label: button.dataset.label,
|
||||
fateType: fateTypeFromButton
|
||||
fateType: fateType
|
||||
},
|
||||
event
|
||||
);
|
||||
|
|
@ -93,7 +70,8 @@ export const enrichedFateRoll = async ({ target, title, label, fateType }, event
|
|||
headerTitle: label,
|
||||
roll: {},
|
||||
hasRoll: true,
|
||||
fateType: fateType
|
||||
fateType: fateType,
|
||||
skips: { reaction: true }
|
||||
};
|
||||
|
||||
config.data = { experiences: {}, traits: {}, fateType: fateType };
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
</div>
|
||||
|
||||
<div class="code-mirror-wrapper {{#if trigger.revealed}}revealed{{/if}}">
|
||||
{{formInput @root.fields.triggers.element.fields.command value=trigger.command elementType="code-mirror" name=(concat "triggers." index ".command") aria=(object label=(localize "Test")) }}
|
||||
{{formInput @root.fields.triggers.element.fields.command value=trigger.command elementType="code-mirror" name=(concat "triggers." index ".command") }}
|
||||
</div>
|
||||
</fieldset>
|
||||
{{/each}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue