Les commerces peuvent appliquer un pourcentage
This commit is contained in:
@ -3,6 +3,7 @@ import { RdDItem } from "../item.js";
|
||||
import { RdDSheetUtility } from "../rdd-sheet-utility.js";
|
||||
import { RdDUtility } from "../rdd-utility.js";
|
||||
import { RdDBaseActorSheet } from "./base-actor-sheet.js";
|
||||
import { RdDCommerce } from "./commerce.js";
|
||||
|
||||
/**
|
||||
* Extend the basic ActorSheet with some very simple modifications
|
||||
@ -67,7 +68,7 @@ export class RdDCommerceSheet extends RdDBaseActorSheet {
|
||||
quantiteIllimite: disponible == undefined,
|
||||
nbLots: disponible ?? 1,
|
||||
tailleLot: 1,
|
||||
prixLot: item.system.cout
|
||||
prixLot: item.calculerPrixCommercant()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { Misc } from "../misc.js";
|
||||
import { RdDBaseActor } from "./base-actor.js";
|
||||
|
||||
export class RdDCommerce extends RdDBaseActor {
|
||||
@ -45,4 +46,8 @@ export class RdDCommerce extends RdDBaseActor {
|
||||
await super.decrementerQuantiteItem(itemVendu, quantite, {supprimerSiZero: false});
|
||||
}
|
||||
|
||||
calculerPrix(item) {
|
||||
const pourcentage = this.system.pourcentage ?? 100;
|
||||
return Misc.keepDecimals(Math.ceil(item.system.cout * pourcentage)/100, 2);
|
||||
}
|
||||
}
|
@ -9,9 +9,9 @@ export class DialogItemVente extends Dialog {
|
||||
item: item,
|
||||
alias: item.actor?.name ?? game.user.name,
|
||||
vendeurId: item.actor?.id ,
|
||||
prixOrigine: item.system.cout,
|
||||
prixUnitaire: item.system.cout,
|
||||
prixLot: item.system.cout,
|
||||
prixOrigine: item.calculerPrixCommercant(),
|
||||
prixUnitaire: item.calculerPrixCommercant(),
|
||||
prixLot: item.calculerPrixCommercant(),
|
||||
tailleLot: 1,
|
||||
quantiteNbLots: quantite,
|
||||
quantiteMaxLots: quantite,
|
||||
|
@ -11,7 +11,7 @@ export class RdDItemService extends RdDItem {
|
||||
return [
|
||||
RdDItem.propertyIfDefined('Qualité', this.system.qualite, this.system.qualite != 0),
|
||||
RdDItem.propertyIfDefined('Moral', 'Situation heureuse', this.system.moral),
|
||||
RdDItem.propertyIfDefined('Coût', `${this.system.cout} sols`),
|
||||
RdDItem.propertyIfDefined('Coût', `${this.calculerPrixCommercant()} sols`),
|
||||
];
|
||||
}
|
||||
}
|
@ -171,7 +171,6 @@ export class RdDItem extends Item {
|
||||
return typesObjetsConnaissance.includes(this.type)
|
||||
}
|
||||
|
||||
|
||||
getItemGroup() {
|
||||
if (this.isInventaire()) return "equipement";
|
||||
if (this.isOeuvre()) return "oeuvre";
|
||||
@ -258,6 +257,14 @@ export class RdDItem extends Item {
|
||||
return this.system.cout ?? 0
|
||||
}
|
||||
|
||||
calculerPrixCommercant() {
|
||||
if (this.parent?.type == 'commerce') {
|
||||
// appliquer le pourcentage
|
||||
return this.parent.calculerPrix(this);
|
||||
}
|
||||
return this.system.cout;
|
||||
}
|
||||
|
||||
prepareDerivedData() {
|
||||
super.prepareDerivedData();
|
||||
if (this.isInventaire()) {
|
||||
|
@ -16,6 +16,7 @@ import { RdDCalendrier } from "./rdd-calendrier.js";
|
||||
import { Environnement } from "./environnement.js";
|
||||
import { RdDItemCompetence } from "./item-competence.js";
|
||||
import { RdDResolutionTable } from "./rdd-resolution-table.js";
|
||||
import { RdDCommerce } from "./actor/commerce.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
// This table starts at 0 -> niveau -10
|
||||
@ -274,6 +275,7 @@ export class RdDUtility {
|
||||
Handlebars.registerHelper('accord', (genre, ...args) => Grammar.accord(genre, args));
|
||||
Handlebars.registerHelper('buildConteneur', (objet, templateItem, options) => { return new Handlebars.SafeString(RdDUtility.buildConteneur(objet, 1, templateItem, options)); });
|
||||
Handlebars.registerHelper('buildContenu', (objet) => { return new Handlebars.SafeString(RdDUtility.buildContenu(objet, 1, true)); });
|
||||
Handlebars.registerHelper('calculerPrixCommercant', item => item.calculerPrixCommercant());
|
||||
Handlebars.registerHelper('caseTmr-label', coord => TMRUtility.getTMRLabel(coord));
|
||||
Handlebars.registerHelper('caseTmr-type', coord => TMRUtility.getTMRType(coord));
|
||||
Handlebars.registerHelper('typeTmr-name', type => TMRUtility.typeTmrName(type));
|
||||
|
Reference in New Issue
Block a user