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 {
|
2023-01-03 13:38:04 +01:00
|
|
|
|
2023-01-01 22:21:30 +01:00
|
|
|
static get defaultIcon() {
|
|
|
|
return "systems/foundryvtt-reve-de-dragon/icons/services/commerce.webp";
|
|
|
|
}
|
|
|
|
|
|
|
|
canReceive(item) {
|
2023-11-03 20:21:17 +01:00
|
|
|
return item.isInventaire('all');
|
2023-01-01 22:21:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
getQuantiteDisponible(item) {
|
2023-06-12 23:04:32 +02:00
|
|
|
return (this.system.illimite || item?.isService()) ? undefined : item.getQuantite();
|
2023-01-01 22:21:30 +01:00
|
|
|
}
|
2023-01-03 13:38:04 +01:00
|
|
|
|
2023-01-01 22:21:30 +01:00
|
|
|
verifierFortune(cout) {
|
|
|
|
return this.system.illimite || super.verifierFortune(cout);
|
|
|
|
}
|
2023-07-27 19:16:59 +02:00
|
|
|
|
2023-01-01 22:21:30 +01:00
|
|
|
async depenserSols(cout) {
|
|
|
|
if (this.system.illimite) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
await super.depenserSols(cout)
|
|
|
|
}
|
2024-06-01 01:53:14 +02:00
|
|
|
async consommerNourritureboisson(itemId, choix, userId) {
|
2023-01-01 22:21:30 +01:00
|
|
|
// ne pas consommer pour un commerce
|
|
|
|
}
|
|
|
|
|
2023-01-05 14:32:35 +01:00
|
|
|
async decrementerQuantiteItem(item, quantite) {
|
2023-01-01 22:21:30 +01:00
|
|
|
if (this.system.illimite) {
|
|
|
|
return;
|
|
|
|
}
|
2023-01-05 14:32:35 +01:00
|
|
|
await super.decrementerQuantiteItem(item, quantite, { supprimerSiZero: false });
|
2023-01-01 22:21:30 +01:00
|
|
|
}
|
|
|
|
|
2023-01-03 01:37:50 +01:00
|
|
|
calculerPrix(item) {
|
|
|
|
const pourcentage = this.system.pourcentage ?? 100;
|
2023-01-03 13:38:04 +01:00
|
|
|
return Misc.keepDecimals(Math.ceil(item.system.cout * pourcentage) / 100, 2);
|
2023-01-03 01:37:50 +01:00
|
|
|
}
|
2023-01-01 22:21:30 +01:00
|
|
|
}
|