Complete Lasten & Gewichte
+ Fixed Belastung Effekt preventing opening new Actorsheets + Added Höchstlast Effekt (minor bug: Actorname? & doubled messages) + Fixed parsing problem on encumbrance
This commit is contained in:
parent
50e2e534a0
commit
a2de64be91
|
|
@ -1,5 +1,5 @@
|
||||||
import { M5Item } from "../items/M5Item";
|
import { M5Item } from "../items/M5Item";
|
||||||
import { M5Attribute, M5CharacterCalculatedData, M5ItemMod, M5ItemType, M5ModOperation, M5ModResult, M5ModType, M5RollData, M5Skill, M5SkillCalculated, M5SkillLearned } from "../M5Base";
|
import { M5Attribute, M5CharacterCalculatedData, M5ItemMod, M5ItemType, M5ModOperation, M5ModResult, M5ModType, M5RollData, M5Skill, M5SkillCalculated } from "../M5Base";
|
||||||
import M5ModAggregate from "./M5ModAggregate";
|
import M5ModAggregate from "./M5ModAggregate";
|
||||||
export class M5Character extends Actor {
|
export class M5Character extends Actor {
|
||||||
// constructor(
|
// constructor(
|
||||||
|
|
@ -204,24 +204,7 @@ export class M5Character extends Actor {
|
||||||
ret.stats.heavyLoad = M5Character.heavyLoadValue(data.attributes.st);
|
ret.stats.heavyLoad = M5Character.heavyLoadValue(data.attributes.st);
|
||||||
ret.stats.loadMax = M5Character.maxLoadValue(data.attributes.st);
|
ret.stats.loadMax = M5Character.maxLoadValue(data.attributes.st);
|
||||||
ret.stats.thrustLoad = M5Character.thrustLoadValue(data.attributes.st);
|
ret.stats.thrustLoad = M5Character.thrustLoadValue(data.attributes.st);
|
||||||
ret.stats.encumbrance = parseFloat((0).toPrecision(3));
|
ret.stats.encumbrance = parseFloat((0).toPrecision(4));
|
||||||
|
|
||||||
// let loadMessage = false;
|
|
||||||
|
|
||||||
// if (data.info.encumbrance > data.info.loadMax && !loadMessage) {
|
|
||||||
// let messageContent = `Höchstlast von ${data.info.name} überschritten: [[1d1]] AP Schaden durch Belastung alle 10 Minuten abziehen!`;
|
|
||||||
// let chatData = {
|
|
||||||
// speaker: ChatMessage.getSpeaker({actor: Actor.name}),
|
|
||||||
// content: messageContent,
|
|
||||||
// };
|
|
||||||
// ChatMessage.create(chatData, {});
|
|
||||||
// loadMessage = true;
|
|
||||||
// // ui.notifications.warn(messageContent);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (data.info.encumbrance < data.info.loadMax && loadMessage) {
|
|
||||||
// loadMessage = false;
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (!skip?.mods) {
|
if (!skip?.mods) {
|
||||||
const aggregate = new M5ModAggregate(data, ret);
|
const aggregate = new M5ModAggregate(data, ret);
|
||||||
|
|
@ -295,12 +278,12 @@ export class M5Character extends Actor {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!!item.system.containerId) {
|
if (!!item.system.containerId) {
|
||||||
ret.gear.containers[item.system.containerId].weight += parseFloat((item.system.weight * item.system.quantity).toPrecision(3));
|
ret.gear.containers[item.system.containerId].weight += parseFloat((item.system.weight * item.system.quantity).toPrecision(4));
|
||||||
if (ret.gear.containers[item.system.containerId].equipped) {
|
if (ret.gear.containers[item.system.containerId].equipped) {
|
||||||
ret.stats.encumbrance += parseFloat((item.system.weight * item.system.quantity).toPrecision(3));
|
ret.stats.encumbrance += (item.system.weight * item.system.quantity);
|
||||||
}
|
}
|
||||||
} else if (item.system.equipped) {
|
} else if (item.system.equipped) {
|
||||||
ret.stats.encumbrance += parseFloat((item.system.weight * item.system.quantity).toPrecision(3));
|
ret.stats.encumbrance += (item.system.weight * item.system.quantity);
|
||||||
}
|
}
|
||||||
|
|
||||||
let icon = item.img;
|
let icon = item.img;
|
||||||
|
|
@ -475,7 +458,7 @@ export class M5Character extends Actor {
|
||||||
item[1]?.delete();
|
item[1]?.delete();
|
||||||
}
|
}
|
||||||
} else if (ret.stats.encumbrance <= ret.stats.heavyLoad) {
|
} else if (ret.stats.encumbrance <= ret.stats.heavyLoad) {
|
||||||
if (!!item) {
|
if (item.length === 1) {
|
||||||
item[0].update({
|
item[0].update({
|
||||||
data: {
|
data: {
|
||||||
equipped: false,
|
equipped: false,
|
||||||
|
|
@ -484,6 +467,34 @@ export class M5Character extends Actor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!skip?.encumbrance) {
|
||||||
|
const item = context.items.filter((x) => x.name === "Höchstlast");
|
||||||
|
if (ret.stats.encumbrance > ret.stats.loadMax) {
|
||||||
|
if (item.length === 0) {
|
||||||
|
let messageContent = `Höchstlast von ${M5Character.name} überschritten: 1 AP Schaden durch Belastung alle 10 Minuten abziehen!`;
|
||||||
|
let chatData = {
|
||||||
|
speaker: ChatMessage.getSpeaker({actor: M5Character.name}),
|
||||||
|
content: messageContent,
|
||||||
|
};
|
||||||
|
ChatMessage.create(chatData, {});
|
||||||
|
ui.notifications.warn(messageContent);
|
||||||
|
this.createEffect("Höchstlast", [{ id: "ap", operation: M5ModOperation.SUBTRACT, type: M5ModType.STAT, value: 1 }]);
|
||||||
|
} else if (item.length === 2) {
|
||||||
|
item[1]?.delete();
|
||||||
|
} else if (item.length === 1) {
|
||||||
|
item[0].update({
|
||||||
|
data: {
|
||||||
|
equipped: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if (ret.stats.encumbrance < ret.stats.loadMax) {
|
||||||
|
if (item.length === 1) {
|
||||||
|
item[0]?.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!skip?.effects) {
|
if (!skip?.effects) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue