Affichage des ajustements V2

This commit is contained in:
2025-10-17 22:51:56 +02:00
parent a6c593c100
commit e16f89743a
29 changed files with 94 additions and 79 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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]
}

View File

@@ -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 []
}

View File

@@ -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 []

View File

@@ -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 []
}

View File

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

View File

@@ -66,7 +66,7 @@ export class RollPartDiff extends RollPart {
const current = this.getCurrent(rollData)
return [{
label: current.label,
diff: current.value
value: current.value
}]
}

View File

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

View File

@@ -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 []
}

View File

@@ -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: '<i class="fa-solid fa-triangle-exclamation"></i> ' + it, diff: undefined } })
{ label: 'Significative requise ' + Misc.getFractionOneN(current.diviseur) },
...current.reasons.map(it => { return { label: '<i class="fa-solid fa-triangle-exclamation"></i> ' + it } })
]
}
return []

View File

@@ -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 []
}

View File

@@ -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}"]`)

View File

@@ -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) { }

View File

@@ -1,4 +1,3 @@
{{log rolled}}
<div>
<span {{#if ajustements}}class="tooltip-overflow tooltip-dotted" {{/if}}>
<span>

View File

@@ -11,7 +11,7 @@
<div class="chat-resume">
{{current.carac.label}} / {{current.comp.label}} à {{current.diff.value}}
<br>{{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.hbs"}}
<br>{{> 'partial-infojet'}}
</div>
<div class="chat-details">
@@ -19,9 +19,9 @@
{{#if rolled.isSuccess}}
<span>
<strong>{{opponent.name}}</strong> doit se défendre à <strong>{{current.diff.value}}</strong>,
{{#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 à <span class="rdd-roll-norm">{{plusMoins dmg.total}} (non-mortel)</span>
{{else}}
ou encaisser à <span class="rdd-roll-echec">{{plusMoins dmg.total}}</span>

View File

@@ -9,7 +9,7 @@
<div class="chat-resume">
{{current.carac.label}}{{#unless (eq current.comp.key '')}} / {{current.comp.label}}{{/unless}} à {{current.diff.value}}
<br>{{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.hbs"}}
<br>{{> 'partial-infojet'}}
</div>
<div class="chat-details">

View File

@@ -14,7 +14,7 @@
<div class="chat-resume">
{{current.carac.label}} / {{current.comp.label}} à {{current.diff.value}}
<br>{{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.hbs"}}
<br>{{> "partial-infojet"}}
</div>
<div class="chat-details">

View File

@@ -11,7 +11,7 @@
<div class="chat-resume">
{{current.carac.label}} / {{current.comp.label}} à {{current.diff.value}}
<br>{{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.hbs"}}
<br>{{> 'partial-infojet'}}
</div>
<div class="chat-details">

View File

@@ -9,7 +9,7 @@
<div class="chat-resume">
{{current.carac.label}} / {{current.comp.label}} à {{current.diff.value}}
<br>{{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.hbs"}}
<br>{{> 'partial-infojet'}}
</div>
<div class="chat-details">

View File

@@ -9,7 +9,7 @@
<div class="chat-resume">
{{current.carac.label}} / {{current.comp.label}} à {{current.diff.value}}
<br>{{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.hbs"}}
<br>{{> 'partial-infojet'}}
</div>
<div class="chat-details">

View File

@@ -9,7 +9,7 @@
<div class="chat-resume">
{{current.carac.label}} / {{current.comp.label}} à {{current.diff.value}}
<br>{{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.hbs"}}
<br>{{> 'partial-infojet'}}
</div>
<div class="chat-details">

View File

@@ -16,7 +16,7 @@
<div class="chat-resume">
{{current.carac.label}} / {{current.comp.label}} à {{current.diff.value}}
<br>{{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.hbs"}}
<br>{{> 'partial-infojet'}}
</div>
<hr>

View File

@@ -9,7 +9,7 @@
<div class="chat-resume">
{{current.carac.label}} / {{current.comp.label}} à {{current.diff.value}}
<br>{{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.hbs"}}
<br>{{> 'partial-infojet'}}
</div>
<div class="chat-details">

View File

@@ -0,0 +1,26 @@
{{#if ajustements}}
<div>
<span class="tooltip-overflow tooltip-dotted" >
<span>
<span>{{rolled.caracValue}} à {{plusMoins rolled.finalLevel}}</span>
<span>= {{rolled.score}}%</span>
{{#if (and rolled.factorHtml (ne rolled.factorHtml 1))}}
<span class="rdd-diviseur">&times;{{{rolled.factorHtml}}}</span>
{{/if}}
</span>
<div class="tooltiptext ttt-ajustements">
{{#each ajustements as |item key|}}
<div class="{{#if item.strong}}strong-text{{/if}}">
{{{item.label}}}{{#if item.value includeZero=true}}: {{plusMoins item.value}}{{/if}}
</div>
{{/each}}
</div>
</span>
</div>
{{/if}}
<div>
<span>{{rolled.roll}} : </span><span class="rdd-roll-{{rolled.code}} strong-text">{{rolled.quality}}</span>
{{#if rolled.ajustementNecessaire}}
<span class="rdd-niveau-requis">(Réussite si {{plusMoins rolled.niveauNecessaire}} / avec niveau {{plusMoins rolled.ajustementNecessaire}}) </span>
{{/if}}
</div>

View File

@@ -2,21 +2,16 @@
<span class="tooltip tooltip-dotted">
<span class="roll-part-resolution">Jet: {{rollData.current.carac.value}} à {{plusMoins rollData.current.totaldiff}}</span>
<div class="tooltiptext ttt-ajustements">
{{#each rollData.ajustements as |ajust|}}
{{#if ajust}}
{{#each rollData.ajustements as |item|}}
<div>
{{#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}}
</div>
{{/if}}
{{/each}}
</div>
</span>
{{#if rollData.current.significative.used}}
<br><span>
<br>
<span>
Significative requise <span class="rdd-diviseur">&times;{{{rollData.current.significative.label}}}</span>!
</span>
{{/if}}