Les commerces peuvent appliquer un pourcentage
This commit is contained in:
parent
d5453c9b04
commit
ceacee8e6c
@ -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));
|
||||
|
@ -557,6 +557,7 @@
|
||||
},
|
||||
"commerce":{
|
||||
"templates": [ "description" ],
|
||||
"pourcentage": 100,
|
||||
"illimite": false
|
||||
}
|
||||
},
|
||||
|
@ -10,7 +10,15 @@
|
||||
{{#if @root.options.isObserver}}
|
||||
<div class="form-group">
|
||||
<input {{@root.disabled}} class="attribute-value" type="checkbox" name="system.illimite" {{#if system.illimite}}checked{{/if}}/>
|
||||
<span for="system.illimite">Quantité illimitée en vente</span>
|
||||
<label for="system.illimite">Quantité illimitée en vente</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<span>
|
||||
<label for="system.pourcentage">Appliquer un pourcentage sur les prix</label>
|
||||
<input {{@root.disabled}} class="attribute-value" type="number" data-dtype="Number"
|
||||
name="system.pourcentage" value="{{system.pourcentage}}"
|
||||
min="20" max="500" step="5"/>
|
||||
</span>
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
|
@ -1,7 +1,7 @@
|
||||
{{#if (ne item.type 'monnaie')}}
|
||||
<li class="item flexrow list-item" data-item-id="{{item._id}}" draggable="true">
|
||||
<span class="equipement-nom {{#if (eq item.type 'conteneur')}}conteneur-name{{/if}} ">
|
||||
<a{{#if (ne item.type 'conteneur')}} class="item-edit"{{/if}} >
|
||||
<a{{#if (and (ne item.type 'conteneur') options.isObserver)}} class="item-edit"{{/if}} >
|
||||
{{#if (eq item.type 'conteneur')}}
|
||||
<i class="{{~#if vide}}far fa-square
|
||||
{{else if ouvert}}far fa-minus-square
|
||||
@ -16,11 +16,13 @@
|
||||
{{#unless item.parent.system.illimite}}
|
||||
<span class="equipement-detail flexrow">
|
||||
{{#unless (or (eq item.type 'service') (and (eq item.type 'conteneur') (not vide)))}}
|
||||
{{#if @root.options.isOwner}}
|
||||
{{#if options.isOwner}}
|
||||
<a class="item-quantite-moins"><i class="fas fa-minus-square"></i></a>
|
||||
{{/if}}
|
||||
<input {{#unless @root.options.isOwner}}disabled{{/unless}} type="number" class="item-quantite" name="items[{{key}}].system.quantite" value="{{item.system.quantite}}" data-dtype="Number" />
|
||||
{{#if @root.options.isOwner}}
|
||||
<input {{#unless options.isOwner}}disabled{{/unless}} type="number" data-dtype="Number"
|
||||
class="item-quantite" name="items[{{key}}].system.quantite"
|
||||
value="{{item.system.quantite}}" />
|
||||
{{#if options.isOwner}}
|
||||
<a class="item-quantite-plus"><i class="fas fa-plus-square"></i></a>
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
@ -28,12 +30,18 @@
|
||||
{{/unless}}
|
||||
<span class="equipement-detail">
|
||||
{{#unless (and (eq item.type 'conteneur') (not vide))}}
|
||||
<input {{#unless @root.options.isOwner}}disabled{{/unless}} type="number" class="input-prix number-x3 item-cout" name="items[{{key}}].system.cout" value="{{numberFormat item.system.cout decimals=2 sign=false}}" data-dtype="Number" />
|
||||
<input {{#unless options.isOwner}}disabled{{/unless}} type="number" data-dtype="Number"
|
||||
class="input-prix number-x3 item-cout" name="items[{{key}}].system.cout"
|
||||
{{#if options.isObserver}}
|
||||
value="{{numberFormat item.system.cout decimals=2 sign=false}}"
|
||||
{{else}}
|
||||
value="{{numberFormat (calculerPrixCommercant item) decimals=2 sign=false}}"
|
||||
{{/if}} />
|
||||
{{/unless}}
|
||||
</span>
|
||||
<span class="equipement-actions item-controls">
|
||||
{{#unless (and (eq item.type 'conteneur') (not vide))}}
|
||||
{{#if @root.options.isOwner}}
|
||||
{{#if options.isOwner}}
|
||||
<a class="item-edit" title="Editer"><i class="fas fa-edit"></i></a>
|
||||
<a class="item-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
|
||||
{{#if (or item.parent.system.illimite (ne item.system.quantite 0))}}
|
||||
|
Loading…
Reference in New Issue
Block a user