Auto format

This commit is contained in:
Vincent Vandemeulebrouck 2021-04-11 18:43:32 +02:00
parent 07b68020b2
commit 7dc1724ab7
2 changed files with 69 additions and 65 deletions

View File

@ -310,22 +310,22 @@ 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) {
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};
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
pr: newPr,
alias: this.name,
potionName: potion.name,
potionImg: potion.img
}
ChatMessage.create({
whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
@ -380,7 +380,7 @@ export class RdDActor extends Actor {
await this._recupereChance();
await this.transformerStress();
await this.retourSeuilDeReve(message);
this.bonusRecuperationPotion= 0; // Reset potion
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`;
@ -404,7 +404,7 @@ export class RdDActor extends Actor {
let definition = definitions.find(d => d.type == type);
for (let blessure of liste) {
if (blessure.jours >= definition.facteur) {
let rolled = await this._jetRecuperationConstitution(Misc.toInt(blessure.soins_complets)+this.bonusRecuperationPotion, message);
let rolled = await this._jetRecuperationConstitution(Misc.toInt(blessure.soins_complets) + this.bonusRecuperationPotion, message);
blessure.soins_complets = 0;
if (rolled.isSuccess && this._retrograderBlessure(type, blessure, moindres)) {
message.content += ` -- une blessure ${type} cicatrise`;
@ -2320,7 +2320,7 @@ export class RdDActor extends Actor {
"cout": artData.exotismeFinal < 0 ? 0 : artData.qualiteFinale * 0.01
}
};
if (artData.ajouterEquipement){
if (artData.ajouterEquipement) {
await this.createEmbeddedDocuments('Item', [platCuisine]);
ui.notifications.info(`${platCuisine.data.quantite} rations de ${platCuisine.name} ont été ajoutés à votre équipement`);
}
@ -3187,7 +3187,7 @@ export class RdDActor extends Actor {
}
/* -------------------------------------------- */
async buildPotionGuerisonList( pointsGuerison) {
async buildPotionGuerisonList(pointsGuerison) {
let pointsGuerisonInitial = pointsGuerison;
let myData = Misc.templateData(this);
const blessures = duplicate(myData.blessures);
@ -3195,70 +3195,70 @@ export class RdDActor extends Actor {
console.log(blessures);
for (let critique of blessures.critiques.liste) {
if (critique.active && pointsGuerison >= 6 ) {
if (critique.active && pointsGuerison >= 6) {
pointsGuerison -= 6;
critique.active = false;
guerisonData.list.push( "1 Blessure Critique (6 points)");
guerisonData.list.push("1 Blessure Critique (6 points)");
}
}
for (let grave of blessures.graves.liste) {
if (grave.active && pointsGuerison >= 4 ) {
if (grave.active && pointsGuerison >= 4) {
pointsGuerison -= 4;
grave.active = false;
guerisonData.list.push( "1 Blessure Grave (4 points)");
guerisonData.list.push("1 Blessure Grave (4 points)");
}
}
for (let legere of blessures.legeres.liste) {
if (legere.active && pointsGuerison >= 2 ) {
if (legere.active && pointsGuerison >= 2) {
pointsGuerison -= 2;
legere.active = false;
guerisonData.list.push( "1 Blessure Légère (2 points)");
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 ));
pointsGuerison -= pvSoignees*2;
guerisonData.list.push( pvSoignees + " Points de Vie soignés");
let pvSoignees = Math.min(pvManquants, Math.floor(pointsGuerison / 2));
pointsGuerison -= pvSoignees * 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) {
potionData.alias = this.name;
if (potionData.data.categorie.includes('Enchante')) {
potionData.pointsGuerison = RdDHerbes.calculePointsGuerison( potionData.data);
potionData.pointsGuerison = RdDHerbes.calculePointsGuerison(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-soin.html`, potionData )
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 );
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 )
});
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 )
});
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-appliquer-potion-soin.html`, potionData)
});
this.bonusRecuperationPotion = potionData.data.herbeBonus;
}
}
@ -3268,27 +3268,27 @@ export class RdDActor extends Actor {
potionData.alias = this.name;
if (potionData.data.categorie.includes('Enchante')) {
potionData.casesRepos = RdDHerbes.calculePointsRepos( potionData.data);
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 )
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 );
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.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 ) {
if (potionData.data.reposalchimique) {
let chanceAphasie = new Roll("1d100").evaluate({ async: false }).total;
if (chanceAphasie <= potionData.data.pr) {
potionData.aphasiePermanente = true;
}
}
@ -3296,62 +3296,64 @@ export class RdDActor extends Actor {
}
ChatMessage.create({
whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-appliquer-potion-repos.html`, potionData )
});
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 )
});
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-appliquer-potion-repos.html`, potionData)
});
this.bonusRepos = potionData.data.herbeBonus;
}
}
/* -------------------------------------------- */
dialogFabriquerPotion( herbe ) {
dialogFabriquerPotion(herbe) {
DialogFabriquerPotion.create(this, herbe, {
html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-fabriquer-potion-base.html',
}, []);
}
/* -------------------------------------------- */
async fabriquerPotion( potionData ) {
async fabriquerPotion(potionData) {
let newPotion = {
name: `Potion de ${potionData.data.categorie} (${potionData.name})`, type: 'potion',
img: "systems/foundryvtt-reve-de-dragon/icons/objets/fiole_verre.webp",
data: { quantite: 1, valeur_deniers: 1, encombrement: 0.01,
data: {
quantite: 1, valeur_deniers: 1, encombrement: 0.01,
categorie: potionData.data.categorie,
herbe: potionData.name,
herbe: potionData.name,
rarete: potionData.data.rarete,
herbebrins: potionData.nbBrins,
description: "" }
description: ""
}
}
await this.createEmbeddedDocuments('Item', [newPotion], { renderSheet: true });
await this.createEmbeddedDocuments('Item', [newPotion], { renderSheet: true });
let newQuantite = potionData.data.quantite - potionData.nbBrins;
let messageData = {
alias: this.name,
categorie: potionData.data.categorie,
herbe: potionData.name,
nbBrinsPotion: potionData.nbBrins,
categorie: potionData.data.categorie,
herbe: potionData.name,
nbBrinsPotion: potionData.nbBrins,
nbBrinsReste: newQuantite
}
if (newQuantite == 0 ) {
await this.deleteEmbeddedDocuments('Item', [ potionData._id ] );
if (newQuantite == 0) {
await this.deleteEmbeddedDocuments('Item', [potionData._id]);
} else {
let update = { _id: potionData._id, 'data.quantite': newQuantite};
let update = { _id: potionData._id, 'data.quantite': newQuantite };
await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
}
ChatMessage.create({
whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
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`, messageData)
});
}
}
/* -------------------------------------------- */
async consommerPotionGenerique( potionData ) {
async consommerPotionGenerique(potionData) {
potionData.alias = this.name;
if (potionData.data.categorie.includes('Enchante')) {
@ -3363,22 +3365,22 @@ export class RdDActor extends Actor {
}
ChatMessage.create({
whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-consommer-potion-generique.html`, potionData )
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-consommer-potion-generique.html`, potionData)
});
}
}
/* -------------------------------------------- */
async consommerPotion( potion ) {
async consommerPotion(potion) {
const potionData = Misc.data(potion);
if ( potionData.data.categorie.includes('Soin')) {
this.consommerPotionSoin( potionData);
} else if( potionData.data.categorie.includes('Repos')) {
if (potionData.data.categorie.includes('Soin')) {
this.consommerPotionSoin(potionData);
} else if (potionData.data.categorie.includes('Repos')) {
this.consommerPotionRepos(potionData);
} else {
this.consommerPotionGenerique(potionData);
this.consommerPotionGenerique(potionData);
}
await this.deleteEmbeddedDocuments('Item', [ potion.id ] );
await this.deleteEmbeddedDocuments('Item', [potion.id]);
}
/* -------------------------------------------- */

View File

@ -9,9 +9,11 @@ export class RdDItem extends Item {
static getTypeObjetsEquipement() {
return typesObjetsEquipement;
}
static getTypesOeuvres() {
return typesObjetsOeuvres;
}
prepareDerivedData() {
super.prepareDerivedData();
const itemData = this.data;