diff --git a/module/rdd-astrologie-editeur.js b/module/rdd-astrologie-editeur.js index 275e9c2b..134046dc 100644 --- a/module/rdd-astrologie-editeur.js +++ b/module/rdd-astrologie-editeur.js @@ -1,3 +1,4 @@ +import { ThemeAstral } from "./sommeil/theme-astral.js"; /** * Extend the base Dialog entity by defining a custom window to perform roll. @@ -7,16 +8,17 @@ export class RdDAstrologieEditeur extends Dialog { /* -------------------------------------------- */ constructor(html, calendrier, calendrierData) { - - let myButtons = { - resetButton: { label: "Re-tirer les nombres astraux", callback: html => this.resetNombreAstraux() }, - saveButton: { label: "Fermer", callback: html => {} } + let dialogConf = { + title: "Editeur d'Astrologie", + content: html, + default: "fermer", + buttons: { + fermer: { label: "Fermer", callback: html => { } } + } }; - - // Common conf - let dialogConf = { content: html, title: "Editeur d'Astrologie", buttons: myButtons, default: "saveButton" }; let dialogOptions = { - classes: ["rdd-roll-dialog"], width: 600, + classes: ["rdd-roll-dialog"], + width: 600, height: 'fit-content', 'max-height': 800, 'z-index': 99999 @@ -30,6 +32,8 @@ export class RdDAstrologieEditeur extends Dialog { activateListeners(html) { super.activateListeners(html); this.html = html; + this.html.find('[name="theme-astral"]').click(event => ThemeAstral.create()); + this.html.find('[name="reset-nombres-astraux"]').click(event => this.resetNombreAstraux()); } @@ -39,6 +43,7 @@ export class RdDAstrologieEditeur extends Dialog { await game.system.rdd.calendrier.rebuildListeNombreAstral(); game.system.rdd.calendrier.showAstrologieEditor(); + this.close() } /* -------------------------------------------- */ diff --git a/module/rdd-astrologie-joueur.js b/module/rdd-astrologie-joueur.js index e288477e..04b48dc3 100644 --- a/module/rdd-astrologie-joueur.js +++ b/module/rdd-astrologie-joueur.js @@ -1,6 +1,7 @@ import { RdDItemCompetence } from "./item-competence.js"; import { Misc } from "./misc.js"; import { SYSTEM_SOCKET_ID } from "./constants.js"; +import { ThemeAstral } from "./sommeil/theme-astral.js"; /** @@ -49,9 +50,12 @@ export class RdDAstrologieJoueur extends Dialog { this.html.find("[name='diffConditions']").val(0); - this.html.find('[name="jet-astrologie"]').click((event) => { + this.html.find('[name="jet-astrologie"]').click(event => { this.requestJetAstrologie(); }); + this.html.find('[name="theme-astral"]').click(event => { + ThemeAstral.create(); + }); } /* -------------------------------------------- */ diff --git a/module/rdd-calendrier.js b/module/rdd-calendrier.js index 68488757..6a576340 100644 --- a/module/rdd-calendrier.js +++ b/module/rdd-calendrier.js @@ -257,6 +257,7 @@ export class RdDCalendrier extends Application { } this.listeNombreAstral = newList; game.settings.set(SYSTEM_RDD, "liste-nombre-astral", newList); + game.actors.forEach(actor => actor.deleteEmbeddedDocuments("Item", actor.listItems('nombreastral').map(it => it.id))); } } @@ -301,7 +302,7 @@ export class RdDCalendrier extends Application { async positionnerHeure(heure) { const indexDate = this.timestamp.indexDate; const addDay = this.timestamp.heure < heure ? 0 : 1; - const newTimestamp = new RdDTimestamp({ indexDate: indexDate + addDay}).addHeures(heure); + const newTimestamp = new RdDTimestamp({ indexDate: indexDate + addDay }).addHeures(heure); await this.setNewTimestamp(newTimestamp) } @@ -370,10 +371,6 @@ export class RdDCalendrier extends Application { game.settings.set(SYSTEM_RDD, "liste-nombre-astral", this.listeNombreAstral); } - static ecartHeureChance(heureNaissance, nombreAstral, heure) { - return (heureNaissance + nombreAstral - heure) % RDD_HEURES_PAR_JOUR; - } - /* -------------------------------------------- */ getAjustementAstrologique(heureNaissance, name = undefined) { let defHeure = RdDTimestamp.findHeure(heureNaissance); @@ -399,6 +396,10 @@ export class RdDCalendrier extends Application { return 0; } + static ecartHeureChance(heureNaissance, nombreAstral, heure) { + return ((heureNaissance + nombreAstral - heure) % RDD_HEURES_PAR_JOUR + RDD_HEURES_PAR_JOUR) % RDD_HEURES_PAR_JOUR; + } + /* -------------------------------------------- */ getData() { let formData = super.getData(); diff --git a/module/rdd-main.js b/module/rdd-main.js index f475b64d..a6a1d188 100644 --- a/module/rdd-main.js +++ b/module/rdd-main.js @@ -55,6 +55,7 @@ import { RdDFauneItemSheet } from "./item/sheet-faune.js"; import { RdDConteneurItemSheet } from "./item/sheet-conteneur.js"; import { RdDSigneDraconiqueItemSheet } from "./item/sheet-signedraconique.js"; import { RdDItemInventaireSheet } from "./item/sheet-base-inventaire.js"; +import { ThemeAstral } from "./sommeil/theme-astral.js"; /** * RdD system @@ -96,6 +97,8 @@ export class SystemReveDeDragon { /* -------------------------------------------- */ async onInit() { game.system.rdd = this; + this.ThemeAstral = ThemeAstral; + console.log(`Initializing Reve de Dragon System`); diff --git a/module/rdd-resolution-table.js b/module/rdd-resolution-table.js index fd2e482a..b5467845 100644 --- a/module/rdd-resolution-table.js +++ b/module/rdd-resolution-table.js @@ -195,17 +195,6 @@ export class RdDResolutionTable { return Math.max(Math.floor(carac * (diff + 10) / 2), 1); } - /* -------------------------------------------- */ - static isAjustementAstrologique(rollData) { - if (rollData.selectedCarac?.label.toLowerCase().includes('chance')) { - return true; - } - if (rollData.selectedSort?.system.isrituel) { - return true; - } - return false; - } - /* -------------------------------------------- */ static isEchec(rollData) { switch (rollData.surprise) { diff --git a/module/rdd-timestamp.js b/module/rdd-timestamp.js index 5dbce01d..6ad453b7 100644 --- a/module/rdd-timestamp.js +++ b/module/rdd-timestamp.js @@ -48,8 +48,12 @@ const FORMULES_PERIODE = [ export class RdDTimestamp { + static hh(heure) { + return heure < 9 ? `0${heure + 1}` : `${heure + 1}`; + } + static iconeHeure(heure) { - return `systems/foundryvtt-reve-de-dragon/icons/heures/hd${heure < 9 ? '0' : ''}${heure + 1}.svg`; + return `systems/foundryvtt-reve-de-dragon/icons/heures/hd${RdDTimestamp.hh(heure)}.svg`; } static init() { @@ -63,6 +67,7 @@ export class RdDTimestamp { for (let i = 0; i < DEFINITION_HEURES.length; i++) { DEFINITION_HEURES[i].heure = i; + DEFINITION_HEURES[i].hh = RdDTimestamp.hh(i); DEFINITION_HEURES[i].icon = RdDTimestamp.iconeHeure(i); DEFINITION_HEURES[i].webp = DEFINITION_HEURES[i].icon.replace(".svg", ".webp"); } @@ -86,6 +91,9 @@ export class RdDTimestamp { return definition } + static definitions() { + return DEFINITION_HEURES + } static formulesDuree() { return FORMULES_DUREE } diff --git a/module/sommeil/theme-astral.js b/module/sommeil/theme-astral.js new file mode 100644 index 00000000..5c91833a --- /dev/null +++ b/module/sommeil/theme-astral.js @@ -0,0 +1,58 @@ +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 + }); + } +} \ No newline at end of file diff --git a/packs/macros.db b/packs/macros.db index 1256c709..65de8aaf 100644 --- a/packs/macros.db +++ b/packs/macros.db @@ -8,5 +8,6 @@ {"name":"Encaissement","type":"script","scope":"global","author":"Hp9ImM4o9YRTSdfu","img":"icons/svg/bones.svg","command":"const selected = game.system.rdd.RdDUtility.getSelectedActor();\nif (selected) {\n selected.encaisser();\n}\nelse {\n ui.notifications.info('Pas de personnage sélectionné');\n}","ownership":{"default":0,"Hp9ImM4o9YRTSdfu":3},"flags":{"core":{"sourceId":"Macro.XHNbjnGKXaCiCadq"}},"_stats":{"systemId":"foundryvtt-reve-de-dragon","systemVersion":"10.3.15","coreVersion":"10.291","createdTime":1671220038331,"modifiedTime":1671234017623,"lastModifiedBy":"Hp9ImM4o9YRTSdfu"},"folder":null,"sort":0,"_id":"WD6T8AdRbX2Ylxqe"} {"name":"Jet quelconque","type":"script","scope":"global","author":"Hp9ImM4o9YRTSdfu","img":"icons/sundries/gaming/dice-runed-tan.webp","command":"const selected = game.system.rdd.RdDUtility.getSelectedActor();\nif (selected) {\n selected.roll();\n}\nelse {\n ui.notifications.info('Pas de personnage sélectionné');\n}","ownership":{"default":0,"Hp9ImM4o9YRTSdfu":3},"flags":{"core":{"sourceId":"Macro.XHNbjnGKXaCiCadq"}},"_stats":{"systemId":"foundryvtt-reve-de-dragon","systemVersion":"10.3.15","coreVersion":"10.291","createdTime":1671220038331,"modifiedTime":1671233500655,"lastModifiedBy":"Hp9ImM4o9YRTSdfu"},"folder":null,"sort":0,"_id":"bnJnbKDHpbqY8Pr9"} {"name":"Recherche et tirage","type":"script","scope":"global","author":"Hp9ImM4o9YRTSdfu","img":"icons/tools/scribal/magnifying-glass.webp","command":"game.system.rdd.commands.tirage()","ownership":{"default":0,"Hp9ImM4o9YRTSdfu":3},"flags":{"core":{"sourceId":"Macro.ZFWPNdQBjQs9z0YW"}},"_stats":{"systemId":"foundryvtt-reve-de-dragon","systemVersion":"10.5.4","coreVersion":"10.291","createdTime":1673472449426,"modifiedTime":1673655461651,"lastModifiedBy":"Hp9ImM4o9YRTSdfu"},"folder":null,"sort":0,"_id":"iVZnxOxhCMpkvYh3"} +{"name":"Thème astral","type":"script","scope":"global","author":"Hp9ImM4o9YRTSdfu","img":"icons/magic/nature/symbol-moon-stars-white.webp","command":"game.system.rdd.ThemeAstral.create();","ownership":{"default":0,"Hp9ImM4o9YRTSdfu":3},"flags":{"core":{"sourceId":"Macro.oA0HPFeFK6YMspAX"}},"_stats":{"systemId":"foundryvtt-reve-de-dragon","systemVersion":"10.6.19","coreVersion":"10.291","createdTime":1678127868791,"modifiedTime":1678150559112,"lastModifiedBy":"Hp9ImM4o9YRTSdfu"},"folder":null,"sort":0,"_id":"koqhiDJSGP4gQ4vf"} {"name":"Jet d'éthylisme","type":"script","scope":"global","author":"Hp9ImM4o9YRTSdfu","img":"icons/consumables/drinks/alcohol-beer-stein-wooden-metal-brown.webp","command":"const selected = game.system.rdd.RdDUtility.getSelectedActor();\nif (selected) {\n selected.jetEthylisme();\n}\nelse {\n ui.notifications.info('Pas de personnage sélectionné');\n}","ownership":{"default":0,"Hp9ImM4o9YRTSdfu":3},"flags":{"core":{"sourceId":"Macro.XHNbjnGKXaCiCadq"}},"_stats":{"systemId":"foundryvtt-reve-de-dragon","systemVersion":"10.3.15","coreVersion":"10.291","createdTime":1671220038331,"modifiedTime":1671233646086,"lastModifiedBy":"Hp9ImM4o9YRTSdfu"},"folder":null,"sort":0,"_id":"mvub1dRHNFmWjRr7"} {"name":"Tirer le tarot","type":"chat","scope":"global","author":"Hp9ImM4o9YRTSdfu","img":"systems/foundryvtt-reve-de-dragon/icons/tarots/dos-tarot.webp","command":"/tirer tarot","ownership":{"default":0,"Hp9ImM4o9YRTSdfu":3},"flags":{"core":{"sourceId":"Macro.HBZSKR9OHCQbLcTC"}},"_stats":{"systemId":"foundryvtt-reve-de-dragon","systemVersion":"10.3.15","coreVersion":"10.291","createdTime":1669469547231,"modifiedTime":1671237401618,"lastModifiedBy":"Hp9ImM4o9YRTSdfu"},"folder":null,"sort":0,"_id":"vTfJTFYYiRu8X5LM"} diff --git a/styles/img/ui/astro-disque.svg b/styles/img/ui/astro-disque.svg new file mode 100644 index 00000000..fccbf45b --- /dev/null +++ b/styles/img/ui/astro-disque.svg @@ -0,0 +1,22 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/styles/simple.css b/styles/simple.css index 9b8eb556..1402e1fd 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -77,6 +77,16 @@ --gradient-violet: linear-gradient(150deg, rgba(100, 45, 124, 0.6), rgba(216, 157, 192, 0.3), rgba(177, 157, 216, 0.5), rgba(107, 62, 121, 0.3), rgba(100, 45, 124, 0.6)); --gradient-purple-black: linear-gradient(150deg, rgba(0, 0, 0, 0.7), rgba(100, 45, 124, 0.4), rgba(82, 17, 131, 0.3),rgba(100, 45, 124, 0.4), rgba(0, 0, 0, 0.7)); --gradient-silver-light: linear-gradient(30deg, rgba(61, 55, 93, 0.2), rgba(178, 179, 196, 0.1), rgba(59, 62, 63, 0.2), rgba(206, 204, 199, 0.1), rgba(61, 46, 49, 0.2)); + --gradient-daylight: conic-gradient( + from 315deg, + hsla(50, 20%, 30%, 0.1) , + hsla(50, 30%, 60%, 0.7) 25%, + hsla(50, 20%, 30%, 0.1) 50%, + hsla(250, 20%, 30%, 0.1) 50%, + hsla(250, 30%, 60%, 0.7) 75%, + hsla(250, 20%, 30%, 0.1) + ); + --gradient-daylight2: radial-gradient(210deg, hsla(50, 30%, 60%, 0.6), hsla(50, 20%, 30%, 0.1) 50%, hsla(250, 20%, 30%, 0.1) 50%, hsla(250, 30%, 60%, 0.6)); --background-custom-button: linear-gradient(to bottom, rgba(33, 55, 74, 0.988) 5%, rgba(21, 40, 51, 0.671) 100%); --background-custom-button-hover: linear-gradient(to bottom, rgb(128, 0, 0) 5%, rgb(62, 1, 1) 100%); @@ -860,12 +870,88 @@ form.rdddialogchrono input[type=datetime-local] { color: var(--color-text-dark-primary); border-radius: 3px; } +form.dialog-astro { + width: 17rem; +} +form.dialog-astro div.astro-roue { + position: relative; + left: 2rem; + width: 13rem; + height: 13rem; +} +div.astro-roue div.astro-heure { + position: absolute; + width: 2rem; + height: 2rem; +} + +div.astro-roue div.astro-cercle1 { + position: absolute; + background: var(--gradient-daylight); + border: 0.2rem solid rgba(100, 45, 124, 0.6); + border-radius: calc(6.1rem); + top: calc(50% - 6.1rem); + left: calc(50% - 6.1rem); + width: calc(100% - 0.8rem); + height: calc(100% - 0.8rem); +} +div.astro-roue div.astro-disque { + position: absolute; + border: none; + top: calc(50% - 4rem); + left: calc(50% - 4rem); + width: calc(100% - 5rem); + height: calc(100% - 5rem); +} +div.astro-roue div.astro-disque img { border: none; } +div.astro-roue div.astro-heure img.astro-heure-img { + width: 2rem; + height: 2rem; + flex-grow: 0; + padding: 0.1rem; + border: 0; + opacity: 0.9; + border: none; +} +div.astro-roue div.astro-heure.heure-12 { top: calc(50% - 1rem - 1.3rem); left: calc(50% - 1rem - 4.8rem); } +div.astro-roue div.astro-heure.heure-01 { top: calc(50% - 1rem - 3.5rem); left: calc(50% - 1rem - 3.5rem); } +div.astro-roue div.astro-heure.heure-02 { top: calc(50% - 1rem - 4.8rem); left: calc(50% - 1rem - 1.3rem); } +div.astro-roue div.astro-heure.heure-03 { top: calc(50% - 1rem - 4.8rem); left: calc(50% - 1rem + 1.3rem); } +div.astro-roue div.astro-heure.heure-04 { top: calc(50% - 1rem - 3.5rem); left: calc(50% - 1rem + 3.5rem); } +div.astro-roue div.astro-heure.heure-05 { top: calc(50% - 1rem - 1.3rem); left: calc(50% - 1rem + 4.8rem); } +div.astro-roue div.astro-heure.heure-06 { top: calc(50% - 1rem + 1.3rem); left: calc(50% - 1rem + 4.8rem); } +div.astro-roue div.astro-heure.heure-07 { top: calc(50% - 1rem + 3.5rem); left: calc(50% - 1rem + 3.5rem); } +div.astro-roue div.astro-heure.heure-08 { top: calc(50% - 1rem + 4.8rem); left: calc(50% - 1rem + 1.3rem); } +div.astro-roue div.astro-heure.heure-09 { top: calc(50% - 1rem + 4.8rem); left: calc(50% - 1rem - 1.3rem); } +div.astro-roue div.astro-heure.heure-10 { top: calc(50% - 1rem + 3.5rem); left: calc(50% - 1rem - 3.5rem); } +div.astro-roue div.astro-heure.heure-11 { top: calc(50% - 1rem + 1.3rem); left: calc(50% - 1rem - 4.8rem); } + +div.astro-roue div.astro-ajustement { + position: absolute; + width: 1rem; + height: 1rem; +} + +div.astro-roue div.astro-ajustement.ajustement-12 { top: calc(50% - 0.5rem - 0.8rem); left: calc(50% - 0.5rem - 2.9rem); } +div.astro-roue div.astro-ajustement.ajustement-01 { top: calc(50% - 0.5rem - 2.1rem); left: calc(50% - 0.5rem - 2.1rem); } +div.astro-roue div.astro-ajustement.ajustement-02 { top: calc(50% - 0.5rem - 2.9rem); left: calc(50% - 0.5rem - 0.8rem); } +div.astro-roue div.astro-ajustement.ajustement-03 { top: calc(50% - 0.5rem - 2.9rem); left: calc(50% - 0.5rem + 0.8rem); } +div.astro-roue div.astro-ajustement.ajustement-04 { top: calc(50% - 0.5rem - 2.1rem); left: calc(50% - 0.5rem + 2.1rem); } +div.astro-roue div.astro-ajustement.ajustement-05 { top: calc(50% - 0.5rem - 0.8rem); left: calc(50% - 0.5rem + 2.9rem); } +div.astro-roue div.astro-ajustement.ajustement-06 { top: calc(50% - 0.5rem + 0.8rem); left: calc(50% - 0.5rem + 2.9rem); } +div.astro-roue div.astro-ajustement.ajustement-07 { top: calc(50% - 0.5rem + 2.1rem); left: calc(50% - 0.5rem + 2.1rem); } +div.astro-roue div.astro-ajustement.ajustement-08 { top: calc(50% - 0.5rem + 2.9rem); left: calc(50% - 0.5rem + 0.8rem); } +div.astro-roue div.astro-ajustement.ajustement-09 { top: calc(50% - 0.5rem + 2.9rem); left: calc(50% - 0.5rem - 0.8rem); } +div.astro-roue div.astro-ajustement.ajustement-10 { top: calc(50% - 0.5rem + 2.1rem); left: calc(50% - 0.5rem - 2.1rem); } +div.astro-roue div.astro-ajustement.ajustement-11 { top: calc(50% - 0.5rem + 0.8rem); left: calc(50% - 0.5rem - 2.9rem); } .window-app .window-content, .window-app.sheet .window-content .sheet-body{ background: rgb(245,245,240) url(img/bg_left.webp) no-repeat left top; } -section.sheet-body{padding: 0.25rem 0.5rem;} +section.sheet-body { + padding: 0.25rem 0.5rem; +} .sheet header.sheet-header :is(.profile-img, .profile-img-token) { object-fit: scale-down; diff --git a/templates/calendar-astrologie-template.html b/templates/calendar-astrologie-template.html index c1872c98..84bf7ae8 100644 --- a/templates/calendar-astrologie-template.html +++ b/templates/calendar-astrologie-template.html @@ -1,7 +1,11 @@
-

Horoscope

+

Horoscope

+
+
{{!-- Sheet Body --}} @@ -43,7 +47,7 @@ - {{actor.name}} + {{actor.name}} {{timestamp-imgSigneHeure actor.system.heure}} {{#each ajustementActeur.ajustements as |ajustement|}} {{#if (ne ajustement.ajustement 0)}} diff --git a/templates/dialog-astrologie-joueur.html b/templates/dialog-astrologie-joueur.html index ce433115..5b77d137 100644 --- a/templates/dialog-astrologie-joueur.html +++ b/templates/dialog-astrologie-joueur.html @@ -5,27 +5,36 @@ - - - - - - - + {{!-- Sheet Body --}}
+
+ + + + + +
+ +
diff --git a/templates/sommeil/theme-astral.hbs b/templates/sommeil/theme-astral.hbs new file mode 100644 index 00000000..655cf161 --- /dev/null +++ b/templates/sommeil/theme-astral.hbs @@ -0,0 +1,52 @@ + +
+ + +
+
+ + +
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
-2
+
+2
+
+
-4
+
+
+2
+
-2
+
+
+
+4
+ +
+ \ No newline at end of file