Item merkmale
This commit is contained in:
1 parent
e4eecb7b8e
commit
9964948e31
17 files changed
+148
-41
No files matched your search
@@ -12,7 +12,8 @@ export class M6ArmorSheet extends M6ItemSheet {
|
||||
...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
|
||||
cycleEquip: this.#cycleEquip, // Fügt NUR für dieses Sheet die neue Action hinzu
|
||||
cycleHelmet: this.#cycleHelmet
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -67,4 +68,12 @@ export class M6ArmorSheet extends M6ItemSheet {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static #cycleHelmet() {
|
||||
this.item.update({
|
||||
system: {
|
||||
zusätzlich: !this.item.system.zusätzlich
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -113,7 +113,6 @@ export class M6ActorSheet extends api.HandlebarsApplicationMixin(sheets.ActorShe
|
||||
/** @inheritdoc */
|
||||
async _prepareContext(options) {
|
||||
const context = await super._prepareContext(options);
|
||||
await prepArmor(this.actor);
|
||||
|
||||
Object.assign(context, {
|
||||
owner: this.document.isOwner,
|
||||
@@ -138,6 +137,7 @@ export class M6ActorSheet extends api.HandlebarsApplicationMixin(sheets.ActorShe
|
||||
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);
|
||||
@@ -267,9 +267,7 @@ export class M6ActorSheet extends api.HandlebarsApplicationMixin(sheets.ActorShe
|
||||
}
|
||||
|
||||
static async #cycleEquip(event, target) {
|
||||
console.warn(target.dataset);
|
||||
const item = this.actor.items.get(target.dataset.itemId);
|
||||
console.warn(item);
|
||||
item.update({
|
||||
system: {
|
||||
equipped: !item.system.equipped
|
||||
@@ -641,7 +639,6 @@ export class M6ActorSheet extends api.HandlebarsApplicationMixin(sheets.ActorShe
|
||||
document.querySelectorAll('input[name="vorteil-segment"]').forEach((radio) => {
|
||||
radio.addEventListener("change", (e) => {
|
||||
vorteil = parseInt(e.target.value);
|
||||
console.log(vorteil);
|
||||
switch (vorteil) {
|
||||
case 1:
|
||||
display.placeholder = `2d20kh + ${skillValue} (Vorteil)`;
|
||||
@@ -658,7 +655,6 @@ export class M6ActorSheet extends api.HandlebarsApplicationMixin(sheets.ActorShe
|
||||
|
||||
document.querySelectorAll('input[name="spezialisierung-segment"]').forEach((radio) => {
|
||||
radio.addEventListener("change", (e) => {
|
||||
console.log(e.target.dataset.name);
|
||||
spezLevel = parseInt(e.target.value);
|
||||
spezName = e.target.dataset.name;
|
||||
});
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
export async function prepArmor(actor) {
|
||||
const actorData = actor.system;
|
||||
|
||||
// 1. Basis-Wert festlegen
|
||||
let baseRüstwert = actorData.rüstwert || 0;
|
||||
|
||||
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
|
||||
@@ -12,13 +10,27 @@ export async function prepArmor(actor) {
|
||||
(i) => i.type === "armor" && i.system.equipped && i.system.zusätzlich
|
||||
);
|
||||
let armorBonus = Math.max(...equippedMainArmor.map((x) => x.system.rüstwert), 0);
|
||||
|
||||
for (let armor of equippedAddArmor) {
|
||||
armorBonus += armor.system.rüstwert;
|
||||
}
|
||||
|
||||
// 3. Finalen Standard-Wert berechnen
|
||||
actorData.rüstwert = baseRüstwert + armorBonus;
|
||||
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) {
|
||||
@@ -45,7 +57,6 @@ export async function prepSpells(actor) {
|
||||
const spellItems = actor.items.filter((x) => x.type === "zauber" && x.system.equipped);
|
||||
const spells = [];
|
||||
const skill = foundry.utils.getProperty(actor, "system.skills.magie.zaubern");
|
||||
console.warn(skill, spellItems);
|
||||
spellItems.forEach((spell) => {
|
||||
const w = {
|
||||
name: spell.name,
|
||||
@@ -63,7 +74,7 @@ export async function prepSpells(actor) {
|
||||
}
|
||||
|
||||
export async function prepWeight(actor) {
|
||||
const items = actor.items.filter((x) => x.system.gewicht);
|
||||
const items = actor.items.filter((x) => x.system.gewicht && !x.system.equipped);
|
||||
let gewicht = items.reduce((accumulator, item) => accumulator + item.system.gewicht, 0);
|
||||
|
||||
let traglast = Math.max(actor.system.skills.körper.athletik.value, 10);
|
||||
|
||||
@@ -69,6 +69,30 @@ export class M6ItemSheet extends api.HandlebarsApplicationMixin(sheets.ItemSheet
|
||||
}
|
||||
};
|
||||
|
||||
_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.id}`]: value.split(/[\s,]+/) });
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- */
|
||||
|
||||
/** @inheritdoc */
|
||||
@@ -96,7 +120,6 @@ export class M6ItemSheet extends api.HandlebarsApplicationMixin(sheets.ItemSheet
|
||||
itemFields: this.item.schema.fields,
|
||||
config: CONFIG
|
||||
});
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
@@ -130,6 +153,7 @@ export class M6ItemSheet extends api.HandlebarsApplicationMixin(sheets.ItemSheet
|
||||
await this._addSpecifics(context);
|
||||
context.tab = context.tabs[partId];
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
@@ -342,7 +366,6 @@ export class M6ItemSheet extends api.HandlebarsApplicationMixin(sheets.ItemSheet
|
||||
async _onDrop(event) {
|
||||
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event);
|
||||
const item = this.item;
|
||||
console.warn(data.type);
|
||||
|
||||
const allowed = Hooks.call("dropItemSheetData", item, this, data);
|
||||
// if (allowed === false) return;
|
||||
@@ -446,10 +469,8 @@ export class M6ItemSheet extends api.HandlebarsApplicationMixin(sheets.ItemSheet
|
||||
// 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;
|
||||
console.warn(isSameActor);
|
||||
|
||||
if (isSameActor) {
|
||||
console.warn("here");
|
||||
// Sortieren, nicht kopieren/verschieben
|
||||
return this._onSortItem(event, item);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ export class M6WeaponSheet extends M6ItemSheet {
|
||||
...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
|
||||
cycleEquip: this.#cycleEquip
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -55,7 +55,6 @@ export class M6ZauberSheet extends M6ItemSheet {
|
||||
async _addSpecifics(context) {
|
||||
context.zauberFields = await this._getFields();
|
||||
context.bonuses = foundry.utils.getProperty(this.actor, "system.skills.magie.zaubern").bonuses;
|
||||
console.warn(context);
|
||||
}
|
||||
|
||||
static #cycleEquip() {
|
||||
|
||||
Reference in new issue
Block a user