encaissement non mortel

This commit is contained in:
Vincent Vandemeulebrouck 2020-11-11 04:21:25 +01:00
parent 397f140cb3
commit c040197d97
3 changed files with 105 additions and 105 deletions

View File

@ -815,51 +815,32 @@ export class RdDActor extends Actor {
}
/* -------------------------------------------- */
encaisserDommages( attackerRoll )
{
//let attackerRoll = rollData.attackerRoll;
let degatsReel = attackerRoll.degats - this.computeArmure(attackerRoll.loc, attackerRoll.domArmePlusDom);
console.log("RollData from attacker!", attackerRoll, degatsReel);
encaisserDommages( attackerRoll ) {
console.log("encaisserDommages", attackerRoll )
const armure = this.computeArmure( attackerRoll.loc, attackerRoll.domArmePlusDom);
let degatsReel = attackerRoll.degats - armure;
let result = RdDUtility.computeBlessuresSante(degatsReel);
let result = RdDUtility.computeBlessuresSante(degatsReel, attackerRoll.mortalite);
this.santeIncDec("vie", result.vie);
this.santeIncDec("endurance", result.endurance);
result.locName = attackerRoll.loc.label;
result.locName = attackerRoll.loc.label; // Add the localisation namme
this.manageBlessures(result); // Will upate the result table
ChatMessage.create( {title: "Blessures !", content: this.data.name + " a encaissé : " +
const blessureLegere = (result.legeres > 0 ? "une blessure légère" : "");
const blessureGrave = (result.graves > 0 ? "une blessure grave" : "");
const blessureCritique = (result.critiques > 0 ? "une blessure critique" : "");
ChatMessage.create({
title: "Blessures !", content: this.data.name + " a encaissé : " +
"<br>Encaissement final : " + degatsReel +
"<br>" + result.legeres + " légères, " + result.graves + " graves et " +
result.critiques + " critique." +
"<br>Et perdu : " +
"<br>" + result.endurance + " Endurance et " + result.vie + " Points de Vie" } );
"<br>" + blessureLegere + blessureGrave + blessureCritique +
"<br>Et a perdu : " +
"<br>" + result.endurance + " Endurance et " + result.vie + " Points de Vie"
});
this.computeEtatGeneral();
this.sheet.render(true);
}
/* -------------------------------------------- */
encaisserDommagesHorsCombat( degats )
{
let degatsReel = degats - this.computeArmure("Corps", 0);
console.log("Enciasser dommages", degatsReel, this.computeArmure("Corps", 0), degats);
let result = RdDUtility.computeBlessuresSante(degatsReel);
this.santeIncDec("vie", result.vie);
this.santeIncDec("endurance", result.endurance);
result.locName = "Corps"; // Add the localisation namme
this.manageBlessures( result ); // Will upate the result table
ChatMessage.create( {title: "Blessures !", content: this.data.name + " a encaissé : " +
"<br>Encaissement final : " + degatsReel +
"<br>" + result.legeres + " légères, " + result.graves + " graves et " +
result.critiques + " critique." +
"<br>Et perdu : " +
"<br>" + result.endurance + " Endurance et " + result.vie + " Points de Vie" } );
this.computeEtatGeneral();
this.sheet.render(true);
}
/* -------------------------------------------- */
parerAttaque( attackerRoll, armeId )

View File

@ -2,27 +2,29 @@
* Extend the base Dialog entity by defining a custom window to perform roll.
* @extends {Dialog}
*/
export class RdDEncaisser extends Dialog {
/* -------------------------------------------- */
constructor(html, actor) {
let myButtons = { rollButton: {
label: "Lancer",
callback: html => this.performEncaisser(html, false)
} };
// Common conf
let dialogConf = {
title: "Jet d'Encaissement",
content: html,
buttons: myButtons,
default: "rollButton"
buttons: {
"mortel": { label: "mortel", callback: html => this.performEncaisser(html, "mortel") },
"non-mortel": { label: "non-mortel", callback: html => this.performEncaisser(html, "non-mortel") },
"cauchemar": { label: "cauchemar", callback: html => this.performEncaisser(html, "cauchemar") }
},
default: "coupMortel"
}
let dialogOptions = {
classes: ["rdddialog"],
width: 320,
height: 240
}
let dialogOptions = { classes: [ "rdddialog"] }
// Select proper roll dialog template and stuff
dialogConf.title = "Jet d'Encaissement",
dialogOptions.width = 320;
dialogOptions.height = 160;
super(dialogConf, dialogOptions);
this.actor = actor;
@ -30,12 +32,13 @@ export class RdDEncaisser extends Dialog {
}
/* -------------------------------------------- */
performEncaisser (html, isReserve=false) {
//console.log("On va encaisser !!", this.modifier);
let result = Number(new Roll("2d10").roll().result);
result += Number(this.modifier);
this.actor.encaisserDommagesHorsCombat(result);
//console.log("ENCAISSER:", result);
performEncaisser(html, mortalite = "mortel") {
this.actor.encaisserDommages({
degats: new Roll("2d10").roll().total,
domArmePlusDom: Number(this.modifier),
loc: { result: 0, label: "Corps" },
mortalite: mortalite
});
}
/* -------------------------------------------- */

View File

@ -84,6 +84,30 @@ const table2func = { "queues": {descr: "queues : Tire une queue de Dragon", fun
"tete" : { descr: "tete: Tire une Tête de Dragon", func: TMRUtility.getTete},
"souffle": { descr: "souffle: Tire un Souffle de Dragon", func: TMRUtility.getSouffle} };
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 },
],
"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 },
],
"cauchemar": [
{ minimum: undefined, maximum: 0, gravite: "frayeur", 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 },
]
};
/* -------------------------------------------- */
export class RdDUtility {
@ -402,39 +426,31 @@ export class RdDUtility {
return { result: result, label: txt };
}
/* -------------------------------------------- */
static computeBlessuresSante( degats )
{
console.log("Degats !!", degats);
let result = { vie: 0,
endurance: 0,
legeres: 0,
graves: 0,
critiques: 0
};
if ( degats < 11 ) {
result.type = "contusion";
let myroll = new Roll("1d4").roll();
result.endurance = -myroll.result;
} else if ( degats < 16 ) {
result.type = "blessure légère";
let myroll = new Roll("1d6").roll();
result.endurance = -myroll.result;
result.legeres = 1;
} else if (degats < 20 ) {
result.type = "blessure grave";
let myroll = new Roll("2d6").roll();
result.endurance = -myroll.result;
result.vie = -2;
result.graves = 1;
} else {
result.type = "critique";
result.endurance = -100; // Force endurance to 0
result.vie = -4 - (degats - 20);
result.critiques = 1;
static computeBlessuresSante( degats, mortalite="mortel" ) {
let encaissement = RdDUtility.selectEncaissement(degats, mortalite)
let over20 = degats > 20 ? degats - 20 : 0
encaissement.endurance = - RdDUtility._evaluatePerte(encaissement.endurance, over20)
encaissement.vie = - RdDUtility._evaluatePerte(encaissement.vie, degats, over20)
return encaissement;
}
return result;
static selectEncaissement( degats, mortalite ) {
const table = definitionsEncaissement[mortalite] === undefined ? definitionsEncaissement["mortel"] : definitionsEncaissement[mortalite];
for (let encaissement of table) {
if ((encaissement.minimum === undefined || encaissement.minimum <= degats)
&& (encaissement.maximum === undefined || degats <= encaissement.maximum)) {
return duplicate(encaissement);
}
}
return duplicate(table[0]);
}
static _evaluatePerte(formula, over20) {
console.log("_evaluatePerte", formula, over20 )
let perte = new Roll(formula, { over20:over20})
perte.evaluate()
return perte.total
}
/* -------------------------------------------- */