Amélioration fenêtre de Tchat #42

This commit is contained in:
Vincent Vandemeulebrouck 2020-12-31 02:08:58 +01:00
parent 77ed4f1482
commit dbe37233d5
7 changed files with 142 additions and 44 deletions

View File

@ -1548,17 +1548,12 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
async _rollCaracResult(rollData) {
let rolled = rollData.rolled;
let resumeCompetence = (rollData.diffLibre + rollData.diffConditions);
let explications = "<br>Points de taches : " + rolled.ptTache;
rollData.show = {
title: rollData.selectedCarac.label,
points: true
};
// Final chat message
let chatOptions = {
content: "<strong>Test : " + rollData.selectedCarac.label + " / " + resumeCompetence + "</strong>"
+ RdDResolutionTable.explainRollData(rollData)
+ explications
}
let chatOptions = { content: await RdDResolutionTable.explainRollDataV2(rollData) }
ChatUtility.chatWithRollMode(chatOptions, this.name)
}

View File

@ -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 ? "<br>Difficulté " + parts.reduce((a, b) => a + ' / ' + b) : "";
return message+ RdDResolutionTable.explain(rollData.rolled)
}
static _buildAjustementsList(rollData) {
let parts = [];
if (rollData.diffLibre != undefined) {
parts.push(`<strong>libre: ${rollData.diffLibre}</strong>`);
@ -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 ? "<br>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) {

View File

@ -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';
}
}

View File

@ -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);

View File

@ -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;

View File

@ -31,7 +31,7 @@
<label class="ctn-fatigue tooltip">
Fatigue
<a id="fatigue-moins">-</a>
<span class="tooltiptext">{{{data.fatigue.html}}}</span>
<span class="tooltiptext tooltiptext-fatigue">{{{data.fatigue.html}}}</span>
<input class="resource-content" id="fatigue-value" type="text" name="data.sante.fatigue.value" value="{{data.sante.fatigue.value}}" data-dtype="Number" />
<span>/ {{data.sante.fatigue.max}}</span>
<a id="fatigue-plus">+</a>
@ -65,7 +65,7 @@
</div>
<div class="flexrow">
<span class="tooltip">Malus de fatigue : {{data.fatigue.malus}}
<span class="tooltiptext">{{{data.fatigue.html}}}</span>
<span class="tooltiptext tooltiptext-fatigue">{{{data.fatigue.html}}}</span>
</span>
<span>{{data.blessures.resume}}</span>
</div>

View File

@ -0,0 +1,30 @@
<h4>
{{#if show.title}}{{show.title}}: {{/if}}
<span class="tooltip">
{{rolled.caracValue}} à {{numberFormat rolled.finalLevel decimals=0 sign=true}}
{{#if ajustements}}
<div class="tooltiptext tooltiptext-ajustements">
<div>Ajustements</div>
{{#each ajustements as |item key|}}
<div class="{{#if item.strong}}strong-text{{/if}}" >{{item.label}}: {{numberFormat item.value decimals=0 sign=true}}{{#if item.unit}}{{item.unit}}{{/if}}</div>
{{/each}}
</div>
{{/if}}
</span>
{{#if rolled.needSignificative}}<label class="rdd-need-significative">(&times;&frac12;)</label>{{/if}} =
{{rolled.score}}%
</h4>
<div>
<span>{{rolled.roll}} : </span>
<span class="rdd-roll-{{rolled.code}} strong-text">{{rolled.quality}}</span>
</div>
{{#if show.points}}
<div>
<span>{{rolled.ptTache}} points de tâche{{#if rolled.ptQualite}}, ajustement Qualité {{numberFormat rolled.ptQualite decimals=0 sign=true}}{{/if}}</span>
</div>
{{/if}}
{{~#if show.explications}}
<div>
{{show.explications}}
</div>
{{/if}}