forked from public/foundryvtt-reve-de-dragon
Enchantement des gemmes et potions
This commit is contained in:
@ -166,22 +166,29 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async $perteRevePotionsEnchantees() {
|
||||
const potionUpdates = this.itemTypes[ITEM_TYPES.potion].map(it => it.perteRevePotion())
|
||||
async $perteReveEnchantementsChateauDormants() {
|
||||
const toUpdate = this.items.filter(it => [ITEM_TYPES.potion, ITEM_TYPES.gemme].includes(it.type))
|
||||
.map(it => it.perteReveChateauDormant())
|
||||
.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
|
||||
})))
|
||||
|
||||
if (toUpdate.length > 0) {
|
||||
console.log('perte de rêve des enchantements', toUpdate)
|
||||
const messageUpdates = await Promise.all(
|
||||
toUpdate.map(async it => await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-pertereve-enchantement-chateaudormant.hbs`, it)))
|
||||
ChatMessage.create({
|
||||
whisper: ChatUtility.getOwners(this),
|
||||
content: messageUpdates.reduce(Misc.joining('<br>'))
|
||||
})
|
||||
await this.updateEmbeddedDocuments('Item', potionUpdates);
|
||||
await this.updateEmbeddedDocuments('Item', toUpdate.map(it => it.update));
|
||||
}
|
||||
}
|
||||
|
||||
async $suppressionLancementsSort() {
|
||||
const updates = this.itemTypes[ITEM_TYPES.sort]
|
||||
.filter(it => it.system.lancements.length > 0)
|
||||
.map(it => { return { _id: it.id, 'system.lancements': [] } })
|
||||
if (updates.length > 0) {
|
||||
await this.updateEmbeddedDocuments('Item', updates)
|
||||
}
|
||||
}
|
||||
|
||||
@ -277,13 +284,14 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
};
|
||||
|
||||
await this._recuperationSante(message)
|
||||
await this._recupereMoralChateauDormant(message);
|
||||
await this._recupereChance();
|
||||
await this.transformerStress();
|
||||
await this.retourSeuilDeReve(message);
|
||||
await this.setBonusPotionSoin(0);
|
||||
await this.retourSust(message);
|
||||
await this.$perteRevePotionsEnchantees();
|
||||
await this._recupereMoralChateauDormant(message)
|
||||
await this._recupereChance()
|
||||
await this.transformerStress()
|
||||
await this.retourSeuilDeReve(message)
|
||||
await this.setBonusPotionSoin(0)
|
||||
await this.retourSust(message)
|
||||
await this.$perteReveEnchantementsChateauDormants()
|
||||
await this.$suppressionLancementsSort()
|
||||
await RdDCoeur.applyCoeurChateauDormant(this, message)
|
||||
if (message.content != "") {
|
||||
message.content = `A la fin Chateau Dormant, ${message.content}<br>Un nouveau jour se lève`;
|
||||
@ -1204,9 +1212,9 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
}
|
||||
}
|
||||
|
||||
async actionHerbe(item, onActionItem = async () => { }) {
|
||||
async fabriquerDecoctionHerbe(item) {
|
||||
if (item.isHerbeAPotion()) {
|
||||
return DialogFabriquerPotion.create(this, item, onActionItem);
|
||||
return DialogFabriquerPotion.create(this, item);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -1726,6 +1734,17 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
if (rollData.isSortReserve) {
|
||||
await this.sortMisEnReserve(selectedSort, rollData.competence, rollData.tmr.coord, Number(selectedSort.system.ptreve_reel));
|
||||
}
|
||||
else {
|
||||
console.log('lancement de sort', rollData.selectedSort)
|
||||
const precedents = rollData.selectedSort.system.lancements ?? []
|
||||
const lancements = [...precedents, {
|
||||
timestamp: game.system.rdd.calendrier.getTimestamp(),
|
||||
reve: rollData.selectedSort.system.ptreve_reel
|
||||
}]
|
||||
await this.updateEmbeddedDocuments('Item',
|
||||
[{ _id: rollData.selectedSort._id, 'system.lancements': lancements }]
|
||||
)
|
||||
}
|
||||
}
|
||||
else {
|
||||
rollData.depenseReve = 0;
|
||||
@ -2849,12 +2868,13 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async fabriquerPotion(herbeData) {
|
||||
let newPotion = {
|
||||
const newPotion = {
|
||||
name: `Potion de ${herbeData.system.categorie} (${herbeData.name})`, type: 'potion',
|
||||
img: "systems/foundryvtt-reve-de-dragon/icons/objets/fiole_verre.webp",
|
||||
system: {
|
||||
quantite: 1, cout: 0, encombrement: 0.1,
|
||||
categorie: herbeData.system.categorie,
|
||||
etat: 'Liquide',
|
||||
herbe: herbeData.name,
|
||||
rarete: herbeData.system.rarete,
|
||||
herbebrins: herbeData.nbBrins,
|
||||
@ -2862,29 +2882,23 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
description: ""
|
||||
}
|
||||
}
|
||||
await this.createEmbeddedDocuments('Item', [newPotion], { renderSheet: true });
|
||||
|
||||
let newQuantite = herbeData.system.quantite - herbeData.nbBrins;
|
||||
let messageData = {
|
||||
alias: this.getAlias(),
|
||||
nbBrinsReste: newQuantite,
|
||||
potion: newPotion,
|
||||
herbe: herbeData
|
||||
}
|
||||
this.diminuerQuantiteObjet(herbeData._id, herbeData.nbBrins);
|
||||
await this.createEmbeddedDocuments('Item', [newPotion])
|
||||
await this.diminuerQuantiteObjet(herbeData._id, herbeData.nbBrins)
|
||||
|
||||
ChatMessage.create({
|
||||
whisper: ChatUtility.getOwners(this),
|
||||
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-fabriquer-potion-base.html`, messageData)
|
||||
});
|
||||
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-fabriquer-potion-base.html`, {
|
||||
alias: this.getAlias(),
|
||||
nbBrinsReste: herbeData.system.quantite - herbeData.nbBrins,
|
||||
potion: newPotion,
|
||||
herbe: herbeData
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async diminuerQuantiteObjet(id, nb, options = { supprimerSiZero: false }) {
|
||||
const item = this.getItem(id);
|
||||
if (item) {
|
||||
await item.diminuerQuantite(nb, options);
|
||||
}
|
||||
await this.getItem(id)?.diminuerQuantite(nb, options);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
Reference in New Issue
Block a user