diff --git a/lang/de.json b/lang/de.json index 43bcc2b..4109c79 100644 --- a/lang/de.json +++ b/lang/de.json @@ -91,6 +91,10 @@ "midgard5.origin": "Heimat", "midgard5.faith": "Glaube", + "midgard5.currency-gold": "Gold", + "midgard5.currency-silver": "Silber", + "midgard5.currency-copper": "Kupfer", + "midgard5.exp-overall": "Erfahrungsschatz", "midgard5.exp-available": "Erfahrungspunkte", "midgard5.grace": "Göttliche Gnade", @@ -197,8 +201,8 @@ "midgard5.enduranceBonus": "Ausdauerbonus", "midgard5.lpProtection": "Rüstungsschutz (LP)", "midgard5.apProtection": "Rüstungsschutz (AP)", - "midgard5.perception" : "Wahrnehmung", - "midgard5.drinking" : "Trinken", + "midgard5.perception": "Wahrnehmung", + "midgard5.drinking": "Trinken", "midgard5.new-skill": "Neue Fertigkeit", "midgard5.special": "Spezial", @@ -287,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/package.json b/package.json index a4d1147..949eb7f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "foundry-system-midgard5", - "version": "2.3.0", + "version": "2.3.1", "description": "", "main": "index.js", "scripts": { 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/actors/M5Character.ts b/source/module/actors/M5Character.ts index 2e4f2f4..e067c62 100644 --- a/source/module/actors/M5Character.ts +++ b/source/module/actors/M5Character.ts @@ -67,9 +67,9 @@ export class M5Character extends Actor { brawlFw: 0, poisonResistance: { value: 0, mods: [] }, enduranceBonus: 0, - perception: {value: 0, mods: []}, + perception: { value: 0, mods: [] }, perceptionFW: 0, - drinking: {value: 0, mods: []}, + drinking: { value: 0, mods: [] }, drinkingFW: 0, }, skillMods: {}, @@ -171,12 +171,24 @@ export class M5Character extends Actor { if (item.system.magic) { label += "*"; } + let rollable = false; + // console.log(item.system.rolls.formulas.map((p) => p.enabled)); + for (let key in item.system.rolls.formulas) { + rollable = item.system.rolls.formulas[key].enabled; + if (rollable) { + break; + } + } ret.gear.items[item.id] = { label: label, magic: item.system.magic, calc: item.system.calc, equipped: item.system?.equipped, + value: item.system.value || 0, + currency: item.system.currency || "", + quantity: item.system.quantity || 0, + rollExist: rollable, }; }); } 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/source/module/sheets/M5CharacterSheet.ts b/source/module/sheets/M5CharacterSheet.ts index d847e42..e98a1ae 100644 --- a/source/module/sheets/M5CharacterSheet.ts +++ b/source/module/sheets/M5CharacterSheet.ts @@ -97,6 +97,60 @@ export default class M5CharacterSheet extends ActorSheet { item.sheet.render(true); }); + html.find(".quantity-increase").on("click", async (event) => { + let row = event.target.parentElement; + let itemId = row.dataset["item"]; + while (!itemId) { + row = row.parentElement; + if (!row) return; + itemId = row.dataset["item"]; + } + + const context = this.actor as any; + const item = context.items.get(itemId); + if (!item.system.quantity) { + item.system.quantity = 0; + } + item.system.quantity += 1; + this.render(); + }); + + html.find(".quantity-decrease").on("click", async (event) => { + let row = event.target.parentElement; + let itemId = row.dataset["item"]; + while (!itemId) { + row = row.parentElement; + if (!row) return; + itemId = row.dataset["item"]; + } + + const context = this.actor as any; + const item = context.items.get(itemId); + if (item.system.quantity > 0) { + item.system.quantity -= 1; + } + this.render(); + }); + + html.find(".roll-consumable-item").on("click", async (event) => { + let row = event.target.parentElement; + let itemId = row.dataset["item"]; + while (!itemId) { + row = row.parentElement; + if (!row) return; + itemId = row.dataset["item"]; + } + + const context = this.actor as any; + const item = context.items.get(itemId); + if (item.system.quantity > 0) { + item.system.quantity -= 1; + } + + await item.roll(); + this.render(); + }); + html.find(".item-delete").on("click", async (event) => { let row = event.target.parentElement; let itemId = row.dataset["item"]; diff --git a/source/system.json b/source/system.json index 58b5641..27c4125 100644 --- a/source/system.json +++ b/source/system.json @@ -3,7 +3,7 @@ "name": "midgard5", "title": "Midgard 5. Edition", "description": "The German RPG Midgard 5. Edition", - "version": "2.3.0", + "version": "2.3.1", "compatibility": { "minimum": "10", "verified": "11", @@ -154,8 +154,8 @@ "primaryTokenAttribute": "lp", "secondaryTokenAttribute": "ap", "url": "https://github.com/Byroks/foundry-vtt-system-midgard5", - "manifest": "https://github.com/Byroks/foundry-vtt-system-midgard5/releases/download/v2.3.0/system.json", - "download": "https://github.com/Byroks/foundry-vtt-system-midgard5/releases/download/v2.3.0/midgard5-v2.3.0.zip", + "manifest": "https://github.com/Byroks/foundry-vtt-system-midgard5/releases/download/v2.3.1/system.json", + "download": "https://github.com/Byroks/foundry-vtt-system-midgard5/releases/download/v2.3.1/midgard5-v2.3.1.zip", "initiative": "@c.calc.attributes.gw.value", "license": "LICENSE.txt" } \ No newline at end of file diff --git a/source/template.json b/source/template.json index c48ea3d..f1665f5 100644 --- a/source/template.json +++ b/source/template.json @@ -16,7 +16,10 @@ "caste": "", "occupation": "", "origin": "", - "faith": "" + "faith": "", + "gold": 0, + "silver": 0, + "copper": 0 } }, "characterBars": { diff --git a/templates/sheets/character/gear.hbs b/templates/sheets/character/gear.hbs index c84b37c..e2dc767 100644 --- a/templates/sheets/character/gear.hbs +++ b/templates/sheets/character/gear.hbs @@ -1,3 +1,20 @@ +
| {{localize "midgard5.currency-gold"}} | +{{localize "midgard5.currency-silver"}} | +{{localize "midgard5.currency-copper"}} | +
|---|---|---|
| + | + | + |