shelving for now

pull/63/head
macniel 2025-10-29 10:46:21 +01:00
parent db708d991c
commit b04315946b
9 changed files with 330 additions and 152 deletions

View File

@ -46,7 +46,7 @@ async function preloadHandlebarsTemplates() {
'systems/DSA_4-1/templates/ui/partial-action-button.hbs',
'systems/DSA_4-1/templates/ui/partial-equipment-button.hbs',
'systems/DSA_4-1/templates/ui/partial-array-editor.hbs',
'systems/DSA_4-1/templates/dialog/modify-liturgy.hbs'
'systems/DSA_4-1/templates/dialog/liturgy-dialog.hbs'
]);
}

View File

@ -3,8 +3,8 @@ export class LiturgyData {
static ranks = ["I", "II", "III", "IV", "V", "VI", "VII", "VIII"]
static #ranks = [
{index: 0, name: "O", lkp: 3, mod: 2, costKaP: 2, costKaPPermant: 0, duration: "{*} KR", strength: "{*}/2"},
{index: 1, name: "I", lkp: 3, mod: 0, costKaP: 5, costKaPPermant: 0, duration: "{*} KR", strength: "{*}/2"},
{index: 0, name: "O", lkp: 3, mod: 2, costKaP: 2, costKaPPermant: 0, duration: "LkP* KR", strength: "LkP*/2"},
{index: 1, name: "I", lkp: 3, mod: 0, costKaP: 5, costKaPPermant: 0, duration: "LkP* KR", strength: "LkP*/2"},
{
index: 2,
name: "II",
@ -12,10 +12,19 @@ export class LiturgyData {
mod: -2,
costKaP: 10,
costKaPPermant: 0,
duration: "{*}*10 KR",
strength: "{*}/2+5"
duration: "LkP*10 KR",
strength: "LkP/2+5"
},
{
index: 3,
name: "III",
lkp: 9,
mod: -4,
costKaP: 15,
costKaPPermant: 0,
duration: "LkP* SR",
strength: "LkP*+5"
},
{index: 3, name: "III", lkp: 9, mod: -4, costKaP: 15, costKaPPermant: 0, duration: "{*} SR", strength: "{*}+5"},
{
index: 4,
name: "IV",
@ -23,8 +32,8 @@ export class LiturgyData {
mod: -6,
costKaP: 20,
costKaPPermant: 0,
duration: "{*} Stunden",
strength: "{*}+10"
duration: "LkP* Stunden",
strength: "LkP*+10"
},
{
index: 5,
@ -33,8 +42,8 @@ export class LiturgyData {
mod: -8,
costKaP: 25,
costKaPPermant: 1,
duration: "{*} Tage",
strength: "{*}+15"
duration: "LkP* Tage",
strength: "LkP*+15"
},
{
index: 6,
@ -43,8 +52,8 @@ export class LiturgyData {
mod: -10,
costKaP: 30,
costKaPPermant: 3,
duration: "{*} Wochen",
strength: "{*}+20"
duration: "LkP* Wochen",
strength: "LkP*+20"
},
{
index: 7,
@ -53,8 +62,8 @@ export class LiturgyData {
mod: -12,
costKaP: 35,
costKaPPermant: 5,
duration: "{*} Monate",
strength: "{*}+25"
duration: "LkP* Monate",
strength: "LkP*+25"
},
{
index: 8,
@ -63,9 +72,9 @@ export class LiturgyData {
mod: -14,
costKaP: 40,
costKaPPermant: 7,
duration: "{*} Jahre oder permanent",
duration: "LkP* Jahre oder permanent",
casttime: "",
strength: "{*}+30"
strength: "LkP*+30"
},
];
@ -99,16 +108,28 @@ export class LiturgyData {
}
]
static getModifiedStrength(originalString, rankIncrease) {
return this.#ranks[this.#ranks.findIndex(p => p.strength === originalString) + rankIncrease]
}
static getModifiedDuration(originalString, rankIncrease) {
return this.#ranks[this.#ranks.findIndex(p => p.duration === originalString) + rankIncrease]
}
static getModifiedRank(rank) {
return LiturgyData.#ranks[rank]
}
static getRankOfLiturgy(liturgy, deity) {
const lookupData = liturgy.herkunft.find(p => p.name === deity)
const rank = lookupData?.grad;
return LiturgyData.#ranks[rank];
const rank = lookupData?.grad
return LiturgyData.#ranks[rank]
}
static lookupAlias(alias) {
return LiturgyData.#aliases.find((entry) => {
return entry.aliases.indexOf(alias) !== -1
})?.originalName ?? alias; // cant determine thus simply return the original query name
})?.originalName ?? alias // cant determine thus simply return the original query name
}
}

