forked from public/foundryvtt-reve-de-dragon
Boire une potion de soin
This commit is contained in:
@ -27,7 +27,6 @@ import { EffetsDraconiques } from "./tmr/effets-draconiques.js";
|
||||
import { Draconique } from "./tmr/draconique.js";
|
||||
import { RdDCarac } from "./rdd-carac.js";
|
||||
import { Monnaie } from "./item-monnaie.js";
|
||||
import { RdDHerbes } from "./rdd-herbes.js";
|
||||
import { DialogConsommer } from "./dialog-consommer.js";
|
||||
import { DialogFabriquerPotion } from "./dialog-fabriquer-potion.js";
|
||||
|
||||
@ -313,7 +312,7 @@ export class RdDActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async verifierPotionsEnchantees() {
|
||||
let potionsEnchantees = this.filterItemsData(it => it.type == 'potion' && it.data.categorie.toLowerCase().includes('enchante'));
|
||||
let potionsEnchantees = this.filterItemsData(it => it.type == 'potion' && it.data.isEnchante);
|
||||
for (let potion of potionsEnchantees) {
|
||||
if (!potion.prpermanent) {
|
||||
console.log(potion);
|
||||
@ -743,7 +742,6 @@ export class RdDActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
async updateCreatureCompetence(compName, fieldName, compValue) {
|
||||
let comp = this.getCompetence(compName);
|
||||
//console.log(comp);
|
||||
if (comp) {
|
||||
const update = { _id: comp.id }
|
||||
if (fieldName == "niveau")
|
||||
@ -752,7 +750,6 @@ export class RdDActor extends Actor {
|
||||
update['data.dommages'] = compValue;
|
||||
else
|
||||
update['data.carac_value'] = compValue;
|
||||
//console.log(update);
|
||||
const updated = await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
|
||||
}
|
||||
}
|
||||
@ -1610,8 +1607,8 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async consommerDialog(item) {
|
||||
if (!item.isConsommable()) return;
|
||||
async actionItem(item) {
|
||||
if (!item.getActionPrincipale()) return;
|
||||
const dialog = await DialogConsommer.create(this, item);
|
||||
dialog.render(true)
|
||||
}
|
||||
@ -1648,7 +1645,7 @@ export class RdDActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async manger(item, doses, options = { diminuerQuantite: true }) {
|
||||
if (!item.isConsommable()) return;
|
||||
if (!item.getActionPrincipale()) return;
|
||||
await this.apprecierCuisine(item);
|
||||
const sust = Misc.templateData(item).sust;
|
||||
if (sust > 0) {
|
||||
@ -1656,10 +1653,10 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
await item.diminuerQuantite(doses, options);
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async boire(item, doses, options = { diminuerQuantite: true }) {
|
||||
if (!item.isConsommable()) return;
|
||||
if (!item.getActionPrincipale()) return;
|
||||
const tplData = Misc.templateData(item);
|
||||
const desaltere = tplData.desaltere;
|
||||
if (desaltere > 0) {
|
||||
@ -3278,10 +3275,7 @@ export class RdDActor extends Actor {
|
||||
async consommerPotionSoin(potionData) {
|
||||
potionData.alias = this.name;
|
||||
|
||||
if (potionData.data.categorie.includes('Enchante')) {
|
||||
potionData.pointsGuerison = RdDHerbes.calculePointsGuerison(potionData.data);
|
||||
potionData.enchanteTexte = "enchantée";
|
||||
potionData.isEnchante = true;
|
||||
if (potionData.data.isEnchante) {
|
||||
ChatMessage.create({
|
||||
whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
|
||||
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-consommer-potion-soin.html`, potionData)
|
||||
@ -3291,7 +3285,7 @@ export class RdDActor extends Actor {
|
||||
potionData.reussiteReve = false;
|
||||
if (!rolled.isSuccess) {
|
||||
await this.reveActuelIncDec(-1);
|
||||
potionData.guerisonData = await this.buildPotionGuerisonList(potionData.pointsGuerison);
|
||||
potionData.guerisonData = await this.buildPotionGuerisonList(potionData.data.puissance);
|
||||
potionData.guerisonMinutes = potionData.guerisonData.pointsConsommes * 5;
|
||||
potionData.reussiteReve = true;
|
||||
}
|
||||
@ -3300,8 +3294,6 @@ export class RdDActor extends Actor {
|
||||
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-appliquer-potion-soin.html`, potionData)
|
||||
});
|
||||
} else {
|
||||
potionData.enchanteTexte = "";
|
||||
potionData.isEnchante = false;
|
||||
ChatMessage.create({
|
||||
whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
|
||||
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-appliquer-potion-soin.html`, potionData)
|
||||
@ -3314,10 +3306,7 @@ export class RdDActor extends Actor {
|
||||
async consommerPotionRepos(potionData) {
|
||||
potionData.alias = this.name;
|
||||
|
||||
if (potionData.data.categorie.includes('Enchante')) {
|
||||
potionData.casesRepos = RdDHerbes.calculePointsRepos(potionData.data);
|
||||
potionData.enchanteTexte = "enchantée";
|
||||
potionData.isEnchante = true;
|
||||
if (potionData.data.isEnchante) {
|
||||
ChatMessage.create({
|
||||
whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
|
||||
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-consommer-potion-repos.html`, potionData)
|
||||
@ -3328,7 +3317,7 @@ export class RdDActor extends Actor {
|
||||
if (!rolled.isSuccess) {
|
||||
await this.reveActuelIncDec(-1);
|
||||
let fatigueActuelle = this.getFatigueActuelle();
|
||||
potionData.caseFatigueReel = (fatigueActuelle >= potionData.casesRepos) ? potionData.casesRepos : fatigueActuelle;
|
||||
potionData.caseFatigueReel = Math.min(fatigueActuelle, potionData.data.puissance);
|
||||
potionData.guerisonDureeUnite = (potionData.data.reposalchimique) ? "rounds" : "minutes";
|
||||
potionData.guerisonDureeValue = (potionData.data.reposalchimique) ? potionData.caseFatigueReel : potionData.caseFatigueReel * 5;
|
||||
potionData.reussiteReve = true;
|
||||
@ -3346,8 +3335,6 @@ export class RdDActor extends Actor {
|
||||
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-appliquer-potion-repos.html`, potionData)
|
||||
});
|
||||
} else {
|
||||
potionData.enchanteTexte = "";
|
||||
potionData.isEnchante = false;
|
||||
ChatMessage.create({
|
||||
whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
|
||||
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-appliquer-potion-repos.html`, potionData)
|
||||
@ -3386,13 +3373,7 @@ export class RdDActor extends Actor {
|
||||
nbBrinsPotion: herbeData.nbBrins,
|
||||
nbBrinsReste: newQuantite
|
||||
}
|
||||
// TODO:
|
||||
if (newQuantite == 0) {
|
||||
await this.deleteEmbeddedDocuments('Item', [herbeData._id]);
|
||||
} else {
|
||||
let update = { _id: herbeData._id, 'data.quantite': newQuantite };
|
||||
await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
|
||||
}
|
||||
this.getObjet(herbeData._id).diminuerQuantite(herbeData.nbBrins);
|
||||
ChatMessage.create({
|
||||
whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
|
||||
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-fabriquer-potion-base.html`, messageData)
|
||||
@ -3404,13 +3385,6 @@ export class RdDActor extends Actor {
|
||||
async consommerPotionGenerique(potionData) {
|
||||
potionData.alias = this.name;
|
||||
|
||||
if (potionData.data.categorie.includes('Enchante')) {
|
||||
potionData.enchanteTexte = "enchantée";
|
||||
potionData.isEnchante = true;
|
||||
} else {
|
||||
potionData.enchanteTexte = "";
|
||||
potionData.isEnchante = false;
|
||||
}
|
||||
ChatMessage.create({
|
||||
whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
|
||||
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-consommer-potion-generique.html`, potionData)
|
||||
|
Reference in New Issue
Block a user