forked from public/foundryvtt-reve-de-dragon
Enchanter des Potions
This commit is contained in:
@ -167,28 +167,23 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async $perteRevePotionsEnchantees() {
|
||||
let potions = this.itemTypes[ITEM_TYPES.potion]
|
||||
.filter(it => Grammar.includesLowerCaseNoAccent(it.system.categorie, 'enchanté') && !it.system.prpermanent)
|
||||
|
||||
const potionUpdates = await Promise.all(potions.map(async it => {
|
||||
const nouveauReve = Math.max(it.system.pr - 1, 0)
|
||||
const potionUpdates = this.itemTypes[ITEM_TYPES.potion].map(
|
||||
it.perteRevePotion())
|
||||
.filter(it => it != undefined)
|
||||
if (potionUpdates.length > 0) {
|
||||
console.log('perte rêve de potions', potionUpdates)
|
||||
const messageUpdates = await Promise.all(potionUpdates.map(async p => await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-potionenchantee-chateaudormant.html`, {
|
||||
pr: foundry.utils.getProperty(p, 'system.pr'),
|
||||
alias: this.getAlias(),
|
||||
potionName: p.name,
|
||||
potionImg: p.img
|
||||
})))
|
||||
ChatMessage.create({
|
||||
whisper: ChatUtility.getOwners(this),
|
||||
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-potionenchantee-chateaudormant.html`, {
|
||||
pr: nouveauReve,
|
||||
alias: this.getAlias(),
|
||||
potionName: it.name,
|
||||
potionImg: it.img
|
||||
})
|
||||
content: messageUpdates.reduce(Misc.joining('<br>'))
|
||||
})
|
||||
return {
|
||||
_id: it._id,
|
||||
'system.pr': nouveauReve,
|
||||
'system.quantite': nouveauReve > 0 ? it.system.quantite : 0
|
||||
}
|
||||
}))
|
||||
|
||||
await this.updateEmbeddedDocuments('Item', potionUpdates);
|
||||
await this.updateEmbeddedDocuments('Item', potionUpdates);
|
||||
}
|
||||
}
|
||||
|
||||
/** --------------------------------------------
|
||||
|
Reference in New Issue
Block a user