finalises calculation for SpoMods
parent
94a80eb321
commit
cc60f9e57f
|
|
@ -18,66 +18,68 @@ export const leadingAttribute = {
|
|||
"Zaubertänzer": "IN"
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @type {[String: {name: string, description: string, modFn: string, castTimeModFn: string, costModFn: string}]}
|
||||
*/
|
||||
export const spoModData = {
|
||||
|
||||
"Veränderte Technik": {
|
||||
name: "Veränderte Technik",
|
||||
description: "Verändert die Technik",
|
||||
mod: -7,
|
||||
castTimeMod: 3,
|
||||
castTimeMode: "Addition"
|
||||
modFn: "mod -7",
|
||||
castTimeModFn: "castTime +3",
|
||||
costModFn: "cost",
|
||||
},
|
||||
"Veränderte Technik, zentral": {
|
||||
name: "Veränderte Technik, zentral",
|
||||
description: "Verändert die Technik",
|
||||
mod: -12,
|
||||
castTimeMod: 3,
|
||||
castTimeMode: "Addition"
|
||||
modFn: "mod -12",
|
||||
castTimeModFn: "castTime +3",
|
||||
costModFn: "cost",
|
||||
},
|
||||
"Halbierte Zauberdauer": {
|
||||
name: "Halbierte Zauberdauer",
|
||||
description: "Halbiert die Zauberdauer für eine Erschwernis von 5",
|
||||
mod: -5,
|
||||
castTimeMod: 0.5,
|
||||
castTimeMode: "Multiply"
|
||||
modFn: "mod -5",
|
||||
castTimeModFn: "castTime / 2",
|
||||
costModFn: "cost",
|
||||
},
|
||||
"Verdoppelte Zauberdauer": {
|
||||
name: "Verdoppelte Zauberdauer",
|
||||
description: "Verdoppelt die Zauberdauer für eine Erleichterung von 3",
|
||||
mod: 3,
|
||||
castTimeMod: 2,
|
||||
castTimeMode: "Multiply"
|
||||
modFn: "mod +3",
|
||||
castTimeModFn: "castTime *2",
|
||||
costModFn: "cost",
|
||||
},
|
||||
"Erzwingen": {
|
||||
name: "Erzwingen",
|
||||
description: "Verringert Erschwernis um 1 je quadrierten AsP Punkt",
|
||||
mod: -1,
|
||||
castTimeMod: 1,
|
||||
castTimeMode: "Addition"
|
||||
modFn: "mod +1",
|
||||
castTimeModFn: "castTime +1",
|
||||
costModFn: "cost ** cost",
|
||||
},
|
||||
"Kosten einsparen": {
|
||||
name: "Kosten einsparen",
|
||||
description: "Reduziert die Kosten des Zaubers um 10% für jede zusätzlich aufgewendete Aktion",
|
||||
mod: -3,
|
||||
castingCosts: 0.1,
|
||||
castingCostsMode: "Multiply",
|
||||
castTimeMod: 1,
|
||||
castTimeMode: "Addition"
|
||||
modFn: "mod -3",
|
||||
castTimeModFn: "castTime +1",
|
||||
costModFn: "cost * 0.1",
|
||||
},
|
||||
// more to come
|
||||
"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,
|
||||
castTimeMod: 1,
|
||||
castTimeMode: "Addition"
|
||||
modFn: "mod -5",
|
||||
castTimeModFn: "castTime +1",
|
||||
costModFn: "cost",
|
||||
},
|
||||
"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,
|
||||
castTimeMod: 1,
|
||||
castTimeMode: "Addition"
|
||||
modFn: "mod -3",
|
||||
castTimeModFn: "castTime +1",
|
||||
costModFn: "cost",
|
||||
},
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ export class SpellDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
this._costModel.variables.forEach(v => this._costMutators[v] = 0)
|
||||
this._castTimeModel.variables.forEach(v => this._castTimeMutators[v] = 0)
|
||||
this.cost = this.normalizeCastingCost() ?? 0
|
||||
this.castingTime = this.#normalizeCastingTime(this._spell)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -127,9 +128,8 @@ export class SpellDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
|
||||
let castTimeMutators = foundry.utils.expandObject(formData.object)["castTimeMutators"]
|
||||
|
||||
if (castTimeMutators) {
|
||||
this._castTimeMutators = castTimeMutators
|
||||
}
|
||||
this._castTimeMutators = castTimeMutators ?? {}
|
||||
|
||||
|
||||
this.mod = 0
|
||||
this._activeVariants = Object.entries(this._variants)
|
||||
|
|
@ -143,8 +143,37 @@ export class SpellDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
|
||||
})
|
||||
|
||||
this.castingTime = this.#normalizeCastingTime(this._spell, this._castTimeMutators)
|
||||
|
||||
this._spomods = foundry.utils.expandObject(formData.object)["spoMods"]
|
||||
|
||||
// eval spomods
|
||||
|
||||
let totalMod = this.mod
|
||||
let totalCost = this.cost
|
||||
let totalCastingTime = Number(this.castingTime)
|
||||
|
||||
Object.entries(this._spomods).forEach(([modName, times]) => {
|
||||
|
||||
const actualMod = spoModData[modName]
|
||||
|
||||
for (let i = 0; i < times; i++) {
|
||||
const ctfn = new Function("castTime", "return " + actualMod.castTimeModFn)
|
||||
totalCastingTime = ctfn(totalCastingTime)
|
||||
|
||||
const cfn = new Function("cost", "return " + actualMod.costModFn)
|
||||
totalCost = cfn(totalCost)
|
||||
|
||||
const zmfn = new Function("mod", "return " + actualMod.modFn)
|
||||
totalMod = zmfn(totalMod)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
this.mod = totalMod
|
||||
this.cost = totalCost
|
||||
this.castingTime = totalCastingTime
|
||||
|
||||
this.render({parts: ["form"]})
|
||||
}
|
||||
|
||||
|
|
@ -205,7 +234,7 @@ export class SpellDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
let actualCastingTime = 0
|
||||
let formula = spell.system.zauberdauer.additionalFormula
|
||||
if (formula) {
|
||||
Object.entries(this._castTimeMutators).forEach(([variableName, variableValue]) => {
|
||||
Object.entries(additionalFormulaData).forEach(([variableName, variableValue]) => {
|
||||
console.log(variableName, variableValue)
|
||||
formula = formula.replaceAll(variableName, variableValue)
|
||||
})
|
||||
|
|
@ -253,7 +282,7 @@ export class SpellDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
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.castingTime = this.castingTime
|
||||
context.ready = true
|
||||
|
||||
// variable probe (should consider Achaz as they can replace one KL in a KL/KL/* spell with IN
|
||||
|
|
|
|||
Loading…
Reference in New Issue