foundryvtt-reve-de-dragon/module/sommeil/theme-astral.js

58 lines
2.0 KiB
JavaScript
Raw Normal View History

import { Misc } from "../misc.js";
import { RdDCalendrier } from "../rdd-calendrier.js";
import { RdDTimestamp } from "../rdd-timestamp.js";
export class ThemeAstral extends Application {
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
template: "systems/foundryvtt-reve-de-dragon/templates/sommeil/theme-astral.hbs",
title: "Thème astral",
width: 'fit-content',
height: 'fit-content',
popOut: true,
resizable: false
});
}
static async create() {
new ThemeAstral().render(true);
}
constructor() {
super({});
}
activateListeners(html) {
super.activateListeners(html);
this.html = html;
this.html.find('select[name="signe-astral"]').change(event => {
this.onCalculThemeAstral();
})
this.html.find('select[name="signe-naissance"]').change(event => {
this.onCalculThemeAstral();
})
this.onCalculThemeAstral();
}
onCalculThemeAstral() {
const signeAstral = RdDTimestamp.definition(this.html.find('select[name="signe-astral"]').val())
const chiffreAstral = signeAstral.heure + 1;
const signeNaissance = RdDTimestamp.definition(this.html.find('select[name="signe-naissance"]').val())
const heureNaissance = signeNaissance.heure + 1;
const heureChance = (chiffreAstral + heureNaissance) % 12 + 1
RdDTimestamp.definitions().forEach(dh => {
const ajustement = RdDCalendrier.ajustementAstrologiqueHeure(heureNaissance, chiffreAstral, dh.heure + 1);
const txtAjustement = ajustement == 0 ? '' : Misc.toSignedString(ajustement);
this.html.find(`div.astro-ajustement.ajustement-${dh.hh}`).text(txtAjustement)
});
const angle = (heureChance * 30 + 330) % 360;
const rotation = `rotate(${angle}deg)`;
this.html.find(`div.astro-roue div.astro-disque img`).css({
'transform': rotation,
'-ms-transform': rotation,
'-moz-transform': rotation,
'-webkit-transform': rotation,
'-o-transform': rotation
});
}
}