forked from public/foundryvtt-reve-de-dragon
#171 - Gestion des potions de repos
This commit is contained in:
@ -310,6 +310,30 @@ export class RdDActor extends Actor {
|
||||
getDemiReve() {
|
||||
return Misc.templateData(this).reve.tmrpos.coord;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async verifierPotionsEnchantees() {
|
||||
let potionsEnchantees = this.filterItemsData( it => it.type == 'potion' && it.data.categorie.toLowerCase().includes('enchante'));
|
||||
for ( let potion of potionsEnchantees) {
|
||||
if ( !potion.prpermanent) {
|
||||
console.log(potion);
|
||||
let newPr = (potion.data.pr > 0) ? potion.data.pr - 1 : 0;
|
||||
let update = { _id: potion._id, 'data.pr': newPr};
|
||||
const updated = await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
|
||||
|
||||
let messageData = {
|
||||
pr : newPr,
|
||||
alias : this.name,
|
||||
potionName : potion.name,
|
||||
potionImg : potion.img
|
||||
}
|
||||
ChatMessage.create({
|
||||
whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
|
||||
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-potionenchantee-chateaudormant.html`, messageData)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async deleteSortReserve(sortReserve) {
|
||||
@ -358,6 +382,7 @@ export class RdDActor extends Actor {
|
||||
await this.retourSeuilDeReve(message);
|
||||
this.bonusRecuperationPotion= 0; // Reset potion
|
||||
await this.retourSust(message);
|
||||
await this.verifierPotionsEnchantees();
|
||||
message.content = `A la fin Chateau Dormant, ${message.content}<br>Un nouveau jour se lève`;
|
||||
ChatMessage.create(message);
|
||||
}
|
||||
@ -3202,7 +3227,7 @@ export class RdDActor extends Actor {
|
||||
return guerisonData;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* -------------------------------------------- */
|
||||
async consommerPotionSoin(potionData) {
|
||||
potionData.alias = this.name;
|
||||
|
||||
@ -3216,22 +3241,17 @@ export class RdDActor extends Actor {
|
||||
});
|
||||
// Gestion de la résistance:
|
||||
let rolled = await RdDResolutionTable.roll(this.getReveActuel(), -8 );
|
||||
potionData.reussiteReve = false;
|
||||
if (!rolled.isSuccess) {
|
||||
await this.reveActuelIncDec(-1);
|
||||
potionData.guerisonData = await this.buildPotionGuerisonList(potionData.pointsGuerison);
|
||||
potionData.guerisonMinutes = potionData.guerisonData.pointsConsommes * 5;
|
||||
potionData.guerisonMinutes = potionData.guerisonData.pointsConsommes * 5;
|
||||
potionData.reussiteReve = true;
|
||||
ChatMessage.create({
|
||||
whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
|
||||
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-appliquer-potion-soin.html`, potionData )
|
||||
});
|
||||
} else {
|
||||
potionData.reussiteReve = false;
|
||||
ChatMessage.create({
|
||||
whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
|
||||
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-appliquer-potion-soin.html`, potionData )
|
||||
});
|
||||
}
|
||||
ChatMessage.create({
|
||||
whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
|
||||
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-appliquer-potion-soin.html`, potionData )
|
||||
});
|
||||
} else {
|
||||
potionData.enchanteTexte = "";
|
||||
potionData.isEnchante = false;
|
||||
@ -3243,17 +3263,64 @@ 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;
|
||||
ChatMessage.create({
|
||||
whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
|
||||
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-consommer-potion-repos.html`, potionData )
|
||||
});
|
||||
// Gestion de la résistance:
|
||||
let rolled = await RdDResolutionTable.roll(this.getReveActuel(), -8 );
|
||||
potionData.reussiteReve = false;
|
||||
if (!rolled.isSuccess) {
|
||||
await this.reveActuelIncDec(-1);
|
||||
let fatigueActuelle = this.getFatigueActuelle();
|
||||
potionData.caseFatigueReel = (fatigueActuelle >= potionData.casesRepos) ? potionData.casesRepos : fatigueActuelle;
|
||||
potionData.guerisonDureeUnite = (potionData.data.reposalchimique) ? "rounds" : "minutes";
|
||||
potionData.guerisonDureeValue = (potionData.data.reposalchimique) ? potionData.caseFatigueReel : potionData.caseFatigueReel*5;
|
||||
potionData.reussiteReve = true;
|
||||
potionData.aphasiePermanente = false;
|
||||
if ( potionData.data.reposalchimique ) {
|
||||
let chanceAphasie = new Roll("1d100").evaluate({async : false} ).total;
|
||||
if ( chanceAphasie <= potionData.data.pr ) {
|
||||
potionData.aphasiePermanente = true;
|
||||
}
|
||||
}
|
||||
await this.santeIncDec("fatigue", -potionData.caseFatigueReel);
|
||||
}
|
||||
ChatMessage.create({
|
||||
whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
|
||||
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 )
|
||||
});
|
||||
this.bonusRepos = potionData.data.herbeBonus;
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async consommerPotion( potion ) {
|
||||
const potionData = Misc.data(potion);
|
||||
|
||||
if ( potionData.data.categorie.includes('Soin')) {
|
||||
this.consommerPotionSoin( potionData);
|
||||
} else if( potion.data.categorie.includes('Repos')) {
|
||||
//TODO
|
||||
} else if( potionData.data.categorie.includes('Repos')) {
|
||||
this.consommerPotionRepos(potionData);
|
||||
} else {
|
||||
//TODO
|
||||
}
|
||||
await this.deleteEmbeddedDocuments('Item', [ potion._id ] );
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -60,6 +60,11 @@ export class RdDHerbes extends Item {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static calculePointsRepos( data ) {
|
||||
return data.herbebonus * data.pr;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static calculePointsGuerison( data ){
|
||||
return data.herbebonus * data.pr;
|
||||
|
@ -187,7 +187,8 @@ export class RdDUtility {
|
||||
'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-alchimie.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/chat-actor-turn-summary.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/chat-actor-competence-xp.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/chat-actor-carac-xp.html'
|
||||
'systems/foundryvtt-reve-de-dragon/templates/chat-actor-carac-xp.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/chat-potionenchantee-chateaudormant.html'
|
||||
];
|
||||
|
||||
Handlebars.registerHelper('upperFirst', str => Misc.upperFirst(str ?? 'Null'));
|
||||
|
Reference in New Issue
Block a user