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

+9
View File
@@ -0,0 +1,9 @@
<?xml version='1.0' encoding='iso-8859-1'?>
<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'>
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg fill="#000000" height="800px" width="800px" version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 298.935 298.935" xmlns:xlink="http://www.w3.org/1999/xlink" enable-background="new 0 0 298.935 298.935">
<g>
<path d="m149.468,77.394c-44.435,0-73.694,25.159-80.457,80.457-4.127,33.746-15.998,88.94-20.955,111.298-1.243,5.607 1.945,11.256 7.394,13.073l48.379,16.136c3.303,1.102 6.93,0.608 9.819-1.336 2.889-1.944 4.711-5.119 4.934-8.594l4.251-66.347c0.293-4.568-2.218-8.856-6.345-10.837l-31.892-15.306c-4.189-2.01-5.955-7.035-3.944-11.224l7.592-15.82c0.965-2.012 2.69-3.557 4.795-4.297 2.105-0.74 4.418-0.613 6.429,0.353l32.174,15.442c3.892,1.868 6.367,5.802 6.367,10.119v41.797c0,0.839 0.262,1.658 0.75,2.341l7.43,10.401c0.756,1.059 1.977,1.687 3.278,1.687 1.301,0 2.521-0.628 3.278-1.687l7.43-10.401c0.488-0.683 0.75-1.502 0.75-2.341v-41.798c0-4.317 2.476-8.251 6.368-10.119l32.174-15.442c2.011-0.965 4.324-1.092 6.429-0.353 2.105,0.74 3.83,2.285 4.795,4.297l7.593,15.82c2.01,4.189 0.244,9.214-3.944,11.224l-31.892,15.306c-4.127,1.981-6.637,6.269-6.345,10.837l4.251,66.347c0.223,3.475 2.045,6.649 4.934,8.594 2.888,1.944 6.516,2.438 9.819,1.336l48.379-16.136c5.459-1.821 8.639-7.455 7.394-13.073-4.956-22.359-16.828-77.552-20.955-111.298-6.763-55.297-36.022-80.456-80.457-80.456z"/>
<path d="m259.957,43.655c-38.229-35.915-89.823-49.669-138.289-41.264-0.95,0.165-1.624,1.012-1.567,1.975l.875,14.836c0.01,0.168-0.107,0.318-0.273,0.348-0.166,0.031-0.328-0.067-0.379-0.228l-4.511-14.337c-0.277-0.881-1.151-1.432-2.066-1.305-5.355,0.742-8.924,1.306-14.283,3.693-0.785,0.35-1.235,1.186-1.097,2.034l4.069,24.987c0.066,0.404-0.132,0.805-0.493,0.998-0.361,0.193-0.804,0.136-1.104-0.143l-20.075-18.659c-0.573-0.533-1.416-0.658-2.119-0.315-14.207,6.92-27.602,16.047-39.666,27.38-0.976,0.917-1.54,2.19-1.562,3.53-0.021,1.34 0.501,2.63 1.449,3.578l34.041,34.041c1.87,1.87 4.881,1.935 6.834,0.152 39.382-35.976 100.072-35.976 139.454,0 1.955,1.786 4.962,1.721 6.834-0.152l34.041-34.041c0.947-0.947 1.468-2.239 1.447-3.578-0.021-1.34-0.584-2.613-1.56-3.53z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.3 KiB

