diff --git a/module/actor.js b/module/actor.js index 93483030..f6882e78 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1548,17 +1548,12 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async _rollCaracResult(rollData) { - let rolled = rollData.rolled; - - let resumeCompetence = (rollData.diffLibre + rollData.diffConditions); - let explications = "
Points de taches : " + rolled.ptTache; - + rollData.show = { + title: rollData.selectedCarac.label, + points: true + }; // Final chat message - let chatOptions = { - content: "Test : " + rollData.selectedCarac.label + " / " + resumeCompetence + "" - + RdDResolutionTable.explainRollData(rollData) - + explications - } + let chatOptions = { content: await RdDResolutionTable.explainRollDataV2(rollData) } ChatUtility.chatWithRollMode(chatOptions, this.name) } diff --git a/module/rdd-resolution-table.js b/module/rdd-resolution-table.js index 4fea285e..09eb8338 100644 --- a/module/rdd-resolution-table.js +++ b/module/rdd-resolution-table.js @@ -88,7 +88,47 @@ export class RdDResolutionTable { return message; } + static async explainRollDataV2(rollData, template = 'chat-resultat-rdd.html') { + rollData.ajustements = RdDResolutionTable._buildAjustements(rollData); + rollData.show = rollData.show || {}; + + let html = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/${template}`, rollData); + return html; + } + + static _buildAjustements(rollData) { + let list = []; + if (rollData.competence) { + list.push({ label: rollData.competence.name, value: rollData.competence.data.niveau}); + } + if (rollData.diffLibre != undefined) { + const label = rollData.selectedSort ? rollData.selectedSort.name : 'libre'; + list.push({ label: label, value: rollData.diffLibre }); + } + if (rollData.diffConditions != undefined) { + list.push({ label: 'conditions', value: rollData.diffConditions }); + } + if (rollData.etat != undefined) { + list.push({ label: 'état', value: rollData.etat }); + } + if (rollData.selectedCarac != undefined && rollData.moral != undefined && rollData.selectedCarac.label == 'Volonté') { + list.push({ label: 'moral', value: rollData.selectedCarac != undefined && rollData.moral != undefined && rollData.selectedCarac.label == 'Volonté' ? rollData.moral : undefined }); + } + if (RdDResolutionTable.isAjustementAstrologique(rollData)) { + list.push({ label: 'astrologique', value: rollData.ajustementAstrologique||0 }); + } + return list; + } + static explainRollData(rollData) { + let parts = RdDResolutionTable._buildAjustementsList(rollData); + let message = parts.length > 0 ? "
Difficulté " + parts.reduce((a, b) => a + ' / ' + b) : ""; + + return message+ RdDResolutionTable.explain(rollData.rolled) + } + + + static _buildAjustementsList(rollData) { let parts = []; if (rollData.diffLibre != undefined) { parts.push(`libre: ${rollData.diffLibre}`); @@ -102,9 +142,7 @@ export class RdDResolutionTable { if (rollData.selectedCarac != undefined && rollData.moral != undefined && rollData.selectedCarac.label == 'Volonté') { parts.push(`moral: ${rollData.moral}`); } - let message = parts.length > 0 ? "
Difficulté " + parts.reduce((a, b) => a + ' / ' + b) : ""; - - return message+ RdDResolutionTable.explain(rollData.rolled) + return parts; } /* -------------------------------------------- */ @@ -165,6 +203,16 @@ export class RdDResolutionTable { return duplicate(this.resolutionTable[caracValue][difficulte + 10]); } + static isAjustementAstrologique(rollData) { + if (rollData.selectedCarac.label.toLowerCase().includes('chance')) { + return true; + } + if (rollData.selectedSort && rollData.selectedSort.data.isrituel) { + return true; + } + return false; + } + /* -------------------------------------------- */ static isEchec(rollData) { switch (rollData.surprise) { diff --git a/module/rdd-roll-resolution.js b/module/rdd-roll-resolution.js index 3f22ef46..ceb7073d 100644 --- a/module/rdd-roll-resolution.js +++ b/module/rdd-roll-resolution.js @@ -2,6 +2,7 @@ import { ChatUtility } from "./chat-utility.js"; import { Misc } from "./misc.js"; import { RdDResolutionTable } from "./rdd-resolution-table.js"; +const titleTableDeResolution = 'Table de résolution'; /** * Extend the base Dialog entity to select roll parameters * @extends {Dialog} @@ -21,6 +22,7 @@ export class RdDRollResolution extends Dialog { static _setDefaultOptions(rollData) { let defRollData = { + show: {title: titleTableDeResolution, points:true}, ajustementsConditions: CONFIG.RDD.ajustementsConditions, difficultesLibres: CONFIG.RDD.difficultesLibres, etat: 0, @@ -36,15 +38,13 @@ export class RdDRollResolution extends Dialog { if (rollData.selectedCarac == i) { rollData.selectedCarac = rollData.carac[i]; } - } } /* -------------------------------------------- */ constructor(rollData, html) { - let conf = { - title: 'Lancer les dés', + title: titleTableDeResolution, content: html, buttons: { 'lancer': { label: 'Lancer les dés', callback: html => this.onAction(html) } @@ -59,9 +59,7 @@ export class RdDRollResolution extends Dialog { async onAction(html) { await RdDResolutionTable.rollData(this.rollData); console.log("RdDRollResolution -=>", this.rollData, this.rollData.rolled); - const message = { - content: "Table de résolution: " + RdDResolutionTable.explainRollData(this.rollData) - }; + const message = { content: await RdDResolutionTable.explainRollDataV2(this.rollData)}; ChatUtility.chatWithRollMode(message, game.user.name) } @@ -121,9 +119,4 @@ export class RdDRollResolution extends Dialog { _computeDiffLibre(rollData) { return Misc.toInt(rollData.diffLibre); } - - /* -------------------------------------------- */ - _getTitle(rollData) { - return 'Table de résolution'; - } } diff --git a/module/rdd-roll.js b/module/rdd-roll.js index 1d24f6b9..a35cb5a9 100644 --- a/module/rdd-roll.js +++ b/module/rdd-roll.js @@ -121,7 +121,7 @@ export class RdDRoll extends Dialog { HtmlUtility._showControlWhen($(".diffMoral"), rollData.selectedCarac == actor.data.data.carac.volonte); HtmlUtility._showControlWhen($("#etat-general"), !dialog._isIgnoreEtatGeneral(rollData)); - HtmlUtility._showControlWhen($("#ajust-astrologique"), dialog._isAjustementAstrologique(rollData)); + HtmlUtility._showControlWhen($("#ajust-astrologique"), RdDResolutionTable.isAjustementAstrologique(rollData)); // Sort management if (rollData.selectedSort) { @@ -229,7 +229,7 @@ export class RdDRoll extends Dialog { const malusEnc = (rollData.surencMalusApply) ? rollData.surencMalusValue : 0; const bonusTactique = RdDBonus.bonusAttaque(rollData.tactique); const malusEncTotal = (rollData.useMalusEncTotal) ? -rollData.encTotal : 0; - const ajustementChance = this._isAjustementAstrologique(rollData) ? rollData.ajustementAstrologique : 0; + const ajustementChance = RdDResolutionTable.isAjustementAstrologique(rollData) ? rollData.ajustementAstrologique : 0; // Gestion malus armure const malusArmureValue = this._computeMalusArmure(rollData); @@ -240,16 +240,6 @@ export class RdDRoll extends Dialog { return etat + diffCompetence + diffLibre + diffMoral + diffConditions + malusEnc + malusEncTotal + malusArmureValue + ajustementChance + bonusTactique; } - _isAjustementAstrologique(rollData) { - if (rollData.selectedCarac.label.toLowerCase().includes('chance')) { - return true; - } - if (rollData.selectedSort && rollData.selectedSort.data.isrituel) { - return true; - } - return false; - } - _computeDiffCompetence(rollData) { if (rollData.competence) { return Misc.toInt(rollData.competence.data.niveau); diff --git a/styles/simple.css b/styles/simple.css index 71bfe4f6..e190cb0d 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -86,6 +86,9 @@ margin: 0; padding: 0; } +.strong-text{ + font-weight: bold; +} .tabs .item.active, .blessures-list li ul li:first-child:hover, a:hover { text-shadow: 1px 0px 0px #ff6600; @@ -364,6 +367,35 @@ table {border: 1px solid #7a7971;} z-index: 9999; display: block; } +.rdd-roll-part{ + align-items: center; + border-radius: 6px; padding: 3px; + background:linear-gradient(30deg, rgba(191, 149, 63, 0.3), rgba(252, 246, 186, 0.3), rgba(179, 135, 40, 0.3), rgba(251, 245, 183, 0.3), rgba(170, 119, 28, 0.3)); +} +.rdd-roll-sign{ + border-radius: 6px; padding: 3px; + background:linear-gradient(30deg, rgba(61, 55, 93, 0.3), rgba(178, 179, 196, 0.3), rgba(59, 62, 63, 0.6), rgba(206, 204, 199, 0.3), rgba(61, 46, 49, 0.3)); +} +.rdd-roll-norm{ + border-radius: 6px; padding: 3px; + background:linear-gradient(30deg, rgba(7, 76, 0, 0.3), rgba(66, 163, 65, 0.2), rgba(184, 226, 163, 0.1), rgba(66, 163, 65, 0.2), rgba(184, 226, 163, 0.3)); +} +.rdd-roll-echec{ + border-radius: 6px; padding: 3px; + background-image: linear-gradient(150deg, rgba(255, 0, 0, 0.3), rgba(255, 200, 128, 0.05),rgba(255, 200, 128, 0.1), rgba(255,10,0,0.3)); +} +.rdd-roll-epart{ + border-radius: 6px; padding: 3px; + background: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)); +} +.rdd-roll-etotal{ + border-radius: 6px; padding: 3px; + background: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)); +} +.rdd-need-significative{ + border-radius: 6px; padding: 3px; + background: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)); +} .table-resolution-carac { background-color: yellow; @@ -1180,22 +1212,25 @@ display: inline-flex; /* Tooltip text */ .tooltip .tooltiptext { visibility: hidden; - width: 360px; - background-color: rgba(30, 25, 20, 0.9); text-align: center; padding: 5px 0; border-radius: 6px; - + /* Position the tooltip text */ position: absolute; z-index: 1; - top: 30px; - left: -30%; - + /* Fade in tooltip */ opacity: 0; transition: opacity 0.3s; +} +.tooltiptext-fatigue{ + width: 360px; + top: 30px; + left: -30%; + + background-color: rgba(30, 25, 20, 0.9); border-image: url(img/ui/bg_control.jpg) 21 repeat; border-image-slice: 6 6 6 6 fill; border-image-width: 6px 6px 6px 6px; @@ -1203,6 +1238,13 @@ display: inline-flex; border-radius: 0px; } +.tooltiptext-ajustements { + width: 150px; + top: 30px; + background: rgba(220,220,210,0.9); + font-size: 0.8rem; +} + /* Show the tooltip text when you mouse over the tooltip container */ .tooltip:hover .tooltiptext { visibility: visible; diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index e7805231..5efded6b 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -31,7 +31,7 @@