112 lines
4.2 KiB
JavaScript
112 lines
4.2 KiB
JavaScript
import {LiturgyData} from "../../data/miracle/liturgyData.mjs";
|
|
|
|
export default {
|
|
_prepareContext: (context) => {
|
|
|
|
const actorData = context.document
|
|
context.system = actorData.system
|
|
context.flags = actorData.flags
|
|
context.derived = context.document.system
|
|
context.originalName = actorData.name
|
|
context.name = context.derived.name ?? actorData.name
|
|
|
|
context.effects = actorData.effects ?? []
|
|
context.liturgies = [];
|
|
context.blessings = [];
|
|
|
|
actorData.itemTypes.Blessing.forEach((item, index) => {
|
|
context.blessings.push({
|
|
deity: item.system.gottheit,
|
|
value: item.system.wert
|
|
})
|
|
})
|
|
actorData.itemTypes.Liturgy.forEach((item, index) => {
|
|
|
|
context.blessings.forEach(({deity, value}) => {
|
|
let insertObject = context.liturgies.find(p => p.deity === deity);
|
|
if (!insertObject) {
|
|
insertObject = {
|
|
deity: deity,
|
|
lkp: value,
|
|
O: [],
|
|
I: [],
|
|
II: [],
|
|
III: [],
|
|
IV: [],
|
|
V: [],
|
|
VI: [],
|
|
VII: [],
|
|
VIII: [],
|
|
"NA": [],
|
|
countO: 1,
|
|
countI: 1,
|
|
countII: 1,
|
|
countIII: 1,
|
|
countIV: 1,
|
|
countV: 1,
|
|
countVI: 1,
|
|
countVII: 1,
|
|
countVIII: 1,
|
|
countNA: 0,
|
|
total: 3,
|
|
|
|
}
|
|
context.liturgies.push(insertObject);
|
|
}
|
|
|
|
// 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;
|
|
|
|
insertObject[name]?.push({
|
|
id: item._id,
|
|
name: item.name,
|
|
lkpReq: lkp,
|
|
lkpMod: mod,
|
|
costKaP,
|
|
fav: item.getFlag("DSA_4-1", "favourite"),
|
|
rank: index, // get effective liturgy rank based on deity
|
|
liturgiekenntnis: deity,
|
|
})
|
|
insertObject.total = insertObject.total + 2;
|
|
|
|
}
|
|
})
|
|
})
|
|
|
|
|
|
// clean up counter
|
|
Object.values(context.liturgies).forEach((litObject) => {
|
|
|
|
if (litObject.I.length === 0) litObject.countI = false;
|
|
if (litObject.II.length === 0) litObject.countII = false;
|
|
if (litObject.III.length === 0) litObject.countIII = false;
|
|
if (litObject.IV.length === 0) litObject.countIV = false;
|
|
if (litObject.V.length === 0) litObject.countV = false;
|
|
if (litObject.VI.length === 0) litObject.countVI = false;
|
|
if (litObject.VII.length === 0) litObject.countVII = false;
|
|
if (litObject.VIII.length === 0) litObject.countVIII = false;
|
|
if (litObject.NA.length === 0) litObject.countNA = false;
|
|
|
|
|
|
})
|
|
|
|
context.hasLiturgies = context.blessings.length > 0;
|
|
|
|
return context
|
|
},
|
|
_onRender: (context, options) => {
|
|
|
|
},
|
|
_getTabConfig: (group, thisObject) => {
|
|
const hasLiturgies = thisObject.document.items.filter(p => p.type === "Liturgy").length > 0 ?? false
|
|
if (hasLiturgies) {
|
|
group?.tabs.push({id: "liturgies", group: "sheet", label: "Liturgien"})
|
|
}
|
|
},
|
|
template: `systems/DSA_4-1/templates/actor/character/tab-liturgies.hbs`
|
|
} |