From a75157226edda3bc35af961db3f0ecfbe5b39ce8 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Fri, 11 Dec 2020 03:23:34 +0100 Subject: [PATCH] Chiffre astral ajuste la chance --- module/actor-sheet.js | 4 ---- module/actor.js | 10 ++++------ module/rdd-calendrier.js | 21 +++++++++++++++++++-- module/rdd-roll.js | 8 +++++--- 4 files changed, 28 insertions(+), 15 deletions(-) diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 4f53555e..6417eb88 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -204,10 +204,6 @@ export class RdDActorSheet extends ActorSheet { // Everything below here is only needed if the sheet is editable if (!this.options.editable) return; - $(function () { - $("#data.heure").val(this.actor.data.data.heure); - }); - // Update Inventory Item html.find('.item-edit').click(ev => { const li = $(ev.currentTarget).parents(".item"); diff --git a/module/actor.js b/module/actor.js index 9ac60848..e71698ad 100644 --- a/module/actor.js +++ b/module/actor.js @@ -17,6 +17,7 @@ import { RdDRollTables } from "./rdd-rolltables.js"; import { ChatUtility } from "./chat-utility.js"; import { RdDItemSort } from "./item-sort.js"; import { Grammar } from "./grammar.js"; +import { RdDCalendrier } from "./rdd-calendrier.js"; export class RdDActor extends Actor { @@ -1467,10 +1468,7 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async rollAppelChance( ) { - let rollData = { - selectedCarac: this.getCaracByName('chance-actuelle'), - diffConditions: this.ajustementAstrologique() - } + let rollData = { selectedCarac: this.getCaracByName('chance-actuelle') }; const dialog = await RdDRoll.create(this, rollData, { html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html'}, @@ -1508,8 +1506,8 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ ajustementAstrologique() { - //TODO: selon heure et heure de naissance... - return 0; + // selon l'heure de naissance... + return game.system.rdd.calendrier.getAjustementAstrologique(this.data.data.heure); } /* -------------------------------------------- */ diff --git a/module/rdd-calendrier.js b/module/rdd-calendrier.js index 95e25bda..32682b99 100644 --- a/module/rdd-calendrier.js +++ b/module/rdd-calendrier.js @@ -85,7 +85,7 @@ export class RdDCalendrier extends Application { } /* -------------------------------------------- */ - ajouterNombreAstral(index) { + ajouterNombreAstral(index) { return { nombreAstral: new Roll("1d12").roll().total, valeursFausses: [], @@ -100,7 +100,7 @@ export class RdDCalendrier extends Application { let index = this.getCurrentDayIndex(); return this.listeNombreAstral[index].nombreAstral; } - return '?'; + return 0; } /* -------------------------------------------- */ @@ -203,6 +203,23 @@ export class RdDCalendrier extends Application { return data; } + getAjustementAstrologique(heureNaissance) + { + let hn = heuresDef[heureNaissance].heure; + let chiffreAstral = this.getCurrentNombreAstral(); + let heureCourante = this.calendrier.heureRdD; + let ecartChance = (hn + chiffreAstral - heureCourante)%12; + console.log("ajustementAstrologique", heureNaissance, hn, chiffreAstral, heureCourante, ecartChance); + switch (ecartChance) + { + case 0: return 4; + case 4: case 8: return 2; + case 6: return -4; + case 3: case 9: return -2; + } + return 0; + } + /* -------------------------------------------- */ getData() { let data = super.getData(); diff --git a/module/rdd-roll.js b/module/rdd-roll.js index 3cc84e04..de8c7c2c 100644 --- a/module/rdd-roll.js +++ b/module/rdd-roll.js @@ -40,7 +40,8 @@ export class RdDRoll extends Dialog { surencMalusApply: false, isNatation: rollData.competence ? rollData.competence.name.toLowerCase().includes("natation") : false, useEncForNatation: false, - encValueForNatation: actor.encombrementTotal ? Math.floor(actor.encombrementTotal) : 0 + encValueForNatation: actor.encombrementTotal ? Math.floor(actor.encombrementTotal) : 0, + ajustementAstrologique: actor.ajustementAstrologique() }, { overwrite: false }); } @@ -199,7 +200,7 @@ export class RdDRoll extends Dialog { let malusEnc = (rollData.surencMalusApply) ? rollData.surencMalusValue : 0; let diffLibre = Misc.toInt(rollData.diffLibre); let malusEncNatation = (rollData.useEncForNatation) ? -rollData.encValueForNatation : 0; - + let ajustementChance = rollData.selectedCarac.label.toLowerCase().includes('chance') ? rollData.ajustementAstrologique : 0; // Gestion malus armure let malusArmureValue = 0; if (rollData.malusArmureValue != 0 && (rollData.selectedCarac.label == "Agilité" || rollData.selectedCarac.label == "Dérobée")) { @@ -209,6 +210,7 @@ export class RdDRoll extends Dialog { $("#addon-message").text(""); } + let diffCompetence = 0; if (rollData.competence) { diffCompetence = Misc.toInt(rollData.competence.data.niveau); @@ -218,7 +220,7 @@ export class RdDRoll extends Dialog { diffLibre = RdDItemSort.getDifficulte(rollData.selectedSort, diffLibre); } - return etat + diffCompetence + diffLibre + diffConditions + malusEnc + malusEncNatation + malusArmureValue; + return etat + diffCompetence + diffLibre + diffConditions + malusEnc + malusEncNatation + malusArmureValue + ajustementChance; } /* -------------------------------------------- */