Chiffre astral ajuste la chance

This commit is contained in:
Vincent Vandemeulebrouck 2020-12-11 03:23:34 +01:00
parent 02f04791b9
commit a75157226e
4 changed files with 28 additions and 15 deletions

View File

@ -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");

View File

@ -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);
}
/* -------------------------------------------- */

View File

@ -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();

View File

@ -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;
}
/* -------------------------------------------- */