Merge branch 'working' into 'master'
Encaissement non mortel et petits fixes See merge request LeRatierBretonnien/foundryvtt-reve-de-dragon!7
This commit is contained in:
commit
c7dc3b95eb
@ -204,8 +204,8 @@ export class RdDActor extends Actor {
|
||||
rollData.domArmePlusDom += parseInt(this.data.data.attributs.plusdom.value);
|
||||
if ( rollData.selectedCarac.label == "Lancer" ) { // +dom only for Melee/Lancer
|
||||
let bdom = parseInt(this.data.data.attributs.plusdom.value);
|
||||
if ( bdom > parseInt(rollData.arme.data.dommages)*2 )
|
||||
bdom = parseInt(rollData.arme.data.dommages)*2;
|
||||
if ( bdom > parseInt(rollData.arme.data.dommages))
|
||||
bdom = parseInt(rollData.arme.data.dommages);
|
||||
rollData.domArmePlusDom += bdom
|
||||
}
|
||||
rollData.degats = parseInt(myroll.result) + rollData.domArmePlusDom;
|
||||
@ -717,7 +717,7 @@ export class RdDActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
rollArme( armeName )
|
||||
{
|
||||
let armeItem = RdDUtility.findCompetence( this.data.items, armeName );
|
||||
let armeItem = this.data.items.find(item=>item.type==="arme" && (item.name === armeName));
|
||||
if ( armeItem && armeItem.data.competence )
|
||||
this.rollCompetence( armeItem.data.competence, armeItem );
|
||||
else
|
||||
@ -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é : " +
|
||||
"<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.manageBlessures(result); // Will upate the result table
|
||||
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>" + 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 )
|
||||
|
@ -2,49 +2,52 @@
|
||||
* 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;
|
||||
this.actor = actor;
|
||||
this.modifier = 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
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
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
activateListeners(html) {
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
// Setup everything onload
|
||||
$(function() {
|
||||
$("#modificateurDegats").val( "0" );
|
||||
$(function () {
|
||||
$("#modificateurDegats").val("0");
|
||||
});
|
||||
|
||||
html.find('#modificateurDegats').click((event) => {
|
||||
|
45
module/rdd-rolltables.js
Normal file
45
module/rdd-rolltables.js
Normal file
@ -0,0 +1,45 @@
|
||||
export class RdDRollTables {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async genericGetTableResult( tableName, toChat)
|
||||
{
|
||||
let pack = game.packs.get("foundryvtt-reve-de-dragon.tables-diverses");
|
||||
await pack.getIndex();
|
||||
let entry = pack.index.find(e => e.name === tableName);
|
||||
let rollQueues = await pack.getEntity(entry._id);
|
||||
let result = await rollQueues.draw( { displayChat: toChat } );
|
||||
console.log("CAT", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async getSouffle( toChat ) {
|
||||
return genericGetTableResult( "Souffles de Dragon", toChat);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async getQueue( toChat = true) {
|
||||
return genericGetTableResult( "Queues de dragon", toChat);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async getTete( toChat = true ) {
|
||||
return genericGetTableResult( "Têtes de Dragon pour haut-rêvants", toChat);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async getTeteHR( toChat = true ) {
|
||||
return genericGetTableResult( "Têtes de Dragon pour tous personnages", toChat);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async getOmbre( toChat = true ) {
|
||||
return genericGetTableResult( "Ombre de Thanatos", toChat);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async getTarot( toChat = true ) {
|
||||
return genericGetTableResult( "Tarot Draconique", toChat);
|
||||
}
|
||||
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
*/
|
||||
import { RdDUtility } from "./rdd-utility.js";
|
||||
import { TMRUtility } from "./tmr-utility.js";
|
||||
import { RdDRollTables } from "./rdd-rolltables.js";
|
||||
|
||||
/** Helper functions */
|
||||
export class RdDTMRDialog extends Dialog {
|
||||
@ -119,7 +120,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
let result = await this.actor.ajouterRefoulement(1);
|
||||
this.updatePreviousRencontres();
|
||||
if (result == "souffle") {
|
||||
let souffle = TMRUtility.getSouffle();
|
||||
let souffle = RdDRollTables.getSouffle();
|
||||
}
|
||||
console.log("-> refouler", this.currentRencontre)
|
||||
this.updateValuesDisplay();
|
||||
@ -245,7 +246,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
if ( result > scoreDef.score ) {
|
||||
content = "Vous êtes entré sur une case humide, et vous avez <strong>raté</strong> votre maîtrise ! Vous <strong>quittez les Terres Médianes</strong> ! ("+ draconic.name +") :" + carac + " / " + level + " -> " + result + " / " + scoreDef.score;
|
||||
if ( result >= scoreDef.etotal ) {
|
||||
let souffle = TMRUtility.getSouffle(true);
|
||||
let souffle = RdDRollTables.getSouffle(true);
|
||||
content += "<br>Vous avez fait un Echec Total. Vous subissez un Souffle de Dragon : " + souffle.name ;
|
||||
this.actor.createOwnedItem( souffle );
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
import { RdDActor } from "./actor.js";
|
||||
import { TMRUtility } from "./tmr-utility.js";
|
||||
import { RdDRollTables } from "./rdd-rolltables.js";
|
||||
|
||||
const level_category = {
|
||||
"generale": "-4",
|
||||
@ -78,11 +79,36 @@ const fatigueMarche = { "aise": { "4":1, "6":2, "8":3, "10":4, "12":6 },
|
||||
"difficile": { "4":3, "6":4, "8":6 },
|
||||
"tresdifficile": { "4":4, "6":6 } }
|
||||
/* Static tables for commands /table */
|
||||
const table2func = { "queues": {descr: "queues : Tire une queue de Dragon", func: TMRUtility.getQueue},
|
||||
"ombre": { descr: "ombre: Tire une Ombre de Dragon", func: TMRUtility.getOmbre },
|
||||
"tetehr": {descr: "tetehr: Tire une Tête de Dragon pour Hauts Revants", fund: TMRUtility.getTeteHR},
|
||||
"tete" : { descr: "tete: Tire une Tête de Dragon", func: TMRUtility.getTete},
|
||||
"souffle": { descr: "souffle: Tire un Souffle de Dragon", func: TMRUtility.getSouffle} };
|
||||
const table2func = { "queues": {descr: "queues : Tire une queue de Dragon", func: RdDRollTables.getQueue},
|
||||
"ombre": { descr: "ombre: Tire une Ombre de Dragon", func: RdDRollTables.getOmbre },
|
||||
"tetehr": {descr: "tetehr: Tire une Tête de Dragon pour Hauts Revants", fund: RdDRollTables.getTeteHR},
|
||||
"tete" : { descr: "tete: Tire une Tête de Dragon", func: RdDRollTables.getTete},
|
||||
"souffle": { descr: "souffle: Tire un Souffle de Dragon", func: RdDRollTables.getSouffle},
|
||||
"tarot" : { descr: "tarot: Tire une carte de Tarot Dracnique", func: RdDRollTables.getTarot} };
|
||||
|
||||
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 +428,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
|
||||
};
|
||||
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;
|
||||
}
|
||||
|
||||
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 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 result;
|
||||
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
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -375,31 +375,6 @@ export class TMRUtility {
|
||||
return result;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async getSouffle( toChat ) {
|
||||
return TMRUtility.genericGetTableResult( "Souffles de Dragon", toChat);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async getQueue( toChat = true) {
|
||||
return TMRUtility.genericGetTableResult( "Queues de dragon", toChat);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async getTete( toChat = true ) {
|
||||
return TMRUtility.genericGetTableResult( "Têtes de Dragon pour haut-rêvants", toChat);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async getTeteHR( toChat = true ) {
|
||||
return TMRUtility.genericGetTableResult( "Têtes de Dragon pour tous personnages", toChat);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async getOmbre( toChat = true ) {
|
||||
return TMRUtility.genericGetTableResult( "Ombre de Thanatos", toChat);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/**
|
||||
* Retourne une recontre en fonction de la case ou du tirage
|
||||
|
Loading…
Reference in New Issue
Block a user