Appel chance RollDialogV2

This commit is contained in:
2026-05-05 23:51:04 +02:00
parent e7acb0c4f2
commit 24753bfc29
14 changed files with 108 additions and 34 deletions
+1
View File
@@ -200,6 +200,7 @@ export default class ChatRollResult {
const chatMessage = ChatUtility.getChatMessage(event)
const savedRoll = this.loadChatMessageRoll(chatMessage)
const actor = this.getActiveActor(savedRoll)
Misc.doIfOwner(actor, it => it.rollAppelChance(
() => this.onAppelChanceSuccess(savedRoll, chatMessage),
() => this.onAppelChanceEchec(savedRoll, chatMessage))
+1
View File
@@ -9,6 +9,7 @@ export const ROLL_TYPE_MEDITATION = 'meditation'
export const ROLL_TYPE_OEUVRE = 'oeuvre'
export const ROLL_TYPE_SORT = 'sort'
export const ROLL_TYPE_TACHE = 'tache'
export const ROLL_TYPE_APPEL_CHANCE = 'appel-chance'
export const ATTAQUE_ROLL_TYPES = [ROLL_TYPE_ATTAQUE]
export const COMBAT_ROLL_TYPES = [ROLL_TYPE_ATTAQUE, ROLL_TYPE_DEFENSE]
+2 -1
View File
@@ -50,6 +50,7 @@ import { RollPartResistance } from "./roll-part-resistance.mjs";
import { RollTypePossession } from "./roll-type-possession.mjs";
import { RollPartPossession } from "./roll-part-possession.mjs";
import { RollPartApprecier } from "./roll-part-apprecier.mjs";
import { RollTypeAppelChance } from "./roll-type-appel-chance.mjs";
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api
@@ -65,6 +66,7 @@ export const ALL_ROLL_TYPES = [
new RollTypeCuisine(),
new RollTypeOeuvre(),
new RollTypeJeu(),
new RollTypeAppelChance(),
// new RollTypeResistance ??
// new RollTypeFixedCarac ??
]
@@ -290,7 +292,6 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
return rollData.type?.allowed
? ROLL_PARTS.filter(p => RollDialog.$isIntersecting(rollData.type.allowed, p.rollTypes))
: ROLL_PARTS
}
/** pre-configure les paramètres des différentes parties de la fenêtre (par exemple, prépare les listes de caractéristiques/compétences */
+1 -1
View File
@@ -27,7 +27,7 @@ export class RollPartComp extends RollPartSelect {
const selected = this.getSelected(rollData)
const all = this.$getActorComps(rollData)
const selectedComp = selected.key
if (selected.forced && selectedComp) {
if (selected.forced && selectedComp!= undefined ) {
refs.all = all.filter(comp => Grammar.equalsInsensitive(comp.label, selectedComp))
if (refs.all.length == 0) {
if (selected.key && selected.key.length > 0) {
+6
View File
@@ -10,6 +10,11 @@ export class RollPartConditions extends RollPart {
settingMin() { return RollPart.settingKey(this, 'min') }
settingMax() { return RollPart.settingKey(this, 'max') }
visible(rollData) {
const current = this.getCurrent(rollData)
return !current.hide
}
onReady(rollParts) {
game.settings.register(SYSTEM_RDD, this.settingMin(),
{
@@ -36,6 +41,7 @@ export class RollPartConditions extends RollPart {
restore(rollData) {
const current = this.getCurrent(rollData)
current.value = this.getSaved(rollData)?.value ?? current.value ?? 0
current.hide = this.getSaved(rollData)?.hide
}
+1 -1
View File
@@ -37,7 +37,7 @@ export class RollPartDiff extends RollPart {
}
const current = this.getCurrent(rollData)
/* TODO: affiner les cas où afficher ou non. devrait s'afficher pour les jets basiques (même si pas d'opposant sélectionné)*/
return Object.values(DIFF).includes(current.type)
return (DIFF.AUCUN !=current.type) && Object.values(DIFF).includes(current.type)
}
prepareContext(rollData) {
+44
View File
@@ -0,0 +1,44 @@
import { CARACS } from "../rdd-carac.js"
import { DIFF, ROLL_TYPE_APPEL_CHANCE } from "./roll-constants.mjs"
import { RollType } from "./roll-type.mjs"
const SPECIAL_ROLL_TYPES_DETAILS = {
label: "fait appel à la chance",
icon: `systems/foundryvtt-reve-de-dragon/assets/ui/chance.svg`,
rollData: {
selected: {
carac: { key: CARACS.CHANCE_ACTUELLE, forced: true },
diff: { value: 0, type: '' },
comp: { key: '', forced: true },
conditions: { hide: true }
}
}
}
export class RollTypeAppelChance extends RollType {
get code() { return ROLL_TYPE_APPEL_CHANCE }
get name() { return `fait appel à la chance` }
get icon() { return `systems/foundryvtt-reve-de-dragon/assets/ui/chance.svg` }
get chatResultTemplate() { return `systems/foundryvtt-reve-de-dragon/templates/roll/result/chat-appel-chance.hbs` }
title(rollData) {
return this.name
}
setRollDataType(rollData) {
foundry.utils.mergeObject(rollData, {
selected: {
carac: { key: CARACS.CHANCE_ACTUELLE, forced: true },
diff: { value: 0, type: '' },
comp: { key: '', forced: true },
conditions: { hide: true }
}
})
super.setRollDataType(rollData)
}
onSelect(rollData) {
this.setDiffType(rollData, DIFF.AUCUN)
}
}
+1 -1
View File
@@ -14,7 +14,7 @@ export class RollType {
return { code: this.code, name: this.name, icon: this.icon, section: 'type', template: this.template, selected: this.isSelected(rollData) }
}
prepare(rollData){}
prepare(rollData) {}
isAllowed(rollData) { return rollData.type.allowed == undefined || rollData.type.allowed.includes(this.code) }
visible(rollData) { return true }
title(rollData) { return this.code }