diff --git a/changelog.md b/changelog.md index e7fab3ab..3ba2eade 100644 --- a/changelog.md +++ b/changelog.md @@ -4,6 +4,7 @@ - Fix d'erreur au chargement de templates RollDialog - Nouvelle fenêtre de jets de dés - Fix: affichage des points de tâche + - Fix: affichage des ajustements cohérent - L'ouverture depuis les caractéristiques permet plusieurs types de jets - attaque/défense - les maladresses sont affichées dans le résultat du jet diff --git a/module/rdd-bonus.js b/module/rdd-bonus.js index f808768e..ff755333 100644 --- a/module/rdd-bonus.js +++ b/module/rdd-bonus.js @@ -47,7 +47,7 @@ export class RdDBonus { penetration: RdDBonus._peneration(rollData), dmgTactique: RdDBonus.dmgBonus(rollData.tactique), dmgParticuliere: RdDBonus._dmgParticuliere(rollData), - dmgSurprise: RdDBonus.dmgBonus(rollData.ajustements?.attaqueDefenseurSurpris.used), + dmgSurprise: RdDBonus.dmgBonus(rollData.ajustements?.attaqueDefenseurSurpris?.used), mortalite: RdDBonus._calculMortalite(rollData, isEntiteIncarnee), dmgActor: RdDBonus.bonusDmg(actor, rollData.selectedCarac?.label.toLowerCase(), dmgArme), dmgForceInsuffisante: Math.min(0, actor.getForce() - forceRequise) diff --git a/module/roll/chat-roll-result.mjs b/module/roll/chat-roll-result.mjs index 9f480fc6..d64212bd 100644 --- a/module/roll/chat-roll-result.mjs +++ b/module/roll/chat-roll-result.mjs @@ -22,6 +22,7 @@ export default class ChatRollResult { static onReady() { foundry.applications.handlebars.loadTemplates({ + 'partial-infojet': 'systems/foundryvtt-reve-de-dragon/templates/roll/result/partial-infojet.hbs', 'partial-appel-chance': 'systems/foundryvtt-reve-de-dragon/templates/roll/result/partial-appel-chance.hbs', 'partial-attaque-particuliere': 'systems/foundryvtt-reve-de-dragon/templates/roll/result/partial-attaque-particuliere.hbs', 'partial-choix-maladresse': 'systems/foundryvtt-reve-de-dragon/templates/roll/result/partial-choix-maladresse.hbs', @@ -145,7 +146,7 @@ export default class ChatRollResult { case ROLL_TYPE_DEFENSE: return RdDCombat.rddCombatForAttackerAndDefender(roll.ids.opponentId, roll.ids.opponentTokenId, roll.ids.actorTokenId) case ROLL_TYPE_ATTAQUE: - return RdDCombat.rddCombatForAttackerAndDefender(roll.ids.actorId, roll.ids.actorTokenId, roll.ids.opponentId) + return RdDCombat.rddCombatForAttackerAndDefender(roll.ids.actorId, roll.ids.actorTokenId, roll.ids.opponentTokenId) } return undefined } @@ -162,6 +163,7 @@ export default class ChatRollResult { await this.saveChatMessageRoll(chatMessage, savedRoll) const copy = foundry.utils.duplicate(savedRoll) RollDialog.loadRollData(copy) + savedRoll.dmg = copy.current.attaque?.dmg this.prepareDisplay(copy) chatMessage.update({ content: await this.buildRollHtml(copy) }) chatMessage.render(true) diff --git a/module/roll/roll-dialog-adapter.mjs b/module/roll/roll-dialog-adapter.mjs index e6252591..6f5a7c9a 100644 --- a/module/roll/roll-dialog-adapter.mjs +++ b/module/roll/roll-dialog-adapter.mjs @@ -8,7 +8,7 @@ import { RdDItemArme } from "../item/arme.js"; import { RdDBonus } from "../rdd-bonus.js"; import { ITEM_TYPES, RDD_CONFIG } from "../constants.js"; import { CARACS } from "../rdd-carac.js"; -import { ROLL_TYPE_ATTAQUE, ROLL_TYPE_OEUVRE } from "./roll-constants.mjs"; +import { ROLL_TYPE_ATTAQUE, ROLL_TYPE_DEFENSE, ROLL_TYPE_OEUVRE } from "./roll-constants.mjs"; import { PART_ATTAQUE } from "./roll-part-attaque.mjs"; /* -------------------------------------------- */ @@ -27,8 +27,8 @@ export class RollDialogAdapter { RollDialogAdapter.setRollDataRolled(rollData, rolled, rollTitle) RollDialogAdapter.adjustRollDataForV1(rollData) RollDialogAdapter.adjustAttaqueParticuliere(rollData) + RollDialogAdapter.adjustAttaqueDmg(rollData) RollDialogAdapter.adjustDemiSurprise(rollData) - return rolled } @@ -96,14 +96,7 @@ export class RollDialogAdapter { rolled.niveauNecessaire = RdDResolutionTable.findNiveauNecessaire(rollData.selectedCarac.value, rolled.roll) rolled.ajustementNecessaire = rolled.niveauNecessaire - diff } - rollData.ajustements = rollData.ajustements.map(aj => { - return { - used: true, - label: aj.label, - value: aj.diff, - descr: aj.diff == undefined ? aj.label : undefined - } - }) + rollData.ajustements = rollData.ajustements.map(aj => { return { label: aj.label, value: aj.value } }) } static adjustDemiSurprise(rollData) { @@ -112,6 +105,18 @@ export class RollDialogAdapter { } } + static adjustAttaqueDmg(rollData) { + switch (rollData.type.current) { + case ROLL_TYPE_ATTAQUE: + rollData.dmg = RdDBonus.dmgRollV2(rollData, rollData.current.attaque) + break + case ROLL_TYPE_DEFENSE: + rollData.dmg = RdDBonus.dmgRollV2(rollData.attackerRoll, rollData.attackerRoll.current.attaque) + break + } + } + + static adjustAttaqueParticuliere(rollData) { if (rollData.type.current != ROLL_TYPE_ATTAQUE || !rollData.rolled.isPart) { return diff --git a/module/roll/roll-dialog.mjs b/module/roll/roll-dialog.mjs index 2e27bd12..a72d1b17 100644 --- a/module/roll/roll-dialog.mjs +++ b/module/roll/roll-dialog.mjs @@ -385,7 +385,7 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2 return RollDialog.getActiveParts(rollData) .map(p => p.getAjustements(rollData)) .reduce((a, b) => a.concat(b)) - .sort((a, b) => a.diff == undefined ? 1 : b.diff == undefined ? -1 : 0) + .sort((a, b) => a.value == undefined ? 1 : b.value == undefined ? -1 : 0) } async buildHTMLTable(carac, diff) { @@ -407,7 +407,7 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2 visibleRollParts.forEach(p => p.prepareContext(rollData)) - RollDialog.calculAjustements(rollData) + RollDialog.calculAjustement(rollData) const templates = RollDialog.getActiveParts(rollData).map(p => p.toTemplateData()) const context = await super._prepareContext() @@ -429,12 +429,11 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2 } } - static calculAjustements(rollData) { + static calculAjustement(rollData) { rollData.ajustements = RollDialog.getAjustements(rollData) - rollData.ajustements.forEach(it => it.isDiff = it.diff != undefined) rollData.current.totaldiff = rollData.ajustements - .map(adj => adj.diff) - .filter(d => d != undefined) + .filter(a => a.value != undefined) + .map(a => a.value) .reduce(Misc.sum(), 0) } @@ -442,13 +441,13 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2 return ALL_ROLL_TYPES.find(m => m.code == this.rollData.type.current) } - async close(options){ - if (this.rollOptions.onClose){ + async close(options) { + if (this.rollOptions.onClose) { this.rollOptions.onClose() } return await super.close(options) } - + async roll() { const roll = RollDialog.saveParts(this.rollData) @@ -479,8 +478,9 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2 static loadRollData(roll) { RollDialog.$prepareRollData(roll) - RollDialog.calculAjustements(roll) + RollDialog.calculAjustement(roll) roll.v2 = true + return roll } async defaultCallback(roll, rolled) { diff --git a/module/roll/roll-part-attaque.mjs b/module/roll/roll-part-attaque.mjs index 4eedb0ad..5519ede1 100644 --- a/module/roll/roll-part-attaque.mjs +++ b/module/roll/roll-part-attaque.mjs @@ -63,14 +63,9 @@ export class RollPartAttaque extends RollPartSelect { getAjustements(rollData) { const current = this.getCurrent(rollData) - const ajustements = [] - if (current.tactique) { - ajustements.push({ label: current.tactique.label, diff: current.tactique.attaque }) - } - if (rollData.opponent?.surprise) { - ajustements.push({ label: rollData.opponent.surprise.label, diff: rollData.opponent.surprise.attaque }) - } - return ajustements + const tactique = current.tactique ? [{ label: current.tactique.label, value: current.tactique.attaque }] : [] + const surprise = rollData.opponent?.surprise ? [{ label: rollData.opponent.surprise.label, value: rollData.opponent.surprise.attaque }] : [] + return [...tactique, ...surprise] } diff --git a/module/roll/roll-part-checkbox.mjs b/module/roll/roll-part-checkbox.mjs index c5476ab0..a55975c4 100644 --- a/module/roll/roll-part-checkbox.mjs +++ b/module/roll/roll-part-checkbox.mjs @@ -35,7 +35,7 @@ export class RollPartCheckbox extends RollPart { getAjustements(rollData) { const current = this.getCurrent(rollData) if (current.checked) { - return [{ label: this.getCheckboxLabelAjustement(rollData), diff: current.value }] + return [{ label: this.getCheckboxLabelAjustement(rollData), value: current.value }] } return [] } diff --git a/module/roll/roll-part-coeur.mjs b/module/roll/roll-part-coeur.mjs index 4465ae82..bd525fb8 100644 --- a/module/roll/roll-part-coeur.mjs +++ b/module/roll/roll-part-coeur.mjs @@ -47,7 +47,7 @@ export class RollPartCoeur extends RollPartSelect { if (current.key != '') { return [{ label: "Coeur pour " + current.label, - diff: current.value + value: current.value }] } return [] diff --git a/module/roll/roll-part-conditions.mjs b/module/roll/roll-part-conditions.mjs index 909d7233..9cfdf732 100644 --- a/module/roll/roll-part-conditions.mjs +++ b/module/roll/roll-part-conditions.mjs @@ -57,7 +57,7 @@ export class RollPartConditions extends RollPart { getAjustements(rollData) { const current = this.getCurrent(rollData) if (current.value != 0) { - return [{ label: DESCR_CONDITIONS, diff: current.value }] + return [{ label: DESCR_CONDITIONS, value: current.value }] } return [] } diff --git a/module/roll/roll-part-defense.mjs b/module/roll/roll-part-defense.mjs index f87a24ec..63ef5dcd 100644 --- a/module/roll/roll-part-defense.mjs +++ b/module/roll/roll-part-defense.mjs @@ -110,7 +110,7 @@ export class RollPartDefense extends RollPartSelect { isArmeDisparate(rollData) { const armeDefense = this.getCurrent(rollData).arme if (armeDefense) { - const armeAttaque = rollData.attackerRoll?.arme + const armeAttaque = rollData.attackerRoll?.current.attaque.arme return RdDItemArme.defenseArmeParade(armeAttaque, armeDefense) == 'sign' } return false diff --git a/module/roll/roll-part-diff.mjs b/module/roll/roll-part-diff.mjs index d54fb4f2..031fb6e4 100644 --- a/module/roll/roll-part-diff.mjs +++ b/module/roll/roll-part-diff.mjs @@ -66,7 +66,7 @@ export class RollPartDiff extends RollPart { const current = this.getCurrent(rollData) return [{ label: current.label, - diff: current.value + value: current.value }] } diff --git a/module/roll/roll-part-meditation.mjs b/module/roll/roll-part-meditation.mjs index 0e55646e..90b971dd 100644 --- a/module/roll/roll-part-meditation.mjs +++ b/module/roll/roll-part-meditation.mjs @@ -72,9 +72,10 @@ export class RollPartMeditation extends RollPartSelect { } getAjustements(rollData) { - const malusEchecs = { label: "Méditation", diff: this.getMalusEchecs(rollData) } - const malusConditions = { label: "Conditions", diff: this.getMalusConditions(rollData) } - return [malusConditions, ...(malusEchecs.diff == 0 ? [] : [malusEchecs])] + const malus = this.getMalusEchecs(rollData) + const malusEchecs = malusEchecs == 0 ? [] : [{ label: "Méditation", value: malus }] + const malusConditions = { label: "Conditions", value: this.getMalusConditions(rollData) } + return [malusConditions, ...malusEchecs] } $selectMeditation(rollData, key) { diff --git a/module/roll/roll-part-select.mjs b/module/roll/roll-part-select.mjs index c681fb65..5b0d0473 100644 --- a/module/roll/roll-part-select.mjs +++ b/module/roll/roll-part-select.mjs @@ -16,7 +16,7 @@ export class RollPartSelect extends RollPart { getAjustements(rollData) { const current = this.getCurrent(rollData) if (current) { - return [{ label: current.label, diff: current.value }] + return [{ label: current.label, value: current.value }] } return [] } diff --git a/module/roll/roll-part-sign.mjs b/module/roll/roll-part-sign.mjs index befb28e9..8dd24c11 100644 --- a/module/roll/roll-part-sign.mjs +++ b/module/roll/roll-part-sign.mjs @@ -76,8 +76,8 @@ export class RollPartSign extends RollPart { const current = this.getCurrent(rollData) if (current.surprise == 'demi') { return [ - { label: 'Significative requise ' + Misc.getFractionOneN(current.diviseur), diff: undefined }, - ...current.reasons.map(it => { return { label: ' ' + it, diff: undefined } }) + { label: 'Significative requise ' + Misc.getFractionOneN(current.diviseur) }, + ...current.reasons.map(it => { return { label: ' ' + it } }) ] } return [] diff --git a/module/roll/roll-part-sort.mjs b/module/roll/roll-part-sort.mjs index ac7627a4..182f7e79 100644 --- a/module/roll/roll-part-sort.mjs +++ b/module/roll/roll-part-sort.mjs @@ -94,16 +94,11 @@ export class RollPartSort extends RollPartSelect { getAjustements(rollData) { const current = this.getCurrent(rollData) if (current) { - const reserve = current.isReserve ? - [{ label: `Mise en réserve en ${this.getCoord(rollData)}` }] : [] - const bonusCase = current.bonusCase ? - [{ label: `Bonus case +${current.bonusCase}%` }] : [] - return [ - { label: current.label, diff: current.value }, - ...bonusCase, - { label: `Rêve ${current.ptreve}` }, - ...reserve - ] + const sort = { label: current.label, value: current.value } + const reserve = current.isReserve ? [{ label: `Mise en réserve en ${this.getCoord(rollData)}` }] : [] + const bonusCase = current.bonusCase ? [{ label: `Bonus case +${current.bonusCase}%` }] : [] + const reve = { label: `Rêve ${current.ptreve}` } + return [sort, ...bonusCase, reve, ...reserve] } return [] } diff --git a/module/roll/roll-part-tricher.mjs b/module/roll/roll-part-tricher.mjs index c0e869c8..0b9c7bb5 100644 --- a/module/roll/roll-part-tricher.mjs +++ b/module/roll/roll-part-tricher.mjs @@ -15,10 +15,6 @@ export class RollPartTricher extends RollPart { current.resultat = Misc.inRange(current.resultat == undefined ? -1 : current.resultat, -1, 100) } - getAjustements(rollData) { - return [] - } - async _onRender(rollDialog, context, options) { const input = rollDialog.element.querySelector(`roll-section[name="${this.code}"] input[name="${this.code}"]`) diff --git a/module/roll/roll-part.mjs b/module/roll/roll-part.mjs index dc7dfb9d..942f51bd 100644 --- a/module/roll/roll-part.mjs +++ b/module/roll/roll-part.mjs @@ -6,6 +6,8 @@ export const ROLLDIALOG_SECTION = { CONDITIONS: 'conditions', AJUSTEMENTS: 'ajustements', } + + export class RollPart { static settingKey(rollPart, key) { return `roll-part-${rollPart.code}.${key}` } @@ -104,9 +106,7 @@ export class RollPart { return { code: this.code, name: this.name, template: this.template, section: this.section } } - getAjustements(rollData) { - return [] - } + getAjustements(rollData) { return [] } async _onRender(rollDialog, context, options) { } diff --git a/templates/chat-infojet.hbs b/templates/chat-infojet.hbs index bc94b4c1..2724a8da 100644 --- a/templates/chat-infojet.hbs +++ b/templates/chat-infojet.hbs @@ -1,4 +1,3 @@ -{{log rolled}}
diff --git a/templates/roll/result/chat-attaque.hbs b/templates/roll/result/chat-attaque.hbs index bb9297ba..f4c81494 100644 --- a/templates/roll/result/chat-attaque.hbs +++ b/templates/roll/result/chat-attaque.hbs @@ -11,7 +11,7 @@
{{current.carac.label}} / {{current.comp.label}} à {{current.diff.value}} -
{{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.hbs"}} +
{{> 'partial-infojet'}}
@@ -19,9 +19,9 @@ {{#if rolled.isSuccess}} {{opponent.name}} doit se défendre à {{current.diff.value}}, - {{#if (eq current.dmg.mortalite 'empoignade')}} + {{#if (eq dmg.mortalite 'empoignade')}} ou {{active.name}} marquera un point d'empoignade - {{else if (eq current.dmg.mortalite 'non-mortel')}} + {{else if (eq dmg.mortalite 'non-mortel')}} ou encaisser à {{plusMoins dmg.total}} (non-mortel) {{else}} ou encaisser à {{plusMoins dmg.total}} diff --git a/templates/roll/result/chat-comp.hbs b/templates/roll/result/chat-comp.hbs index 63aec64b..b380b32a 100644 --- a/templates/roll/result/chat-comp.hbs +++ b/templates/roll/result/chat-comp.hbs @@ -9,7 +9,7 @@
{{current.carac.label}}{{#unless (eq current.comp.key '')}} / {{current.comp.label}}{{/unless}} à {{current.diff.value}} -
{{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.hbs"}} +
{{> 'partial-infojet'}}
diff --git a/templates/roll/result/chat-cuisine.hbs b/templates/roll/result/chat-cuisine.hbs index 5e6e8c47..a9469c70 100644 --- a/templates/roll/result/chat-cuisine.hbs +++ b/templates/roll/result/chat-cuisine.hbs @@ -14,7 +14,7 @@
{{current.carac.label}} / {{current.comp.label}} à {{current.diff.value}} -
{{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.hbs"}} +
{{> "partial-infojet"}}
diff --git a/templates/roll/result/chat-defense.hbs b/templates/roll/result/chat-defense.hbs index d121bb4d..2000cfb8 100644 --- a/templates/roll/result/chat-defense.hbs +++ b/templates/roll/result/chat-defense.hbs @@ -11,7 +11,7 @@
{{current.carac.label}} / {{current.comp.label}} à {{current.diff.value}} -
{{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.hbs"}} +
{{> 'partial-infojet'}}
diff --git a/templates/roll/result/chat-jeu.hbs b/templates/roll/result/chat-jeu.hbs index ddfa604c..2b0f53a5 100644 --- a/templates/roll/result/chat-jeu.hbs +++ b/templates/roll/result/chat-jeu.hbs @@ -9,7 +9,7 @@
{{current.carac.label}} / {{current.comp.label}} à {{current.diff.value}} -
{{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.hbs"}} +
{{> 'partial-infojet'}}
diff --git a/templates/roll/result/chat-meditation.hbs b/templates/roll/result/chat-meditation.hbs index 7fb38db2..1066de5e 100644 --- a/templates/roll/result/chat-meditation.hbs +++ b/templates/roll/result/chat-meditation.hbs @@ -9,7 +9,7 @@
{{current.carac.label}} / {{current.comp.label}} à {{current.diff.value}} -
{{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.hbs"}} +
{{> 'partial-infojet'}}
diff --git a/templates/roll/result/chat-oeuvre.hbs b/templates/roll/result/chat-oeuvre.hbs index cbd39ad9..f8c9559a 100644 --- a/templates/roll/result/chat-oeuvre.hbs +++ b/templates/roll/result/chat-oeuvre.hbs @@ -9,7 +9,7 @@
{{current.carac.label}} / {{current.comp.label}} à {{current.diff.value}} -
{{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.hbs"}} +
{{> 'partial-infojet'}}
diff --git a/templates/roll/result/chat-sort.hbs b/templates/roll/result/chat-sort.hbs index e862cd9d..035a3f3b 100644 --- a/templates/roll/result/chat-sort.hbs +++ b/templates/roll/result/chat-sort.hbs @@ -16,7 +16,7 @@
{{current.carac.label}} / {{current.comp.label}} à {{current.diff.value}} -
{{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.hbs"}} +
{{> 'partial-infojet'}}

diff --git a/templates/roll/result/chat-tache.hbs b/templates/roll/result/chat-tache.hbs index b9d07de2..6829d90e 100644 --- a/templates/roll/result/chat-tache.hbs +++ b/templates/roll/result/chat-tache.hbs @@ -9,7 +9,7 @@
{{current.carac.label}} / {{current.comp.label}} à {{current.diff.value}} -
{{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.hbs"}} +
{{> 'partial-infojet'}}
diff --git a/templates/roll/result/partial-infojet.hbs b/templates/roll/result/partial-infojet.hbs new file mode 100644 index 00000000..c373383d --- /dev/null +++ b/templates/roll/result/partial-infojet.hbs @@ -0,0 +1,26 @@ +{{#if ajustements}} +
+ + + {{rolled.caracValue}} à {{plusMoins rolled.finalLevel}} + = {{rolled.score}}% + {{#if (and rolled.factorHtml (ne rolled.factorHtml 1))}} + ×{{{rolled.factorHtml}}} + {{/if}} + +
+ {{#each ajustements as |item key|}} +
+ {{{item.label}}}{{#if item.value includeZero=true}}: {{plusMoins item.value}}{{/if}} +
+ {{/each}} +
+
+
+{{/if}} +
+ {{rolled.roll}} : {{rolled.quality}} + {{#if rolled.ajustementNecessaire}} + (Réussite si {{plusMoins rolled.niveauNecessaire}} / avec niveau {{plusMoins rolled.ajustementNecessaire}}) + {{/if}} +
\ No newline at end of file diff --git a/templates/roll/roll-ajustements.hbs b/templates/roll/roll-ajustements.hbs index 34851e01..b3bd2cee 100644 --- a/templates/roll/roll-ajustements.hbs +++ b/templates/roll/roll-ajustements.hbs @@ -2,21 +2,16 @@ Jet: {{rollData.current.carac.value}} à {{plusMoins rollData.current.totaldiff}}
- {{#each rollData.ajustements as |ajust|}} - {{#if ajust}} + {{#each rollData.ajustements as |item|}}
- {{#if ajust.descr}} - {{{ajust.descr}}} - {{else}} - {{{ajust.label}}}{{#if ajust.isDiff}}: {{plusMoins ajust.diff}}{{/if}} - {{/if}} + {{{item.label}}}{{#if item.value includeZero=true}}: {{plusMoins item.value}}{{/if}}
- {{/if}} {{/each}}
{{#if rollData.current.significative.used}} -
+
+ Significative requise ×{{{rollData.current.significative.label}}}! {{/if}}