diff --git a/module/actor.js b/module/actor.js index e5c399ab..ab6bf606 100644 --- a/module/actor.js +++ b/module/actor.js @@ -27,6 +27,7 @@ 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"; /* -------------------------------------------- */ @@ -619,6 +620,7 @@ export class RdDActor extends Actor { dialog.render(true); } + /* -------------------------------------------- */ async resultCombatReveDeDragon(rollData) { rollData.queues = []; if (rollData.rolled.isEchec) { @@ -3051,9 +3053,85 @@ export class RdDActor extends Actor { } /* -------------------------------------------- */ - consommerPotion( potion ) { + async buildPotionGuerisonList( pointsGuerison) { + let pointsGuerisonInitial = pointsGuerison; + let myData = Misc.templateData(this); + const blessures = duplicate(myData.blessures); + let guerisonData = { list: [], pointsConsommes: 0 } + + console.log(blessures); + for (let critique of blessures.critiques.liste) { + if (critique.active && pointsGuerison >= 6 ) { + pointsGuerison -= 6; + critique.active = false; + guerisonData.list.push( "1 Blessure Critique (6 points)"); + } + } + for (let grave of blessures.graves.liste) { + if (grave.active && pointsGuerison >= 4 ) { + pointsGuerison -= 4; + grave.active = false; + guerisonData.list.push( "1 Blessure Grave (4 points)"); + } + } + for (let legere of blessures.legeres.liste) { + if (legere.active && pointsGuerison >= 2 ) { + pointsGuerison -= 2; + legere.active = false; + guerisonData.list.push( "1 Blessure Légère (2 points)"); + } + } + await this.update({ "data.blessures": blessures }); + + let pvManquants = myData.sante.vie.max - myData.sante.vie.value; + let pvSoignees = Math.min(pvManquants, Math.floor(pointsGuerison / 2 )); + guerisonData.list.push( pvSoignees + " Points de Vie soignés"); + await this.santeIncDec('vie', +pvSoignees, false); + guerisonData.pointsConsommes = pointsGuerisonInitial - pointsGuerison; + + return guerisonData; + } + + /* -------------------------------------------- */ + async consommerPotionSoin(potionData) { + if (potionData.data.categorie.includes('Enchante')) { + potionData.pointsGuerison = RdDHerbes.calculePointsGuerison( potionData.data); + potionData.alias = this.name; + potionData.enchanteTexte = "enchantée"; + potionData.isEnchante = true; + ChatMessage.create({ + whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name), + content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-consommer-potion-soin.html`, potionData ) + }); + // Gestion de la résistance: + let rolled = await RdDResolutionTable.roll(this.getReveActuel(), -8 ); + if (!rolled.isSuccess) { + await this.reveActuelIncDec(-1); + potionData.guerisonData = await this.buildPotionGuerisonList(potionData.pointsGuerison); + potionData.guerisonMinutes = potionData.guerisonData.pointsConsommes * 5; + ChatMessage.create({ + whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name), + content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-appliquer-potion-soin.html`, potionData ) + }); + } else { + + } + } else { + + } + } + + /* -------------------------------------------- */ + async consommerPotion( potion ) { const potionData = Misc.data(potion); - console.log("Potion consommée", potionData); + + if ( potionData.data.categorie.includes('Soin')) { + this.consommerPotionSoin( potionData); + } else if( potion.data.categorie.includes('Repos')) { + //TODO + } else { + //TODO + } } /* -------------------------------------------- */ diff --git a/system.json b/system.json index c2818c66..6de0bc62 100644 --- a/system.json +++ b/system.json @@ -2,11 +2,11 @@ "name": "foundryvtt-reve-de-dragon", "title": "Rêve de Dragon", "description": "Rêve de Dragon RPG for FoundryVTT", - "version": "1.4.1", + "version": "1.4.2", "manifestPlusVersion": "1.0.0", "minimumCoreVersion": "0.7.5", "compatibleCoreVersion": "0.7.9", - "templateVersion": 111, + "templateVersion": 112, "author": "LeRatierBretonnien", "authors": [ { diff --git a/template.json b/template.json index b8f084e6..98fbdca9 100644 --- a/template.json +++ b/template.json @@ -726,6 +726,7 @@ "herbe": "", "herbebrins": 0, "herbebonus": 0, + "reposalchimique": false, "pr": 0, "prpermanent": false, "prdate": 0, diff --git a/templates/item-potion-sheet.html b/templates/item-potion-sheet.html index 7164df1e..0a0d78cf 100644 --- a/templates/item-potion-sheet.html +++ b/templates/item-potion-sheet.html @@ -5,7 +5,7 @@
{{#if isOwned}} {{/if}} @@ -57,6 +57,26 @@ {{/if}} + {{#if isRepos}} +