Fix: Encombrement décimal
This commit is contained in:
@@ -594,7 +594,7 @@ export class RdDBaseActor extends Actor {
|
||||
}
|
||||
|
||||
getEncTotal() {
|
||||
return Math.floor(this.encTotal ?? 0)
|
||||
return Number(this.encTotal?.toFixed(2) ?? 0.00)
|
||||
}
|
||||
|
||||
async createItem(type, name = undefined) {
|
||||
|
||||
@@ -7,7 +7,7 @@ const fields = foundry.data.fields
|
||||
export class CommonInventaire extends CommonTemplate {
|
||||
fields() {
|
||||
return {
|
||||
encombrement: new fields.NumberField({ label: "Encombrement", initial: 0, ...INTEGER }),
|
||||
encombrement: new fields.NumberField({ label: "Encombrement", initial: 0, ...DECIMAL }),
|
||||
quantite: new fields.NumberField({ label: "Quantité", initial: 1, ...INTEGER }),
|
||||
qualite: new fields.NumberField({ label: "Qualité", initial: 0, ...INTEGER_SIGNED }),
|
||||
cout: new fields.NumberField({ label: "Coût", initial: 0.0, ...DECIMAL }),
|
||||
|
||||
@@ -693,6 +693,26 @@ class _13_0_21_AjoutAppreciation extends Migration {
|
||||
}
|
||||
}
|
||||
|
||||
class _13_0_22_PoidsDesMonnaies extends Migration {
|
||||
get code() { return "poid-monnaies" }
|
||||
get version() { return "13.0.22" }
|
||||
|
||||
async migrate() {
|
||||
await this.applyItemsUpdates(items => items
|
||||
.filter(it => it.type == ITEM_TYPES.monnaie)
|
||||
.map(it => {
|
||||
return { _id: it.id, 'system.encombrement': this.poids(it) }
|
||||
})
|
||||
)
|
||||
}
|
||||
poids(monnaie) {
|
||||
if (monnaie.system.cout < 0.05) return 0.001
|
||||
if (monnaie.system.cout < 0.5) return 0.002
|
||||
if (monnaie.system.cout < 5) return 0.003
|
||||
return 0.004
|
||||
}
|
||||
}
|
||||
|
||||
export class Migrations {
|
||||
static getMigrations() {
|
||||
return [
|
||||
@@ -719,6 +739,7 @@ export class Migrations {
|
||||
new _13_0_4_FixReveActuel(),
|
||||
new _13_0_7_FixNiveauOeuvres(),
|
||||
new _13_0_21_AjoutAppreciation(),
|
||||
new _13_0_22_PoidsDesMonnaies(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user