forked from public/foundryvtt-reve-de-dragon
Ajout des "boutiques"
Une boutique est un Item service permettant de définir l'inventaire en vente, et de le vendre facilement. Les boutiques peuvent être accédées par les joueurs (avec le lien) pour y faire leurs courses.
This commit is contained in:
@ -58,6 +58,7 @@ export const defaultItemImg = {
|
||||
poison: "systems/foundryvtt-reve-de-dragon/icons/maladies_venins/venin.webp",
|
||||
oeuvre: "systems/foundryvtt-reve-de-dragon/icons/competence_comedie.webp",
|
||||
nourritureboisson: "systems/foundryvtt-reve-de-dragon/icons/objets/provision_crue.webp",
|
||||
service: "systems/foundryvtt-reve-de-dragon/icons/items/services.webp",
|
||||
signedraconique: "systems/foundryvtt-reve-de-dragon/icons/tmr/signe_draconique.webp",
|
||||
gemme: "systems/foundryvtt-reve-de-dragon/icons/gemmes/almaze.webp",
|
||||
possession: "systems/foundryvtt-reve-de-dragon/icons/entites/possession2.webp",
|
||||
@ -73,10 +74,6 @@ export class RdDItem extends Item {
|
||||
return game.system.rdd.itemClasses[itemType]?.defaultIcon ?? defaultItemImg[itemType];
|
||||
}
|
||||
|
||||
static isItemInventaire(newLocal) {
|
||||
return typesObjetsInventaire.includes(newLocal.type);
|
||||
}
|
||||
|
||||
static isFieldInventaireModifiable(type, field) {
|
||||
switch (field) {
|
||||
case 'quantite':
|
||||
@ -154,7 +151,7 @@ export class RdDItem extends Item {
|
||||
return typesObjetsCompetence.includes(this.type)
|
||||
}
|
||||
isInventaire() {
|
||||
return RdDItem.isItemInventaire(this)
|
||||
return typesObjetsInventaire.includes(this.type);
|
||||
}
|
||||
isOeuvre() {
|
||||
return typesObjetsOeuvres.includes(this.type)
|
||||
@ -222,7 +219,7 @@ export class RdDItem extends Item {
|
||||
}
|
||||
|
||||
getQuantite() {
|
||||
return Math.round(this.isConteneur() ? 1 : (this.system.quantite ?? 0))
|
||||
return Math.round(this.system.quantite ?? 0)
|
||||
}
|
||||
|
||||
getEncTotal() {
|
||||
@ -297,7 +294,7 @@ export class RdDItem extends Item {
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async actionPrincipale(actor, onActionItem = async () => { }) {
|
||||
if (!this.getActionPrincipale()) {
|
||||
@ -423,31 +420,38 @@ export class RdDItem extends Item {
|
||||
return [true, undefined];
|
||||
}
|
||||
|
||||
async proposerVente() {
|
||||
async proposerVente({ service = undefined, quantiteMax = undefined }) {
|
||||
console.log(this);
|
||||
if (this.isConteneurNonVide()) {
|
||||
ui.notifications.warn(`Votre ${this.name} n'est pas vide, pas possible de le proposer`);
|
||||
return;
|
||||
}
|
||||
await DialogItemVente.display(this, async (vente) => {
|
||||
vente["properties"] = this.getProprietes();
|
||||
if (vente.isOwned) {
|
||||
if (vente.quantiteNbLots * vente.tailleLot > vente.quantiteMax) {
|
||||
ui.notifications.warn(`Vous avez ${vente.quantiteMax} ${vente.item.name}, ce n'est pas suffisant pour vendre ${vente.quantiteNbLots} de ${vente.tailleLot}`)
|
||||
return;
|
||||
await DialogItemVente.display({
|
||||
item: this,
|
||||
service,
|
||||
quantiteMax,
|
||||
callback: async (vente) => {
|
||||
vente["properties"] = this.getProprietes();
|
||||
if (vente.isOwned) {
|
||||
if (vente.quantiteNbLots * vente.tailleLot > vente.quantiteMax) {
|
||||
ui.notifications.warn(`Vous avez ${vente.quantiteMax} ${vente.item.name}, ce n'est pas suffisant pour vendre ${vente.quantiteNbLots} de ${vente.tailleLot}`)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
vente.jsondata = JSON.stringify(vente.item);
|
||||
vente.jsondata = JSON.stringify(vente.item);
|
||||
|
||||
console.log(vente);
|
||||
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-vente-item.html', vente);
|
||||
ChatMessage.create(RdDUtility.chatDataSetup(html));
|
||||
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-vente-item.html', vente);
|
||||
ChatMessage.create(RdDUtility.chatDataSetup(html));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getProprietes() {
|
||||
return this[`_${this.type}ChatData`]().filter(it => it != undefined);
|
||||
if (this[`_${this.type}ChatData`]) {
|
||||
return this[`_${this.type}ChatData`]().filter(it => it != undefined);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -465,12 +469,19 @@ export class RdDItem extends Item {
|
||||
payload: chatData,
|
||||
});
|
||||
|
||||
renderTemplate('systems/foundryvtt-reve-de-dragon/templates/post-item.html', chatData).then(html => {
|
||||
renderTemplate(this.getChatItemTemplate(), chatData).then(html => {
|
||||
let chatOptions = RdDUtility.chatDataSetup(html, modeOverride);
|
||||
ChatMessage.create(chatOptions)
|
||||
});
|
||||
}
|
||||
|
||||
getChatItemTemplate() {
|
||||
switch (this.type) {
|
||||
case 'service': return 'systems/foundryvtt-reve-de-dragon/templates/post-item-service.html';
|
||||
}
|
||||
return 'systems/foundryvtt-reve-de-dragon/templates/post-item.html';
|
||||
}
|
||||
|
||||
static propertyIfDefined(name, val, condition = true) {
|
||||
return condition ? `<b>${name}</b>: ${val}` : undefined;
|
||||
}
|
||||
@ -719,5 +730,4 @@ export class RdDItem extends Item {
|
||||
...this._inventaireTemplateChatData()
|
||||
]
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user