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,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) };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user