diff --git a/lang/de.json b/lang/de.json index 25f285a..4109c79 100644 --- a/lang/de.json +++ b/lang/de.json @@ -291,6 +291,7 @@ "midgard5.kido-variante-kontrollieren": "Kontrollieren", "midgard5.mod-operation-add100": "Addieren (max 100)", + "midgard5.mod-operation-roll": "Wurf Modifikation", "midgard5.mod-operation-add": "Addieren", "midgard5.mod-operation-set": "Basiswert", "midgard5.mod-operation-fixed": "Fester Wert", diff --git a/source/module/M5Base.ts b/source/module/M5Base.ts index 6a1a022..0562cce 100644 --- a/source/module/M5Base.ts +++ b/source/module/M5Base.ts @@ -85,7 +85,7 @@ export enum M5Stats { PROTECTION_LP = "lpProtection", PROTECTION_AP = "apProtection", PERCEPTION = "perception", - DRINKING = "drinking" + DRINKING = "drinking", } export enum M5ModType { @@ -96,6 +96,7 @@ export enum M5ModType { export enum M5ModOperation { ADD_100 = "add100", + ROLL = "roll", ADD = "add", SET = "set", FIXED = "fixed", diff --git a/source/module/items/M5Item.ts b/source/module/items/M5Item.ts index cc942ff..037a5e1 100644 --- a/source/module/items/M5Item.ts +++ b/source/module/items/M5Item.ts @@ -258,7 +258,6 @@ export class M5Item extends Item { } const roll = new M5Roll(rollData, this.actor, item.name); - console.log(roll); return roll.toMessage(); } else { ChatMessage.create({ diff --git a/source/module/rolls/M5Roll.ts b/source/module/rolls/M5Roll.ts index 01163e1..f0b2565 100644 --- a/source/module/rolls/M5Roll.ts +++ b/source/module/rolls/M5Roll.ts @@ -1,6 +1,6 @@ import { Evaluated } from "@league-of-foundry-developers/foundry-vtt-types/src/foundry/client/dice/roll"; import { M5Character } from "../actors/M5Character"; -import { M5EwResult, M5RollData, M5RollResult, M5SkillUnlearned, M5Stats } from "../M5Base"; +import { M5EwResult, M5ModOperation, M5ModType, M5RollData, M5RollResult, M5SkillUnlearned, M5Stats } from "../M5Base"; import { stat } from "fs"; export class M5Roll { @@ -115,31 +115,20 @@ export class M5Roll { return ChatMessage.create(chatData); } - static fromAttribute(actor: any, attributeKey: string) { - const character = actor as M5Character; - const attribute = character.attribute(attributeKey); - - const rollData = actor.getRollData() as M5RollData; - rollData.i = attribute.value + attribute.bonus; - rollData.rolls["0"] = { - formula: "@i - 1d100", - enabled: true, - label: (game as Game).i18n.localize("midgard5.pw"), - result: "", - total: 0, - totalStr: "", - dice: {}, - css: "", - } as M5RollResult; - - return new M5Roll(rollData, actor, (game as Game).i18n.localize(`midgard5.actor-${attributeKey}-long`)); - } - static fromAttributeValue(actor: any, attributeKey: string, attributeValue: number) { const rollData = actor.getRollData() as M5RollData; + const itemData = actor.items.filter((x) => x.type === "effect").map((y) => y.system.mods); + rollData.c = 0; + for (let effectKey in itemData) { + for (let modkey in itemData[effectKey]) + if (itemData[effectKey][modkey].type === M5ModType.ATTRIBUTE && itemData[effectKey][modkey].operation === M5ModOperation.ROLL) { + rollData.c += itemData[effectKey][modkey].value; + } + } + rollData.i = attributeValue; rollData.rolls["0"] = { - formula: "@i - 1d100", + formula: "@i - 1d100 - @c", enabled: true, label: (game as Game).i18n.localize("midgard5.pw"), result: "", @@ -208,7 +197,7 @@ export class M5Roll { static perception(actor: any) { const rollData = actor.getRollData() as M5RollData; - + rollData.rolls["0"] = { formula: "1d20 + @c.calc.stats.perception.value + @c.calc.stats.perceptionFW", enabled: true, @@ -219,13 +208,13 @@ export class M5Roll { dice: {}, css: "", } as M5RollResult; - + return new M5Roll(rollData, actor, (game as Game).i18n.localize("midgard5.perception")); } - + static drinking(actor: any) { const rollData = actor.getRollData() as M5RollData; - + rollData.rolls["0"] = { formula: "1d20 + @c.calc.stats.drinking.value + @c.calc.stats.drinkingFW", enabled: true, @@ -236,7 +225,7 @@ export class M5Roll { dice: {}, css: "", } as M5RollResult; - + return new M5Roll(rollData, actor, (game as Game).i18n.localize("midgard5.drinking")); } diff --git a/templates/sheets/partial/mod.hbs b/templates/sheets/partial/mod.hbs index d4a2bfe..03701a2 100644 --- a/templates/sheets/partial/mod.hbs +++ b/templates/sheets/partial/mod.hbs @@ -36,6 +36,7 @@ {{#select mod.operation}} {{#if (eq mod.type "attribute")}} + {{/if}} @@ -48,7 +49,7 @@ - + {{/each}}