From 3a58485d27ada9ff569bfea3b6647454119dc34c Mon Sep 17 00:00:00 2001 From: Byroks Date: Sun, 24 Mar 2024 15:06:30 +0100 Subject: [PATCH 1/3] #90 Clean Spell Button funktioniert nicht (#94) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes: + hinzufügen von roll funktion für Zauberwert Reviewed-on: https://git.byroks.de/MidgardVTT-Entwicklung/foundry-vtt-system-midgard5/pulls/94 Reviewed-by: Le-Frique --- source/module/rolls/M5Roll.ts | 17 +++++++++++++++++ source/module/sheets/M5CharacterSheet.ts | 5 +++++ templates/sheets/character/spells.hbs | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/source/module/rolls/M5Roll.ts b/source/module/rolls/M5Roll.ts index 9a5f316..a7ad922 100644 --- a/source/module/rolls/M5Roll.ts +++ b/source/module/rolls/M5Roll.ts @@ -212,6 +212,23 @@ export class M5Roll { return new M5Roll(rollData, actor, (game as Game).i18n.localize("midgard5.perception")); } + static cleanSpell(actor: any) { + const rollData = actor.getRollData() as M5RollData; + + rollData.rolls["0"] = { + formula: "1d20 + @c.calc.stats.spellCasting.value", + enabled: true, + label: (game as Game).i18n.localize("midgard5.spellCasting"), + result: "", + total: 0, + totalStr: "", + dice: {}, + css: "", + } as M5RollResult; + + return new M5Roll(rollData, actor, (game as Game).i18n.localize("midgard5.spellCasting")); + } + static drinking(actor: any) { const rollData = actor.getRollData() as M5RollData; diff --git a/source/module/sheets/M5CharacterSheet.ts b/source/module/sheets/M5CharacterSheet.ts index 7cbc2ff..d34d69c 100644 --- a/source/module/sheets/M5CharacterSheet.ts +++ b/source/module/sheets/M5CharacterSheet.ts @@ -247,6 +247,11 @@ export default class M5CharacterSheet extends ActorSheet { await roll.toMessage(); }); + html.find(".roll-cleanSpell-button").on("click", async (event) => { + const roll = M5Roll.cleanSpell(this.actor); + await roll.toMessage(); + }); + html.find(".roll-perception-button").on("click", async (event) => { const roll = M5Roll.perception(this.actor); await roll.toMessage(); diff --git a/templates/sheets/character/spells.hbs b/templates/sheets/character/spells.hbs index df236c5..9fbd500 100644 --- a/templates/sheets/character/spells.hbs +++ b/templates/sheets/character/spells.hbs @@ -8,7 +8,7 @@ {{localize "midgard5.spellCasting"}} {{data.calc.stats.spellCasting.value}} - From 046d5f02864722b9b23d302edde1dd9d1c4428c4 Mon Sep 17 00:00:00 2001 From: Byroks Date: Sun, 24 Mar 2024 15:09:08 +0100 Subject: [PATCH 2/3] #91 Automatische Praxispunkte (#93) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes: + implementation von Automatischen Praxispunkten + Hinzufügen von System Settings zur abschaltung von Automatischen Praxispunkten + Aufräumen von Helpers und settings in eigene Dateien Co-authored-by: LeFrique Reviewed-on: https://git.byroks.de/MidgardVTT-Entwicklung/foundry-vtt-system-midgard5/pulls/93 --- lang/de.json | 8 ++- source/helpers.ts | 110 ++++++++++++++++++++++++++++++++ source/index.ts | 107 ++----------------------------- source/module/M5Base.ts | 2 +- source/module/items/M5Item.ts | 2 +- source/module/rolls/M5Roll.ts | 46 ++++++++++++- source/settings.ts | 16 +++++ source/template.json | 6 +- templates/sheets/item/class.hbs | 2 +- 9 files changed, 192 insertions(+), 107 deletions(-) create mode 100644 source/helpers.ts create mode 100644 source/settings.ts diff --git a/lang/de.json b/lang/de.json index 4ed4493..d6aff9d 100644 --- a/lang/de.json +++ b/lang/de.json @@ -181,7 +181,11 @@ "midgard5.meditieren": "Meditieren", "midgard5.menschenkenntnis": "Menschenkenntnis", "midgard5.meucheln": "Meucheln", - "midgard5.musizieren": "Musizieren", + "midgard5.musizierenFloete": "Musizieren (Flöten)", + "midgard5.musizierenBlas": "Musizieren (Blasinstrumente)", + "midgard5.musizierenRythmus": "Musizieren (Rythmusinstrumente)", + "midgard5.musizierenStreich": "Musizieren (Streichinstrumente)", + "midgard5.musizierenZupf": "Musizieren (Zupfinstrumente)", "midgard5.naturkunde": "Naturkunde", "midgard5.ninjutsu": "NinJutsu", "midgard5.orakelkunst": "Orakelkunst", @@ -298,7 +302,7 @@ "midgard5.spell-process-veraendern": "Verändern", "midgard5.spell-process-vigilsignien": "Vigilsignien", "midgard5.spell-process-wundertat": "Wundertat", - "midgard5.spell-process-wilder_Dweomer": "Wilder Dweomer", + "midgard5.spell-process-wilder_dweomer": "Wilder Dweomer", "midgard5.spell-process-zerstoeren": "Zerstören", "midgard5.spell-process-zauberlied": "Zauberlieder", "midgard5.spell-process-zaubersalz": "Zaubersalze", diff --git a/source/helpers.ts b/source/helpers.ts new file mode 100644 index 0000000..f0c0572 --- /dev/null +++ b/source/helpers.ts @@ -0,0 +1,110 @@ +/* global Handlebars, game, TextEditor, WOD5E */ + +import { M5Skill } from "./module/M5Base"; +import { M5Character } from "./module/actors/M5Character"; + +/** + * Define any helpers necessary for working with Handlebars + * @return {Promise} + */ +export const loadHelpers = async function () { + Handlebars.registerHelper("times", (n: number, block) => { + var accum = ""; + for (let i = 0; i < n; ++i) accum += block.fn(i); + return accum; + }); + + Handlebars.registerHelper("array", (arr: any[], index: number) => { + return arr[index]; + }); + + Handlebars.registerHelper("m5concat", (...values) => { + const options = values.pop(); + const join = options.hash?.join || ""; + //return new Handlebars.SafeString(values.join(join)); + return values.map((val) => val.toString()).join(join); + }); + + Handlebars.registerHelper("add", (...values) => { + const options = values.pop(); + return values.reduce((prev, cur) => prev + cur); + }); + + Handlebars.registerHelper("localizeMidgard", (str: string) => { + const template = Handlebars.compile("{{localize value}}"); + return template({ + value: "midgard5." + str, + }); + }); + + Handlebars.registerHelper("skillBonus", (actorId: string, skill: M5Skill) => { + const actor = (game as Game).actors.get(actorId) as M5Character; + return actor.skillBonus(skill).toString(); + }); + + Handlebars.registerHelper("skillEw", (actorId: string, skill: M5Skill) => { + const actor = (game as Game).actors.get(actorId) as M5Character; + return actor.skillEw(skill).toString(); + }); + + Handlebars.registerHelper("skill", (skillId: string) => { + return (game as Game).items.get(skillId); + }); + + Handlebars.registerHelper("itemValue", (id: string, path: string) => { + let obj = (game as Game).items.get(id); + path.split(".").forEach((p) => (obj = obj[p])); + return `${obj}`; + }); + + Handlebars.registerHelper("actorItemValue", (actorId: any, itemId: string, path: string, token?: boolean) => { + //console.log("actorItemValue", actorId, itemId, path) + const actor = (game as Game).actors.get(actorId); + let obj = actor.items.get(itemId)?.system; + path.split(".").forEach((p) => { + if (obj) obj = obj[p]; + }); + return `${obj}`; + }); + + Handlebars.registerHelper("icon", (relpath: string) => { + return `systems/midgard5/assets/icons/${relpath}`; + }); + + Handlebars.registerHelper("isSkillInList", (skillName: string, list: any) => { + for (let key in list) { + if (list[key]?.label?.toLowerCase() === skillName?.toLowerCase()) { + return true; + } + } + return false; + }); + + Handlebars.registerHelper("skillEwInList", (skillName: string, list: any) => { + for (let key in list) { + if (list[key]?.label?.toLowerCase() === skillName?.toLowerCase()) { + return list[key].calc.ew; + } + } + return false; + }); + + Handlebars.registerHelper("stripHtml", function (param) { + var regex = /(<([^>]+)>)/gi; + return param.replace(regex, ""); + }); + + Handlebars.registerHelper("contains", (label: string, contains: string) => { + return label.toLowerCase().includes(contains.toLowerCase()); + }); + + Handlebars.registerHelper("count", (object: any) => { + var length = 0; + for (var key in object) { + if (object.hasOwnProperty(key)) { + ++length; + } + } + return length; + }); +}; diff --git a/source/index.ts b/source/index.ts index 49f7311..2d4de52 100644 --- a/source/index.ts +++ b/source/index.ts @@ -2,112 +2,17 @@ import Logger from "./utils/Logger"; import M5CharacterSheet from "./module/sheets/M5CharacterSheet"; import preloadTemplates from "./PreloadTemplates"; import { M5Character } from "./module/actors/M5Character"; -import { M5ItemMod, M5ModOperation, M5Skill, M5TimeUnit } from "./module/M5Base"; +import { M5ModOperation, M5TimeUnit } from "./module/M5Base"; import { M5ItemSheet } from "./module/sheets/M5ItemSheet"; import { M5Item } from "./module/items/M5Item"; +import { loadHelpers } from "./helpers"; +import { loadSettings } from "./settings"; Hooks.once("init", async () => { Logger.log("M5 | Initialisierung Midgard 5"); - Handlebars.registerHelper("times", (n: number, block) => { - var accum = ""; - for (let i = 0; i < n; ++i) accum += block.fn(i); - return accum; - }); - - Handlebars.registerHelper("array", (arr: any[], index: number) => { - return arr[index]; - }); - - Handlebars.registerHelper("m5concat", (...values) => { - const options = values.pop(); - const join = options.hash?.join || ""; - //return new Handlebars.SafeString(values.join(join)); - return values.map((val) => val.toString()).join(join); - }); - - Handlebars.registerHelper("add", (...values) => { - const options = values.pop(); - return values.reduce((prev, cur) => prev + cur); - }); - - Handlebars.registerHelper("localizeMidgard", (str: string) => { - const template = Handlebars.compile("{{localize value}}"); - return template({ - value: "midgard5." + str, - }); - }); - - Handlebars.registerHelper("skillBonus", (actorId: string, skill: M5Skill) => { - const actor = (game as Game).actors.get(actorId) as M5Character; - return actor.skillBonus(skill).toString(); - }); - - Handlebars.registerHelper("skillEw", (actorId: string, skill: M5Skill) => { - const actor = (game as Game).actors.get(actorId) as M5Character; - return actor.skillEw(skill).toString(); - }); - - Handlebars.registerHelper("skill", (skillId: string) => { - return (game as Game).items.get(skillId); - }); - - Handlebars.registerHelper("itemValue", (id: string, path: string) => { - let obj = (game as Game).items.get(id); - path.split(".").forEach((p) => (obj = obj[p])); - return `${obj}`; - }); - - Handlebars.registerHelper("actorItemValue", (actorId: any, itemId: string, path: string, token?: boolean) => { - //console.log("actorItemValue", actorId, itemId, path) - const actor = (game as Game).actors.get(actorId); - let obj = actor.items.get(itemId)?.system; - path.split(".").forEach((p) => { - if (obj) obj = obj[p]; - }); - return `${obj}`; - }); - - Handlebars.registerHelper("icon", (relpath: string) => { - return `systems/midgard5/assets/icons/${relpath}`; - }); - - Handlebars.registerHelper("isSkillInList", (skillName: string, list: any) => { - for (let key in list) { - if (list[key]?.label?.toLowerCase() === skillName?.toLowerCase()) { - return true; - } - } - return false; - }); - - Handlebars.registerHelper("skillEwInList", (skillName: string, list: any) => { - for (let key in list) { - if (list[key]?.label?.toLowerCase() === skillName?.toLowerCase()) { - return list[key].calc.ew; - } - } - return false; - }); - - Handlebars.registerHelper("stripHtml", function (param) { - var regex = /(<([^>]+)>)/gi; - return param.replace(regex, ""); - }); - - Handlebars.registerHelper("contains", (label: string, contains: string) => { - return label.toLowerCase().includes(contains.toLowerCase()); - }); - - Handlebars.registerHelper("count", (object: any) => { - var length = 0; - for (var key in object) { - if (object.hasOwnProperty(key)) { - ++length; - } - } - return length; - }); + // Load settings into Foundry + loadSettings(); // Default Sheet für Items definieren und das Standardsheet deaktivieren Items.unregisterSheet("core", ItemSheet); @@ -121,6 +26,8 @@ Hooks.once("init", async () => { CONFIG.Item.documentClass = M5Item; //RegisterSettings(); await preloadTemplates(); + + loadHelpers(); }); Hooks.once("setup", () => { diff --git a/source/module/M5Base.ts b/source/module/M5Base.ts index 586b84f..004e1f1 100644 --- a/source/module/M5Base.ts +++ b/source/module/M5Base.ts @@ -29,7 +29,7 @@ export interface M5RollData { c: any; i: any; iType: string; - rolls: {}; + rolls: any; res: { label: string; }; diff --git a/source/module/items/M5Item.ts b/source/module/items/M5Item.ts index c4eb60c..72845cc 100644 --- a/source/module/items/M5Item.ts +++ b/source/module/items/M5Item.ts @@ -323,7 +323,7 @@ export class M5Item extends Item { } } - const roll = new M5Roll(rollData, this.actor, item.name); + const roll = new M5Roll(rollData, this.actor, item.name, item.id); return roll.toMessage(); } else { ChatMessage.create({ diff --git a/source/module/rolls/M5Roll.ts b/source/module/rolls/M5Roll.ts index a7ad922..aab59a2 100644 --- a/source/module/rolls/M5Roll.ts +++ b/source/module/rolls/M5Roll.ts @@ -11,7 +11,7 @@ export class M5Roll { public _total: number = 0; public pool: PoolTerm = null; - constructor(public data: M5RollData, public actor: any, public label: string) { + constructor(public data: M5RollData, public actor: any, public label: string, public id?: string) { //super(null) //this.data = rollData } @@ -88,6 +88,50 @@ export class M5Roll { }); this.data.res.label = this.label; + if ((game as Game).settings.get("midgard5", "automatedPP")) { + if ((this.data.i.type === "language" || this.data.i.type === "general") && this.data.rolls[0].dice[0] >= 16) { + this.actor.items.get(this.id).update({ + system: { + pp: this.data.i.pp + 1, + }, + }); + } else if (this.data.rolls[0].dice[0] === 20) { + if (this.data.i.type === "combat") { + // Rolling through skill + this.actor.items.get(this.id).update({ + system: { + pp: this.data.i.pp + 1, + }, + }); + } else if (this.data.iType === "weapon") { + // Rolling through Weapon Item + const skill = this.actor.items.get(this.data.i.skillId); + skill.update({ + system: { + pp: skill.system.pp + 1, + }, + }); + } else if (this.data.iType === "defensiveWeapon") { + // Rolling through defensiveWeapon Item + const skill = this.actor.items.get(this.data.i.skillId); + skill.update({ + system: { + pp: skill.system.pp + 1, + }, + }); + } else if (this.data.iType === "spell") { + // Rolling through Spell Item + const klasse = this.actor.items.find((x) => x.type === "class" && x.system.equipped); + klasse.update({ + system: { + lernKostenZauber: { + [this.data.i.process]: { pp: klasse.system.lernKostenZauber[this.data.i.process].pp + 1 }, + }, + }, + }); + } + } + } this._evaluated = true; return this; diff --git a/source/settings.ts b/source/settings.ts new file mode 100644 index 0000000..d9ba705 --- /dev/null +++ b/source/settings.ts @@ -0,0 +1,16 @@ +/* global game */ + +/** + * Define all game settings here + * @return {Promise} + */ +export const loadSettings = async function () { + (game as Game).settings.register("midgard5", "automatedPP", { + name: "Automatische Praxispunkte", + hint: "Falls aktiv, werden Praxispunkte automatisch angerechnet.", + scope: "world", + config: true, + default: true, + type: Boolean, + }); +}; diff --git a/source/template.json b/source/template.json index 23483b4..de2ef9e 100644 --- a/source/template.json +++ b/source/template.json @@ -101,7 +101,11 @@ "meditieren": { "fw": 0, "attribute": "wk", "initial": 8, "pp": 0 }, "menschenkenntnis": { "fw": 3, "attribute": "in", "initial": 8, "pp": 0 }, "meucheln": { "fw": 0, "attribute": "gs", "initial": 8, "pp": 0 }, - "musizieren": { "fw": 0, "attribute": "gs", "initial": 12, "pp": 0 }, + "musizierenFloete": { "fw": 0, "attribute": "gs", "initial": 12, "pp": 0 }, + "musizierenBlas": { "fw": 0, "attribute": "gs", "initial": 12, "pp": 0 }, + "musizierenRythmus": { "fw": 0, "attribute": "gs", "initial": 12, "pp": 0 }, + "musizierenStreich": { "fw": 0, "attribute": "gs", "initial": 12, "pp": 0 }, + "musizierenZupf": { "fw": 0, "attribute": "gs", "initial": 12, "pp": 0 }, "ninjutsu": { "fw": 0, "attribute": "gw", "initial": 8, "pp": 0 }, "naturkunde": { "fw": 0, "attribute": "in", "initial": 8, "pp": 0 }, "orakelkunst": { "fw": 0, "attribute": "in", "initial": 8, "pp": 0 }, diff --git a/templates/sheets/item/class.hbs b/templates/sheets/item/class.hbs index e12e040..6e657c0 100644 --- a/templates/sheets/item/class.hbs +++ b/templates/sheets/item/class.hbs @@ -89,7 +89,7 @@ {{#each data.lernKostenZauber as |wert name|}} - + {{/each}} From 7ac704cc619cf4a3f4b8d407a2c69929f431a425 Mon Sep 17 00:00:00 2001 From: LeFrique Date: Sun, 24 Mar 2024 20:02:24 +0100 Subject: [PATCH 3/3] Entbehrungen (#89) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ich habe die Entbehrungswerte für Zähigkeit unter den Grundwerten abgelegt und werde die Tage noch Entbehrungseffekte und ein Macro in der Extension dafür anlegen. Die Boni für die Klassen wie zB Barbar +10 könnten wir dann da direkt mit in der jeweilige Klasse berücksichtigen. Grundsätzlich kann man das aber jetzt schonmal nutzen und der Grundwertebogen war mir zu leer ;) ![grafik](/attachments/fbb80a27-91d7-4b00-bd39-7c24af3bda60) Co-authored-by: Byroks Reviewed-on: https://git.byroks.de/MidgardVTT-Entwicklung/foundry-vtt-system-midgard5/pulls/89 Co-authored-by: LeFrique Co-committed-by: LeFrique --- lang/de.json | 20 ++++--- source/module/M5Base.ts | 21 ++----- source/module/actors/M5Character.ts | 66 ++++------------------ source/module/actors/M5ModAggregate.ts | 5 +- source/module/items/M5Item.ts | 24 ++++++++ source/module/rolls/M5Roll.ts | 62 ++++++++++++-------- source/module/sheets/M5CharacterSheet.ts | 13 +++-- source/template.json | 9 ++- templates/sheets/character/base_values.hbs | 52 +++++++++++------ templates/sheets/character/gear.hbs | 12 +++- templates/sheets/character/skills.hbs | 18 ------ templates/sheets/character/spells.hbs | 4 +- templates/sheets/item/class.hbs | 2 +- templates/sheets/item/container.hbs | 12 ++++ 14 files changed, 174 insertions(+), 146 deletions(-) diff --git a/lang/de.json b/lang/de.json index d6aff9d..6f95cdd 100644 --- a/lang/de.json +++ b/lang/de.json @@ -40,7 +40,7 @@ "midgard5.background": "Hintergrund", "midgard5.attribute": "Eigenschaft", "midgard5.attributes": "Eigenschaften", - "midgard5.points": "Punkte", + "midgard5.points": "Erfahrung", "midgard5.calculated-value": "Berechneter Wert", "midgard5.calculated-values": "Werte und Boni", @@ -131,7 +131,7 @@ "midgard5.heavy-load": "Schwere Last", "midgard5.thrust-load": "Schublast", "midgard5.load-max": "Höchstlast", - "midgard5.load-capacity": "Tragkraft", + "midgard5.capacity": "Tragkraft", "midgard5.exp-overall": "Erfahrungsschatz", "midgard5.exp-available": "Erfahrungspunkte", @@ -215,7 +215,9 @@ "midgard5.thaumagraphie": "Thaumagraphie", "midgard5.thaumalogie": "Thaumalogie", "midgard5.tierkunde": "Tierkunde", - "midgard5.ueberleben": "Überleben", + "midgard5.ueberlebenWald": "Überleben (Wald)", + "midgard5.ueberlebenSteppe": "Überleben (Steppe)", + "midgard5.ueberlebenGebirge": "Überleben (Gebirge)", "midgard5.verfuehren": "Verführen", "midgard5.verhoeren": "Verhören", "midgard5.verstellen": "Verstellen", @@ -243,8 +245,11 @@ "midgard5.enduranceBonus": "Ausdauerbonus", "midgard5.lpProtection": "Rüstungsschutz (LP)", "midgard5.apProtection": "Rüstungsschutz (AP)", - "midgard5.perception": "Wahrnehmung", - "midgard5.drinking": "Trinken", + "midgard5.deprivation": "Zähigkeit", + "midgard5.deprivations": "Entbehrungen", + "midgard5.deprivationCold": "Zähigkeit Kälte", + "midgard5.deprivationHeat": "Zähigkeit Hitze", + "midgard5.deprivationFood": "Zähigkeit Durst/Hunger", "midgard5.new-skill": "Neue Fertigkeit", "midgard5.special": "Spezial", @@ -403,8 +408,9 @@ "midgard5.mod-stat-ap": "Ausdauerpunkte", "midgard5.mod-stat-lpProtection": "Rüstungsschutz (LP)", "midgard5.mod-stat-apProtection": "Rüstungsschutz (AP)", - "midgard5.mod-stat-perception": "Wahrnehmung", - "midgard5.mod-stat-drinking": "Trinken", + "midgard5.mod-stat-deprivationCold": "Entbehrungen Kälte", + "midgard5.mod-stat-deprivationHeat": "Entbehrungen Hitze", + "midgard5.mod-stat-deprivationFood": "Entbehrungen Durst/Hunger", "midgard5.mod-type": "Typ der Modifikation", "midgard5.mod-id": "Was soll modifiziert werden", diff --git a/source/module/M5Base.ts b/source/module/M5Base.ts index 004e1f1..d31f2b1 100644 --- a/source/module/M5Base.ts +++ b/source/module/M5Base.ts @@ -103,17 +103,9 @@ export enum M5Stats { AP = "ap", PROTECTION_LP = "lpProtection", PROTECTION_AP = "apProtection", - PERCEPTION = "perception", - DRINKING = "drinking", - HOARD = "hoard", - HOARD_NEXT = "hoardNext", - HOARD_MIN = "hoardMin", - WEALTH = "wealth", - LOAD = "load", - HEAVY_LOAD = "heavyLoad", - LOAD_MAX = "loadMax", - THRUST_LOAD = "thrustLoad", - ENCUMBRANCE = "encumbrance", + DEPRIVATION_COLD = "deprivationCold", + DEPRIVATION_HEAT = "deprivationHeat", + DEPRIVATION_FOOD = "deprivationFood", } export enum M5ModType { @@ -197,10 +189,9 @@ export interface M5CharacterCalculatedData { brawlFw: number; poisonResistance: M5ModResult; enduranceBonus: number; - perception: M5ModResult; - perceptionFW: number; - drinking: M5ModResult; - drinkingFW: number; + deprivationCold: M5ModResult; + deprivationHeat: M5ModResult; + deprivationFood: M5ModResult; hoard: number; hoardNext: number; hoardMin: number; diff --git a/source/module/actors/M5Character.ts b/source/module/actors/M5Character.ts index 8c6e8bb..4b9546e 100644 --- a/source/module/actors/M5Character.ts +++ b/source/module/actors/M5Character.ts @@ -114,10 +114,9 @@ export class M5Character extends Actor { brawlFw: 0, poisonResistance: { value: 0, mods: [] }, enduranceBonus: 0, - perception: { value: 0, mods: [] }, - perceptionFW: 0, - drinking: { value: 0, mods: [] }, - drinkingFW: 0, + deprivationCold: { value: 0, mods: [] }, + deprivationHeat: { value: 0, mods: [] }, + deprivationFood: { value: 0, mods: [] }, hoard: 0, encumbrance: 0, load: 0, @@ -189,10 +188,9 @@ export class M5Character extends Actor { ret.stats.brawlFw = ret.stats.brawl.value + ret.stats.attackBonus.value + (data.info.race === "Zwerg" ? 1 : 0); ret.stats.poisonResistance = this.modResult(30 + Math.floor(ret.attributes.ko.value / 2)); ret.stats.enduranceBonus = Math.floor(ret.attributes.ko.value / 10) + Math.floor(ret.attributes.st.value / 20); - ret.stats.perception = this.modResult(0); - ret.stats.perceptionFW = 6; - ret.stats.drinking = this.modResult(0); - ret.stats.drinkingFW = Math.floor(ret.attributes.ko.value / 10); + ret.stats.deprivationCold = this.modResult(Math.floor(ret.attributes.ko.value / 2)); + ret.stats.deprivationHeat = this.modResult(Math.floor(ret.attributes.ko.value / 2)); + ret.stats.deprivationFood = this.modResult(Math.floor(40 + ret.attributes.ko.value / 2)); ret.stats.hoardMin = M5Character.levelThreshold.at(ret.level - 1) / 2; ret.stats.hoardNext = M5Character.levelThreshold.at(ret.level) / 2; ret.stats.wealth = parseFloat((data.info.gold + data.info.silver / 10 + data.info.copper / 100).toPrecision(3)); @@ -207,7 +205,10 @@ export class M5Character extends Actor { const aggregate = new M5ModAggregate(data, ret); context.items - ?.filter((item) => (item.type === "item" || item.type === "effect" || item.type === "armor" || item.type === "container" || item.type === "class") && item.system.equipped) + ?.filter( + (item) => + (item.type === "item" || item.type === "skill" || item.type === "effect" || item.type === "armor" || item.type === "container" || item.type === "class") && item.system.equipped + ) .forEach((item) => { const mods = item.system.mods; //console.log("Actor item mods", mods) @@ -250,6 +251,7 @@ export class M5Character extends Actor { calc: item.system.calc, equipped: item.system?.equipped, weight: item.system.weight || 0, + capacity: item.system.capacity || 0, value: item.system.value || 0, currency: item.system.currency || "", quantity: item.system.quantity || 0, @@ -447,41 +449,7 @@ export class M5Character extends Actor { containerId: item.system.containerId || "", }; }); - - //if (!skip?.encumbrance) { - //const item = context.items.filter((x) => x.name === "Belastung"); - //if (item.length === 0) { - // this.createEffect("Belastung", [ - // { id: "movement", operation: M5ModOperation.DIVISION, type: M5ModType.STAT, value: 2 }, - // { id: "attackBonus", operation: M5ModOperation.SUBTRACT, type: M5ModType.STAT, value: 4 }, - // { id: "defenseBonus", operation: M5ModOperation.SUBTRACT, type: M5ModType.STAT, value: 4 } - // ]); - //} else if (item.length === 2) { - // item[1]?.delete(); - //} - // - //if (item.length === 1) { - // item[0]?.update({ - // img: "icons/containers/bags/sack-simple-leather-orange.webp" }); - // } - // - //if (ret.stats.encumbrance <= ret.stats.heavyLoad) { - // item[0]?.update({ - // data: { - // equipped: false, - // } - // }); - // } - // - //if (ret.stats.encumbrance > ret.stats.heavyLoad) { - // item[0].update({ - // data: { - // equipped: true, - // }, - // }); - // } - //} - } + } if (!skip?.class) { context.items @@ -540,16 +508,6 @@ export class M5Character extends Actor { pp: item.system.pp, calc: item.system.calc, } as M5SkillCalculated; - - // Adjust attribute Aussehen based on Athletik skill - if (item.name === "Athletik") { - ret.attributes.au.value += Math.floor(item.system.fw / 3); - } - - // Adjust stat Bewegungsweite based on Laufen skill - if (item.name === "Laufen") { - ret.stats.movement.value += Math.floor(item.system.fw / 3); - } }); } diff --git a/source/module/actors/M5ModAggregate.ts b/source/module/actors/M5ModAggregate.ts index 63350eb..f1eca6b 100644 --- a/source/module/actors/M5ModAggregate.ts +++ b/source/module/actors/M5ModAggregate.ts @@ -41,8 +41,9 @@ export default class M5ModAggregate { this.push({ type: M5ModType.STAT, id: M5Stats.AP, operation: M5ModOperation.SET, value: calc.stats.ap.value }, characterString); this.push({ type: M5ModType.STAT, id: M5Stats.PROTECTION_LP, operation: M5ModOperation.SET, value: calc.stats.lpProtection.value }, characterString); this.push({ type: M5ModType.STAT, id: M5Stats.PROTECTION_AP, operation: M5ModOperation.SET, value: calc.stats.apProtection.value }, characterString); - this.push({ type: M5ModType.STAT, id: M5Stats.PERCEPTION, operation: M5ModOperation.SET, value: calc.stats.perception.value }, characterString); - this.push({ type: M5ModType.STAT, id: M5Stats.DRINKING, operation: M5ModOperation.SET, value: calc.stats.drinking.value }, characterString); + this.push({ type: M5ModType.STAT, id: M5Stats.DEPRIVATION_COLD, operation: M5ModOperation.SET, value: calc.stats.deprivationCold.value }, characterString); + this.push({ type: M5ModType.STAT, id: M5Stats.DEPRIVATION_HEAT, operation: M5ModOperation.SET, value: calc.stats.deprivationHeat.value }, characterString); + this.push({ type: M5ModType.STAT, id: M5Stats.DEPRIVATION_FOOD, operation: M5ModOperation.SET, value: calc.stats.deprivationFood.value }, characterString); } push(mod: M5ItemMod, source: string) { diff --git a/source/module/items/M5Item.ts b/source/module/items/M5Item.ts index 72845cc..24b7c3f 100644 --- a/source/module/items/M5Item.ts +++ b/source/module/items/M5Item.ts @@ -13,6 +13,7 @@ export class M5Item extends Item { const character = actor as M5Character; const itemData = (this as any).system; const calc = itemData.calc; + const name = (this as any).name; if (itemType === "item") { calc.containers = null; @@ -45,6 +46,29 @@ export class M5Item extends Item { }, ]; + // Adjust attribute Aussehen based on Athletik skill + if (name === "Athletik") { + itemData.mods[0] = { type: "attribute", id: "au", operation: "add100", value: Math.floor(calc.fw / 3) }; + } + // Adjust stat Bewegungsweite based on Laufen skill + if (name === "Laufen") { + itemData.mods[0] = { type: "stat", id: "movement", operation: "add", value: Math.floor(calc.fw / 3) }; + } + + // Adjust stat Kälte based on Überleben (Gebirge) skill + if (name === "Überleben (Gebirge)") { + itemData.mods[0] = { type: "stat", id: "deprivationCold", operation: "add", value: Math.floor(calc.fw * 5) }; + } + + // // Adjust stat Kälte based on Überleben (Steppe) skill + if (name === "Überleben (Steppe)") { + itemData.mods[0] = { type: "stat", id: "deprivationHeat", operation: "add", value: Math.floor(calc.fw * 5) }; + } + // // Adjust stat Durst & Hunger based on Robustheit skill + if (name === "Robustheit") { + itemData.mods[0] = { type: "stat", id: "deprivationFood", operation: "add", value: Math.floor(calc.fw * 5) }; + } + if (character) { const actorCalc = character.derivedData({ containers: true, diff --git a/source/module/rolls/M5Roll.ts b/source/module/rolls/M5Roll.ts index aab59a2..5e80689 100644 --- a/source/module/rolls/M5Roll.ts +++ b/source/module/rolls/M5Roll.ts @@ -88,7 +88,8 @@ export class M5Roll { }); this.data.res.label = this.label; - if ((game as Game).settings.get("midgard5", "automatedPP")) { + console.log(this.data); + if ((game as Game).settings.get("midgard5", "automatedPP") && this.data.iType !== null) { if ((this.data.i.type === "language" || this.data.i.type === "general") && this.data.rolls[0].dice[0] >= 16) { this.actor.items.get(this.id).update({ system: { @@ -239,13 +240,13 @@ export class M5Roll { return new M5Roll(rollData, actor, (game as Game).i18n.localize("midgard5.brawl")); } - static perception(actor: any) { + static deprivationCold(actor: any) { const rollData = actor.getRollData() as M5RollData; rollData.rolls["0"] = { - formula: "1d20 + @c.calc.stats.perception.value + @c.calc.stats.perceptionFW", + formula: "@c.calc.stats.deprivationCold.value -1D100", enabled: true, - label: (game as Game).i18n.localize("midgard5.perception"), + label: (game as Game).i18n.localize("midgard5.deprivationCold"), result: "", total: 0, totalStr: "", @@ -253,7 +254,41 @@ export class M5Roll { css: "", } as M5RollResult; - return new M5Roll(rollData, actor, (game as Game).i18n.localize("midgard5.perception")); + return new M5Roll(rollData, actor, (game as Game).i18n.localize("midgard5.deprivationCold")); + } + + static deprivationHeat(actor: any) { + const rollData = actor.getRollData() as M5RollData; + + rollData.rolls["0"] = { + formula: "@c.calc.stats.deprivationHeat.value -1D100", + enabled: true, + label: (game as Game).i18n.localize("midgard5.deprivationHeat"), + result: "", + total: 0, + totalStr: "", + dice: {}, + css: "", + } as M5RollResult; + + return new M5Roll(rollData, actor, (game as Game).i18n.localize("midgard5.deprivationHeat")); + } + + static deprivationFood(actor: any) { + const rollData = actor.getRollData() as M5RollData; + + rollData.rolls["0"] = { + formula: "@c.calc.stats.deprivationFood.value -1D100", + enabled: true, + label: (game as Game).i18n.localize("midgard5.deprivationFood"), + result: "", + total: 0, + totalStr: "", + dice: {}, + css: "", + } as M5RollResult; + + return new M5Roll(rollData, actor, (game as Game).i18n.localize("midgard5.deprivationFood")); } static cleanSpell(actor: any) { @@ -273,23 +308,6 @@ export class M5Roll { return new M5Roll(rollData, actor, (game as Game).i18n.localize("midgard5.spellCasting")); } - 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, - label: (game as Game).i18n.localize("midgard5.drinking"), - result: "", - total: 0, - totalStr: "", - dice: {}, - css: "", - } as M5RollResult; - - return new M5Roll(rollData, actor, (game as Game).i18n.localize("midgard5.drinking")); - } - static defense(actor: any) { const rollData = actor.getRollData() as M5RollData; rollData.i = { diff --git a/source/module/sheets/M5CharacterSheet.ts b/source/module/sheets/M5CharacterSheet.ts index d34d69c..234c992 100644 --- a/source/module/sheets/M5CharacterSheet.ts +++ b/source/module/sheets/M5CharacterSheet.ts @@ -252,13 +252,18 @@ export default class M5CharacterSheet extends ActorSheet { await roll.toMessage(); }); - html.find(".roll-perception-button").on("click", async (event) => { - const roll = M5Roll.perception(this.actor); + html.find(".roll-deprivationCold-button").on("click", async (event) => { + const roll = M5Roll.deprivationCold(this.actor); await roll.toMessage(); }); - html.find(".roll-drinking-button").on("click", async (event) => { - const roll = M5Roll.drinking(this.actor); + html.find(".roll-deprivationHeat-button").on("click", async (event) => { + const roll = M5Roll.deprivationHeat(this.actor); + await roll.toMessage(); + }); + + html.find(".roll-deprivationFood-button").on("click", async (event) => { + const roll = M5Roll.deprivationFood(this.actor); await roll.toMessage(); }); diff --git a/source/template.json b/source/template.json index de2ef9e..ba41359 100644 --- a/source/template.json +++ b/source/template.json @@ -135,7 +135,9 @@ "tauchen": { "fw": 6, "attribute": "ko", "initial": 8, "pp": 0 }, "tanzen": { "fw": 6, "attribute": "ko", "initial": 8, "pp": 0 }, "tierkunde": { "fw": 0, "attribute": "in", "initial": 8, "pp": 0 }, - "ueberleben": { "fw": 6, "attribute": "in", "initial": 8, "pp": 0 }, + "ueberlebenWald": { "fw": 6, "attribute": "in", "initial": 8, "pp": 0 }, + "ueberlebenSteppe": { "fw": 6, "attribute": "in", "initial": 8, "pp": 0 }, + "ueberlebenGebirge": { "fw": 6, "attribute": "in", "initial": 8, "pp": 0 }, "verfuehren": { "fw": 3, "attribute": "pa", "initial": 8, "pp": 0 }, "verhoeren": { "fw": 3, "attribute": "pa", "initial": 8, "pp": 0 }, "verstellen": { "fw": 3, "attribute": "pa", "initial": 8, "pp": 0 }, @@ -220,6 +222,7 @@ "physical": { "value": 0, "weight": 0, + "capacity": 0, "containerId": "", "magic": false }, @@ -319,6 +322,7 @@ "templates": ["itemDescription", "attributeSelection"], "fw": 0, "attribute": "st", + "equipped": true, "skill": "", "type": "general", "rolls": { @@ -332,7 +336,8 @@ "output": "" }, "pp": 0, - "calc": {} + "calc": {}, + "mods": {} }, "item": { "templates": ["itemDescription", "equippable", "physical", "valuable", "hoarded"], diff --git a/templates/sheets/character/base_values.hbs b/templates/sheets/character/base_values.hbs index b3bfae8..20b25b7 100644 --- a/templates/sheets/character/base_values.hbs +++ b/templates/sheets/character/base_values.hbs @@ -46,8 +46,8 @@ {{localize "midgard5.luckPoints"}} - - + {{localize "midgard5.valuable"}} + {{data.calc.stats.wealth}} @@ -104,23 +104,43 @@ {{data.calc.stats.resistanceBody.value}} {{#if (eq data.info.race "Zwerg")}} - - {{localize "midgard5.hoard"}} - {{data.calc.stats.hoard}} - - - - - {{localize "midgard5.hoardMin"}} - {{data.calc.stats.hoardMin}} - {{localize "midgard5.hoard-next"}} - {{data.calc.stats.hoardNext}} - + + {{localize "midgard5.hoard"}} + {{data.calc.stats.hoard}} + + + {{localize "midgard5.hoardMin"}} + {{data.calc.stats.hoardMin}} + {{localize "midgard5.hoard-next"}} + {{data.calc.stats.hoardNext}} + {{/if}} - - \ No newline at end of file + + +
+
+
{{localize "midgard5.deprivations"}} & {{localize "midgard5.deprivation"}}
+ + + + + + + + + + + + + + + + +
{{localize "midgard5.deprivationFood"}}{{data.calc.stats.deprivationFood.value}}{{localize "midgard5.deprivationHeat"}}{{ data.calc.stats.deprivationHeat.value}}{{localize "midgard5.deprivationCold"}}{{data.calc.stats.deprivationCold.value}}
+
+
\ No newline at end of file diff --git a/templates/sheets/character/gear.hbs b/templates/sheets/character/gear.hbs index 78f5384..79efc09 100644 --- a/templates/sheets/character/gear.hbs +++ b/templates/sheets/character/gear.hbs @@ -48,9 +48,9 @@ - - - + + + @@ -231,6 +231,7 @@ {{localize "TYPES.Item.container"}} {{localize "midgard5.item-value"}} {{localize "midgard5.item-weight"}} + {{localize "midgard5.capacity"}} @@ -254,6 +255,11 @@ {{item.weight}} kg {{/unless}} + + {{#unless (eq item.capacity "")}} + {{item.capacity}} kg + {{/unless}} + {{#if item.equipped}} diff --git a/templates/sheets/character/skills.hbs b/templates/sheets/character/skills.hbs index 23c8c18..cbebdde 100644 --- a/templates/sheets/character/skills.hbs +++ b/templates/sheets/character/skills.hbs @@ -27,24 +27,6 @@ {{/each}} - - - {{localize "midgard5.drinking"}} - {{data.calc.stats.drinkingFW}} - {{data.calc.stats.drinking.value}} - {{add data.calc.stats.drinking.value data.calc.stats.drinkingFW}} - - - - - - {{localize "midgard5.perception"}} - {{data.calc.stats.perceptionFW}} - {{data.calc.stats.perception.value}} - {{add data.calc.stats.perception.value data.calc.stats.perceptionFW}} - - - diff --git a/templates/sheets/character/spells.hbs b/templates/sheets/character/spells.hbs index 9fbd500..34fe0a0 100644 --- a/templates/sheets/character/spells.hbs +++ b/templates/sheets/character/spells.hbs @@ -72,8 +72,8 @@ {{/each}} - - + + diff --git a/templates/sheets/item/class.hbs b/templates/sheets/item/class.hbs index 6e657c0..2d8e4ba 100644 --- a/templates/sheets/item/class.hbs +++ b/templates/sheets/item/class.hbs @@ -89,7 +89,7 @@ {{#each data.lernKostenZauber as |wert name|}} - + {{/each}} diff --git a/templates/sheets/item/container.hbs b/templates/sheets/item/container.hbs index 2add63f..13c1a87 100644 --- a/templates/sheets/item/container.hbs +++ b/templates/sheets/item/container.hbs @@ -26,6 +26,12 @@ + +
+ {{localize "midgard5.capacity"}} + +
+ @@ -42,6 +48,12 @@ + +
+ {{localize "midgard5.item-weight"}} + +
+