functioning spells & more

This commit is contained in:
Byroks committed 2026-10-21 19:18:13 +02:00
1 parent 2291c5d1e6
commit e4eecb7b8e
28 files changed
+681 -131

No files matched your search

+74
View File
@@ -0,0 +1,74 @@
export async function prepArmor(actor) {
const actorData = actor.system;
// 1. Basis-Wert festlegen
let baseRüstwert = actorData.rüstwert || 0;
// 2. Ausgerüstete Rüstung finden und addieren
const equippedMainArmor = actor.items.filter(
(i) => i.type === "armor" && i.system.equipped && !i.system.zusätzlich
);
const equippedAddArmor = actor.items.filter(
(i) => i.type === "armor" && i.system.equipped && i.system.zusätzlich
);
let armorBonus = Math.max(...equippedMainArmor.map((x) => x.system.rüstwert), 0);
for (let armor of equippedAddArmor) {
armorBonus += armor.system.rüstwert;
}
// 3. Finalen Standard-Wert berechnen
actorData.rüstwert = baseRüstwert + armorBonus;
}
export async function prepWeapons(actor) {
const weaponItems = actor.items.filter((x) => x.type === "weapon" && x.system.equipped);
const weapons = [];
weaponItems.forEach((weapon) => {
const skill = foundry.utils.getProperty(actor, weapon.system.fertigkeit);
const w = {
name: weapon.name,
skillValue: skill.value,
bonusValue:
skill.bonuses.find((x) => x.name === weapon.system.spezialisierung)?.level + 1 || "",
img: weapon.img,
skillPath: weapon.system.fertigkeit,
path: weapon.system.fertigkeit,
id: weapon.id
};
weapons.push(w);
});
return weapons;
}
export async function prepSpells(actor) {
const spellItems = actor.items.filter((x) => x.type === "zauber" && x.system.equipped);
const spells = [];
const skill = foundry.utils.getProperty(actor, "system.skills.magie.zaubern");
console.warn(skill, spellItems);
spellItems.forEach((spell) => {
const w = {
name: spell.name,
skillValue: skill.value,
bonusValue:
skill.bonuses.find((x) => x.name === spell.system.eigenschaften.ursprung)?.level + 1 || "",
img: spell.img,
skillPath: "system.skills.magie.zaubern",
path: "Zaubern",
id: spell.id
};
spells.push(w);
});
return spells;
}
export async function prepWeight(actor) {
const items = actor.items.filter((x) => x.system.gewicht);
let gewicht = items.reduce((accumulator, item) => accumulator + item.system.gewicht, 0);
let traglast = Math.max(actor.system.skills.körper.athletik.value, 10);
return {
traglast,
gewicht
};
}