mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +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 { 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 target = getCommandTarget({ allowNull: true });
|
||||||
const title = fateType + ' Fate Roll';
|
const title = fateType + ' Fate Roll';
|
||||||
|
|
|
||||||
|
|
@ -2685,7 +2685,8 @@
|
||||||
"noAssignedPlayerCharacter": "You have no assigned character.",
|
"noAssignedPlayerCharacter": "You have no assigned character.",
|
||||||
"noSelectedToken": "You have no selected token",
|
"noSelectedToken": "You have no selected token",
|
||||||
"onlyUseableByPC": "This can only be used with a PC 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",
|
"attributeFaulty": "The supplied Attribute doesn't exist",
|
||||||
"domainCardWrongDomain": "You don't have access to that Domain",
|
"domainCardWrongDomain": "You don't have access to that Domain",
|
||||||
"domainCardToHighLevel": "The Domain Card is too high level to be selected",
|
"domainCardToHighLevel": "The Domain Card is too high level to be selected",
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,30 @@
|
||||||
import { getCommandTarget, rollCommandToJSON } from '../helpers/utils.mjs';
|
import { getCommandTarget, rollCommandToJSON } from '../helpers/utils.mjs';
|
||||||
|
|
||||||
export default function DhFateRollEnricher(match, _options) {
|
export default function DhFateRollEnricher(match, _options) {
|
||||||
console.log("match", match);
|
|
||||||
const roll = rollCommandToJSON(match[1], match[0]);
|
const roll = rollCommandToJSON(match[1], match[0]);
|
||||||
if (!roll) return match[0];
|
if (!roll) return match[0];
|
||||||
console.log("roll", roll);
|
|
||||||
|
|
||||||
return getFateMessage(roll.result, roll?.flavor);
|
return getFateMessage(roll.result, roll?.flavor);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFateMessage(roll, flavor) {
|
function getFateMessage(roll, flavor) {
|
||||||
console.log("roll", roll);
|
const fateType = roll?.type ?? 'Hope';
|
||||||
const label = flavor ?? 'Fate';
|
const fateTypeLocalized = fateType === "Hope" ? game.i18n.localize("DAGGERHEART.GENERAL.hope") : game.i18n.localize("DAGGERHEART.GENERAL.fear");
|
||||||
const fateType = roll?.type ?? 'Hope'
|
|
||||||
|
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 dataLabel = game.i18n.localize('DAGGERHEART.GENERAL.fate');
|
||||||
|
|
||||||
const fateElement = document.createElement('span');
|
const fateElement = document.createElement('span');
|
||||||
fateElement.innerHTML = `
|
fateElement.innerHTML = `
|
||||||
<button type="button" class="fate-roll-button${roll?.inline ? ' inline' : ''}"
|
<button type="button" class="fate-roll-button${roll?.inline ? ' inline' : ''}"
|
||||||
data-title="${label}"
|
data-title="${title}"
|
||||||
data-label="${dataLabel}"
|
data-label="${dataLabel}"
|
||||||
data-fateType="${fateType}"
|
data-fateType="${fateType}"
|
||||||
>
|
>
|
||||||
${fateType} ${label} Roll
|
${title}
|
||||||
</button>
|
</button>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|
@ -39,7 +40,7 @@ export const renderFateButton = async event => {
|
||||||
target,
|
target,
|
||||||
title: button.dataset.title,
|
title: button.dataset.title,
|
||||||
label: button.dataset.label,
|
label: button.dataset.label,
|
||||||
fateType: button.dataset.fateType
|
fateType: button.dataset.fatetype
|
||||||
},
|
},
|
||||||
event
|
event
|
||||||
);
|
);
|
||||||
|
|
@ -59,12 +60,7 @@ export const enrichedFateRoll = async (
|
||||||
fateType: fateType
|
fateType: fateType
|
||||||
};
|
};
|
||||||
|
|
||||||
if (target) {
|
config.data = { experiences: {}, traits: {}, fateType: fateType };
|
||||||
await target.diceRoll(config);
|
config.source = { actor: target?.uuid };
|
||||||
} else {
|
await CONFIG.Dice.daggerheart.FateRoll.build(config);
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue