diff --git a/src/lang/de.json b/src/lang/de.json index 164dc25c..66de97ee 100644 --- a/src/lang/de.json +++ b/src/lang/de.json @@ -44,6 +44,13 @@ "bonusDamage": "Zusätzlicher Schaden:", "buttonText": "Würfeln" }, + "SPELL_DIALOG": { + "notReadyReason": { + "title": "Zauber kann aus folgenden Gründen nicht gewirkt werden:", + "noRepresentation": "Keine Repräsentation gewählt", + "tooManySpoMods": "Zu viele Spontane Modifikationen ausgewählt" + } + }, "ITEM_BROWSER": { "progress": "{current}/{max}: Importiere von {compendium}" } diff --git a/src/module/data/spomods/spoModData.mjs b/src/module/data/spellData/spellData.mjs similarity index 76% rename from src/module/data/spomods/spoModData.mjs rename to src/module/data/spellData/spellData.mjs index 66c4d199..5be5b2bc 100644 --- a/src/module/data/spomods/spoModData.mjs +++ b/src/module/data/spellData/spellData.mjs @@ -1,4 +1,24 @@ -const data = { +export const leadingAttribute = { + "Alchimist": "KL", + "Borbaradianer": "KL", + "Druide": "KL", + "Geode (Herren der Erde)": "KL", + "Magier": "KL", + "Scharlatane": "KL", + "Zibilijas": "KL", + "Achaz": "IN", + "Derwisch": "IN", + "Durro-Dûn": "IN", + "Elfe": "IN", + "Ferkina": "IN", + "Geode (Diener Sumus)": "IN", + "Hexe": "IN", + "Schamane": "IN", + "Schelm": "IN", + "Zaubertänzer": "IN" +} + +export const spoModData = { "Veränderte Technik": { name: "Veränderte Technik", @@ -30,7 +50,7 @@ const data = { }, "Erzwingen": { name: "Erzwingen", - description: "Verringert Erschwernis um 1 je doppelten AsP Punkt", + description: "Verringert Erschwernis um 1 je quadrierten AsP Punkt", mod: -1, castTimeMod: 1, castTimeMode: "Addition" @@ -38,7 +58,7 @@ const data = { "Kosten einsparen": { name: "Kosten einsparen", description: "Reduziert die Kosten des Zaubers um 10% für jede zusätzlich aufgewendete Aktion", - mod: 3, + mod: -3, castingCosts: 0.1, castingCostsMode: "Multiply", castTimeMod: 1, @@ -48,19 +68,17 @@ const data = { "Vergrößerung von Reichweite oder Wirkungsradius": { name: "Vergrößerung von Reichweite oder Wirkungsradius", description: "Vergrößert die Reichweite oder wenn möglich den Wirkungsradius auf kosten von Aktionen", - mod: 5, + mod: -5, castTimeMod: 1, castTimeMode: "Addition" }, "Verkleinerung von Reichweite oder Wirkungsradius": { name: "Verkleinerung von Reichweite oder Wirkungsradius", description: "Verkleinert die Reichweite oder wenn möglich den Wirkungsradius auf kosten von Aktionen", - mod: 3, + mod: -3, castTimeMod: 1, castTimeMode: "Addition" }, -} - -export default data \ No newline at end of file +} \ No newline at end of file diff --git a/src/module/dialog/spellDialog.mjs b/src/module/dialog/spellDialog.mjs index 5d03ffba..2228cc32 100644 --- a/src/module/dialog/spellDialog.mjs +++ b/src/module/dialog/spellDialog.mjs @@ -1,6 +1,6 @@ -import {Talent} from "../data/talent.mjs"; + import {ATTRIBUTE} from "../data/attribute.mjs"; -import SpoModData from "../data/spomods/spoModData.mjs"; +import {spoModData, leadingAttribute} from "../data/spellData/spellData.mjs"; const { ApplicationV2, @@ -50,6 +50,7 @@ export class SpellDialog extends HandlebarsApplicationMixin(ApplicationV2) { _variants = {} _costModel = {} _castTimeModel = {} + _spomods = {} displayModResult = 0 constructor(actor, spellId) { @@ -142,6 +143,8 @@ export class SpellDialog extends HandlebarsApplicationMixin(ApplicationV2) { }) + this._spomods = foundry.utils.expandObject(formData.object)["spoMods"] + this.render({parts: ["form"]}) } @@ -247,10 +250,11 @@ export class SpellDialog extends HandlebarsApplicationMixin(ApplicationV2) { context.text = this._spell.system.wirkung context.dice = [] context.colorfulDice = game.settings.get('DSA_4-1', 'optional_colorfuldice') - context.modResult = this._spell.system.zfw - this.mod + context.modResult = this._spell.system.zfw + this.mod context.penalty = (this.mod > 0 ? "+" : "") + this.mod context.displayModResult = (context.modResult > 0 ? "+" : "") + context.modResult context.castingTime = this.#normalizeCastingTime(this._spell) + context.ready = true // variable probe (should consider Achaz as they can replace one KL in a KL/KL/* spell with IN @@ -291,6 +295,9 @@ export class SpellDialog extends HandlebarsApplicationMixin(ApplicationV2) { Object.entries(this._spell.system.repräsentation).forEach(([key, value]) => { context.representationOptions[key] = key }) + if (!this._selectedRepresentation) { + context.ready = false + } // Costs and Mutators @@ -308,26 +315,70 @@ export class SpellDialog extends HandlebarsApplicationMixin(ApplicationV2) { } // SpoMods + + context.spoModCount = Object.values(this._spomods).reduce((previousValue, currentValue) => previousValue + currentValue, 0) + context.maxSpoModCount = 0 + + if (this._selectedRepresentation) { + const leadingAttributKey = leadingAttribute[this._selectedRepresentation] + + context.maxSpoModCount = (this._actor.system.attribute[leadingAttributKey.toLowerCase()].aktuell ?? 0) - 12 + if (context.maxSpoModCount < 0) { + context.maxSpoModCount = 0 + } + } + + if (context.spoModCount > context.maxSpoModCount) { + context.ready = false + } + + const mapper = (spoModName) => { + + let data = spoModData[spoModName] + let value = this._spomods[data.name] ?? 0 + let totalModValue = data.mod * value + return { + ...data, + value, + totalModValue + } + } + + context.spoMods = [] if (this._spell.system.modifikationen) { this._spell.system.modifikationen.split(",").forEach(spoMod => { switch (spoMod.trim()) { case "Zauberdauer": - context.spoMods.push(SpoModData["Halbierte Zauberdauer"]) - context.spoMods.push(SpoModData["Verdoppelte Zauberdauer"]) + context.spoMods.push(mapper("Halbierte Zauberdauer")) + context.spoMods.push(mapper("Verdoppelte Zauberdauer")) break; case "Kosten": - context.spoMods.push(SpoModData["Kosten einsparen"]) + context.spoMods.push(mapper("Kosten einsparen")) break; case "Reichweite": - context.spoMods.push(SpoModData["Verkleinerung von Reichweite oder Wirkungsradius"]) - context.spoMods.push(SpoModData["Vergrößerung von Reichweite oder Wirkungsradius"]) + context.spoMods.push(mapper("Verkleinerung von Reichweite oder Wirkungsradius")) + context.spoMods.push(mapper("Vergrößerung von Reichweite oder Wirkungsradius")) break; } }) } + if (!context.ready) { + + context.notReadyReasons = `${game.i18n.format("SPELL_DIALOG.notReadyReason.title")}" + } + return context } diff --git a/src/style/organisms/_dialog.scss b/src/style/organisms/_dialog.scss index c12deb44..18d2dd61 100644 --- a/src/style/organisms/_dialog.scss +++ b/src/style/organisms/_dialog.scss @@ -38,6 +38,15 @@ .variant { display: grid; grid-template-columns: 80px 1fr; + + input[type="number"] { + + padding: 0; + margin: 0; + height: 21px; + max-width: 30px; + + } } } diff --git a/src/templates/dialog/spell-dialog.hbs b/src/templates/dialog/spell-dialog.hbs index 50a3aab6..917f595b 100644 --- a/src/templates/dialog/spell-dialog.hbs +++ b/src/templates/dialog/spell-dialog.hbs @@ -52,14 +52,15 @@ {{#if this.spoMods}}
- Spontane Modifikation + Spontane Modifikation {{#if this.spoModCount}}{{#if this.maxSpoModCount}} + [{{this.spoModCount}}/{{this.maxSpoModCount}}]{{/if}}{{/if}}
{{#each this.spoMods}}
@@ -104,7 +105,9 @@
- \ No newline at end of file