forked from public/foundryvtt-reve-de-dragon
		
	
		
			
				
	
	
		
			53 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			1.3 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) {
 | |
|     if (item.isInventaire('all')) {
 | |
|       return true;
 | |
|     }
 | |
|     return super.canReceive(item);
 | |
|   }
 | |
| 
 | |
|   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);
 | |
|   }
 | |
| } |