forked from public/foundryvtt-reve-de-dragon
Separation difficulte libre/conditions
* ajout de diffConditions pour gérer l'ajustement de conditions * renommage de bmValue en diffLibre * calcul de l'ajustement (etat+conditions+difficulté libre) * présentation des 2 champs fix: * utiliser .change() au lieu de .click() permet de supporter aussi les changements au clavier
This commit is contained in:
141
module/actor.js
141
module/actor.js
@ -166,8 +166,8 @@ export class RdDActor extends Actor {
|
||||
console.log(">>> ROLL", rollData, rolled);
|
||||
let xpmsg = RdDResolutionTable.buildXpMessage(rolled, rollData.finalLevel);
|
||||
|
||||
let resumeCompetence = (rollData.competence) ? rollData.competence.name : rollData.bmValue;
|
||||
let explications = "<br>Points de taches : " + rolled.tache + ", Points de qualité: " + rolled.qualite;
|
||||
let resumeCompetence = (rollData.competence) ? rollData.competence.name : (rollData.diffLibre + rollData.diffConditions);
|
||||
let explications = "<br>Points de taches : " + rolled.ptTache + ", ajustement qualité: " + rolled.ptQualite;
|
||||
|
||||
// Fight management !
|
||||
let defenseMsg;
|
||||
@ -217,7 +217,8 @@ export class RdDActor extends Actor {
|
||||
// Final chat message
|
||||
let chatOptions = {
|
||||
content: "<strong>Test : " + rollData.selectedCarac.label + " / " + resumeCompetence + "</strong>"
|
||||
+ "<br>Jet : " + rollData.selectedCarac.value + " / " + rollData.finalLevelStr + " -> " + rolled.score + "%<br><strong>Résutat : </strong>" + rolled.roll
|
||||
+ "<br>Difficultés <strong>libre : " + rollData.diffLibre + "</strong> / conditions : " + Misc.toSignedString(rollData.diffConditions) +" / état : " + rollData.etat
|
||||
+ "<br>Jet : " + rolled.roll + " sur "+ rolled.score + "% (" + rollData.selectedCarac.value + " à " +Misc.toSignedString(rollData.finalLevel) + ")"
|
||||
+ "<br><strong>" + quality + "</strong>"
|
||||
+ explications + xpmsg,
|
||||
user: game.user._id,
|
||||
@ -264,7 +265,7 @@ export class RdDActor extends Actor {
|
||||
let closeTMR = true;
|
||||
let coutReve = sort.data.ptreve_reel || sort.data.ptreve; // cas de sort à ptreve variables
|
||||
|
||||
let explications = "<br>Lancement du sort <strong>" + sort.name + "</strong> : " + Misc._upperFirst(sort.data.draconic)
|
||||
let explications = "<br>Lancement du sort <strong>" + sort.name + "</strong> : " + Misc.upperFirst(sort.data.draconic)
|
||||
+ " pour "+coutReve+ " points de Rêve"
|
||||
+ "<br>Depuis la case " + rollData.coord + " (" + TMRUtility.getTMRDescription(rollData.coord).label + ")";
|
||||
|
||||
@ -694,7 +695,7 @@ export class RdDActor extends Actor {
|
||||
case "etotal": return { factor: 0, comment: "Echec Total (0%) - " + result.roll }
|
||||
}
|
||||
let second = RdDResolutionTable.rollChances(target)
|
||||
switch (second.qualite) {
|
||||
switch (second.quality) {
|
||||
case "part": case "sign":
|
||||
return { factor: 1.5, comment: "Double Particulière (150%) - " + result.roll + " puis " + second.roll }
|
||||
default:
|
||||
@ -716,9 +717,11 @@ export class RdDActor extends Actor {
|
||||
selectedSort: sortList[0],
|
||||
coord: coord,
|
||||
finalLevel: 0,
|
||||
bmValue: sortList[0].data.difficulte, // Per default at startup
|
||||
diffConditions: 0,
|
||||
diffLibre: sortList[0].data.difficulte, // Per default at startup
|
||||
coutreve: Array(20).fill().map((item, index) => 1 + index),
|
||||
bonusmalusTable: CONFIG.RDD.bonusmalus
|
||||
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
|
||||
difficultesLibres: CONFIG.RDD.difficultesLibres
|
||||
}
|
||||
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-sort.html', rollData);
|
||||
new RdDRollDialog("sort", html, rollData, this ).render(true);
|
||||
@ -729,41 +732,43 @@ export class RdDActor extends Actor {
|
||||
{
|
||||
let rollData = {
|
||||
selectedCarac: this.data.data.carac[caracName],
|
||||
bonusmalusTable: CONFIG.RDD.bonusmalus,
|
||||
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
|
||||
difficultesLibres: CONFIG.RDD.difficultesLibres,
|
||||
etat: this.data.data.compteurs.etat.value,
|
||||
finalLevel: 0,
|
||||
bmValue: 0
|
||||
diffConditions: 0,
|
||||
diffLibre: 0
|
||||
}
|
||||
console.log(caracName, rollData);
|
||||
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html', rollData);
|
||||
new RdDRollDialog("carac", html, rollData, this ).render(true);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getSortList() {
|
||||
return this.data.items.filter(item => item.type == "sort");
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getDraconicList() {
|
||||
return this.data.items.filter(item => item.data.categorie == 'draconic')
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async displayTMR(mode="normal" )
|
||||
{
|
||||
let isRapide= mode == "rapide"
|
||||
if (mode != "visu")
|
||||
{
|
||||
let minReveValue = (isRapide) ? 3 : 2;
|
||||
if (this.data.data.reve.reve.value <= minReveValue ) {
|
||||
ChatMessage.create( { title: "Montée impossible !", content: "Vous n'avez plus assez de Points de Reve pour monter dans les Terres Médianes",
|
||||
whisper: ChatMessage.getWhisperRecipients(game.user.name) } );
|
||||
return;
|
||||
}
|
||||
console.log(caracName, rollData);
|
||||
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html', rollData);
|
||||
new RdDRollDialog("carac", html, rollData, this ).render(true);
|
||||
}
|
||||
|
||||
let data = {
|
||||
/* -------------------------------------------- */
|
||||
getSortList() {
|
||||
return this.data.items.filter(item => item.type == "sort");
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getDraconicList() {
|
||||
return this.data.items.filter(item => item.data.categorie == 'draconic')
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async displayTMR(mode="normal" )
|
||||
{
|
||||
let isRapide= mode == "rapide"
|
||||
if (mode != "visu")
|
||||
{
|
||||
let minReveValue = (isRapide) ? 3 : 2;
|
||||
if (this.data.data.reve.reve.value <= minReveValue ) {
|
||||
ChatMessage.create( { title: "Montée impossible !", content: "Vous n'avez plus assez de Points de Reve pour monter dans les Terres Médianes",
|
||||
whisper: ChatMessage.getWhisperRecipients(game.user.name) } );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let data = {
|
||||
fatigueHTML:"<table class='table-fatigue'>" + RdDUtility.makeHTMLfatigueMatrix( this.data.data.sante.fatigue.value, this.data.data.sante.endurance.max ).html() + "</table>",
|
||||
draconic: this.getDraconicList(),
|
||||
sort: this.getSortList(),
|
||||
@ -771,36 +776,38 @@ export class RdDActor extends Actor {
|
||||
pointsReve: this.data.data.reve.reve.value,
|
||||
isRapide: isRapide
|
||||
}
|
||||
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-tmr.html', data );
|
||||
this.currentTMR = new RdDTMRDialog(html, this, data, mode == "visu");
|
||||
this.currentTMR.render(true);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
rollArme( 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
|
||||
this.rollCompetence( armeName ); //Bypass mode!
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollCompetence( name, armeItem=undefined, attackerRoll=undefined )
|
||||
{
|
||||
let competence = RdDUtility.findCompetence( this.data.items, name);
|
||||
console.log("rollCompetence !!!", competence, armeItem, attackerRoll);
|
||||
// Common rollData values
|
||||
let rollData = {
|
||||
bonusmalusTable: CONFIG.RDD.bonusmalus,
|
||||
etat: this.data.data.compteurs.etat.value,
|
||||
bmValue: (attackerRoll) ? attackerRoll.bmValue : 0,
|
||||
attackerRoll: attackerRoll,
|
||||
finalLevel: 0
|
||||
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-tmr.html', data );
|
||||
this.currentTMR = new RdDTMRDialog(html, this, data, mode == "visu");
|
||||
this.currentTMR.render(true);
|
||||
}
|
||||
|
||||
if ( competence.type == 'competencecreature') { // Specific case for Creatures
|
||||
|
||||
/* -------------------------------------------- */
|
||||
rollArme( 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
|
||||
this.rollCompetence( armeName ); //Bypass mode!
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollCompetence( name, armeItem=undefined, attackerRoll=undefined )
|
||||
{
|
||||
let competence = RdDUtility.findCompetence( this.data.items, name);
|
||||
console.log("rollCompetence !!!", competence, armeItem, attackerRoll);
|
||||
// Common rollData values
|
||||
let rollData = {
|
||||
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
|
||||
difficultesLibres: CONFIG.RDD.difficultesLibres,
|
||||
etat: this.data.data.compteurs.etat.value,
|
||||
diffConditions: 0,
|
||||
diffLibre: (attackerRoll) ? attackerRoll.diffLibre : 0,
|
||||
attackerRoll: attackerRoll,
|
||||
finalLevel: 0
|
||||
}
|
||||
|
||||
if ( competence.type == 'competencecreature') { // Specific case for Creatures
|
||||
if ( competence.data.iscombat ) {
|
||||
armeItem = { name: name, data: { dommages: competence.data.dommages} };
|
||||
}
|
||||
@ -894,7 +901,7 @@ export class RdDActor extends Actor {
|
||||
parerAttaque( attackerRoll, armeId )
|
||||
{
|
||||
let armeItem = this.getOwnedItem(armeId); // Item.data.data !
|
||||
console.log("Going to PARY !!!!!!!!!", armeItem, attackerRoll.bmValue);
|
||||
console.log("Going to PARY !!!!!!!!!", armeItem, attackerRoll.diffLibre);
|
||||
this.rollCompetence( armeItem.data.data.competence, armeItem.data, attackerRoll );
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user