mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
Fixed enricher button; localization fixes; debug cleanup
This commit is contained in:
parent
7d0011792f
commit
3c75c0f6c6
3 changed files with 24 additions and 18 deletions
|
|
@ -259,7 +259,16 @@ Hooks.on('chatMessage', (_, message) => {
|
|||
|
||||
const { result: rollCommand, flavor } = result;
|
||||
|
||||
const fateType = rollCommand.type ?? "Hope";
|
||||
const fateTypeFromRollCommand = rollCommand?.type ?
|
||||
(rollCommand?.type?.toLowerCase() == "fear" ? "Fear" :
|
||||
(rollCommand?.type?.toLowerCase() == "hope" ? "Hope" : "BAD")) : "Hope";
|
||||
|
||||
if (fateTypeFromRollCommand == "BAD") {
|
||||
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.fateParsing'));
|
||||
return false;
|
||||
}
|
||||
|
||||
const fateType = fateTypeFromRollCommand;
|
||||
|
||||
const target = getCommandTarget({ allowNull: true });
|
||||
const title = fateType + ' Fate Roll';
|
||||
|
|
|
|||
|
|
@ -2685,7 +2685,8 @@
|
|||
"noAssignedPlayerCharacter": "You have no assigned character.",
|
||||
"noSelectedToken": "You have no selected token",
|
||||
"onlyUseableByPC": "This can only be used with a PC token",
|
||||
"dualityParsing": "Duality roll not properly formated",
|
||||
"dualityParsing": "Duality roll not properly formatted",
|
||||
"fateParsing": "Fate roll not properly formatted",
|
||||
"attributeFaulty": "The supplied Attribute doesn't exist",
|
||||
"domainCardWrongDomain": "You don't have access to that Domain",
|
||||
"domainCardToHighLevel": "The Domain Card is too high level to be selected",
|
||||
|
|
|
|||
|
|
@ -1,29 +1,30 @@
|
|||
import { getCommandTarget, rollCommandToJSON } from '../helpers/utils.mjs';
|
||||
|
||||
export default function DhFateRollEnricher(match, _options) {
|
||||
console.log("match", match);
|
||||
const roll = rollCommandToJSON(match[1], match[0]);
|
||||
if (!roll) return match[0];
|
||||
console.log("roll", roll);
|
||||
|
||||
return getFateMessage(roll.result, roll?.flavor);
|
||||
}
|
||||
|
||||
function getFateMessage(roll, flavor) {
|
||||
console.log("roll", roll);
|
||||
const label = flavor ?? 'Fate';
|
||||
const fateType = roll?.type ?? 'Hope'
|
||||
const fateType = roll?.type ?? 'Hope';
|
||||
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 fateElement = document.createElement('span');
|
||||
fateElement.innerHTML = `
|
||||
<button type="button" class="fate-roll-button${roll?.inline ? ' inline' : ''}"
|
||||
data-title="${label}"
|
||||
data-title="${title}"
|
||||
data-label="${dataLabel}"
|
||||
data-fateType="${fateType}"
|
||||
>
|
||||
${fateType} ${label} Roll
|
||||
${title}
|
||||
</button>
|
||||
`;
|
||||
|
||||
|
|
@ -39,7 +40,7 @@ export const renderFateButton = async event => {
|
|||
target,
|
||||
title: button.dataset.title,
|
||||
label: button.dataset.label,
|
||||
fateType: button.dataset.fateType
|
||||
fateType: button.dataset.fatetype
|
||||
},
|
||||
event
|
||||
);
|
||||
|
|
@ -59,12 +60,7 @@ export const enrichedFateRoll = async (
|
|||
fateType: fateType
|
||||
};
|
||||
|
||||
if (target) {
|
||||
await target.diceRoll(config);
|
||||
} else {
|
||||
// For no target, call FateRoll directly with basic data
|
||||
config.data = { experiences: {}, traits: {}, fateType: fateType };
|
||||
config.source = { actor: null };
|
||||
await CONFIG.Dice.daggerheart.FateRoll.build(config);
|
||||
}
|
||||
config.data = { experiences: {}, traits: {}, fateType: fateType };
|
||||
config.source = { actor: target?.uuid };
|
||||
await CONFIG.Dice.daggerheart.FateRoll.build(config);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue