51 lines
1.2 KiB
JavaScript
51 lines
1.2 KiB
JavaScript
import { Misc } from "../misc.js";
|
|
import { RdDBaseActor } from "./base-actor.js";
|
|
|
|
export class RdDCommerce extends RdDBaseActor {
|
|
|
|
static get defaultIcon() {
|
|
return "systems/foundryvtt-reve-de-dragon/icons/services/commerce.webp";
|
|
}
|
|
|
|
prepareData() {
|
|
super.prepareData();
|
|
}
|
|
prepareDerivedData() {
|
|
super.prepareDerivedData();
|
|
}
|
|
|
|
canReceive(item) {
|
|
return item.isInventaire('all');
|
|
}
|
|
|
|
getQuantiteDisponible(item) {
|
|
return (this.system.illimite || item?.isService()) ? undefined : item.getQuantite();
|
|
}
|
|
|
|
verifierFortune(cout) {
|
|
return this.system.illimite || super.verifierFortune(cout);
|
|
}
|
|
|
|
async depenserSols(cout) {
|
|
if (this.system.illimite) {
|
|
return
|
|
}
|
|
await super.depenserSols(cout)
|
|
}
|
|
|
|
async consommerNourritureAchetee(achat, vente, createdItemId) {
|
|
// ne pas consommer pour un commerce
|
|
}
|
|
|
|
async decrementerQuantiteItem(item, quantite) {
|
|
if (this.system.illimite) {
|
|
return;
|
|
}
|
|
await super.decrementerQuantiteItem(item, quantite, { supprimerSiZero: false });
|
|
}
|
|
|
|
calculerPrix(item) {
|
|
const pourcentage = this.system.pourcentage ?? 100;
|
|
return Misc.keepDecimals(Math.ceil(item.system.cout * pourcentage) / 100, 2);
|
|
}
|
|
} |