forked from public/foundryvtt-reve-de-dragon
Affichage des ajustements V2
This commit is contained in:
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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
|
||||
|
@@ -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) {
|
||||
|
@@ -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]
|
||||
}
|
||||
|
||||
|
||||
|
@@ -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 []
|
||||
}
|
||||
|
@@ -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 []
|
||||
|
@@ -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 []
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -66,7 +66,7 @@ export class RollPartDiff extends RollPart {
|
||||
const current = this.getCurrent(rollData)
|
||||
return [{
|
||||
label: current.label,
|
||||
diff: current.value
|
||||
value: current.value
|
||||
}]
|
||||
}
|
||||
|
||||
|
@@ -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) {
|
||||
|
@@ -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 []
|
||||
}
|
||||
|
@@ -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 []
|
||||
|
@@ -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 []
|
||||
}
|
||||
|
@@ -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}"]`)
|
||||
|
||||
|
@@ -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) { }
|
||||
|
||||
|
Reference in New Issue
Block a user