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

1
assets/ui/maladresse.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style="height: 256px; width: 256px;"><g class="" transform="translate(0,0)" style=""><path d="M221.313 16a23.682 23.695 0 0 0-23.688 23.688v106.406a23.682 23.695 0 0 0 2.156 9.72 23.682 23.695 0 0 0 3.157 13.81l41.75 71.626-79 55.438 6.094-48.625a23.682 23.695 0 0 0-8.186-20.97l-66.28-81.937a23.682 23.695 0 0 0-33.314-3.5l-9.188 7.438a23.682 23.695 0 0 0-3.53 33.344l59.78 73.906-11.25 89.937a23.682 23.695 0 0 0 12.47 23.876l37.468 53.47a23.695 23.682 1.57 0 0 2.344 2.812 23.682 23.695 0 0 0 13.594 20.062L262 491.53a23.682 23.695 0 0 0 9.97 2.22 23.682 23.695 0 0 0 23.53-2.063l87.156-60.937a23.682 23.695 0 0 0 5.844-33l-6.78-9.688a23.682 23.695 0 0 0-32.97-5.875l-72.406 50.657-59.063-27.625 120.595-84.626a23.695 23.682 1.57 0 0 5.53-5.5 23.682 23.695 0 0 0 14.626-13.594l37.22-91.53 87.813-44.845a23.694 23.682 1.18 0 0 10.312-31.875L488 122.687a23.694 23.682 1.18 0 0-31.875-10.343l-94.688 48.375a23.694 23.682 1.18 0 0-9.843 9.436 23.682 23.695 0 0 0-8.344 10.47l-27.375 67.31-5.22-7.436a23.682 23.695 0 0 0-3-8.844l-50.81-87.094V39.688A23.682 23.695 0 0 0 233.154 16h-11.843zM77.75 376A59.994 60 0 0 0 16 436a59.994 60 0 1 0 120 0 59.994 60 0 0 0-58.25-60z" fill="#fff" fill-opacity="1"></path></g></svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

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 {

View File

@@ -22,15 +22,10 @@
{{#if (eq current.dmg.mortalite 'empoignade')}}
ou {{active.name}} marquera un point d'empoignade
{{else if (eq current.dmg.mortalite 'non-mortel')}}
ou encaisser à <span class="rdd-roll-norm">{{plusMoins current.dmg.total}} (non-mortel)</span>
ou encaisser à <span class="rdd-roll-norm">{{plusMoins dmg.total}} (non-mortel)</span>
{{else}}
{{!-- {{~#if (eq current.dmg.mortalite 'mortel')}} --}}
ou encaisser à <span class="rdd-roll-echec">{{plusMoins current.dmg.total}}</span>
{{!-- {{~#if (eq current.dmg.mortalite 'cauchemar')}} --}}
{{!-- {{else}}
<span class="rdd-roll-etotal">{{plusMoins dmg.total}}</span> (entités de cauchemar) --}}
ou encaisser à <span class="rdd-roll-echec">{{plusMoins dmg.total}}</span>
{{/if}}
</span>
{{#if show.recul}}
<span class='chat-card-info'>
@@ -65,6 +60,7 @@
<div class="chat-actions">
{{> 'partial-attaque-particuliere'}}
{{> 'partial-maladresse'}}
{{!-- TODO: maladresses --}}
</div>

View File

@@ -44,7 +44,7 @@
{{> 'partial-info-appel-moral'}}
</div>
<div class="chat-actions">
{{!-- TODO: maladresses --}}
{{> 'partial-maladresse'}}
{{> 'partial-recul-choc'}}
{{> 'partial-encaissement'}}
</div>

View File

@@ -0,0 +1,13 @@
{{#if show.maladresse}}
{{#if type.maladresse}}
<span class='chat-card-info'>
<img src="systems/foundryvtt-reve-de-dragon/assets/ui/maladresse.svg"/> Maladresse!
</span>
{{else}}
<a class='chat-card-button tirer-maladresse' data-maladresse='{{show.maladresse}}'
data-tooltip="Tirer la maladresse">
<img src="systems/foundryvtt-reve-de-dragon/assets/ui/maladresse.svg"/> Tirer une maladresse
{{#if (eq show.maladresse 'avec-arme')}}armé{{else}}non armé{{/if}}
</a>
{{/if}}
{{/if}}