#33 Wrong wealth calculation

Changes:
 + add function to adjust item value depending on currency
This commit is contained in:
Byroks 2024-01-08 13:54:11 +01:00
parent cfdba0ee75
commit a5c5b6c9e7
1 changed files with 37 additions and 26 deletions

View File

@ -145,12 +145,11 @@ 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 = data.info.gold + data.info.silver / 10 + data.info.copper / 100;
ret.stats.hoard = 0;
if (!skip?.mods) {
const aggregate = new M5ModAggregate(data, ret);
@ -177,10 +176,10 @@ 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;
}
@ -249,7 +248,6 @@ export class M5Character extends Actor {
quantity: item.system.quantity || 0,
rollExist: rollable,
};
});
}
@ -262,7 +260,7 @@ export class M5Character extends Actor {
let label = item.name;
if (item.system.magic) {
label += "*";
};
}
ret.gear.effects[item.id] = {
label: label,
@ -306,10 +304,10 @@ 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;
}
@ -335,10 +333,10 @@ 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;
}
@ -364,10 +362,10 @@ 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;
}
@ -521,6 +519,19 @@ export class M5Character extends Actor {
return (this as any).getEmbeddedDocument("Item", itemId);
}
private calculateValue(value: number, currency: string): number {
switch (currency) {
case "gold":
return value;
case "silver":
return value / 10;
case "copper":
return value / 100;
default:
return 0;
}
}
private modResult(value: number): M5ModResult {
return {
value: value,