Merge branch 'working' into 'master'

Récupération de fatigue

See merge request LeRatierBretonnien/foundryvtt-reve-de-dragon!19
This commit is contained in:
Leratier Bretonnien 2020-11-17 13:21:01 +00:00
commit 3d34921072
8 changed files with 263 additions and 181 deletions

View File

@ -122,7 +122,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async performRoll(rollData) { async performRoll(rollData) {
let rolled = await RdDResolutionTable.roll(rollData.carac, rollData.finalLevel, true); let rolled = RdDResolutionTable.roll(rollData.carac, rollData.finalLevel);
//rolled.isPart = true; // Pour tester le particulières //rolled.isPart = true; // Pour tester le particulières
rollData.rolled = rolled; // garder le résultat rollData.rolled = rolled; // garder le résultat
console.log("performRoll", rollData, rolled) console.log("performRoll", rollData, rolled)
@ -329,58 +329,96 @@ export class RdDActor extends Actor {
} }
async dormir(heures=1) { async dormir(heures=1) {
let message = { title : "Récupération", content :"Vous dormez " + heures + " heure" + (heures > 1 ? "s": "") };
this.recupereEndurance(message);
for (let i=0; i<heures; i++) { for (let i=0; i<heures; i++) {
console.log("recuperationReve", this.data.data); await this.recupererFatigueUneHeure(message);
/** this.recuperationReve(message);
* TODO: récupérer les segment de fatigue }
*/ ChatMessage.create( message );
this.recuperationReve(); }
recupereEndurance(message) {
const avant = this.data.data.sante.endurance.value;
this.santeIncDec("endurance", this.data.data.sante.endurance.max - avant);
const recupere = this.data.data.sante.endurance.value - avant;
if (recupere>0) {
message.content += "<br>Vous récuperez " + recupere + " points d'endurance";
} }
} }
async recuperationReve() { async recupererFatigueUneHeure(message) {
const seuil = this.data.data.reve.seuil.value; let fatigue = duplicate(this.data.data.sante.fatigue)
const reve = this.getReveActuel(); if (fatigue.value == 0) {
console.log("recuperationReve", this.data.data); message.content += "<br>Vous êtes déjà reposé";
let message = { title : "Récupération" } return;
if (reve > seuil) { }
message.content = "Vous avez déjà récupéré suffisament (seuil " + seuil + ", rêve actuel "+reve+")"; const segments = RdDUtility.getSegmentsFatigue(this.data.data.sante.endurance.max);
} let cumul = 0;
else { console.log("recupererFatigue", segments);
let deRecuperation = await RdDDice.deDraconique();
console.log("recuperationReve", deRecuperation); let i;
if (deRecuperation>=7) for (i=0; i <11; i++) {
{ cumul += segments[i];
// Rêve de Dragon ! let diff = cumul - fatigue.value ;
message.content = "Vous faites un <strong>Rêve de Dragon</strong> de " + deRecuperation + " Points de rêve"; if (diff >= 0)
message.content += await this.combattreReveDeDragon(deRecuperation); {
} const limit2Segments = Math.floor(segments[i] / 2);
else{ if (diff > limit2Segments && i > 0) {
message.content = "Vous récupérez " + deRecuperation + " Points de rêve"; cumul -= segments[i-1]; // le segment est à moins de la moitié, il est récupéré
await this.updatePointsDeReve(deRecuperation);
} }
cumul -= segments[i];
break;
} }
ChatMessage.create( message ); }
fatigue.value = cumul;
await this.update( {"data.sante.fatigue": fatigue } );
if (fatigue.value == 0)
{
message.content += "<br>Vous êtes bien reposé";
}
} }
async combattreReveDeDragon(force){ recuperationReve(message) {
const seuil = this.data.data.reve.seuil.value;
const reve = this.getReveActuel();
if (reve >= seuil) {
message.content += "<br>Vous avez suffisament rêvé (seuil " + seuil + ", rêve actuel "+reve+")";
}
else {
let deRecuperation = RdDDice.deDraconique();
console.log("recuperationReve", deRecuperation);
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 += this.combattreReveDeDragon(deRecuperation);
}
else{
message.content += "<br>Vous récupérez " + deRecuperation + " Points de rêve";
this.updatePointsDeReve(deRecuperation);
}
}
}
combattreReveDeDragon(force){
let draconic = this.getBestDraconic(); let draconic = this.getBestDraconic();
let niveau = Math.max(0, draconic.data.niveau); let niveau = Math.max(0, draconic.data.niveau);
let etat = this.data.data.compteurs.etat.value; let etat = this.data.data.compteurs.etat.value;
let difficulte = niveau - etat - force; let difficulte = niveau - etat - force;
let reveActuel = this.getReveActuel(); let reveActuel = this.getReveActuel();
let roll = await RdDResolutionTable.roll(reveActuel, difficulte); let rolled = RdDResolutionTable.roll(reveActuel, difficulte);
let message = "" // TODO: xp particulière
const resultatRdD = await this.appliquerReveDeDragon(roll, force); consome.log("combattreReveDeDragon", rolled );
return resultatRdD; return this.appliquerReveDeDragon(rolled, force);
} }
async appliquerReveDeDragon(roll, force) { appliquerReveDeDragon(roll, force) {
let message = ""; let message = "";
if (roll.isSuccess) { if (roll.isSuccess) {
message += "<br>Vous gagnez " + force + " points de Rêve"; message += "<br>Vous gagnez " + force + " points de Rêve";
this.updatePointDeSeuil(); this.updatePointDeSeuil();
await this.updatePointsDeReve(force); this.updatePointsDeReve(force);
} }
if (roll.isPart) { if (roll.isPart) {
// TODO: Dialog pour choix entre HR opu général? // TODO: Dialog pour choix entre HR opu général?
@ -716,9 +754,9 @@ export class RdDActor extends Actor {
if ( data.value < 0 ) data.value = 0; if ( data.value < 0 ) data.value = 0;
if (name == "endurance" && this.data.type != 'entite' ) { if (name == "endurance" && this.data.type != 'entite' ) {
if ( sante.fatigue && inc < 0 ) // Each endurance lost -> fatigue lost if ( sante.fatigue && inc < 0 ) { // Each endurance lost -> fatigue lost
sante.fatigue.value = sante.fatigue.value - inc sante.fatigue.value = sante.fatigue.value - inc
}
// If endurance is 0 -> -1 vie // If endurance is 0 -> -1 vie
if ( data.value == 0 && sante.vie.value > 0) { if ( data.value == 0 && sante.vie.value > 0) {
sante.vie.value = sante.vie.value - 1; sante.vie.value = sante.vie.value - 1;
@ -732,7 +770,7 @@ export class RdDActor extends Actor {
let blessures = this.data.data.blessures; let blessures = this.data.data.blessures;
let nbGraves = this.GetNumberBlessures(blessures.graves.liste); let nbGraves = this.GetNumberBlessures(blessures.graves.liste);
let nbCritiques = this.GetNumberBlessures(blessures.critiques.liste); let nbCritiques = this.GetNumberBlessures(blessures.critiques.liste);
let maxEnd = Math.floor( data.max / nbGraves); let maxEnd = Math.floor( data.max / (2*nbGraves));
if (data.value > maxEnd ) data.value = maxEnd; if (data.value > maxEnd ) data.value = maxEnd;
if ( nbCritiques > 0 && data.value > 1) data.value = 1; if ( nbCritiques > 0 && data.value > 1) data.value = 1;
@ -829,9 +867,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async stressTest() { async stressTest() {
let target = RdDResolutionTable.computeChances(this.data.data.carac.reve.value, 0); let stressRoll = this._stressRoll();
let stressRoll = this._stressRoll(target);
let compteurs = duplicate(this.data.data.compteurs); let compteurs = duplicate(this.data.data.compteurs);
let convertion = Math.floor(compteurs.stress.value * stressRoll.factor); let convertion = Math.floor(compteurs.stress.value * stressRoll.factor);
@ -839,30 +875,35 @@ export class RdDActor extends Actor {
compteurs.stress.value = Math.max(compteurs.stress.value - convertion - 1, 0); compteurs.stress.value = Math.max(compteurs.stress.value - convertion - 1, 0);
ChatMessage.create({ ChatMessage.create({
title: "Jet de Stress", content: "Vous avez transformé " + convertion + " points de Stress en Expérience avec une réussite " + stressRoll.comment, title: "Jet de Stress", content: "Vous avez transformé " + convertion + " points de Stress en Expérience" + stressRoll.comment,
whisper: ChatMessage.getWhisperRecipients(game.user.name) whisper: ChatMessage.getWhisperRecipients(game.user.name)
}); });
await this.update({ "data.compteurs": compteurs }); await this.update({ "data.compteurs": compteurs });
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async _stressRoll(target) { _stressRoll() {
let result = await RdDResolutionTable.rollChances(target) let result = RdDResolutionTable.roll(this.data.data.carac.reve.value, 0);
switch (result.quality) { console.log("_stressRoll", result);
case "sign": return { factor: 0.75, comment: "Significative (75%) - " + result.roll } switch (result.code) {
case "norm": return { factor: 0.5, comment: "Normale (50%) - " + result.roll } case "sign": return { factor: 0.75, comment: " (75%): " + result.quality + " - " + result.roll + " sur " + result.score + "%" }
case "echec": return { factor: 0.2, comment: "Echec (20%) - " + result.roll } case "norm": return { factor: 0.5, comment: " (50%): " + result.quality + " - " + result.roll + " sur " + result.score + "%" }
case "epart": return { factor: 0.1, comment: "Echec particulier(10%) - " + result.roll } case "echec": return { factor: 0.2, comment: " (20%): " + result.quality + " - " + result.roll + " sur " + result.score + "%" }
case "etotal": return { factor: 0, comment: "Echec Total (0%) - " + result.roll } case "epart": return { factor: 0.1, comment: " (10%): " + result.quality + " - " + result.roll + " sur " + result.score + "%" }
} case "etotal": return { factor: 0, comment: " (0%): " + result.quality + " - " + result.roll + " sur " + result.score + "%" }
let second = await RdDResolutionTable.rollChances(target) case "part":
switch (second.quality) { {
case "part": case "sign": let second = RdDResolutionTable.roll(this.data.data.carac.reve.value, 0);
return { factor: 1.5, comment: "Double Particulière (150%) - " + result.roll + " puis " + second.roll } console.log("_stressRoll", second);
default: switch (second.code) {
return { factor: 1, comment: "Particulière (100%) - " + result.roll + " puis " + second.roll } case "part": case "sign":
} return { factor: 1.5, comment: " (150%): Double Particulière - " + result.roll + " puis " + second.roll + " sur " + result.score + "%" }
default:
return { factor: 1, comment: " (150%): " + result.quality + " - " + result.roll + " puis " + second.roll + " sur " + result.score + "%" }
}
}
} }
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async rollUnSort(coord) { async rollUnSort(coord) {

View File

@ -1,13 +1,16 @@
export class RdDDice { export class RdDDice {
static async deDraconique() { static deDraconique(rollMode="selfroll") {
let roll = new Roll("1d8x8").evaluate(); let roll = new Roll("1d8x8").evaluate();
await this.show(roll); this.show(roll, rollMode);
return roll.total - Math.ceil(roll.total / 8); return roll.total - Math.ceil(roll.total / 8);
} }
static async show(roll, rollMode = "roll") {
await this.showDiceSoNice(roll, rollMode); static show(roll, rollMode = "roll") {
if (roll.showDice || game.settings.get("foundryvtt-reve-de-dragon", "dice-so-nice") == true) {
this.showDiceSoNice(roll, rollMode);
}
return roll; return roll;
} }

View File

@ -103,11 +103,19 @@ Hooks.once("init", async function() {
rollDataHandler: {} rollDataHandler: {}
} }
// Create specific settings // Create specific settings
game.settings.register("foundryvtt-reve-de-dragon", "configuration", { // game.settings.register("foundryvtt-reve-de-dragon", "configuration", {
name: "configuration", // name: "configuration",
scope: "world", // scope: "world",
config: false, // config: false,
type: Object // type: Object
// });
game.settings.register("foundryvtt-reve-de-dragon", "dice-so-nice", {
name: "Montrer les dés pour toutes les jets",
hint: "Utilise Dice So Nice pour tous les jets de dés possibles. Décocher pour limiter à la table de résolution",
scope: "client",
config: true,
default: false,
type: Boolean
}); });
//game.settings.get("<systemName>","<settingName>") to retrieve it and game.settings.set("<systemName>","<settingName>", <newValue>) //game.settings.get("<systemName>","<settingName>") to retrieve it and game.settings.set("<systemName>","<settingName>", <newValue>)
@ -167,8 +175,12 @@ Hooks.once("init", async function() {
/* Foundry VTT Initialization */ /* Foundry VTT Initialization */
/* -------------------------------------------- */ /* -------------------------------------------- */
Hooks.once("ready", function() { Hooks.once("ready", function() {
ChatMessage.create( { title: "Bienvenu dans le Rêve !", content : "Bienvenu dans le Rêve des Dragons !<br> " + ChatMessage.create( {
"Vous trouverez quelques infos pour démarrer dans ce document : @Compendium[foundryvtt-reve-de-dragon.rappel-des-regles.7uGrUHGdPu0EmIu2]{Documentation MJ/Joueurs}" } ); whisper: [game.user],
title: "Bienvenu dans le Rêve !",
content : "Bienvenu dans le Rêve des Dragons !<br> " +
"Vous trouverez quelques infos pour démarrer dans ce document : @Compendium[foundryvtt-reve-de-dragon.rappel-des-regles.7uGrUHGdPu0EmIu2]{Documentation MJ/Joueurs}" }
);
/* Affiche le calendrier */ /* Affiche le calendrier */
let calendrier = new RdDCalendrier(); let calendrier = new RdDCalendrier();

View File

@ -85,21 +85,20 @@ export class RdDResolutionTable {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static async roll(carac, finalLevel, showDice=false) { static roll(carac, finalLevel) {
let chances = this.computeChances(carac, finalLevel); let chances = this.computeChances(carac, finalLevel);
chances.showDice = showDice; chances.showDice = true;
let rolled = await this.rollChances(chances); let rolled = this.rollChances(chances);
rolled.carac = carac; rolled.carac = carac;
rolled.finalLevel = finalLevel; rolled.finalLevel = finalLevel;
return rolled; return rolled;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static async rollChances(chances) { static rollChances(chances) {
let myRoll = new Roll("d100").roll(); let myRoll = new Roll("d100").roll();
if (chances.showDice) { myRoll.showDice = chances.showDice;
await RdDDice.showDiceSoNice(myRoll); RdDDice.show(myRoll);
}
chances.roll = myRoll.total; chances.roll = myRoll.total;
mergeObject(chances, this._computeReussite(chances, chances.roll)); mergeObject(chances, this._computeReussite(chances, chances.roll));
return chances; return chances;

View File

@ -137,9 +137,8 @@ export class RdDTMRDialog extends Dialog {
} }
this.currentRencontre = undefined; this.currentRencontre = undefined;
let rencontre = this.rencontresExistantes.find(prev => prev.coord == coordTMR); let rencontre = this.rencontresExistantes.find(prev => prev.coord == coordTMR);
let deRencontre = new Roll("d7").roll();
console.log("manageRencontre", deRencontre, rencontre);
if (rencontre == undefined) { if (rencontre == undefined) {
let deRencontre = new Roll("d7").roll();
if (deRencontre.total == 7) { if (deRencontre.total == 7) {
rencontre = await TMRUtility.rencontreTMRRoll(coordTMR, cellDescr); rencontre = await TMRUtility.rencontreTMRRoll(coordTMR, cellDescr);
} }

View File

@ -27,22 +27,23 @@ const competence_xp_par_niveau = [ 5, 5, 5, 10, 10, 10, 10, 15, 15, 15, 15, 20,
const carac_array = [ "taille", "apparence", "constitution", "force", "agilite", "dexterite", "vue", "ouie", "odoratgout", "volonte", "intellect", "empathie", "reve", "chance", "melee", "tir", "lancer", "derobee"]; const carac_array = [ "taille", "apparence", "constitution", "force", "agilite", "dexterite", "vue", "ouie", "odoratgout", "volonte", "intellect", "empathie", "reve", "chance", "melee", "tir", "lancer", "derobee"];
const difficultesLibres = [0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]; const difficultesLibres = [0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10];
const ajustementsConditions = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10]; const ajustementsConditions = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10];
const fatigueMatrix = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, // Dummy filler for the array.
[2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3 ], function _buildAllSegmentsFatigue(max) {
[2, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3 ], const cycle = [5, 2, 4, 1, 3, 0];
[3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 ], let fatigue = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]];
[3, 3, 3, 3, 3, 4, 3, 3, 3, 3, 3, 4 ], for (let i = 0; i <= 40; i++) {
[3, 3, 4, 3, 3, 4, 3, 3, 4, 3, 3, 4 ], const ligneFatigue= duplicate(fatigue[i]);
[3, 3, 4, 3, 4, 4, 3, 3, 4, 3, 4, 4 ], const caseIncrementee = cycle[i % 6];
[3, 4, 4, 3, 4, 4, 3, 4, 4, 3, 4, 4 ], ligneFatigue[caseIncrementee]++;
[3, 4, 4, 4, 4, 4, 3, 4, 4, 4, 4, 4 ], ligneFatigue[caseIncrementee + 6]++;
[4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 ], ligneFatigue.fatigueMax = 2 * (i + 1);
[4, 4, 4, 4, 4, 5, 4, 4, 4, 4, 4, 5 ], fatigue[i + 1] = ligneFatigue ;
[4, 4, 5, 4, 4, 5, 4, 4, 5, 4, 4, 5 ], }
[4, 4, 5, 4, 5, 5, 4, 4, 5, 4, 5, 5 ], return fatigue;
[4, 5, 5, 4, 5, 5, 4, 5, 5, 4, 5, 5 ], }
[4, 5, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5 ],
[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 ] ]; const fatigueMatrix = _buildAllSegmentsFatigue(30);
const fatigueMalus = [ 0, 0, 0, -1, -1, -1, -2, -3, -4, -5, -6, -7 ]; // Provides the malus for each segment of fatigue const fatigueMalus = [ 0, 0, 0, -1, -1, -1, -2, -3, -4, -5, -6, -7 ]; // Provides the malus for each segment of fatigue
const fatigueLineSize = [ 3, 6, 7, 8, 9, 10, 11, 12]; const fatigueLineSize = [ 3, 6, 7, 8, 9, 10, 11, 12];
const fatigueLineMalus = [ 0, -1, -2, -3, -4, -5, -6, -7 ]; const fatigueLineMalus = [ 0, -1, -2, -3, -4, -5, -6, -7 ];
@ -84,7 +85,6 @@ const definitionsEncaissement = {
/* -------------------------------------------- */ /* -------------------------------------------- */
export class RdDUtility { export class RdDUtility {
/* -------------------------------------------- */ /* -------------------------------------------- */
static async preloadHandlebarsTemplates( ) { static async preloadHandlebarsTemplates( ) {
const templatePaths = [ const templatePaths = [
@ -255,12 +255,12 @@ export class RdDUtility {
/* -------------------------------------------- */ /* -------------------------------------------- */
static computeCarac( data) static computeCarac( data)
{ {
let fmax = parseInt(data.carac.taille.value) + 4; data.carac.force.value = Math.min(data.carac.force.value, parseInt(data.carac.taille.value) + 4);
if ( data.carac.force.value > fmax )
data.carac.force.value = fmax;
data.carac.derobee.value = Math.floor(parseInt(((21 - data.carac.taille.value)) + parseInt(data.carac.agilite.value)) / 2); data.carac.derobee.value = Math.floor(parseInt(((21 - data.carac.taille.value)) + parseInt(data.carac.agilite.value)) / 2);
let bonusDomKey = Math.floor( (parseInt(data.carac.force.value) + parseInt(data.carac.taille.value)) / 2); let bonusDomKey = Math.floor( (parseInt(data.carac.force.value) + parseInt(data.carac.taille.value)) / 2);
// TODO: gérer table des bonus dommages (et autres) des créatures
data.attributs.plusdom.value = 2 data.attributs.plusdom.value = 2
if (bonusDomKey < 8) if (bonusDomKey < 8)
data.attributs.plusdom.value = -1; data.attributs.plusdom.value = -1;
@ -275,15 +275,12 @@ export class RdDUtility {
data.carac.lancer.value = Math.floor( (parseInt(data.carac.tir.value) + parseInt(data.carac.force.value)) / 2); data.carac.lancer.value = Math.floor( (parseInt(data.carac.tir.value) + parseInt(data.carac.force.value)) / 2);
data.sante.vie.max = Math.ceil( (parseInt(data.carac.taille.value) + parseInt(data.carac.constitution.value)) /2 ); data.sante.vie.max = Math.ceil( (parseInt(data.carac.taille.value) + parseInt(data.carac.constitution.value)) /2 );
if ( data.sante.vie.value > data.sante.vie.max)
data.sante.vie.value = data.sante.vie.max; data.sante.vie.value = Math.min(data.sante.vie.value, data.sante.vie.max)
let endurance = Math.max( parseInt(data.carac.taille.value) + parseInt(data.carac.constitution.value), parseInt(data.sante.vie.max) + parseInt(data.carac.volonte.value) ); data.sante.endurance.max = Math.max( parseInt(data.carac.taille.value) + parseInt(data.carac.constitution.value), parseInt(data.sante.vie.max) + parseInt(data.carac.volonte.value) );
data.sante.endurance.max = endurance; data.sante.endurance.value = Math.min(data.sante.endurance.value, data.sante.endurance.max);
if ( data.sante.endurance.value > endurance) data.sante.fatigue.max = data.sante.endurance.max*2;
data.sante.endurance.value = endurance; data.sante.fatigue.value = Math.min(data.sante.fatigue.value, data.sante.fatigue.max);
data.sante.fatigue.max = endurance*2;
if ( data.sante.fatigue.value > data.sante.fatigue.max )
data.sante.fatigue.value = data.sante.fatigue.max;
data.attributs.sconst.value = 5; // Max ! data.attributs.sconst.value = 5; // Max !
if ( data.carac.constitution.value < 9 ) if ( data.carac.constitution.value < 9 )
@ -306,31 +303,47 @@ export class RdDUtility {
data.compteurs.chance.max = data.carac.chance.value; data.compteurs.chance.max = data.carac.chance.value;
} }
static getSegmentsFatigue(endurance) {
endurance = Math.max(endurance, 1);
endurance = Math.min(endurance, fatigueMatrix.length);
return fatigueMatrix[endurance];
}
static cumulSegments(segments) {
let cumuls = [segments[0]];
for (let i = 1; i < 12; i++) {
cumuls[i] = segments[i] + cumuls[i - 1];
}
return cumuls;
}
/* -------------------------------------------- */ /* -------------------------------------------- */
// Build the nice (?) html table used to manage fatigue. // Build the nice (?) html table used to manage fatigue.
// max should Mbe the endurance max value // max should be the endurance max value
static makeHTMLfatigueMatrix( value, max ) static makeHTMLfatigueMatrix( fatigue, maxEndurance) {
{ let segments = this.getSegmentsFatigue(maxEndurance);
max = (max < 16) ? 16 : max; return this.makeHTMLfatigueMatrixForSegment(fatigue, segments);
max = (max > 30) ? 30 : max; }
value = (value > max*2) ? max*2 : value;
value = (value < 0) ? 0 : value;
let fatigueTab = fatigueMatrix[max]; static makeHTMLfatigueMatrixForSegment(fatigue, segments) {
fatigue = Math.max(fatigue, 0);
fatigue = Math.min(fatigue, segments.fatigueMax);
let table = $("<table/>").addClass('table-fatigue'); let table = $("<table/>").addClass('table-fatigue');
let segmentIdx = 0; let segmentIdx = 0;
let fatigueCount = 0; let fatigueCount = 0;
for (var line=0; line < fatigueLineSize.length; line++) { for (var line = 0; line < fatigueLineSize.length; line++) {
let row = $("<tr/>"); let row = $("<tr/>");
let segmentsPerLine = fatigueLineSize[line]; let segmentsPerLine = fatigueLineSize[line];
row.append("<td class='fatigue-malus'>" + fatigueLineMalus[line] + "</td>"); row.append("<td class='fatigue-malus'>" + fatigueLineMalus[line] + "</td>");
while (segmentIdx < segmentsPerLine) { while (segmentIdx < segmentsPerLine) {
let freeSize = fatigueTab[segmentIdx]; let freeSize = segments[segmentIdx];
for (let col=0; col <5; col++) { for (let col = 0; col < 5; col++) {
if ( col < freeSize ) { if (col < freeSize) {
if (fatigueCount < value ) if (fatigueCount < fatigue)
row.append("<td class='fatigue-used'/>"); row.append("<td class='fatigue-used'/>");
else else
row.append("<td class='fatigue-free'/>"); row.append("<td class='fatigue-free'/>");
fatigueCount++; fatigueCount++;
@ -343,7 +356,6 @@ export class RdDUtility {
} }
table.append(row); table.append(row);
} }
//console.log("fatigue", table);
return table; return table;
} }

View File

@ -271,7 +271,7 @@ export class TMRUtility {
let rencontre = this.rencontreTMRTypeCase(cellDescr.type); let rencontre = this.rencontreTMRTypeCase(cellDescr.type);
if (rencontre){ if (rencontre){
rencontre = duplicate(rencontre); rencontre = duplicate(rencontre);
rencontre.force = await this.evaluerForceRencontre(rencontre); rencontre.force = this.evaluerForceRencontre(rencontre);
rencontre.coord = coordTMR; rencontre.coord = coordTMR;
} }
return rencontre; return rencontre;
@ -280,13 +280,15 @@ export class TMRUtility {
static rencontreTMRTypeCase(typeTMR, roll=undefined) { static rencontreTMRTypeCase(typeTMR, roll=undefined) {
if (!roll) if (!roll)
{ {
roll = new Roll("d100").roll().total; roll = RdDDice.show(new Roll("d100").evaluate()).total;
console.log("rencontreTMRTypeCase", roll);
} }
typeTMR = typeTMR.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, ""); typeTMR = typeTMR.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "");
for( let rencontre of rencontresTable) { for( let rencontre of rencontresTable) {
let scoreDef = rencontre.data[typeTMR]; let scoreDef = rencontre.data[typeTMR];
let min = scoreDef.substr(0,2); let min = scoreDef.substr(0,2);
let max = scoreDef.substr(3,2); let max = scoreDef.substr(3,2);
if (min=="00") min = 101;
if (max=="00") max = 100; if (max=="00") max = 100;
if (roll >= min && roll <= max) { if (roll >= min && roll <= max) {
return rencontre; return rencontre;
@ -300,7 +302,7 @@ export class TMRUtility {
* @param {*} caseName * @param {*} caseName
* @param {*} roll * @param {*} roll
*/ */
static async getRencontre( caseName, roll ) { static getRencontre( caseName, roll ) {
if (!roll) { if (!roll) {
roll = new Roll("1d100").roll().total; roll = new Roll("1d100").roll().total;
} }
@ -310,8 +312,8 @@ export class TMRUtility {
} }
let rencontre = this.rencontreTMRTypeCase(caseName, roll); let rencontre = this.rencontreTMRTypeCase(caseName, roll);
if (rencontre){ if (rencontre) {
let force = await this.evaluerForceRencontre(rencontre); let force = this.evaluerForceRencontre(rencontre);
ChatMessage.create({ content: "Rencontre en " + caseName + "(jet : " + roll + "%)<br>Vous rencontrez un " + rencontre.name + " d'une force de " + force + " Points de Rêve" }); ChatMessage.create({ content: "Rencontre en " + caseName + "(jet : " + roll + "%)<br>Vous rencontrez un " + rencontre.name + " d'une force de " + force + " Points de Rêve" });
} }
return false; return false;
@ -323,9 +325,9 @@ export class TMRUtility {
// TODO random get same type // TODO random get same type
} }
static async evaluerForceRencontre(rencontre) { static evaluerForceRencontre(rencontre) {
if (this.isReveDeDragon(rencontre)) { if (this.isReveDeDragon(rencontre)) {
let ddr = await RdDDice.deDraconique(); let ddr = RdDDice.deDraconique();
return ddr + 7; return ddr + 7;
} }
else { else {
@ -371,6 +373,7 @@ export class TMRUtility {
msg += "Ce Tourbillon Noir disparait !" msg += "Ce Tourbillon Noir disparait !"
} else if (rencontre.name == "Rêve de Dragon") { } else if (rencontre.name == "Rêve de Dragon") {
// TODO: xp particulière
msg += "Vous maîtrisez le Rêve de Dragon !" msg += "Vous maîtrisez le Rêve de Dragon !"
msg += actor.appliquerReveDeDragon(rolled, rencontre.force); msg += actor.appliquerReveDeDragon(rolled, rencontre.force);
} }

View File

@ -278,10 +278,13 @@
{{!-- Compteurs/Blessures Tab --}} {{!-- Compteurs/Blessures Tab --}}
<div class="tab blessurescompteurs" data-group="primary" data-tab="blessurescompteurs"> <div class="tab blessurescompteurs" data-group="primary" data-tab="blessurescompteurs">
<div class="flex-group-left flexrow"> <div class="flex-group-left flexrow">
<span class="dormir-une-heure"><a><img src="icons/svg/sleep.svg" alt="Dormir une heure" width="50" height="50"/></a></span>
</div>
<div class="flex-group-left flexrow">
<ol class="item-list"> <ol class="item-list">
{{#each data.compteurs as |compteur key|}} {{#each data.compteurs as |compteur key|}}
<li class="item flexrow""> <li class="item flexrow">
<span class="arme-label">{{compteur.label}}</span> <span class="arme-label">{{compteur.label}}</span>
{{#if compteur.isInput}} {{#if compteur.isInput}}
<input class="stress-value stress-style compteur-edit" id="{{key}}-edit" type="text" name="{{key}}" value="{{compteur.value}}" data-dtype="number"/> <input class="stress-value stress-style compteur-edit" id="{{key}}-edit" type="text" name="{{key}}" value="{{compteur.value}}" data-dtype="number"/>
@ -385,57 +388,67 @@
{{!-- hautreve Tab --}} {{!-- hautreve Tab --}}
<div class="tab hautreve" data-group="primary" data-tab="hautreve" style="height:200px"> <div class="tab hautreve" data-group="primary" data-tab="hautreve" style="height:200px">
<div> <div>
<span class="visu-tmr"><strong><a>Regarder les Terres Medianes</a></strong></span> <ol class="item-list">
</div> <li class="item flexrow">
<div> <span class="competence-label">Position en TMR :</span>
<span class="monte-tmr"><strong><a>Monter Normale dans les Terres Medianes !</a></strong></span> <span>
</div>
<div>
<span class="monte-tmr-rapide"><strong><a>Monter en Accéléré dans les Terres Medianes !</a></strong></span>
</div>
<div>
<span class="dormir-une-heure"><strong><a>Dormir une heure</a></strong></span>
</div>
<div>
<ol class="item-list">
<li class="item flexrow">
<span class="ptreve-actuel"><a>Points de Rêve actuels</a> :</span>
<span><input class="pointsreve-value" type="text" name="data.reve.reve.value" value="{{data.reve.reve.value}}" data-dtype="Number"/></span>
</li>
<li class="item flexrow">
<span class="seuil-reve"><a>Seuil de Rêve</a> :</span>
<span><input class="seuil-reve-value" type="text" name="data.reve.seuil.value" value="{{data.reve.seuil.value}}" data-dtype="Number"/></span>
</li>
{{#if data.isGM}} {{#if data.isGM}}
<li class="item flexrow"> <input class="competence-value" type="text" name="data.reve.tmrpos.coord" value="{{data.reve.tmrpos.coord}}" data-dtype="String"/>
<span class="competence-label">Position en TMR : </span>
<span><input class="competence-value" type="text" name="data.reve.tmrpos.coord" value="{{data.reve.tmrpos.coord}}" data-dtype="String"/></span>
</li>
<li class="item flexrow" >
<span class="competence-label">Refoulement : </span>
<span><input class="competence-value" type="text" name="data.reve.refoulement.value" value="{{data.reve.refoulement.value}}" data-dtype="Number"/></span>
</li>
{{else}} {{else}}
<li class="item flexrow" >Position en TMR : {{data.reve.tmrpos.coord}} </li> {{data.reve.tmrpos.coord}}
<li class="item flexrow" >Refoulement : {{data.reve.refoulement.value}} </li>
{{/if}} {{/if}}
</ol> </span>
</div> </li>
<div> <li class="item flexrow" >
<span><strong>Sorts:</strong></span> <span class="competence-label"></span>
<ol class="item-list"> <div>
{{#each data.sorts as |mysort key|}} <span class="monte-tmr"><a><img src="icons/svg/up.svg" alt="Montée normale dans les Terres Medianes !" width="50" height="50"/></a></span>
<li class="item flexrow" data-item-id="{{mysort._id}}" data-attribute="{{key}}"> <span class="monte-tmr-rapide"><a><img src="icons/svg/thrust.svg" alt="Montée accélérée dans les Terres Medianes !" width="50" height="50"/></a></span>
<span class="sort-label"> <a data-id="{{mysort._id}}">{{mysort.name}}</a></span> <span class="visu-tmr"><a><img src="icons/svg/eye.svg" alt="Regarder les Terres Medianes" width="50" height="50"/></a></span>
<span>{{mysort.data.draconic}} / {{mysort.data.difficulte}}</span>
<div class="item-controls">
<a class="item-control item-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
</div> </div>
</li> </li>
{{/each}} <li class="item flexrow">
</ol> <span class="ptreve-actuel competence-label"><a>Points de Rêve actuels</a> :</span>
</div> <span><input class="pointsreve-value" type="text" name="data.reve.reve.value" value="{{data.reve.reve.value}}" data-dtype="Number"/></span>
</li>
<li class="item flexrow">
<span class="competence-label">Seuil de Rêve :</span>
<span>
{{#if data.isGM}}
<input class="seuil-reve-value" type="text" name="data.reve.seuil.value" value="{{data.reve.seuil.value}}" data-dtype="Number"/>
{{else}}
{{data.reve.seuil.value}}
{{/if}}
</span>
</li>
<li class="item flexrow" >
<span class="competence-label">Refoulement : </span>
<span>
{{#if data.isGM}}
<input class="competence-value" type="text" name="data.reve.refoulement.value" value="{{data.reve.refoulement.value}}" data-dtype="Number"/>
{{else}}
{{data.reve.refoulement.value}}
{{/if}}
</span>
</li>
</ol>
</div>
<div>
<span><strong>Sorts:</strong></span>
<ol class="item-list">
{{#each data.sorts as |mysort key|}}
<li class="item flexrow" data-item-id="{{mysort._id}}" data-attribute="{{key}}">
<span class="sort-label"> <a data-id="{{mysort._id}}">{{mysort.name}}</a></span>
<span>{{mysort.data.draconic}} / {{mysort.data.difficulte}}</span>
<div class="item-controls">
<a class="item-control item-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
</ol>
</div>
</div> </div>
{{!-- Equipment Tab --}} {{!-- Equipment Tab --}}