View File

@ -1,6 +1,38 @@
import {LiturgyData} from "../data/miracle/liturgydata.mjs";
export class ModifyLiturgy {
const {ApplicationV2, HandlebarsApplicationMixin} = foundry.applications.api
export class LiturgyDialog extends HandlebarsApplicationMixin(ApplicationV2) {
static DEFAULT_OPTIONS = {
classes: ['dsa41', 'dialog', 'liturgy'],
tag: "form",
position: {
width: 480,
height: 800
},
window: {
resizable: false,
title: "Liturgie wirken"
},
form: {
submitOnChange: false,
closeOnSubmit: false,
handler: LiturgyDialog.#onSubmitForm
},
actions: {
selectVariant: LiturgyDialog.#selectVariant,
addMod: LiturgyDialog.#addModification,
removeMod: LiturgyDialog.#removeModification,
}
}
static PARTS = {
form: {
template: 'systems/DSA_4-1/templates/dialog/liturgy-dialog.hbs',
}
}
static data = {}
static naming = {
@ -10,79 +42,156 @@ export class ModifyLiturgy {
"castduration": "Wirkzeit",
"duration": "Wirkdauer"
}
static #romanNumerals = ["I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X"]
/**
*
* @type {Actor}
* @private
*/
_actor = null
constructor(data) {
ModifyLiturgy.data = data;
ModifyLiturgy.data.maxmods = Math.round(data.lkp / 3);
ModifyLiturgy.data.variation = null;
}
constructor(actor, liturgyValue, liturgyId, deity) {
super()
this._actor = actor
this._liturgy = this._actor.itemTypes["Liturgy"].find(p => p._id === liturgyId)
this._deity = deity
this._maxmods = Math.round(liturgyValue / 3)
this._variations = []
Object.entries(this._liturgy.system.auswirkung).forEach(([rank, text]) => {
static renderMods(html) {
let result = '';
ModifyLiturgy.data.mods.forEach(((mod, index) => {
result += `<tr><td>${LiturgyData.ranks[mod.rank]}</td><td>${ModifyLiturgy.naming[mod.mod]}</td><td><button class="remove-mod" data-index="${index}"><i class="fa-solid fa-xmark"></i></button></td></tr>`
}))
return result;
}
handleRender(html) {
html.off('click', 'input[name="data.variation"]')
html.on('click', 'input[name="data.variation"]', (evt) => {
if (evt.currentTarget.checked) {
ModifyLiturgy.data.variation = evt.currentTarget.dataset['rank'];
ModifyLiturgy.data.mods = [];
if (text) {
this._variations.push({
level: LiturgyDialog.#romanNumerals.findIndex(p => p === rank) + 1,
rank: rank,
effect: text
})
}
this.render(html)
})
html.off('click', 'button[class="remove-mod"]')
html.on('click', 'button[class="remove-mod"]', (evt) => {
const {index} = evt.currentTarget.dataset;
ModifyLiturgy.data.mods.splice(index, 1);
this.render(html)
})
html.off('change', 'select[name="mod"]')
html.on('change', 'select[name="mod"]', (evt) => {
const value = evt.currentTarget.value;
if (value === '') return;
const currentRank = ModifyLiturgy.data.mods.length + Number(ModifyLiturgy.data.rank);
ModifyLiturgy.data.mods.push({
rank: currentRank,
mod: value,
});
evt.currentTarget.value = "";
this.render(html)
this._variation = this._variations[0]
this._mods = []
this._initialRank = 0
}
static async #onSubmitForm(event, form, formData) {
event.preventDefault()
}
static #selectVariant(event, target) {
if (target.checked) {
this._variation = this._variations.find(p => p.rank === target.dataset['rank']);
this._mods = [];
}
this.render({parts: ["form"]})
event.stopPropagation()
event.preventDefault()
return false
}
static #addModification(event, target) {
event.stopPropagation()
event.preventDefault()
const value = this.element.querySelector('select[name="mod"]').value
if (value === '') return
const currentRank = this._mods.length + (this._variation?.level ?? 0)
this._mods.push({
rank: currentRank,
displayRank: LiturgyDialog.#romanNumerals.findIndex(p => p === currentRank),
mod: value,
})
this.render({parts: ["form"]})
return false
}
// render state
$('#mods', html).html(ModifyLiturgy.renderMods(html))
static #removeModification(event, target) {
event.stopPropagation()
event.preventDefault()
const {index} = target.dataset
this._mods.splice(index, 1)
this.render({parts: ["form"]})
return false
}
_configureRenderOptions(options) {
super._configureRenderOptions(options)
// state handling
if (ModifyLiturgy.data.mods.length === ModifyLiturgy.data.maxmods) {
$(".editor, .editor *", html).attr('disabled', 'disabled');
$(".editor select", html).hide();
$('span#info', html).text('LkW lässt keine weitere Modifikationen zu')
$("#mod_rank", html).text(LiturgyData.ranks[ModifyLiturgy.data.mods.length + Number(ModifyLiturgy.data.rank)]);
} else if (ModifyLiturgy.data.variation == null) {
$(".editor select *", html).attr('disabled', 'disabled');
$(".editor select", html).hide();
$('span#info', html).text('Keine Variante ausgewählt')
$("#mod_rank", html).text('');
} else {
$(".editor, .editor *", html).removeAttr('disabled');
$(".editor select", html).show();
$('span#info', html).text('')
$("#mod_rank", html).text('');
if (options.window) {
if (this._liturgy) {
options.window.title = `${this._liturgy.name} wirken`
}
}
return options
}
}
#getLiturgyData() {
let baseline = LiturgyData.getModifiedRank(this._variation?.level ?? 0)
baseline.duration = this._liturgy.system.wirkungsdauer
let upgradeDuration = false
let upgradeCastDuration = false
let upgradeStrength = false
this._mods.forEach(({mod}) => {
switch (mod) {
case "range":
break;
case "strength":
upgradeStrength = true
break;
case "target":
break;
case "castduration":
upgradeCastDuration = true
break;
case "duration":
upgradeDuration = true
break;
}
})
baseline.name = this._liturgy.name
baseline.effectiveLevel = (this._variation?.level ?? 0) + this._mods.length
baseline.costKaP = LiturgyData.getModifiedRank(baseline.effectiveLevel).costKaP
baseline.costKaPPermanent = LiturgyData.getModifiedRank(baseline.effectiveLevel).costKaPPermanent
baseline.mod = LiturgyData.getModifiedRank(baseline.effectiveLevel).mod
baseline.rank = LiturgyData.getModifiedRank(baseline.effectiveLevel).name
// insert mods into text
baseline.text = this._variation.effect
const strengthRegexp = /(LkP\*.*?)[ .]/g
baseline.text = baseline.text.replace(strengthRegexp, LiturgyData.getModifiedRank((baseline.effectiveLevel ?? 0) + upgradeStrength).strength)
const durationRegexp = /(LkP\*?.*?)(\*10 KR| Stunden| Tage| Wochen| Monate| Jahre oder permanent)/g
const effectiveDuration = LiturgyData.getModifiedDuration((baseline.effectiveLevel ?? 0) + upgradeDuration + upgradeStrength).duration
baseline.duration = baseline.duration.replace(durationRegexp, effectiveDuration.replace("{*}", "LkP"))
return baseline
}
async _prepareContext(options) {
const context = await super._prepareContext(options)
context.actor = this._actor
context.liturgy = this._liturgy
context.mods = this._mods
context.variation = this._variation
context.maxmods = this._maxmods
context.variations = this._variations
context.canMod = (this._maxmods - (this._variation?.level ?? 0) - this._mods.length) >= 0
context.addingModRank = LiturgyDialog.#romanNumerals[(context._variation?.level ?? 0) + this._mods.length + 1]
context.resultingLiturgy = this.#getLiturgyData()
return context
}
}

View File

@ -57,6 +57,7 @@ export default {
// sort by rank
const rankData = LiturgyData.getRankOfLiturgy(item.system, deity)
if (rankData) {
console.log(rankData)
let {index, name, lkp, mod, costKaP} = rankData;
insertObject["count" + name] = insertObject["count" + name] + 1;

View File

@ -11,6 +11,8 @@ import {CombatActionDialog} from "../dialog/combatAction.mjs";
import {ActionManager} from "./actions/action-manager.mjs";
import {DefenseActionDialog} from "../dialog/defenseAction.mjs";
import {RestingDialog} from "../dialog/restingDialog.mjs";
import {Character} from "../documents/character.mjs";
import {LiturgyDialog} from "../dialog/modify-liturgy.mjs";
const {HandlebarsApplicationMixin, DocumentSheetV2} = foundry.applications.api
const {ActorSheetV2} = foundry.applications.sheets
@ -41,6 +43,7 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
openCultureDocument: CharacterSheet.#openCultureDocument,
openSpeciesDocument: CharacterSheet.#openSpeciesDocument,
openCombatAction: CharacterSheet.#openCombatAction,
openLiturgyDialog: CharacterSheet.#openLiturgyDialog,
progressCooldown: CharacterSheet.#progressCooldown,
cancelCooldown: CharacterSheet.#cancelCooldown,
activateCooldown: CharacterSheet.#activateCooldown,
@ -209,6 +212,11 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
}
}
static #openLiturgyDialog(event, target) {
const {id, lkp, deity} = target.dataset
new LiturgyDialog(this.document, lkp, id, deity).render(true)
}
static #startResting(event, target) {
const dialog = new RestingDialog(this.document)

View File

@ -4,55 +4,55 @@
"Cereborns Handreichung (Handwerkssegen)",
"Hauch der Leidenschaft (Handwerkssegen)"
],
"grad": 1,
"grad": 2,
"herkunft": [
{
"name": "Praios",
"grad": 1
"grad": 2
},
{
"name": "Rondra",
"grad": 1
"grad": 2
},
{
"name": "Efferd",
"grad": 1
"grad": 2
},
{
"name": "Travia",
"grad": 1
"grad": 2
},
{
"name": "Boron",
"grad": 1
"grad": 2
},
{
"name": "Hesinde",
"grad": 1
"grad": 2
},
{
"name": "Firun",
"grad": 1
"grad": 2
},
{
"name": "Tsa",
"grad": 1
"grad": 2
},
{
"name": "Phex",
"grad": 1
"grad": 2
},
{
"name": "Peraine",
"grad": 1
"grad": 2
},
{
"name": "Ingrerimm",
"grad": 1
"grad": 2
},
{
"name": "Rahja",
"grad": 1
"grad": 2
}
],
"reichweite": "Berührung",
@ -60,6 +60,6 @@
"zauberdauer": "1 Spielrunde (Gebet)",
"wirkungsdauer": "bis zum Ende der Probe, maximal LkP* Tage",
"auswirkung": {
"I": "Mit dieser Liturgie erfährt eine Person durch den Geweihten eine göttliche Inspiration in einem Talent, das für den Geweihten ein Mirakel+ Talent ist. Der TaW der inspirierten Person steigt für eine Probe um LkP*/2+5 Punkte. Solcherart geschaffene Werkstücke können bei vielen TaP* der Talentprobe nach Maßgabe des Meisters entweder besonders kunstfertig oder aber besonders robust sein, was beim Bau von Behelfsbrücken oder dergleichen wichtig sein kann."
"II": "Mit dieser Liturgie erfährt eine Person durch den Geweihten eine göttliche Inspiration in einem Talent, das für den Geweihten ein Mirakel+ Talent ist. Der TaW der inspirierten Person steigt für eine Probe um LkP*/2+5 Punkte. Solcherart geschaffene Werkstücke können bei vielen TaP* der Talentprobe nach Maßgabe des Meisters entweder besonders kunstfertig oder aber besonders robust sein, was beim Bau von Behelfsbrücken oder dergleichen wichtig sein kann."
}
}

