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

+88 -45
View File
@@ -1,6 +1,7 @@
import { systemPath } from "../constants.mjs";
import { prepareActiveEffectCategories } from "../helpers/utils.mjs";
import { addSpezialisierung, editSepzialisierung } from "./components/spezialisierung-actions.mjs";
import { prepArmor, prepWeapons, prepWeight, prepSpells } from "./components/character-prep.mjs";
const { api, sheets } = foundry.applications;
@@ -25,6 +26,7 @@ export class M6ActorSheet extends api.HandlebarsApplicationMixin(sheets.ActorShe
toggleEffect: this.#toggleEffect,
rollSkill: this.#rollSkill,
rollWeapon: this.#rollWeapon,
rollSpell: this.#rollSpell,
cycleEquip: this.#cycleEquip,
addSpezialisierung: addSpezialisierung,
editSepzialisierung: editSepzialisierung
@@ -41,23 +43,24 @@ export class M6ActorSheet extends api.HandlebarsApplicationMixin(sheets.ActorShe
primary: {
tabs: [
{
id: "properties",
id: "eigenschaften",
icon: "fa-shield-halved"
},
{
id: "items",
icon: "fa-suitcase"
},
{
id: "biographie",
icon: "fa-feather"
id: "zauber",
icon: "fa-hand-sparkles"
},
{
id: "effects",
icon: "fa-bolt"
}
],
initial: "properties",
initial: "eigenschaften",
labelPrefix: "Midgard6.Sheets.Tabs"
}
};
@@ -67,13 +70,17 @@ export class M6ActorSheet extends api.HandlebarsApplicationMixin(sheets.ActorShe
/** @inheritdoc */
static PARTS = {
tabs: {
template: systemPath("templates/actor/tabs.hbs")
template: systemPath("templates/shared/tabs.hbs")
},
header: {
template: systemPath("templates/actor/header.hbs")
},
properties: {
template: systemPath("templates/shared/properties.hbs"),
eigenschaften: {
template: systemPath("templates/actor/eigenschaften.hbs"),
scrollable: [""]
},
zauber: {
template: systemPath("templates/actor/zauber.hbs"),
scrollable: [""]
},
items: {
@@ -106,6 +113,7 @@ export class M6ActorSheet extends api.HandlebarsApplicationMixin(sheets.ActorShe
/** @inheritdoc */
async _prepareContext(options) {
const context = await super._prepareContext(options);
await prepArmor(this.actor);
Object.assign(context, {
owner: this.document.isOwner,
@@ -125,23 +133,24 @@ export class M6ActorSheet extends api.HandlebarsApplicationMixin(sheets.ActorShe
/** @inheritdoc */
async _preparePartContext(partId, context) {
switch (partId) {
// case "stats":
// context.fields = await this._getResources();
// context.tab = context.tabs[partId];
// break;
case "effects":
context.effects = prepareActiveEffectCategories(this.actor.allApplicableEffects());
context.tab = context.tabs[partId];
break;
case "properties":
case "eigenschaften":
context.skills = await this._getSkills();
context.resistenzen = await this._getResistenzen();
context.equippedWeapons = await this._prepWeapons();
context.equippedWeapons = await prepWeapons(this.actor);
context.equippedSpells = await prepSpells(this.actor);
context.tab = context.tabs[partId];
break;
case "items":
context.itemTypes = await this._getItems();
context.gewicht = this._clacWeight();
context.gewicht = await prepWeight(this.actor);
context.tab = context.tabs[partId];
break;
case "zauber":
context.zauber = await this._getZauber();
context.tab = context.tabs[partId];
break;
}
@@ -257,28 +266,10 @@ export class M6ActorSheet extends api.HandlebarsApplicationMixin(sheets.ActorShe
return fieldSets;
}
async _prepWeapons() {
const weaponItems = this.actor.items.filter((x) => x.type === "weapon" && x.system.equipped);
const weapons = [];
weaponItems.forEach((weapon) => {
const skill = foundry.utils.getProperty(this.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;
}
static async #cycleEquip(event, target) {
console.warn(target.dataset);
const item = this.actor.items.get(target.dataset.itemId);
console.warn(item);
item.update({
system: {
equipped: !item.system.equipped
@@ -329,15 +320,8 @@ export class M6ActorSheet extends api.HandlebarsApplicationMixin(sheets.ActorShe
return types;
}
_clacWeight() {
const items = this.actor.items.filter((x) => x.system.gewicht);
let gewicht = items.reduce((accumulator, item) => accumulator + item.system.gewicht, 0);
let traglast = Math.max(this.actor.system.skills.körper.athletik.value, 10);
return {
traglast,
gewicht
};
_getZauber() {
return this.actor.items.filter((item) => item.type === "zauber");
}
/* -------------------------------------------------- */
@@ -427,6 +411,65 @@ export class M6ActorSheet extends api.HandlebarsApplicationMixin(sheets.ActorShe
effect.update({ disabled: !effect.disabled });
}
static async #rollSpell(event, target) {
const dataset = target.dataset;
const skill = foundry.utils.getProperty(this.actor, "system.skills.magie.zaubern");
const item = this.actor.items.get(dataset.itemId);
const actor = this.actor;
const dialogResult = await this.rollDialog({
name: dataset.name,
skill,
damageRoll: item.system.eigenschaften.schaden,
preSelectedSpez: item.system.eigenschaften.ursprung,
actor
});
console.log("Dialog Result", dialogResult);
if (dialogResult === "abort") {
return;
}
// Construct the Roll instance
const skillValue = skill.value;
let die = "";
switch (dialogResult.vorteil) {
case -1:
die = "2d20kl";
break;
case 1:
die = "2d20kh";
break;
default:
die = "1d20";
break;
}
let rollTerm = "@die + @skill";
let rollFlavor = dataset.name;
let roll;
if (dialogResult.spezLevel) {
rollTerm += " + @spezBonus";
rollFlavor += ": " + dialogResult.spezName;
}
if (dialogResult.customRoll) {
roll = new Roll(dialogResult.customRoll);
} else {
roll = new Roll(
rollTerm,
{ die: die, skill: skillValue, spezBonus: dialogResult.spezLevel + 1 },
{ flavor: rollFlavor }
);
}
// The parsed terms of the roll formula
console.log("Roll:", roll); // [Die, OperatorTerm, NumericTerm, OperatorTerm, NumericTerm]
// Execute the roll
await roll.evaluate();
roll.toMessage();
}
static async #rollSkill(event, target) {
const dataset = target.dataset;
const skill = foundry.utils.getProperty(this.actor, target.dataset.path.replace(".value", ""));
@@ -437,7 +480,7 @@ export class M6ActorSheet extends api.HandlebarsApplicationMixin(sheets.ActorShe
actor
});
console.log("Dialog Result", dialogResult);
if (!dialogResult) {
if (dialogResult === "abort") {
return;
}
// Construct the Roll instance
@@ -496,7 +539,7 @@ export class M6ActorSheet extends api.HandlebarsApplicationMixin(sheets.ActorShe
actor
});
console.log("Dialog Result", dialogResult);
if (!dialogResult) {
if (dialogResult === "abort") {
return;
}
// Construct the Roll instance