Merge branch 'develop'
This commit is contained in:
+40
-47
@@ -92,14 +92,14 @@ Hooks.once("init", async () => {
|
||||
|
||||
Handlebars.registerHelper("count", (object: any) => {
|
||||
var length = 0;
|
||||
for( var key in object ) {
|
||||
if( object.hasOwnProperty(key) ) {
|
||||
for (var key in object) {
|
||||
if (object.hasOwnProperty(key)) {
|
||||
++length;
|
||||
}
|
||||
}
|
||||
return length;
|
||||
});
|
||||
|
||||
|
||||
// Default Sheet für Items definieren und das Standardsheet deaktivieren
|
||||
Items.unregisterSheet("core", ItemSheet);
|
||||
Items.registerSheet("midgard5", M5ItemSheet, { makeDefault: true });
|
||||
@@ -124,12 +124,10 @@ Hooks.on("getChatLogEntryContext", function (html, options) {
|
||||
name: "LP & AP Schaden",
|
||||
icon: '<i class="fas fa-tint"></i>',
|
||||
condition: (li) => {
|
||||
// Only show this context menu if there are re-rollable dice in the message
|
||||
const damageRolls = li.find(".apply-damage").length;
|
||||
const damageRolls = li.find(".damage").length;
|
||||
|
||||
// All must be true to show the reroll dialogue
|
||||
// The button doesn't work for the GM right now, so we don't need to show it
|
||||
return game["user"].character && damageRolls > 0;
|
||||
return (game["user"].character || game["canvas"].tokens.controlled) && damageRolls > 0;
|
||||
},
|
||||
callback: (li) => applyDamage(li, 2),
|
||||
},
|
||||
@@ -137,12 +135,10 @@ Hooks.on("getChatLogEntryContext", function (html, options) {
|
||||
name: "AP Schaden",
|
||||
icon: '<i class="fas fa-shield-alt"></i>',
|
||||
condition: (li) => {
|
||||
// Only show this context menu if there are re-rollable dice in the message
|
||||
const damageRolls = li.find(".apply-damage").length;
|
||||
const damageRolls = li.find(".damage").length;
|
||||
|
||||
// All must be true to show the reroll dialogue
|
||||
// The button doesn't work for the GM right now, so we don't need to show it
|
||||
return game["user"].character && damageRolls > 0;
|
||||
return (game["user"].character || game["canvas"].tokens.controlled) && damageRolls > 0;
|
||||
},
|
||||
callback: (li) => applyDamage(li, 1),
|
||||
},
|
||||
@@ -150,12 +146,10 @@ Hooks.on("getChatLogEntryContext", function (html, options) {
|
||||
name: "LP & AP Heilen",
|
||||
icon: '<i class="fas fa-heart"></i>',
|
||||
condition: (li) => {
|
||||
// Only show this context menu if there are re-rollable dice in the message
|
||||
const damageRolls = li.find(".apply-damage").length;
|
||||
const damageRolls = li.find(".heal").length;
|
||||
|
||||
// All must be true to show the reroll dialogue
|
||||
// The button doesn't work for the GM right now, so we don't need to show it
|
||||
return game["user"].character && damageRolls > 0;
|
||||
return (game["user"].character || game["canvas"].tokens.controlled) && damageRolls > 0;
|
||||
},
|
||||
callback: (li) => applyDamage(li, -1),
|
||||
},
|
||||
@@ -163,12 +157,10 @@ Hooks.on("getChatLogEntryContext", function (html, options) {
|
||||
name: "AP Heilen",
|
||||
icon: '<i class="far fa-heart"></i>',
|
||||
condition: (li) => {
|
||||
// Only show this context menu if there are re-rollable dice in the message
|
||||
const damageRolls = li.find(".apply-damage").length;
|
||||
const damageRolls = li.find(".heal").length;
|
||||
|
||||
// All must be true to show the reroll dialogue
|
||||
// The button doesn't work for the GM right now, so we don't need to show it
|
||||
return game["user"].character && damageRolls > 0;
|
||||
return (game["user"].character || game["canvas"].tokens.controlled) && damageRolls > 0;
|
||||
},
|
||||
callback: (li) => applyDamage(li, -2),
|
||||
}
|
||||
@@ -219,15 +211,6 @@ Hooks.on("updateCombat", function (combat: Combat, updateData: { round: number;
|
||||
}
|
||||
});
|
||||
|
||||
function limitHeal(heal: number, current: number, max: number): number {
|
||||
if (current === max) {
|
||||
return 0;
|
||||
} else if (heal + current > max) {
|
||||
return max - current;
|
||||
}
|
||||
return heal;
|
||||
}
|
||||
|
||||
Hooks.on("renderCombatTracker", (combatTracker, html, context) => {
|
||||
if (context.combat === null) {
|
||||
html.find("h3.encounter-title")[0].innerHTML = game["i18n"].localize("midgard5.no-encounter");
|
||||
@@ -244,27 +227,28 @@ Hooks.once("ready", () => {
|
||||
});
|
||||
|
||||
async function applyDamage(roll, direction) {
|
||||
const damageValue = Array.from(roll.find(".apply-damage") as HTMLElement[])
|
||||
const damageValue = Array.from(roll.find(".apply") as HTMLElement[])
|
||||
.map((x) => Math.max(0, Number(x.innerText)))
|
||||
.reduce((prev, curr) => prev + curr, 0);
|
||||
const userId = game["user"].character.id;
|
||||
const viewedSceneId = game["user"].viewedScene;
|
||||
const token = game["actors"].get(userId).getDependentTokens(viewedSceneId)[0]?.delta.syntheticActor;
|
||||
const controlledTokens = game["canvas"].tokens.controlled;
|
||||
const actor = game["user"].character;
|
||||
|
||||
if (token) {
|
||||
switch (direction) {
|
||||
case 2:
|
||||
token["system"].lp.value -= Math.max(0, damageValue - token["system"].calc.stats.lpProtection.value);
|
||||
case 1:
|
||||
token["system"].ap.value -= Math.max(0, damageValue - token["system"].calc.stats.apProtection.value);
|
||||
break;
|
||||
case -1:
|
||||
token["system"].lp.value += limitHeal(damageValue, token["system"].lp.value, token["system"].lp.max);
|
||||
case -2:
|
||||
token["system"].ap.value += limitHeal(damageValue, token["system"].ap.value, token["system"].ap.max);
|
||||
}
|
||||
token.render();
|
||||
if (controlledTokens) {
|
||||
controlledTokens.forEach((controlledToken) => {
|
||||
let token = controlledToken.document.delta.syntheticActor;
|
||||
switch (direction) {
|
||||
case 2:
|
||||
token["system"].lp.value -= Math.max(0, damageValue - token["system"].calc.stats.lpProtection.value);
|
||||
case 1:
|
||||
token["system"].ap.value -= Math.max(0, damageValue - token["system"].calc.stats.apProtection.value);
|
||||
break;
|
||||
case -1:
|
||||
token["system"].lp.value += limitHeal(damageValue, token["system"].lp.value, token["system"].lp.max);
|
||||
case -2:
|
||||
token["system"].ap.value += limitHeal(damageValue, token["system"].ap.value, token["system"].ap.max);
|
||||
}
|
||||
token.render();
|
||||
});
|
||||
} else {
|
||||
switch (direction) {
|
||||
case 2:
|
||||
@@ -273,10 +257,19 @@ async function applyDamage(roll, direction) {
|
||||
actor["system"].ap.value -= Math.max(0, damageValue - actor["system"].calc.stats.apProtection.value);
|
||||
break;
|
||||
case -1:
|
||||
actor["system"].lp.value += limitHeal(damageValue, token["system"].lp.value, token["system"].lp.max);
|
||||
actor["system"].lp.value += limitHeal(damageValue, actor["system"].lp.value, actor["system"].lp.max);
|
||||
case -2:
|
||||
actor["system"].ap.value += limitHeal(damageValue, token["system"].ap.value, token["system"].ap.max);
|
||||
actor["system"].ap.value += limitHeal(damageValue, actor["system"].ap.value, actor["system"].ap.max);
|
||||
}
|
||||
actor.render();
|
||||
}
|
||||
}
|
||||
|
||||
function limitHeal(heal: number, current: number, max: number): number {
|
||||
if (current === max) {
|
||||
return 0;
|
||||
} else if (heal + current > max) {
|
||||
return max - current;
|
||||
}
|
||||
return heal;
|
||||
}
|
||||
|
||||
@@ -61,6 +61,13 @@ export enum M5ItemType {
|
||||
EFFECT = "effect",
|
||||
}
|
||||
|
||||
export enum M5SkillType {
|
||||
INNATE = "innate",
|
||||
GENERAL = "general",
|
||||
LANGUAGE = "language",
|
||||
COMBAT = "combat",
|
||||
}
|
||||
|
||||
export enum M5EwResult {
|
||||
TBD = "",
|
||||
FUMBLE = "roll-ew-result-fumble",
|
||||
@@ -102,6 +109,11 @@ export enum M5Stats {
|
||||
HOARD_NEXT = "hoardNext",
|
||||
HOARD_MIN = "hoardMin",
|
||||
WEALTH = "wealth",
|
||||
LOAD = "load",
|
||||
HEAVY_LOAD = "heavyLoad",
|
||||
LOAD_MAX = "loadMax",
|
||||
THRUST_LOAD = "thrustLoad",
|
||||
ENCUMBRANCE = "encumbrance",
|
||||
}
|
||||
|
||||
export enum M5ModType {
|
||||
@@ -193,6 +205,11 @@ export interface M5CharacterCalculatedData {
|
||||
hoardNext: number;
|
||||
hoardMin: number;
|
||||
wealth: number;
|
||||
load: number;
|
||||
heavyLoad: number;
|
||||
loadMax: number;
|
||||
thrustLoad: number;
|
||||
encumbrance: number;
|
||||
};
|
||||
skillMods: {};
|
||||
skills: {
|
||||
|
||||
+341
-154
@@ -1,5 +1,18 @@
|
||||
import { M5Item } from "../items/M5Item";
|
||||
import { M5Attribute, M5CharacterCalculatedData, M5ItemMod, M5ItemType, M5ModOperation, M5ModResult, M5RollData, M5Skill, M5SkillCalculated, M5SkillLearned } from "../M5Base";
|
||||
import {
|
||||
M5Attribute,
|
||||
M5CharacterCalculatedData,
|
||||
M5ItemMod,
|
||||
M5ItemType,
|
||||
M5ModOperation,
|
||||
M5ModResult,
|
||||
M5ModType,
|
||||
M5RollData,
|
||||
M5Skill,
|
||||
M5SkillCalculated,
|
||||
M5SkillLearned,
|
||||
M5SkillType,
|
||||
} from "../M5Base";
|
||||
import M5ModAggregate from "./M5ModAggregate";
|
||||
export class M5Character extends Actor {
|
||||
// constructor(
|
||||
@@ -23,18 +36,64 @@ export class M5Character extends Actor {
|
||||
return -2;
|
||||
}
|
||||
|
||||
static loadValue(attribute: M5Attribute) {
|
||||
const value = this.attributeMinMax(attribute);
|
||||
if (value > 99) return 35;
|
||||
if (value > 95) return 30;
|
||||
if (value > 80) return 25;
|
||||
if (value > 60) return 20;
|
||||
if (value > 30) return 15;
|
||||
if (value > 10) return 10;
|
||||
if (value > 0) return 5;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static heavyLoadValue(attribute: M5Attribute) {
|
||||
const value = this.attributeMinMax(attribute);
|
||||
if (value > 99) return 50;
|
||||
if (value > 95) return 45;
|
||||
if (value > 80) return 40;
|
||||
if (value > 60) return 35;
|
||||
if (value > 30) return 30;
|
||||
if (value > 10) return 25;
|
||||
if (value > 0) return 20;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static maxLoadValue(attribute: M5Attribute) {
|
||||
const value = this.attributeMinMax(attribute);
|
||||
if (value > 99) return 90;
|
||||
if (value > 95) return 80;
|
||||
if (value > 80) return 75;
|
||||
if (value > 60) return 70;
|
||||
if (value > 30) return 60;
|
||||
if (value > 10) return 50;
|
||||
if (value > 0) return 40;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static thrustLoadValue(attribute: M5Attribute) {
|
||||
const value = this.attributeMinMax(attribute);
|
||||
if (value > 99) return 200;
|
||||
if (value > 95) return 170;
|
||||
if (value > 80) return 150;
|
||||
if (value > 60) return 140;
|
||||
if (value > 30) return 120;
|
||||
if (value > 10) return 70;
|
||||
if (value > 0) return 50;
|
||||
return 0;
|
||||
}
|
||||
|
||||
derivedData(
|
||||
skip: {
|
||||
mods?: boolean;
|
||||
skills?: boolean;
|
||||
weapons?: boolean;
|
||||
defensiveWeapons?: boolean;
|
||||
armor?: boolean;
|
||||
items?: boolean;
|
||||
containers?: boolean;
|
||||
spells?: boolean;
|
||||
effects?: boolean;
|
||||
containers?: boolean;
|
||||
kampfkuenste?: boolean;
|
||||
encumbrance?: boolean;
|
||||
} = {}
|
||||
): M5CharacterCalculatedData {
|
||||
let ret: M5CharacterCalculatedData = {
|
||||
@@ -72,6 +131,11 @@ export class M5Character extends Actor {
|
||||
drinking: { value: 0, mods: [] },
|
||||
drinkingFW: 0,
|
||||
hoard: 0,
|
||||
encumbrance: 0,
|
||||
load: 0,
|
||||
heavyLoad: 0,
|
||||
thrustLoad: 0,
|
||||
loadMax: 0,
|
||||
},
|
||||
skillMods: {},
|
||||
skills: {
|
||||
@@ -149,6 +213,11 @@ export class M5Character extends Actor {
|
||||
ret.stats.hoardNext = M5Character.levelThreshold.at(ret.level) / 2;
|
||||
ret.stats.wealth = parseFloat((data.info.gold + data.info.silver / 10 + data.info.copper / 100).toPrecision(3));
|
||||
ret.stats.hoard = 0;
|
||||
ret.stats.load = M5Character.loadValue(data.attributes.st);
|
||||
ret.stats.heavyLoad = M5Character.heavyLoadValue(data.attributes.st);
|
||||
ret.stats.loadMax = M5Character.maxLoadValue(data.attributes.st);
|
||||
ret.stats.thrustLoad = M5Character.thrustLoadValue(data.attributes.st);
|
||||
ret.stats.encumbrance = 0;
|
||||
|
||||
if (!skip?.mods) {
|
||||
const aggregate = new M5ModAggregate(data, ret);
|
||||
@@ -167,54 +236,10 @@ export class M5Character extends Actor {
|
||||
ret.skillMods = aggregate.calculate();
|
||||
}
|
||||
|
||||
if (!skip?.items) {
|
||||
context.items
|
||||
?.filter((item) => item.type === "item")
|
||||
.forEach((item) => {
|
||||
item.prepareDerivedData();
|
||||
|
||||
let label = item.name;
|
||||
if (item.system.magic) {
|
||||
label += "*";
|
||||
}
|
||||
if (item.system.valuable) {
|
||||
ret.stats.wealth += this.calculateValue(item.system.value * item.system.quantity, item.system.currency);
|
||||
}
|
||||
if (item.system.hoarded) {
|
||||
ret.stats.hoard += this.calculateValue(item.system.value * item.system.quantity, item.system.currency);
|
||||
}
|
||||
|
||||
let icon = item.img;
|
||||
let rollable = false;
|
||||
|
||||
for (let key in item.system.rolls.formulas) {
|
||||
rollable = item.system.rolls.formulas[key]?.enabled;
|
||||
if (rollable) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ret.gear.items[item.id] = {
|
||||
label: label,
|
||||
icon: icon,
|
||||
magic: item.system.magic,
|
||||
calc: item.system.calc,
|
||||
equipped: item.system?.equipped,
|
||||
valuable: item.system?.valuable,
|
||||
hoarded: item.system?.hoarded,
|
||||
weight: item.system.weight || 0,
|
||||
containerId: item.system.containerId || "",
|
||||
value: item.system.value || 0,
|
||||
currency: item.system.currency || "",
|
||||
quantity: item.system.quantity || 0,
|
||||
rollExist: rollable,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
if (!skip?.containers) {
|
||||
context.items
|
||||
?.filter((item) => item.type === "container")
|
||||
.sort((a, b) => a?.sort - b?.sort)
|
||||
.forEach((item) => {
|
||||
item.prepareDerivedData();
|
||||
|
||||
@@ -222,6 +247,7 @@ export class M5Character extends Actor {
|
||||
if (item.system.magic) {
|
||||
label += "*";
|
||||
}
|
||||
|
||||
let icon = item.img;
|
||||
let rollable = false;
|
||||
|
||||
@@ -249,8 +275,247 @@ export class M5Character extends Actor {
|
||||
}
|
||||
|
||||
if (!skip?.items) {
|
||||
context.items
|
||||
?.filter((item) => item.type === "item")
|
||||
.sort((a, b) => a?.sort - b?.sort)
|
||||
.forEach((item) => {
|
||||
item.prepareDerivedData();
|
||||
|
||||
let label = item.name;
|
||||
if (item.system.magic) {
|
||||
label += "*";
|
||||
}
|
||||
if (item.system.valuable) {
|
||||
ret.stats.wealth += parseFloat(this.calculateValue(item.system.value * item.system.quantity, item.system.currency).toPrecision(3));
|
||||
}
|
||||
if (item.system.hoarded) {
|
||||
ret.stats.hoard += parseFloat(this.calculateValue(item.system.value * item.system.quantity, item.system.currency).toPrecision(3));
|
||||
}
|
||||
|
||||
if (!!item.system.containerId) {
|
||||
ret.gear.containers[item.system.containerId].weight += parseFloat((item.system.weight * item.system.quantity).toPrecision(4));
|
||||
if (ret.gear.containers[item.system.containerId].equipped) {
|
||||
ret.stats.encumbrance += item.system.weight * item.system.quantity;
|
||||
}
|
||||
} else if (item.system.equipped) {
|
||||
ret.stats.encumbrance += item.system.weight * item.system.quantity;
|
||||
}
|
||||
|
||||
let icon = item.img;
|
||||
let rollable = false;
|
||||
|
||||
// console.log(item.system.rolls.formulas.map((p) => p.enabled));
|
||||
for (let key in item.system.rolls.formulas) {
|
||||
rollable = item.system.rolls.formulas[key]?.enabled;
|
||||
if (rollable) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ret.gear.items[item.id] = {
|
||||
label: label,
|
||||
icon: icon,
|
||||
magic: item.system.magic,
|
||||
calc: item.system.calc,
|
||||
equipped: item.system?.equipped,
|
||||
valuable: item.system?.valuable,
|
||||
hoarded: item.system?.hoarded,
|
||||
weight: item.system.weight || 0,
|
||||
containerId: item.system.containerId || "",
|
||||
value: item.system.value || 0,
|
||||
currency: item.system.currency || "",
|
||||
quantity: item.system.quantity || 0,
|
||||
rollExist: rollable,
|
||||
};
|
||||
});
|
||||
|
||||
context.items
|
||||
?.filter((item) => item.type === "weapon")
|
||||
.sort((a, b) => a?.sort - b?.sort)
|
||||
.forEach((item) => {
|
||||
item.prepareDerivedData();
|
||||
|
||||
let label = item.name;
|
||||
if (item.system.magic) {
|
||||
label +=
|
||||
"*(" +
|
||||
(item.system.stats.attackBonus < 0 ? "" : "+") +
|
||||
item.system.stats.attackBonus +
|
||||
"/" +
|
||||
(item.system.stats.damageBonus < 0 ? "" : "+") +
|
||||
item.system.stats.damageBonus +
|
||||
")";
|
||||
}
|
||||
if (item.system.valuable) {
|
||||
ret.stats.wealth += this.calculateValue(item.system.value * item.system.quantity, item.system.currency);
|
||||
}
|
||||
if (item.system.hoarded) {
|
||||
ret.stats.hoard += this.calculateValue(item.system.value * item.system.quantity, item.system.currency);
|
||||
}
|
||||
if (!!item.system.containerId) {
|
||||
ret.gear.containers[item.system.containerId].weight += item.system.weight;
|
||||
if (ret.gear.containers[item.system.containerId].equipped) {
|
||||
ret.stats.encumbrance += item.system.weight;
|
||||
}
|
||||
} else if (item.system.equipped) {
|
||||
ret.stats.encumbrance += item.system.weight || 0;
|
||||
}
|
||||
|
||||
ret.gear.weapons[item.id] = {
|
||||
label: label,
|
||||
skillId: item.system.skillId,
|
||||
magic: item.system.magic,
|
||||
valuable: item.system?.valuable,
|
||||
hoarded: item.system?.hoarded,
|
||||
value: item.system.value || 0,
|
||||
currency: item.system.currency || "",
|
||||
calc: item.system.calc,
|
||||
special: item.system.special,
|
||||
damageBase: item.system.damageBase,
|
||||
equipped: item.system?.equipped,
|
||||
weight: item.system.weight || 0,
|
||||
containerId: item.system.containerId || "",
|
||||
};
|
||||
});
|
||||
|
||||
context.items
|
||||
?.filter((item) => item.type === "defensiveWeapon")
|
||||
.sort((a, b) => a?.sort - b?.sort)
|
||||
.forEach((item) => {
|
||||
item.prepareDerivedData();
|
||||
|
||||
let label = item.name;
|
||||
if (item.system.magic) {
|
||||
label += "*(" + (item.system.stats.defenseBonus < 0 ? "" : "+") + item.system.stats.defenseBonus + ")";
|
||||
}
|
||||
if (item.system.valuable) {
|
||||
ret.stats.wealth += this.calculateValue(item.system.value * item.system.quantity, item.system.currency);
|
||||
}
|
||||
if (item.system.hoarded) {
|
||||
ret.stats.hoard += this.calculateValue(item.system.value * item.system.quantity, item.system.currency);
|
||||
}
|
||||
if (!!item.system.containerId) {
|
||||
ret.gear.containers[item.system.containerId].weight += item.system.weight;
|
||||
if (ret.gear.containers[item.system.containerId].equipped) {
|
||||
ret.stats.encumbrance += item.system.weight;
|
||||
}
|
||||
} else if (item.system.equipped) {
|
||||
ret.stats.encumbrance += item.system.weight || 0;
|
||||
}
|
||||
|
||||
ret.gear.defensiveWeapons[item.id] = {
|
||||
label: label,
|
||||
skillId: item.system.skillId,
|
||||
magic: item.system.magic,
|
||||
valuable: item.system?.valuable,
|
||||
hoarded: item.system?.hoarded,
|
||||
value: item.system.value || 0,
|
||||
currency: item.system.currency || "",
|
||||
defenseBonus: item.system.stats.defenseBonus,
|
||||
calc: item.system.calc,
|
||||
equipped: item.system?.equipped,
|
||||
weight: item.system.weight || 0,
|
||||
containerId: item.system.containerId || "",
|
||||
};
|
||||
});
|
||||
|
||||
context.items
|
||||
?.filter((item) => item.type === "armor")
|
||||
.sort((a, b) => a?.sort - b?.sort)
|
||||
.forEach((item) => {
|
||||
item.prepareDerivedData();
|
||||
|
||||
let label = item.name;
|
||||
if (item.system.magic) {
|
||||
label += "*";
|
||||
}
|
||||
if (item.system.valuable) {
|
||||
ret.stats.wealth += this.calculateValue(item.system.value * item.system.quantity, item.system.currency);
|
||||
}
|
||||
if (item.system.hoarded) {
|
||||
ret.stats.hoard += this.calculateValue(item.system.value * item.system.quantity, item.system.currency);
|
||||
}
|
||||
if (!!item.system.containerId) {
|
||||
ret.gear.containers[item.system.containerId].weight += item.system.weight;
|
||||
if (ret.gear.containers[item.system.containerId].equipped) {
|
||||
ret.stats.encumbrance += item.system.weight;
|
||||
}
|
||||
} else if (item.system.equipped) {
|
||||
ret.stats.encumbrance += 0;
|
||||
} else {
|
||||
ret.stats.encumbrance += item.system.weight || 0;
|
||||
}
|
||||
|
||||
ret.gear.armor[item.id] = {
|
||||
label: label,
|
||||
magic: item.system.magic,
|
||||
valuable: item.system?.valuable,
|
||||
hoarded: item.system?.hoarded,
|
||||
value: item.system.value || 0,
|
||||
currency: item.system.currency || "",
|
||||
lpProtection: item.system.lpProtection,
|
||||
calc: item.system.calc,
|
||||
equipped: item.system?.equipped,
|
||||
weight: item.system.weight || 0,
|
||||
containerId: item.system.containerId || "",
|
||||
};
|
||||
});
|
||||
|
||||
// if (!skip?.encumbrance) {
|
||||
// const item = context.items.filter((x) => x.name === "Belastung");
|
||||
// if (ret.stats.encumbrance > ret.stats.heavyLoad) {
|
||||
// if (item.length === 0) {
|
||||
// this.createEffect("Belastung", [{ id: "movement", operation: M5ModOperation.DIVISION, type: M5ModType.STAT, value: 2 }]);
|
||||
// } else if (item.length === 1) {
|
||||
// item[0].update({
|
||||
// data: {
|
||||
// equipped: true,
|
||||
// },
|
||||
// });
|
||||
// } else if (item.length === 2) {
|
||||
// item[1]?.delete();
|
||||
// }
|
||||
// } else if (ret.stats.encumbrance <= ret.stats.heavyLoad) {
|
||||
// if (item.length === 1) {
|
||||
// item[0]?.update({
|
||||
// data: {
|
||||
// equipped: false,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (!skip?.encumbrance) {
|
||||
// const item = context.items.filter((x) => x.name === "Höchstlast");
|
||||
// if (ret.stats.encumbrance > ret.stats.loadMax) {
|
||||
// if (item.length === 0) {
|
||||
// this.createEffect("Höchstlast", [{ id: "ap", operation: M5ModOperation.SUBTRACT, type: M5ModType.STAT, value: 1 }]);
|
||||
// } else if (item.length === 1) {
|
||||
// item[0].update({
|
||||
// data: {
|
||||
// equipped: true,
|
||||
// },
|
||||
// });
|
||||
// } else if (item.length === 2) {
|
||||
// item[1]?.delete();
|
||||
// }
|
||||
// } else if (ret.stats.encumbrance <= ret.stats.loadMax) {
|
||||
// if (item.length === 1) {
|
||||
// item[0]?.update({
|
||||
// data: {
|
||||
// equipped: false,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
if (!skip?.effects) {
|
||||
context.items
|
||||
?.filter((item) => item.type === "effect")
|
||||
.sort((a, b) => a?.sort - b?.sort)
|
||||
.forEach((item) => {
|
||||
item.prepareDerivedData();
|
||||
|
||||
@@ -272,6 +537,7 @@ export class M5Character extends Actor {
|
||||
if (!skip?.skills) {
|
||||
context.items
|
||||
?.filter((item) => item.type === "skill")
|
||||
.sort((a, b) => a?.sort - b?.sort)
|
||||
.forEach((item) => {
|
||||
item.prepareDerivedData();
|
||||
const skillMap = ret.skills[item.system.type];
|
||||
@@ -282,118 +548,23 @@ export class M5Character extends Actor {
|
||||
pp: item.system.pp,
|
||||
calc: item.system.calc,
|
||||
} as M5SkillCalculated;
|
||||
});
|
||||
}
|
||||
|
||||
if (!skip?.weapons) {
|
||||
context.items
|
||||
?.filter((item) => item.type === "weapon")
|
||||
.forEach((item) => {
|
||||
item.prepareDerivedData();
|
||||
|
||||
let label = item.name;
|
||||
if (item.system.magic) {
|
||||
label +=
|
||||
"*(" +
|
||||
(item.system.stats.attackBonus < 0 ? "" : "+") +
|
||||
item.system.stats.attackBonus +
|
||||
"/" +
|
||||
(item.system.stats.damageBonus < 0 ? "" : "+") +
|
||||
item.system.stats.damageBonus +
|
||||
")";
|
||||
}
|
||||
if (item.system.valuable) {
|
||||
ret.stats.wealth += this.calculateValue(item.system.value * item.system.quantity, item.system.currency);
|
||||
}
|
||||
if (item.system.hoarded) {
|
||||
ret.stats.hoard += this.calculateValue(item.system.value * item.system.quantity, item.system.currency);
|
||||
// Adjust attribute Aussehen based on Athletik skill
|
||||
if (item.name === "Athletik") {
|
||||
ret.attributes.au.value += Math.floor(item.system.fw / 3);
|
||||
}
|
||||
|
||||
ret.gear.weapons[item.id] = {
|
||||
label: label,
|
||||
skillId: item.system.skillId,
|
||||
magic: item.system.magic,
|
||||
valuable: item.system?.valuable,
|
||||
hoarded: item.system?.hoarded,
|
||||
value: item.system.value || 0,
|
||||
currency: item.system.currency || "",
|
||||
calc: item.system.calc,
|
||||
special: item.system.special,
|
||||
damageBase: item.system.damageBase,
|
||||
equipped: item.system?.equipped,
|
||||
containerId: item.system.containerId || "",
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
if (!skip?.defensiveWeapons) {
|
||||
context.items
|
||||
?.filter((item) => item.type === "defensiveWeapon")
|
||||
.forEach((item) => {
|
||||
item.prepareDerivedData();
|
||||
|
||||
let label = item.name;
|
||||
if (item.system.magic) {
|
||||
label += "*(" + (item.system.stats.defenseBonus < 0 ? "" : "+") + item.system.stats.defenseBonus + ")";
|
||||
// Adjust stat Bewegungsweite based on Laufen skill
|
||||
if (item.name === "Laufen") {
|
||||
ret.stats.movement.value += Math.floor(item.system.fw / 3);
|
||||
}
|
||||
if (item.system.valuable) {
|
||||
ret.stats.wealth += this.calculateValue(item.system.value * item.system.quantity, item.system.currency);
|
||||
}
|
||||
if (item.system.hoarded) {
|
||||
ret.stats.hoard += this.calculateValue(item.system.value * item.system.quantity, item.system.currency);
|
||||
}
|
||||
|
||||
ret.gear.defensiveWeapons[item.id] = {
|
||||
label: label,
|
||||
skillId: item.system.skillId,
|
||||
magic: item.system.magic,
|
||||
valuable: item.system?.valuable,
|
||||
hoarded: item.system?.hoarded,
|
||||
value: item.system.value || 0,
|
||||
currency: item.system.currency || "",
|
||||
defenseBonus: item.system.stats.defenseBonus,
|
||||
calc: item.system.calc,
|
||||
equipped: item.system?.equipped,
|
||||
containerId: item.system.containerId || "",
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
if (!skip?.armor) {
|
||||
context.items
|
||||
?.filter((item) => item.type === "armor")
|
||||
.forEach((item) => {
|
||||
item.prepareDerivedData();
|
||||
|
||||
let label = item.name;
|
||||
if (item.system.magic) {
|
||||
label += "*";
|
||||
}
|
||||
if (item.system.valuable) {
|
||||
ret.stats.wealth += this.calculateValue(item.system.value * item.system.quantity, item.system.currency);
|
||||
}
|
||||
if (item.system.hoarded) {
|
||||
ret.stats.hoard += this.calculateValue(item.system.value * item.system.quantity, item.system.currency);
|
||||
}
|
||||
|
||||
ret.gear.armor[item.id] = {
|
||||
label: label,
|
||||
magic: item.system.magic,
|
||||
valuable: item.system?.valuable,
|
||||
hoarded: item.system?.hoarded,
|
||||
value: item.system.value || 0,
|
||||
currency: item.system.currency || "",
|
||||
lpProtection: item.system.lpProtection,
|
||||
calc: item.system.calc,
|
||||
equipped: item.system?.equipped,
|
||||
containerId: item.system.containerId || "",
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
if (!skip?.spells) {
|
||||
context.items
|
||||
?.filter((item) => item.type === "spell")
|
||||
.sort((a, b) => a?.sort - b?.sort)
|
||||
.forEach((item) => {
|
||||
item.prepareDerivedData();
|
||||
|
||||
@@ -408,6 +579,7 @@ export class M5Character extends Actor {
|
||||
if (!skip?.kampfkuenste) {
|
||||
context.items
|
||||
?.filter((item) => item.type === "kampfkunst")
|
||||
.sort((a, b) => a?.sort - b?.sort)
|
||||
.forEach((item) => {
|
||||
item.prepareDerivedData();
|
||||
|
||||
@@ -511,7 +683,7 @@ export class M5Character extends Actor {
|
||||
return data?.attributes[name];
|
||||
}
|
||||
|
||||
createSkill(skillName: string): Promise<M5Item> {
|
||||
async createSkill(skillName: string): Promise<M5Item> {
|
||||
const itemData = {
|
||||
name: skillName,
|
||||
type: "skill",
|
||||
@@ -523,10 +695,25 @@ export class M5Character extends Actor {
|
||||
});
|
||||
}
|
||||
|
||||
createItem(itemName: string, itemType: M5ItemType): Promise<M5Item> {
|
||||
createItem(itemName: string, itemType: M5ItemType, options?: any): Promise<M5Item> {
|
||||
const itemData = {
|
||||
name: itemName,
|
||||
type: itemType,
|
||||
data: options,
|
||||
};
|
||||
|
||||
return (this as any).createEmbeddedDocuments("Item", [itemData]).then((docs) => {
|
||||
const item = docs[0];
|
||||
return item;
|
||||
});
|
||||
}
|
||||
|
||||
async createEffect(itemName: string, mods: M5ItemMod[]): Promise<M5Item> {
|
||||
const itemData = {
|
||||
name: itemName,
|
||||
type: "effect",
|
||||
|
||||
system: { mods: mods, equipped: true },
|
||||
};
|
||||
|
||||
return (this as any).createEmbeddedDocuments("Item", [itemData]).then((docs) => {
|
||||
|
||||
@@ -14,22 +14,22 @@ export class M5Item extends Item {
|
||||
const itemData = (this as any).system;
|
||||
const calc = itemData.calc;
|
||||
|
||||
if (itemType === "item") {
|
||||
calc.containers = null;
|
||||
if (itemType === "item") {
|
||||
calc.containers = null;
|
||||
|
||||
if (actor) {
|
||||
const actorCalc = actor.derivedData({ weapons: true, defensiveWeapons: true, armor: true, items: true, spells: true, effects: true, kampfkuenste: true });
|
||||
if (actorCalc) {
|
||||
calc.containers = actorCalc.gear.containers;
|
||||
if (actor) {
|
||||
const actorCalc = actor.derivedData({ containers: false, items: true, spells: true, effects: true, kampfkuenste: true, encumbrance: true });
|
||||
if (actorCalc) {
|
||||
calc.containers = actorCalc.gear.containers;
|
||||
}
|
||||
const container = character.getItem(itemData.containerId);
|
||||
//console.log("M5Item.prepareDerivedData:containers", itemData, container?.system)
|
||||
if (container) {
|
||||
container.prepareDerivedData();
|
||||
const containerData = container.system;
|
||||
}
|
||||
}
|
||||
const container = character.getItem(itemData.containerId);
|
||||
//console.log("M5Item.prepareDerivedData:containers", itemData, container?.system)
|
||||
if (container) {
|
||||
container.prepareDerivedData();
|
||||
const containerData = container.system;
|
||||
}
|
||||
}
|
||||
} else if (itemType === "skill") {
|
||||
} else if (itemType === "skill") {
|
||||
calc.fw = itemData.fw;
|
||||
calc.bonus = 0;
|
||||
|
||||
@@ -46,7 +46,14 @@ export class M5Item extends Item {
|
||||
];
|
||||
|
||||
if (character) {
|
||||
const actorCalc = character.derivedData({ skills: true, weapons: true, defensiveWeapons: true, armor: true, items: true, spells: true, effects: true, kampfkuenste: true });
|
||||
const actorCalc = character.derivedData({
|
||||
skills: true,
|
||||
items: true,
|
||||
spells: true,
|
||||
effects: true,
|
||||
kampfkuenste: true,
|
||||
encumbrance: true,
|
||||
});
|
||||
if (actorCalc?.skillMods && Object.keys(actorCalc.skillMods).indexOf(itemId) !== -1) {
|
||||
pairs = pairs.concat(actorCalc.skillMods[itemId]);
|
||||
}
|
||||
@@ -81,9 +88,8 @@ export class M5Item extends Item {
|
||||
calc.combatSkills = null;
|
||||
calc.containers = null;
|
||||
|
||||
|
||||
if (actor) {
|
||||
const actorCalc = character.derivedData({ weapons: true, defensiveWeapons: true, armor: true, items: true, spells: true, effects: true, kampfkuenste: true });
|
||||
const actorCalc = character.derivedData({ items: true, spells: true, effects: true, kampfkuenste: true, encumbrance: true });
|
||||
if (actorCalc) {
|
||||
calc.ew += actorCalc.stats.attackBonus.value;
|
||||
calc.combatSkills = actorCalc.skills.combat;
|
||||
@@ -94,8 +100,8 @@ export class M5Item extends Item {
|
||||
if (container) {
|
||||
container.prepareDerivedData();
|
||||
const containerData = container.system;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const skill = character.getItem(itemData.skillId);
|
||||
//console.log("M5Item.prepareDerivedData:weapon", itemData, skill?.system)
|
||||
if (skill) {
|
||||
@@ -104,6 +110,9 @@ export class M5Item extends Item {
|
||||
calc.ew += skillData.calc.ew;
|
||||
calc.bonus += skillData.calc.bonus;
|
||||
calc.fw += skillData.fw;
|
||||
} else {
|
||||
calc.ew += 4;
|
||||
calc.fw += 4;
|
||||
}
|
||||
}
|
||||
} else if (itemType === "defensiveWeapon") {
|
||||
@@ -115,7 +124,7 @@ export class M5Item extends Item {
|
||||
calc.containers = null;
|
||||
|
||||
if (actor) {
|
||||
const actorCalc = character.derivedData({ weapons: true, defensiveWeapons: true, armor: true, items: true, spells: true, effects: true, kampfkuenste: true });
|
||||
const actorCalc = character.derivedData({ items: true, spells: true, effects: true, kampfkuenste: true, encumbrance: true });
|
||||
if (actorCalc) {
|
||||
calc.ew += actorCalc.stats.defense.value + actorCalc.stats.defenseBonus.value;
|
||||
calc.combatSkills = actorCalc.skills.combat;
|
||||
@@ -127,7 +136,7 @@ export class M5Item extends Item {
|
||||
if (container) {
|
||||
container.prepareDerivedData();
|
||||
const containerData = container.system;
|
||||
}
|
||||
}
|
||||
|
||||
const skill = character.getItem(itemData.skillId);
|
||||
//console.log("M5Item.prepareDerivedData:weapon", itemData, skill?.system)
|
||||
@@ -148,7 +157,7 @@ export class M5Item extends Item {
|
||||
itemData.mods[5] = { type: "stat", id: "apProtection", operation: "set", value: itemData.apProtection };
|
||||
calc.containers = null;
|
||||
if (actor) {
|
||||
const actorCalc = actor.derivedData({ weapons: true, defensiveWeapons: true, armor: true, items: true, spells: true, effects: true, kampfkuenste: true });
|
||||
const actorCalc = actor.derivedData({ items: true, spells: true, effects: true, kampfkuenste: true, encumbrance: true });
|
||||
if (actorCalc) {
|
||||
calc.containers = actorCalc.gear.containers;
|
||||
}
|
||||
@@ -157,12 +166,12 @@ export class M5Item extends Item {
|
||||
if (container) {
|
||||
container.prepareDerivedData();
|
||||
const containerData = container.system;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (itemType === "spell") {
|
||||
calc.fw = 0;
|
||||
if (actor) {
|
||||
const actorCalc = character.derivedData({ weapons: true, defensiveWeapons: true, armor: true, items: true, spells: true, effects: true, kampfkuenste: true });
|
||||
const actorCalc = character.derivedData({ items: true, spells: true, effects: true, kampfkuenste: true, encumbrance: true });
|
||||
if (actorCalc) {
|
||||
calc.ew = actorCalc.stats.spellCasting.value;
|
||||
}
|
||||
@@ -174,7 +183,7 @@ export class M5Item extends Item {
|
||||
calc.generalSkills = null;
|
||||
|
||||
if (actor) {
|
||||
const actorCalc = character.derivedData({ weapons: true, defensiveWeapons: true, armor: true, items: true, spells: true, effects: true, kampfkuenste: true });
|
||||
const actorCalc = character.derivedData({ items: true, spells: true, effects: true, kampfkuenste: true, encumbrance: true });
|
||||
if (actorCalc) {
|
||||
calc.generalSkills = actorCalc.skills.general;
|
||||
}
|
||||
@@ -217,7 +226,13 @@ export class M5Item extends Item {
|
||||
}
|
||||
case M5ModType.SKILL: {
|
||||
if (character) {
|
||||
const actorCalc = character.derivedData({ weapons: true, defensiveWeapons: true, armor: true, items: true, spells: true, effects: true, kampfkuenste: true });
|
||||
const actorCalc = character.derivedData({
|
||||
items: true,
|
||||
spells: true,
|
||||
effects: true,
|
||||
kampfkuenste: true,
|
||||
encumbrance: true,
|
||||
});
|
||||
if (actorCalc) {
|
||||
let category = (game as Game).i18n.localize("midgard5.skill");
|
||||
Object.keys(actorCalc.skills.general).forEach((skillId) => {
|
||||
|
||||
@@ -269,27 +269,6 @@ export class M5Roll {
|
||||
return new M5Roll(rollData, actor, (game as Game).i18n.localize("midgard5.resistanceMind"));
|
||||
}
|
||||
|
||||
static async initativeRoll(actor: any) {
|
||||
let newInitiative; // the initiative value for the combatant
|
||||
|
||||
// ...
|
||||
// The intnitiative value is calculated here
|
||||
// ...
|
||||
|
||||
let combatant = game["combat"].getCombatantByActor(actor._id);
|
||||
if (!combatant) {
|
||||
await game["combat"].createEmbeddedDocuments("Combatant", [{ actorId: actor._id }]);
|
||||
combatant = game["combat"].getCombatantByActor(actor._id);
|
||||
}
|
||||
|
||||
const initiatives = {
|
||||
_id: combatant._id,
|
||||
initiative: actor.system.calc.attributes.gw.value,
|
||||
};
|
||||
|
||||
await game["combat"].updateEmbeddedDocuments("Combatant", [initiatives]);
|
||||
}
|
||||
|
||||
static resistanceBody(actor: any) {
|
||||
const rollData = actor.getRollData() as M5RollData;
|
||||
rollData.i = {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Logger from "../../utils/Logger";
|
||||
import { M5Character } from "../actors/M5Character";
|
||||
import { M5Item } from "../items/M5Item";
|
||||
import { M5ItemType, M5SkillLearned, M5SkillUnlearned } from "../M5Base";
|
||||
import { M5ItemType, M5SkillLearned, M5SkillType, M5SkillUnlearned } from "../M5Base";
|
||||
import { M5Roll } from "../rolls/M5Roll";
|
||||
|
||||
export default class M5CharacterSheet extends ActorSheet {
|
||||
@@ -11,7 +11,13 @@ export default class M5CharacterSheet extends ActorSheet {
|
||||
width: 1000,
|
||||
height: 800,
|
||||
classes: ["midgard5", "sheet", "character"],
|
||||
tabs: [{ navSelector: ".sheet-navigation", contentSelector: ".sheet-content", initial: "base_values" }],
|
||||
tabs: [
|
||||
{
|
||||
navSelector: ".sheet-navigation",
|
||||
contentSelector: ".sheet-content",
|
||||
initial: "base_values",
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
@@ -68,28 +74,17 @@ export default class M5CharacterSheet extends ActorSheet {
|
||||
});
|
||||
|
||||
html.find(".roll-attribute-button").on("click", async (event) => {
|
||||
let elem = event.target;
|
||||
let attributeStr = elem.dataset["attribute"];
|
||||
while (!attributeStr) {
|
||||
elem = elem.parentElement;
|
||||
if (!elem) return;
|
||||
attributeStr = elem.dataset["attribute"];
|
||||
}
|
||||
const attributeValue = parseInt(elem.dataset["value"]);
|
||||
let target = event.target.closest("[data-attribute]") as HTMLElement;
|
||||
let attributeValue = target ? parseInt(target.dataset.value) : null;
|
||||
let attributeStr = target ? target.dataset.attribute : null;
|
||||
|
||||
const roll = M5Roll.fromAttributeValue(this.actor, attributeStr, attributeValue);
|
||||
//console.log("roll-attribute-button", parent, attributeStr, attributeValue, roll)
|
||||
await roll.toMessage();
|
||||
});
|
||||
|
||||
html.find(".edit-item").on("click", async (event) => {
|
||||
let row = event.target.parentElement;
|
||||
let itemId = row.dataset["item"];
|
||||
while (!itemId) {
|
||||
row = row.parentElement;
|
||||
if (!row) return;
|
||||
itemId = row.dataset["item"];
|
||||
}
|
||||
let target = event.target.closest("[data-item-id]") as HTMLElement;
|
||||
let itemId = target ? target.dataset.itemId : null;
|
||||
|
||||
const context = this.actor as any;
|
||||
const item = context.items.get(itemId);
|
||||
@@ -98,13 +93,8 @@ export default class M5CharacterSheet extends ActorSheet {
|
||||
});
|
||||
|
||||
html.find(".quantity-increase").on("click", async (event) => {
|
||||
let row = event.target.parentElement;
|
||||
let itemId = row.dataset["item"];
|
||||
while (!itemId) {
|
||||
row = row.parentElement;
|
||||
if (!row) return;
|
||||
itemId = row.dataset["item"];
|
||||
}
|
||||
let target = event.target.closest("[data-item-id]") as HTMLElement;
|
||||
let itemId = target ? target.dataset.itemId : null;
|
||||
|
||||
const context = this.actor as any;
|
||||
const item = context.items.get(itemId);
|
||||
@@ -120,13 +110,8 @@ export default class M5CharacterSheet extends ActorSheet {
|
||||
});
|
||||
|
||||
html.find(".quantity-decrease").on("click", async (event) => {
|
||||
let row = event.target.parentElement;
|
||||
let itemId = row.dataset["item"];
|
||||
while (!itemId) {
|
||||
row = row.parentElement;
|
||||
if (!row) return;
|
||||
itemId = row.dataset["item"];
|
||||
}
|
||||
let target = event.target.closest("[data-item-id]") as HTMLElement;
|
||||
let itemId = target ? target.dataset.itemId : null;
|
||||
|
||||
const context = this.actor as any;
|
||||
const item = context.items.get(itemId);
|
||||
@@ -141,13 +126,8 @@ export default class M5CharacterSheet extends ActorSheet {
|
||||
});
|
||||
|
||||
html.find(".roll-consumable-item").on("click", async (event) => {
|
||||
let row = event.target.parentElement;
|
||||
let itemId = row.dataset["item"];
|
||||
while (!itemId) {
|
||||
row = row.parentElement;
|
||||
if (!row) return;
|
||||
itemId = row.dataset["item"];
|
||||
}
|
||||
let target = event.target.closest("[data-item-id]") as HTMLElement;
|
||||
let itemId = target ? target.dataset.itemId : null;
|
||||
|
||||
const context = this.actor as any;
|
||||
const item = context.items.get(itemId);
|
||||
@@ -164,13 +144,8 @@ export default class M5CharacterSheet extends ActorSheet {
|
||||
});
|
||||
|
||||
html.find(".item-delete").on("click", async (event) => {
|
||||
let row = event.target.parentElement;
|
||||
let itemId = row.dataset["item"];
|
||||
while (!itemId) {
|
||||
row = row.parentElement;
|
||||
if (!row) return;
|
||||
itemId = row.dataset["item"];
|
||||
}
|
||||
let target = event.target.closest("[data-item-id]") as HTMLElement;
|
||||
let itemId = target ? target.dataset.itemId : null;
|
||||
|
||||
const context = this.actor as any;
|
||||
const item = context.items.get(itemId);
|
||||
@@ -179,8 +154,8 @@ export default class M5CharacterSheet extends ActorSheet {
|
||||
});
|
||||
|
||||
html.find(".roll-learned-button").on("click", async (event) => {
|
||||
const row = event.target.parentElement.parentElement;
|
||||
let skillId = row.dataset["item"];
|
||||
let target = event.target.closest("[data-item-id]") as HTMLElement;
|
||||
let skillId = target ? target.dataset.itemId : null;
|
||||
|
||||
const actor = this.actor as any;
|
||||
const item = actor.items.get(skillId) as M5Item;
|
||||
@@ -188,8 +163,8 @@ export default class M5CharacterSheet extends ActorSheet {
|
||||
});
|
||||
|
||||
html.find(".roll-general-button").on("click", async (event) => {
|
||||
const row = event.target.parentElement.parentElement;
|
||||
let skillName = row.dataset["skill"];
|
||||
let target = event.target.closest("[data-skill]") as HTMLElement;
|
||||
let skillName = target ? target.dataset.skill : null;
|
||||
|
||||
const data = this.actor.system;
|
||||
const unlearnedSkill = data.skills.general[skillName] as M5SkillUnlearned;
|
||||
@@ -199,8 +174,8 @@ export default class M5CharacterSheet extends ActorSheet {
|
||||
});
|
||||
|
||||
html.find(".learn-button").on("click", async (event) => {
|
||||
const row = event.target.parentElement.parentElement;
|
||||
let skillName = row.dataset["skill"];
|
||||
let target = event.target.closest("[data-skill]") as HTMLElement;
|
||||
let skillName = target ? target.dataset.skill : null;
|
||||
|
||||
const data = this.actor.system;
|
||||
const unlearnedSkill = data.skills.general[skillName] as M5SkillUnlearned;
|
||||
@@ -219,9 +194,47 @@ export default class M5CharacterSheet extends ActorSheet {
|
||||
});
|
||||
});
|
||||
|
||||
html.find(".fw-increase").on("click", async (event) => {
|
||||
let target = event.target.closest("[data-item-id]") as HTMLElement;
|
||||
let itemId = target ? target.dataset.itemId : null;
|
||||
|
||||
const context = this.actor as any;
|
||||
const item = context.items.get(itemId);
|
||||
if (!item.system.fw) {
|
||||
item.system.fw = 0;
|
||||
}
|
||||
if (item.system.fw < 18) {
|
||||
item.update({
|
||||
data: {
|
||||
fw: Math.min(item.system.fw + 1, 18),
|
||||
},
|
||||
});
|
||||
}
|
||||
this.render();
|
||||
});
|
||||
|
||||
html.find(".fw-decrease").on("click", async (event) => {
|
||||
let target = event.target.closest("[data-item-id]") as HTMLElement;
|
||||
let itemId = target ? target.dataset.itemId : null;
|
||||
|
||||
const context = this.actor as any;
|
||||
const item = context.items.get(itemId);
|
||||
if (!item.system.fw) {
|
||||
item.system.fw = 0;
|
||||
}
|
||||
if (item.system.fw > 8) {
|
||||
item.update({
|
||||
data: {
|
||||
fw: Math.max(item.system.fw - 1, 8),
|
||||
},
|
||||
});
|
||||
}
|
||||
this.render();
|
||||
});
|
||||
|
||||
html.find(".roll-weapon-button").on("click", async (event) => {
|
||||
const row = event.target.parentElement.parentElement;
|
||||
let itemId = row.dataset["item"];
|
||||
let target = event.target.closest("[data-item-id]") as HTMLElement;
|
||||
let itemId = target ? target.dataset.itemId : null;
|
||||
|
||||
const context = this.actor as any;
|
||||
const item = context.items.get(itemId) as M5Item;
|
||||
@@ -260,21 +273,17 @@ export default class M5CharacterSheet extends ActorSheet {
|
||||
});
|
||||
|
||||
html.find(".change-equipped").on("click", async (event) => {
|
||||
let row = event.target.parentElement;
|
||||
let itemId = row.dataset["item"];
|
||||
while (!itemId) {
|
||||
row = row.parentElement;
|
||||
if (!row) return;
|
||||
itemId = row.dataset["item"];
|
||||
}
|
||||
let target = event.target.closest("[data-item-id]") as HTMLElement;
|
||||
let itemId = target ? target.dataset.itemId : null;
|
||||
|
||||
const context = this.actor as any;
|
||||
const item = context.items.get(itemId);
|
||||
if (item.system.equipped === true) {
|
||||
item.system.equipped = false;
|
||||
} else {
|
||||
item.system.equipped = true;
|
||||
}
|
||||
item.update({
|
||||
data: {
|
||||
equipped: !item.system.equipped,
|
||||
},
|
||||
});
|
||||
|
||||
this.render();
|
||||
});
|
||||
|
||||
@@ -282,14 +291,7 @@ export default class M5CharacterSheet extends ActorSheet {
|
||||
const data = this.actor.system;
|
||||
|
||||
const character = this.actor as M5Character;
|
||||
character.createItem((game as Game).i18n.localize("TYPES.Item.item"), M5ItemType.ITEM).then((i) => {
|
||||
const item = i as any;
|
||||
item.update({
|
||||
data: {
|
||||
quantity: 1,
|
||||
},
|
||||
});
|
||||
});
|
||||
character.createItem((game as Game).i18n.localize("TYPES.Item.item"), M5ItemType.ITEM, { quantity: 1 });
|
||||
});
|
||||
|
||||
html.find(".add-weapon").on("click", async (event) => {
|
||||
@@ -317,13 +319,42 @@ export default class M5CharacterSheet extends ActorSheet {
|
||||
const data = this.actor.system;
|
||||
|
||||
const character = this.actor as M5Character;
|
||||
character.createItem((game as Game).i18n.localize("TYPES.Item.container"), M5ItemType.CONTAINER).then((i) => {
|
||||
const item = i as any;
|
||||
item.update({
|
||||
data: {
|
||||
quantity: 1,
|
||||
},
|
||||
});
|
||||
character.createItem((game as Game).i18n.localize("TYPES.Item.container"), M5ItemType.CONTAINER, { quantity: 1 });
|
||||
});
|
||||
|
||||
html.find(".add-innate-skill").on("click", async (event) => {
|
||||
const data = this.actor.system;
|
||||
|
||||
const character = this.actor as M5Character;
|
||||
character.createItem((game as Game).i18n.localize("midgard5.innate-ability"), M5ItemType.SKILL, {
|
||||
type: M5SkillType.INNATE,
|
||||
});
|
||||
});
|
||||
|
||||
html.find(".add-general-skill").on("click", async (event) => {
|
||||
const data = this.actor.system;
|
||||
|
||||
const character = this.actor as M5Character;
|
||||
character.createItem((game as Game).i18n.localize("TYPES.Item.skill"), M5ItemType.SKILL, {
|
||||
type: M5SkillType.GENERAL,
|
||||
});
|
||||
});
|
||||
|
||||
html.find(".add-combat-skill").on("click", async (event) => {
|
||||
const data = this.actor.system;
|
||||
|
||||
const character = this.actor as M5Character;
|
||||
character.createItem((game as Game).i18n.localize("midgard5.weapon-skill"), M5ItemType.SKILL, {
|
||||
type: M5SkillType.COMBAT,
|
||||
});
|
||||
});
|
||||
|
||||
html.find(".add-language-skill").on("click", async (event) => {
|
||||
const data = this.actor.system;
|
||||
|
||||
const character = this.actor as M5Character;
|
||||
character.createItem((game as Game).i18n.localize("midgard5.language"), M5ItemType.SKILL, {
|
||||
type: M5SkillType.LANGUAGE,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -331,28 +362,16 @@ export default class M5CharacterSheet extends ActorSheet {
|
||||
const data = this.actor.system;
|
||||
|
||||
const character = this.actor as M5Character;
|
||||
character.createItem((game as Game).i18n.localize("TYPES.Item.spell"), M5ItemType.SPELL).then((i) => {
|
||||
const item = i as any;
|
||||
item.update({
|
||||
data: {
|
||||
process: "none",
|
||||
},
|
||||
});
|
||||
});
|
||||
character.createItem((game as Game).i18n.localize("TYPES.Item.spell"), M5ItemType.SPELL, { process: "none" });
|
||||
});
|
||||
|
||||
html.find(".add-kampfkunst").on("click", async (event) => {
|
||||
const data = this.actor.system;
|
||||
|
||||
const character = this.actor as M5Character;
|
||||
character.createItem((game as Game).i18n.localize("TYPES.Item.kampfkunst"), M5ItemType.KAMPFKUNST).then((i) => {
|
||||
const item = i as any;
|
||||
item.update({
|
||||
data: {
|
||||
type: "angriff",
|
||||
variante: "anstuermen",
|
||||
},
|
||||
});
|
||||
character.createItem((game as Game).i18n.localize("TYPES.Item.kampfkunst"), M5ItemType.KAMPFKUNST, {
|
||||
type: "angriff",
|
||||
variante: "anstuermen",
|
||||
});
|
||||
});
|
||||
|
||||
@@ -363,12 +382,69 @@ export default class M5CharacterSheet extends ActorSheet {
|
||||
character.createItem((game as Game).i18n.localize("TYPES.Item.effect"), M5ItemType.EFFECT);
|
||||
});
|
||||
|
||||
html.find(".join-combat").on("click", async (event) => {
|
||||
if (!!game["combat"]) {
|
||||
let combatant = game["combat"].getCombatantByActor(this.actor._id);
|
||||
if (!combatant) {
|
||||
await game["combat"].createEmbeddedDocuments("Combatant", [{ actorId: this.actor._id }]);
|
||||
combatant = game["combat"].getCombatantByActor(this.actor._id);
|
||||
}
|
||||
|
||||
const initiatives = {
|
||||
_id: combatant._id,
|
||||
initiative: this.actor.system.calc.attributes.gw.value,
|
||||
};
|
||||
|
||||
await game["combat"].updateEmbeddedDocuments("Combatant", [initiatives]);
|
||||
}
|
||||
});
|
||||
|
||||
html.find(".ranged-combat").on("click", async (event) => {
|
||||
if (!!game["combat"]) {
|
||||
let combatant = game["combat"].getCombatantByActor(this.actor._id);
|
||||
if (!combatant) {
|
||||
await game["combat"].createEmbeddedDocuments("Combatant", [{ actorId: this.actor._id }]);
|
||||
combatant = game["combat"].getCombatantByActor(this.actor._id);
|
||||
}
|
||||
|
||||
const initiatives = {
|
||||
_id: combatant._id,
|
||||
initiative: 0.01 * this.actor.system.calc.attributes.gw.value,
|
||||
};
|
||||
|
||||
await game["combat"].updateEmbeddedDocuments("Combatant", [initiatives]);
|
||||
}
|
||||
});
|
||||
|
||||
html.find(".spell-combat").on("click", async (event) => {
|
||||
if (!!game["combat"]) {
|
||||
let combatant = game["combat"].getCombatantByActor(this.actor._id);
|
||||
if (!combatant) {
|
||||
await game["combat"].createEmbeddedDocuments("Combatant", [{ actorId: this.actor._id }]);
|
||||
combatant = game["combat"].getCombatantByActor(this.actor._id);
|
||||
}
|
||||
|
||||
const initiatives = {
|
||||
_id: combatant._id,
|
||||
initiative: 0.001 * this.actor.system.calc.attributes.gw.value,
|
||||
};
|
||||
|
||||
await game["combat"].updateEmbeddedDocuments("Combatant", [initiatives]);
|
||||
}
|
||||
});
|
||||
|
||||
// Drag & Drop
|
||||
const dragDrop = new DragDrop({
|
||||
dragSelector: ".items-list .item",
|
||||
dropSelector: ".sheet-body",
|
||||
permissions: { dragstart: this._canDragStart.bind(this), drop: this._canDragDrop.bind(this) },
|
||||
callbacks: { dragstart: this._onTransferItemDragStart.bind(this), drop: this._onTransferItemDrop.bind(this) },
|
||||
dropSelector: null,
|
||||
permissions: {
|
||||
dragstart: this._canDragStart.bind(this),
|
||||
drop: this._canDragDrop.bind(this),
|
||||
},
|
||||
callbacks: {
|
||||
dragstart: this._onTransferItemDragStart.bind(this),
|
||||
drop: this._onTransferItemDrop.bind(this),
|
||||
},
|
||||
});
|
||||
dragDrop.bind(html[0]);
|
||||
}
|
||||
@@ -378,29 +454,24 @@ export default class M5CharacterSheet extends ActorSheet {
|
||||
}
|
||||
|
||||
_canDragDrop(selector) {
|
||||
return true;
|
||||
return this.options.editable;
|
||||
}
|
||||
|
||||
_onTransferItemDragStart(event) {
|
||||
const li = event.currentTarget;
|
||||
$(event.currentTarget).attr("data-item-actorid", this.actor.id);
|
||||
const li = event.target;
|
||||
$(event.target).attr("data-item-actorid", this.actor.id);
|
||||
const item = this.actor.items.get(li.dataset.itemId);
|
||||
|
||||
// limit transfer on personal weapons/armour/gear
|
||||
if (["skill", "item", "weapon", "defensiveWeapon", "armor", "spell", "effect", "kampfkunst", "container"].includes(item.type)) {
|
||||
const dragData = {
|
||||
type: "Transfer",
|
||||
actorId: this.actor.id,
|
||||
data: item.toObject(false),
|
||||
tokenId: null,
|
||||
};
|
||||
const dragData = {
|
||||
type: "Transfer",
|
||||
actorId: this.actor.id,
|
||||
data: item.toObject(false),
|
||||
tokenId: null,
|
||||
};
|
||||
|
||||
if (this.actor.isToken) dragData.tokenId = this.actor.token.id;
|
||||
if (this.actor.isToken) dragData.tokenId = this.actor.token.id;
|
||||
|
||||
event.dataTransfer.setData("text/plain", JSON.stringify(dragData));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
event.dataTransfer.setData("text/plain", JSON.stringify(dragData));
|
||||
}
|
||||
|
||||
async _onTransferItemDrop(event) {
|
||||
@@ -408,6 +479,7 @@ export default class M5CharacterSheet extends ActorSheet {
|
||||
let data = null;
|
||||
try {
|
||||
data = JSON.parse(event.dataTransfer.getData("text/plain"));
|
||||
data.data.system.containerId = ""; //Clean containerId
|
||||
if (data.type !== "Transfer") return false;
|
||||
} catch (err) {
|
||||
return false;
|
||||
@@ -415,14 +487,22 @@ export default class M5CharacterSheet extends ActorSheet {
|
||||
|
||||
if (!data.data) return false;
|
||||
|
||||
if (data.actorId === this.actor.id) return false;
|
||||
if (data.actorId === this.actor.id) {
|
||||
return this._onSortItem(event, data.data);
|
||||
}
|
||||
|
||||
try {
|
||||
this.actor.createEmbeddedDocuments("Item", [duplicate(data.data)]); // Create a new Item
|
||||
const actor = (game as any).actors.get(data.actorId);
|
||||
await actor.items.get(data.data._id)?.delete(); // Delete originating item from other actor
|
||||
} catch (e) {
|
||||
console.error("Error transfering item between actors", e);
|
||||
// limit transfer on personal weapons/armour/gear
|
||||
if (["item", "weapon", "defensiveWeapon", "armor", "container"].includes(data.data.type)) {
|
||||
try {
|
||||
this.actor.createEmbeddedDocuments("Item", [duplicate(data.data)]); // Create a new Item
|
||||
const actor = (game as any).actors.get(data.actorId);
|
||||
await actor.items.get(data.data._id)?.delete(); // Delete originating item from other actor
|
||||
} catch (e) {
|
||||
console.error("Error transfering item between actors", e);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
ui.notifications.warn("Nur Gegenstände können übertragen werden.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,195 +1,174 @@
|
||||
import { M5Item } from "../items/M5Item"
|
||||
import { M5Attributes, M5ItemMod, M5ModOperation, M5ModType, M5RollTemplate } from "../M5Base"
|
||||
import { M5Item } from "../items/M5Item";
|
||||
import { M5Attributes, M5ItemMod, M5ModOperation, M5ModType, M5RollTemplate } from "../M5Base";
|
||||
|
||||
export class M5ItemSheet extends ItemSheet {
|
||||
|
||||
static get defaultOptions() {
|
||||
return mergeObject(super.defaultOptions, {
|
||||
width: 640,
|
||||
height: 480,
|
||||
classes: ["midgard5", "sheet", "item"]
|
||||
})
|
||||
classes: ["midgard5", "sheet", "item"],
|
||||
});
|
||||
}
|
||||
|
||||
get template() {
|
||||
//console.log("M5ItemSheet", this.item.data.type)
|
||||
const path = "systems/midgard5/templates/sheets/item"
|
||||
return `${path}/${this.item.type}.hbs`
|
||||
const path = "systems/midgard5/templates/sheets/item";
|
||||
return `${path}/${this.item.type}.hbs`;
|
||||
}
|
||||
|
||||
override getData(options?: Partial<ItemSheet.Options>): ItemSheet.Data<ItemSheet.Options> | Promise<ItemSheet.Data<ItemSheet.Options>> {
|
||||
const item = this.item as M5Item
|
||||
return Promise.resolve(super.getData()).then(value => {
|
||||
item.prepareDerivedData()
|
||||
const context = value as any
|
||||
const item = this.item as M5Item;
|
||||
return Promise.resolve(super.getData()).then((value) => {
|
||||
item.prepareDerivedData();
|
||||
const context = value as any;
|
||||
|
||||
// Use a safe clone of the item data for further operations.
|
||||
const itemData = context.item
|
||||
const itemData = context.item;
|
||||
|
||||
// Retrieve the roll data for TinyMCE editors.
|
||||
context.rollData = {}
|
||||
let actor = this.object?.parent ?? null
|
||||
context.rollData = {};
|
||||
let actor = this.object?.parent ?? null;
|
||||
if (actor) {
|
||||
context.rollData = actor.getRollData()
|
||||
context.rollData = actor.getRollData();
|
||||
}
|
||||
|
||||
context.data = itemData.system
|
||||
context.flags = itemData.flags
|
||||
|
||||
return context
|
||||
})
|
||||
|
||||
context.data = itemData.system;
|
||||
context.flags = itemData.flags;
|
||||
|
||||
return context;
|
||||
});
|
||||
}
|
||||
|
||||
override activateListeners(html: JQuery) {
|
||||
super.activateListeners(html)
|
||||
super.activateListeners(html);
|
||||
|
||||
html.find(".add-mod").on("click", async (event) => {
|
||||
const context = this.object
|
||||
const mods = context.system.mods
|
||||
const modIndex = Object.keys(mods).length
|
||||
const context = this.object;
|
||||
const mods = context.system.mods;
|
||||
const modIndex = Object.keys(mods).length;
|
||||
mods[modIndex.toString()] = {
|
||||
type: M5ModType.ATTRIBUTE,
|
||||
id: M5Attributes.ST,
|
||||
operation: M5ModOperation.ADD,
|
||||
value: 0
|
||||
} as M5ItemMod
|
||||
value: 0,
|
||||
} as M5ItemMod;
|
||||
this.object.update({
|
||||
data: {
|
||||
mods: mods
|
||||
}
|
||||
})
|
||||
})
|
||||
mods: mods,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
html.find(".item-delete").on("click", async (event) => {
|
||||
let row = event.target.parentElement
|
||||
let itemId = row.dataset["item"]
|
||||
while (!itemId) {
|
||||
row = row.parentElement
|
||||
if (!row)
|
||||
return
|
||||
itemId = row.dataset["item"]
|
||||
}
|
||||
html.find(".mod-delete").on("click", async (event) => {
|
||||
let target = event.target.closest("[data-mod-id]") as HTMLElement;
|
||||
let modId = target ? target.dataset.modId : null;
|
||||
|
||||
const context = this.item
|
||||
const item = context.items.get(itemId)
|
||||
item.delete()
|
||||
this.render(false)
|
||||
})
|
||||
const context = this.item;
|
||||
delete context.system.mods[modId];
|
||||
this.render(false);
|
||||
});
|
||||
|
||||
html.find(".roll-delete").on("click", async (event) => {
|
||||
//console.log("roll-delete", this.item.data.data.rolls.formulas)
|
||||
let target = event.target.closest("[data-roll]") as HTMLElement;
|
||||
let rollIndex = target ? target.dataset.roll : null;
|
||||
|
||||
let row = event.target.parentElement
|
||||
let rollIndex = row.dataset["roll"]
|
||||
while (!rollIndex) {
|
||||
row = row.parentElement
|
||||
if (!row)
|
||||
return
|
||||
rollIndex = row.dataset["roll"]
|
||||
}
|
||||
|
||||
const rolls = this.item.system.rolls.formulas
|
||||
rolls[rollIndex] = null
|
||||
|
||||
this.item.update({
|
||||
data: {
|
||||
rolls: {
|
||||
formulas: rolls
|
||||
}
|
||||
}
|
||||
})
|
||||
this.render(false)
|
||||
})
|
||||
const rolls = this.item.system.rolls.formulas;
|
||||
delete rolls[rollIndex];
|
||||
this.render(false);
|
||||
});
|
||||
|
||||
html.find(".roll-create").on("click", async (event) => {
|
||||
const rolls = this.item.system.rolls.formulas
|
||||
const rolls = this.item.system.rolls.formulas;
|
||||
|
||||
const indeces = Object.keys(rolls).map(index => parseInt(index)).sort().reverse()
|
||||
const index = (indeces.find(index => !!rolls[index.toString()]) ?? -1) + 1
|
||||
console.log("roll-create", rolls, indeces, index)
|
||||
const indeces = Object.keys(rolls)
|
||||
.map((index) => parseInt(index))
|
||||
.sort()
|
||||
.reverse();
|
||||
const index = (indeces.find((index) => !!rolls[index.toString()]) ?? -1) + 1;
|
||||
console.log("roll-create", rolls, indeces, index);
|
||||
|
||||
rolls[index.toString()] = {
|
||||
formula: "1d6",
|
||||
label: (game as Game).i18n.localize("midgard5.roll"),
|
||||
enabled: true
|
||||
} as M5RollTemplate
|
||||
enabled: true,
|
||||
} as M5RollTemplate;
|
||||
|
||||
this.item.update({
|
||||
data: {
|
||||
rolls: {
|
||||
formulas: rolls
|
||||
}
|
||||
}
|
||||
})
|
||||
this.render(false)
|
||||
})
|
||||
formulas: rolls,
|
||||
},
|
||||
},
|
||||
});
|
||||
this.render(false);
|
||||
});
|
||||
|
||||
// Drag & Drop
|
||||
if (["item"].includes(this.object.type)) {
|
||||
const itemToItemAssociation = new DragDrop({
|
||||
dragSelector: ".item",
|
||||
dropSelector: null,
|
||||
permissions: { dragstart: this._canDragStart.bind(this), drop: this._canDragDrop.bind(this) },
|
||||
dropSelector: ".item-list",
|
||||
permissions: {
|
||||
dragstart: this._canDragStart.bind(this),
|
||||
drop: this._canDragDrop.bind(this),
|
||||
},
|
||||
callbacks: { drop: this._onDropItem.bind(this) },
|
||||
})
|
||||
itemToItemAssociation.bind(html[0])
|
||||
});
|
||||
itemToItemAssociation.bind(html[0]);
|
||||
}
|
||||
}
|
||||
|
||||
_canDragStart(selector) {
|
||||
console.log("M5ItemSheet._canDragStart", selector)
|
||||
return this.options.editable && this.object.isOwner
|
||||
console.log("M5ItemSheet._canDragStart", selector);
|
||||
return this.options.editable && this.object.isOwner;
|
||||
}
|
||||
|
||||
_canDragDrop(selector) {
|
||||
console.log("M5ItemSheet._canDragDrop", selector)
|
||||
return true
|
||||
console.log("M5ItemSheet._canDragDrop", selector);
|
||||
return true;
|
||||
}
|
||||
|
||||
async _onDropItem(event) {
|
||||
let data
|
||||
const obj = this.object
|
||||
const li = event.currentTarget
|
||||
let data;
|
||||
const obj = this.object;
|
||||
const li = event.currentTarget;
|
||||
|
||||
try {
|
||||
data = JSON.parse(event.dataTransfer.getData("text/plain"))
|
||||
if (data.type !== "Item")
|
||||
return false
|
||||
data = JSON.parse(event.dataTransfer.getData("text/plain"));
|
||||
if (data.type !== "Item") return false;
|
||||
} catch (err) {
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
|
||||
// Case 1 - Import from a Compendium pack
|
||||
let itemObject
|
||||
let itemObject;
|
||||
if (data.pack) {
|
||||
const compendiumObject = await (this as any).importItemFromCollection(data.pack, data.id)
|
||||
itemObject = compendiumObject.data
|
||||
const compendiumObject = await (this as any).importItemFromCollection(data.pack, data.id);
|
||||
itemObject = compendiumObject.data;
|
||||
}
|
||||
|
||||
// Case 2 - Import from World entity
|
||||
else {
|
||||
const originalItem = await (game as Game).items.get(data.id)
|
||||
itemObject = duplicate(originalItem)
|
||||
if (!itemObject)
|
||||
return
|
||||
const originalItem = await (game as Game).items.get(data.id);
|
||||
itemObject = duplicate(originalItem);
|
||||
if (!itemObject) return;
|
||||
}
|
||||
|
||||
if ((itemObject.type === "mod")) {
|
||||
let mods = obj?.system?.mods
|
||||
if (!mods)
|
||||
mods = []
|
||||
if (itemObject.type === "mod") {
|
||||
let mods = obj?.system?.mods;
|
||||
if (!mods) mods = [];
|
||||
|
||||
itemObject.id = randomID()
|
||||
console.log("M5ItemSheet._onDropItem", itemObject)
|
||||
mods.push(itemObject)
|
||||
itemObject.id = randomID();
|
||||
console.log("M5ItemSheet._onDropItem", itemObject);
|
||||
mods.push(itemObject);
|
||||
|
||||
obj.update({
|
||||
data: {
|
||||
mods: mods
|
||||
}
|
||||
})
|
||||
mods: mods,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async _onDragItemStart(event) { }
|
||||
async _onDragItemStart(event) {}
|
||||
}
|
||||
|
||||
@@ -234,6 +234,10 @@
|
||||
height: 1rem;
|
||||
}
|
||||
|
||||
.wide-button {
|
||||
margin: 0.25rem 0;
|
||||
}
|
||||
|
||||
.learn-button {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
|
||||
+3
-117
@@ -3,7 +3,7 @@
|
||||
"name": "midgard5",
|
||||
"title": "Midgard 5. Edition",
|
||||
"description": "The German RPG Midgard 5. Edition",
|
||||
"version": "2.4.2",
|
||||
"version": "2.5.0",
|
||||
"compatibility": {
|
||||
"minimum": "10",
|
||||
"verified": "11",
|
||||
@@ -12,120 +12,6 @@
|
||||
"authors": [{ "name": "Byroks" }, { "name": "Le-Frique" }, { "name": "Oskaloq" }],
|
||||
"scripts": ["bundle.js"],
|
||||
"styles": ["bundle.css"],
|
||||
"packs": [
|
||||
{
|
||||
"name": "blaupause-spielfiguren",
|
||||
"label": "Blaupausen für Spielfiguren",
|
||||
"system": "midgard5",
|
||||
"path": "./packs/actors/blaupause-spielfiguren.db",
|
||||
"type": "Actor"
|
||||
},
|
||||
{
|
||||
"name": "makros-standardwurfel",
|
||||
"label": "Standardwürfel",
|
||||
"system": "midgard5",
|
||||
"path": "./packs/macros/makros-standardwurfel.db",
|
||||
"type": "Macro"
|
||||
},
|
||||
{
|
||||
"name": "makros-kritische-ereignisse",
|
||||
"label": "Makros Kritische Ereignisse",
|
||||
"system": "midgard5",
|
||||
"path": "./packs/macros/makros-kritische-ereignisse.db",
|
||||
"type": "Macro"
|
||||
},
|
||||
{
|
||||
"name": "tabellen-kritische-ereignisse",
|
||||
"label": "Tabellen Kritische Ereignisse",
|
||||
"system": "midgard5",
|
||||
"path": "./packs/rolltables/tabellen-kritische-ereignisse.db",
|
||||
"type": "RollTable"
|
||||
},
|
||||
{
|
||||
"name": "ausruestung",
|
||||
"label": "Ausrüstung",
|
||||
"system": "midgard5",
|
||||
"path": "./packs/items/ausruestung.db",
|
||||
"type": "Item"
|
||||
},
|
||||
{
|
||||
"name": "fertigkeiten",
|
||||
"label": "Fertigkeiten",
|
||||
"system": "midgard5",
|
||||
"path": "./packs/items/fertigkeiten.db",
|
||||
"type": "Item"
|
||||
},
|
||||
{
|
||||
"name": "kampf",
|
||||
"label": "Kampf",
|
||||
"system": "midgard5",
|
||||
"path": "./packs/items/kampf.db",
|
||||
"type": "Item"
|
||||
},
|
||||
{
|
||||
"name": "kampfzustaende",
|
||||
"label": "Kampfzustände",
|
||||
"system": "midgard5",
|
||||
"path": "./packs/items/kampfzustaende.db",
|
||||
"type": "Item"
|
||||
},
|
||||
{
|
||||
"name": "verletzungen",
|
||||
"label": "Verletzungen",
|
||||
"system": "midgard5",
|
||||
"path": "./packs/items/verletzungen.db",
|
||||
"type": "Item"
|
||||
},
|
||||
{
|
||||
"name": "ruestkammer",
|
||||
"label": "Rüstkammer",
|
||||
"system": "midgard5",
|
||||
"path": "./packs/items/ruestkammer.db",
|
||||
"type": "Item"
|
||||
},
|
||||
{
|
||||
"name": "waffenkammer",
|
||||
"label": "Waffenkammer",
|
||||
"system": "midgard5",
|
||||
"path": "./packs/items/waffenkammer.db",
|
||||
"type": "Item"
|
||||
},
|
||||
{
|
||||
"name": "zauberwirkungen",
|
||||
"label": "Zauberwirkungen",
|
||||
"system": "midgard5",
|
||||
"path": "./packs/items/zauberwirkungen.db",
|
||||
"type": "Item"
|
||||
}
|
||||
],
|
||||
"packFolders": [
|
||||
{
|
||||
"name": "Midgard 5",
|
||||
"sorting": "a",
|
||||
"color": "#0000FF",
|
||||
"packs": ["blaupause-spielfiguren", "tabellen-kritische-ereignisse", "makros-kritische-ereignisse", "makros-standardwurfel"],
|
||||
"folders": [
|
||||
{
|
||||
"name": "Ausrüstung",
|
||||
"sorting": "a",
|
||||
"color": "#008000",
|
||||
"packs": ["ausruestung", "ruestkammer", "waffenkammer"]
|
||||
},
|
||||
{
|
||||
"name": "Effekte",
|
||||
"sorting": "a",
|
||||
"color": "#800080",
|
||||
"packs": ["kampfzustaende", "verletzungen", "zauberwirkungen"]
|
||||
},
|
||||
{
|
||||
"name": "Fähigkeiten",
|
||||
"sorting": "a",
|
||||
"color": "#800000",
|
||||
"packs": ["fertigkeiten", "kampf"]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"languages": [
|
||||
{
|
||||
"lang": "de",
|
||||
@@ -138,8 +24,8 @@
|
||||
"primaryTokenAttribute": "lp",
|
||||
"secondaryTokenAttribute": "ap",
|
||||
"url": "https://git.byroks.de/MidgardVTT-Entwicklung/foundry-vtt-system-midgard5",
|
||||
"manifest": "https://git.byroks.de/MidgardVTT-Entwicklung/foundry-vtt-system-midgard5/releases/download/v2.4.2/system.json",
|
||||
"download": "https://git.byroks.de/MidgardVTT-Entwicklung/foundry-vtt-system-midgard5/releases/download/v2.4.2/midgard5-v2.4.2.zip",
|
||||
"manifest": "https://git.byroks.de/MidgardVTT-Entwicklung/foundry-vtt-system-midgard5/releases/download/v2.5.0/system.json",
|
||||
"download": "https://git.byroks.de/MidgardVTT-Entwicklung/foundry-vtt-system-midgard5/releases/download/v2.5.0/midgard5-v2.5.0.zip",
|
||||
"initiative": "@c.calc.attributes.gw.value",
|
||||
"license": "LICENSE.txt"
|
||||
}
|
||||
|
||||
+11
-1
@@ -233,13 +233,17 @@
|
||||
"none": "midgard5.spell-process-none",
|
||||
"beherrschen": "midgard5.spell-process-beherrschen",
|
||||
"bewegen": "midgard5.spell-process-bewegen",
|
||||
"blutzauber": "midgard5.spell-process-blutzauber",
|
||||
"chaoswunder": "midgard5.spell-process-chaoswunder",
|
||||
"erkennen": "midgard5.spell-process-erkennen",
|
||||
"erschaffen": "midgard5.spell-process-erschaffen",
|
||||
"formen": "midgard5.spell-process-formen",
|
||||
"finstere_magie": "midgard5.spell-process-finstere_magie",
|
||||
"veraendern": "midgard5.spell-process-veraendern",
|
||||
"zerstoeren": "midgard5.spell-process-zerstoeren",
|
||||
"wundertat": "midgard5.spell-process-wundertat",
|
||||
"dweomer": "midgard5.spell-process-dweomer",
|
||||
"wilder_dweomer": "midgard5.spell-process-wilder_dweomer",
|
||||
"zauberlied": "midgard5.spell-process-zauberlied",
|
||||
"salz": "midgard5.spell-process-salz",
|
||||
"thaumagraphie": "midgard5.spell-process-thaumagraphie",
|
||||
@@ -247,7 +251,9 @@
|
||||
"nekromantie": "midgard5.spell-process-nekromantie",
|
||||
"thaumatherapie": "midgard5.spell-process-thaumatherapie",
|
||||
"zaubermittel": "midgard5.spell-process-zaubermittel",
|
||||
"zauberschutz": "midgard5.spell-process-zauberschutz"
|
||||
"zauberschutz": "midgard5.spell-process-zauberschutz",
|
||||
"zauberrunen": "midgard5.spell-process-zauberrunen",
|
||||
"zaubersiegel": "midgard5.spell-process-siegel"
|
||||
},
|
||||
"spellTypeSelection": {
|
||||
"gedanke": "midgard5.spell-type-gedanke",
|
||||
@@ -401,12 +407,16 @@
|
||||
"type": "",
|
||||
"process": "",
|
||||
"ap": "",
|
||||
"lp": "",
|
||||
"castDuration": "",
|
||||
"range": "",
|
||||
"effectTarget": "",
|
||||
"effectArea": "",
|
||||
"effectDuration": "",
|
||||
"origin": "",
|
||||
"agens": "",
|
||||
"reagens": "",
|
||||
"material": "",
|
||||
"rolls": {
|
||||
"formulas": {
|
||||
"0": {
|
||||
|
||||
Reference in New Issue
Block a user