diff --git a/lang/de.json b/lang/de.json index a083c65..3be5527 100644 --- a/lang/de.json +++ b/lang/de.json @@ -416,7 +416,7 @@ "chat": { "luckPoint": "Glückspunkt", "destiny": "Schicksalsgunst", - "modify": "Nachträglich +2", + "modify": "Nachträglich", "cancel": "Abbrechen", "roll": "Würfeln", "reroll": "Neuwürfeln", diff --git a/source/index.ts b/source/index.ts index 693967e..927f44d 100644 --- a/source/index.ts +++ b/source/index.ts @@ -181,7 +181,7 @@ Hooks.on("getChatLogEntryContext", function (html, options) { const message = (game as Game).messages.get(li.attr("data-message-id")); // All must be true to show the reroll dialogue - return game["user"].character.id === (game as Game).actors.get(message["speaker"].actor).id && !message["flags"].rerolled; + return (game["user"].isGM || game["user"].character?.id === (game as Game).actors.get(message["speaker"].actor)?.id) && !message["flags"].rerolled; }, callback: (li) => reroll(li), } diff --git a/source/module/rolls/M5Roll.ts b/source/module/rolls/M5Roll.ts index 7d57af8..3935929 100644 --- a/source/module/rolls/M5Roll.ts +++ b/source/module/rolls/M5Roll.ts @@ -26,11 +26,11 @@ export class M5Roll { .map((rollName, index) => { indexMap.set(index, rollName); const formula = this.data.rolls[rollName]; - formula.formula = index === 0 ? formula.formula + " + " + this.data.b.modifier : formula.formula; + formula.formula = index === 0 ? formula.formula.replace(/(\d*d\d*)/, `{$1 + ${this.data.b.modifier}}`) : formula.formula; const roll = new Roll(formula.formula, this.data); return roll; }); - + console.log(rolls); this.pool = PoolTerm.fromRolls(rolls); console.log("evaluate", this._evaluated, this.pool); return this.pool.evaluate({ async: true }).then((results) => { @@ -110,14 +110,13 @@ export class M5Roll { if (!this._evaluated) await this.evaluate(); const rMode = checkOptions["rollMode"] || (game as Game).settings.get("core", "rollMode"); - const chatData = { type: CONST.CHAT_MESSAGE_TYPES.ROLL, content: await this.render(), speaker: ChatMessage.getSpeaker({ actor: this.actor }), sound: CONFIG.sounds.dice, roll: Roll.fromTerms([this.pool]), - flags: { data: this.data }, + flags: { data: this.data, rerolled: false, faces: this.pool.dice.map((x) => x.faces) }, }; let foo = ChatMessage.applyRollMode(chatData, rMode); diff --git a/source/module/rolls/reroll.ts b/source/module/rolls/reroll.ts index 32eee57..774eb3c 100644 --- a/source/module/rolls/reroll.ts +++ b/source/module/rolls/reroll.ts @@ -4,9 +4,11 @@ import { M5Roll } from "./M5Roll"; export const reroll = async (roll) => { const message = (game as Game).messages.get(roll.attr("data-message-id")); const actor = (game as Game).actors.get(message["speaker"].actor); + // const die const template = "systems/midgard5/templates/chat/reroll-dialog.hbs"; const html = await renderTemplate(template, { sg: actor.system.sg, gp: actor.system.gp }); + console.log(message["flags"].faces[0]); // Button defining let buttons = {}; buttons = { @@ -22,7 +24,7 @@ export const reroll = async (roll) => { }, modify: { icon: '', - label: (game as Game).i18n.localize("midgard5.chat.modify"), + label: (game as Game).i18n.localize("midgard5.chat.modify") + " +" + (message["flags"].faces[0] === 100 ? 10 : 2), callback: () => rerollDie("modify", "gp"), }, cancel: { @@ -77,7 +79,7 @@ export const reroll = async (roll) => { for (var key in flagData.rolls) { if (!!flagData.rolls[key]) { rollData.rolls[key] = { - formula: key === "0" ? flagData.rolls[key]?.result + " + 2" : flagData.rolls[key]?.result, + formula: key === "0" ? flagData.rolls[key]?.result + " + " + (message["flags"].faces[0] === 100 ? 10 : 2) : flagData.rolls[key]?.result, enabled: flagData.rolls[key]?.enabled, label: flagData.rolls[key]?.label, result: "", diff --git a/templates/chat/roll-m5.hbs b/templates/chat/roll-m5.hbs index 1613af5..9e516fd 100644 --- a/templates/chat/roll-m5.hbs +++ b/templates/chat/roll-m5.hbs @@ -125,7 +125,7 @@ {{#each rolls as |roll index|}} {{#if roll.enabled}} - {{roll.label}} + {{roll.label}} {{#if (eq index '0')}} {{#if (gt ../b.modifier 0)}}+{{../b.modifier}}{{/if}}{{#if (gt 0 ../b.modifier)}}{{../b.modifier}}{{/if}}{{/if}} {{roll.totalStr}} {{roll.result}}