Prepare for version 0.9 (#8)
Foundry VTT System Release / build-and-release (push) Failing after 3m47s
Foundry VTT System Release / build-and-release (push) Failing after 3m47s
Reviewed-on: #8 Co-authored-by: Byroks <byroks@gmail.com>
This commit was merged in pull request #8.
This commit is contained in:
1 parent
9568be0211
commit
49b8eddf15
84 files changed
+8046
-468
No files matched your search
@@ -0,0 +1,11 @@
|
||||
export const systemID = "midgard6-lvd";
|
||||
|
||||
/**
|
||||
* Translates repository paths to Foundry Data paths.
|
||||
* @param {string} path - A path relative to the root of this repository.
|
||||
* @returns {string} The path relative to the Foundry data folder.
|
||||
*/
|
||||
export const systemPath = (path) => `systems/${systemID}/${path}`;
|
||||
export const assetPath = (path) => `systems/${systemID}/assets/${path}`;
|
||||
|
||||
export const swordSVG = "systems/midgard6-lvd/assets/sword.svg";
|
||||
@@ -0,0 +1,23 @@
|
||||
import { ItemData } from "./item-data.mjs";
|
||||
|
||||
function defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
const baseData = ItemData.defineSchema();
|
||||
const extendData = {
|
||||
rüstwert: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
integer: true,
|
||||
initial: 1,
|
||||
min: 0
|
||||
}),
|
||||
zusätzlich: new fields.BooleanField({ inital: false }),
|
||||
equipped: new fields.BooleanField({ inital: false })
|
||||
};
|
||||
|
||||
return Object.assign(baseData, extendData);
|
||||
}
|
||||
|
||||
export class ArmorData extends ItemData {
|
||||
static defineSchema = defineSchema;
|
||||
}
|
||||
@@ -0,0 +1,380 @@
|
||||
function defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return {
|
||||
locked: new fields.BooleanField({ initial: false }),
|
||||
biographie: new fields.SchemaField({
|
||||
mondgestalt: new fields.StringField({ initial: "" }),
|
||||
abenteuertyp: new fields.StringField({ initial: "" }),
|
||||
glaube: new fields.StringField({ initial: "" }),
|
||||
spezies: new fields.StringField({ initial: "" }),
|
||||
kultur: new fields.StringField({ initial: "" }),
|
||||
beschreibung: new fields.HTMLField({ initial: "" })
|
||||
}),
|
||||
legende: new fields.HTMLField({ initial: "" }),
|
||||
schicksalsmünzen: new fields.NumberField({ initital: 3, min: 0, required: true }),
|
||||
grad: new fields.SchemaField({
|
||||
erfahrungspunkteFrei: new fields.NumberField({
|
||||
required: true,
|
||||
min: 0,
|
||||
initial: 0
|
||||
}),
|
||||
erfahrungspunkteEingesetzt: new fields.NumberField({
|
||||
required: true,
|
||||
min: 0,
|
||||
initial: 0
|
||||
}),
|
||||
erfahrungsschatz: new fields.NumberField({
|
||||
required: true,
|
||||
min: 0,
|
||||
initial: 0
|
||||
}),
|
||||
grad: new fields.NumberField({
|
||||
required: true,
|
||||
min: 1,
|
||||
initial: 1
|
||||
})
|
||||
}),
|
||||
rüstwert: new fields.SchemaField({
|
||||
base: new fields.NumberField({
|
||||
required: true,
|
||||
min: 0,
|
||||
initial: 0
|
||||
}),
|
||||
mod: new fields.NumberField({
|
||||
required: true,
|
||||
initial: 0
|
||||
})
|
||||
}),
|
||||
resources: new fields.SchemaField({
|
||||
leben: new fields.SchemaField({
|
||||
value: new fields.NumberField({
|
||||
required: true,
|
||||
min: 0,
|
||||
initial: 4
|
||||
}),
|
||||
max: new fields.NumberField({
|
||||
required: true,
|
||||
initial: 8
|
||||
})
|
||||
}),
|
||||
ausdauer: new fields.SchemaField({
|
||||
value: new fields.NumberField({
|
||||
required: true,
|
||||
min: 0,
|
||||
initial: 4
|
||||
}),
|
||||
max: new fields.NumberField({
|
||||
required: true,
|
||||
initial: 44
|
||||
})
|
||||
})
|
||||
}),
|
||||
resistenzen: new fields.SchemaField(
|
||||
{
|
||||
reflexe: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
min: 0,
|
||||
initial: 4
|
||||
}),
|
||||
willenskraft: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
min: 0,
|
||||
initial: 4
|
||||
}),
|
||||
zähigkeit: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
min: 0,
|
||||
initial: 4
|
||||
})
|
||||
},
|
||||
{ label: "resistenzen" }
|
||||
),
|
||||
skills: new fields.SchemaField({
|
||||
kampf: new fields.SchemaField(
|
||||
{
|
||||
anführen: new fields.SchemaField({
|
||||
value: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5,
|
||||
label: "anführen"
|
||||
}),
|
||||
bonuses: new fields.ArrayField(new fields.ObjectField())
|
||||
}),
|
||||
fernkampf: new fields.SchemaField({
|
||||
value: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5,
|
||||
label: "fernkampf"
|
||||
}),
|
||||
bonuses: new fields.ArrayField(new fields.ObjectField())
|
||||
}),
|
||||
nahkampf: new fields.SchemaField({
|
||||
value: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5,
|
||||
label: "nahkampf"
|
||||
}),
|
||||
bonuses: new fields.ArrayField(new fields.ObjectField())
|
||||
})
|
||||
},
|
||||
{ label: "kampf" }
|
||||
),
|
||||
körper: new fields.SchemaField(
|
||||
{
|
||||
athletik: new fields.SchemaField({
|
||||
value: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5,
|
||||
label: "athletik"
|
||||
}),
|
||||
bonuses: new fields.ArrayField(new fields.ObjectField())
|
||||
}),
|
||||
beweglichkeit: new fields.SchemaField({
|
||||
value: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5,
|
||||
label: "beweglichkeit"
|
||||
}),
|
||||
bonuses: new fields.ArrayField(new fields.ObjectField())
|
||||
}),
|
||||
fingerfertigkeit: new fields.SchemaField({
|
||||
value: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5,
|
||||
label: "fingerfertigkeit"
|
||||
}),
|
||||
bonuses: new fields.ArrayField(new fields.ObjectField())
|
||||
}),
|
||||
heimlichkeit: new fields.SchemaField({
|
||||
value: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5,
|
||||
label: "heimlichkeit"
|
||||
}),
|
||||
bonuses: new fields.ArrayField(new fields.ObjectField())
|
||||
}),
|
||||
wahrnehmung: new fields.SchemaField({
|
||||
value: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5,
|
||||
label: "wahrnehmung"
|
||||
}),
|
||||
bonuses: new fields.ArrayField(new fields.ObjectField())
|
||||
})
|
||||
},
|
||||
{ label: "körper" }
|
||||
),
|
||||
ausdruck: new fields.SchemaField(
|
||||
{
|
||||
darbietung: new fields.SchemaField({
|
||||
value: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5,
|
||||
label: "darbietung"
|
||||
}),
|
||||
bonuses: new fields.ArrayField(new fields.ObjectField())
|
||||
}),
|
||||
einschüchterung: new fields.SchemaField({
|
||||
value: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5,
|
||||
label: "einschüchterung"
|
||||
}),
|
||||
bonuses: new fields.ArrayField(new fields.ObjectField())
|
||||
}),
|
||||
empathie: new fields.SchemaField({
|
||||
value: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5,
|
||||
label: "empathie"
|
||||
}),
|
||||
bonuses: new fields.ArrayField(new fields.ObjectField())
|
||||
}),
|
||||
gassenwissen: new fields.SchemaField({
|
||||
value: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5,
|
||||
label: "gassenwissen"
|
||||
}),
|
||||
bonuses: new fields.ArrayField(new fields.ObjectField())
|
||||
}),
|
||||
manipulation: new fields.SchemaField({
|
||||
value: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5,
|
||||
label: "manipulation"
|
||||
}),
|
||||
bonuses: new fields.ArrayField(new fields.ObjectField())
|
||||
}),
|
||||
überzeugen: new fields.SchemaField({
|
||||
value: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5,
|
||||
label: "überzeugen"
|
||||
}),
|
||||
bonuses: new fields.ArrayField(new fields.ObjectField())
|
||||
})
|
||||
},
|
||||
{ label: "ausdruck" }
|
||||
),
|
||||
geist: new fields.SchemaField(
|
||||
{
|
||||
bildung: new fields.SchemaField({
|
||||
value: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5,
|
||||
label: "bildung"
|
||||
}),
|
||||
bonuses: new fields.ArrayField(new fields.ObjectField())
|
||||
}),
|
||||
handwerk: new fields.SchemaField({
|
||||
value: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5,
|
||||
label: "handwerk"
|
||||
}),
|
||||
bonuses: new fields.ArrayField(new fields.ObjectField())
|
||||
}),
|
||||
heilkunst: new fields.SchemaField({
|
||||
value: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5,
|
||||
label: "heilkunst"
|
||||
}),
|
||||
bonuses: new fields.ArrayField(new fields.ObjectField())
|
||||
}),
|
||||
kulturwissen: new fields.SchemaField({
|
||||
value: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5,
|
||||
label: "kulturwissen"
|
||||
}),
|
||||
bonuses: new fields.ArrayField(new fields.ObjectField())
|
||||
}),
|
||||
tierführung: new fields.SchemaField({
|
||||
value: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5,
|
||||
label: "tierführung"
|
||||
}),
|
||||
bonuses: new fields.ArrayField(new fields.ObjectField())
|
||||
}),
|
||||
überlebenskunst: new fields.SchemaField({
|
||||
value: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5,
|
||||
label: "überlebenskunst"
|
||||
}),
|
||||
bonuses: new fields.ArrayField(new fields.ObjectField())
|
||||
})
|
||||
},
|
||||
{ label: "geist" }
|
||||
),
|
||||
magie: new fields.SchemaField(
|
||||
{
|
||||
thaumaturgie: new fields.SchemaField({
|
||||
value: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5,
|
||||
label: "thaumaturgie"
|
||||
}),
|
||||
bonuses: new fields.ArrayField(new fields.ObjectField())
|
||||
}),
|
||||
zaubern: new fields.SchemaField({
|
||||
value: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5,
|
||||
label: "zaubern"
|
||||
}),
|
||||
bonuses: new fields.ArrayField(new fields.ObjectField())
|
||||
}),
|
||||
zauberwissen: new fields.SchemaField({
|
||||
value: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
max: 15,
|
||||
min: 5,
|
||||
initial: 5,
|
||||
label: "zauberwissen"
|
||||
}),
|
||||
bonuses: new fields.ArrayField(new fields.ObjectField())
|
||||
})
|
||||
},
|
||||
{ label: "magie" }
|
||||
)
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
export class CharacterData extends foundry.abstract.TypeDataModel {
|
||||
static defineSchema = defineSchema;
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
function defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return {
|
||||
biography: new fields.HTMLField({ initial: "" }),
|
||||
attributes: new fields.SchemaField({
|
||||
strength: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
integer: true,
|
||||
initial: 10
|
||||
}),
|
||||
agility: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
integer: true,
|
||||
initial: 10
|
||||
}),
|
||||
spirit: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
integer: true,
|
||||
initial: 10
|
||||
})
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
export class CharacterData extends foundry.abstract.TypeDataModel<
|
||||
ReturnType<typeof defineSchema>,
|
||||
Actor.Implementation
|
||||
> {
|
||||
static defineSchema = defineSchema;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
function defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return {
|
||||
beschreibung: new fields.HTMLField({ initial: "" }),
|
||||
gruppe: new fields.StringField({ initial: "" }),
|
||||
linkId: new fields.StringField({ initial: "" })
|
||||
};
|
||||
}
|
||||
|
||||
export class HintergrundData extends foundry.abstract.TypeDataModel {
|
||||
static defineSchema = defineSchema;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
function defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return {
|
||||
beschreibung: new fields.HTMLField({ initial: "" }),
|
||||
anzahl: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
integer: true,
|
||||
initial: 1,
|
||||
min: 0
|
||||
}),
|
||||
wert: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
integer: true,
|
||||
initial: 1,
|
||||
step: 1,
|
||||
min: 0
|
||||
}),
|
||||
gewicht: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
integer: true,
|
||||
initial: 1,
|
||||
step: 1,
|
||||
min: 0
|
||||
}),
|
||||
merkmale: new fields.ArrayField(new fields.StringField({}), { initial: [] })
|
||||
};
|
||||
}
|
||||
|
||||
export class ItemData extends foundry.abstract.TypeDataModel {
|
||||
static defineSchema = defineSchema;
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
function defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return {
|
||||
description: new fields.HTMLField({ initial: "" }),
|
||||
quantity: new fields.NumberField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
integer: true,
|
||||
initial: 1,
|
||||
min: 0
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
export class ItemData extends foundry.abstract.TypeDataModel<
|
||||
ReturnType<typeof defineSchema>,
|
||||
Item.Implementation
|
||||
> {
|
||||
static defineSchema = defineSchema;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { ItemData } from "./item-data.mjs";
|
||||
|
||||
function defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
const baseData = ItemData.defineSchema();
|
||||
const extendData = {
|
||||
schaden: new fields.StringField({ initial: "1d6" }),
|
||||
equipped: new fields.BooleanField({ inital: false }),
|
||||
fertigkeit: new fields.StringField({ initial: "system.skills.kampf.nahkampf" }),
|
||||
spezialisierung: new fields.StringField({ initial: "" }),
|
||||
customRoll: new fields.StringField({ initial: "" })
|
||||
};
|
||||
|
||||
return Object.assign(baseData, extendData);
|
||||
}
|
||||
|
||||
export class WeaponData extends ItemData {
|
||||
static defineSchema = defineSchema;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
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: 0,
|
||||
min: 0,
|
||||
max: 3
|
||||
}),
|
||||
ursprung: new fields.StringField({ initial: "Kleiner Zauber" }),
|
||||
schaden: new fields.StringField({ initial: "" }),
|
||||
reichweite: new fields.StringField({ initial: "Kurz" }),
|
||||
zauberdauer: new fields.StringField({ initial: "1 Aktion" }),
|
||||
wirkungsdauer: new fields.StringField({ initial: "1 Runde" }),
|
||||
wirkungsweise: new fields.StringField({ initial: "Einfluss" }),
|
||||
ziel: new fields.StringField({ initial: "1 Wesen" }),
|
||||
vorgang: new fields.StringField({ initial: "Geste" })
|
||||
}),
|
||||
equipped: new fields.BooleanField({ initial: false })
|
||||
};
|
||||
}
|
||||
|
||||
export class ZauberData extends foundry.abstract.TypeDataModel {
|
||||
static defineSchema = defineSchema;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
export const loadHelpers = async function () {
|
||||
Handlebars.registerHelper("ifeq", function (arg1, arg2, options) {
|
||||
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 = "") {
|
||||
let arg = arg1;
|
||||
if (typeof arg2 === "string") {
|
||||
arg = arg + "" + arg2;
|
||||
}
|
||||
return foundry.utils.getProperty(actor, arg);
|
||||
});
|
||||
|
||||
Handlebars.registerHelper("isdefined", function (value, options) {
|
||||
return value !== undefined ? options.fn(this) : options.inverse(this);
|
||||
});
|
||||
|
||||
Handlebars.registerHelper("localizeConcat", function (arg1, arg2) {
|
||||
return game.i18n?.localize(arg1 + arg2);
|
||||
});
|
||||
|
||||
Handlebars.registerHelper("splitArray", function (arr) {
|
||||
if (!Array.isArray(arr)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return arr.join(", ");
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
export const loadPartials = async function () {
|
||||
await foundry.applications.handlebars.loadTemplates([
|
||||
"systems/midgard6-lvd/templates/chat/chat-message-header.hbs",
|
||||
"systems/midgard6-lvd/templates/chat/secret-roll.hbs"
|
||||
]);
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
export const loadSettings = async function () {
|
||||
game.settings.register("midgard6-lvd", "zauberAlsTag", {
|
||||
name: game.i18n.localize("Midgard6.Settings.zauberAlsTag.name"),
|
||||
hint: game.i18n.localize("Midgard6.Settings.zauberAlsTag.hint"),
|
||||
scope: "user",
|
||||
config: true,
|
||||
default: false,
|
||||
type: Boolean,
|
||||
requiresReload: true
|
||||
});
|
||||
|
||||
// Automatically collapse chat message descriptions
|
||||
game.settings.register("midgard6-lvd", "beschreibungChatActive", {
|
||||
name: game.i18n.localize("Midgard6.Settings.beschreibungChatActive.name"),
|
||||
hint: game.i18n.localize("Midgard6.Settings.beschreibungChatActive.hint"),
|
||||
scope: "client",
|
||||
config: true,
|
||||
default: false,
|
||||
type: Boolean
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* Searches through an object recursively and localizes strings.
|
||||
* @param {Record<string, unknown>} object
|
||||
*/
|
||||
export function localizeHelper(object) {
|
||||
for (const [key, value] of Object.entries(object)) {
|
||||
// const type = foundry.utils.getType(value)
|
||||
switch (typeof value) {
|
||||
case "object":
|
||||
if (value) localizeHelper(value);
|
||||
break;
|
||||
case "string":
|
||||
if (key === "label") object[key] = game.i18n.localize(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Prepare the data structure for Active Effects which are currently embedded in an Actor or Item.
|
||||
* @param {ActiveEffect[]} effects A collection or generator of Active Effect documents to prepare sheet data for.
|
||||
* @return {object} Data for rendering.
|
||||
*/
|
||||
export function prepareActiveEffectCategories(effects) {
|
||||
const categories = {
|
||||
temporary: {
|
||||
type: "temporary",
|
||||
label: game.i18n.localize("M6.Effect.Temporary"),
|
||||
effects: []
|
||||
},
|
||||
passive: {
|
||||
type: "passive",
|
||||
label: game.i18n.localize("M6.Effect.Passive"),
|
||||
effects: []
|
||||
},
|
||||
inactive: {
|
||||
type: "inactive",
|
||||
label: game.i18n.localize("M6.Effect.Inactive"),
|
||||
effects: []
|
||||
}
|
||||
};
|
||||
|
||||
// Iterate over active effects, classifying them into categories
|
||||
for (const e of effects) {
|
||||
if (!e.active) categories.inactive.effects.push(e);
|
||||
else if (e.isTemporary) categories.temporary.effects.push(e);
|
||||
else categories.passive.effects.push(e);
|
||||
}
|
||||
|
||||
// Sort each category
|
||||
for (const c of Object.values(categories)) {
|
||||
c.effects.sort((a, b) => (a.sort || 0) - (b.sort || 0));
|
||||
}
|
||||
return categories;
|
||||
}
|
||||
File renamed without changes.
@@ -0,0 +1,79 @@
|
||||
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 M6ArmorSheet 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
|
||||
cycleHelmet: this.#cycleHelmet
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
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() {
|
||||
this.item.update({
|
||||
system: {
|
||||
equipped: !this.item.system.equipped
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static #cycleHelmet() {
|
||||
this.item.update({
|
||||
system: {
|
||||
zusätzlich: !this.item.system.zusätzlich
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,829 @@
|
||||
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";
|
||||
import { rollSpell, rollWeapon, rollSkill } from "./components/roll-actions.mjs";
|
||||
|
||||
const { api, sheets } = foundry.applications;
|
||||
|
||||
/**
|
||||
* Extend the basic ActorSheet with some very simple modifications.
|
||||
*/
|
||||
export class M6ActorSheet extends api.HandlebarsApplicationMixin(sheets.ActorSheetV2) {
|
||||
/** @inheritdoc */
|
||||
static DEFAULT_OPTIONS = {
|
||||
classes: ["M6", "actor"],
|
||||
window: {
|
||||
resizable: true
|
||||
},
|
||||
position: {
|
||||
width: 800,
|
||||
height: 800
|
||||
},
|
||||
actions: {
|
||||
viewDoc: this.#viewDoc,
|
||||
createDoc: this.#createDoc,
|
||||
deleteDoc: this.#deleteDoc,
|
||||
toggleEffect: this.#toggleEffect,
|
||||
rollSkill: rollSkill,
|
||||
rollWeapon: rollWeapon,
|
||||
rollSpell: rollSpell,
|
||||
cycleEquip: this.#cycleEquip,
|
||||
cycleLock: this.#cycleLock,
|
||||
addSpezialisierung: addSpezialisierung,
|
||||
editSepzialisierung: editSepzialisierung,
|
||||
increaseDoc: this.#increaseDoc,
|
||||
decreaseDoc: this.#decreaseDoc
|
||||
},
|
||||
form: {
|
||||
submitOnChange: true
|
||||
},
|
||||
dragDrop: [{ dragSelector: ".draggable", dropSelector: null }]
|
||||
};
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
static TABS = {
|
||||
primary: {
|
||||
tabs: [
|
||||
{
|
||||
id: "eigenschaften",
|
||||
icon: "fa-shield-halved"
|
||||
},
|
||||
|
||||
{
|
||||
id: "items",
|
||||
icon: "fa-suitcase"
|
||||
},
|
||||
{
|
||||
id: "zauber",
|
||||
icon: "fa-hand-sparkles"
|
||||
},
|
||||
{
|
||||
id: "hintergrund",
|
||||
icon: "fa-list"
|
||||
},
|
||||
{
|
||||
id: "biographie",
|
||||
icon: "fa-feather-pointed"
|
||||
},
|
||||
{
|
||||
id: "effects",
|
||||
icon: "fa-bolt"
|
||||
}
|
||||
],
|
||||
initial: "eigenschaften",
|
||||
labelPrefix: "Midgard6.Sheets.Tabs"
|
||||
}
|
||||
};
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/** @inheritdoc */
|
||||
static PARTS = {
|
||||
tabs: {
|
||||
template: systemPath("templates/shared/tabs.hbs")
|
||||
},
|
||||
header: {
|
||||
template: systemPath("templates/actor/header.hbs")
|
||||
},
|
||||
eigenschaften: {
|
||||
template: systemPath("templates/actor/eigenschaften.hbs"),
|
||||
scrollable: [""]
|
||||
},
|
||||
zauber: {
|
||||
template: systemPath("templates/actor/zauber.hbs"),
|
||||
scrollable: [""]
|
||||
},
|
||||
items: {
|
||||
template: systemPath("templates/actor/items.hbs"),
|
||||
scrollable: [""]
|
||||
},
|
||||
hintergrund: {
|
||||
template: systemPath("templates/actor/hintergrund.hbs"),
|
||||
scrollable: [""]
|
||||
},
|
||||
biographie: {
|
||||
template: systemPath("templates/actor/biographie.hbs"),
|
||||
scrollable: [""]
|
||||
},
|
||||
effects: {
|
||||
template: systemPath("templates/shared/effects.hbs"),
|
||||
scrollable: [""]
|
||||
}
|
||||
};
|
||||
|
||||
_attachPartListeners(partId, html, bubble) {
|
||||
super._attachPartListeners(partId, html, bubble);
|
||||
|
||||
switch (partId) {
|
||||
case "hintergrund":
|
||||
const collapsible = html.querySelectorAll("div[data-action=collapsible]");
|
||||
if (collapsible) {
|
||||
collapsible.forEach((node) => {
|
||||
node.addEventListener(
|
||||
"click",
|
||||
function () {
|
||||
node.classList.toggle("active");
|
||||
var content = node.nextElementSibling;
|
||||
content.classList.toggle("active");
|
||||
node.getElementsByTagName("i")[0].classList.toggle("fa-compress");
|
||||
},
|
||||
{ capture: true }
|
||||
);
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/** @inheritdoc */
|
||||
_initializeApplicationOptions(options) {
|
||||
const initialized = super._initializeApplicationOptions(options);
|
||||
|
||||
initialized.classes.push(initialized.document.type);
|
||||
|
||||
return initialized;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/** @inheritdoc */
|
||||
async _prepareContext(options) {
|
||||
const context = await super._prepareContext(options);
|
||||
|
||||
Object.assign(context, {
|
||||
owner: this.document.isOwner,
|
||||
limited: this.document.limited,
|
||||
actor: this.actor,
|
||||
system: this.actor.system,
|
||||
skills: this.actor.system.skills,
|
||||
flags: this.actor.flags,
|
||||
config: CONFIG
|
||||
});
|
||||
console.warn(context);
|
||||
return context;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/** @inheritdoc */
|
||||
async _preparePartContext(partId, context) {
|
||||
switch (partId) {
|
||||
case "effects":
|
||||
context.effects = prepareActiveEffectCategories(this.actor.allApplicableEffects());
|
||||
context.tab = context.tabs[partId];
|
||||
break;
|
||||
case "eigenschaften":
|
||||
context.armor = await prepArmor(this.actor);
|
||||
context.skills = await this._getSkills();
|
||||
context.resistenzen = await this._getResistenzen();
|
||||
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 = await prepWeight(this.actor);
|
||||
context.tab = context.tabs[partId];
|
||||
break;
|
||||
case "zauber":
|
||||
context.zauber = await this._getZauber();
|
||||
context.tab = context.tabs[partId];
|
||||
break;
|
||||
case "hintergrund":
|
||||
context.fields = await this._getFields();
|
||||
context.tab = context.tabs[partId];
|
||||
break;
|
||||
case "biographie":
|
||||
context.enrichedBeschreibung =
|
||||
await foundry.applications.ux.TextEditor.implementation.enrichHTML(
|
||||
this.actor.system.biographie.beschreibung,
|
||||
{
|
||||
// Whether to show secret blocks in the finished html
|
||||
secrets: this.document.isOwner,
|
||||
// Data to fill in for inline rolls
|
||||
rollData: this.actor.getRollData(),
|
||||
// Relative UUID resolution
|
||||
relativeTo: this.actor
|
||||
}
|
||||
);
|
||||
context.tab = context.tabs[partId];
|
||||
break;
|
||||
default:
|
||||
context.tab = context.tabs[partId];
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the system fields for the form-fields generic.
|
||||
* @returns {object[]}
|
||||
*/
|
||||
async _getFields() {
|
||||
const doc = this.actor;
|
||||
const source = doc._source;
|
||||
const systemFields = CONFIG.Actor.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.push(fieldset);
|
||||
} else {
|
||||
fieldSets.push({ outer: { field, value: foundry.utils.getProperty(source, path) } });
|
||||
}
|
||||
}
|
||||
return fieldSets;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
async _getSkills() {
|
||||
const doc = this.actor;
|
||||
const source = doc._source;
|
||||
const systemFields = CONFIG.Actor.dataModels[doc.type]?.schema.fields.skills.fields;
|
||||
const fieldSets = [];
|
||||
// TODO: Find a clever way to handle enrichment
|
||||
for (const field of Object.values(systemFields ?? {})) {
|
||||
const path = `system.skills.${field.name}`;
|
||||
if (field instanceof foundry.data.fields.SchemaField) {
|
||||
const fieldset = {
|
||||
fieldset: true,
|
||||
legend: `Midgard6.Skills.gruppen.${field.label}`,
|
||||
fields: []
|
||||
};
|
||||
await this.#addSkillFields(fieldset, field.fields, source, path);
|
||||
fieldSets.push(fieldset);
|
||||
} else {
|
||||
fieldSets.push({ outer: { field, value: foundry.utils.getProperty(source, path) } });
|
||||
}
|
||||
}
|
||||
return fieldSets;
|
||||
}
|
||||
|
||||
async #addSkillFields(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.#addSkillFields(fieldset, field.fields, source, path);
|
||||
} else if (field.constructor.hasFormSupport) {
|
||||
fieldset.fields.push({
|
||||
field,
|
||||
value: foundry.utils.getProperty(source, path),
|
||||
localizationName: "Midgard6.Skills." + field.label,
|
||||
bonuses: foundry.utils.getProperty(source, _path).bonuses
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
async _getResistenzen() {
|
||||
const doc = this.actor;
|
||||
const source = doc._source;
|
||||
const systemFields = CONFIG.Actor.dataModels[doc.type]?.schema.fields.resistenzen;
|
||||
const fieldset = {
|
||||
fieldset: true,
|
||||
legend: `Midgard6.Attribute.${systemFields.label}`,
|
||||
fields: []
|
||||
};
|
||||
for (const field of Object.values(systemFields.fields ?? {})) {
|
||||
const path = `system.resistenzen.${field.name}`;
|
||||
fieldset.fields.push({
|
||||
field,
|
||||
value: foundry.utils.getProperty(source, path),
|
||||
localizationName: "Midgard6.Resistenzen." + field.name
|
||||
});
|
||||
}
|
||||
return fieldset;
|
||||
}
|
||||
|
||||
async _getResources() {
|
||||
const doc = this.actor;
|
||||
const source = doc._source;
|
||||
const systemFields = CONFIG.Actor.dataModels[doc.type]?.schema.fields.resources.fields;
|
||||
const fieldSets = [];
|
||||
// TODO: Find a clever way to handle enrichment
|
||||
for (const field of Object.values(systemFields ?? {})) {
|
||||
const path = `system.skills.${field.name}`;
|
||||
if (field instanceof foundry.data.fields.SchemaField) {
|
||||
const fieldset = {
|
||||
fieldset: true,
|
||||
legend: `Midgard6.resources.${field.label}`,
|
||||
fields: []
|
||||
};
|
||||
await this.#addSystemFields(fieldset, field.fields, source, path);
|
||||
fieldSets.push(fieldset);
|
||||
} else {
|
||||
fieldSets.push({ outer: { field, value: foundry.utils.getProperty(source, path) } });
|
||||
}
|
||||
}
|
||||
return fieldSets;
|
||||
}
|
||||
|
||||
static async #cycleEquip(event, target) {
|
||||
const item = this.actor.items.get(target.dataset.itemId);
|
||||
item.update({
|
||||
system: {
|
||||
equipped: !item.system.equipped
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static async #cycleLock(event) {
|
||||
const actor = this.actor;
|
||||
|
||||
// Update the locked state
|
||||
actor.update({ "system.locked": !actor.system.locked });
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* 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.push({
|
||||
field,
|
||||
value: foundry.utils.getProperty(source, path),
|
||||
localizationName: "Midgard6.Skills." + field.label
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Adapted from Actor#itemTypes.
|
||||
*/
|
||||
_getItems() {
|
||||
const types = Object.fromEntries(
|
||||
game.documentTypes.Item.map((t) => {
|
||||
return [t, { label: game.i18n.localize(CONFIG.Item.typeLabels[t]), items: [] }];
|
||||
})
|
||||
);
|
||||
for (const item of this.actor.items) {
|
||||
types[item.type].items.push(item);
|
||||
}
|
||||
|
||||
for (const item of this.actor.items) {
|
||||
types[item.type].items.sort((a, b) => a.sort - b.sort);
|
||||
}
|
||||
// Only show Base if it's actually being used
|
||||
if (types.base.items.length === 0) delete types.base;
|
||||
return types;
|
||||
}
|
||||
|
||||
_getZauber() {
|
||||
return this.actor.items.filter((item) => item.type === "zauber");
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Actions performed after any render of the Application.
|
||||
* Post-render steps are not awaited by the render process.
|
||||
* @param {ApplicationRenderContext} context Prepared context data.
|
||||
* @param {RenderOptions} options Provided render options.
|
||||
* @protected
|
||||
* @inheritdoc
|
||||
*/
|
||||
async _onRender(context, options) {
|
||||
await super._onRender(context, options);
|
||||
this.#disableOverrides();
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
/* Event handlers */
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
static async #increaseDoc(event, target) {
|
||||
const item = this.actor.items.get(target.dataset.itemId);
|
||||
if (event.shiftKey || event.ctrlKey) {
|
||||
return item.update({ ["system.anzahl"]: (item.system.anzahl += 10) });
|
||||
}
|
||||
return item.update({ ["system.anzahl"]: (item.system.anzahl += 1) });
|
||||
}
|
||||
|
||||
static async #decreaseDoc(event, target) {
|
||||
const item = this.actor.items.get(target.dataset.itemId);
|
||||
if (event.shiftKey || event.ctrlKey) {
|
||||
return item.update({ ["system.anzahl"]: (item.system.anzahl -= 10) });
|
||||
}
|
||||
return item.update({ ["system.anzahl"]: (item.system.anzahl -= 1) });
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders an embedded document's sheet.
|
||||
*
|
||||
* @this M6ActorSheet
|
||||
* @param {PointerEvent} event The originating click event.
|
||||
* @param {HTMLElement} target The capturing HTML element which defined a [data-action].
|
||||
* @protected
|
||||
*/
|
||||
static async #viewDoc(event, target) {
|
||||
const doc = this._getEmbeddedDocument(target);
|
||||
doc.sheet.render(true);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Handles item deletion.
|
||||
*
|
||||
* @this M6ActorSheet
|
||||
* @param {PointerEvent} event The originating click event.
|
||||
* @param {HTMLElement} target The capturing HTML element which defined a [data-action].
|
||||
* @protected
|
||||
*/
|
||||
static async #deleteDoc(event, target) {
|
||||
const doc = this._getEmbeddedDocument(target);
|
||||
doc.delete();
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Handle creating a new Owned Item or ActiveEffect for the actor using initial data defined in the HTML dataset.
|
||||
*
|
||||
* @this M6ActorSheet
|
||||
* @param {PointerEvent} event The originating click event.
|
||||
* @param {HTMLElement} target The capturing HTML element which defined a [data-action].
|
||||
* @private
|
||||
*/
|
||||
static async #createDoc(event, target) {
|
||||
const docCls = getDocumentClass(target.dataset.documentClass);
|
||||
const docData = {
|
||||
name: docCls.defaultName({
|
||||
type: target.dataset.type,
|
||||
parent: this.actor
|
||||
})
|
||||
};
|
||||
for (const [dataKey, value] of Object.entries(target.dataset)) {
|
||||
if (["action", "documentClass"].includes(dataKey)) continue;
|
||||
foundry.utils.setProperty(docData, dataKey, value);
|
||||
}
|
||||
docCls.create(docData, { parent: this.actor });
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Determines effect parent to pass to helper.
|
||||
*
|
||||
* @this M6ActorSheet
|
||||
* @param {PointerEvent} event The originating click event.
|
||||
* @param {HTMLElement} target The capturing HTML element which defined a [data-action].
|
||||
* @private
|
||||
*/
|
||||
static async #toggleEffect(event, target) {
|
||||
const effect = this._getEmbeddedDocument(target);
|
||||
effect.update({ disabled: !effect.disabled });
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
/* Helper functions */
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Fetches the embedded document representing the containing HTML element.
|
||||
*
|
||||
* @param {HTMLElement} target The element subject to search.
|
||||
* @returns {Item|ActiveEffect} The embedded Item or ActiveEffect.
|
||||
*/
|
||||
_getEmbeddedDocument(target) {
|
||||
const docRow = target.closest("[data-document-class]");
|
||||
if (docRow.dataset.documentClass === "Item") {
|
||||
return this.actor.items.get(docRow.dataset.itemId);
|
||||
} else if (docRow.dataset.documentClass === "ActiveEffect") {
|
||||
const parent =
|
||||
docRow.dataset.parentId === this.actor.id
|
||||
? this.actor
|
||||
: this.actor.items.get(docRow?.dataset.parentId);
|
||||
return parent.effects.get(docRow.dataset.effectId);
|
||||
} else {
|
||||
console.warn("Could not find document class");
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
/* Actor override handling */
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Submit a document update based on the processed form data.
|
||||
* @param {SubmitEvent} event The originating form submission event.
|
||||
* @param {HTMLFormElement} form The form element that was submitted.
|
||||
* @param {object} submitData Processed and validated form data to be used for a document update.
|
||||
* @returns {Promise<void>}
|
||||
* @protected
|
||||
* @inheritdoc
|
||||
*/
|
||||
async _processSubmitData(event, form, submitData) {
|
||||
const overrides = foundry.utils.flattenObject(this.actor.overrides);
|
||||
for (const k of Object.keys(overrides)) delete submitData[k];
|
||||
this.document.update(submitData);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Disables inputs subject to active effects.
|
||||
*/
|
||||
#disableOverrides() {
|
||||
const flatOverrides = foundry.utils.flattenObject(this.actor.overrides);
|
||||
for (const override of Object.keys(flatOverrides)) {
|
||||
const input = this.element.querySelector(`[name="${override}"]`);
|
||||
if (input) input.disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
/* Drag and drop */
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Define whether a user is able to begin a dragstart workflow for a given drag selector.
|
||||
* @param {string} selector The candidate HTML selector for dragging.
|
||||
* @returns {boolean} Can the current user drag this selector?
|
||||
* @protected
|
||||
*/
|
||||
_canDragStart(selector) {
|
||||
return this.isEditable;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Define whether a user is able to conclude a drag-and-drop workflow for a given drop selector.
|
||||
* @param {string} selector The candidate HTML selector for the drop target.
|
||||
* @returns {boolean} Can the current user drop on this selector?
|
||||
* @protected
|
||||
*/
|
||||
_canDragDrop(selector) {
|
||||
return this.isEditable;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Callback actions which occur at the beginning of a drag start workflow.
|
||||
* @param {DragEvent} event The originating DragEvent.
|
||||
* @protected
|
||||
*/
|
||||
_onDragStart(event) {
|
||||
const li = event.currentTarget;
|
||||
const dataset = event.target.dataset;
|
||||
|
||||
if ("link" in event.target.dataset) return;
|
||||
|
||||
let dragData = null;
|
||||
|
||||
if (li.dataset.effectId) {
|
||||
const effect = this.item.effects.get(li.dataset.effectId);
|
||||
dragData = effect.toDragData();
|
||||
}
|
||||
|
||||
dragData = {
|
||||
type: dataset.type,
|
||||
itemId: dataset.itemId
|
||||
};
|
||||
|
||||
if (!dragData) return;
|
||||
|
||||
event.dataTransfer.setData("text/plain", JSON.stringify(dragData));
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Callback actions which occur when a dragged element is over a drop target.
|
||||
* @param {DragEvent} event The originating DragEvent.
|
||||
* @protected
|
||||
*/
|
||||
_onDragOver(event) {}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Callback actions which occur when a dragged element is dropped on a target.
|
||||
* @param {DragEvent} event The originating DragEvent.
|
||||
* @protected
|
||||
*/
|
||||
async _onDrop(event) {
|
||||
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event);
|
||||
const item = this.item;
|
||||
|
||||
const allowed = Hooks.call("dropItemSheetData", item, this, data);
|
||||
if (allowed === false) return;
|
||||
// Handle different data types
|
||||
switch (data.type) {
|
||||
case "ActiveEffect":
|
||||
return this._onDropActiveEffect(event, data);
|
||||
case "Actor":
|
||||
return this._onDropActor(event, data);
|
||||
case "Item":
|
||||
return this._onDropItem(event, data);
|
||||
case "Folder":
|
||||
return this._onDropFolder(event, data);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Handle the dropping of ActiveEffect data onto an Actor Sheet.
|
||||
* @param {DragEvent} event The concluding DragEvent which contains drop data.
|
||||
* @param {object} data The data transfer extracted from the event.
|
||||
* @returns {Promise<ActiveEffect|boolean>} The created ActiveEffect object or false if it couldn't be created.
|
||||
* @protected
|
||||
*/
|
||||
async _onDropActiveEffect(event, data) {
|
||||
const aeCls = getDocumentClass("ActiveEffect");
|
||||
const effect = await aeCls.fromDropData(data);
|
||||
if (!this.item.isOwner || !effect) return false;
|
||||
|
||||
if (this.item.uuid === effect.parent?.uuid) return this._onEffectSort(event, effect);
|
||||
aeCls.create(effect, { parent: this.item });
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Sorts an Active Effect based on its surrounding attributes.
|
||||
*
|
||||
* @param {DragEvent} event
|
||||
* @param {ActiveEffect} effect
|
||||
*/
|
||||
_onEffectSort(event, effect) {
|
||||
const effects = this.item.effects;
|
||||
const dropTarget = event.target.closest("[data-effect-id]");
|
||||
if (!dropTarget) return;
|
||||
const target = effects.get(dropTarget.dataset.effectId);
|
||||
|
||||
// Don't sort on yourself
|
||||
if (effect.id === target.id) return;
|
||||
|
||||
// Identify sibling items based on adjacent HTML elements
|
||||
const siblings = [];
|
||||
for (let el of dropTarget.parentElement.children) {
|
||||
const siblingId = el.dataset.effectId;
|
||||
if (siblingId && siblingId !== effect.id) siblings.push(effects.get(el.dataset.effectId));
|
||||
}
|
||||
|
||||
// Perform the sort
|
||||
const sortUpdates = foundry.utils.performIntegerSort(effect, {
|
||||
target,
|
||||
siblings
|
||||
});
|
||||
const updateData = sortUpdates.map((u) => {
|
||||
const update = u.update;
|
||||
update._id = u.target._id;
|
||||
return update;
|
||||
});
|
||||
|
||||
// Perform the update
|
||||
this.item.updateEmbeddedDocuments("ActiveEffect", updateData);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Handle dropping of an Actor data onto another Actor sheet.
|
||||
* @param {DragEvent} event The concluding DragEvent which contains drop data.
|
||||
* @param {object} data The data transfer extracted from the event.
|
||||
* @returns {Promise<object|boolean>} A data object which describes the result of the drop, or false if the drop was
|
||||
* not permitted.
|
||||
* @protected
|
||||
*/
|
||||
async _onDropActor(event, data) {
|
||||
if (!this.item.isOwner) return false;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
async _onDropItemCreate(actor, itemData) {
|
||||
itemData = itemData instanceof Array ? itemData : [itemData];
|
||||
return actor.createEmbeddedDocuments("Item", itemData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle dropping of an item reference or item data onto an Actor Sheet.
|
||||
* @param {DragEvent} event The concluding DragEvent which contains drop data.
|
||||
* @param {object} data The data transfer extracted from the event.
|
||||
* @returns {Promise<Item[]|boolean>} The created or updated Item instances, or false if the drop was not permitted.
|
||||
* @protected
|
||||
*/
|
||||
async _onDropItem(event, data) {
|
||||
if (!this.actor.isOwner) return false;
|
||||
|
||||
if (this.actor.items.get(data.itemId)) return this._onSortItem(event, data);
|
||||
|
||||
const item = await Item.implementation.fromDropData(data);
|
||||
const itemData = item.toObject();
|
||||
|
||||
return this._onDropItemCreate(this.actor, itemData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a drop event for an existing embedded Item to sort that Item relative to its siblings
|
||||
* @param {Event} event
|
||||
* @param {Item} item
|
||||
* @private
|
||||
*/
|
||||
_onSortItem(event, item) {
|
||||
// Get the drag source and drop target
|
||||
const items = this.actor.items;
|
||||
const dropTarget = event.target.closest("[data-item-id]");
|
||||
const source = items.get(item.itemId);
|
||||
if (!dropTarget) return;
|
||||
const target = items.get(dropTarget.dataset.itemId);
|
||||
// Don't sort on yourself
|
||||
if (source.id === target.id) return;
|
||||
// Identify sibling items based on adjacent HTML elements
|
||||
const siblings = [];
|
||||
for (let el of dropTarget.parentElement.children) {
|
||||
const siblingId = el.dataset.itemId;
|
||||
if (siblingId && siblingId !== source.id) siblings.push(items.get(siblingId));
|
||||
}
|
||||
|
||||
// Perform the sort
|
||||
const sortUpdates = foundry.utils.performIntegerSort(source, {
|
||||
target,
|
||||
siblings
|
||||
});
|
||||
const updateData = sortUpdates.map((u) => {
|
||||
const update = u.update;
|
||||
update._id = u.target.id;
|
||||
return update;
|
||||
});
|
||||
|
||||
// Perform the update
|
||||
return this.actor.updateEmbeddedDocuments("Item", updateData);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Handle dropping of a Folder on an Actor Sheet.
|
||||
* The core sheet currently supports dropping a Folder of Items to create all items as owned items.
|
||||
* @param {DragEvent} event The concluding DragEvent which contains drop data.
|
||||
* @param {object} data The data transfer extracted from the event.
|
||||
* @returns {Promise<Item[]>}
|
||||
* @protected
|
||||
*/
|
||||
async _onDropFolder(event, data) {
|
||||
if (!this.item.isOwner) return [];
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
/* The following pieces set up drag */
|
||||
/* handling and are unlikely to need modification */
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
// This is marked as private because there's no real need
|
||||
// for subclasses or external hooks to mess with it directly
|
||||
#dragDrop = this.#createDragDropHandlers();
|
||||
|
||||
/**
|
||||
* Returns an array of DragDrop instances.
|
||||
* @type {DragDrop[]}
|
||||
*/
|
||||
get dragDrop() {
|
||||
return this.#dragDrop;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Create drag-and-drop workflow handlers for this Application.
|
||||
* @returns {DragDrop[]} An array of DragDrop handlers.
|
||||
* @private
|
||||
*/
|
||||
#createDragDropHandlers() {
|
||||
return this.options.dragDrop.map((d) => {
|
||||
d.permissions = {
|
||||
dragstart: this._canDragStart.bind(this),
|
||||
drop: this._canDragDrop.bind(this)
|
||||
};
|
||||
d.callbacks = {
|
||||
dragstart: this._onDragStart.bind(this),
|
||||
dragover: this._onDragOver.bind(this),
|
||||
drop: this._onDrop.bind(this)
|
||||
};
|
||||
return new foundry.applications.ux.DragDrop(d);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
import React from "react";
|
||||
import { createRoot, type Root } from "react-dom/client";
|
||||
import { CharacterSheetApp } from "./components/CharacterSheetApp";
|
||||
|
||||
export class CharacterSheet extends foundry.applications.sheets.ActorSheetV2 {
|
||||
static DEFAULT_OPTIONS = {
|
||||
classes: ["fvtt-ts-react-boilerplate", "sheet", "actor"],
|
||||
position: { width: 600, height: 480 }
|
||||
};
|
||||
|
||||
#root: Root | null = null;
|
||||
|
||||
override async _renderHTML(
|
||||
...args: Parameters<foundry.applications.sheets.ActorSheetV2["_renderHTML"]>
|
||||
) {
|
||||
return args[0];
|
||||
}
|
||||
|
||||
override _replaceHTML(
|
||||
...args: Parameters<foundry.applications.sheets.ActorSheetV2["_replaceHTML"]>
|
||||
) {
|
||||
const content = args[1];
|
||||
if (!this.#root) this.#root = createRoot(content);
|
||||
this.#root.render(React.createElement(CharacterSheetApp, { actor: this.document }));
|
||||
}
|
||||
|
||||
override async close(...args: Parameters<foundry.applications.sheets.ActorSheetV2["close"]>) {
|
||||
this.#root?.unmount();
|
||||
this.#root = null;
|
||||
return super.close(...args);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { fmtMod, modifier } from "./CharacterSheetApp.logic";
|
||||
|
||||
describe("modifier", () => {
|
||||
it("matches the d20-style table around the 10 baseline", () => {
|
||||
expect(modifier(10)).toBe(0);
|
||||
expect(modifier(11)).toBe(0);
|
||||
expect(modifier(12)).toBe(1);
|
||||
expect(modifier(9)).toBe(-1);
|
||||
expect(modifier(20)).toBe(5);
|
||||
});
|
||||
});
|
||||
|
||||
describe("fmtMod", () => {
|
||||
it("prefixes non-negative values with +", () => {
|
||||
expect(fmtMod(0)).toBe("+0");
|
||||
expect(fmtMod(3)).toBe("+3");
|
||||
});
|
||||
|
||||
it("leaves negative values as-is", () => {
|
||||
expect(fmtMod(-2)).toBe("-2");
|
||||
});
|
||||
});
|
||||
@@ -1,6 +0,0 @@
|
||||
// Pure game-logic helpers, deliberately kept free of any Foundry global.
|
||||
// Code that touches `actor`/`ChatMessage`/etc. needs a running Foundry instance
|
||||
// and isn't realistically unit-testable — this is the boundary to keep that out.
|
||||
export const modifier = (score: number) => Math.floor((score - 10) / 2);
|
||||
|
||||
export const fmtMod = (mod: number) => (mod >= 0 ? `+${mod}` : `${mod}`);
|
||||
@@ -1,38 +0,0 @@
|
||||
.sheet {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
|
||||
.attributes {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.attributeLabel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
font-size: 0.8rem;
|
||||
text-transform: capitalize;
|
||||
|
||||
.modifier {
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
.totals {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.chatRow {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
|
||||
input {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
import React, { useState } from "react";
|
||||
import styles from "./CharacterSheetApp.module.scss";
|
||||
import { localize } from "../../i18n";
|
||||
import { modifier, fmtMod } from "./CharacterSheetApp.logic";
|
||||
|
||||
export function CharacterSheetApp({ actor }: { actor: Actor.Implementation }) {
|
||||
const system = actor.system;
|
||||
const attrs = system.attributes;
|
||||
const [chatMessage, setChatMessage] = useState("");
|
||||
|
||||
const updateAttribute = (key: "strength" | "agility" | "spirit", value: number) => {
|
||||
actor.update({ system: { attributes: { [key]: value } } });
|
||||
};
|
||||
|
||||
const updateBiography = (value: string) => {
|
||||
actor.update({ system: { biography: value } });
|
||||
};
|
||||
|
||||
const sendChatMessage = () => {
|
||||
if (!chatMessage.trim()) return;
|
||||
ChatMessage.create({
|
||||
speaker: ChatMessage.getSpeaker({ actor }),
|
||||
content: chatMessage
|
||||
});
|
||||
setChatMessage("");
|
||||
};
|
||||
|
||||
// derived purely from current doc state — recomputed every render, no local state needed
|
||||
const total = attrs.strength + attrs.agility + attrs.spirit;
|
||||
const totalMod = modifier(attrs.strength) + modifier(attrs.agility) + modifier(attrs.spirit);
|
||||
|
||||
return (
|
||||
<div className={styles.sheet}>
|
||||
<h1>{actor.name}</h1>
|
||||
<div className={styles.attributes}>
|
||||
{(["strength", "agility", "spirit"] as const).map((key) => (
|
||||
<label className={styles.attributeLabel} key={key}>
|
||||
{localize(`BOILERPLATE.Attributes.${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("BOILERPLATE.Sheet.Total")}: {total}
|
||||
</span>
|
||||
<span>
|
||||
{localize("BOILERPLATE.Sheet.TotalMod")}: {fmtMod(totalMod)}
|
||||
</span>
|
||||
</div>
|
||||
<label className={styles.attributeLabel}>
|
||||
{localize("BOILERPLATE.Sheet.Biography")}
|
||||
<textarea defaultValue={system.biography} onBlur={(e) => updateBiography(e.target.value)} />
|
||||
</label>
|
||||
|
||||
<div className={styles.chatRow}>
|
||||
<input
|
||||
type="text"
|
||||
placeholder={localize("BOILERPLATE.Sheet.ChatPlaceholder")}
|
||||
value={chatMessage}
|
||||
onChange={(e) => setChatMessage(e.target.value)}
|
||||
onKeyDown={(e) => e.key === "Enter" && sendChatMessage()}
|
||||
/>
|
||||
<button type="button" onClick={sendChatMessage}>
|
||||
{localize("BOILERPLATE.Sheet.SendToChat")}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
.sheet {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
|
||||
.label {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
font-size: 0.8rem;
|
||||
text-transform: capitalize;
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
import React from "react";
|
||||
import styles from "./ItemSheetApp.module.scss";
|
||||
import { localize } from "../../i18n";
|
||||
|
||||
export function ItemSheetApp({ item }: { item: Item.Implementation }) {
|
||||
const system = item.system;
|
||||
|
||||
const updateQuantity = (value: number) => {
|
||||
item.update({ system: { quantity: value } });
|
||||
};
|
||||
|
||||
const updateDescription = (value: string) => {
|
||||
item.update({ system: { description: value } });
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={styles.sheet}>
|
||||
<h1>{item.name}</h1>
|
||||
<label className={styles.label}>
|
||||
{localize("BOILERPLATE.Item.Quantity")}
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
value={system.quantity}
|
||||
onChange={(e) => updateQuantity(Number(e.target.value))}
|
||||
/>
|
||||
</label>
|
||||
<label className={styles.label}>
|
||||
{localize("BOILERPLATE.Item.Description")}
|
||||
<textarea
|
||||
defaultValue={system.description}
|
||||
onBlur={(e) => updateDescription(e.target.value)}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
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 * item.system.anzahl,
|
||||
0
|
||||
);
|
||||
|
||||
let traglast = Math.max(actor.system.skills.körper.athletik.value, 10);
|
||||
return {
|
||||
traglast,
|
||||
gewicht
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,361 @@
|
||||
import { systemPath } from "../../constants.mjs";
|
||||
|
||||
export async function 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 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 = game.i18n.localize("Midgard6.Zaubern") + ": " + item.name;
|
||||
let roll;
|
||||
|
||||
if (dialogResult.spezLevel) {
|
||||
rollTerm += " + @spezBonus";
|
||||
rollFlavor += ": " + dialogResult.spezName;
|
||||
}
|
||||
|
||||
if (dialogResult.customRoll) {
|
||||
roll = new Roll(dialogResult.customRoll, {}, { title: rollFlavor });
|
||||
} else {
|
||||
roll = new Roll(
|
||||
rollTerm,
|
||||
{
|
||||
die: die,
|
||||
skill: skillValue,
|
||||
spezBonus: dialogResult.spezLevel + 1
|
||||
},
|
||||
{ title: rollFlavor }
|
||||
);
|
||||
}
|
||||
|
||||
if (item.system.eigenschaften.schaden) {
|
||||
const attackRoll = await roll.evaluate();
|
||||
roll = [
|
||||
attackRoll,
|
||||
await new Roll(
|
||||
"@die",
|
||||
{ die: item.system.eigenschaften.schaden },
|
||||
{ title: game.i18n.localize("Midgard6.Schaden") }
|
||||
).evaluate()
|
||||
];
|
||||
} else {
|
||||
// Execute the roll
|
||||
await roll.evaluate();
|
||||
}
|
||||
|
||||
// The parsed terms of the roll formula
|
||||
console.log("Roll:", roll); // [Die, OperatorTerm, NumericTerm, OperatorTerm, NumericTerm]
|
||||
|
||||
const chatData = {
|
||||
rolls: roll,
|
||||
speaker: ChatMessage.getSpeaker(),
|
||||
flags: {
|
||||
"midgard6-lvd": {
|
||||
title: rollFlavor,
|
||||
eigenschaften: item.system.eigenschaften,
|
||||
isSpell: true,
|
||||
beschreibung: await foundry.applications.ux.TextEditor.implementation.enrichHTML(
|
||||
item.system.beschreibung,
|
||||
{
|
||||
// Whether to show secret blocks in the finished html
|
||||
secrets: false,
|
||||
// Data to fill in for inline rolls
|
||||
rollData: this.actor.getRollData(),
|
||||
// Relative UUID resolution
|
||||
relativeTo: this.actor
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ChatMessage.applyMode(chatData, dialogResult.rollMode);
|
||||
|
||||
await ChatMessage.create(chatData);
|
||||
}
|
||||
|
||||
export async function rollSkill(event, target) {
|
||||
const dataset = target.dataset;
|
||||
const skill = foundry.utils.getProperty(this.actor, target.dataset.path.replace(".value", ""));
|
||||
const actor = this.actor;
|
||||
const dialogResult = await rollDialog({
|
||||
name: dataset.name,
|
||||
skill,
|
||||
actor
|
||||
});
|
||||
console.log("Dialog Result", dialogResult);
|
||||
if (dialogResult === "abort") {
|
||||
return;
|
||||
}
|
||||
// Construct the Roll instance
|
||||
const skillValue = skill.value || skill;
|
||||
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, {}, { title: rollFlavor });
|
||||
} else {
|
||||
roll = new Roll(
|
||||
rollTerm,
|
||||
{
|
||||
die: die,
|
||||
skill: skillValue,
|
||||
spezBonus: dialogResult.spezLevel + 1
|
||||
},
|
||||
{ title: rollFlavor }
|
||||
);
|
||||
}
|
||||
|
||||
// The parsed terms of the roll formula
|
||||
console.log("Roll:", roll); // [Die, OperatorTerm, NumericTerm, OperatorTerm, NumericTerm]
|
||||
|
||||
// Execute the roll
|
||||
await roll.evaluate();
|
||||
|
||||
const chatData = {
|
||||
rolls: roll,
|
||||
speaker: ChatMessage.getSpeaker(),
|
||||
flags: {
|
||||
"midgard6-lvd": {
|
||||
title: rollFlavor
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Nutze applyRollMode, um Sichtbarkeiten (Whisper, Blind) korrekt zu setzen
|
||||
ChatMessage.applyMode(chatData, dialogResult.rollMode);
|
||||
|
||||
// Erstelle die Nachricht mit den manipulierten Daten
|
||||
await ChatMessage.create(chatData);
|
||||
}
|
||||
|
||||
export async function rollWeapon(event, target) {
|
||||
const dataset = target.dataset;
|
||||
const weapon = this.actor.items.get(dataset.itemId);
|
||||
const skill = foundry.utils.getProperty(this.actor, weapon.system.fertigkeit);
|
||||
const actor = this.actor;
|
||||
const dialogResult = await rollDialog({
|
||||
name: weapon.name,
|
||||
skill,
|
||||
damageRoll: weapon.system.schaden,
|
||||
preSelectedSpez: weapon.system.spezialisierung,
|
||||
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 = game.i18n.localize("Midgard6.Angriff");
|
||||
let attackRoll;
|
||||
let damageRoll;
|
||||
|
||||
if (dialogResult.spezLevel) {
|
||||
rollTerm += " + @spezBonus";
|
||||
rollFlavor += " (" + dialogResult.spezName + ")";
|
||||
}
|
||||
rollFlavor += ": " + weapon.name;
|
||||
|
||||
if (dialogResult.customRoll) {
|
||||
attackRoll = await new Roll(dialogResult.customRoll, {}, { title: rollFlavor }).evaluate();
|
||||
} else {
|
||||
attackRoll = await new Roll(
|
||||
rollTerm,
|
||||
{
|
||||
die: die,
|
||||
skill: skillValue,
|
||||
spezBonus: dialogResult.spezLevel + 1
|
||||
},
|
||||
{
|
||||
title: rollFlavor
|
||||
}
|
||||
).evaluate();
|
||||
}
|
||||
|
||||
damageRoll = await new Roll(
|
||||
"@die",
|
||||
{ die: weapon.system.schaden },
|
||||
{ title: game.i18n.localize("Midgard6.Schaden") }
|
||||
).evaluate();
|
||||
|
||||
// The parsed terms of the roll formula
|
||||
const chatData = {
|
||||
rolls: [attackRoll, damageRoll],
|
||||
speaker: ChatMessage.getSpeaker(),
|
||||
flags: {
|
||||
"midgard6-lvd": {
|
||||
title: rollFlavor,
|
||||
eigenschaften: weapon.eigenschaften,
|
||||
merkmale: weapon.system.merkmale,
|
||||
beschreibung: await foundry.applications.ux.TextEditor.implementation.enrichHTML(
|
||||
weapon.system.beschreibung,
|
||||
{
|
||||
secrets: false,
|
||||
rollData: this.actor.getRollData(),
|
||||
relativeTo: this.actor
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ChatMessage.applyMode(chatData, dialogResult.rollMode);
|
||||
|
||||
await ChatMessage.create(chatData);
|
||||
}
|
||||
|
||||
async function rollDialog(rollDialogRequest) {
|
||||
// Assamble dialog depending on roll type
|
||||
let label = rollDialogRequest.name;
|
||||
let skillValue = rollDialogRequest.skill.value || rollDialogRequest.skill;
|
||||
let bonuses = rollDialogRequest.skill.bonuses || [];
|
||||
let damageRoll = rollDialogRequest.damageRoll || "";
|
||||
let preSelectedSpez = rollDialogRequest.preSelectedSpez || "";
|
||||
let vorteil = 0;
|
||||
let customRoll = "";
|
||||
let spezLevel;
|
||||
let spezName = "";
|
||||
// 1. Define the path to .hbs template
|
||||
const templatePath = systemPath("templates/dialog/roll-dialog.hbs");
|
||||
const templateData = {
|
||||
skillValue,
|
||||
bonuses,
|
||||
vorteil,
|
||||
damageRoll,
|
||||
preSelectedSpez,
|
||||
customRoll,
|
||||
rollModes: CONFIG.ChatMessage.modes
|
||||
};
|
||||
// 2. Render the Handlebars template into an HTML string
|
||||
const content = await foundry.applications.handlebars.renderTemplate(templatePath, templateData);
|
||||
// return new Promise((resolve, reject) => {
|
||||
// const dialog = new foundry.applications.api.DialogV2({
|
||||
return foundry.applications.api.DialogV2.wait({
|
||||
window: { title: "Würfel Modifikatoren: " + label },
|
||||
position: {
|
||||
width: 600
|
||||
},
|
||||
classes: ["M6", "dialog"],
|
||||
content,
|
||||
actions: {},
|
||||
render: (_event, dialog) => {
|
||||
const dialogHTML = dialog.element;
|
||||
|
||||
const display = dialogHTML.querySelector("#rollDisplay");
|
||||
|
||||
// Variable bei jeder Änderung aktualisieren
|
||||
document.querySelectorAll('input[name="vorteil-segment"]').forEach((radio) => {
|
||||
radio.addEventListener("change", (e) => {
|
||||
vorteil = parseInt(e.target.value);
|
||||
switch (vorteil) {
|
||||
case 1:
|
||||
display.placeholder = `2d20kh + ${skillValue} (Vorteil)`;
|
||||
break;
|
||||
case -1:
|
||||
display.placeholder = `2d20kl + ${skillValue} (Nachteil)`;
|
||||
break;
|
||||
default:
|
||||
display.placeholder = `1d20 + ${skillValue}`;
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
document.querySelectorAll('input[name="spezialisierung-segment"]').forEach((radio) => {
|
||||
radio.addEventListener("change", (e) => {
|
||||
spezLevel = parseInt(e.target.value);
|
||||
spezName = e.target.dataset.name;
|
||||
});
|
||||
if (radio.dataset.name === preSelectedSpez) {
|
||||
radio.click();
|
||||
}
|
||||
});
|
||||
},
|
||||
buttons: [
|
||||
{
|
||||
action: "abort",
|
||||
label: "Midgard6.Dialog.abbrechen",
|
||||
callback: (event, button, dialog) => {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
{
|
||||
action: "roll",
|
||||
label: "Midgard6.Dialog.würfeln",
|
||||
default: true,
|
||||
callback: (event, button, dialog) => {
|
||||
const rollData = {
|
||||
customRoll: button.form.elements.customRoll.value,
|
||||
customDamageRoll: button.form.elements.customDamageRoll?.value || "",
|
||||
vorteil,
|
||||
spezLevel,
|
||||
spezName,
|
||||
rollMode:
|
||||
button.form.elements.rollMode?.value || game.settings.get("core", "messageMode")
|
||||
};
|
||||
return rollData;
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
import { systemPath } from "../../constants.mjs";
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
export async function addSpezialisierung(event, target) {
|
||||
const dataset = target.dataset;
|
||||
const path = dataset.path.replace(".value", "");
|
||||
const name = dataset.name;
|
||||
const skill = foundry.utils.getProperty(this.actor, path);
|
||||
|
||||
let level = 1;
|
||||
|
||||
const templatePath = systemPath("templates/dialog/spezialisierung-dialog.hbs");
|
||||
const templateData = {
|
||||
level
|
||||
};
|
||||
const content = await foundry.applications.handlebars.renderTemplate(templatePath, templateData);
|
||||
return foundry.applications.api.DialogV2.wait({
|
||||
window: {
|
||||
title:
|
||||
game.i18n.localize("Midgard6.Sheets.spezialisierung") +
|
||||
" " +
|
||||
game.i18n.localize(`Midgard6.Skills.${name}`)
|
||||
},
|
||||
classes: ["M6", "dialog"],
|
||||
position: {
|
||||
width: 600
|
||||
},
|
||||
content,
|
||||
actions: {},
|
||||
render: (_event, dialog) => {
|
||||
const dialogHTML = dialog.element;
|
||||
// Variable bei jeder Änderung aktualisieren
|
||||
dialogHTML.querySelectorAll('input[name="level-segment"]').forEach((radio) => {
|
||||
radio.addEventListener("change", (e) => {
|
||||
level = parseInt(e.target.value);
|
||||
});
|
||||
});
|
||||
},
|
||||
buttons: [
|
||||
{
|
||||
action: "abort",
|
||||
label: "Midgard6.Dialog.abbrechen"
|
||||
},
|
||||
{
|
||||
action: "safe",
|
||||
label: "Midgard6.Dialog.speichern",
|
||||
default: true,
|
||||
callback: async (event, button, dialog) => {
|
||||
const spez = {
|
||||
name: button.form.elements.spezName.value,
|
||||
level,
|
||||
path
|
||||
};
|
||||
skill.bonuses.push(spez);
|
||||
await this.actor.update({ [`${path}.bonuses`]: skill.bonuses });
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
export async function editSepzialisierung(event, target) {
|
||||
const dataset = target.dataset;
|
||||
const path = dataset.path;
|
||||
const name = dataset.name;
|
||||
const skill = foundry.utils.getProperty(this.actor, path);
|
||||
|
||||
let level = 1;
|
||||
let spezName = dataset.name;
|
||||
|
||||
const templatePath = systemPath("templates/dialog/spezialisierung-dialog.hbs");
|
||||
const templateData = {
|
||||
spezName,
|
||||
level
|
||||
};
|
||||
// 2. Render the Handlebars template into an HTML string
|
||||
const content = await foundry.applications.handlebars.renderTemplate(templatePath, templateData);
|
||||
return foundry.applications.api.DialogV2.wait({
|
||||
window: {
|
||||
title:
|
||||
game.i18n.localize("Midgard6.Sheets.spezialisierung") +
|
||||
" " +
|
||||
game.i18n.localize(path.replace(/^.*\.(?=[^.]+$)/g, "Midgard6.Skills."))
|
||||
},
|
||||
classes: ["M6", "dialog"],
|
||||
position: {
|
||||
width: 600
|
||||
},
|
||||
content,
|
||||
actions: {},
|
||||
render: (_event, dialog) => {
|
||||
const dialogHTML = dialog.element;
|
||||
|
||||
dialogHTML.querySelectorAll('input[name="level-segment"]').forEach((radio) => {
|
||||
radio.addEventListener("change", (e) => {
|
||||
level = parseInt(e.target.value);
|
||||
});
|
||||
});
|
||||
},
|
||||
buttons: [
|
||||
{
|
||||
action: "abort",
|
||||
label: "Midgard6.Dialog.abbrechen"
|
||||
},
|
||||
{
|
||||
action: "delete",
|
||||
label: "Midgard6.Dialog.löschen",
|
||||
callback: async (event, button, dialog) => {
|
||||
// const bonuses = this.actor[path].bonuses || [];
|
||||
const bonuses = skill.bonuses.filter((x) => x.name !== name);
|
||||
await this.actor.update({ [`${path}.bonuses`]: bonuses });
|
||||
}
|
||||
},
|
||||
{
|
||||
action: "safe",
|
||||
label: "Midgard6.Dialog.speichern",
|
||||
default: true,
|
||||
callback: async (event, button, dialog) => {
|
||||
const spez = {
|
||||
name: button.form.elements.spezName.value,
|
||||
level,
|
||||
path
|
||||
};
|
||||
const index = skill.bonuses.findIndex((x) => x.name === name);
|
||||
skill.bonuses.splice(index, 1, spez);
|
||||
await this.actor.update({ [`${path}.bonuses`]: skill.bonuses });
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
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 M6HintergrundSheet extends M6ItemSheet {
|
||||
static get DEFAULT_OPTIONS() {
|
||||
return {
|
||||
...super.DEFAULT_OPTIONS, // Kopiert alle bestehenden Actions aus M6ItemSheet
|
||||
actions: {
|
||||
...super.DEFAULT_OPTIONS.actions
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static TABS = {
|
||||
primary: {
|
||||
tabs: [
|
||||
{
|
||||
id: "beschreibung",
|
||||
icon: "fa-feather-pointed"
|
||||
},
|
||||
{
|
||||
id: "effects",
|
||||
icon: "fa-bolt"
|
||||
}
|
||||
],
|
||||
initial: "beschreibung",
|
||||
labelPrefix: "Midgard6.Sheets.Tabs"
|
||||
}
|
||||
};
|
||||
|
||||
/** @inheritdoc */
|
||||
static PARTS = {
|
||||
header: {
|
||||
template: systemPath("templates/hintergrund/header.hbs")
|
||||
},
|
||||
tabs: {
|
||||
template: systemPath("templates/shared/tabs.hbs")
|
||||
},
|
||||
beschreibung: {
|
||||
template: systemPath("templates/hintergrund/description.hbs"),
|
||||
scrollable: [""]
|
||||
},
|
||||
effects: {
|
||||
template: systemPath("templates/shared/effects.hbs"),
|
||||
scrollable: [""]
|
||||
}
|
||||
};
|
||||
|
||||
_addSpecifics(context) {
|
||||
if (context.source.type === "legende") {
|
||||
const schicksalsgaben = context.actor.items.filter((x) => x.type === "schicksalsgabe");
|
||||
context.schicksalsgaben = schicksalsgaben;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,573 @@
|
||||
import { prepareActiveEffectCategories } from "../helpers/utils.mjs";
|
||||
import { systemPath } from "../constants.mjs";
|
||||
const { api, sheets } = foundry.applications;
|
||||
|
||||
/**
|
||||
* Extend the basic ItemSheet with some very simple modifications.
|
||||
*/
|
||||
export class M6ItemSheet extends api.HandlebarsApplicationMixin(sheets.ItemSheet) {
|
||||
/** @inheritdoc */
|
||||
|
||||
static DEFAULT_OPTIONS = {
|
||||
window: {
|
||||
resizable: true
|
||||
},
|
||||
position: {
|
||||
width: 650,
|
||||
height: 450
|
||||
},
|
||||
classes: ["M6", "item", "standard-form"],
|
||||
actions: {
|
||||
viewDoc: this.#viewEffect,
|
||||
createDoc: this.#createEffect,
|
||||
deleteDoc: this.#deleteEffect,
|
||||
toggleEffect: this.#toggleEffect
|
||||
},
|
||||
form: {
|
||||
submitOnChange: true
|
||||
},
|
||||
// Custom property that's merged into `this.options`
|
||||
dragDrop: [{ dragSelector: ".draggable", dropSelector: null }]
|
||||
};
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
static TABS = {
|
||||
primary: {
|
||||
tabs: [
|
||||
{
|
||||
id: "beschreibung",
|
||||
icon: "fa-feather-pointed"
|
||||
},
|
||||
{
|
||||
id: "effects",
|
||||
icon: "fa-bolt"
|
||||
}
|
||||
],
|
||||
initial: "beschreibung",
|
||||
labelPrefix: "Midgard6.Sheets.Tabs"
|
||||
}
|
||||
};
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/** @inheritdoc */
|
||||
static PARTS = {
|
||||
header: {
|
||||
template: systemPath("templates/item/header.hbs")
|
||||
},
|
||||
tabs: {
|
||||
template: systemPath("templates/shared/tabs.hbs")
|
||||
},
|
||||
beschreibung: {
|
||||
template: systemPath("templates/item/description.hbs"),
|
||||
scrollable: [""]
|
||||
},
|
||||
effects: {
|
||||
template: systemPath("templates/shared/effects.hbs"),
|
||||
scrollable: [""]
|
||||
}
|
||||
};
|
||||
|
||||
_attachPartListeners(partId, html, bubble) {
|
||||
super._attachPartListeners(partId, html, bubble);
|
||||
|
||||
if (partId === "eigenschaften") {
|
||||
const inputs = html.querySelectorAll("input[data-action=splitIntoArray]");
|
||||
|
||||
if (inputs) {
|
||||
inputs.forEach((input) => {
|
||||
input.addEventListener("blur", this._onInputBlur.bind(this));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Die eigentliche Funktion, die beim Verlassen des Feldes feuert
|
||||
_onInputBlur(event) {
|
||||
event.preventDefault();
|
||||
const currentInput = event.currentTarget;
|
||||
const value = currentInput.value;
|
||||
console.log("Feld verlassen! Aktueller Wert:", value);
|
||||
this.item.update({ [`${currentInput.name}`]: value.split(/[\s,]+/) });
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/** @inheritdoc */
|
||||
_initializeApplicationOptions(options) {
|
||||
const initialized = super._initializeApplicationOptions(options);
|
||||
|
||||
initialized.classes.push(initialized.document.type);
|
||||
|
||||
return initialized;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/** @inheritdoc */
|
||||
async _prepareContext(options) {
|
||||
const context = await super._prepareContext(options);
|
||||
|
||||
Object.assign(context, {
|
||||
owner: this.document.isOwner,
|
||||
limited: this.document.limited,
|
||||
item: this.item,
|
||||
actor: this.actor,
|
||||
system: this.item.system,
|
||||
flags: this.item.flags,
|
||||
itemFields: this.item.schema.fields,
|
||||
config: CONFIG
|
||||
});
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/** @inheritdoc */
|
||||
async _preparePartContext(partId, context) {
|
||||
// TODO: Come up with clever way to automatically handle enriching HTML fields
|
||||
switch (partId) {
|
||||
case "effects":
|
||||
context.effects = prepareActiveEffectCategories(this.item.effects);
|
||||
context.tab = context.tabs[partId];
|
||||
break;
|
||||
case "beschreibung":
|
||||
context.fields = await this._getFields();
|
||||
context.enrichedBeschreibung =
|
||||
await foundry.applications.ux.TextEditor.implementation.enrichHTML(
|
||||
this.item.system.beschreibung,
|
||||
{
|
||||
// Whether to show secret blocks in the finished html
|
||||
secrets: this.document.isOwner,
|
||||
// Data to fill in for inline rolls
|
||||
rollData: this.item.getRollData(),
|
||||
// Relative UUID resolution
|
||||
relativeTo: this.item
|
||||
}
|
||||
);
|
||||
context.tab = context.tabs[partId];
|
||||
break;
|
||||
default:
|
||||
await this._addSpecifics(context);
|
||||
context.tab = context.tabs[partId];
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* 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.push(fieldset);
|
||||
} else {
|
||||
fieldSets.push({ outer: { 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.push({ field, value: foundry.utils.getProperty(source, path) });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Actions performed after any render of the Application.
|
||||
* Post-render steps are not awaited by the render process.
|
||||
* @param {ApplicationRenderContext} context Prepared context data.
|
||||
* @param {RenderOptions} options Provided render options.
|
||||
* @protected
|
||||
*/
|
||||
_onRender(context, options) {
|
||||
this.#dragDrop.forEach((d) => d.bind(this.element));
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
/* Event handlers */
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Renders an embedded document's sheet.
|
||||
*
|
||||
* @this UTSItemSheet
|
||||
* @param {PointerEvent} event The originating click event.
|
||||
* @param {HTMLElement} target The capturing HTML element which defined a [data-action].
|
||||
* @protected
|
||||
*/
|
||||
static async #viewEffect(event, target) {
|
||||
const effect = this._getEffect(target);
|
||||
effect.sheet.render(true);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Handles item deletion.
|
||||
*
|
||||
* @this UTSItemSheet
|
||||
* @param {PointerEvent} event The originating click event.
|
||||
* @param {HTMLElement} target The capturing HTML element which defined a [data-action].
|
||||
* @protected
|
||||
*/
|
||||
static async #deleteEffect(event, target) {
|
||||
const effect = this._getEffect(target);
|
||||
effect.delete();
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Handle creating a new Owned Item or ActiveEffect for the actor using initial data defined in the HTML dataset.
|
||||
*
|
||||
* @this UTSItemSheet
|
||||
* @param {PointerEvent} event The originating click event.
|
||||
* @param {HTMLElement} target The capturing HTML element which defined a [data-action].
|
||||
* @private
|
||||
*/
|
||||
static async #createEffect(event, target) {
|
||||
const aeCls = getDocumentClass("ActiveEffect");
|
||||
const effectData = {
|
||||
name: aeCls.defaultName({
|
||||
type: target.dataset.type,
|
||||
parent: this.item
|
||||
})
|
||||
};
|
||||
for (const [dataKey, value] of Object.entries(target.dataset)) {
|
||||
if (["action", "documentClass"].includes(dataKey)) continue;
|
||||
foundry.utils.setProperty(effectData, dataKey, value);
|
||||
}
|
||||
|
||||
aeCls.create(effectData, { parent: this.item });
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Determines effect parent to pass to helper.
|
||||
*
|
||||
* @this UTSItemSheet
|
||||
* @param {PointerEvent} event The originating click event.
|
||||
* @param {HTMLElement} target The capturing HTML element which defined a [data-action].
|
||||
* @private
|
||||
*/
|
||||
static async #toggleEffect(event, target) {
|
||||
const effect = this._getEffect(target);
|
||||
effect.update({ disabled: !effect.disabled });
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
/* Helper functions */
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Fetches the row with the data for the rendered embedded document.
|
||||
*
|
||||
* @param {HTMLElement} target The element with the action.
|
||||
* @returns {HTMLLIElement} The document's row.
|
||||
*/
|
||||
_getEffect(target) {
|
||||
const li = target.closest(".effect");
|
||||
return this.item.effects.get(li?.dataset?.effectId);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
/* Drag and drop */
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Define whether a user is able to begin a dragstart workflow for a given drag selector.
|
||||
* @param {string} selector The candidate HTML selector for dragging.
|
||||
* @returns {boolean} Can the current user drag this selector?
|
||||
* @protected
|
||||
*/
|
||||
_canDragStart(selector) {
|
||||
return this.isEditable;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Define whether a user is able to conclude a drag-and-drop workflow for a given drop selector.
|
||||
* @param {string} selector The candidate HTML selector for the drop target.
|
||||
* @returns {boolean} Can the current user drop on this selector?
|
||||
* @protected
|
||||
*/
|
||||
_canDragDrop(selector) {
|
||||
return this.isEditable;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Callback actions which occur at the beginning of a drag start workflow.
|
||||
* @param {DragEvent} event The originating DragEvent.
|
||||
* @protected
|
||||
*/
|
||||
_onDragStart(event) {
|
||||
const li = event.currentTarget;
|
||||
if ("link" in event.target.dataset) return;
|
||||
|
||||
let dragData = null;
|
||||
|
||||
if (li.dataset.effectId) {
|
||||
const effect = this.item.effects.get(li.dataset.effectId);
|
||||
dragData = effect.toDragData();
|
||||
}
|
||||
|
||||
if (!dragData) return;
|
||||
|
||||
event.dataTransfer.setData("text/plain", JSON.stringify(dragData));
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Callback actions which occur when a dragged element is over a drop target.
|
||||
* @param {DragEvent} event The originating DragEvent.
|
||||
* @protected
|
||||
*/
|
||||
_onDragOver(event) {}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Callback actions which occur when a dragged element is dropped on a target.
|
||||
* @param {DragEvent} event The originating DragEvent.
|
||||
* @protected
|
||||
*/
|
||||
async _onDrop(event) {
|
||||
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event);
|
||||
const item = this.item;
|
||||
|
||||
const allowed = Hooks.call("dropItemSheetData", item, this, data);
|
||||
// if (allowed === false) return;
|
||||
|
||||
// Handle different data types
|
||||
switch (data.type) {
|
||||
case "ActiveEffect":
|
||||
return this._onDropActiveEffect(event, data);
|
||||
case "Actor":
|
||||
return this._onDropActor(event, data);
|
||||
case "Item":
|
||||
return this._onDropItem(event, data);
|
||||
case "Folder":
|
||||
return this._onDropFolder(event, data);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Handle the dropping of ActiveEffect data onto an Actor Sheet.
|
||||
* @param {DragEvent} event The concluding DragEvent which contains drop data.
|
||||
* @param {object} data The data transfer extracted from the event.
|
||||
* @returns {Promise<ActiveEffect|boolean>} The created ActiveEffect object or false if it couldn't be created.
|
||||
* @protected
|
||||
*/
|
||||
async _onDropActiveEffect(event, data) {
|
||||
const aeCls = getDocumentClass("ActiveEffect");
|
||||
const effect = await aeCls.fromDropData(data);
|
||||
if (!this.item.isOwner || !effect) return false;
|
||||
|
||||
if (this.item.uuid === effect.parent?.uuid) return this._onEffectSort(event, effect);
|
||||
aeCls.create(effect, { parent: this.item });
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Sorts an Active Effect based on its surrounding attributes.
|
||||
*
|
||||
* @param {DragEvent} event
|
||||
* @param {ActiveEffect} effect
|
||||
*/
|
||||
_onEffectSort(event, effect) {
|
||||
const effects = this.item.effects;
|
||||
const dropTarget = event.target.closest("[data-effect-id]");
|
||||
if (!dropTarget) return;
|
||||
const target = effects.get(dropTarget.dataset.effectId);
|
||||
|
||||
// Don't sort on yourself
|
||||
if (effect.id === target.id) return;
|
||||
|
||||
// Identify sibling items based on adjacent HTML elements
|
||||
const siblings = [];
|
||||
for (let el of dropTarget.parentElement.children) {
|
||||
const siblingId = el.dataset.effectId;
|
||||
if (siblingId && siblingId !== effect.id) siblings.push(effects.get(el.dataset.effectId));
|
||||
}
|
||||
|
||||
// Perform the sort
|
||||
const sortUpdates = foundry.utils.performIntegerSort(effect, {
|
||||
target,
|
||||
siblings
|
||||
});
|
||||
const updateData = sortUpdates.map((u) => {
|
||||
const update = u.update;
|
||||
update._id = u.target._id;
|
||||
return update;
|
||||
});
|
||||
|
||||
// Perform the update
|
||||
this.item.updateEmbeddedDocuments("ActiveEffect", updateData);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Handle dropping of an Actor data onto another Actor sheet.
|
||||
* @param {DragEvent} event The concluding DragEvent which contains drop data.
|
||||
* @param {object} data The data transfer extracted from the event.
|
||||
* @returns {Promise<object|boolean>} A data object which describes the result of the drop, or false if the drop was
|
||||
* not permitted.
|
||||
* @protected
|
||||
*/
|
||||
async _onDropActor(event, data) {
|
||||
if (!this.item.isOwner) return false;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Handle dropping of an item reference or item data onto an Actor Sheet.
|
||||
* @param {DragEvent} event The concluding DragEvent which contains drop data.
|
||||
* @param {object} data The data transfer extracted from the event.
|
||||
* @returns {Promise<Item[]|boolean>} The created or updated Item instances, or false if the drop was not permitted.
|
||||
* @protected
|
||||
*/
|
||||
async _onDropItem(event, data) {
|
||||
if (!this.item.isOwner) return false;
|
||||
|
||||
// Prüfen, ob das Item von diesem Actor stammt und Shift NICHT gedrückt ist
|
||||
const isSameActor = this.actor.uuid === item.parent?.uuid;
|
||||
const isShift = event.shiftKey;
|
||||
|
||||
if (isSameActor) {
|
||||
// Sortieren, nicht kopieren/verschieben
|
||||
return this._onSortItem(event, item);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a drop event for an existing embedded Item to sort that Item relative to its siblings
|
||||
* @param {Event} event
|
||||
* @param {Item} item
|
||||
* @private
|
||||
*/
|
||||
_onSortItem(event, item) {
|
||||
// Get the drag source and drop target
|
||||
const items = this.actor.items;
|
||||
const dropTarget = event.target.closest("[data-item-id]");
|
||||
if (!dropTarget) return;
|
||||
const target = items.get(dropTarget.dataset.itemId);
|
||||
|
||||
// Don't sort on yourself
|
||||
if (item.id === target.id) return;
|
||||
|
||||
// Identify sibling items based on adjacent HTML elements
|
||||
const siblings = [];
|
||||
for (let el of dropTarget.parentElement.children) {
|
||||
const siblingId = el.dataset.itemId;
|
||||
if (siblingId && siblingId !== item.id) siblings.push(items.get(el.dataset.itemId));
|
||||
}
|
||||
|
||||
// Perform the sort
|
||||
const sortUpdates = foundry.utils.SortingHelpers.performIntegerSort(item, {
|
||||
target,
|
||||
siblings
|
||||
});
|
||||
const updateData = sortUpdates.map((u) => {
|
||||
const update = u.update;
|
||||
update._id = u.target._id;
|
||||
return update;
|
||||
});
|
||||
|
||||
// Perform the update
|
||||
return this.actor.updateEmbeddedDocuments("Item", updateData);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Handle dropping of a Folder on an Actor Sheet.
|
||||
* The core sheet currently supports dropping a Folder of Items to create all items as owned items.
|
||||
* @param {DragEvent} event The concluding DragEvent which contains drop data.
|
||||
* @param {object} data The data transfer extracted from the event.
|
||||
* @returns {Promise<Item[]>}
|
||||
* @protected
|
||||
*/
|
||||
async _onDropFolder(event, data) {
|
||||
if (!this.item.isOwner) return [];
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
/* The following pieces set up drag */
|
||||
/* handling and are unlikely to need modification */
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
// This is marked as private because there's no real need
|
||||
// for subclasses or external hooks to mess with it directly
|
||||
#dragDrop = this.#createDragDropHandlers();
|
||||
|
||||
/**
|
||||
* Returns an array of DragDrop instances.
|
||||
* @type {DragDrop[]}
|
||||
*/
|
||||
get dragDrop() {
|
||||
return this.#dragDrop;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Create drag-and-drop workflow handlers for this Application.
|
||||
* @returns {DragDrop[]} An array of DragDrop handlers.
|
||||
* @private
|
||||
*/
|
||||
#createDragDropHandlers() {
|
||||
return this.options.dragDrop.map((d) => {
|
||||
d.permissions = {
|
||||
dragstart: this._canDragStart.bind(this),
|
||||
drop: this._canDragDrop.bind(this)
|
||||
};
|
||||
d.callbacks = {
|
||||
dragstart: this._onDragStart.bind(this),
|
||||
dragover: this._onDragOver.bind(this),
|
||||
drop: this._onDrop.bind(this)
|
||||
};
|
||||
return new foundry.applications.ux.DragDrop(d);
|
||||
});
|
||||
}
|
||||
|
||||
async _addSpecifics(context) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
import React from "react";
|
||||
import { createRoot, type Root } from "react-dom/client";
|
||||
import { ItemSheetApp } from "./components/ItemSheetApp";
|
||||
|
||||
export class ItemSheet extends foundry.applications.sheets.ItemSheetV2 {
|
||||
static DEFAULT_OPTIONS = {
|
||||
classes: ["fvtt-ts-react-boilerplate", "sheet", "item"],
|
||||
position: { width: 480, height: 360 }
|
||||
};
|
||||
|
||||
#root: Root | null = null;
|
||||
|
||||
override async _renderHTML(
|
||||
...args: Parameters<foundry.applications.sheets.ItemSheetV2["_renderHTML"]>
|
||||
) {
|
||||
return args[0];
|
||||
}
|
||||
|
||||
override _replaceHTML(
|
||||
...args: Parameters<foundry.applications.sheets.ItemSheetV2["_replaceHTML"]>
|
||||
) {
|
||||
const content = args[1];
|
||||
if (!this.#root) this.#root = createRoot(content);
|
||||
this.#root.render(React.createElement(ItemSheetApp, { item: this.document }));
|
||||
}
|
||||
|
||||
override async close(...args: Parameters<foundry.applications.sheets.ItemSheetV2["close"]>) {
|
||||
this.#root?.unmount();
|
||||
this.#root = null;
|
||||
return super.close(...args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
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 M6WeaponSheet extends M6ItemSheet {
|
||||
static get DEFAULT_OPTIONS() {
|
||||
return {
|
||||
...super.DEFAULT_OPTIONS, // Kopiert alle bestehenden Actions aus M6ItemSheet
|
||||
actions: {
|
||||
...super.DEFAULT_OPTIONS.actions,
|
||||
cycleEquip: this.#cycleEquip
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
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/waffen/eigenschaften.hbs"),
|
||||
scrollable: [""]
|
||||
},
|
||||
beschreibung: {
|
||||
template: systemPath("templates/item/description.hbs"),
|
||||
scrollable: [""]
|
||||
},
|
||||
effects: {
|
||||
template: systemPath("templates/shared/effects.hbs"),
|
||||
scrollable: [""]
|
||||
}
|
||||
};
|
||||
|
||||
async _addSpecifics(context) {
|
||||
context.bonuses =
|
||||
foundry.utils.getProperty(this.actor, this.item.system.fertigkeit)?.bonuses || [];
|
||||
}
|
||||
|
||||
static #cycleEquip() {
|
||||
this.item.update({
|
||||
system: {
|
||||
equipped: !this.item.system.equipped
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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 || [];
|
||||
}
|
||||
|
||||
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) };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
@import url("flex/bootstrap-grid.css");
|
||||
@import url("./header.scss");
|
||||
@import url("./tabs.scss");
|
||||
@import url("./resistenzen.scss");
|
||||
@import url("./dialog.scss");
|
||||
@import url("./items-page.scss");
|
||||
@import url("./hintergrund.scss");
|
||||
@import url("./icons.scss");
|
||||
@import url("./chat-messages.scss");
|
||||
|
||||
:root {
|
||||
--M6-background-grey: #d3d7d7;
|
||||
--M6-background-brown: #eedecd;
|
||||
--M6-background-white: #fdfeff;
|
||||
--M6-text-grey: #595d5f;
|
||||
--M6-text-brown: #be7742;
|
||||
}
|
||||
|
||||
.inline-roll {
|
||||
background-color: var(--M6-background-brown);
|
||||
}
|
||||
.M6 {
|
||||
fieldset {
|
||||
border-radius: 0;
|
||||
border: none;
|
||||
background-color: var(--M6-background-grey);
|
||||
|
||||
&.highlight {
|
||||
background-color: var(--M6-background-brown);
|
||||
}
|
||||
legend {
|
||||
color: var(--M6-text-brown);
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
h5 {
|
||||
color: var(--M6-text-grey);
|
||||
}
|
||||
i {
|
||||
font-size: 18px;
|
||||
text-shadow: 0 0 10px var(--M6-background-white);
|
||||
}
|
||||
i:hover {
|
||||
text-shadow: 0 0 10px var(--M6-background-brown);
|
||||
}
|
||||
|
||||
prose-mirror.active {
|
||||
background-color: var(--M6-background-white);
|
||||
}
|
||||
}
|
||||
|
||||
.application {
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.M6 {
|
||||
background-color: var(--M6-background-white);
|
||||
color: var(--M6-text-grey);
|
||||
|
||||
input {
|
||||
background-color: var(--M6-background-white);
|
||||
color: black;
|
||||
border-radius: 0;
|
||||
transition: none;
|
||||
&.skill {
|
||||
max-width: 2rem;
|
||||
text-align: center;
|
||||
margin-left: 0.5rem;
|
||||
height: 24px;
|
||||
}
|
||||
&.attribut {
|
||||
max-width: 2rem;
|
||||
text-align: center;
|
||||
margin: 0 0.5rem;
|
||||
}
|
||||
&.text {
|
||||
&.center {
|
||||
text-align: center;
|
||||
}
|
||||
&.right {
|
||||
text-align: end;
|
||||
}
|
||||
}
|
||||
}
|
||||
input:disabled {
|
||||
border: none;
|
||||
}
|
||||
input:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
select {
|
||||
background-color: var(--M6-background-white);
|
||||
color: black;
|
||||
border-radius: 0;
|
||||
transition: none;
|
||||
margin-bottom: 4px;
|
||||
option:hover {
|
||||
background-color: var(--M6-background-brown);
|
||||
}
|
||||
}
|
||||
p {
|
||||
&.center {
|
||||
text-align: center;
|
||||
}
|
||||
&.right {
|
||||
text-align: end;
|
||||
}
|
||||
}
|
||||
|
||||
.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 {
|
||||
img {
|
||||
border-radius: 0 0 50% 50%;
|
||||
border: solid 8px var(--M6-background-grey);
|
||||
border-top: none;
|
||||
flex: 0 0 100px;
|
||||
object-fit: fill;
|
||||
}
|
||||
}
|
||||
.tab {
|
||||
height: 100%;
|
||||
padding-top: 10px;
|
||||
}
|
||||
.tab {
|
||||
ul {
|
||||
list-style: none;
|
||||
padding-left: 5px;
|
||||
}
|
||||
.itemHeader {
|
||||
border-bottom: 1px solid var(--color-border-light-primary);
|
||||
.type-label {
|
||||
font-size: 20px;
|
||||
}
|
||||
.document-controls {
|
||||
flex: 0 0 100px;
|
||||
}
|
||||
}
|
||||
.item {
|
||||
img {
|
||||
border: none;
|
||||
flex: 0 0 30px;
|
||||
padding-right: 5px;
|
||||
}
|
||||
.document-controls {
|
||||
flex: 0 0 50px;
|
||||
}
|
||||
}
|
||||
}
|
||||
.tab[data-tab="effects"] {
|
||||
ul {
|
||||
list-style: none;
|
||||
padding-left: 5px;
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.effects-header {
|
||||
font-size: 16px;
|
||||
border-bottom: 1px solid var(--color-border-light-primary);
|
||||
.document-controls {
|
||||
flex: 0 0 100px;
|
||||
}
|
||||
}
|
||||
.effect {
|
||||
.effect-label {
|
||||
img {
|
||||
border: none;
|
||||
flex: 0 0 30px;
|
||||
padding-right: 5px;
|
||||
}
|
||||
.effect-name {
|
||||
line-height: 24px;
|
||||
}
|
||||
}
|
||||
.effect-duration {
|
||||
flex: 0 0 130px;
|
||||
}
|
||||
.document-controls {
|
||||
flex: 0 0 80px;
|
||||
}
|
||||
}
|
||||
.effect-label {
|
||||
flex: 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
.chat-message {
|
||||
background: none;
|
||||
border-radius: 0;
|
||||
}
|
||||
.message-header {
|
||||
.message-names {
|
||||
color: var(--M6-text-brown);
|
||||
font-weight: bold;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.portrait {
|
||||
padding: 0 4px;
|
||||
}
|
||||
}
|
||||
.chat-message.message {
|
||||
background-color: var(--M6-background-grey);
|
||||
|
||||
fieldset {
|
||||
background-color: var(--M6-background-white);
|
||||
|
||||
&.highlight {
|
||||
background-color: var(--M6-background-brown);
|
||||
}
|
||||
legend {
|
||||
color: var(--M6-text-brown);
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
.collapsible {
|
||||
background-color: var(--M6-background-white);
|
||||
cursor: pointer;
|
||||
padding: 12px;
|
||||
font-size: 15px;
|
||||
margin-bottom: 4px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin: 8px 4px;
|
||||
|
||||
&.active {
|
||||
background-color: var(--M6-background-brown);
|
||||
box-shadow: none;
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
}
|
||||
|
||||
/* Add a background color to the button if it is clicked on (add the .active class with JS), and when you move the mouse over it (hover) */
|
||||
|
||||
/* Style the collapsible content. Note: hidden by default */
|
||||
.content {
|
||||
padding: 0 18px;
|
||||
display: none;
|
||||
width: auto;
|
||||
overflow: hidden;
|
||||
background-color: var(--M6-background-white);
|
||||
&.active {
|
||||
display: block;
|
||||
width: auto;
|
||||
margin: 8px 4px;
|
||||
margin-top: 0;
|
||||
}
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.tags {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.125rem;
|
||||
list-style-type: none;
|
||||
padding-left: 0;
|
||||
margin: 0.25rem;
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
.tag {
|
||||
background-color: var(--M6-background-brown);
|
||||
color: black;
|
||||
font-family: var(--sans-serif);
|
||||
font-size: var(--font-size-10);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
text-rendering: optimizeLegibility;
|
||||
align-items: center;
|
||||
border-radius: 2px;
|
||||
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.5);
|
||||
display: inline-flex;
|
||||
font-weight: 500;
|
||||
padding: 0.3em;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
.application.dialog.M6 {
|
||||
background-color: var(--M6-background-white);
|
||||
color: var(--M6-text-grey);
|
||||
|
||||
fieldset {
|
||||
border-radius: 0;
|
||||
border: none;
|
||||
background-color: var(--M6-background-grey);
|
||||
|
||||
&.highlight {
|
||||
background-color: var(--M6-background-brown);
|
||||
}
|
||||
legend {
|
||||
color: var(--M6-text-brown);
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
h5 {
|
||||
color: var(--M6-text-grey);
|
||||
}
|
||||
i {
|
||||
font-size: 18px;
|
||||
text-shadow: 0 0 10px var(--M6-background-white);
|
||||
}
|
||||
i:hover {
|
||||
text-shadow: 0 0 10px var(--M6-background-brown);
|
||||
}
|
||||
input {
|
||||
background-color: var(--M6-background-white);
|
||||
color: black;
|
||||
border-radius: 0;
|
||||
&.skill {
|
||||
max-width: 2rem;
|
||||
text-align: center;
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
&.attribut {
|
||||
max-width: 2rem;
|
||||
text-align: center;
|
||||
margin: 0 0.5rem;
|
||||
}
|
||||
&.text {
|
||||
&.right {
|
||||
text-align: end;
|
||||
}
|
||||
}
|
||||
}
|
||||
p {
|
||||
&.center {
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
fieldset {
|
||||
background-color: var(--M6-background-grey);
|
||||
legend {
|
||||
color: var(--M6-text-brown);
|
||||
font-size: 20px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Container für die gesamte Reihe */
|
||||
.segmented-button-row {
|
||||
display: inline-flex;
|
||||
overflow: hidden;
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
/* Einzelnes Segment */
|
||||
.segmented-button {
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* Versteckt den echten Radio-Button, behält aber die Tastatur-Navigation */
|
||||
.segmented-button input[type="radio"] {
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
/* Inhalt des Segments (Layout & Abstände) */
|
||||
.segmented-button__content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0 8px;
|
||||
height: 100%;
|
||||
transition:
|
||||
background-color 0.2s,
|
||||
color 0.2s;
|
||||
background-color: transparent;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
/* --- ZUSTÄNDE --- */
|
||||
|
||||
/* Selektiert (Selected State) */
|
||||
.segmented-button input[type="radio"]:checked + .segmented-button__content {
|
||||
// background-color: #e8def8; /* M3 Secondary Container Color */
|
||||
text-shadow: 0 0 10px var(--M6-text-brown) !important;
|
||||
color: #1d192b; /* M3 On-Secondary Container Text */
|
||||
.icon {
|
||||
text-shadow: 0 0 10px var(--M6-text-brown) !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* Hover-Effekt */
|
||||
.segmented-button:hover .segmented-button__content {
|
||||
background-color: rgba(73, 69, 79, 0.08);
|
||||
}
|
||||
.segmented-button input[type="radio"]:checked:hover + .segmented-button__content {
|
||||
background-color: rgba(232, 222, 248, 0.85);
|
||||
}
|
||||
|
||||
/* Tastatur-Fokus (Barrierefreiheit) */
|
||||
.segmented-button input[type="radio"]:focus-visible + .segmented-button__content {
|
||||
outline: 2px solid #6750a4;
|
||||
outline-offset: -2px;
|
||||
}
|
||||
Vendored
+1978
File diff suppressed because it is too large.
Load diff
+7
@@ -0,0 +1,7 @@
|
||||
/*!
|
||||
* Bootstrap Grid v4.1.3 (https://getbootstrap.com/)
|
||||
* Copyright 2011-2018 The Bootstrap Authors
|
||||
* Copyright 2011-2018 Twitter, Inc.
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||
*/@-ms-viewport{width:device-width}html{box-sizing:border-box;-ms-overflow-style:scrollbar}*,::after,::before{box-sizing:inherit}.container{width:100%;padding-right:15px;padding-left:15px;margin-right:auto;margin-left:auto}@media (min-width:576px){.container{max-width:540px}}@media (min-width:768px){.container{max-width:720px}}@media (min-width:992px){.container{max-width:960px}}@media (min-width:1200px){.container{max-width:1140px}}.container-fluid{width:100%;padding-right:15px;padding-left:15px;margin-right:auto;margin-left:auto}.row{display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;margin-right:-15px;margin-left:-15px}.no-gutters{margin-right:0;margin-left:0}.no-gutters>.col,.no-gutters>[class*=col-]{padding-right:0;padding-left:0}.col,.col-1,.col-10,.col-11,.col-12,.col-2,.col-3,.col-4,.col-5,.col-6,.col-7,.col-8,.col-9,.col-auto,.col-lg,.col-lg-1,.col-lg-10,.col-lg-11,.col-lg-12,.col-lg-2,.col-lg-3,.col-lg-4,.col-lg-5,.col-lg-6,.col-lg-7,.col-lg-8,.col-lg-9,.col-lg-auto,.col-md,.col-md-1,.col-md-10,.col-md-11,.col-md-12,.col-md-2,.col-md-3,.col-md-4,.col-md-5,.col-md-6,.col-md-7,.col-md-8,.col-md-9,.col-md-auto,.col-sm,.col-sm-1,.col-sm-10,.col-sm-11,.col-sm-12,.col-sm-2,.col-sm-3,.col-sm-4,.col-sm-5,.col-sm-6,.col-sm-7,.col-sm-8,.col-sm-9,.col-sm-auto,.col-xl,.col-xl-1,.col-xl-10,.col-xl-11,.col-xl-12,.col-xl-2,.col-xl-3,.col-xl-4,.col-xl-5,.col-xl-6,.col-xl-7,.col-xl-8,.col-xl-9,.col-xl-auto{position:relative;width:100%;min-height:1px;padding-right:15px;padding-left:15px}.col{-ms-flex-preferred-size:0;flex-basis:0;-ms-flex-positive:1;flex-grow:1;max-width:100%}.col-auto{-ms-flex:0 0 auto;flex:0 0 auto;width:auto;max-width:none}.col-1{-ms-flex:0 0 8.333333%;flex:0 0 8.333333%;max-width:8.333333%}.col-2{-ms-flex:0 0 16.666667%;flex:0 0 16.666667%;max-width:16.666667%}.col-3{-ms-flex:0 0 25%;flex:0 0 25%;max-width:25%}.col-4{-ms-flex:0 0 33.333333%;flex:0 0 33.333333%;max-width:33.333333%}.col-5{-ms-flex:0 0 41.666667%;flex:0 0 41.666667%;max-width:41.666667%}.col-6{-ms-flex:0 0 50%;flex:0 0 50%;max-width:50%}.col-7{-ms-flex:0 0 58.333333%;flex:0 0 58.333333%;max-width:58.333333%}.col-8{-ms-flex:0 0 66.666667%;flex:0 0 66.666667%;max-width:66.666667%}.col-9{-ms-flex:0 0 75%;flex:0 0 75%;max-width:75%}.col-10{-ms-flex:0 0 83.333333%;flex:0 0 83.333333%;max-width:83.333333%}.col-11{-ms-flex:0 0 91.666667%;flex:0 0 91.666667%;max-width:91.666667%}.col-12{-ms-flex:0 0 100%;flex:0 0 100%;max-width:100%}.order-first{-ms-flex-order:-1;order:-1}.order-last{-ms-flex-order:13;order:13}.order-0{-ms-flex-order:0;order:0}.order-1{-ms-flex-order:1;order:1}.order-2{-ms-flex-order:2;order:2}.order-3{-ms-flex-order:3;order:3}.order-4{-ms-flex-order:4;order:4}.order-5{-ms-flex-order:5;order:5}.order-6{-ms-flex-order:6;order:6}.order-7{-ms-flex-order:7;order:7}.order-8{-ms-flex-order:8;order:8}.order-9{-ms-flex-order:9;order:9}.order-10{-ms-flex-order:10;order:10}.order-11{-ms-flex-order:11;order:11}.order-12{-ms-flex-order:12;order:12}.offset-1{margin-left:8.333333%}.offset-2{margin-left:16.666667%}.offset-3{margin-left:25%}.offset-4{margin-left:33.333333%}.offset-5{margin-left:41.666667%}.offset-6{margin-left:50%}.offset-7{margin-left:58.333333%}.offset-8{margin-left:66.666667%}.offset-9{margin-left:75%}.offset-10{margin-left:83.333333%}.offset-11{margin-left:91.666667%}@media (min-width:576px){.col-sm{-ms-flex-preferred-size:0;flex-basis:0;-ms-flex-positive:1;flex-grow:1;max-width:100%}.col-sm-auto{-ms-flex:0 0 auto;flex:0 0 auto;width:auto;max-width:none}.col-sm-1{-ms-flex:0 0 8.333333%;flex:0 0 8.333333%;max-width:8.333333%}.col-sm-2{-ms-flex:0 0 16.666667%;flex:0 0 16.666667%;max-width:16.666667%}.col-sm-3{-ms-flex:0 0 25%;flex:0 0 25%;max-width:25%}.col-sm-4{-ms-flex:0 0 33.333333%;flex:0 0 33.333333%;max-width:33.333333%}.col-sm-5{-ms-flex:0 0 41.666667%;flex:0 0 41.666667%;max-width:41.666667%}.col-sm-6{-ms-flex:0 0 50%;flex:0 0 50%;max-width:50%}.col-sm-7{-ms-flex:0 0 58.333333%;flex:0 0 58.333333%;max-width:58.333333%}.col-sm-8{-ms-flex:0 0 66.666667%;flex:0 0 66.666667%;max-width:66.666667%}.col-sm-9{-ms-flex:0 0 75%;flex:0 0 75%;max-width:75%}.col-sm-10{-ms-flex:0 0 83.333333%;flex:0 0 83.333333%;max-width:83.333333%}.col-sm-11{-ms-flex:0 0 91.666667%;flex:0 0 91.666667%;max-width:91.666667%}.col-sm-12{-ms-flex:0 0 100%;flex:0 0 100%;max-width:100%}.order-sm-first{-ms-flex-order:-1;order:-1}.order-sm-last{-ms-flex-order:13;order:13}.order-sm-0{-ms-flex-order:0;order:0}.order-sm-1{-ms-flex-order:1;order:1}.order-sm-2{-ms-flex-order:2;order:2}.order-sm-3{-ms-flex-order:3;order:3}.order-sm-4{-ms-flex-order:4;order:4}.order-sm-5{-ms-flex-order:5;order:5}.order-sm-6{-ms-flex-order:6;order:6}.order-sm-7{-ms-flex-order:7;order:7}.order-sm-8{-ms-flex-order:8;order:8}.order-sm-9{-ms-flex-order:9;order:9}.order-sm-10{-ms-flex-order:10;order:10}.order-sm-11{-ms-flex-order:11;order:11}.order-sm-12{-ms-flex-order:12;order:12}.offset-sm-0{margin-left:0}.offset-sm-1{margin-left:8.333333%}.offset-sm-2{margLine truncated
|
||||
/*# sourceMappingURL=bootstrap-grid.min.css.map */
|
||||
@@ -0,0 +1,52 @@
|
||||
.application.sheet.M6 {
|
||||
.sheet-header {
|
||||
margin-top: 8px;
|
||||
margin-right: 12px;
|
||||
.profile-img {
|
||||
position: absolute;
|
||||
top: 24px;
|
||||
left: calc(50% - 50px - 6px);
|
||||
background-color: var(--M6-background-white);
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
.text {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.container {
|
||||
padding: 8px;
|
||||
background-color: var(--M6-background-grey);
|
||||
}
|
||||
}
|
||||
&.item {
|
||||
.custom-input {
|
||||
&.left {
|
||||
padding-left: 30px;
|
||||
}
|
||||
&.right {
|
||||
padding-right: 30px;
|
||||
}
|
||||
}
|
||||
|
||||
.input-icon {
|
||||
position: absolute;
|
||||
top: 40%;
|
||||
transform: translateY(-50%);
|
||||
color: #888;
|
||||
/* Prevent the icon from blocking input clicks if it's purely decorative */
|
||||
pointer-events: none;
|
||||
&.left {
|
||||
left: 18px;
|
||||
}
|
||||
&.right {
|
||||
right: 18px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.icon-checked {
|
||||
background-color: var(--M6-text-brown);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
.application.sheet.M6 {
|
||||
.collapsible {
|
||||
background-color: var(--M6-background-white);
|
||||
cursor: pointer;
|
||||
padding: 12px;
|
||||
font-size: 15px;
|
||||
margin-bottom: 4px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
&.active {
|
||||
background-color: var(--M6-background-brown);
|
||||
box-shadow: none;
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
}
|
||||
|
||||
/* Add a background color to the button if it is clicked on (add the .active class with JS), and when you move the mouse over it (hover) */
|
||||
|
||||
/* Style the collapsible content. Note: hidden by default */
|
||||
.content {
|
||||
padding: 0 18px;
|
||||
display: none;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
background-color: var(--M6-background-white);
|
||||
&.active {
|
||||
display: block;
|
||||
width: 100%;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
.sword {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
/* Das SVG wird als Maske geladen */
|
||||
mask: url("../assets/sword.svg") no-repeat center / contain;
|
||||
-webkit-mask: url("../assets/sword.svg") no-repeat center / contain;
|
||||
|
||||
/* Standardfarbe (wird durch die Maske in die Form des SVGs gepresst) */
|
||||
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);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
.application.sheet.M6.actor {
|
||||
.tab[data-tab="items"] {
|
||||
ul {
|
||||
padding-bottom: 20px;
|
||||
margin: 0;
|
||||
list-style: none;
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
.sticky-progress-container {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
background-color: #f1f1f1;
|
||||
box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
|
||||
padding: 10px 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 9999; /* Bleibt immer im Vordergrund */
|
||||
}
|
||||
|
||||
/* Der graue Hintergrund des Balkens */
|
||||
.progress-background {
|
||||
width: 90%; /* Breite des Balkens auf dem Bildschirm */
|
||||
max-width: 800px; /* Maximale Breite auf großen Bildschirmen */
|
||||
background-color: #e0e0e0;
|
||||
overflow: hidden; /* Schneidet den inneren Balken sauber ab */
|
||||
transform: skewX(-30deg);
|
||||
}
|
||||
|
||||
/* Der eigentliche, animierte Ladebalken */
|
||||
.progress-bar {
|
||||
height: 20px;
|
||||
background-color: var(--M6-background-brown); /* Grün */
|
||||
text-align: center;
|
||||
line-height: 20px;
|
||||
color: white;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
width: 100%;
|
||||
}
|
||||
progress::-moz-progress-bar {
|
||||
background: var(--M6-background-brown);
|
||||
}
|
||||
progress::-webkit-progress-value {
|
||||
background: var(--M6-background-brown);
|
||||
}
|
||||
progress {
|
||||
color: var(--M6-background-brown);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
.application.sheet.M6.actor {
|
||||
.resistenzenHeader {
|
||||
font-weight: bold;
|
||||
font-size: 16px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.resistenzenAttribut {
|
||||
max-width: 2rem;
|
||||
text-align: center;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.fa-dice-d20 {
|
||||
border-radius: 40%;
|
||||
background-color: var(--M6-background-grey);
|
||||
margin-right: -7px;
|
||||
position: relative;
|
||||
font-size: 18px;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
.application.sheet.M6 {
|
||||
section {
|
||||
&.window-content {
|
||||
backdrop-filter: blur(0rem);
|
||||
overflow: visible;
|
||||
min-height: 0;
|
||||
}
|
||||
}
|
||||
.tabs {
|
||||
border: none;
|
||||
position: absolute;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 0.625rem;
|
||||
left: calc(100% + 3px);
|
||||
top: 20%;
|
||||
|
||||
.sheet-stack {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
color: var(--M6-text-grey);
|
||||
|
||||
.container {
|
||||
position: relative;
|
||||
text-align: center;
|
||||
width: 32px;
|
||||
height: 36px;
|
||||
|
||||
.background {
|
||||
position: absolute;
|
||||
left: 0px;
|
||||
top: 0px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
mask: var(--mask-square) no-repeat center;
|
||||
background-color: var(--M6-background-grey);
|
||||
}
|
||||
|
||||
.border {
|
||||
position: absolute;
|
||||
left: 0px;
|
||||
top: 0px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: var(--M6-background-grey);
|
||||
mask: var(--mask-square) no-repeat center;
|
||||
}
|
||||
|
||||
.value {
|
||||
position: relative;
|
||||
font-family: var(--cosmere-font-header);
|
||||
font-weight: 600;
|
||||
color: var(--M6-text-brown);
|
||||
z-index: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.active {
|
||||
text-shadow: 0 0 10px var(--M6-text-brown);
|
||||
|
||||
.container {
|
||||
width: 38px;
|
||||
height: 36px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
import { systemPath } from "./constants.mjs";
|
||||
import { loadHelpers } from "./helpers/handlebar-helpers.mjs";
|
||||
import { loadPartials } from "./helpers/partials.mjs";
|
||||
import { loadSettings } from "./helpers/settings.mjs";
|
||||
|
||||
import { CharacterData } from "./data/character-data.mjs";
|
||||
import { WeaponData } from "./data/weapon-data.mjs";
|
||||
import { ItemData } from "./data/item-data.mjs";
|
||||
import { ArmorData } from "./data/armor-data.mjs";
|
||||
import { ZauberData } from "./data/zauber-data.mjs";
|
||||
import { HintergrundData } from "./data/hintergrund-data.mjs";
|
||||
import { M6ActorSheet } from "./sheets/character-sheet.mjs";
|
||||
import { M6ItemSheet } from "./sheets/item-sheet.mjs";
|
||||
import { M6WeaponSheet } from "./sheets/weapon-sheet.mjs";
|
||||
import { M6ArmorSheet } from "./sheets/armor-sheet.mjs";
|
||||
import { M6ZauberSheet } from "./sheets/zauber-sheet.mjs";
|
||||
import { M6HintergrundSheet } from "./sheets/hintergrund-sheet.mjs";
|
||||
import { M6ChatMessage } from "./ui/chat-message.mjs";
|
||||
import "./styles/M6.scss";
|
||||
|
||||
Hooks.once("init", () => {
|
||||
CONFIG.ChatMessage.documentClass = M6ChatMessage;
|
||||
CONFIG.ChatMessage.template = systemPath("templates/chat/message-default.hbs");
|
||||
|
||||
CONFIG.Actor.dataModels.character = CharacterData;
|
||||
CONFIG.Actor.trackableAttributes = {
|
||||
pc: {
|
||||
bar: ["resources.leben", "resources.ausdauer"],
|
||||
value: ["level"]
|
||||
},
|
||||
npc: {
|
||||
bar: ["resources.leben", "resources.ausdauer"],
|
||||
value: []
|
||||
}
|
||||
};
|
||||
CONFIG.Item.dataModels.item = ItemData;
|
||||
CONFIG.Item.dataModels.geld = ItemData;
|
||||
CONFIG.Item.dataModels.weapon = WeaponData;
|
||||
CONFIG.Item.dataModels.armor = ArmorData;
|
||||
CONFIG.Item.dataModels.zauber = ZauberData;
|
||||
CONFIG.Item.dataModels.hintergrund = HintergrundData;
|
||||
|
||||
foundry.applications.apps.DocumentSheetConfig.registerSheet(Actor, "midgard6-lvd", M6ActorSheet, {
|
||||
types: ["character"],
|
||||
makeDefault: true
|
||||
});
|
||||
foundry.applications.apps.DocumentSheetConfig.registerSheet(Item, "midgard6-lvd", M6ItemSheet, {
|
||||
types: ["item"],
|
||||
makeDefault: true
|
||||
});
|
||||
foundry.applications.apps.DocumentSheetConfig.registerSheet(Item, "midgard6-lvd", M6ItemSheet, {
|
||||
types: ["geld"]
|
||||
});
|
||||
foundry.applications.apps.DocumentSheetConfig.registerSheet(Item, "midgard6-lvd", M6WeaponSheet, {
|
||||
types: ["weapon"]
|
||||
});
|
||||
foundry.applications.apps.DocumentSheetConfig.registerSheet(Item, "midgard6-lvd", M6ArmorSheet, {
|
||||
types: ["armor"]
|
||||
});
|
||||
foundry.applications.apps.DocumentSheetConfig.registerSheet(Item, "midgard6-lvd", M6ZauberSheet, {
|
||||
types: ["zauber"]
|
||||
});
|
||||
foundry.applications.apps.DocumentSheetConfig.registerSheet(
|
||||
Item,
|
||||
"midgard6-lvd",
|
||||
M6HintergrundSheet,
|
||||
{
|
||||
types: ["gunst"]
|
||||
}
|
||||
);
|
||||
foundry.applications.apps.DocumentSheetConfig.registerSheet(
|
||||
Item,
|
||||
"midgard6-lvd",
|
||||
M6HintergrundSheet,
|
||||
{
|
||||
types: ["makel"]
|
||||
}
|
||||
);
|
||||
foundry.applications.apps.DocumentSheetConfig.registerSheet(
|
||||
Item,
|
||||
"midgard6-lvd",
|
||||
M6HintergrundSheet,
|
||||
{
|
||||
types: ["schicksalsgabe"]
|
||||
}
|
||||
);
|
||||
foundry.applications.apps.DocumentSheetConfig.registerSheet(
|
||||
Item,
|
||||
"midgard6-lvd",
|
||||
M6HintergrundSheet,
|
||||
{
|
||||
types: ["legende"]
|
||||
}
|
||||
);
|
||||
|
||||
loadSettings();
|
||||
|
||||
loadHelpers();
|
||||
|
||||
loadPartials();
|
||||
});
|
||||
|
||||
Hooks.on("renderChatMessageHTML", (message, html, data) => {
|
||||
const collapsible = html.querySelectorAll("div[data-action=collapsible]");
|
||||
if (collapsible) {
|
||||
collapsible.forEach((node) => {
|
||||
node.addEventListener(
|
||||
"click",
|
||||
function () {
|
||||
node.classList.toggle("active");
|
||||
var content = node.nextElementSibling;
|
||||
content.classList.toggle("active");
|
||||
node.getElementsByTagName("i")[0].classList.toggle("fa-compress");
|
||||
},
|
||||
{ capture: true }
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -1,28 +0,0 @@
|
||||
import { CharacterData } from "./data/character-data";
|
||||
import { ItemData } from "./data/item-data";
|
||||
import { CharacterSheet } from "./sheets/character-sheet";
|
||||
import { ItemSheet } from "./sheets/item-sheet";
|
||||
|
||||
Hooks.once("init", () => {
|
||||
CONFIG.Actor.dataModels.character = CharacterData;
|
||||
CONFIG.Item.dataModels.item = ItemData;
|
||||
|
||||
foundry.applications.apps.DocumentSheetConfig.registerSheet(
|
||||
Actor,
|
||||
"fvtt-ts-react-boilerplate",
|
||||
CharacterSheet,
|
||||
{
|
||||
types: ["character"],
|
||||
makeDefault: true
|
||||
}
|
||||
);
|
||||
foundry.applications.apps.DocumentSheetConfig.registerSheet(
|
||||
Item,
|
||||
"fvtt-ts-react-boilerplate",
|
||||
ItemSheet,
|
||||
{
|
||||
types: ["item"],
|
||||
makeDefault: true
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
import { CharacterData } from "../data/character-data";
|
||||
import { ItemData } from "../data/item-data";
|
||||
import { WeaponData } from "../data/weapon-data";
|
||||
import { ArmorData } from "../data/armor-data";
|
||||
import { ZauberData } from "../data/zauber-data";
|
||||
import { HintergrundData } from "../data/hintergrund-data";
|
||||
|
||||
declare module "fvtt-types/configuration" {
|
||||
interface DataModelConfig {
|
||||
Actor: { character: typeof CharacterData };
|
||||
Item: {
|
||||
item: typeof ItemData,
|
||||
weapon: typeof WeaponData,
|
||||
armor: typeof ArmorData,
|
||||
zauber: typeof ZauberData
|
||||
hintergrund: typeof HintergrundData };
|
||||
}
|
||||
}
|
||||
Vendored
-9
@@ -1,9 +0,0 @@
|
||||
import type { CharacterData } from "../data/character-data";
|
||||
import type { ItemData } from "../data/item-data";
|
||||
|
||||
declare module "fvtt-types/configuration" {
|
||||
interface DataModelConfig {
|
||||
Actor: { character: typeof CharacterData };
|
||||
Item: { item: typeof ItemData };
|
||||
}
|
||||
}
|
||||
File renamed without changes.
@@ -0,0 +1,170 @@
|
||||
// import { processMessage } from "./message-logic/process-message.js";
|
||||
|
||||
export class M6ChatMessage extends ChatMessage {
|
||||
// Default avatar for the chat message
|
||||
static DEFAULT_AVATAR = "icons/svg/mystery-man.svg";
|
||||
|
||||
/**
|
||||
* Render the HTML for the ChatMessage which should be added to the log
|
||||
* @param {object} [options] Additional options passed to the Handlebars template.
|
||||
* @param {boolean} [options.canDelete] Render a delete button. By default, this is true for GM users.
|
||||
* @param {boolean} [options.canClose] Render a close button for dismissing chat card notifications.
|
||||
* @returns {Promise<HTMLElement>}
|
||||
*/
|
||||
async renderHTML({ canDelete, canClose = false, ...rest } = {}) {
|
||||
// Default message template
|
||||
this.template = CONFIG.ChatMessage.template;
|
||||
|
||||
// By default, GM users have the trash-bin icon in the chat log itself
|
||||
canDelete ??= game.user.isGM || game.user === this.author;
|
||||
|
||||
if (typeof this.system.renderHTML === "function") {
|
||||
const html = await this.system.renderHTML({ canDelete, canClose, ...rest });
|
||||
Hooks.callAll("renderChatMessageHTML", this, html);
|
||||
return html;
|
||||
}
|
||||
// Determine some metadata
|
||||
const speakerActor = this.speakerActor;
|
||||
const data = this.toObject(false);
|
||||
if (!this.isRoll || this.isContentVisible) {
|
||||
data.content = await foundry.applications.ux.TextEditor.implementation.enrichHTML(
|
||||
data?.flags?.m6?.description || this.content,
|
||||
{
|
||||
rollData: this.getRollData(),
|
||||
secrets: speakerActor?.isOwner ?? game.user.isGM
|
||||
}
|
||||
);
|
||||
}
|
||||
const isWhisper = this.whisper.length;
|
||||
|
||||
// Construct message data
|
||||
this.messageData = {
|
||||
// Base messageData and permissions
|
||||
...rest,
|
||||
message: data,
|
||||
canDelete,
|
||||
canClose,
|
||||
isGM: game.user.isGM,
|
||||
isWhisper: this.whisper.length,
|
||||
whisperTo: this.whisper.map((u) => game.users.get(u)?.name).filterJoin(", "),
|
||||
isContentVisible: this.isContentVisible,
|
||||
|
||||
// User and author data
|
||||
user: game.user,
|
||||
author: this.author,
|
||||
|
||||
// Display info
|
||||
title: this.flags["midgard6-lvd"]?.title,
|
||||
name: this.flags["midgard6-lvd"]?.name,
|
||||
description: this.flags["midgard6-lvd"]?.description,
|
||||
alias: this.alias,
|
||||
speakerActor,
|
||||
|
||||
// If the user can't see the currently visible content, then prefer the author's avatar;
|
||||
// Otherwise, use the character's avatar (if present), and fall back to the default avatar
|
||||
// as a last resort
|
||||
portrait:
|
||||
((this.isContentVisible ? speakerActor?.img : undefined) ?? this.author?.avatar) ||
|
||||
this.constructor.DEFAULT_AVATAR,
|
||||
|
||||
// CSS classes
|
||||
cssClass: [
|
||||
this.style === CONST.CHAT_MESSAGE_STYLES.IC ? "ic" : null,
|
||||
this.style === CONST.CHAT_MESSAGE_STYLES.EMOTE ? "emote" : null,
|
||||
isWhisper ? "whisper" : null,
|
||||
this.blind ? "blind" : null
|
||||
].filterJoin(" "),
|
||||
|
||||
// System-specific flags
|
||||
eigenschaften: this.isContentVisible ? this.getFlag("midgard6-lvd", "eigenschaften") : "",
|
||||
merkmale: this.isContentVisible ? this.getFlag("midgard6-lvd", "merkmale") : "",
|
||||
beschreibung: this.isContentVisible ? this.getFlag("midgard6-lvd", "beschreibung") : "",
|
||||
zeigeZauberAlsTag: game.settings.get("midgard6-lvd", "zauberAlsTag"),
|
||||
isSpell: this.getFlag("midgard6-lvd", "isSpell"),
|
||||
isRoll: this?.isRoll || false
|
||||
};
|
||||
// Render additional message data
|
||||
if (this.isRoll) {
|
||||
await this.#renderRollContent(this.messageData);
|
||||
}
|
||||
|
||||
// Add a check in for in case modules are adding content to use that as the description
|
||||
// if (this.messageData?.message?.content) {
|
||||
// this.messageData.description = this.messageData?.message?.content;
|
||||
// }
|
||||
// Render the chat message
|
||||
let html = await foundry.applications.handlebars.renderTemplate(
|
||||
this.template,
|
||||
this.messageData
|
||||
);
|
||||
html = foundry.utils.parseHTML(html);
|
||||
// Flag expanded state of dice rolls
|
||||
Hooks.callAll("renderChatMessageHTML", this, html, this.messageData);
|
||||
|
||||
// Get whether descriptions should auto-expand for this user or not and apply the styling
|
||||
const autoExpand = game.settings.get("midgard6-lvd", "beschreibungChatActive");
|
||||
if (autoExpand) {
|
||||
const collapsibleContent = html.querySelector(".collapsible.beschreibung");
|
||||
if (collapsibleContent) {
|
||||
collapsibleContent.classList.toggle("active");
|
||||
var content = collapsibleContent.nextElementSibling;
|
||||
content.classList.toggle("active");
|
||||
collapsibleContent.getElementsByTagName("i")[0].classList.toggle("fa-compress");
|
||||
}
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
// Code pulled from core since this is a private method as of V13
|
||||
async #renderRollContent(messageData) {
|
||||
const data = messageData.message;
|
||||
const renderRolls = async (isPrivate) => {
|
||||
let html = "";
|
||||
let content = [];
|
||||
|
||||
for (const roll of this.rolls) {
|
||||
html = await roll.render({
|
||||
isPrivate
|
||||
});
|
||||
content.push({ options: roll.options, html });
|
||||
}
|
||||
return content;
|
||||
};
|
||||
|
||||
// Suppress the "to:" whisper flavor for private rolls
|
||||
if (this.blind || this.whisper.length) messageData.isWhisper = false;
|
||||
|
||||
// Display standard Roll HTML content
|
||||
if (this.isContentVisible) {
|
||||
const el = document.createElement("div");
|
||||
el.innerHTML = data.content; // Ensure the content does not already contain custom HTML
|
||||
if (!el.childElementCount && this.rolls.length) {
|
||||
data.content = await this.#renderRollHTML(false);
|
||||
}
|
||||
} else {
|
||||
// Otherwise, show "rolled privately" messages for Roll content
|
||||
const name = this.author?.name ?? game.i18n.localize("CHAT.UnknownUser");
|
||||
data.flavor = game.i18n.format("CHAT.PrivateRollContent", {
|
||||
user: foundry.utils.escapeHTML(name)
|
||||
});
|
||||
data.content = await renderRolls(true);
|
||||
messageData.alias = name;
|
||||
}
|
||||
}
|
||||
|
||||
async #renderRollHTML(isPrivate) {
|
||||
let html = "";
|
||||
let content = [];
|
||||
|
||||
for (const roll of this.rolls) {
|
||||
html = await roll.render({
|
||||
isPrivate,
|
||||
message: this
|
||||
});
|
||||
content.push({ options: roll.options, html });
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user