forked from public/foundryvtt-reve-de-dragon
Roll V2 sur compétences&combat
Corrections associées Maintenant, active en mode rollV2
This commit is contained in:
@@ -5,6 +5,7 @@ import { RdDCombat } from "../rdd-combat.js"
|
||||
import { ROLL_TYPE_ATTAQUE, ROLL_TYPE_DEFENSE } from "./roll-constants.mjs"
|
||||
import { RdDResolutionTable } from "../rdd-resolution-table.js"
|
||||
import { RDD_CONFIG, renderTemplate } from "../constants.js"
|
||||
import { EMPOIGNADE } from "../item/arme.js"
|
||||
|
||||
export default class ChatRollResult {
|
||||
static init() {
|
||||
@@ -56,8 +57,7 @@ export default class ChatRollResult {
|
||||
isShowEncaissement(roll) {
|
||||
switch (roll.type.current) {
|
||||
case ROLL_TYPE_DEFENSE:
|
||||
return roll.rolled.isEchec &&
|
||||
roll.attackerRoll?.dmg.mortalite != 'empoignade'
|
||||
return roll.rolled.isEchec && roll.attackerRoll?.dmg.mortalite != EMPOIGNADE
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
@@ -9,6 +9,14 @@ export const ROLL_TYPE_OEUVRE = 'oeuvre'
|
||||
export const ROLL_TYPE_SORT = 'sort'
|
||||
export const ROLL_TYPE_TACHE = 'tache'
|
||||
|
||||
export const ATTAQUE_ROLL_TYPES = [ROLL_TYPE_ATTAQUE]
|
||||
export const COMBAT_ROLL_TYPES = [ROLL_TYPE_ATTAQUE, ROLL_TYPE_DEFENSE]
|
||||
export const DEMIREVE_ROLL_TYPES = [ROLL_TYPE_SORT]
|
||||
export const DEFAULT_ROLL_TYPES = [ROLL_TYPE_COMP, ROLL_TYPE_JEU, ROLL_TYPE_MEDITATION, ROLL_TYPE_CUISINE, ROLL_TYPE_OEUVRE, ROLL_TYPE_TACHE]
|
||||
export const ALL_ROLL_TYPES = [...DEFAULT_ROLL_TYPES, ...COMBAT_ROLL_TYPES, ...DEMIREVE_ROLL_TYPES]
|
||||
|
||||
|
||||
|
||||
export const DIFF = {
|
||||
LIBRE: 'libre',
|
||||
ATTAQUE: 'attaque',
|
||||
|
@@ -264,8 +264,8 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
|
||||
const potential = ALL_ROLL_TYPES.find(m => m.code == rollData.type.current)?.code
|
||||
const allowed = rollData.type.retry && potential
|
||||
? [potential]
|
||||
: (rollData.type.allowed ?? ALL_ROLL_TYPES.filter(m => m.isAllowed(rollData) && m.visible(rollData)).map(m => m.code))
|
||||
const rollType = allowed.find(c => c == rollData.type.current) ?? (allowed.length > 0 ? allowed[0].code : ROLL_TYPE_COMP);
|
||||
: (rollData.type.allowed ?? ALL_ROLL_TYPES.filter(m => m.isAllowed(rollData) && m.visible(rollData)).map(m => m.code) ?? [ROLL_TYPE_COMP])
|
||||
const rollType = allowed.find(c => c == rollData.type.current) ?? allowed[0]
|
||||
|
||||
rollData.type.allowed = allowed
|
||||
rollData.type.current = rollType
|
||||
|
@@ -1,7 +1,8 @@
|
||||
import { RdDBonus } from "../rdd-bonus.js"
|
||||
import { ROLL_TYPE_ATTAQUE } from "./roll-constants.mjs"
|
||||
import { DIFF, ROLL_TYPE_ATTAQUE } from "./roll-constants.mjs"
|
||||
import { PART_CARAC } from "./roll-part-carac.mjs"
|
||||
import { PART_COMP } from "./roll-part-comp.mjs"
|
||||
import { PART_DIFF } from "./roll-part-diff.mjs"
|
||||
import { RollPartSelect } from "./roll-part-select.mjs"
|
||||
import { ROLLDIALOG_SECTION } from "./roll-part.mjs"
|
||||
|
||||
@@ -22,7 +23,8 @@ export class RollPartAttaque extends RollPartSelect {
|
||||
refs.attaques = attaques.map(it => RollPartAttaque.$extractAttaque(it, rollData.active.actor))
|
||||
refs.tactiques = TACTIQUES
|
||||
if (refs.attaques.length > 0) {
|
||||
this.$selectAttaque(rollData)
|
||||
const attaque = this.findAttaque(refs.attaques, this.getSaved(rollData))
|
||||
this.$selectAttaque(rollData, attaque?.key)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,19 +34,34 @@ export class RollPartAttaque extends RollPartSelect {
|
||||
}
|
||||
|
||||
restore(rollData) {
|
||||
const saved = this.getSaved(rollData)
|
||||
super.restore(rollData)
|
||||
this.getCurrent(rollData).dmg = this.getSaved(rollData).dmg
|
||||
if (saved.dmg) {
|
||||
this.getCurrent(rollData).dmg = this.getSaved(rollData).dmg
|
||||
}
|
||||
}
|
||||
|
||||
findAttaque(attaques, saved) {
|
||||
return attaques.find(at => at.arme.id == saved?.arme?.id &&
|
||||
at.comp.id == saved?.comp?.id
|
||||
)
|
||||
}
|
||||
|
||||
choices(refs) { return refs.attaques }
|
||||
|
||||
static $extractAttaque(attaque, actor) {
|
||||
return foundry.utils.mergeObject({
|
||||
key: `${attaque.action}::${attaque.label}`,
|
||||
tactique: TACTIQUES[0]
|
||||
},
|
||||
attaque
|
||||
)
|
||||
// const extracted = foundry.utils.mergeObject({
|
||||
// key: `${attaque.action}::${attaque.label}`,
|
||||
// tactique: TACTIQUES[0]
|
||||
// },
|
||||
// attaque
|
||||
// )
|
||||
// return extracted
|
||||
// extracted.initialDiff = attaque.comp?.system.default_diffLibre ?? 0
|
||||
attaque.key = `${attaque.action}::${attaque.label}`
|
||||
attaque.tactique = TACTIQUES[0]
|
||||
attaque.initialDiff = attaque.comp?.system.default_diffLibre ?? 0
|
||||
return attaque
|
||||
}
|
||||
|
||||
prepareContext(rollData) {
|
||||
@@ -101,6 +118,12 @@ export class RollPartAttaque extends RollPartSelect {
|
||||
switch (part.code) {
|
||||
case PART_CARAC: return part.filterCaracs(rollData, [current.carac.key])
|
||||
case PART_COMP: return part.filterComps(rollData, [current.comp.name])
|
||||
case PART_DIFF: {
|
||||
if (current.initialDiff) {
|
||||
part.setDiff(rollData, { type: DIFF.ATTAQUE, value: current.initialDiff })
|
||||
current.initialDiff = undefined
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
|
@@ -51,10 +51,10 @@ export class RollPartDiff extends RollPart {
|
||||
)
|
||||
}
|
||||
|
||||
setDiff(rollData, diffDefense) {
|
||||
setDiff(rollData, diff) {
|
||||
const current = this.getCurrent(rollData)
|
||||
current.value = diffDefense.diff
|
||||
current.type = diffDefense.type
|
||||
current.value = diff.diff
|
||||
current.type = diff.type
|
||||
}
|
||||
|
||||
getAjustements(rollData) {
|
||||
|
Reference in New Issue
Block a user