+19 -3
View File
@@ -67,11 +67,21 @@
"short": "Max.", "short": "Max.",
"long": "Maximal" "long": "Maximal"
}, },
"Zauber": {
"zauberdauer": "Zauberdauer",
"reichweite": "Reichweite",
"wirkungsdauer": "Wirkungsdauer",
"schaden": "Schaden",
"stufe": "Stufe",
"ursprung": "Ursprung",
"ziel": "Ziel"
},
"Sheets": { "Sheets": {
"Tabs": { "Tabs": {
"properties": "Fertigkeiten", "eigenschaften": "Fertigkeiten",
"items": "Gegenstände", "items": "Gegenstände",
"effects": "Effekte" "effects": "Effekte",
"zauber": "Zauber"
}, },
"spezialisierung": "Spezialisierung" "spezialisierung": "Spezialisierung"
}, },
@@ -79,6 +89,7 @@
"Quantity": "Anzahl", "Quantity": "Anzahl",
"Description": "Beschreibung", "Description": "Beschreibung",
"Eigenschaften": "Eigenschaften", "Eigenschaften": "Eigenschaften",
"Rüstwert": "Rüstwert",
"type": { "type": {
"item": { "item": {
"singular": "Gegenstand", "singular": "Gegenstand",
@@ -91,6 +102,10 @@
"armor": { "armor": {
"singular": "Rüstung", "singular": "Rüstung",
"plural": "Rüstungen" "plural": "Rüstungen"
},
"zauber": {
"singular": "Zauber",
"plural": "Zauber"
} }
} }
} }
@@ -102,7 +117,8 @@
"Item": { "Item": {
"item": "Gegenstand", "item": "Gegenstand",
"weapon": "Waffe", "weapon": "Waffe",
"armor": "Rüstung" "armor": "Rüstung",
"zauber": "Zauber"
} }
} }
} }
+2 -1
View File
@@ -4,13 +4,14 @@ function defineSchema() {
const fields = foundry.data.fields; const fields = foundry.data.fields;
const baseData = ItemData.defineSchema(); const baseData = ItemData.defineSchema();
const extendData = { const extendData = {
rüstung: new fields.NumberField({ rüstwert: new fields.NumberField({
required: true, required: true,
nullable: false, nullable: false,
integer: true, integer: true,
initial: 1, initial: 1,
min: 0 min: 0
}), }),
zusätzlich: new fields.BooleanField({ inital: false }),
equipped: new fields.BooleanField({ inital: false }) equipped: new fields.BooleanField({ inital: false })
}; };
+1
View File
@@ -8,6 +8,7 @@ function defineSchema() {
spezies: new fields.StringField({ initial: "" }), spezies: new fields.StringField({ initial: "" }),
kultur: new fields.StringField({ initial: "" }) kultur: new fields.StringField({ initial: "" })
}), }),
rüstwert: new fields.NumberField({ initial: 0, min: 0 }),
resources: new fields.SchemaField({ resources: new fields.SchemaField({
leben: new fields.SchemaField({ leben: new fields.SchemaField({
value: new fields.NumberField({ value: new fields.NumberField({
+27
View File
@@ -0,0 +1,27 @@
function defineSchema() {
const fields = foundry.data.fields;
return {
beschreibung: new fields.HTMLField({ initial: "" }),
eigenschaften: new fields.SchemaField({
stufe: new fields.NumberField({
required: true,
nullable: false,
integer: true,
initial: 1,
min: 0,
max: 3
}),
ursprung: new fields.StringField({ initial: "Kleiner Zauber" }),
schaden: new fields.StringField({ initial: "" }),
zauberdauer: new fields.StringField({ intial: "1 Aktion" }),
wirkungsdauer: new fields.StringField({ intial: "" }),
ziel: new fields.StringField({ intial: "selbst" }),
reichweite: new fields.StringField({ intial: "" })
}),
equipped: new fields.BooleanField({ initial: false })
};
}
export class ZauberData extends foundry.abstract.TypeDataModel {
static defineSchema = defineSchema;
}
+8
View File
@@ -3,6 +3,10 @@ export const loadHelpers = async function () {
return arg1 == arg2 ? options.fn(this) : options.inverse(this); return arg1 == arg2 ? options.fn(this) : options.inverse(this);
}); });
Handlebars.registerHelper("unlesseq", function (arg1, arg2, options) {
return arg1 != arg2 ? options.fn(this) : options.inverse(this);
});
Handlebars.registerHelper("fetchPath", function (actor, arg1, arg2 = "") { Handlebars.registerHelper("fetchPath", function (actor, arg1, arg2 = "") {
let arg = arg1; let arg = arg1;
if (typeof arg2 === "string") { if (typeof arg2 === "string") {
@@ -15,4 +19,8 @@ export const loadHelpers = async function () {
Handlebars.registerHelper("isdefined", function (value) { Handlebars.registerHelper("isdefined", function (value) {
return value !== undefined; return value !== undefined;
}); });
Handlebars.registerHelper("localizeConcat", function (arg1, arg2) {
return game.i18n?.localize(arg1 + arg2);
});
}; };
+43
View File
@@ -17,6 +17,49 @@ export class M6ArmorSheet extends M6ItemSheet {
}; };
} }
static TABS = {
primary: {
tabs: [
{
id: "eigenschaften",
icon: "fa-shield-halved"
},
{
id: "beschreibung",
icon: "fa-feather-pointed"
},
{
id: "effects",
icon: "fa-bolt"
}
],
initial: "eigenschaften",
labelPrefix: "Midgard6.Sheets.Tabs"
}
};
/** @inheritdoc */
static PARTS = {
header: {
template: systemPath("templates/item/header.hbs")
},
tabs: {
template: systemPath("templates/shared/tabs.hbs")
},
eigenschaften: {
template: systemPath("templates/item/rüstung/eigenschaften.hbs"),
scrollable: [""]
},
beschreibung: {
template: systemPath("templates/item/description.hbs"),
scrollable: [""]
},
effects: {
template: systemPath("templates/shared/effects.hbs"),
scrollable: [""]
}
};
static #cycleEquip() { static #cycleEquip() {
this.item.update({ this.item.update({
system: { system: {
+88 -45
View File
@@ -1,6 +1,7 @@
import { systemPath } from "../constants.mjs"; import { systemPath } from "../constants.mjs";
import { prepareActiveEffectCategories } from "../helpers/utils.mjs"; import { prepareActiveEffectCategories } from "../helpers/utils.mjs";
import { addSpezialisierung, editSepzialisierung } from "./components/spezialisierung-actions.mjs"; import { addSpezialisierung, editSepzialisierung } from "./components/spezialisierung-actions.mjs";
import { prepArmor, prepWeapons, prepWeight, prepSpells } from "./components/character-prep.mjs";
const { api, sheets } = foundry.applications; const { api, sheets } = foundry.applications;
@@ -25,6 +26,7 @@ export class M6ActorSheet extends api.HandlebarsApplicationMixin(sheets.ActorShe
toggleEffect: this.#toggleEffect, toggleEffect: this.#toggleEffect,
rollSkill: this.#rollSkill, rollSkill: this.#rollSkill,
rollWeapon: this.#rollWeapon, rollWeapon: this.#rollWeapon,
rollSpell: this.#rollSpell,
cycleEquip: this.#cycleEquip, cycleEquip: this.#cycleEquip,
addSpezialisierung: addSpezialisierung, addSpezialisierung: addSpezialisierung,
editSepzialisierung: editSepzialisierung editSepzialisierung: editSepzialisierung
@@ -41,23 +43,24 @@ export class M6ActorSheet extends api.HandlebarsApplicationMixin(sheets.ActorShe
primary: { primary: {
tabs: [ tabs: [
{ {
id: "properties", id: "eigenschaften",
icon: "fa-shield-halved" icon: "fa-shield-halved"
}, },
{ {
id: "items", id: "items",
icon: "fa-suitcase" icon: "fa-suitcase"
}, },
{ {
id: "biographie", id: "zauber",
icon: "fa-feather" icon: "fa-hand-sparkles"
}, },
{ {
id: "effects", id: "effects",
icon: "fa-bolt" icon: "fa-bolt"
} }
], ],
initial: "properties", initial: "eigenschaften",
labelPrefix: "Midgard6.Sheets.Tabs" labelPrefix: "Midgard6.Sheets.Tabs"
} }
}; };
@@ -67,13 +70,17 @@ export class M6ActorSheet extends api.HandlebarsApplicationMixin(sheets.ActorShe
/** @inheritdoc */ /** @inheritdoc */
static PARTS = { static PARTS = {
tabs: { tabs: {
template: systemPath("templates/actor/tabs.hbs") template: systemPath("templates/shared/tabs.hbs")
}, },
header: { header: {
template: systemPath("templates/actor/header.hbs") template: systemPath("templates/actor/header.hbs")
}, },
properties: { eigenschaften: {
template: systemPath("templates/shared/properties.hbs"), template: systemPath("templates/actor/eigenschaften.hbs"),
scrollable: [""]
},
zauber: {
template: systemPath("templates/actor/zauber.hbs"),
scrollable: [""] scrollable: [""]
}, },
items: { items: {
@@ -106,6 +113,7 @@ export class M6ActorSheet extends api.HandlebarsApplicationMixin(sheets.ActorShe
/** @inheritdoc */ /** @inheritdoc */
async _prepareContext(options) { async _prepareContext(options) {
const context = await super._prepareContext(options); const context = await super._prepareContext(options);
await prepArmor(this.actor);
Object.assign(context, { Object.assign(context, {
owner: this.document.isOwner, owner: this.document.isOwner,
@@ -125,23 +133,24 @@ export class M6ActorSheet extends api.HandlebarsApplicationMixin(sheets.ActorShe
/** @inheritdoc */ /** @inheritdoc */
async _preparePartContext(partId, context) { async _preparePartContext(partId, context) {
switch (partId) { switch (partId) {
// case "stats":
// context.fields = await this._getResources();
// context.tab = context.tabs[partId];
// break;
case "effects": case "effects":
context.effects = prepareActiveEffectCategories(this.actor.allApplicableEffects()); context.effects = prepareActiveEffectCategories(this.actor.allApplicableEffects());
context.tab = context.tabs[partId]; context.tab = context.tabs[partId];
break; break;
case "properties": case "eigenschaften":
context.skills = await this._getSkills(); context.skills = await this._getSkills();
context.resistenzen = await this._getResistenzen(); 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]; context.tab = context.tabs[partId];
break; break;
case "items": case "items":
context.itemTypes = await this._getItems(); 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]; context.tab = context.tabs[partId];
break; break;
} }
@@ -257,28 +266,10 @@ export class M6ActorSheet extends api.HandlebarsApplicationMixin(sheets.ActorShe
return fieldSets; 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) { static async #cycleEquip(event, target) {
console.warn(target.dataset);
const item = this.actor.items.get(target.dataset.itemId); const item = this.actor.items.get(target.dataset.itemId);
console.warn(item);
item.update({ item.update({
system: { system: {
equipped: !item.system.equipped equipped: !item.system.equipped
@@ -329,15 +320,8 @@ export class M6ActorSheet extends api.HandlebarsApplicationMixin(sheets.ActorShe
return types; return types;
} }
_clacWeight() { _getZauber() {
const items = this.actor.items.filter((x) => x.system.gewicht); return this.actor.items.filter((item) => item.type === "zauber");
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
};
} }
/* -------------------------------------------------- */ /* -------------------------------------------------- */
@@ -427,6 +411,65 @@ export class M6ActorSheet extends api.HandlebarsApplicationMixin(sheets.ActorShe
effect.update({ disabled: !effect.disabled }); 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) { static async #rollSkill(event, target) {
const dataset = target.dataset; const dataset = target.dataset;
const skill = foundry.utils.getProperty(this.actor, target.dataset.path.replace(".value", "")); 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 actor
}); });
console.log("Dialog Result", dialogResult); console.log("Dialog Result", dialogResult);
if (!dialogResult) { if (dialogResult === "abort") {
return; return;
} }
// Construct the Roll instance // Construct the Roll instance
@@ -496,7 +539,7 @@ export class M6ActorSheet extends api.HandlebarsApplicationMixin(sheets.ActorShe
actor actor
}); });
console.log("Dialog Result", dialogResult); console.log("Dialog Result", dialogResult);
if (!dialogResult) { if (dialogResult === "abort") {
return; return;
} }
// Construct the Roll instance // Construct the Roll instance
+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
};
}
+1 -1
View File
@@ -57,7 +57,7 @@ export class M6ItemSheet extends api.HandlebarsApplicationMixin(sheets.ItemSheet
template: systemPath("templates/item/header.hbs") template: systemPath("templates/item/header.hbs")
}, },
tabs: { tabs: {
template: systemPath("templates/actor/tabs.hbs") template: systemPath("templates/shared/tabs.hbs")
}, },
beschreibung: { beschreibung: {
template: systemPath("templates/item/description.hbs"), template: systemPath("templates/item/description.hbs"),
+2 -2
View File
@@ -44,10 +44,10 @@ export class M6WeaponSheet extends M6ItemSheet {
template: systemPath("templates/item/header.hbs") template: systemPath("templates/item/header.hbs")
}, },
tabs: { tabs: {
template: systemPath("templates/actor/tabs.hbs") template: systemPath("templates/shared/tabs.hbs")
}, },
eigenschaften: { eigenschaften: {
template: systemPath("templates/item/eigenschaften.hbs"), template: systemPath("templates/item/waffen/eigenschaften.hbs"),
scrollable: [""] scrollable: [""]
}, },
beschreibung: { beschreibung: {
+108
View File
@@ -0,0 +1,108 @@
import { prepareActiveEffectCategories } from "../helpers/utils.mjs";
import { systemPath } from "../constants.mjs";
import { M6ItemSheet } from "./item-sheet.mjs";
const { api, sheets } = foundry.applications;
/**
* Extend the basic ItemSheet with some very simple modifications.
*/
export class M6ZauberSheet extends M6ItemSheet {
static get DEFAULT_OPTIONS() {
return {
...super.DEFAULT_OPTIONS, // Kopiert alle bestehenden Actions aus M6ItemSheet
actions: {
...super.DEFAULT_OPTIONS.actions,
cycleEquip: this.#cycleEquip // Fügt NUR für dieses Sheet die neue Action hinzu
}
};
}
static TABS = {
primary: {
tabs: [
{
id: "eigenschaften",
icon: "fa-shield-halved"
},
{
id: "beschreibung",
icon: "fa-feather-pointed"
}
],
initial: "eigenschaften",
labelPrefix: "Midgard6.Sheets.Tabs"
}
};
/** @inheritdoc */
static PARTS = {
header: {
template: systemPath("templates/zauber/header.hbs")
},
tabs: {
template: systemPath("templates/shared/tabs.hbs")
},
eigenschaften: {
template: systemPath("templates/zauber/eigenschaften.hbs"),
scrollable: [""]
},
beschreibung: {
template: systemPath("templates/zauber/description.hbs"),
scrollable: [""]
}
};
async _addSpecifics(context) {
context.zauberFields = await this._getFields();
context.bonuses = foundry.utils.getProperty(this.actor, "system.skills.magie.zaubern").bonuses;
console.warn(context);
}
static #cycleEquip() {
this.item.update({
system: {
equipped: !this.item.system.equipped
}
});
}
/* -------------------------------------------------- */
/**
* Handles the system fields for the form-fields generic.
*/
async _getFields() {
const doc = this.item;
const source = doc._source;
const systemFields = CONFIG.Item.dataModels[doc.type]?.schema.fields;
const fieldSets = {};
// TODO: Find a clever way to handle enrichment
for (const field of Object.values(systemFields ?? {})) {
const path = `system.${field.name}`;
if (field instanceof foundry.data.fields.SchemaField) {
const fieldset = { fieldset: true, legend: field.label, fields: {} };
await this.#addSystemFields(fieldset, field.fields, source, path);
fieldSets[field.name] = fieldset;
} else {
fieldSets[field.name] = { field, value: foundry.utils.getProperty(source, path) };
}
}
return fieldSets;
}
/* -------------------------------------------------- */
/**
* Recursively add system model fields to the fieldset.
*/
async #addSystemFields(fieldset, schema, source, _path = "system") {
for (const field of Object.values(schema)) {
const path = `${_path}.${field.name}`;
if (field instanceof foundry.data.fields.SchemaField) {
this.#addSystemFields(fieldset, field.fields, source, path);
} else if (field.constructor.hasFormSupport) {
fieldset.fields[field.name] = { field, value: foundry.utils.getProperty(source, path) };
}
}
}
}
+16 -1
View File
@@ -96,6 +96,21 @@
} }
} }
.armor-box {
position: absolute;
margin-left: -8px;
i {
font-size: 20px;
}
}
.armor-value {
position: absolute;
right: 8px;
font-size: 16px;
color: var(--M6-background-white);
}
.sheet-header { .sheet-header {
img { img {
border-radius: 0 0 50% 50%; border-radius: 0 0 50% 50%;
@@ -109,7 +124,7 @@
height: 100%; height: 100%;
padding-top: 10px; padding-top: 10px;
} }
.tab[data-tab="items"] { .tab {
ul { ul {
list-style: none; list-style: none;
padding-left: 5px; padding-left: 5px;
+11
View File
@@ -8,3 +8,14 @@
/* Standardfarbe (wird durch die Maske in die Form des SVGs gepresst) */ /* Standardfarbe (wird durch die Maske in die Form des SVGs gepresst) */
background-color: var(--M6-text-grey); background-color: var(--M6-text-grey);
} }
.helmet {
width: 24px;
height: 24px;
/* Das SVG wird als Maske geladen */
mask: url("../assets/helmet.svg") no-repeat center / contain;
-webkit-mask: url("../assets/helmet.svg") no-repeat center / contain;
/* Standardfarbe (wird durch die Maske in die Form des SVGs gepresst) */
background-color: var(--M6-text-grey);
}
+6
View File
@@ -2,10 +2,12 @@ import { CharacterData } from "./data/character-data.mjs";
import { WeaponData } from "./data/weapon-data.mjs"; import { WeaponData } from "./data/weapon-data.mjs";
import { ItemData } from "./data/item-data.mjs"; import { ItemData } from "./data/item-data.mjs";
import { ArmorData } from "./data/armor-data.mjs"; import { ArmorData } from "./data/armor-data.mjs";
import { ZauberData } from "./data/zauber-data.mjs";
import { M6ActorSheet } from "./sheets/character-sheet.mjs"; import { M6ActorSheet } from "./sheets/character-sheet.mjs";
import { M6ItemSheet } from "./sheets/item-sheet.mjs"; import { M6ItemSheet } from "./sheets/item-sheet.mjs";
import { M6WeaponSheet } from "./sheets/weapon-sheet.mjs"; import { M6WeaponSheet } from "./sheets/weapon-sheet.mjs";
import { M6ArmorSheet } from "./sheets/armor-sheet.mjs"; import { M6ArmorSheet } from "./sheets/armor-sheet.mjs";
import { M6ZauberSheet } from "./sheets/zauber-sheet.mjs";
import { loadHelpers } from "./helpers/handlebar-helpers.mjs"; import { loadHelpers } from "./helpers/handlebar-helpers.mjs";
import "./styles/M6.scss"; import "./styles/M6.scss";
@@ -24,6 +26,7 @@ Hooks.once("init", () => {
CONFIG.Item.dataModels.item = ItemData; CONFIG.Item.dataModels.item = ItemData;
CONFIG.Item.dataModels.weapon = WeaponData; CONFIG.Item.dataModels.weapon = WeaponData;
CONFIG.Item.dataModels.armor = ArmorData; CONFIG.Item.dataModels.armor = ArmorData;
CONFIG.Item.dataModels.zauber = ZauberData;
foundry.applications.apps.DocumentSheetConfig.registerSheet(Actor, "midgard6-lvd", M6ActorSheet, { foundry.applications.apps.DocumentSheetConfig.registerSheet(Actor, "midgard6-lvd", M6ActorSheet, {
types: ["character"], types: ["character"],
@@ -39,6 +42,9 @@ Hooks.once("init", () => {
foundry.applications.apps.DocumentSheetConfig.registerSheet(Item, "midgard6-lvd", M6ArmorSheet, { foundry.applications.apps.DocumentSheetConfig.registerSheet(Item, "midgard6-lvd", M6ArmorSheet, {
types: ["armor"] types: ["armor"]
}); });
foundry.applications.apps.DocumentSheetConfig.registerSheet(Item, "midgard6-lvd", M6ZauberSheet, {
types: ["zauber"]
});
loadHelpers(); loadHelpers();
}); });
-40
View File
@@ -1,40 +0,0 @@
<div className={{styles.sheet}}>
<h1>{{actor.name}}</h1>
<div className={{styles.skills}}>
{{(["anführen", "fernkampf", "nahkampf"] as const).map((key) => (
<label className={{styles.attributeLabel}} key={{key}}>
{{localize(`Midgard6.skills.${key}`)}}
<input
type="number"
value={{attrs[key]}}
onChange="{{(e) => updateAttribute(key, Number(e.target.value))}}"/>
<span className={{styles.modifier}}>{{fmtMod(modifier(attrs[key]))}}</span>
</label>
))}}
</div>
<div className={{styles.totals}}>
<span>
{{localize("Midgard6.Sheet.Total")}}: {{total}}
</span>
<span>
{{localize("Midgard6.Sheet.TotalMod")}}: {{fmtMod(totalMod)}}
</span>
</div>
<label className={{styles.attributeLabel}}>
{{localize("Midgard6.Sheet.Biography")}}
<textarea defaultValue={{system.biography}} onBlur="{{(e) => updateBiography(e.target.value)}}" />
</label>
<div className={{styles.chatRow}}>
<input
type="text"
placeholder={{localize("Midgard6.Sheet.ChatPlaceholder")}}
value={{chatMessage}}
onChange="{{(e) => setChatMessage(e.target.value)}}"
onKeyDown="{{(e) => e.key === "Enter" && sendChatMessage()}}"
/>
<button type="button" onClick={{sendChatMessage}}>
{{localize("Midgard6.Sheet.SendToChat")}}
</button>
</div>
</div>
@@ -1,7 +1,7 @@
<section <section
class="standard-form tab scrollable {{tab.cssClass}}" class="standard-form tab scrollable {{tab.cssClass}}"
data-group="primary" data-group="primary"
data-tab="properties" data-tab="eigenschaften"
> >
<div class="container"> <div class="container">
<div class="row"> <div class="row">
@@ -11,26 +11,25 @@
<fieldset> <fieldset>
<legend>{{localize legend}}</legend> <legend>{{localize legend}}</legend>
{{#each fields}} {{#each fields}}
<div class="d-flex justify-content-between align-items-center"> <div class="row align-items-center">
<div class="flex-grow-1 flexrow" style="max-width: 16rem;"> <div class="col-6 row align-items-center" style="width: 100%; margin-left: 0">
<a <a
class="col-6" class="col-8"
data-action="rollSkill" data-action="rollSkill"
data-name="{{localize localizationName}}" data-name="{{localize localizationName}}"
data-path="{{field.fieldPath}}" data-path="{{field.fieldPath}}"
> >
<p class="flex1" style="margin-left: 4px; max-width:7rem">{{localize <p>{{localize
localizationName localizationName
}}</p> }}</p>
</a> </a>
<a <a
class="flex-grow-0"
data-action="rollSkill" data-action="rollSkill"
data-name="{{localize localizationName}}" data-name="{{localize localizationName}}"
data-path="{{field.fieldPath}}" data-path="{{field.fieldPath}}"
> >
<i <i
class="flex-grow-0 fa-solid fa-dice-d20" class="fa-solid fa-dice-d20"
style="padding:2px 0; margin-right: -14px" style="padding:2px 0; margin-right: -14px"
></i> ></i>
</a> </a>
@@ -46,12 +45,13 @@
data-path="{{field.fieldPath}}" data-path="{{field.fieldPath}}"
>+</a> >+</a>
</div> </div>
<div class="d-flex"> <div class="col d-flex flex-wrap" style="gap: 4px 8px; width: 100%">
{{#each bonuses}} {{#each bonuses}}
<a data-action="editSepzialisierung" <a data-action="editSepzialisierung"
data-name="{{name}}" data-name="{{name}}"
data-level="{{level}}" data-level="{{level}}"
data-path="{{path}}" data-path="{{path}}"
style="white-space: nowrap;"
{{#unless @last}}style="margin-right: 4px"{{/unless}}>{{name}}: {{level}}{{#unless @last}},{{/unless}}</a> {{#unless @last}}style="margin-right: 4px"{{/unless}}>{{name}}: {{level}}{{#unless @last}},{{/unless}}</a>
{{/each}} {{/each}}
</div> </div>
@@ -96,13 +96,18 @@
<div class="d-flex align-items-end"> <div class="d-flex align-items-end">
<div> <div>
<p class="resistenzenHeader">{{localize "Midgard6.aktuell"}}</p> <p class="resistenzenHeader">{{localize "Midgard6.aktuell"}}</p>
<div class="d-flex align-items-center">
<input <div class="armor-box">
class="attribut" <i class="fa-solid fa-shield"></i>
type="number" <span class="armor-value">{{system.rüstwert}}</span>
name="system.resources.leben.value" </div>
value="{{system.resources.leben.value}}" <input
/> class="attribut"
type="number"
name="system.resources.leben.value"
value="{{system.resources.leben.value}}"
/>
</div>
</div> </div>
<p class="center">/</p> <p class="center">/</p>
<div> <div>
@@ -173,6 +178,37 @@
</div> </div>
</fieldset> </fieldset>
</div> </div>
<div>
<fieldset class="highlight">
<legend>{{localize "Midgard6.Item.type.zauber.plural" }}</legend>
<div class="container">
{{#each equippedSpells as |weapon|}}
<div class="item row align-items-center">
<div class="col-10">
<div class="d-flex justify-content-start align-items-center">
<img class="" style="margin-right: 4px" src="{{weapon.img}}" alt="{{weapon.name}}" width="24" height="24" />
<p>{{weapon.name}}: </p>
<p>
<i class="fas fa-dice-d20" style="font-size:12px; margin:0 2px 0 4px"></i>
+ {{weapon.skillValue}} {{#if weapon.bonusValue}}+ {{weapon.bonusValue}}{{/if}}</p>
</div>
</div>
<div class="col-2 document-controls">
<a
class="item-control"
title="{{localize 'Midgard6.Angriff'}} {{weapon.name}}"
data-action="rollSpell"
data-item-id="{{weapon.id}}"
data-skillPath="{{weapon.path}}"
>
<i class="fas fa-dice-d20"></i>
</a>
</div>
</div>
{{/each}}
</div>
</fieldset>
</div>
</div> </div>
</div> </div>
</div> </div>
+1
View File
@@ -133,6 +133,7 @@
<li class="item flexrow draggable" data-item-id="{{item._id}}" data-type="Item" data-document-class="Item"> <li class="item flexrow draggable" data-item-id="{{item._id}}" data-type="Item" data-document-class="Item">
<img src="{{item.img}}" alt="{{item.name}}" width="24" height="24" /> <img src="{{item.img}}" alt="{{item.name}}" width="24" height="24" />
<div class="item-name">{{item.system.anzahl}}x {{item.name}}</div> <div class="item-name">{{item.system.anzahl}}x {{item.name}}</div>
<a class="helmet" data-action="cycleEquip" data-item-id="{{item._id}}" style="{{#if item.system.equipped}}background-color: var(--M6-text-brown){{/if}}">
<div class="document-controls"> <div class="document-controls">
<a <a
class="item-control item-edit" class="item-control item-edit"
+62
View File
@@ -0,0 +1,62 @@
{{! Items Tab }}
<section class="standard-form tab scrollable {{tab.cssClass}}" data-group="primary" data-tab="zauber">
<div class="container">
<div class="row">
<div class="col-12">
<fieldset >
<legend>{{localize "Midgard6.Item.type.zauber.plural" }}</legend>
<ul class="itemTypes">
{{!-- {{#with itemTypes.zauber}} --}}
<li class="itemHeader">
<div class="document-controls">
{{#if @root.editable}}
<a
class="item-control item-create"
title="{{localize 'DOCUMENT.Create' type="Zauber"}}"
data-action="createDoc"
data-document-class="Item"
data-type="zauber"
>
<i class="fas fa-plus"></i>
{{localize "DOCUMENT.Create" type="Zauber"}}
</a>
{{/if}}
</div>
</li>
<ul class="items">
{{#each zauber as |zauber|}}
<li class="item row align-content-center draggable" data-item-id="{{zauber._id}}" data-type="Zauber" data-document-class="Item">
<p class="col-3 item-name">{{zauber.name}}</p>
<p class="col-3 item-name">{{zauber.system.eigenschaften.ursprung}}</p>
<p class="col-1 item-name">{{zauber.system.eigenschaften.stufe}}</p>
<a class="col-2 fa-solid {{#if zauber.system.equipped}}fa-book-open{{else}}fa-book{{/if}}" data-action="cycleEquip" data-item-id="{{zauber._id}}" style="{{#if zauber.system.equipped}}color: var(--M6-text-brown);{{/if}} margin: 0.5rem 0;"></a>
<a class="col-1 fa-solid fa-dice-d20" data-action="rollSpell" data-item-id="{{zauber._id}}" style="margin: 0.5rem 0;"></a>
<div class="col-2 d-flex document-controls" style="margin: 0.5rem 0;">
{{#if @root.editable}}
<a
class="item-control item-edit"
title="{{localize 'DOCUMENT.Update' type=zauber.name}}"
data-action="viewDoc"
>
<i class="fas fa-edit"></i>
</a>
<a
class="item-control item-delete"
title="{{localize 'DOCUMENT.Delete' type=zauber.name}}"
data-action="deleteDoc"
>
<i class="fas fa-trash"></i>
</a>
{{/if}}
</div>
</li>
{{/each}}
</ul>
{{!-- {{/with}} --}}
</fieldset>
</div>
</div>
</div>
</ul>
</section>
+16 -21
View File
@@ -1,12 +1,22 @@
<header class="sheet-header" style="margin: 1px;"> <header class="sheet-header">
<div class="container"> <div class="container">
<div class="row align-items-end" style="height: 108px" > <div class="row align-items-end" style="height: 108px" >
<div class="col-6" style="height:32px"> <img
{{#if (isdefined system.equipped)}} class="profile-img"
<div class="d-flex justify-content-center justify-items-center"> style="z-index:1"
<a class="sword {{#if system.equipped}}icon-checked{{/if}}" data-action="cycleEquip" data-item-id="{{item._id}}"></a> src="{{item.img}}"
</div> alt="{{item.name}}"
{{#if editable}}
data-action="editImage"
data-edit="img"
{{/if}} {{/if}}
data-tooltip="{{item.name}}"
height="100" width="100"
>
<div class="col-12">
<input class="text" type="text" style="color: var(--M6-text-brown); font-weight: bold; font-size:24px; background-color: var(--Midgard6-background-grey)" placeholder="{{localize "Midgard6.name"}}" name="name" value="{{item.name}}" />
</div>
<div class="col-6">
</div> </div>
<div class="col-6"> <div class="col-6">
<input class="custom-input right text" type="number" placeholder="{{localize "Midgard6.Gegenstand.anzahl"}}" name="system.anzahl" value="{{item.system.anzahl}}" /> <input class="custom-input right text" type="number" placeholder="{{localize "Midgard6.Gegenstand.anzahl"}}" name="system.anzahl" value="{{item.system.anzahl}}" />
@@ -20,21 +30,6 @@
<input class="custom-input right text" type="number" placeholder="{{localize "Midgard6.Gegenstand.gewicht"}}" name="system.gewicht" value="{{item.system.gewicht}}" /> <input class="custom-input right text" type="number" placeholder="{{localize "Midgard6.Gegenstand.gewicht"}}" name="system.gewicht" value="{{item.system.gewicht}}" />
<i class="fa-solid fa-weight-hanging input-icon right"></i> <i class="fa-solid fa-weight-hanging input-icon right"></i>
</div> </div>
<div class="col-12">
<input class="text" type="text" placeholder="{{localize "Midgard6.name"}}" name="name" value="{{item.name}}" />
</div>
<img
class="profile-img"
style="z-index:1"
src="{{item.img}}"
alt="{{item.name}}"
{{#if editable}}
data-action="editImage"
data-edit="img"
{{/if}}
data-tooltip="{{item.name}}"
height="100" width="100"
>
</div> </div>
</div> </div>
</header> </header>
@@ -0,0 +1,29 @@
<section
class="standard-form tab {{tab.cssClass}}"
data-tab="{{tab.id}}"
data-group="{{tab.group}}"
style="overflow: hidden"
>
<fieldset style="height:100%">
<legend>{{localize "Midgard6.Item.Eigenschaften"}}</legend>
<div class="container">
<div class="row">
<div class="col-6">
<div class="d-flex justify-content-between">
<p>Rüstung</p>
<input
type="text"
style=" max-width:10rem"
name="system.rüstwert"
id="rollDisplay"
placeholder="0"
value="{{system.rüstwert}}"
/>
</div>
</div>
<div class="col-6">
</div>
</div>
</div>
</fieldset>
</section>
File renamed without changes.
+26
View File
@@ -0,0 +1,26 @@
{{! Beschreibung Allgemein Tab }}
<section
class="standard-form tab {{tab.cssClass}}"
data-tab="{{tab.id}}"
data-group="{{tab.group}}"
style="overflow: hidden"
>
{{! Editors must receive enriched text data from getData to properly handle rolls, UUID links, etc. }}
<fieldset style="height:100%">
<legend>{{localize "Midgard6.Item.Description"}}</legend>
{{#if editable}}
<prose-mirror
style="height:100%"
name="system.beschreibung"
data-document-u-u-i-d="{{actor.uuid}}"
value="{{system.beschreibung}}"
collaborate="true"
toggled="true"
>
{{{enrichedBeschreibung}}}
</prose-mirror>
{{else}}
{{{enrichedBeschreibung}}}
{{/if}}
</fieldset>
</section>
+32
View File
@@ -0,0 +1,32 @@
<section
class="standard-form tab scrollable {{tab.cssClass}}"
data-tab="{{tab.id}}"
data-group="{{tab.group}}"
>
<fieldset style="height:100%">
<legend>{{localize "Midgard6.Item.Eigenschaften"}}</legend>
<div class="container">
<div class="row">
{{#each zauberFields.eigenschaften.fields}}
{{#unlesseq field.name "ursprung"}}
{{#unlesseq field.name "stufe"}}
<div class="col-6">
<div class="d-flex justify-content-between">
<p>{{localizeConcat "Midgard6.Zauber." field.name}}</p>
<input
type="text"
style="margin-bottom: 4px; max-width:10rem"
name="{{field.fieldPath}}"
id="rollDisplay"
placeholder="{{localizeConcat 'Midgard6.Zauber.' field.name}}"
value="{{value}}"
/>
</div>
</div>
{{/unlesseq}}
{{/unlesseq}}
{{/each}}
</div>
</div>
</fieldset>
</section>
+45
View File
@@ -0,0 +1,45 @@
<header class="sheet-header">
<div class="container">
<div class="row align-items-end" style="height: 108px" >
<div class="col-12">
<input class="text" type="text" style="color: var(--M6-text-brown); font-weight: bold; font-size:24px; background-color: var(--Midgard6-background-grey)" placeholder="{{localize "Midgard6.name"}}" name="name" value="{{item.name}}" />
</div>
<div class="col-6" style="height:32px">
</div>
<div class="col-6">
</div>
<div class="col-6">
<input class="custom-input text" type="text" placeholder="{{localize "Midgard6.Zauber.stufe"}}" name="system.eigenschaften.stufe" value="{{item.system.eigenschaften.stufe}}" />
</div>
<div class="col-6">
<select
class="text right"
style="text-align: right"
name="system.eigenschaften.ursprung"
id="ursprung"
placeholder="Kleiner Zauber/ Zaubersalz"
/>
{{#each bonuses as |bonus|}}
<option {{#ifeq bonus.name system.eigenschaften.ursprung}}selected{{/ifeq}} value="{{bonus.name}}">
{{bonus.name}}
</option>
{{/each}}
<option {{#ifeq system.eigenschaften.ursprung "Kleiner Zauber"}}selected{{/ifeq}} value="Kleiner Zauber">Kleiner Zauber</option>
<option {{#ifeq system.eigenschaften.ursprung "Zaubersalz"}}selected{{/ifeq}} value="Zaubersalz">Zaubersalz</option>
</select>
</div>
<img
class="profile-img"
style="z-index:1"
src="{{item.img}}"
alt="{{item.name}}"
{{#if editable}}
data-action="editImage"
data-edit="img"
{{/if}}
data-tooltip="{{item.name}}"
height="100" width="100"
>
</div>
</div>
</header>
+2 -1
View File
@@ -2,10 +2,11 @@ import { CharacterData } from "../data/character-data";
import { ItemData } from "../data/item-data"; import { ItemData } from "../data/item-data";
import { WeaponData } from "../data/weapon-data"; import { WeaponData } from "../data/weapon-data";
import { ArmorData } from "../data/armor-data"; import { ArmorData } from "../data/armor-data";
import {ZauberrData } from "../data/zauber-data";
declare module "fvtt-types/configuration" { declare module "fvtt-types/configuration" {
interface DataModelConfig { interface DataModelConfig {
Actor: { character: typeof CharacterData }; Actor: { character: typeof CharacterData };
Item: { item: typeof ItemData, weapon: typeof WeaponData, armor: typeof ArmorData }; Item: { item: typeof ItemData, weapon: typeof WeaponData, armor: typeof ArmorData, zauber: typeof ZauberData };
} }
} }
+2 -1
View File
@@ -35,7 +35,8 @@
"Item": { "Item": {
"item": {}, "item": {},
"weapon": {}, "weapon": {},
"armor": {} "armor": {},
"zauber": {}
} }
}, },
"compatibility": { "compatibility": {