Correction de l'ajustement de luminosité
On passe de la nuit début vaisseau au jour fin vaisseau
This commit is contained in:
parent
5e140546ea
commit
62cc3fc96b
@ -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);
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user