127 lines
4.7 KiB
JavaScript
127 lines
4.7 KiB
JavaScript
export default {
|
|
_prepareContext: async (context, options, object) => {
|
|
|
|
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.advantages = []
|
|
|
|
const getModsOfAttribute = async (keyPath, object) => {
|
|
let returnValue = [];
|
|
Array.from(object.appliedEffects).forEach(
|
|
(e) =>
|
|
e.changes.filter(c => c.key === keyPath).forEach(change => {
|
|
returnValue.push({
|
|
name: e.name,
|
|
value: change.value > 0 ? "+" + change.value : "" + change.value,
|
|
icon: e.icon,
|
|
})
|
|
}))
|
|
return returnValue;
|
|
}
|
|
|
|
context.mods = {
|
|
"mu": await getModsOfAttribute('system.attribute.mu.mod', actorData),
|
|
"kl": await getModsOfAttribute('system.attribute.kl.mod', actorData),
|
|
"in": await getModsOfAttribute('system.attribute.in.mod', actorData),
|
|
"ch": await getModsOfAttribute('system.attribute.ch.mod', actorData),
|
|
"ff": await getModsOfAttribute('system.attribute.ff.mod', actorData),
|
|
"ge": await getModsOfAttribute('system.attribute.ge.mod', actorData),
|
|
"ko": await getModsOfAttribute('system.attribute.ko.mod', actorData),
|
|
"kk": await getModsOfAttribute('system.attribute.kk.mod', actorData),
|
|
"at": await getModsOfAttribute('system.at.mod', actorData),
|
|
"pa": await getModsOfAttribute('system.pa.mod', actorData),
|
|
"fk": await getModsOfAttribute('system.fk.mod', actorData),
|
|
|
|
}
|
|
context.attributes = [
|
|
{
|
|
eigenschaft: "mu",
|
|
name: "MU",
|
|
tooltip: "Mut",
|
|
wert: context.derived.attribute.mu.aktuell ?? 0,
|
|
},
|
|
{
|
|
eigenschaft: "kl",
|
|
name: "KL",
|
|
tooltip: "Klugheit",
|
|
wert: context.derived.attribute.kl.aktuell ?? 0,
|
|
},
|
|
{
|
|
eigenschaft: "in",
|
|
name: "IN",
|
|
tooltip: "Intuition",
|
|
wert: context.derived.attribute.in.aktuell ?? 0,
|
|
},
|
|
{
|
|
eigenschaft: "ch",
|
|
name: "CH",
|
|
tooltip: "Charisma",
|
|
wert: context.derived.attribute.ch.aktuell ?? 0,
|
|
},
|
|
{
|
|
eigenschaft: "ff",
|
|
name: "FF",
|
|
tooltip: "Fingerfertigkeit",
|
|
wert: context.derived.attribute.ff.aktuell ?? 0,
|
|
},
|
|
{
|
|
eigenschaft: "ge",
|
|
name: "GE",
|
|
tooltip: "Geschicklichkeit",
|
|
wert: context.derived.attribute.ge.aktuell ?? 0,
|
|
},
|
|
{
|
|
eigenschaft: "ko",
|
|
name: "KO",
|
|
tooltip: "Konstitution",
|
|
wert: context.derived.attribute.ko.aktuell ?? 0,
|
|
},
|
|
{
|
|
eigenschaft: "kk",
|
|
name: "KK",
|
|
tooltip: "Körperkraft",
|
|
wert: context.derived.attribute.kk.aktuell ?? 0,
|
|
},
|
|
|
|
]
|
|
|
|
Object.values(actorData.items).forEach((item) => {
|
|
if (item.type === "Advantage") {
|
|
context.advantages.push({
|
|
id: item._id,
|
|
name: item.name,
|
|
value: item.system.value,
|
|
options: item.system.auswahl,
|
|
description: item.system.description,
|
|
isAdvantage: !item.system.nachteil,
|
|
isDisadvantage: item.system.nachteil,
|
|
isBadAttribute: item.system.schlechteEigenschaft
|
|
});
|
|
}
|
|
}
|
|
);
|
|
|
|
context.specialAbilities = [];
|
|
Object.values(actorData.items).forEach((item) => {
|
|
if (item.type === "SpecialAbility") {
|
|
context.specialAbilities.push({
|
|
id: item._id,
|
|
name: item.name,
|
|
});
|
|
}
|
|
}
|
|
);
|
|
},
|
|
_onRender: (context, options) => {
|
|
|
|
},
|
|
_getTabConfig: (group) => {
|
|
group.tabs.push({id: "attributes", group: "sheet", label: "Eigenschaften"})
|
|
},
|
|
template: `systems/DSA_4-1/templates/actor/character/tab-attributes.hbs`
|
|
} |