foundry-dsa41-game/src/module/sheets/character/effects.mjs

55 lines
2.0 KiB
JavaScript

export default {
_prepareContext: (context, object) => {
const actorData = context.document
context.spells = []
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.isGM = game.user.isGM
context.effects = []
Object.values(actorData.items).forEach((item, index) => {
if (item.type === "ActiveEffect") {
const effect = item.effects[0];
const conditions = []
if (effect) {
effect.changes.forEach(change => {
if (change.key.indexOf("wunden") === -1) {
const key = change.key
.replace(/system\./g, "")
.replace(/\.mod/g, "")
.replace(/attribute./g, "")
.replace(/.links/g, "(Links)")
.replace(/.rechts/g, "(Rechts)")
const value = Number(change.value) > 0 ? "+" + change.value : change.value
conditions.push(
`${key}${value}`
)
}
})
}
context.effects.push({
name: item.name,
conditions: conditions.join(" "),
id: item._id,
actor: actorData._id
});
}
})
return context
},
_onRender: (context, options) => {
},
_getTabConfig: (group) => {
group.tabs.push({id: "effects", group: "sheet", label: "Effekte"})
},
template: `systems/DSA_4-1/templates/actor/character/tab-effects.hbs`
}