export async function prepArmor(actor) { const actorData = actor.system; // 1. Basis-Wert festlegen let baseRüstwert = actorData.rüstwert.base || 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.mod = baseRüstwert + armorBonus; const armors = []; const einschränkungen = []; [...equippedMainArmor, ...equippedAddArmor]?.forEach((armor) => { einschränkungen.push(...armor.system.merkmale); const w = { name: armor.name, rüstwert: armor.system.rüstwert, img: armor.img, id: armor.id }; armors.push(w); }); return { armors: armors, einschränkungen: [...new Set(einschränkungen)] }; } 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"); 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 && !x.system.equipped); 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 }; }