diff --git a/changelog.md b/changelog.md index 70384690..a08f01fd 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,9 @@ # 11.2 +## 11.2.8 - L'éclairage d'Akarlikarlikar +- l'ajustement de la lumière jour/nuit s'étale sur moins de temps (vaisseau et Lyre) +- les nouveaux tooltips ne masquent plus l'information d'expérience +- les jets de dés pour maîtriser les rencontres fonctionnent de nouveau + ## 11.2.7 - Les explications d'Akarlikarlikar - Ajout de tooltips sur la plupart des boutons, liens clickables, objets, tâches, ... - Fix: on peut de nouveau regarder l'inventaire avec les droits limités/observateur diff --git a/module/misc.js b/module/misc.js index 354fef4d..10edee27 100644 --- a/module/misc.js +++ b/module/misc.js @@ -22,6 +22,10 @@ export class Misc { const isPositiveNumber = value != NaN && value > 0; return isPositiveNumber ? "+" + number : number } + + static modulo(n, m) { + return ((n % m) + m) % m; + } static sum() { return (a, b) => Number(a) + Number(b); diff --git a/module/rdd-combat.js b/module/rdd-combat.js index 1458a16c..39f23ae2 100644 --- a/module/rdd-combat.js +++ b/module/rdd-combat.js @@ -515,7 +515,7 @@ export class RdDCombat { static _callJetDeVie(event) { let actorId = event.currentTarget.attributes['data-actorId'].value; let tokenId = event.currentTarget.attributes['data-tokenId'].value; - let token = canvas.tokens.placeables.find(t => t.id == tokenId) + let token = canvas.tokens.get(tokenId) const actor = token?.actor ?? game.actors.get(actorId); if (actor?.isOwner) { actor.jetDeVie(); diff --git a/module/rolldata-ajustements.js b/module/rolldata-ajustements.js index 457c9153..df601186 100644 --- a/module/rolldata-ajustements.js +++ b/module/rolldata-ajustements.js @@ -64,19 +64,19 @@ export const referenceAjustements = { }, encTotal: { isVisible: (rollData, actor) => RdDCarac.isAgiliteOuDerobee(rollData.selectedCarac) && RdDItemCompetence.isMalusEncombrementTotal(rollData.competence), - isUsed: (rollData, actor) => !rollData.oeuvre && RdDCarac.isAgiliteOuDerobee(rollData.selectedCarac) && RdDItemCompetence.isMalusEncombrementTotal(rollData.competence) && rollData.use.encTotal, + isUsed: (rollData, actor) => !rollData.oeuvre && RdDCarac.isAgiliteOuDerobee(rollData.selectedCarac) && RdDItemCompetence.isMalusEncombrementTotal(rollData.competence) && rollData.use?.encTotal, getLabel: (rollData, actor) => 'Encombrement total', getValue: (rollData, actor) => -actor.getEncTotal() }, surenc: { isVisible: (rollData, actor) => RdDCarac.isActionPhysique(rollData.selectedCarac) && actor.isSurenc(), - isUsed: (rollData, actor) => rollData.use?.surenc && RdDCarac.isActionPhysique(rollData.selectedCarac), + isUsed: (rollData, actor) => rollData.use.surenc && RdDCarac.isActionPhysique(rollData.selectedCarac), getLabel: (rollData, actor) => 'Sur-encombrement', getValue: (rollData, actor) => actor.computeMalusSurEncombrement() }, moral: { isVisible: (rollData, actor) => actor.isPersonnage() && RdDCarac.isActionPhysique(rollData.selectedCarac) && rollData.use?.moral, - isUsed: (rollData, actor) => rollData.use?.moral, + isUsed: (rollData, actor) => rollData.use.moral, getLabel: (rollData, actor) => 'Appel au moral', getValue: (rollData, actor) => 1 }, @@ -84,7 +84,7 @@ export const referenceAjustements = { isVisible: (rollData, actor) => actor.isPersonnage() && RdDCarac.isVolonte(rollData.selectedCarac), isUsed: (rollData, actor) => rollData.use.coeur != undefined, getLabel: (rollData, actor) => 'Ajustement de cœur', - getValue: (rollData, actor) => -2 * (rollData.use.coeur?.coeur ?? 0) + getValue: (rollData, actor) => -2 * (rollData.use?.coeur?.coeur ?? 0) }, moralTotal: { isUsed: (rollData, actor) => RdDCarac.isVolonte(rollData.selectedCarac), @@ -141,7 +141,7 @@ export const referenceAjustements = { getLabel: (rollData, actor) => "Force de l'alcool: ", getValue: (rollData, actor) => rollData.forceAlcool, }, - ethylisme:{ + ethylisme: { isVisible: (rollData, actor) => rollData.ethylisme != undefined, isUsed: (rollData, actor) => rollData.ethylisme != undefined, getLabel: (rollData, actor) => "Ethylisme - " + RdDUtility.getNomEthylisme(rollData.ethylisme), @@ -159,7 +159,9 @@ export class RollDataAjustements { /* -------------------------------------------- */ static calcul(rollData, actor) { - rollData.ajustements = {}; + // s'assurer de la correction des infos rollData + mergeObject(rollData, { ajustements: {}, use: {} }, { overwrite: false }) + for (var key in referenceAjustements) { const reference = referenceAjustements[key]; rollData.ajustements[key] = { diff --git a/module/time/rdd-timestamp.js b/module/time/rdd-timestamp.js index ad6f1948..eb8ea8e5 100644 --- a/module/time/rdd-timestamp.js +++ b/module/time/rdd-timestamp.js @@ -2,7 +2,6 @@ import { SHOW_DICE, SYSTEM_RDD } from "../constants.js"; import { Grammar } from "../grammar.js"; import { Misc } from "../misc.js"; import { RdDDice } from "../rdd-dice.js"; -import { AutoAdjustDarkness } from "./auto-adjust-darkness.js"; export const WORLD_TIMESTAMP_SETTING = "calendrier"; @@ -16,14 +15,14 @@ export const RDD_MINUTES_PAR_JOUR = 1440; //RDD_HEURES_PAR_JOUR * RDD_MINUTES_PA const ROUNDS_PAR_MINUTE = 10; const DEFINITION_HEURES = [ - { key: "vaisseau", label: "Vaisseau", lettreFont: 'v', saison: "Printemps" , darkness: 0.7}, - { key: "sirene", label: "Sirène", lettreFont: 'i', saison: "Printemps" , darkness: 0.4}, - { key: "faucon", label: "Faucon", lettreFont: 'f', saison: "Printemps" , darkness: 0}, - { key: "couronne", label: "Couronne", lettreFont: '', saison: "Eté" , darkness: 0}, + { key: "vaisseau", label: "Vaisseau", lettreFont: 'v', saison: "Printemps", darkness: 0.9 }, + { key: "sirene", label: "Sirène", lettreFont: 'i', saison: "Printemps", darkness: 0.1 }, + { key: "faucon", label: "Faucon", lettreFont: 'f', saison: "Printemps", darkness: 0 }, + { key: "couronne", label: "Couronne", lettreFont: '', saison: "Eté", darkness: 0 }, { key: "dragon", label: "Dragon", lettreFont: 'd', saison: "Eté", darkness: 0 }, - { key: "epees", label: "Epées", lettreFont: 'e', saison: "Eté", darkness: 0}, - { key: "lyre", label: "Lyre", lettreFont: 'l', saison: "Automne", darkness: 0.4 }, - { key: "serpent", label: "Serpent", lettreFont: 's', saison: "Automne", darkness: 0.7 }, + { key: "epees", label: "Epées", lettreFont: 'e', saison: "Eté", darkness: 0 }, + { key: "lyre", label: "Lyre", lettreFont: 'l', saison: "Automne", darkness: 0.1 }, + { key: "serpent", label: "Serpent", lettreFont: 's', saison: "Automne", darkness: 0.9 }, { key: "poissonacrobate", label: "Poisson Acrobate", lettreFont: 'p', saison: "Automne", darkness: 1 }, { key: "araignee", label: "Araignée", lettreFont: 'a', saison: "Hiver", darkness: 1 }, { key: "roseau", label: "Roseau", lettreFont: 'r', saison: "Hiver", darkness: 1 }, @@ -98,10 +97,10 @@ export class RdDTimestamp { */ static definition(signe) { if (signe == undefined) { - signe = 0; + signe = 0 } if (Number.isInteger(signe)) { - return DEFINITION_HEURES[signe % RDD_HEURES_PAR_JOUR]; + return DEFINITION_HEURES[Misc.modulo(signe, RDD_HEURES_PAR_JOUR)] } let definition = DEFINITION_HEURES.find(it => it.key == signe); if (!definition) { @@ -119,10 +118,7 @@ export class RdDTimestamp { } static ajustementAstrologiqueHeure(hn, nbAstral, heure) { - let ecart = (hn + nbAstral - heure) % RDD_HEURES_PAR_JOUR; - if (ecart < 0) { - ecart = (ecart + RDD_HEURES_PAR_JOUR) % RDD_HEURES_PAR_JOUR; - } + let ecart = Misc.modulo(hn + nbAstral - heure, RDD_HEURES_PAR_JOUR); switch (ecart) { case 0: return 4; case 4: case 8: return 2; @@ -158,11 +154,13 @@ export class RdDTimestamp { } static defHeure(heure) { - return DEFINITION_HEURES.find(it => (it.heure) == heure % RDD_HEURES_PAR_JOUR); + heure = Misc.modulo(heure, RDD_HEURES_PAR_JOUR); + return DEFINITION_HEURES.find(it => it.heure == heure) } + static findHeure(heure) { heure = Grammar.toLowerCaseNoAccentNoSpace(heure); - let parHeureOuLabel = DEFINITION_HEURES.filter(it => (it.heure) == parseInt(heure) % RDD_HEURES_PAR_JOUR || Grammar.toLowerCaseNoAccentNoSpace(it.label) == heure); + let parHeureOuLabel = DEFINITION_HEURES.filter(it => Grammar.toLowerCaseNoAccentNoSpace(it.label) == heure || it.heure == Misc.modulo(parseInt(heure), RDD_HEURES_PAR_JOUR)); if (parHeureOuLabel.length == 1) { return parHeureOuLabel[0]; } @@ -232,19 +230,19 @@ export class RdDTimestamp { } get annee() { return Math.floor(this.indexDate / RDD_JOURS_PAR_AN) } - get mois() { return Math.floor((this.indexDate % RDD_JOURS_PAR_AN) / RDD_JOURS_PAR_MOIS) } - get jour() { return (this.indexDate % RDD_JOURS_PAR_AN) % RDD_JOURS_PAR_MOIS } + get mois() { return Math.floor(Misc.modulo(this.indexDate, RDD_JOURS_PAR_AN) / RDD_JOURS_PAR_MOIS) } + get jour() { return Misc.modulo(Misc.modulo(this.indexDate, RDD_JOURS_PAR_AN), RDD_JOURS_PAR_MOIS) } get heure() { return Math.floor(this.indexMinute / RDD_MINUTES_PAR_HEURES) } - get minute() { return this.indexMinute % RDD_MINUTES_PAR_HEURES } + get minute() { return Misc.modulo(this.indexMinute, RDD_MINUTES_PAR_HEURES) } get round() { return ROUNDS_PAR_MINUTE * (this.indexMinute - Math.floor(this.indexMinute)) } get angleHeure() { return this.indexMinute / RDD_MINUTES_PAR_JOUR * 360 - 45 } get angleMinute() { return this.indexMinute / RDD_MINUTES_PAR_HEURES * 360 + 45 } get darkness() { - const darknessDebut = RdDTimestamp.definition(this.heure).darkness *100 - const darknessFin = RdDTimestamp.definition(this.heure + 1).darkness *100 + const darknessDebut = 100 * RdDTimestamp.definition(this.heure).darkness + const darknessFin = 100 * RdDTimestamp.definition(this.heure + 1).darkness const darknessMinute = Math.round((darknessFin - darknessDebut) * this.minute / RDD_MINUTES_PAR_HEURES); - return (darknessDebut + darknessMinute)/100 + return (darknessDebut + darknessMinute) / 100 } /** @@ -297,7 +295,7 @@ export class RdDTimestamp { const heure = this.heure + heures; return new RdDTimestamp({ indexDate: this.indexDate + Math.floor(heure / RDD_HEURES_PAR_JOUR), - indexMinute: this.indexMinute + (heure % RDD_HEURES_PAR_JOUR) * RDD_MINUTES_PAR_HEURES + indexMinute: this.indexMinute + Misc.modulo(heure, RDD_HEURES_PAR_JOUR) * RDD_MINUTES_PAR_HEURES }) } @@ -347,7 +345,7 @@ export class RdDTimestamp { return { jours: jours, heures: Math.floor(minutes / RDD_MINUTES_PAR_HEURES), - minutes: minutes % RDD_MINUTES_PAR_HEURES + minutes: Misc.modulo(minutes, RDD_MINUTES_PAR_HEURES) } } } \ No newline at end of file diff --git a/system.json b/system.json index a10866f6..23820357 100644 --- a/system.json +++ b/system.json @@ -1,8 +1,8 @@ { "id": "foundryvtt-reve-de-dragon", "title": "Rêve de Dragon", - "version": "11.2.7", - "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-11.2.7.zip", + "version": "11.2.8", + "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-11.2.8.zip", "manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v11/system.json", "changelog": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/branch/v11/changelog.md", "compatibility": { diff --git a/templates/actor/competence.html b/templates/actor/competence.html index a90045f8..92cf7ec3 100644 --- a/templates/actor/competence.html +++ b/templates/actor/competence.html @@ -1,13 +1,13 @@ {{#unless system.isHidden}} -