Gestion des maladresses

This commit is contained in:
2025-10-16 00:33:24 +02:00
parent 6d7f66569a
commit 5da5cb0314
10 changed files with 63 additions and 22 deletions

View File

@@ -156,11 +156,16 @@ export class RdDResolutionTable {
}
}
/* -------------------------------------------- */
static replaceParticuliereDemiSurprise(chances){
foundry.utils.mergeObject(chances, reussites.find(x => x.code == 'part'), { overwrite: true });
}
/* -------------------------------------------- */
static significativeRequise(chances) {
chances.roll = Math.min(chances.part + 1, chances.sign)
foundry.utils.mergeObject(chances, reussites.find(x => x.code == 'sign'), { overwrite: true });
}
}
/* -------------------------------------------- */
static succesRequis(chances) {

View File

@@ -9,6 +9,9 @@ import { EMPOIGNADE } from "../item/arme.js"
import { RdDTextEditor } from "../apps/rdd-text-roll-editor.js"
import { RollTypeCuisine } from "./roll-type-cuisine.mjs"
import { RollTypeMeditation } from "./roll-type-meditation.mjs"
import { PART_DEFENSE } from "./roll-part-defense.mjs"
import { PART_ATTAQUE } from "./roll-part-attaque.mjs"
import { RdDRollTables } from "../rdd-rolltables.js"
export default class ChatRollResult {
static init() {
@@ -21,6 +24,7 @@ export default class ChatRollResult {
foundry.applications.handlebars.loadTemplates({
'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-maladresse': 'systems/foundryvtt-reve-de-dragon/templates/roll/result/partial-maladresse.hbs',
'partial-encaissement': 'systems/foundryvtt-reve-de-dragon/templates/roll/result/partial-encaissement.hbs',
'partial-recul-choc': 'systems/foundryvtt-reve-de-dragon/templates/roll/result/partial-recul-choc.hbs',
'partial-info-appel-moral': 'systems/foundryvtt-reve-de-dragon/templates/roll/result/partial-info-appel-moral.hbs',
@@ -49,7 +53,7 @@ export default class ChatRollResult {
roll.show.chance = this.isAppelChancePossible(roll)
roll.show.encaissement = this.isShowEncaissement(roll)
roll.show.recul = this.getRecul(roll)
//roll.show.particuliere = roll.show.particuliere ?? []
roll.show.maladresse = this.getMaladresse(roll)
}
isAppelChancePossible(roll) {
@@ -66,6 +70,23 @@ export default class ChatRollResult {
return false
}
getMaladresse(roll) {
switch (roll.type.current) {
case ROLL_TYPE_DEFENSE:
if (roll.rolled.isETotal) {
const arme = roll.current[PART_DEFENSE].arme
return arme ? 'avec-arme' : 'sans-arme'
}
break
case ROLL_TYPE_ATTAQUE:
if (roll.rolled.isETotal || (roll.rolled.isEchec && roll.active.surprise == 'demi')) {
const arme = roll.current[PART_ATTAQUE].arme
return arme.system.baseInit > 4 ? 'avec-arme' : 'sans-arme'
}
break
}
return undefined
}
getRecul(roll, defender = roll.active.actor, attacker = roll.opponent?.actor) {
switch (roll.type.current) {
@@ -115,6 +136,7 @@ export default class ChatRollResult {
$(html).on("click", '.faire-gouter', event => this.onClickFaireGouter(event))
$(html).on("click", '.monter-tmr-normale', event => this.onClickMonteeTMR(event, 'normal'))
$(html).on("click", '.monter-tmr-rapide', event => this.onClickMonteeTMR(event, 'rapide'))
$(html).on("click", '.tirer-maladresse', event => this.onClickTirerMaladresse(event))
}
@@ -247,4 +269,13 @@ export default class ChatRollResult {
await this.updateChatMessage(chatMessage, savedRoll)
}
}
async onClickTirerMaladresse(event) {
const chatMessage = ChatUtility.getChatMessage(event)
const typeMaladresse = event.currentTarget.attributes['data-maladresse'].value
const savedRoll = this.loadChatMessageRoll(chatMessage)
await RdDRollTables.getMaladresse({ arme: typeMaladresse == 'avec-arme' })
savedRoll.type.maladresse = true
savedRoll.type.retry = true
await this.updateChatMessage(chatMessage, savedRoll)
}
}

View File

@@ -27,6 +27,7 @@ export class RollDialogAdapter {
RollDialogAdapter.setRollDataRolled(rollData, rolled, rollTitle)
RollDialogAdapter.adjustRollDataForV1(rollData)
RollDialogAdapter.adjustAttaqueParticuliere(rollData)
RollDialogAdapter.adjustDemiSurprise(rollData)
return rolled
}
@@ -105,6 +106,12 @@ export class RollDialogAdapter {
})
}
static adjustDemiSurprise(rollData) {
if (rollData.active.surprise == 'demi' && rollData.rolled.isPart) {
RdDResolutionTable.replaceParticuliereDemiSurprise(rollData.rolled)
}
}
static adjustAttaqueParticuliere(rollData) {
if (rollData.type.current != ROLL_TYPE_ATTAQUE || !rollData.rolled.isPart) {
return

View File

@@ -50,14 +50,6 @@ export class RollPartAttaque extends RollPartSelect {
choices(refs) { return refs.attaques }
static $extractAttaque(attaque, actor) {
// 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

View File

@@ -1,9 +1,6 @@
import { ITEM_TYPES } from "../constants.js"
import { Grammar } from "../grammar.js"
import { ATTAQUE_TYPE, RdDItemArme } from "../item/arme.js"
import { RdDBonus } from "../rdd-bonus.js"
import { CARACS } from "../rdd-carac.js"
import { StatusEffects } from "../settings/status-effects.js"
import { DIFF, ROLL_TYPE_DEFENSE } from "./roll-constants.mjs"
import { PART_CARAC } from "./roll-part-carac.mjs"
import { PART_COMP } from "./roll-part-comp.mjs"

View File

@@ -1,5 +1,4 @@
import { DIFF, ROLL_TYPE_ATTAQUE } from "./roll-constants.mjs"
import { PART_ATTAQUE } from "./roll-part-attaque.mjs"
import { RollType } from "./roll-type.mjs"
export class RollTypeAttaque extends RollType {