forked from public/foundryvtt-reve-de-dragon
Add sort
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import { RdDUtility } from "./rdd-utility.js";
|
||||
import { TMRUtility } from "./tmr-utility.js";
|
||||
import { RdDRollDialog } from "./rdd-roll-dialog.js";
|
||||
import { RdDTMRDialog } from "./rdd-tmr-dialog.js";
|
||||
|
||||
@ -193,13 +194,41 @@ export class RdDActor extends Actor {
|
||||
await this.setFlag( "foundryvtt-reve-de-dragon", "rollData", undefined );
|
||||
await this.setFlag( "foundryvtt-reve-de-dragon", "rollData", rollData );
|
||||
|
||||
// Sort management
|
||||
let lvl = ""
|
||||
if ( rollData.selectedSort) {
|
||||
if ( rollData.selectedSort) { // Lancement de sort !
|
||||
specialStr = "<br>Lancement du sort <strong>" + rollData.selectedSort.name + "</strong> : " + rollData.selectedSort.data.draconic + "/" + rollData.selectedSort.data.difficulte +
|
||||
"/" + rollData.selectedSort.data.caseTMR + "/" + rollData.selectedSort.data.ptreve;
|
||||
specialStr += "<br>Depuis la case " + rollData.coord + "(" + TMRUtility.getTMRDescription(rollData.coord).label + ")";
|
||||
lvl = rollData.selectedDraconic.name +"/"+ rollData.selectedSort.name;
|
||||
specialStr = "";
|
||||
let costReve = rollData.selectedSort.data.ptreve;
|
||||
let myReve = duplicate(this.data.data.reve.reve);
|
||||
if ( rollData.pointsDeTache > 0 ) { // Réussite du sort !
|
||||
if (rollData.pointsDeTache >= 4 ) costReve = Math.ceil(costReve/2);
|
||||
if (costReve < 1 ) costReve = 1;
|
||||
myReve.value = myReve.value - costReve; // Todo 0 pts de reve !!!!
|
||||
if (myReve.value < 0) myReve.value = 0;
|
||||
await this.update( {"data.reve.reve": myReve } );
|
||||
specialStr += "<br>Réussite du sort pour " + costReve + " Points de Rêve";
|
||||
} else {
|
||||
if ( rollData.pointsDeTache == -4) { // Echec total !
|
||||
costReve *= 2;
|
||||
myReve.value = myReve.value - costReve; // Todo 0 pts de reve !!!!
|
||||
if (myReve.value < 0) myReve.value = 0;
|
||||
await this.update( {"data.reve.reve": myReve } );
|
||||
specialStr += "<br><strong>Echec TOTAL</strong> du sort !, pour " + costReve + " Points de Rêve";
|
||||
} else {
|
||||
specialStr += "<br>Echec du sort !";
|
||||
}
|
||||
}
|
||||
if (myReve.value == 0) { // 0 points de reve
|
||||
ChatMessage.create( {title: "Zero Points de Reve !", content: this.name + " est réduit à 0 Points de Rêve, et tombe endormi !" } );
|
||||
}
|
||||
} else {
|
||||
lvl = (rollData.competence) ? rollData.competence.name : rollData.bmValue;
|
||||
}
|
||||
|
||||
// Final chat message
|
||||
let chatOptions = { content: "<strong>Test : " + rollData.selectedCarac.label + " / " + lvl + "</strong><br>Jet : " +
|
||||
rollData.selectedCarac.value + " / " + rollData.finalLevelStr + " -> " + rollData.rollTarget.score + "%<br><strong>Résutat : </strong>" + result + "<br>" +
|
||||
"<strong>" + quality + "</strong>" + specialStr + xpmsg,
|
||||
@ -265,9 +294,8 @@ export class RdDActor extends Actor {
|
||||
|
||||
let refoulement = duplicate(this.data.data.reve.refoulement);
|
||||
refoulement.value = refoulement.value + value;
|
||||
let myroll = new Roll("d20");
|
||||
myroll.roll();
|
||||
if ( myroll.total <= refoulement.value ) {
|
||||
let total = new Roll("d20").roll().total;
|
||||
if ( total <= refoulement.value ) {
|
||||
ChatMessage.create( { title : "Souffle de Dragon",
|
||||
content: game.user.name + " subit un Souffle de Dragon !" } );
|
||||
refoulement.value = 0;
|
||||
@ -321,9 +349,7 @@ export class RdDActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
testSiSonne( sante, endurance )
|
||||
{
|
||||
let myroll = new Roll("d20");
|
||||
myroll.roll();
|
||||
let result = myroll.total;
|
||||
let result = new Roll("d20").roll().total;
|
||||
if ( result <= endurance.value)
|
||||
sante.sonne.value = false;
|
||||
if ( result > endurance.value || result == 20) // 20 is always a failure
|
||||
@ -366,12 +392,12 @@ export class RdDActor extends Actor {
|
||||
|
||||
if (lastValue - data.value > 1) this.testSiSonne(sante, data); // Peut-être sonné si 2 points d'endurance perdus d'un coup
|
||||
}
|
||||
console.log(name, inc, data.value);
|
||||
//console.log(name, inc, data.value);
|
||||
|
||||
let diffEndurance = sante.endurance.max - this.data.data.sante.endurance.value;
|
||||
if ( sante.fatigue.value < diffEndurance) // If endurance lost, then the same amount of fatigue cannot be recovered
|
||||
sante.fatigue.value = diffEndurance;
|
||||
console.log("SANTE::::", sante);
|
||||
//console.log("SANTE::::", sante);
|
||||
|
||||
await this.update( {"data.sante": sante } );
|
||||
}
|
||||
@ -493,9 +519,10 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async displayTMR( sortID )
|
||||
async displayTMR( isRapide=false )
|
||||
{
|
||||
if (this.data.data.reve.reve.value <= 1 ) {
|
||||
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;
|
||||
@ -506,10 +533,11 @@ export class RdDActor extends Actor {
|
||||
draconic: this.getDraconicList(),
|
||||
sort: this.getSortList(),
|
||||
caracReve: this.data.data.carac.reve.value,
|
||||
pointsReve: this.data.data.reve.reve.value
|
||||
pointsReve: this.data.data.reve.reve.value,
|
||||
isRapide: isRapide
|
||||
}
|
||||
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-tmr.html', data );
|
||||
new RdDTMRDialog(sortID, html, this ).render(true);
|
||||
new RdDTMRDialog(html, this, data ).render(true);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
Reference in New Issue
Block a user