forked from public/foundryvtt-reve-de-dragon
#171 - Gestion potion de soins (WIP)
This commit is contained in:
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
Reference in New Issue
Block a user