View File

@ -33,8 +33,9 @@
</tr>
{{#each this.O}}
<tr>
<td class="liturgy rollable" data-id="{{this.id}}" data-rank="{{this.rank}}"
data-lkp="{{../lkp}}" data-deity="{{this.deity}}">
<td class="liturgy rollable" data-action="openLiturgyDialog" data-id="{{this.id}}"
data-rank="{{this.rank}}"
data-lkp="{{../lkp}}" data-deity="{{../deity}}">
{{> 'systems/DSA_4-1/templates/ui/partial-die.hbs' }}
</td>
<td class="clickable" data-id="{{this.id}}" data-action="openActorSheet">
@ -52,8 +53,9 @@
</tr>
{{#each this.I}}
<tr>
<td class="liturgy rollable" data-id="{{this.id}}" data-rank="{{this.rank}}"
data-lkp="{{../lkp}}" data-deity="{{this.deity}}">
<td class="liturgy rollable" data-action="openLiturgyDialog" data-id="{{this.id}}"
data-rank="{{this.rank}}"
data-lkp="{{../lkp}}" data-deity="{{../deity}}">
{{> 'systems/DSA_4-1/templates/ui/partial-die.hbs' }}
</td>
<td class="clickable" data-id="{{this.id}}" data-action="openActorSheet">
@ -72,8 +74,9 @@
</tr>
{{#each this.II}}
<tr>
<td class="liturgy rollable" data-id="{{this.id}}" data-rank="{{this.rank}}"
data-lkp="{{../lkp}}" data-deity="{{this.deity}}">
<td class="liturgy rollable" data-action="openLiturgyDialog" data-id="{{this.id}}"
data-rank="{{this.rank}}"
data-lkp="{{../lkp}}" data-deity="{{../deity}}">
{{> 'systems/DSA_4-1/templates/ui/partial-die.hbs' }}
</td>
<td class="clickable" data-id="{{this.id}}"
@ -91,8 +94,9 @@
</tr>
{{#each this.III}}
<tr>
<td class="liturgy rollable" data-id="{{this.id}}" data-rank="{{this.rank}}"
data-lkp="{{../lkp}}" data-deity="{{this.deity}}">
<td class="liturgy rollable" data-action="openLiturgyDialog" data-id="{{this.id}}"
data-rank="{{this.rank}}"
data-lkp="{{../lkp}}" data-deity="{{../deity}}">
{{> 'systems/DSA_4-1/templates/ui/partial-die.hbs' }}
</td>
<td class="clickable" data-id="{{this.id}}"
@ -110,8 +114,9 @@
</tr>
{{#each this.IV}}
<tr>
<td class="liturgy rollable" data-id="{{this.id}}" data-rank="{{this.rank}}"
data-lkp="{{../lkp}}" data-deity="{{this.deity}}">
<td class="liturgy rollable" data-action="openLiturgyDialog" data-id="{{this.id}}"
data-rank="{{this.rank}}"
data-lkp="{{../lkp}}" data-deity="{{../deity}}">
{{> 'systems/DSA_4-1/templates/ui/partial-die.hbs' }}
</td>
<td class="clickable" data-id="{{this.id}}"
@ -128,8 +133,9 @@
</tr>
{{#each this.V}}
<tr>
<td class="liturgy rollable" data-id="{{this.id}}" data-rank="{{this.rank}}"
data-lkp="{{../lkp}}" data-deity="{{this.deity}}">
<td class="liturgy rollable" data-action="openLiturgyDialog" data-id="{{this.id}}"
data-rank="{{this.rank}}"
data-lkp="{{../lkp}}" data-deity="{{../deity}}">
{{> 'systems/DSA_4-1/templates/ui/partial-die.hbs' }}
</td>
<td class="clickable" data-id="{{this.id}}"
@ -147,8 +153,9 @@
</tr>
{{#each this.VI}}
<tr>
<td class="liturgy rollable" data-id="{{this.id}}" data-rank="{{this.rank}}"
data-lkp="{{../lkp}}" data-deity="{{this.deity}}">
<td class="liturgy rollable" data-action="openLiturgyDialog" data-id="{{this.id}}"
data-rank="{{this.rank}}"
data-lkp="{{../lkp}}" data-deity="{{../deity}}">
{{> 'systems/DSA_4-1/templates/ui/partial-die.hbs' }}
</td>
<td class="clickable" data-id="{{this.id}}"
@ -165,8 +172,9 @@
</tr>
{{#each this.VII}}
<tr>
<td class="liturgy rollable" data-id="{{this.id}}" data-rank="{{this.rank}}"
data-lkp="{{../lkp}}" data-deity="{{this.deity}}">
<td class="liturgy rollable" data-action="openLiturgyDialog" data-id="{{this.id}}"
data-rank="{{this.rank}}"
data-lkp="{{../lkp}}" data-deity="{{../deity}}">
{{> 'systems/DSA_4-1/templates/ui/partial-die.hbs' }}
</td>
<td class="clickable" data-id="{{this.id}}"
@ -183,8 +191,9 @@
</tr>
{{#each this.VIII}}
<tr>
<td class="liturgy rollable" data-id="{{this.id}}" data-rank="{{this.rank}}"
data-lkp="{{../lkp}}" data-deity="{{this.deity}}">
<td class="liturgy rollable" data-action="openLiturgyDialog" data-id="{{this.id}}"
data-rank="{{this.rank}}"
data-lkp="{{../lkp}}" data-deity="{{../deity}}">
{{> 'systems/DSA_4-1/templates/ui/partial-die.hbs' }}
</td>
<td class="clickable" data-id="{{this.id}}"

View File

@ -0,0 +1,66 @@
<section>
<table>
<tr>
<th>Grad</th>
<th>Wirkung</th>
</tr>
</th>
{{#each variations}}
<tr>
<th><label><input type="radio" data-action="selectVariant" data-rank="{{this.rank}}" {{checked
(eq this.rank ../variation.rank)}}>{{this.rank}}</label></th>
<td>{{this.effect}}</td>
</tr>
{{/each}}
</table>
<h2>Modifizieren</h2>
<table id="mods">
{{#each mods}}
<tr>
<td>{{this.displayRank}}</td>
<td>{{this.mod}}</td>
<td>
<button data-action="removeMod" data-index="{{@key}}">
<i class="fa-solid fa-xmark"></i>
</button>
</td>
</tr>
{{/each}}
</table>
<div class="editor">
<div id="mod_rank" class="rank">{{this.addingModRank}}</div>
<div class="modification">
<select name="mod" {{disabled (not canMod)}}>
<option value=""> - auswählen -</option>
<option value="range">Reichweite</option>
<option value="strength">Wirkung</option>
<option value="target">Ziele</option>
<option value="castduration">Wirkzeit</option>
<option value="duration">Wirkungsdauer</option>
</select>
<button data-action="addMod"><i class="fa fa-plus"></i></button>
<span id="info"></span>
</div>
</div>
<div class="result">
{{#if resultingLiturgy}}
<div><span>Liturgie:</span> {{resultingLiturgy.name}}</div>
<div><span>Grad:</span> {{resultingLiturgy.rank}}</div>
<div><span>Kosten:</span>{{resultingLiturgy.costKaP}} KaP {{#if resultingLiturgy.costKaPPermanent}}
(davon {{resultingLiturgy.costKaP}} permanent){{/if}}</div>
<div><span>Ziel:</span>{{resultingLiturgy.target}}</div>
<div><span>Wirkdauer:</span>{{resultingLiturgy.duration}}</div>
<div><span>Wirkzeit:</span>{{resultingLiturgy.casttime}}</div>
<div>{{resultingLiturgy.text}}</div>
{{/if}}
</div>
</section>

View File

@ -1,36 +0,0 @@
<table>
<tr>
<th>Grad</th>
<th>Wirkung</th>
</tr>
</th>
{{#each variations}}
<tr>
<th><label><input type="radio" name="data.variation" data-rank="{{this.rank}}">{{this.rank}}</label></th>
<td>{{this.effect}}</td>
</tr>
{{/each}}
</table>
<h2>Modifizieren</h2>
<table id="mods"></table>
<div class="editor">
<div id="mod_rank" class="rank"></div>
<div class="modification">
<select name="mod" disabled="disabled">
<option value=""> - auswählen -</option>
<option value="range">Reichweite</option>
<option value="strength">Wirkung</option>
<option value="target">Ziele</option>
<option value="castduration">Wirkzeit</option>
<option value="duration">Wirkungsdauer</option>
</select>
<span id="info"></span>
</div>
</div>
<div class="result"></div>