Merge branch 'amelioration-encaissement' into 'v1.2'
#100 Amélioration messages encaissement See merge request LeRatierBretonnien/foundryvtt-reve-de-dragon!109
This commit is contained in:
commit
0290b182ca
321
module/actor.js
321
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);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -1047,29 +1025,32 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
testSiSonne( sante, endurance )
|
||||
{
|
||||
let result = new Roll("1d20").roll().total;
|
||||
if ( result <= endurance)
|
||||
sante.sonne.value = false;
|
||||
if ( result > endurance || result == 20) // 20 is always a failure
|
||||
sante.sonne.value = true;
|
||||
if (result == 1) {
|
||||
sante.sonne.value = false;
|
||||
testSiSonne(sante, endurance) {
|
||||
const roll = new Roll("1d20").roll();
|
||||
roll.showDice = true;
|
||||
RdDDice.show(roll);
|
||||
let result = {
|
||||
roll: roll,
|
||||
sonne: roll.total > endurance || roll.total == 20
|
||||
}
|
||||
if (roll.total == 1) {
|
||||
let xp = Misc.toInt(this.data.data.carac.constitution.xp) + 1;
|
||||
this.update({ "data.carac.constitution.xp": xp }); // +1 XP !
|
||||
// TODO : Output to chat
|
||||
}
|
||||
if (result.sonne) {
|
||||
// 20 is always a failure
|
||||
sante.sonne.value = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
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,45 +1082,54 @@ 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 result = {
|
||||
sonne: false,
|
||||
};
|
||||
|
||||
let minValue = 0;
|
||||
if (this.type == 'personnage') {
|
||||
// TODO: les animaux/humanoïdes on théoriquement aussi un sconst, mais la SPA n'est pas passé par là
|
||||
minValue = name == "vie" ? -Number(this.data.data.attributs.sconst.value) : 0;
|
||||
}
|
||||
|
||||
let newValue = Math.max(minValue, Math.min(data.value + inc, data.max));
|
||||
//console.log("New value ", inc, minValue, newValue);
|
||||
result.newValue = Math.max(minValue, Math.min(data.value + inc, data.max));
|
||||
//console.log("New value ", inc, minValue, result.newValue);
|
||||
|
||||
if (name == "endurance" && this.data.type != 'entite') {
|
||||
if (sante.fatigue && inc < 0) { // Each endurance lost -> fatigue lost
|
||||
sante.fatigue.value = sante.fatigue.value - inc
|
||||
}
|
||||
if ( !isCritique && newValue == 0 && inc < 0) { // perte endurance et endurance devient 0 -> -1 vie sauf si coup critique
|
||||
if (!isCritique && result.newValue == 0 && inc < 0) { // perte endurance et endurance devient 0 -> -1 vie sauf si coup critique
|
||||
sante.vie.value = sante.vie.value - 1;
|
||||
}
|
||||
newValue = Math.max(0, newValue);
|
||||
result.newValue = Math.max(0, result.newValue);
|
||||
if (inc > 0) { // le max d'endurance s'applique seulement à la récupération
|
||||
newValue = Math.min(newValue, this._computeEnduranceMax())
|
||||
result.newValue = Math.min(result.newValue, this._computeEnduranceMax())
|
||||
}
|
||||
if (data.value - newValue > 1) {
|
||||
this.testSiSonne(sante, newValue); // Peut-être sonné si 2 points d'endurance perdus d'un coup
|
||||
} else if (inc>0) {
|
||||
if (data.value - result.newValue > 1) {
|
||||
// Peut-être sonné si 2 points d'endurance perdus d'un coup
|
||||
const testIsSonne = this.testSiSonne(sante, result.newValue);
|
||||
result.sonne = testIsSonne.sonne;
|
||||
result.jetEndurance = testIsSonne.roll.total;
|
||||
} else if (inc > 0 && !this.isEntiteCauchemar()) {
|
||||
sante.sonne.value = false;
|
||||
}
|
||||
}
|
||||
data.value = newValue;
|
||||
//console.log(name, inc, data.value, newValue, minValue, data.max);
|
||||
data.value = result.newValue;
|
||||
//console.log(name, inc, data.value, result.newValue, minValue, data.max);
|
||||
if (sante.fatigue) { // If endurance lost, then the same amount of fatigue cannot be recovered
|
||||
sante.fatigue.value = Math.max(sante.fatigue.value, this._computeFatigueMin());
|
||||
}
|
||||
//console.log("SANTE::::", sante);
|
||||
|
||||
await this.update({ "data.sante": sante });
|
||||
return result;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -1411,8 +1401,9 @@ export class RdDActor extends Actor {
|
||||
value: carac.value,
|
||||
xp: carac.xp
|
||||
}
|
||||
let content = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-carac-xp.html`, xpData);
|
||||
ChatUtility.createChatMessage({ content: content }, "default", this.name);
|
||||
ChatUtility.createChatMessage(this.name, "default", {
|
||||
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-carac-xp.html`, xpData)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1436,8 +1427,9 @@ export class RdDActor extends Actor {
|
||||
archetype: competence.data.niveau_archetype,
|
||||
archetypeWarning: competence.data.niveau > competence.data.niveau_archetype
|
||||
}
|
||||
let content = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-competence-xp.html`, xpData);
|
||||
ChatUtility.createChatMessage({ content: content }, "default", this.name);
|
||||
ChatUtility.createChatMessage(this.name, "default", {
|
||||
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-competence-xp.html`, xpData)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1464,8 +1456,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 +1475,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 +1513,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 +1525,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 +1549,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 +1563,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 +1583,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 +1711,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 +1834,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 +1904,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 +1930,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 +1949,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 +1973,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 +1992,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 +2022,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 +2109,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 +2126,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 +2138,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 +2153,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')) {
|
||||
@ -2168,62 +2161,67 @@ export class RdDActor extends Actor {
|
||||
|
||||
console.log("encaisserDommages", attackerRoll)
|
||||
|
||||
let santeOrig = duplicate(this.data.data.sante);
|
||||
let encaissement = this.jetEncaissement(attackerRoll);
|
||||
|
||||
this.ajouterBlessure(encaissement); // Will upate the result table
|
||||
|
||||
await this.santeIncDec("vie", encaissement.vie);
|
||||
await this.santeIncDec("endurance", encaissement.endurance, (encaissement.critiques > 0));
|
||||
|
||||
const blessureLegere = (encaissement.legeres > 0 ? "une blessure légère" : "");
|
||||
const blessureGrave = (encaissement.graves > 0 ? "une blessure grave" : "");
|
||||
const blessureCritique = (encaissement.critiques > 0 ? "une blessure critique" : "");
|
||||
|
||||
let commonMsg = {
|
||||
title: "Blessures !",
|
||||
roll: encaissement.roll,
|
||||
content: `${this.data.name} a encaissé ${blessureLegere}${blessureGrave}${blessureCritique} (${encaissement.locName})`
|
||||
}
|
||||
let addonMsg = "<br>Et a perdu : <br>" + encaissement.endurance + " Endurance et " + encaissement.vie + " Points de Vie";
|
||||
if ( this.hasPlayerOwner ) {
|
||||
commonMsg.content += addonMsg; // Message pour tout le monde
|
||||
ChatMessage.create( commonMsg );
|
||||
} else { // Le defenseur n'est pas un PJ, donc message complet uniquement pour le MJ
|
||||
ChatMessage.create( commonMsg ); // Message pour tout le monde
|
||||
let gmMsg = duplicate(commonMsg);
|
||||
gmMsg.content = addonMsg; // Et message complémentaire uniquement pour le MJ
|
||||
gmMsg.whisper = ChatMessage.getWhisperRecipients( "GM" );
|
||||
ChatMessage.create( gmMsg );
|
||||
}
|
||||
const perteVie = await this.santeIncDec("vie", - encaissement.vie);
|
||||
const perteEndurance = await this.santeIncDec("endurance", -encaissement.endurance, (encaissement.critiques > 0));
|
||||
|
||||
this.computeEtatGeneral();
|
||||
this.sheet.render(false);
|
||||
|
||||
let santeActuelle = duplicate(this.data.data.sante);
|
||||
|
||||
encaissement.alias = this.data.name;
|
||||
encaissement.hasPlayerOwner = this.hasPlayerOwner;
|
||||
encaissement.resteEndurance = santeActuelle.endurance.value
|
||||
encaissement.sonne = perteEndurance.sonne;
|
||||
encaissement.jetEndurance = perteEndurance.jetEndurance,
|
||||
encaissement.endurance = santeOrig.endurance.value - perteEndurance.newValue;
|
||||
encaissement.vie = santeOrig.vie.value - perteVie.newValue;
|
||||
|
||||
ChatUtility.createChatWithRollMode(this.name, {
|
||||
roll: encaissement.roll,
|
||||
content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-resultat-encaissement.html', encaissement)
|
||||
});
|
||||
|
||||
if (!encaissement.hasPlayerOwner && encaissement.endurance != 0) {
|
||||
encaissement = duplicate(encaissement);
|
||||
encaissement.isGM = true;
|
||||
ChatMessage.create({
|
||||
whisper: ChatMessage.getWhisperRecipients("GM"),
|
||||
content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-resultat-encaissement.html', encaissement)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
jetEncaissement(rollData) {
|
||||
|
||||
rollData.dmg.loc = rollData.dmg.loc?? RdDUtility.getLocalisation();
|
||||
|
||||
const roll = new Roll("2d10 + @dmg - @armure", {
|
||||
dmg: rollData.dmg.total,
|
||||
armure: this.computeArmure( rollData )
|
||||
}).roll();
|
||||
const roll = new Roll("2d10").roll();
|
||||
roll.showDice = true;
|
||||
RdDDice.show(roll, game.settings.get("core", "rollMode"));
|
||||
|
||||
let encaissement = RdDUtility.selectEncaissement(roll.total, rollData.dmg.mortalite)
|
||||
let over20 = Math.max(roll.total - 20, 0);
|
||||
const armure = this.computeArmure(rollData);
|
||||
const jetTotal = roll.total + rollData.dmg.total - armure;
|
||||
|
||||
let encaissement = RdDUtility.selectEncaissement(jetTotal, rollData.dmg.mortalite)
|
||||
let over20 = Math.max(jetTotal - 20, 0);
|
||||
encaissement.dmg = rollData.dmg;
|
||||
encaissement.dmg.loc = rollData.dmg.loc ?? RdDUtility.getLocalisation();
|
||||
encaissement.dmg.loc.label = encaissement.dmg.loc.label ?? 'Corps;'
|
||||
encaissement.roll = roll;
|
||||
encaissement.vie = - RdDUtility._evaluatePerte(encaissement.vie, over20);
|
||||
encaissement.endurance = - RdDUtility._evaluatePerte(encaissement.endurance, over20);
|
||||
encaissement.loc = rollData.dmg.loc;
|
||||
encaissement.locName = rollData.dmg.loc.label ?? "Corps";
|
||||
encaissement.armure = armure;
|
||||
encaissement.total = jetTotal;
|
||||
encaissement.vie = RdDUtility._evaluatePerte(encaissement.vie, over20);
|
||||
encaissement.endurance = RdDUtility._evaluatePerte(encaissement.endurance, over20);
|
||||
encaissement.penetration = rollData.arme?.data.penetration ?? 0;
|
||||
|
||||
return encaissement;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
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 +2294,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 +2329,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 +2455,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',
|
||||
|
@ -3,21 +3,20 @@
|
||||
* Class providing helper methods to get the list of users, and
|
||||
*/
|
||||
export class ChatUtility {
|
||||
/* -------------------------------------------- */
|
||||
static removeMyChatMessageContaining(part) {
|
||||
const toDelete = game.messages.filter(it => it.user._id == game.user._id)
|
||||
.filter(it => it.data.content.includes(part));
|
||||
toDelete.forEach(it => it.delete());
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static chatWithRollMode(chatOptions, name) {
|
||||
let rollMode = game.settings.get("core", "rollMode");
|
||||
ChatUtility.createChatMessage(chatOptions, rollMode, name);
|
||||
static createChatWithRollMode(name, chatOptions) {
|
||||
ChatUtility.createChatMessage(name, game.settings.get("core", "rollMode"), chatOptions);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static createChatMessage(chatOptions, rollMode, name) {
|
||||
static createChatMessage(name, rollMode, chatOptions) {
|
||||
switch (rollMode) {
|
||||
case "blindroll": // GM only
|
||||
if (!game.user.isGM) {
|
||||
|
@ -136,7 +136,6 @@ export class RdDCombat {
|
||||
}
|
||||
const defenderTokenId = event.currentTarget.attributes['data-defenderTokenId'].value;
|
||||
|
||||
let defenderRoll = this._getDefense(attackerRoll.passeArme);
|
||||
const armeParadeId = event.currentTarget.attributes['data-armeid']?.value;
|
||||
|
||||
switch (button) {
|
||||
@ -150,13 +149,13 @@ export class RdDCombat {
|
||||
() => this.attaqueChanceuse(attackerRoll),
|
||||
() => this._onEchecTotal(attackerRoll));
|
||||
case '#appel-chance-defense': return this.defender.rollAppelChance(
|
||||
() => this.defenseChanceuse(attackerRoll, defenderRoll),
|
||||
() => this.defenseChanceuse(attackerRoll),
|
||||
() => this.afficherOptionsDefense(attackerRoll, { defenseChance: true }));
|
||||
case '#appel-destinee-attaque': return this.attacker.appelDestinee(
|
||||
() => this.attaqueSignificative(attackerRoll),
|
||||
() => { });
|
||||
case '#appel-destinee-defense': return this.defender.appelDestinee(
|
||||
() => this.defenseDestinee(defenderRoll),
|
||||
() => this.defenseDestinee(attackerRoll),
|
||||
() => { });
|
||||
}
|
||||
}
|
||||
@ -194,7 +193,7 @@ export class RdDCombat {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
defenseChanceuse(attackerRoll, defenderRoll) {
|
||||
defenseChanceuse(attackerRoll) {
|
||||
ui.notifications.info("La défense est rejouée grâce à la chance")
|
||||
attackerRoll.essais.defenseChance = true;
|
||||
attackerRoll.essais.defense = false;
|
||||
@ -203,7 +202,9 @@ export class RdDCombat {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
defenseDestinee(defenderRoll) {
|
||||
defenseDestinee(attackerRoll) {
|
||||
let defenderRoll = this._getDefense(attackerRoll.passeArme);
|
||||
if (defenderRoll) {
|
||||
ui.notifications.info('Défense significative grâce à la destinée')
|
||||
RdDResolutionTable.forceSignificative(defenderRoll.rolled);
|
||||
this.removeChatMessageActionsPasseArme(defenderRoll.passeArme);
|
||||
@ -214,6 +215,10 @@ export class RdDCombat {
|
||||
this._onEsquiveNormale(defenderRoll);
|
||||
}
|
||||
}
|
||||
else {
|
||||
ui.notifications.warn("Appel à la destinée impossible, la passe d'armes est déjà terminée!")
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
afficherOptionsDefense(attackerRoll, essais) {
|
||||
@ -417,9 +422,9 @@ export class RdDCombat {
|
||||
const arme = rollData.arme;
|
||||
const avecArme = arme?.data.categorie_parade != 'sans-armes';
|
||||
const action = (rollData.attackerRoll ? (arme ? "la parade" : "l'esquive") : "l'attaque");
|
||||
ChatUtility.chatWithRollMode({
|
||||
ChatUtility.createChatWithRollMode(this.defender.name, {
|
||||
content: `<strong>Echec total à ${action}!</strong> ` + await RdDRollTables.getMaladresse({ arme: avecArme })
|
||||
}, this.defender.name)
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -489,45 +494,45 @@ 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({
|
||||
ChatUtility.createChatWithRollMode(this.defender.name, {
|
||||
content: `(à gérer) L'attaquant doit jouer résistance et peut être désarmé (p132)`
|
||||
}, this.defender.name)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
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);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -579,10 +584,9 @@ export class RdDCombat {
|
||||
/* -------------------------------------------- */
|
||||
_onEsquiveParticuliere(rollData) {
|
||||
console.log("RdDCombat._onEsquiveParticuliere >>>", rollData);
|
||||
let chatOptions = {
|
||||
ChatUtility.createChatWithRollMode(this.defender.name, {
|
||||
content: "<strong>Vous pouvez esquiver une deuxième esquive!</strong>"
|
||||
}
|
||||
ChatUtility.chatWithRollMode(chatOptions, this.defender.name)
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -651,11 +655,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;
|
||||
@ -663,13 +667,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';
|
||||
}
|
||||
@ -696,7 +700,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);
|
||||
}
|
||||
@ -746,7 +756,6 @@ export class RdDCombat {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async displayActorCombatStatus(actor) {
|
||||
let rollMode = game.settings.get("core", "rollMode");
|
||||
let rollData = {
|
||||
alias: actor.name,
|
||||
etatGeneral: actor.getEtatGeneral(),
|
||||
@ -762,8 +771,9 @@ export class RdDCombat {
|
||||
} else if (actor.countBlessuresByName("graves") > 0) {
|
||||
rollData.isGrave = true;
|
||||
}
|
||||
let content = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-turn-summary.html`, rollData);
|
||||
ChatUtility.createChatMessage({ content: content }, rollMode, actor.name);
|
||||
ChatUtility.createChatWithRollMode(actor.name, {
|
||||
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-turn-summary.html`, rollData)
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -192,15 +192,14 @@ export class RdDCommands {
|
||||
};
|
||||
await RdDResolutionTable.rollData(rollData);
|
||||
msg.content = await RdDResolutionTable.buildRollDataHtml(rollData);
|
||||
ChatUtility.chatWithRollMode(msg, game.user.name);
|
||||
ChatUtility.createChatWithRollMode(game.user.name, msg);
|
||||
}
|
||||
|
||||
async rollDeDraconique(msg) {
|
||||
let rollMode = game.settings.get("core", "rollMode");
|
||||
let ddr = new DeDraconique().evaluate();
|
||||
await RdDDice.show(ddr, rollMode);
|
||||
msg.content = `Lancer d'un Dé draconique: ${ddr.total}`;
|
||||
ChatUtility.createChatMessage(msg, rollMode, game.user.name);
|
||||
ChatUtility.createChatWithRollMode(game.user.name, msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -91,9 +91,9 @@ export class RdDResolutionTable {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async displayRollData(rollData, actor = undefined, template = 'chat-resultat-general.html') {
|
||||
ChatUtility.chatWithRollMode(
|
||||
{ content: await RdDResolutionTable.buildRollDataHtml(rollData, actor, template) },
|
||||
actor?.userName ?? game.user.name)
|
||||
ChatUtility.createChatWithRollMode(actor?.userName ?? game.user.name, {
|
||||
content: await RdDResolutionTable.buildRollDataHtml(rollData, actor, template)
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -98,25 +98,25 @@ const nomEthylisme = ["Emeché", "Gris", "Pinté", "Pas frais", "Ivre", "Bu", "C
|
||||
/* -------------------------------------------- */
|
||||
const definitionsEncaissement = {
|
||||
"mortel": [
|
||||
{ minimum: undefined, maximum: 0, endurance: "0", vie: "0", legeres: 0, graves: 0, critiques: 0 },
|
||||
{ minimum: 1, maximum: 10, endurance: "1d4", vie: "0", legeres: 0, graves: 0, critiques: 0 },
|
||||
{ minimum: 11, maximum: 15, endurance: "1d6", vie: "0", legeres: 1, graves: 0, critiques: 0 },
|
||||
{ minimum: 16, maximum: 19, endurance: "2d6", vie: "2", legeres: 0, graves: 1, critiques: 0 },
|
||||
{ minimum: 20, maximum: undefined, endurance: "100", vie: "4 + @over20", legeres: 0, graves: 0, critiques: 1 },
|
||||
{ minimum: undefined, maximum: 0, endurance: "0", vie: "0", eraflures: 0, legeres: 0, graves: 0, critiques: 0 },
|
||||
{ minimum: 1, maximum: 10, endurance: "1d4", vie: "0", eraflures: 1, legeres: 0, graves: 0, critiques: 0 },
|
||||
{ minimum: 11, maximum: 15, endurance: "1d6", vie: "0", eraflures: 0, legeres: 1, graves: 0, critiques: 0 },
|
||||
{ minimum: 16, maximum: 19, endurance: "2d6", vie: "2", eraflures: 0, legeres: 0, graves: 1, critiques: 0 },
|
||||
{ minimum: 20, maximum: undefined, endurance: "100", vie: "4 + @over20", eraflures: 0, legeres: 0, graves: 0, critiques: 1 },
|
||||
],
|
||||
"non-mortel": [
|
||||
{ minimum: undefined, maximum: 0, endurance: "0", vie: "0", legeres: 0, graves: 0, critiques: 0 },
|
||||
{ minimum: 1, maximum: 10, endurance: "1d4", vie: "0", legeres: 0, graves: 0, critiques: 0 },
|
||||
{ minimum: 11, maximum: 15, endurance: "1d6", vie: "0", legeres: 0, graves: 0, critiques: 0 },
|
||||
{ minimum: 16, maximum: 19, endurance: "2d6", vie: "0", legeres: 1, graves: 0, critiques: 0 },
|
||||
{ minimum: 20, maximum: undefined, endurance: "100", vie: "1", legeres: 1, graves: 0, critiques: 0 },
|
||||
{ minimum: undefined, maximum: 0, endurance: "0", vie: "0", eraflures: 0, legeres: 0, graves: 0, critiques: 0 },
|
||||
{ minimum: 1, maximum: 10, endurance: "1d4", vie: "0", eraflures: 1, legeres: 0, graves: 0, critiques: 0 },
|
||||
{ minimum: 11, maximum: 15, endurance: "1d6", vie: "0", eraflures: 1, legeres: 0, graves: 0, critiques: 0 },
|
||||
{ minimum: 16, maximum: 19, endurance: "2d6", vie: "0", eraflures: 0, legeres: 1, graves: 0, critiques: 0 },
|
||||
{ minimum: 20, maximum: undefined, endurance: "100", vie: "0", eraflures: 0, legeres: 1, graves: 0, critiques: 0 },
|
||||
],
|
||||
"cauchemar": [
|
||||
{ minimum: undefined, maximum: 0, endurance: "0", vie: "0", legeres: 0, graves: 0, critiques: 0 },
|
||||
{ minimum: 1, maximum: 10, endurance: "1d4", vie: "0", legeres: 0, graves: 0, critiques: 0 },
|
||||
{ minimum: 11, maximum: 15, endurance: "1d6", vie: "0", legeres: 0, graves: 0, critiques: 0 },
|
||||
{ minimum: 16, maximum: 19, endurance: "2d6", vie: "0", legeres: 0, graves: 0, critiques: 0 },
|
||||
{ minimum: 20, maximum: undefined, endurance: "3d6 + @over20", vie: "0", legeres: 0, graves: 0, critiques: 0 },
|
||||
{ minimum: undefined, maximum: 0, endurance: "0", vie: "0", eraflures: 0, legeres: 0, graves: 0, critiques: 0 },
|
||||
{ minimum: 1, maximum: 10, endurance: "1d4", vie: "0", eraflures: 1, legeres: 0, graves: 0, critiques: 0 },
|
||||
{ minimum: 11, maximum: 15, endurance: "1d6", vie: "0", eraflures: 1, legeres: 0, graves: 0, critiques: 0 },
|
||||
{ minimum: 16, maximum: 19, endurance: "2d6", vie: "0", eraflures: 1, legeres: 0, graves: 0, critiques: 0 },
|
||||
{ minimum: 20, maximum: undefined, endurance: "3d6 + @over20", vie: "0", eraflures: 1, legeres: 0, graves: 0, critiques: 0 },
|
||||
]
|
||||
};
|
||||
|
||||
@ -193,6 +193,7 @@ export class RdDUtility {
|
||||
'systems/foundryvtt-reve-de-dragon/templates/chat-demande-attaque-etotal.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-appelchance.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-attaque.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-encaissement.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-parade.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-esquive.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-competence.html',
|
||||
@ -551,10 +552,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;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -2,7 +2,7 @@
|
||||
{{#if (eq surprise 'totale')}}
|
||||
<span><strong>{{defender.name}}</strong> est totalement surpris</span>
|
||||
{{else if essais.defense}}
|
||||
<span><strong>{{defender.name}}</strong> doit</span>
|
||||
<span><strong>{{defender.name}}</strong> doit :</span>
|
||||
{{else}}
|
||||
<span><strong>{{defender.name}}</strong> doit se défendre
|
||||
{{#if (eq surprise 'demi')}} avec une significative {{/if}} :
|
||||
@ -12,7 +12,6 @@
|
||||
<br>
|
||||
{{#unless (eq surprise 'totale')}}
|
||||
{{#if essais.defense}}
|
||||
<br>
|
||||
{{#unless essais.defenseChance}}
|
||||
{{#if (eq defender.data.type 'personnage')}}
|
||||
<a class='chat-card-button' id='appel-chance-defense' data-attackerId='{{attackerId}}'
|
||||
@ -20,7 +19,6 @@
|
||||
</a>
|
||||
<br>
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
{{#if (eq defender.data.type 'personnage')}}
|
||||
{{#if (gt defender.data.data.compteurs.destinee.value 0)}}
|
||||
<a class='chat-card-button' id='appel-destinee-defense' data-attackerId='{{attackerId}}'
|
||||
@ -29,6 +27,7 @@
|
||||
<br>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
{{else}}
|
||||
{{#each armes as |arme key|}}
|
||||
<a class='chat-card-button' id='parer-button' data-attackerId='{{../attackerId}}' data-defenderTokenId='{{../defenderTokenId}}' data-armeid='{{arme._id }}'>
|
||||
|
42
templates/chat-resultat-encaissement.html
Normal file
42
templates/chat-resultat-encaissement.html
Normal file
@ -0,0 +1,42 @@
|
||||
{{#if isGM}}
|
||||
<span>
|
||||
{{#if (gt endurance 0)}}
|
||||
De plus, {{alias}} a perdu {{endurance}} points d'endurance
|
||||
{{#if (ne vie 0)}}et <span class="rdd-roll-echec">{{vie}} points de vie</span>{{/if}}
|
||||
{{/if}}
|
||||
</span>
|
||||
{{else}}
|
||||
<h4>{{alias}} encaisse à
|
||||
<span>
|
||||
{{numberFormat dmg.total decimals=0 sign=true}}
|
||||
{{#if (eq dmg.mortalite 'non-mortel')~}}(coups non mortels)
|
||||
{{~else if (eq dmg.mortalite 'cauchemar')}}(entité de cauchemar)
|
||||
{{~/if}}
|
||||
</span>
|
||||
</h4>
|
||||
<div>
|
||||
Je d'encaissement de {{roll.total}}
|
||||
{{#unless (eq armure 0)}}, l'armure a protègé de {{armure}} {{#unless (eq penetration 0)}}(pénétration de {{penetration}})
|
||||
{{/unless}}
|
||||
{{/unless}}, total: <span class="rdd-roll-echec">{{total}}</span>
|
||||
<br>
|
||||
{{alias}} subit
|
||||
{{#if (gt eraflures 0)}}une contusion
|
||||
{{else if (gt legeres 0)}}une blessure légère
|
||||
{{else if (gt graves 0)}}une blessure grave
|
||||
{{else if (gt critique 0)}}une blessure critique
|
||||
{{else}}Rien du tout
|
||||
{{/if}}
|
||||
|
||||
({{dmg.loc.label}})
|
||||
{{#if (gt endurance 0)}}
|
||||
{{#if hasPlayerOwner}}, a perdu {{endurance}} points d'endurance
|
||||
{{#if (ne vie 0)}}, <span class="rdd-roll-echec">{{vie}} points de vie</span>{{/if}}
|
||||
{{/if}}
|
||||
{{#if (gt endurance 1)}}
|
||||
et {{#if sonne}}est <strong>sonné</strong><img class="chat-icon" src="icons/svg/stoned.svg" alt="charge" height="16" width="16" /> jusqu'à la fin du prochain round{{else}}n'est pas sonné{{/if}}
|
||||
({{jetEndurance}} / {{resteEndurance}})!
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/if}}
|
Loading…
Reference in New Issue
Block a user