Merge branch 'develop' into lasten
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { M5Item } from "../items/M5Item";
|
||||
import { M5Attribute, M5Attributes, M5CharacterCalculatedData, M5ItemMod, M5ModOperation, M5ModResult, M5RollData, M5Skill, M5SkillCalculated, M5SkillLearned, M5Stats } from "../M5Base";
|
||||
import { M5Attribute, M5CharacterCalculatedData, M5ItemMod, M5ItemType, M5ModOperation, M5ModResult, M5RollData, M5Skill, M5SkillCalculated, M5SkillLearned } from "../M5Base";
|
||||
import M5ModAggregate from "./M5ModAggregate";
|
||||
export class M5Character extends Actor {
|
||||
// constructor(
|
||||
@@ -198,9 +198,9 @@ export class M5Character extends Actor {
|
||||
ret.stats.perceptionFW = 6;
|
||||
ret.stats.drinking = this.modResult(0);
|
||||
ret.stats.drinkingFW = Math.floor(ret.attributes.ko.value / 10);
|
||||
ret.stats.hoardMin = M5Character.levelThreshold.at (ret.level - 1)/2;
|
||||
ret.stats.hoardNext = M5Character.levelThreshold.at (ret.level)/2;
|
||||
ret.stats.wealth = data.info.gold + data.info.silver/10 + data.info.copper/100;
|
||||
ret.stats.hoardMin = M5Character.levelThreshold.at(ret.level - 1) / 2;
|
||||
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);
|
||||
@@ -212,19 +212,19 @@ export class M5Character extends Actor {
|
||||
|
||||
// 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, {});
|
||||
// let chatData = {
|
||||
// speaker: ChatMessage.getSpeaker({actor: Actor.name}),
|
||||
// content: messageContent,
|
||||
// };
|
||||
// ChatMessage.create(chatData, {});
|
||||
// loadMessage = true;
|
||||
// // ui.notifications.warn(messageContent);
|
||||
// // ui.notifications.warn(messageContent);
|
||||
// }
|
||||
|
||||
// if (data.info.encumbrance < data.info.loadMax && loadMessage) {
|
||||
// loadMessage = false;
|
||||
// }
|
||||
|
||||
|
||||
if (!skip?.mods) {
|
||||
const aggregate = new M5ModAggregate(data, ret);
|
||||
|
||||
@@ -251,17 +251,17 @@ export class M5Character extends Actor {
|
||||
let label = item.name;
|
||||
if (item.system.magic) {
|
||||
label += "*";
|
||||
};
|
||||
if (item.system.valuable) {
|
||||
ret.stats.wealth += item.system.value || 0;
|
||||
};
|
||||
}
|
||||
if (item.system.valuable) {
|
||||
ret.stats.wealth += this.calculateValue(item.system.value, item.system.currency);
|
||||
}
|
||||
if (item.system.hoarded) {
|
||||
ret.stats.hoard += item.system.value || 0;
|
||||
};
|
||||
}
|
||||
if (item.system.equipped) {
|
||||
ret.stats.encumbrance += item.system.weight || 0;
|
||||
}
|
||||
|
||||
|
||||
let icon = item.img;
|
||||
let rollable = false;
|
||||
|
||||
@@ -272,7 +272,7 @@ export class M5Character extends Actor {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ret.gear.items[item.id] = {
|
||||
label: label,
|
||||
icon: icon,
|
||||
@@ -320,13 +320,11 @@ export class M5Character extends Actor {
|
||||
calc: item.system.calc,
|
||||
equipped: item.system?.equipped,
|
||||
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,
|
||||
};
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -339,8 +337,8 @@ export class M5Character extends Actor {
|
||||
let label = item.name;
|
||||
if (item.system.magic) {
|
||||
label += "*";
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
ret.gear.effects[item.id] = {
|
||||
label: label,
|
||||
magic: item.system.magic,
|
||||
@@ -383,25 +381,29 @@ export class M5Character extends Actor {
|
||||
(item.system.stats.damageBonus < 0 ? "" : "+") +
|
||||
item.system.stats.damageBonus +
|
||||
")";
|
||||
};
|
||||
}
|
||||
if (item.system.valuable) {
|
||||
ret.stats.wealth += item.system.value || 0;
|
||||
};
|
||||
ret.stats.wealth += this.calculateValue(item.system.value, item.system.currency);
|
||||
}
|
||||
if (item.system.hoarded) {
|
||||
ret.stats.hoard += item.system.value || 0;
|
||||
};
|
||||
}
|
||||
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,
|
||||
value: item.system.value || 0,
|
||||
calc: item.system.calc,
|
||||
special: item.system.special,
|
||||
damageBase: item.system.damageBase,
|
||||
equipped: item.system?.equipped,
|
||||
containerId: item.system.containerId || "",
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -415,17 +417,17 @@ export class M5Character extends Actor {
|
||||
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 += item.system.value || 0;
|
||||
};
|
||||
ret.stats.wealth += this.calculateValue(item.system.value, item.system.currency);
|
||||
}
|
||||
if (item.system.hoarded) {
|
||||
ret.stats.hoard += item.system.value || 0;
|
||||
};
|
||||
}
|
||||
if (item.system.equipped) {
|
||||
ret.stats.encumbrance += item.system.weight || 0;
|
||||
}
|
||||
|
||||
|
||||
ret.gear.defensiveWeapons[item.id] = {
|
||||
label: label,
|
||||
skillId: item.system.skillId,
|
||||
@@ -433,7 +435,10 @@ export class M5Character extends Actor {
|
||||
valuable: item.system?.valuable,
|
||||
hoarded: item.system?.hoarded,
|
||||
value: item.system.value || 0,
|
||||
defenseBonus: item.system.stats.defenseBonus,
|
||||
calc: item.system.calc,
|
||||
equipped: item.system?.equipped,
|
||||
containerId: item.system.containerId || "",
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -447,25 +452,29 @@ export class M5Character extends Actor {
|
||||
let label = item.name;
|
||||
if (item.system.magic) {
|
||||
label += "*";
|
||||
};
|
||||
}
|
||||
if (item.system.valuable) {
|
||||
ret.stats.wealth += item.system.value || 0;
|
||||
};
|
||||
ret.stats.wealth += this.calculateValue(item.system.value, item.system.currency);
|
||||
}
|
||||
if (item.system.hoarded) {
|
||||
ret.stats.hoard += item.system.value || 0;
|
||||
};
|
||||
}
|
||||
if (item.system.equipped) {
|
||||
ret.stats.encumbrance += 0;
|
||||
} else {ret.stats.encumbrance += item.system.weight || 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,
|
||||
lpProtection: item.system.lpProtection,
|
||||
calc: item.system.calc,
|
||||
equipped: item.system?.equipped,
|
||||
containerId: item.system.containerId || "",
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -602,11 +611,36 @@ export class M5Character extends Actor {
|
||||
});
|
||||
}
|
||||
|
||||
createItem(itemName: string, itemType: M5ItemType): Promise<M5Item> {
|
||||
const itemData = {
|
||||
name: itemName,
|
||||
type: itemType,
|
||||
};
|
||||
|
||||
return (this as any).createEmbeddedDocuments("Item", [itemData]).then((docs) => {
|
||||
const item = docs[0];
|
||||
return item;
|
||||
});
|
||||
}
|
||||
|
||||
getItem(itemId: string): any {
|
||||
if (!(this as any).items) return null;
|
||||
return (this as any).getEmbeddedDocument("Item", itemId);
|
||||
}
|
||||
|
||||
private calculateValue(value: number, currency: string): number {
|
||||
switch (currency) {
|
||||
case "gold":
|
||||
return value;
|
||||
case "silver":
|
||||
return parseFloat((value / 10).toPrecision(3));
|
||||
case "copper":
|
||||
return parseFloat((value / 100).toPrecision(3));
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private modResult(value: number): M5ModResult {
|
||||
return {
|
||||
value: value,
|
||||
|
||||
Reference in New Issue
Block a user