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 ) encaisserDommages( attackerRoll ) {
{ console.log("encaisserDommages", attackerRoll )
//let attackerRoll = rollData.attackerRoll; const armure = this.computeArmure( attackerRoll.loc, attackerRoll.domArmePlusDom);
let degatsReel = attackerRoll.degats - this.computeArmure(attackerRoll.loc, attackerRoll.domArmePlusDom); let degatsReel = attackerRoll.degats - armure;
console.log("RollData from attacker!", attackerRoll, degatsReel);
let result = RdDUtility.computeBlessuresSante(degatsReel); let result = RdDUtility.computeBlessuresSante(degatsReel, attackerRoll.mortalite);
this.santeIncDec("vie", result.vie); this.santeIncDec("vie", result.vie);
this.santeIncDec("endurance", result.endurance); 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
this.manageBlessures( result ); // Will upate the result table const blessureLegere = (result.legeres > 0 ? "une blessure légère" : "");
ChatMessage.create( {title: "Blessures !", content: this.data.name + " a encaissé : " + 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>Encaissement final : " + degatsReel +
"<br>" + result.legeres + " légères, " + result.graves + " graves et " + "<br>" + blessureLegere + blessureGrave + blessureCritique +
result.critiques + " critique." + "<br>Et a perdu : " +
"<br>Et perdu : " + "<br>" + result.endurance + " Endurance et " + result.vie + " Points de Vie"
"<br>" + result.endurance + " Endurance et " + result.vie + " Points de Vie" } ); });
this.computeEtatGeneral(); this.computeEtatGeneral();
this.sheet.render(true); 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 ) parerAttaque( attackerRoll, armeId )

View File

@ -2,27 +2,29 @@
* Extend the base Dialog entity by defining a custom window to perform roll. * Extend the base Dialog entity by defining a custom window to perform roll.
* @extends {Dialog} * @extends {Dialog}
*/ */
export class RdDEncaisser extends Dialog { export class RdDEncaisser extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
constructor(html, actor) { constructor(html, actor) {
let myButtons = { rollButton: {
label: "Lancer",
callback: html => this.performEncaisser(html, false)
} };
// Common conf // Common conf
let dialogConf = { let dialogConf = {
title: "Jet d'Encaissement",
content: html, content: html,
buttons: myButtons, buttons: {
default: "rollButton" "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 // Select proper roll dialog template and stuff
dialogConf.title = "Jet d'Encaissement",
dialogOptions.width = 320;
dialogOptions.height = 160;
super(dialogConf, dialogOptions); super(dialogConf, dialogOptions);
this.actor = actor; this.actor = actor;
@ -30,12 +32,13 @@ export class RdDEncaisser extends Dialog {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
performEncaisser (html, isReserve=false) { performEncaisser(html, mortalite = "mortel") {
//console.log("On va encaisser !!", this.modifier); this.actor.encaisserDommages({
let result = Number(new Roll("2d10").roll().result); degats: new Roll("2d10").roll().total,
result += Number(this.modifier); domArmePlusDom: Number(this.modifier),
this.actor.encaisserDommagesHorsCombat(result); loc: { result: 0, label: "Corps" },
//console.log("ENCAISSER:", result); mortalite: mortalite
});
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -43,8 +46,8 @@ export class RdDEncaisser extends Dialog {
super.activateListeners(html); super.activateListeners(html);
// Setup everything onload // Setup everything onload
$(function() { $(function () {
$("#modificateurDegats").val( "0" ); $("#modificateurDegats").val("0");
}); });
html.find('#modificateurDegats').click((event) => { html.find('#modificateurDegats').click((event) => {

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}, "tete" : { descr: "tete: Tire une Tête de Dragon", func: TMRUtility.getTete},
"souffle": { descr: "souffle: Tire un Souffle de Dragon", func: TMRUtility.getSouffle} }; "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 { export class RdDUtility {
@ -402,39 +426,31 @@ export class RdDUtility {
return { result: result, label: txt }; return { result: result, label: txt };
} }
/* -------------------------------------------- */ static computeBlessuresSante( degats, mortalite="mortel" ) {
static computeBlessuresSante( degats ) let encaissement = RdDUtility.selectEncaissement(degats, mortalite)
{ let over20 = degats > 20 ? degats - 20 : 0
console.log("Degats !!", degats); encaissement.endurance = - RdDUtility._evaluatePerte(encaissement.endurance, over20)
let result = { vie: 0, encaissement.vie = - RdDUtility._evaluatePerte(encaissement.vie, degats, over20)
endurance: 0, return encaissement;
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;
} }
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
} }
/* -------------------------------------------- */ /* -------------------------------------------- */