2023-01-03 01:37:50 +01:00
|
|
|
import { Misc } from "../misc.js";
|
2023-01-01 22:21:30 +01:00
|
|
|
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) {
|
2023-01-03 00:31:32 +01:00
|
|
|
if (item.isInventaire('all')) {
|
2023-01-01 22:21:30 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return super.canReceive(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
getQuantiteDisponible(item) {
|
|
|
|
return this.system.illimite ? 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(itemVendu, quantite) {
|
|
|
|
if (this.system.illimite) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
await super.decrementerQuantiteItem(itemVendu, quantite, {supprimerSiZero: false});
|
|
|
|
}
|
|
|
|
|
2023-01-03 01:37:50 +01:00
|
|
|
calculerPrix(item) {
|
|
|
|
const pourcentage = this.system.pourcentage ?? 100;
|
|
|
|
return Misc.keepDecimals(Math.ceil(item.system.cout * pourcentage)/100, 2);
|
|
|
|
}
|
2023-01-01 22:21:30 +01:00
|
|
|
}
|