diff --git a/module/actor.js b/module/actor.js index e93cbf52..5c3032fe 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1636,24 +1636,14 @@ export class RdDActor extends Actor { } /* -------------------------------------------- */ - _tacheResult(rollData) { + async _tacheResult(rollData) { // Mise à jour de la tache rollData.tache.data.points_de_tache_courant += rollData.rolled.ptTache; this.updateEmbeddedEntity( "OwnedItem", rollData.tache); this.santeIncDec( "fatigue", rollData.tache.data.fatigue); - // Message de résultat ChatUtility.chatWithRollMode({ - content: "Test de Tache : " + rollData.tache.name + " - " + rollData.selectedCarac.label + " / " + rollData.competence.name + "" - + RdDResolutionTable.explainRollData(rollData) - + "
Points de taches : " + rollData.rolled.ptTache + ", ajustement qualité: " + rollData.rolled.ptQualite - }, this.name); - // Message spécifique de la tâche - ChatUtility.chatWithRollMode({ - content: "Votre tâche " + rollData.tache.name + " a duré " + rollData.tache.data.periodicite + "." - + "
Votre avancement est désormais de " + rollData.tache.data.points_de_tache_courant + " Points de Tache sur un objectif de " - + rollData.tache.data.points_de_tache + "." - + "
Et vous vous êtes fatigué de " + rollData.tache.data.fatigue + " cases." + content: await RdDResolutionTable.explainRollDataV2(rollData, 'chat-resultat-tache.html') }, this.name); } @@ -1661,18 +1651,14 @@ export class RdDActor extends Actor { _tacheETotal(rollData) { rollData.tache.data.difficulte--; this.updateEmbeddedEntity( "OwnedItem", rollData.tache); - ChatUtility.chatWithRollMode( { - content: "Vous avez fait un Echec Total sur votre Tache " + rollData.tache.name + " : en conséquence, la difficulté a augmenté de 1" - }, this.name); } /* -------------------------------------------- */ - _competenceResult(rollData) { + async _competenceResult(rollData) { + rollData.show = {points:true}; ChatUtility.chatWithRollMode({ - content: "Test : " + rollData.selectedCarac.label + " / " + rollData.competence.name + "" - + RdDResolutionTable.explainRollData(rollData) - + "
Points de taches : " + rollData.rolled.ptTache + ", ajustement qualité: " + rollData.rolled.ptQualite - }, this.name); + content: await RdDResolutionTable.explainRollDataV2(rollData, 'chat-resultat-competence.html') + }, this.name); } /* -------------------------------------------- */ @@ -1706,6 +1692,10 @@ export class RdDActor extends Actor { await this.chanceActuelleIncDec(-1) } ChatMessage.create(message); + + ChatUtility.chatWithRollMode({ + content: await RdDResolutionTable.explainRollDataV2(rollData, 'chat-resultat-appelchance.html') + }, this.name); } /* -------------------------------------------- */ diff --git a/module/rdd-bonus.js b/module/rdd-bonus.js index 88c6d1b2..6276c514 100644 --- a/module/rdd-bonus.js +++ b/module/rdd-bonus.js @@ -13,7 +13,7 @@ const conditionsTactiques = [ export class RdDBonus { /* -------------------------------------------- */ - static _find(condition) { + static find(condition) { return conditionsTactiques.find(e => e.type == condition) || conditionsTactiques.find(e => e.type == 'pret'); } @@ -25,7 +25,7 @@ export class RdDBonus { ui.notifications.warn("Calcul de bonus dégats sur eswquive"); } else { dmg.dmgArme = RdDBonus._dmgArme(rollData); - dmg.ignoreArmure = 0; // TODO: calculer pour arcs et arbaletes, gérer pour lmes créatures + dmg.penetration = RdDBonus._peneration(rollData); dmg.dmgTactique = RdDBonus.dmgBonus(rollData.tactique); dmg.dmgParticuliere = RdDBonus._dmgParticuliere(rollData); dmg.dmgSurprise = RdDBonus.dmgBonus(rollData.surpriseDefenseur); @@ -38,17 +38,17 @@ export class RdDBonus { /* -------------------------------------------- */ static description(condition) { - return RdDBonus._find(condition).descr; + return RdDBonus.find(condition).descr; } /* -------------------------------------------- */ static dmgBonus(condition) { - return RdDBonus._find(condition).dmg; + return RdDBonus.find(condition).dmg; } /* -------------------------------------------- */ static bonusAttaque(condition) { - return RdDBonus._find(condition).attaque; + return RdDBonus.find(condition).attaque; } /* -------------------------------------------- */ @@ -68,6 +68,10 @@ export class RdDBonus { static _dmgArme(rollData) { return rollData.arme ? parseInt(rollData.arme.data.dommages) : 0; } + + static _peneration(rollData) { + return rollData.arme ? parseInt(rollData.arme.data.penetration) : 0; + } /* -------------------------------------------- */ static _dmgPerso(dmgActor, categorie, dmgArme) { diff --git a/module/rdd-combat.js b/module/rdd-combat.js index a22a350f..2442ea72 100644 --- a/module/rdd-combat.js +++ b/module/rdd-combat.js @@ -62,7 +62,7 @@ export class RdDCombat { content: message, whisper: ChatUtility.getWhisperRecipients("blindroll", recipient.name), }; - + // envoyer le message au destinataire if (!game.user.isGM || recipient.hasPlayerOwner) { let data = { @@ -73,7 +73,7 @@ export class RdDCombat { rollMode: true }; mergeObject(data, chatMessage); - game.socket.emit("system.foundryvtt-reve-de-dragon", { msg: topic, data: data}); + game.socket.emit("system.foundryvtt-reve-de-dragon", { msg: topic, data: data }); } else { chatMessage.whisper = [game.user]; } @@ -224,12 +224,16 @@ export class RdDCombat { /* -------------------------------------------- */ _onAttaqueParticuliere(rollData) { console.log("RdDCombat.onAttaqueParticuliere >>>", rollData); - let message = "Réussite particulière en attaque"; - message += "
Attaquer en Force"; // Finesse et Rapidité seulement en mêlée et si la difficulté libre est de -1 minimum + let message = ` +

Réussite particulière en attaque

+
Attaquer en Force + `; if (rollData.selectedCarac.label == "Mêlée" && rollData.diffLibre < 0) { - message += "
Attaquer en Rapidité"; - message += "
Attaquer en Finesse"; + message += ` +
Attaquer en Rapidité +
Attaquer en Finesse"; + ` } game.system.rdd.rollDataHandler[this.attackerId] = rollData; // TODO: use a dialog? @@ -240,34 +244,42 @@ export class RdDCombat { async _onAttaqueNormale(rollData) { console.log("RdDCombat.onAttaqueNormale >>>", rollData); let explications = ""; - + rollData.dmg = RdDBonus.dmg(rollData, this.attacker.getBonusDegat(), this.defender.isEntiteCauchemar()); - + if (this.target) { explications += "
Cible : " + this.defender.data.name; } explications += "
Encaissement à " + Misc.toSignedString(rollData.dmg.total) + " (" + rollData.dmg.loc.label + ")"; - + // Save rollData for defender game.system.rdd.rollDataHandler[this.attackerId] = duplicate(rollData); - + // Message spécial pour la rapidité, qui reste difficile à gérer automatiquement if (rollData.particuliereAttaque == 'rapidite') { explications += "
Vous avez attaqué en Rapidité. Vous pourrez faire une deuxième attaque, ou utiliser votre arme pour vous défendre."; } - + // Final chat message let chatOptions = { content: "Test : " + rollData.selectedCarac.label + " / " + rollData.competence.name + "" - + RdDResolutionTable.explainRollData(rollData) - + explications + + RdDResolutionTable.explainRollData(rollData) + + explications } ChatUtility.chatWithRollMode(chatOptions, this.attacker.name) - + + rollData.show = { + cible: this.target ? this.defender.data.name : 'la cible', + isRecul : (rollData.particuliereAttaque == 'force' || rollData.tactique == 'charge') + } + ChatUtility.chatWithRollMode( + { content: await RdDResolutionTable.explainRollDataV2(rollData, 'chat-resultat-attaque.html') }, + this.name) + if (!await this.accorderEntite('avant-defense')) { return; } - + if (this.target) { this._sendMessageDefense(rollData); } @@ -593,8 +605,8 @@ export class RdDCombat { await this.computeRecul(rollData, true); this._sendMessageEncaisser(rollData.attackerRoll); } - - + + /* -------------------------------------------- */ async computeDeteriorationArme(rollData) { const attackerRoll = rollData.attackerRoll; @@ -678,7 +690,7 @@ export class RdDCombat { } /* -------------------------------------------- */ - _sendMessageEncaisser(rollData){ + _sendMessageEncaisser(rollData) { let message = "" + this.defender.name + " doit:" + this._buildMessageEncaisser(rollData); RdDCombat._sendRollMessage(this.attacker, this.defender, this.defenderTokenId, "msg_encaisser", message, rollData); } diff --git a/module/rdd-resolution-table.js b/module/rdd-resolution-table.js index e9cd6f05..3183cec0 100644 --- a/module/rdd-resolution-table.js +++ b/module/rdd-resolution-table.js @@ -1,4 +1,5 @@ import { Misc } from "./misc.js"; +import { RdDBonus } from "./rdd-bonus.js"; import { RdDDice } from "./rdd-dice.js"; /** @@ -88,7 +89,7 @@ export class RdDResolutionTable { return message; } - static async explainRollDataV2(rollData, template = 'chat-resultat-rdd.html') { + static async explainRollDataV2(rollData, template = 'chat-resultat-general.html') { rollData.ajustements = RdDResolutionTable._buildAjustements(rollData); rollData.show = rollData.show || {}; @@ -101,21 +102,29 @@ export class RdDResolutionTable { if (rollData.competence) { list.push({ label: rollData.competence.name, value: rollData.competence.data.niveau}); } + if (rollData.tactique) { + const surprise = RdDBonus.find(rollData.tactique); + list.push({ label: surprise.descr, value: surprise.attaque }); + } + if (rollData.surpriseDefenseur) { + const surprise = RdDBonus.find(rollData.surpriseDefenseur); + list.push({ label: surprise.descr, value: surprise.attaque }); + } if (rollData.diffLibre != undefined) { - const label = rollData.selectedSort ? rollData.selectedSort.name : 'libre'; + 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 }); + list.push({ label: 'Conditions', value: rollData.diffConditions }); } if (rollData.etat != undefined) { - list.push({ label: 'état', value: rollData.etat }); + list.push({ label: 'Etat', 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 }); + 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 }); + list.push({ label: 'Astrologique', value: rollData.ajustementAstrologique||0 }); } if (rollData.rolled.bonus && rollData.selectedSort) { list.push({ label: 'Bonus de case', value: rollData.rolled.bonus, unit: '%' }); diff --git a/module/rdd-roll-resolution.js b/module/rdd-roll-resolution.js index ceb7073d..6a3b87cd 100644 --- a/module/rdd-roll-resolution.js +++ b/module/rdd-roll-resolution.js @@ -11,7 +11,7 @@ const titleTableDeResolution = 'Table de résolution'; export class RdDRollResolution extends Dialog { /* -------------------------------------------- */ - static async open(rollData = {selectedCarac:10}) { + static async open(rollData = {}) { RdDRollResolution._setDefaultOptions(rollData); let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-resolution.html', rollData); const dialog = new RdDRollResolution(rollData, html); @@ -21,8 +21,9 @@ export class RdDRollResolution extends Dialog { /* -------------------------------------------- */ static _setDefaultOptions(rollData) { + let defRollData = { - show: {title: titleTableDeResolution, points:true}, + show: { title: titleTableDeResolution, points: true }, ajustementsConditions: CONFIG.RDD.ajustementsConditions, difficultesLibres: CONFIG.RDD.difficultesLibres, etat: 0, @@ -30,15 +31,19 @@ export class RdDRollResolution extends Dialog { carac: {}, finalLevel: 0, diffConditions: 0, - diffLibre: 0 + diffLibre: 0, } - mergeObject(rollData, defRollData, {overwrite: false}); + mergeObject(rollData, defRollData, { overwrite: false }); for (let i = 1; i < 21; i++) { - rollData.carac[i] = { type: "number", value: i, label: i } - if (rollData.selectedCarac == i) { - rollData.selectedCarac = rollData.carac[i]; - } + const key = `${i}`; + rollData.carac[key] = { type: "number", value: i, label: key } } + let selected = (rollData.selectedCarac && rollData.selectedCarac.label) + ? rollData.selectedCarac.label + : (Number.isInteger(rollData.selectedCarac)) + ? rollData.selectedCarac + : 10; + rollData.selectedCarac = rollData.carac[selected]; } /* -------------------------------------------- */ @@ -59,7 +64,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: await RdDResolutionTable.explainRollDataV2(this.rollData)}; + const message = { content: await RdDResolutionTable.explainRollDataV2(this.rollData) }; ChatUtility.chatWithRollMode(message, game.user.name) } @@ -75,7 +80,7 @@ export class RdDRollResolution extends Dialog { function updateRollResult(rollData) { rollData.caracValue = parseInt(rollData.selectedCarac.value) rollData.finalLevel = dialog._computeFinalLevel(rollData); - + // Mise à jour valeurs $("#carac").val(rollData.caracValue); $("#roll-param").text(rollData.selectedCarac.value + " / " + Misc.toSignedString(rollData.finalLevel)); @@ -84,7 +89,7 @@ export class RdDRollResolution extends Dialog { $(".span-valeur").remove(); $("#resolutionValeurs").append(RdDResolutionTable.buildHTMLResults(rollData.caracValue, rollData.finalLevel)); } - + // Setup everything onload $(function () { $("#diffLibre").val(Misc.toInt(rollData.diffLibre)); diff --git a/styles/simple.css b/styles/simple.css index 2bf7790a..322baeab 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -203,6 +203,10 @@ table {border: 1px solid #7a7971;} -ms-flex-pack: justify; justify-content: space-between; } +.flex-shrink { + flex: 'flex-shrink' ; +} + /* Styles limited to foundryvtt-reve-de-dragon sheets */ .foundryvtt-reve-de-dragon .sheet-header { @@ -723,7 +727,7 @@ ul, li { margin: 0.25rem; } .control-icon.tokenhudicon.right { - margin-left: 8px; + margin-left: 8px; } .rdd-hud-menu { font-size: 0.75rem; @@ -1211,38 +1215,39 @@ display: inline-flex; /* Tooltip text */ .tooltip .tooltiptext { - visibility: hidden; text-align: center; - padding: 5px 0; - border-radius: 6px; /* Position the tooltip text */ + top: 20px; position: absolute; z-index: 1; /* Fade in tooltip */ + visibility: hidden; opacity: 0; transition: opacity 0.3s; } -.tooltiptext-fatigue{ +.tooltip .ttt-fatigue{ width: 360px; - top: 30px; - left: -30%; - background-color: rgba(30, 25, 20, 0.9); + background: 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; border-image-outset: 0px 0px 0px 0px; border-radius: 0px; + + font-size: 0.8rem; + padding: 3px 0; } -.tooltiptext-ajustements { +.tooltip .ttt-ajustements { width: 150px; - top: 30px; background: rgba(220,220,210,0.9); - font-size: 0.8rem; + border-radius: 6px; + font-size: 0.9rem; + padding: 3px 0; } /* Show the tooltip text when you mouse over the tooltip container */ diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 69803ff8..6a0f3f48 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -29,9 +29,9 @@