Fix: on peut de nouveau acheter aux commerces
This commit is contained in:
parent
a96f4bf641
commit
6e405ea753
@ -1,5 +1,9 @@
|
|||||||
# 13.0
|
# 13.0
|
||||||
|
|
||||||
|
## 13.0.3 - La dernière auberge d'Illysis
|
||||||
|
|
||||||
|
- On peut de nouveau acheter aux commerces
|
||||||
|
|
||||||
## 13.0.0 - Le début de l'errance d'Illysis
|
## 13.0.0 - Le début de l'errance d'Illysis
|
||||||
|
|
||||||
- Migration vers la version 13 de Foundry
|
- Migration vers la version 13 de Foundry
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import { DialogItemAchat } from "../achat-vente/dialog-item-achat.js";
|
|
||||||
import { RdDItem } from "../item.js";
|
import { RdDItem } from "../item.js";
|
||||||
import { RdDUtility } from "../rdd-utility.js";
|
|
||||||
import { RdDBaseActorSheet } from "./base-actor-sheet.js";
|
import { RdDBaseActorSheet } from "./base-actor-sheet.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,13 +42,8 @@ export class RdDCommerceSheet extends RdDBaseActorSheet {
|
|||||||
activateListeners(html) {
|
activateListeners(html) {
|
||||||
super.activateListeners(html);
|
super.activateListeners(html);
|
||||||
|
|
||||||
this.html.find('a.item-acheter').click(async event => await this.vente(this.getItem(event)));
|
|
||||||
this.html.find('.service-acheter').click(async event => await this.vente(this.getItem(event)));
|
|
||||||
|
|
||||||
if (!this.options.editable) return;
|
if (!this.options.editable) return;
|
||||||
|
|
||||||
this.html.find('a.item-quantite-moins').click(async event => await this.getItem(event)?.quantiteIncDec(-1, { supprimerSiZero: false }));
|
|
||||||
this.html.find('a.item-quantite-plus').click(async event => await this.getItem(event)?.quantiteIncDec(1));
|
|
||||||
this.html.find('input.item-quantite').change(async event => {
|
this.html.find('input.item-quantite').change(async event => {
|
||||||
const newQuantite = Math.max(0, Number.parseInt(this.html.find(event.currentTarget).val()));
|
const newQuantite = Math.max(0, Number.parseInt(this.html.find(event.currentTarget).val()));
|
||||||
await this.getItem(event)?.update({ "system.quantite": newQuantite });
|
await this.getItem(event)?.update({ "system.quantite": newQuantite });
|
||||||
@ -64,28 +57,4 @@ export class RdDCommerceSheet extends RdDBaseActorSheet {
|
|||||||
getTypesInventaire() {
|
getTypesInventaire() {
|
||||||
return RdDItem.getItemTypesInventaire('all');
|
return RdDItem.getItemTypesInventaire('all');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async vente(item) {
|
|
||||||
const acheteur = RdDUtility.getSelectedActor();
|
|
||||||
if (!acheteur) {
|
|
||||||
ui.notifications.warn(`Pas d'acheteur sélectionné`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const disponible = this.actor.getQuantiteDisponible(item)
|
|
||||||
if (disponible == 0) {
|
|
||||||
ui.notifications.warn(`${this.getAlias()} n'a plus de ${item.name} en vente`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await DialogItemAchat.onAcheter({
|
|
||||||
item,
|
|
||||||
vendeur: this.actor,
|
|
||||||
acheteur,
|
|
||||||
quantiteIllimite: disponible == undefined,
|
|
||||||
nbLots: disponible ?? 1,
|
|
||||||
tailleLot: 1,
|
|
||||||
prixLot: item.calculerPrixCommercant()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
|
import { DialogItemAchat } from "../achat-vente/dialog-item-achat.js";
|
||||||
import { Misc } from "../misc.js";
|
import { Misc } from "../misc.js";
|
||||||
|
import { RdDUtility } from "../rdd-utility.js";
|
||||||
import { RdDBaseActor } from "./base-actor.js";
|
import { RdDBaseActor } from "./base-actor.js";
|
||||||
|
|
||||||
export class RdDCommerce extends RdDBaseActor {
|
export class RdDCommerce extends RdDBaseActor {
|
||||||
@ -37,4 +39,27 @@ export class RdDCommerce extends RdDBaseActor {
|
|||||||
const pourcentage = this.system.pourcentage ?? 100;
|
const pourcentage = this.system.pourcentage ?? 100;
|
||||||
return Misc.keepDecimals(Math.ceil(item.system.cout * pourcentage) / 100, 2);
|
return Misc.keepDecimals(Math.ceil(item.system.cout * pourcentage) / 100, 2);
|
||||||
}
|
}
|
||||||
|
async vente(item) {
|
||||||
|
const acheteur = RdDUtility.getSelectedActor();
|
||||||
|
if (!acheteur) {
|
||||||
|
ui.notifications.warn(`Pas d'acheteur sélectionné`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const disponible = this.getQuantiteDisponible(item)
|
||||||
|
if (disponible == 0) {
|
||||||
|
ui.notifications.warn(`${this.getAlias()} n'a plus de ${item.name} en vente`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await DialogItemAchat.onAcheter({
|
||||||
|
item,
|
||||||
|
vendeur: this,
|
||||||
|
acheteur,
|
||||||
|
quantiteIllimite: disponible == undefined,
|
||||||
|
nbLots: disponible ?? 1,
|
||||||
|
tailleLot: 1,
|
||||||
|
prixLot: item.calculerPrixCommercant()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
import { ACTOR_TYPES } from "../constants.js"
|
||||||
import { Misc } from "../misc.js"
|
import { Misc } from "../misc.js"
|
||||||
import { RdDSheetUtility } from "../rdd-sheet-utility.js"
|
import { RdDSheetUtility } from "../rdd-sheet-utility.js"
|
||||||
import { RdDUtility } from "../rdd-utility.js"
|
import { RdDUtility } from "../rdd-utility.js"
|
||||||
@ -19,9 +20,8 @@ const _VENDRE = {
|
|||||||
}
|
}
|
||||||
const _ACHAT_SERVICE = {
|
const _ACHAT_SERVICE = {
|
||||||
code: 'item-service-acheter', label: 'Acheter', icon: it => 'fa-regular fa-coins',
|
code: 'item-service-acheter', label: 'Acheter', icon: it => 'fa-regular fa-coins',
|
||||||
//filter: it => Misc.toInt(it.system.quantite) > 0,
|
filter: it => Misc.toInt(it.system.quantite) > 0 && it.parent?.type == ACTOR_TYPES.commerce,
|
||||||
//optionsFilter: options => options.editable,
|
action: (item, actor) => actor.vente(item)
|
||||||
//action: (item, actor) => item.proposerVente()
|
|
||||||
}
|
}
|
||||||
const _MONTRER = {
|
const _MONTRER = {
|
||||||
code: 'item-montrer', label: 'Montrer', icon: it => 'fa-solid fa-comment',
|
code: 'item-montrer', label: 'Montrer', icon: it => 'fa-solid fa-comment',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user