Rename herbeData (creer potion d'herbe)

This commit is contained in:
Vincent Vandemeulebrouck 2021-04-11 23:03:55 +02:00
parent 893f2aa835
commit a39e2a3256

View File

@ -3363,33 +3363,34 @@ export class RdDActor extends Actor {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async fabriquerPotion(potionData) { async fabriquerPotion(herbeData) {
let newPotion = { let newPotion = {
name: `Potion de ${potionData.data.categorie} (${potionData.name})`, type: 'potion', name: `Potion de ${herbeData.data.categorie} (${herbeData.name})`, type: 'potion',
img: "systems/foundryvtt-reve-de-dragon/icons/objets/fiole_verre.webp", img: "systems/foundryvtt-reve-de-dragon/icons/objets/fiole_verre.webp",
data: { data: {
quantite: 1, valeur_deniers: 1, encombrement: 0.01, quantite: 1, valeur_deniers: 1, encombrement: 0.01,
categorie: potionData.data.categorie, categorie: herbeData.data.categorie,
herbe: potionData.name, herbe: herbeData.name,
rarete: potionData.data.rarete, rarete: herbeData.data.rarete,
herbebrins: potionData.nbBrins, herbebrins: herbeData.nbBrins,
description: "" description: ""
} }
} }
await this.createEmbeddedDocuments('Item', [newPotion], { renderSheet: true }); await this.createEmbeddedDocuments('Item', [newPotion], { renderSheet: true });
let newQuantite = potionData.data.quantite - potionData.nbBrins; let newQuantite = herbeData.data.quantite - herbeData.nbBrins;
let messageData = { let messageData = {
alias: this.name, alias: this.name,
categorie: potionData.data.categorie, categorie: herbeData.data.categorie,
herbe: potionData.name, herbe: herbeData.name,
nbBrinsPotion: potionData.nbBrins, nbBrinsPotion: herbeData.nbBrins,
nbBrinsReste: newQuantite nbBrinsReste: newQuantite
} }
// TODO:
if (newQuantite == 0) { if (newQuantite == 0) {
await this.deleteEmbeddedDocuments('Item', [potionData._id]); await this.deleteEmbeddedDocuments('Item', [herbeData._id]);
} else { } else {
let update = { _id: potionData._id, 'data.quantite': newQuantite }; let update = { _id: herbeData._id, 'data.quantite': newQuantite };
await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
} }
ChatMessage.create({ ChatMessage.create({