mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Temp
This commit is contained in:
parent
2599d1287d
commit
f9c30b583c
4 changed files with 72 additions and 4 deletions
|
|
@ -10,6 +10,7 @@ import DhpChatLog from './module/ui/chatLog.mjs';
|
||||||
import DhpPlayers from './module/ui/players.mjs';
|
import DhpPlayers from './module/ui/players.mjs';
|
||||||
import DhpRuler from './module/ui/ruler.mjs';
|
import DhpRuler from './module/ui/ruler.mjs';
|
||||||
import DhpTokenRuler from './module/ui/tokenRuler.mjs';
|
import DhpTokenRuler from './module/ui/tokenRuler.mjs';
|
||||||
|
import { dualityRollEnricher } from './module/enrichers/DualityRollEnricher.mjs';
|
||||||
|
|
||||||
globalThis.SYSTEM = SYSTEM;
|
globalThis.SYSTEM = SYSTEM;
|
||||||
|
|
||||||
|
|
@ -21,6 +22,11 @@ Hooks.once('init', () => {
|
||||||
documents
|
documents
|
||||||
};
|
};
|
||||||
|
|
||||||
|
CONFIG.TextEditor.enrichers.push({
|
||||||
|
pattern: /\[\[\/dr\s?(.*?)\]\]/g,
|
||||||
|
enricher: dualityRollEnricher
|
||||||
|
});
|
||||||
|
|
||||||
CONFIG.statusEffects = Object.values(SYSTEM.GENERAL.conditions).map(x => ({
|
CONFIG.statusEffects = Object.values(SYSTEM.GENERAL.conditions).map(x => ({
|
||||||
...x,
|
...x,
|
||||||
name: game.i18n.localize(x.name)
|
name: game.i18n.localize(x.name)
|
||||||
|
|
@ -89,7 +95,6 @@ Hooks.once('init', () => {
|
||||||
game.socket.on(`system.${SYSTEM.id}`, handleSocketEvent);
|
game.socket.on(`system.${SYSTEM.id}`, handleSocketEvent);
|
||||||
|
|
||||||
registerDHPSettings();
|
registerDHPSettings();
|
||||||
|
|
||||||
RegisterHandlebarsHelpers.registerHelpers();
|
RegisterHandlebarsHelpers.registerHelpers();
|
||||||
|
|
||||||
return preloadHandlebarsTemplates();
|
return preloadHandlebarsTemplates();
|
||||||
|
|
@ -121,6 +126,29 @@ Hooks.on(socketEvent.GMUpdate, async (action, uuid, update) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Hooks.on('renderChatMessageHTML', (message, element) => {
|
||||||
|
element.querySelectorAll('.duality-roll-button').forEach(element =>
|
||||||
|
element.addEventListener('click', async event => {
|
||||||
|
const button = event.currentTarget;
|
||||||
|
let target = game.canvas.tokens.controlled.length > 0 ? game.canvas.tokens.controlled[0].actor : null;
|
||||||
|
if (!game.user.isGM) {
|
||||||
|
target = game.user.character;
|
||||||
|
if (!target) {
|
||||||
|
notifications.error('DAGGERHEART.Notification.Error.NoAssignedPlayerCharacter');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!target) {
|
||||||
|
notifications.error('DAGGERHEART.Notification.Error.NoSelectedToken');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const test = await gmTarget.diceRoll(3);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
const preloadHandlebarsTemplates = async function () {
|
const preloadHandlebarsTemplates = async function () {
|
||||||
return foundry.applications.handlebars.loadTemplates([
|
return foundry.applications.handlebars.loadTemplates([
|
||||||
'systems/daggerheart/templates/sheets/parts/attributes.hbs',
|
'systems/daggerheart/templates/sheets/parts/attributes.hbs',
|
||||||
|
|
|
||||||
|
|
@ -93,13 +93,16 @@
|
||||||
"LacksDomain": "Your character doesn't have the domain of the card!",
|
"LacksDomain": "Your character doesn't have the domain of the card!",
|
||||||
"MaxLoadoutReached": "You can't have any more domain cards at this level!",
|
"MaxLoadoutReached": "You can't have any more domain cards at this level!",
|
||||||
"DuplicateDomainCard": "You already have a domain card with that name!",
|
"DuplicateDomainCard": "You already have a domain card with that name!",
|
||||||
"ActionRequiresTarget": "The action requires at least one target"
|
"ActionRequiresTarget": "The action requires at least one target",
|
||||||
|
"NoAssignedPlayerCharacter": "You have no assigned character.",
|
||||||
|
"NoSelectedToken": "You have no selected token"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"General": {
|
"General": {
|
||||||
"OpenBetaDisclaimer": "Daggerheart Open Beta {version}",
|
|
||||||
"Hope": "Hope",
|
"Hope": "Hope",
|
||||||
"Fear": "Fear",
|
"Fear": "Fear",
|
||||||
|
"Duality": "Duality",
|
||||||
|
"Check": "{check} Check",
|
||||||
"CriticalSuccess": "Critical Success",
|
"CriticalSuccess": "Critical Success",
|
||||||
"Advantage": "Advantage",
|
"Advantage": "Advantage",
|
||||||
"Disadvantage": "Disadvantage",
|
"Disadvantage": "Disadvantage",
|
||||||
|
|
|
||||||
38
module/enrichers/DualityRollEnricher.mjs
Normal file
38
module/enrichers/DualityRollEnricher.mjs
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
import { abilities } from '../config/actorConfig.mjs';
|
||||||
|
|
||||||
|
export async function dualityRollEnricher(match, _options) {
|
||||||
|
try {
|
||||||
|
const {
|
||||||
|
hope = 'd12',
|
||||||
|
fear = 'd12',
|
||||||
|
attribute,
|
||||||
|
advantage,
|
||||||
|
disadvantage
|
||||||
|
} = JSON.parse(`{${match[1].replace(' ', ',').replace(/(\w+(?==))(=)/g, '"$1":')}}`);
|
||||||
|
const dualityElement = document.createElement('span');
|
||||||
|
|
||||||
|
const attributeLabel =
|
||||||
|
attribute && abilities[attribute]
|
||||||
|
? game.i18n.format('DAGGERHEART.General.Check', {
|
||||||
|
check: game.i18n.localize(abilities[attribute].label)
|
||||||
|
})
|
||||||
|
: null;
|
||||||
|
const label = attributeLabel ?? game.i18n.localize('DAGGERHEART.General.Duality');
|
||||||
|
dualityElement.innerHTML = `
|
||||||
|
<button class="duality-roll-button"
|
||||||
|
data-hope="${hope}"
|
||||||
|
data-fear="${fear}"
|
||||||
|
${attribute ? `data-attribute="${attribute}"` : ''}
|
||||||
|
${advantage ? 'data-advantage="true"' : ''}
|
||||||
|
${disadvantage ? 'data-disadvantage="true"' : ''}
|
||||||
|
>
|
||||||
|
<i class="fa-solid fa-circle-half-stroke"></i>
|
||||||
|
${label}
|
||||||
|
</button>
|
||||||
|
`;
|
||||||
|
|
||||||
|
return dualityElement;
|
||||||
|
} catch (_) {
|
||||||
|
return match[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -76,7 +76,6 @@
|
||||||
<div class="tab features {{this.tabs.primary.features.cssClass}}" data-group="primary" data-tab="features">
|
<div class="tab features {{this.tabs.primary.features.cssClass}}" data-group="primary" data-tab="features">
|
||||||
<div class="tab-container">
|
<div class="tab-container">
|
||||||
<div class="flexcol tab-inner-container">
|
<div class="flexcol tab-inner-container">
|
||||||
<div class="system-info">{{localize "DAGGERHEART.General.OpenBetaDisclaimer" version="V1.4"}}</div>
|
|
||||||
<div class="feature-sheet-body flexrow">
|
<div class="feature-sheet-body flexrow">
|
||||||
<div class="body-section flex2">
|
<div class="body-section flex2">
|
||||||
{{> "systems/daggerheart/templates/sheets/parts/defense.hbs" }}
|
{{> "systems/daggerheart/templates/sheets/parts/defense.hbs" }}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue