Auto formatting
This commit is contained in:
parent
c9cc1de16e
commit
e7b9070cf1
180
module/actor.js
180
module/actor.js
@ -216,8 +216,7 @@ export class RdDActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
getBestDraconic() {
|
||||
const list = this.getDraconicList().sort((a, b) => b.data.niveau - a.data.niveau);
|
||||
if (list.length==0)
|
||||
{
|
||||
if (list.length == 0) {
|
||||
return { name: "none", niveau: -11 };
|
||||
}
|
||||
return duplicate(list[0]);
|
||||
@ -241,11 +240,8 @@ export class RdDActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getSurprise() {
|
||||
if (this.isEntiteCauchemar()) {
|
||||
return '';
|
||||
}
|
||||
// TODO: gérer une liste de flags demi-surprise (avec icône sur le token)?
|
||||
if ( this.data.data.sante.sonne && this.data.data.sante.sonne.value) {
|
||||
if (this.getSonne()) {
|
||||
return 'demi';
|
||||
}
|
||||
return '';
|
||||
@ -277,7 +273,7 @@ export class RdDActor extends Actor {
|
||||
await this._recupererVie(message);
|
||||
await this.transformerStress(message);
|
||||
await this.retourSeuilDeReve(message);
|
||||
message.content = "A la fin Chateau Dormant, " + message.content +"<br>Un nouveau jour se lève";
|
||||
message.content = `A la fin Chateau Dormant, ${message.content}<br>Un nouveau jour se lève`;
|
||||
ChatMessage.create(message);
|
||||
}
|
||||
|
||||
@ -291,16 +287,16 @@ export class RdDActor extends Actor {
|
||||
let rolled = await this._jetRecuperationConstitution(Misc.toInt(blessure.soins_complets), message);
|
||||
blessure.soins_complets = 0;
|
||||
if (rolled.isSuccess && this._retrograderBlessure(type, blessure, moindres)) {
|
||||
message.content += " -- une blessure " + type + " cicatrise";
|
||||
message.content += ` -- une blessure ${type} cicatrise`;
|
||||
count++;
|
||||
}
|
||||
else if (rolled.isETotal) {
|
||||
message.content += " -- une blessure " + type + " s'infecte (temps de guérison augmenté de " + definition.facteur + " jours, perte de vie)";
|
||||
message.content += ` -- une blessure ${type} s'infecte (temps de guérison augmenté de ${definition.facteur} jours, perte de vie)`;
|
||||
blessure.jours = 0;
|
||||
await this.santeIncDec("vie", -1);
|
||||
}
|
||||
else {
|
||||
message.content += " -- une blessure " + type + " reste stable";
|
||||
message.content += ` -- une blessure ${type} reste stable`;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -310,8 +306,7 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_retrograderBlessure(type, blessure, blessuresMoindres)
|
||||
{
|
||||
_retrograderBlessure(type, blessure, blessuresMoindres) {
|
||||
if (type != "legere") {
|
||||
let retrograde = blessuresMoindres.find(b => !b.active);
|
||||
if (!retrograde) {
|
||||
@ -335,8 +330,7 @@ export class RdDActor extends Actor {
|
||||
let vieManquante = this.data.data.sante.vie.max - this.data.data.sante.vie.value;
|
||||
if (nbBlessures == 0 && vieManquante > 0) {
|
||||
let bonusSoins = 0;
|
||||
for (let b of blessures)
|
||||
{
|
||||
for (let b of blessures) {
|
||||
bonusSoins = Math.max(bonusSoins, Misc.toInt(b.soins_complets));
|
||||
}
|
||||
let rolled = await this._jetRecuperationConstitution(bonusSoins, message)
|
||||
@ -418,8 +412,7 @@ export class RdDActor extends Actor {
|
||||
let ethylisme = duplicate(this.data.data.compteurs.ethylisme);
|
||||
ethylisme.nb_doses = 0;
|
||||
ethylisme.jet_moral = false;
|
||||
if (ethylisme.value < 1)
|
||||
{
|
||||
if (ethylisme.value < 1) {
|
||||
ethylisme.value = Math.min(ethylisme.value + 1, 1);
|
||||
if (ethylisme.value <= 0) {
|
||||
message.content += `<br>Vous dégrisez un peu (${RdDUtility.getNomEthylisme(ethylisme.value)})`;
|
||||
@ -448,23 +441,20 @@ export class RdDActor extends Actor {
|
||||
fatigue.value = Math.max(fatigueMin, this._calculRecuperationSegment(fatigue.value));
|
||||
console.log("recupererFatigue", fatigue)
|
||||
await this.update({ "data.sante.fatigue": fatigue });
|
||||
if (fatigue.value == 0)
|
||||
{
|
||||
if (fatigue.value == 0) {
|
||||
message.content += "<br>Vous êtes bien reposé";
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_calculRecuperationSegment(actuel)
|
||||
{
|
||||
_calculRecuperationSegment(actuel) {
|
||||
const segments = RdDUtility.getSegmentsFatigue(this.data.data.sante.endurance.max);
|
||||
let cumul = 0;
|
||||
let i;
|
||||
for (i = 0; i < 11; i++) {
|
||||
cumul += segments[i];
|
||||
let diff = cumul - actuel;
|
||||
if (diff >= 0)
|
||||
{
|
||||
if (diff >= 0) {
|
||||
const limit2Segments = Math.floor(segments[i] / 2);
|
||||
if (diff > limit2Segments && i > 0) {
|
||||
cumul -= segments[i - 1]; // le segment est à moins de la moitié, il est récupéré
|
||||
@ -486,8 +476,7 @@ export class RdDActor extends Actor {
|
||||
else {
|
||||
let deRecuperation = (await DeDraconique.ddr("selfroll")).total;
|
||||
console.log("recuperationReve", deRecuperation);
|
||||
if (deRecuperation>=7)
|
||||
{
|
||||
if (deRecuperation >= 7) {
|
||||
// Rêve de Dragon !
|
||||
message.content += `<br>Vous faites un <strong>Rêve de Dragon</strong> de ${deRecuperation} Points de rêve`;
|
||||
message.content += await this.combattreReveDeDragon(deRecuperation);
|
||||
@ -553,8 +542,7 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async updateCarac( caracName, caracValue )
|
||||
{
|
||||
async updateCarac(caracName, caracValue) {
|
||||
let caracpath = "data.carac." + caracName + ".value"
|
||||
if (caracName == "reve") {
|
||||
if (caracValue > Misc.toInt(this.data.data.reve.seuil.value)) {
|
||||
@ -565,16 +553,14 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async updateCaracXP( caracName, caracXP )
|
||||
{
|
||||
async updateCaracXP(caracName, caracXP) {
|
||||
let caracpath = "data.carac." + caracName + ".xp";
|
||||
await this.update({ [caracpath]: caracXP });
|
||||
this.checkCaracXP(caracName);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async updateCreatureCompetence( compName, fieldName, compValue )
|
||||
{
|
||||
async updateCreatureCompetence(compName, fieldName, compValue) {
|
||||
let comp = this.getCompetence(compName);
|
||||
console.log(comp);
|
||||
if (comp) {
|
||||
@ -591,8 +577,7 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async updateCompetence( compName, compValue )
|
||||
{
|
||||
async updateCompetence(compName, compValue) {
|
||||
let comp = this.getCompetence(compName);
|
||||
if (comp) {
|
||||
let troncList = RdDUtility.isTronc(compName);
|
||||
@ -604,7 +589,8 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
ChatMessage.create({
|
||||
whisper: ChatMessage.getWhisperRecipients(game.user.name),
|
||||
content: message } );
|
||||
content: message
|
||||
});
|
||||
}
|
||||
const update = { _id: comp._id, 'data.niveau': maxNiveau };
|
||||
const updated = await this.updateEmbeddedEntity("OwnedItem", update); // Updates one EmbeddedEntity
|
||||
@ -614,8 +600,7 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async updateCompetenceXP( compName, compValue )
|
||||
{
|
||||
async updateCompetenceXP(compName, compValue) {
|
||||
let comp = this.getCompetence(compName);
|
||||
if (comp) {
|
||||
const update = { _id: comp._id, 'data.xp': compValue };
|
||||
@ -626,8 +611,7 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async updateCompetenceArchetype( compName, compValue )
|
||||
{
|
||||
async updateCompetenceArchetype(compName, compValue) {
|
||||
let comp = this.getCompetence(compName);
|
||||
if (comp) {
|
||||
const update = { _id: comp._id, 'data.niveau_archetype': compValue };
|
||||
@ -638,8 +622,7 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async updateCompteurValue( fieldName, fieldValue )
|
||||
{
|
||||
async updateCompteurValue(fieldName, fieldValue) {
|
||||
//console.log("Update", fieldName, fieldValue);
|
||||
let compteurs = duplicate(this.data.data.compteurs);
|
||||
compteurs[fieldName].value = fieldValue;
|
||||
@ -647,8 +630,7 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async updateProtectionValue( fieldName, fieldValue )
|
||||
{
|
||||
async updateProtectionValue(fieldName, fieldValue) {
|
||||
let attributs = duplicate(this.data.data.attributs);
|
||||
attributs[fieldName].value = fieldValue;
|
||||
await this.update({ "data.attributs": attributs });
|
||||
@ -855,8 +837,7 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
computeEtatGeneral( )
|
||||
{
|
||||
computeEtatGeneral() {
|
||||
let data = this.data.data;
|
||||
// Pas d'état général pour les entités forçage à 0
|
||||
if (this.data.type == 'entite') {
|
||||
@ -1031,10 +1012,7 @@ export class RdDActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getSonne() {
|
||||
if ( !this.isEntiteCauchemar() && this.data.data.sante.sonne ) {
|
||||
return this.data.data.sante.sonne.value;
|
||||
}
|
||||
return false;
|
||||
return !this.isEntiteCauchemar() && (this.data.data.sante.sonne?.value ?? false);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -1063,13 +1041,11 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
countBlessures( blessuresListe )
|
||||
{
|
||||
countBlessures(blessuresListe) {
|
||||
return blessuresListe.filter(b => b.active).length
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
countBlessuresByName( name )
|
||||
{
|
||||
countBlessuresByName(name) {
|
||||
return this.countBlessures(this.data.data.blessures[name].liste);
|
||||
}
|
||||
|
||||
@ -1101,9 +1077,10 @@ export class RdDActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async santeIncDec(name, inc, isCritique = false) {
|
||||
|
||||
const sante = duplicate(this.data.data.sante);
|
||||
let data = sante[name];
|
||||
if (data==undefined) {
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
let minValue = 0;
|
||||
@ -1464,8 +1441,7 @@ export class RdDActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
async rollUnSort(coord) {
|
||||
let sortList = duplicate(this.getSortList()); // Duplication car les pts de reve sont modifiés dans le sort
|
||||
if (!sortList || sortList.length == 0)
|
||||
{
|
||||
if (!sortList || sortList.length == 0) {
|
||||
ui.notifications.info("Aucun sort disponible!");
|
||||
return;
|
||||
}
|
||||
@ -1484,7 +1460,8 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
const dialog = await RdDRoll.create(this, rollData,
|
||||
{ html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-sort.html',
|
||||
{
|
||||
html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-sort.html',
|
||||
close: html => { this.currentTMR.maximize() } // Re-display TMR
|
||||
},
|
||||
{
|
||||
@ -1521,7 +1498,8 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
ChatMessage.create({
|
||||
content: "Vous êtes sous le coup d'une Mauvaise Rencontre en Persective." + addMsg,
|
||||
whisper: ChatMessage.getWhisperRecipients(game.user.name) } );
|
||||
whisper: ChatMessage.getWhisperRecipients(game.user.name)
|
||||
});
|
||||
}
|
||||
return rencSpecial;
|
||||
}
|
||||
@ -1532,7 +1510,8 @@ export class RdDActor extends Actor {
|
||||
if (inertieDraconique) {
|
||||
ChatMessage.create({
|
||||
content: "Vous êtes sous le coup d'une Inertie Draconique : vous perdez 2 cases de Fatigue par déplacement au lieu d'1.",
|
||||
whisper: ChatMessage.getWhisperRecipients(game.user.name) } );
|
||||
whisper: ChatMessage.getWhisperRecipients(game.user.name)
|
||||
});
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
@ -1555,7 +1534,8 @@ export class RdDActor extends Actor {
|
||||
if (resistFleuve) {
|
||||
ChatMessage.create({
|
||||
content: "Vous êtes sous le coup d'une Double Résistance du Fleuve : vous devez maîtriser 2 fois chaque case humide, un second jet est donc effectué.",
|
||||
whisper: ChatMessage.getWhisperRecipients(game.user.name) } );
|
||||
whisper: ChatMessage.getWhisperRecipients(game.user.name)
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -1568,7 +1548,8 @@ export class RdDActor extends Actor {
|
||||
await this.reveActuelIncDec(-1);
|
||||
ChatMessage.create({
|
||||
content: "Vous êtes sous le coup d'un Péage : l'entrée sur cette case vous coûte 1 Point de Rêve (déduit automatiquement).",
|
||||
whisper: ChatMessage.getWhisperRecipients(game.user.name) } );
|
||||
whisper: ChatMessage.getWhisperRecipients(game.user.name)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -1587,7 +1568,8 @@ export class RdDActor extends Actor {
|
||||
if (pontHumide && cellDescr.type == 'pont') {
|
||||
ChatMessage.create({
|
||||
content: "Vous êtes sous le coup d'une Impraticabilité des Ponts : ils doivent être maîtrisés comme des cases humides.",
|
||||
whisper: ChatMessage.getWhisperRecipients(game.user.name) } );
|
||||
whisper: ChatMessage.getWhisperRecipients(game.user.name)
|
||||
});
|
||||
return true;
|
||||
}
|
||||
// Débordement ?
|
||||
@ -1714,7 +1696,8 @@ export class RdDActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async creerTacheDepuisLivre(item) {
|
||||
let tache = { name: "Lire " + item.name, type: 'tache',
|
||||
let tache = {
|
||||
name: "Lire " + item.name, type: 'tache',
|
||||
data: {
|
||||
carac: 'intellect',
|
||||
competence: 'Ecriture',
|
||||
@ -1836,8 +1819,7 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollAppelChance(onSuccess = () => {}, onEchec = () => {})
|
||||
{
|
||||
async rollAppelChance(onSuccess = () => { }, onEchec = () => { }) {
|
||||
let rollData = { selectedCarac: this.getCaracByName('chance-actuelle'), surprise: '' };
|
||||
const dialog = await RdDRoll.create(this, rollData,
|
||||
{ html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html' },
|
||||
@ -1907,8 +1889,10 @@ export class RdDActor extends Actor {
|
||||
if (rolled.isPart && rolled.finalLevel < 0) {
|
||||
// Cas de désir lancinant, pas d'expérience sur particulière
|
||||
if (this.checkDesirLancinant()) {
|
||||
ChatMessage.create( { content: `Vous souffrez au moins d'un Désir Lancinant, vous ne pouvez pas gagner d'expérience sur une Particulière tant que le désir n'est pas assouvi`,
|
||||
whisper: ChatMessage.getWhisperRecipients(game.user.name) } );
|
||||
ChatMessage.create({
|
||||
content: `Vous souffrez au moins d'un Désir Lancinant, vous ne pouvez pas gagner d'expérience sur une Particulière tant que le désir n'est pas assouvi`,
|
||||
whisper: ChatMessage.getWhisperRecipients(game.user.name)
|
||||
});
|
||||
return { result: false, xpcarac: 0, xpCompetence: 0 };
|
||||
}
|
||||
|
||||
@ -1931,8 +1915,10 @@ export class RdDActor extends Actor {
|
||||
selectedCarac.xp = Misc.toInt(selectedCarac.xp) + xpCarac;
|
||||
await this.update({ "data.carac": carac });
|
||||
} else {
|
||||
ChatMessage.create( { content: `Vous avez ${xpCarac} à répartir pour la caractérisque dérivée ${caracName}. Vous devez le faire manuellement.`,
|
||||
whisper: ChatMessage.getWhisperRecipients(game.user.name) } );
|
||||
ChatMessage.create({
|
||||
content: `Vous avez ${xpCarac} à répartir pour la caractérisque dérivée ${caracName}. Vous devez le faire manuellement.`,
|
||||
whisper: ChatMessage.getWhisperRecipients(game.user.name)
|
||||
});
|
||||
}
|
||||
}
|
||||
return { result: true, xpCarac: xpCarac, xpCompetence: xpComp }; //XP
|
||||
@ -1948,8 +1934,10 @@ export class RdDActor extends Actor {
|
||||
this._appliquerAjoutExperience(data);
|
||||
|
||||
// Ajout du nombre astral
|
||||
const item = {name: "Nombre Astral", type: "nombreastral", data:
|
||||
{ value: data.nbAstral, istrue: data.isvalid, jourindex: Number(data.date), jourlabel: game.system.rdd.calendrier.getDateFromIndex( Number(data.date) ) } };
|
||||
const item = {
|
||||
name: "Nombre Astral", type: "nombreastral", data:
|
||||
{ value: data.nbAstral, istrue: data.isvalid, jourindex: Number(data.date), jourlabel: game.system.rdd.calendrier.getDateFromIndex(Number(data.date)) }
|
||||
};
|
||||
await this.createEmbeddedEntity("OwnedItem", item);
|
||||
|
||||
// Suppression des anciens nombres astraux
|
||||
@ -1970,8 +1958,7 @@ export class RdDActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getCaracByName(caracName) {
|
||||
switch (caracName)
|
||||
{
|
||||
switch (caracName) {
|
||||
case 'reve-actuel': case 'Rêve actuel':
|
||||
return {
|
||||
label: 'Rêve actuel',
|
||||
@ -1990,8 +1977,7 @@ export class RdDActor extends Actor {
|
||||
|
||||
static _findCaracByName(carac, name) {
|
||||
name = name.toLowerCase();
|
||||
switch (name)
|
||||
{
|
||||
switch (name) {
|
||||
case 'reve-actuel': case 'rêve actuel':
|
||||
return carac.reve;
|
||||
case 'chance-actuelle': case 'chance actuelle':
|
||||
@ -2021,23 +2007,23 @@ export class RdDActor extends Actor {
|
||||
if (monteLaborieuse) {
|
||||
ChatMessage.create({
|
||||
content: "Vous êtes sous le coup d'une Montée Laborieuse : vos montées en TMR coûtent 1 Point de Rêve de plus.",
|
||||
whisper: ChatMessage.getWhisperRecipients(game.user.name) } );
|
||||
whisper: ChatMessage.getWhisperRecipients(game.user.name)
|
||||
});
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async displayTMR(mode="normal")
|
||||
{
|
||||
async displayTMR(mode = "normal") {
|
||||
let isRapide = mode == "rapide";
|
||||
if (mode != "visu")
|
||||
{
|
||||
if (mode != "visu") {
|
||||
let minReveValue = (isRapide) ? 3 : 2;
|
||||
if (this.getReveActuel() < minReveValue) {
|
||||
ChatMessage.create({
|
||||
content: "Vous n'avez plus assez de Points de Reve pour monter dans les Terres Médianes",
|
||||
whisper: ChatMessage.getWhisperRecipients(game.user.name) } );
|
||||
whisper: ChatMessage.getWhisperRecipients(game.user.name)
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -2108,7 +2094,6 @@ export class RdDActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
computeArmure(attackerRoll) {
|
||||
let locData = attackerRoll.loc;
|
||||
let dmg = attackerRoll.dmg.dmgArme + attackerRoll.dmg.dmgActor;
|
||||
let arme = attackerRoll.arme;
|
||||
// TODO: arc ignore armure
|
||||
@ -2126,8 +2111,7 @@ export class RdDActor extends Actor {
|
||||
update.data.protection = "1d" + update.data.protection;
|
||||
// if ( update.data.protection.toString().length == 1 )
|
||||
// update.data.protection = "1d"+update.data.protection;
|
||||
else if (res = /(\d+d\d+)(\-\d+)?/.exec( update.data.protection ))
|
||||
{
|
||||
else if (res = /(\d+d\d+)(\-\d+)?/.exec(update.data.protection)) {
|
||||
let malus = Misc.toInt(res[2]) - 1;
|
||||
update.data.protection = res[1] + malus;
|
||||
}
|
||||
@ -2139,6 +2123,7 @@ export class RdDActor extends Actor {
|
||||
this.updateEmbeddedEntity("OwnedItem", update);
|
||||
}
|
||||
}
|
||||
// TODO: max armure (chutes)
|
||||
const penetration = arme ? Misc.toInt(arme.data.penetration) : 0;
|
||||
protection = Math.max(protection - penetration, 0);
|
||||
protection += this.getProtectionNaturelle();
|
||||
@ -2153,13 +2138,6 @@ export class RdDActor extends Actor {
|
||||
new RdDEncaisser(html, this).render(true);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async encaisser( ) {
|
||||
let data = { ajustementsEncaissement: RdDUtility.getAjustementsEncaissement() };
|
||||
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-encaisser.html', data );
|
||||
new RdDEncaisser(html, this).render(true);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async encaisserDommages(attackerRoll, attacker = undefined) {
|
||||
if (attacker && !await attacker.accorder(this, 'avant-encaissement')) {
|
||||
@ -2222,8 +2200,7 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
ajouterBlessure( encaissement )
|
||||
{
|
||||
ajouterBlessure(encaissement) {
|
||||
// Fast exit
|
||||
if (this.data.type == 'entite') return; // Une entité n'a pas de blessures
|
||||
if (encaissement.legeres + encaissement.graves + encaissement.critiques == 0) return;
|
||||
@ -2296,18 +2273,15 @@ export class RdDActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
/* -- entites -- */
|
||||
/* retourne true si on peut continuer, false si on ne peut pas continuer */
|
||||
async targetEntiteNonAccordee(target, when='avant-encaissement')
|
||||
{
|
||||
if (target)
|
||||
{
|
||||
async targetEntiteNonAccordee(target, when = 'avant-encaissement') {
|
||||
if (target) {
|
||||
return !await this.accorder(target.actor, when);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async accorder(entite, when = 'avant-encaissement')
|
||||
{
|
||||
async accorder(entite, when = 'avant-encaissement') {
|
||||
if (when != game.settings.get("foundryvtt-reve-de-dragon", "accorder-entite-cauchemar")
|
||||
|| !entite.isEntiteCauchemar()
|
||||
|| entite.isEntiteCauchemarAccordee(this)) {
|
||||
@ -2334,22 +2308,19 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
isEntiteCauchemar()
|
||||
{
|
||||
isEntiteCauchemar() {
|
||||
return this.data.type == 'entite';
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
isEntiteCauchemarAccordee(attaquant)
|
||||
{
|
||||
isEntiteCauchemarAccordee(attaquant) {
|
||||
if (!this.isEntiteCauchemar()) { return true; }
|
||||
let resonnance = this.data.data.sante.resonnance;
|
||||
return (resonnance.actors.find(it => it == attaquant._id));
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async setEntiteReveAccordee(attaquant)
|
||||
{
|
||||
async setEntiteReveAccordee(attaquant) {
|
||||
if (!this.isEntiteCauchemar()) {
|
||||
ui.notifications.error("Impossible de s'accorder à " + this.name + ": ce n'est pas une entite de cauchemer/rêve");
|
||||
return;
|
||||
@ -2463,7 +2434,8 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
const dialog = await RdDRoll.create(this, rollData,
|
||||
{ html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-alchimie.html',
|
||||
{
|
||||
html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-alchimie.html',
|
||||
},
|
||||
{
|
||||
name: 'tache-alchimique',
|
||||
|
@ -494,18 +494,18 @@ export class RdDCombat {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_getDiviseurSignificative(rollData) {
|
||||
let facteurSign = (this.defender.isDemiSurprise() || rollData.needParadeSignificative) ? 2 : 1;
|
||||
if (RdDBonus.isDefenseAttaqueFinesse(rollData)) {
|
||||
_getDiviseurSignificative(defenderRoll) {
|
||||
let facteurSign = (this.defender.isDemiSurprise() || defenderRoll.needParadeSignificative) ? 2 : 1;
|
||||
if (RdDBonus.isDefenseAttaqueFinesse(defenderRoll)) {
|
||||
facteurSign *= 2;
|
||||
}
|
||||
return facteurSign;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_onParadeParticuliere(rollData) {
|
||||
console.log("RdDCombat._onParadeParticuliere >>>", rollData);
|
||||
if (!rollData.attackerRoll.isPart) {
|
||||
_onParadeParticuliere(defenderRoll) {
|
||||
console.log("RdDCombat._onParadeParticuliere >>>", defenderRoll);
|
||||
if (!defenderRoll.attackerRoll.isPart) {
|
||||
// TODO: attaquant doit jouer résistance et peut être désarmé p132
|
||||
ChatUtility.chatWithRollMode({
|
||||
content: `(à gérer) L'attaquant doit jouer résistance et peut être désarmé (p132)`
|
||||
@ -514,25 +514,25 @@ export class RdDCombat {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async _onParadeNormale(rollData) {
|
||||
console.log("RdDCombat._onParadeNormale >>>", rollData);
|
||||
async _onParadeNormale(defenderRoll) {
|
||||
console.log("RdDCombat._onParadeNormale >>>", defenderRoll);
|
||||
|
||||
this._consumeDefense(rollData.passeArme);
|
||||
await this.computeRecul(rollData);
|
||||
await this.computeDeteriorationArme(rollData);
|
||||
this._consumeDefense(defenderRoll.passeArme);
|
||||
await this.computeRecul(defenderRoll);
|
||||
await this.computeDeteriorationArme(defenderRoll);
|
||||
|
||||
await RdDResolutionTable.displayRollData(rollData, this.defender, 'chat-resultat-parade.html');
|
||||
await RdDResolutionTable.displayRollData(defenderRoll, this.defender, 'chat-resultat-parade.html');
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async _onParadeEchec(rollData) {
|
||||
console.log("RdDCombat._onParadeEchec >>>", rollData);
|
||||
async _onParadeEchec(defenderRoll) {
|
||||
console.log("RdDCombat._onParadeEchec >>>", defenderRoll);
|
||||
|
||||
await RdDResolutionTable.displayRollData(rollData, this.defender, 'chat-resultat-parade.html');
|
||||
await RdDResolutionTable.displayRollData(defenderRoll, this.defender, 'chat-resultat-parade.html');
|
||||
|
||||
this.removeChatMessageActionsPasseArme(rollData.passeArme);
|
||||
this._sendMessageDefense(rollData.attackerRoll, { defense: true });
|
||||
this._storeDefense(rollData);
|
||||
this.removeChatMessageActionsPasseArme(defenderRoll.passeArme);
|
||||
this._sendMessageDefense(defenderRoll.attackerRoll, { defense: true });
|
||||
this._storeDefense(defenderRoll);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -656,11 +656,11 @@ export class RdDCombat {
|
||||
}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async computeRecul(rollData) { // Calcul du recul (p. 132)
|
||||
const attaque = rollData.attackerRoll;
|
||||
if (this._isAttaqueCauseRecul(attaque)) {
|
||||
async computeRecul(defenderRoll) { // Calcul du recul (p. 132)
|
||||
const attackerRoll = defenderRoll.attackerRoll;
|
||||
if (this._isAttaqueCauseRecul(attackerRoll)) {
|
||||
|
||||
let impactRecul = this._computeImpactRecul(attaque);
|
||||
let impactRecul = this._computeImpactRecul(attackerRoll);
|
||||
const agilite = this.defender.isEntiteCauchemar()
|
||||
? this.defender.data.data.carac.reve.value
|
||||
: this.defender.data.data.carac.agilite.value;
|
||||
@ -668,13 +668,13 @@ export class RdDCombat {
|
||||
let rollRecul = await RdDResolutionTable.rollData({ caracValue: 10, finalLevel: impactRecul, showDice: false });
|
||||
|
||||
if (rollRecul.isSuccess) {
|
||||
rollData.show.recul = 'encaisse';
|
||||
defenderRoll.show.recul = 'encaisse';
|
||||
} else if (rollRecul.isETotal) {
|
||||
rollData.show.recul = 'chute';
|
||||
defenderRoll.show.recul = 'chute';
|
||||
}
|
||||
else {
|
||||
let chute = await RdDResolutionTable.rollData({ caracValue: agilite, finalLevel: impactRecul, showDice: false });
|
||||
rollData.show.recul = (chute.isSuccess)
|
||||
defenderRoll.show.recul = (chute.isSuccess)
|
||||
? 'recul'
|
||||
: 'chute';
|
||||
}
|
||||
@ -701,7 +701,13 @@ export class RdDCombat {
|
||||
console.log("RdDCombat.encaisser >>>", attackerRoll, defenderTokenId);
|
||||
|
||||
let defenderRoll = this._consumeDefense(attackerRoll.passeArme);
|
||||
if (defenderRoll && RdDCombat.isEchecTotal(defenderRoll)) {
|
||||
if (!defenderRoll) {
|
||||
defenderRoll = {
|
||||
attackerRoll: attackerRoll,
|
||||
show: {}
|
||||
};
|
||||
}
|
||||
else if (RdDCombat.isEchecTotal(defenderRoll)) {
|
||||
// TODO: echec total!!!
|
||||
this._onEchecTotal(defenderRoll);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ export class RdDDice {
|
||||
if (game.modules.get("dice-so-nice") && game.modules.get("dice-so-nice").active) {
|
||||
let whisper = null;
|
||||
let blind = false;
|
||||
rollMode = rollMode || game.settings.get("core", "rollMode");
|
||||
rollMode = rollMode ?? game.settings.get("core", "rollMode");
|
||||
switch (rollMode) {
|
||||
case "blindroll": //GM only
|
||||
blind = true;
|
||||
|
@ -551,10 +551,10 @@ export class RdDUtility {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static _evaluatePerte(formula, over20) {
|
||||
console.log("_evaluatePerte", formula, over20)
|
||||
let perte = new Roll(formula, { over20: over20 })
|
||||
perte.evaluate()
|
||||
return perte.total
|
||||
console.log("_evaluatePerte", formula, over20);
|
||||
let perte = new Roll(formula, { over20: over20 });
|
||||
perte.evaluate();
|
||||
return perte.total;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
Loading…
Reference in New Issue
Block a user