Correction async pas utiles
This commit is contained in:
parent
803b340ad0
commit
fbe70e42ea
@ -122,7 +122,7 @@ export class RdDActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
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
|
||||
rollData.rolled = rolled; // garder le résultat
|
||||
console.log("performRoll", rollData, rolled)
|
||||
@ -363,24 +363,23 @@ export class RdDActor extends Actor {
|
||||
ChatMessage.create( message );
|
||||
}
|
||||
|
||||
async combattreReveDeDragon(force){
|
||||
combattreReveDeDragon(force){
|
||||
let draconic = this.getBestDraconic();
|
||||
let niveau = Math.max(0, draconic.data.niveau);
|
||||
let etat = this.data.data.compteurs.etat.value;
|
||||
let difficulte = niveau - etat - force;
|
||||
let reveActuel = this.getReveActuel();
|
||||
let roll = await RdDResolutionTable.roll(reveActuel, difficulte);
|
||||
let message = ""
|
||||
const resultatRdD = await this.appliquerReveDeDragon(roll, force);
|
||||
return resultatRdD;
|
||||
let rolled = RdDResolutionTable.roll(reveActuel, difficulte);
|
||||
consome.log("combattreReveDeDragon", rolled );
|
||||
return this.appliquerReveDeDragon(rolled, force);
|
||||
}
|
||||
|
||||
async appliquerReveDeDragon(roll, force) {
|
||||
appliquerReveDeDragon(roll, force) {
|
||||
let message = "";
|
||||
if (roll.isSuccess) {
|
||||
message += "<br>Vous gagnez " + force + " points de Rêve";
|
||||
this.updatePointDeSeuil();
|
||||
await this.updatePointsDeReve(force);
|
||||
this.updatePointsDeReve(force);
|
||||
}
|
||||
if (roll.isPart) {
|
||||
// TODO: Dialog pour choix entre HR opu général?
|
||||
@ -716,9 +715,9 @@ export class RdDActor extends Actor {
|
||||
if ( data.value < 0 ) data.value = 0;
|
||||
|
||||
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
|
||||
|
||||
}
|
||||
// If endurance is 0 -> -1 vie
|
||||
if ( data.value == 0 && sante.vie.value > 0) {
|
||||
sante.vie.value = sante.vie.value - 1;
|
||||
@ -829,9 +828,7 @@ export class RdDActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async stressTest() {
|
||||
let target = RdDResolutionTable.computeChances(this.data.data.carac.reve.value, 0);
|
||||
let stressRoll = this._stressRoll(target);
|
||||
|
||||
let stressRoll = this._stressRoll();
|
||||
let compteurs = duplicate(this.data.data.compteurs);
|
||||
let convertion = Math.floor(compteurs.stress.value * stressRoll.factor);
|
||||
|
||||
@ -839,28 +836,33 @@ export class RdDActor extends Actor {
|
||||
compteurs.stress.value = Math.max(compteurs.stress.value - convertion - 1, 0);
|
||||
|
||||
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)
|
||||
});
|
||||
await this.update({ "data.compteurs": compteurs });
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async _stressRoll(target) {
|
||||
let result = await RdDResolutionTable.rollChances(target)
|
||||
switch (result.quality) {
|
||||
case "sign": return { factor: 0.75, comment: "Significative (75%) - " + result.roll }
|
||||
case "norm": return { factor: 0.5, comment: "Normale (50%) - " + result.roll }
|
||||
case "echec": return { factor: 0.2, comment: "Echec (20%) - " + result.roll }
|
||||
case "epart": return { factor: 0.1, comment: "Echec particulier(10%) - " + result.roll }
|
||||
case "etotal": return { factor: 0, comment: "Echec Total (0%) - " + result.roll }
|
||||
}
|
||||
let second = await RdDResolutionTable.rollChances(target)
|
||||
switch (second.quality) {
|
||||
_stressRoll() {
|
||||
let result = RdDResolutionTable.roll(this.data.data.carac.reve.value, 0);
|
||||
console.log("_stressRoll", result);
|
||||
switch (result.code) {
|
||||
case "sign": return { factor: 0.75, comment: " (75%): " + result.quality + " - " + result.roll + " sur " + result.score + "%" }
|
||||
case "norm": return { factor: 0.5, comment: " (50%): " + result.quality + " - " + result.roll + " sur " + result.score + "%" }
|
||||
case "echec": return { factor: 0.2, comment: " (20%): " + result.quality + " - " + result.roll + " sur " + result.score + "%" }
|
||||
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 + "%" }
|
||||
case "part":
|
||||
{
|
||||
let second = RdDResolutionTable.roll(this.data.data.carac.reve.value, 0);
|
||||
console.log("_stressRoll", second);
|
||||
switch (second.code) {
|
||||
case "part": case "sign":
|
||||
return { factor: 1.5, comment: "Double Particulière (150%) - " + result.roll + " puis " + second.roll }
|
||||
return { factor: 1.5, comment: " (150%): Double Particulière - " + result.roll + " puis " + second.roll + " sur " + result.score + "%" }
|
||||
default:
|
||||
return { factor: 1, comment: "Particulière (100%) - " + result.roll + " puis " + second.roll }
|
||||
return { factor: 1, comment: " (150%): " + result.quality + " - " + result.roll + " puis " + second.roll + " sur " + result.score + "%" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,16 @@
|
||||
export class RdDDice {
|
||||
|
||||
static async deDraconique() {
|
||||
static deDraconique(rollMode="selfroll") {
|
||||
let roll = new Roll("1d8x8").evaluate();
|
||||
await this.show(roll);
|
||||
this.show(roll, rollMode);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -103,11 +103,19 @@ Hooks.once("init", async function() {
|
||||
rollDataHandler: {}
|
||||
}
|
||||
// Create specific settings
|
||||
game.settings.register("foundryvtt-reve-de-dragon", "configuration", {
|
||||
name: "configuration",
|
||||
scope: "world",
|
||||
config: false,
|
||||
type: Object
|
||||
// game.settings.register("foundryvtt-reve-de-dragon", "configuration", {
|
||||
// name: "configuration",
|
||||
// scope: "world",
|
||||
// config: false,
|
||||
// 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>)
|
||||
|
||||
|
@ -85,21 +85,20 @@ export class RdDResolutionTable {
|
||||
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
static async roll(carac, finalLevel, showDice=false) {
|
||||
static roll(carac, finalLevel) {
|
||||
let chances = this.computeChances(carac, finalLevel);
|
||||
chances.showDice = showDice;
|
||||
let rolled = await this.rollChances(chances);
|
||||
chances.showDice = true;
|
||||
let rolled = this.rollChances(chances);
|
||||
rolled.carac = carac;
|
||||
rolled.finalLevel = finalLevel;
|
||||
return rolled;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async rollChances(chances) {
|
||||
static rollChances(chances) {
|
||||
let myRoll = new Roll("d100").roll();
|
||||
if (chances.showDice) {
|
||||
await RdDDice.showDiceSoNice(myRoll);
|
||||
}
|
||||
myRoll.showDice = chances.showDice;
|
||||
RdDDice.show(myRoll);
|
||||
chances.roll = myRoll.total;
|
||||
mergeObject(chances, this._computeReussite(chances, chances.roll));
|
||||
return chances;
|
||||
|
@ -137,9 +137,8 @@ export class RdDTMRDialog extends Dialog {
|
||||
}
|
||||
this.currentRencontre = undefined;
|
||||
let rencontre = this.rencontresExistantes.find(prev => prev.coord == coordTMR);
|
||||
let deRencontre = new Roll("d7").roll();
|
||||
console.log("manageRencontre", deRencontre, rencontre);
|
||||
if (rencontre == undefined) {
|
||||
let deRencontre = new Roll("d7").roll();
|
||||
if (deRencontre.total == 7) {
|
||||
rencontre = await TMRUtility.rencontreTMRRoll(coordTMR, cellDescr);
|
||||
}
|
||||
|
@ -271,7 +271,7 @@ export class TMRUtility {
|
||||
let rencontre = this.rencontreTMRTypeCase(cellDescr.type);
|
||||
if (rencontre){
|
||||
rencontre = duplicate(rencontre);
|
||||
rencontre.force = await this.evaluerForceRencontre(rencontre);
|
||||
rencontre.force = this.evaluerForceRencontre(rencontre);
|
||||
rencontre.coord = coordTMR;
|
||||
}
|
||||
return rencontre;
|
||||
@ -280,13 +280,15 @@ export class TMRUtility {
|
||||
static rencontreTMRTypeCase(typeTMR, roll=undefined) {
|
||||
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, "");
|
||||
for( let rencontre of rencontresTable) {
|
||||
let scoreDef = rencontre.data[typeTMR];
|
||||
let min = scoreDef.substr(0,2);
|
||||
let max = scoreDef.substr(3,2);
|
||||
if (min=="00") min = 101;
|
||||
if (max=="00") max = 100;
|
||||
if (roll >= min && roll <= max) {
|
||||
return rencontre;
|
||||
@ -300,7 +302,7 @@ export class TMRUtility {
|
||||
* @param {*} caseName
|
||||
* @param {*} roll
|
||||
*/
|
||||
static async getRencontre( caseName, roll ) {
|
||||
static getRencontre( caseName, roll ) {
|
||||
if (!roll) {
|
||||
roll = new Roll("1d100").roll().total;
|
||||
}
|
||||
@ -311,7 +313,7 @@ export class TMRUtility {
|
||||
|
||||
let rencontre = this.rencontreTMRTypeCase(caseName, roll);
|
||||
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" });
|
||||
}
|
||||
return false;
|
||||
@ -323,9 +325,9 @@ export class TMRUtility {
|
||||
// TODO random get same type
|
||||
}
|
||||
|
||||
static async evaluerForceRencontre(rencontre) {
|
||||
static evaluerForceRencontre(rencontre) {
|
||||
if (this.isReveDeDragon(rencontre)) {
|
||||
let ddr = await RdDDice.deDraconique();
|
||||
let ddr = RdDDice.deDraconique();
|
||||
return ddr + 7;
|
||||
}
|
||||
else {
|
||||
|
Loading…
Reference in New Issue
Block a user