RollV2, tchat et appel chance

gestion des appels à la chance pour tout jet V2

correction de soucis forçage du jet

continuation des messages de défense
This commit is contained in:
2025-09-27 23:48:17 +02:00
parent a7e14736e4
commit faca73b0a1
23 changed files with 240 additions and 153 deletions

View File

@@ -46,7 +46,7 @@ import { PAS_DE_DRACONIC, POSSESSION_SANS_DRACONIC } from "./item/base-items.js"
import { RdDRollResult } from "./rdd-roll-result.js";
import { RdDInitiative } from "./initiative.mjs";
import RollDialog from "./roll/roll-dialog.mjs";
import { OptionsAvancees, ROLL_DIALOG_V2 } from "./settings/options-avancees.js";
import { OptionsAvancees, ROLL_DIALOG_V2, ROLL_DIALOG_V2_TEST } from "./settings/options-avancees.js";
export const MAINS_DIRECTRICES = ['Droitier', 'Gaucher', 'Ambidextre']
@@ -3049,7 +3049,7 @@ export class RdDActor extends RdDBaseActorSang {
/* -------------------------------------------- */
async _rollArtV2(oeuvreId, callbackAction = async (rd) => await this._resultArtV2(rd)) {
async _rollArtV2(oeuvreId) {
const oeuvre = this.items.get(oeuvreId)
const rollData = {
title: `Interpretation de ${oeuvre.name} par ${this.name}`,
@@ -3066,23 +3066,12 @@ export class RdDActor extends RdDBaseActorSang {
}
await RollDialog.create(rollData, {
onRollDone: (dialog) => {
this._onCloseRollDialog()
dialog.close()
},
customChatMessage: true,
callbacks: [callbackAction]
if (!OptionsAvancees.isUsing(ROLL_DIALOG_V2_TEST))
dialog.close()
}
})
}
// TODO: move vers ChatRollResult
async _resultArtV2(artData) {
const niveau = artData.oeuvre.system.niveau ?? 0
const baseQualite = (artData.rolled.isSuccess ? niveau : artData.competence.system.niveau)
artData.qualiteFinale = Math.min(baseQualite, niveau) + artData.rolled.ptQualite
//this.$onRollCompetence(artData)
await RdDRollResult.displayRollData(artData, this.name, `chat-resultat-${artData.art}.hbs`)
}
/* -------------------------------------------- */
async rollOeuvre(id) {
if (OptionsAvancees.isUsing(ROLL_DIALOG_V2)) {

View File

@@ -197,8 +197,12 @@ export class ChatUtility {
static async onCreateChatMessage(chatMessage, options, id) {
if (chatMessage.isAuthor) {
await chatMessage.setFlag(SYSTEM_RDD, 'rdd-timestamp', game.system.rdd.calendrier.getTimestamp());
await ChatUtility.setTimestamp(chatMessage)
await chatMessage.update({ content: await RdDTextEditor.enrichHTML(chatMessage.content, undefined, { showLink: false }) })
}
}
static async setTimestamp(chatMessage) {
await chatMessage.setFlag(SYSTEM_RDD, 'rdd-timestamp', game.system.rdd.calendrier.getTimestamp());
}
}

View File

@@ -34,6 +34,9 @@ export class Misc {
return ((n % m) + m) % m;
}
static inRange(value, min,max){
return Math.max(min, Math.min(value, max))
}
static sum() {
return (a, b) => Number(a) + Number(b);
}

View File

@@ -36,7 +36,7 @@ export class RdDBonus {
/* -------------------------------------------- */
static dmg(rollData, actor, isEntiteIncarnee = false) {
const dmgArme = RdDBonus.dmgArme(rollData.arme, rollData.arme?.system.dommagesReels)
const forceRequise = RdDItemArme.valeurMain(rollData.arme?.system.force ?? 0, RdDItemArme.getMainAttaque(rollData.competence))
const forceRequise = rollData.arme ? RdDItemArme.valeurMain(rollData.arme.system.force ?? 0, RdDItemArme.getMainAttaque(rollData.competence)) : 0
let dmg = {
total: 0,
dmgArme: dmgArme,

View File

@@ -18,7 +18,8 @@ import { RdDInitiative } from "./initiative.mjs";
import RollDialog from "./roll/roll-dialog.mjs";
import { PART_DEFENSE } from "./roll/roll-part-defense.mjs";
import { RollDialogAdapter } from "./roll/roll-dialog-adapter.mjs";
import { DIFF, ROLL_TYPE_ATTAQUE, ROLL_TYPE_DEFENSE } from "./roll/roll-constants.mjs";
import { ROLL_TYPE_ATTAQUE, ROLL_TYPE_DEFENSE } from "./roll/roll-constants.mjs";
import { OptionsAvancees, ROLL_DIALOG_V2_TEST } from "./settings/options-avancees.js";
/* -------------------------------------------- */
const premierRoundInit = [
@@ -402,19 +403,19 @@ export class RdDCombat {
/* -------------------------------------------- */
static registerChatCallbacks(html) {
for (let button of [
'.defense-button',
'.parer-button',
'.esquiver-button',
'.button-defense',
'.button-parade',
'.button-esquive',
'.button-encaisser',
'.particuliere-attaque',
'.encaisser-button',
'.appel-chance-defense',
'.appel-destinee-defense',
'.appel-chance-attaque',
'.appel-destinee-attaque',
'.echec-total-attaque',
'.appel-chance',
'.chat-encaissement',
'.resister-recul',
// '.appel-chance',
// '.chat-encaissement',
// '.resister-recul',
]) {
$(html).on("click", button, event => {
const rddCombat = RdDCombat.rddCombatForAttackerAndDefender(
@@ -474,11 +475,11 @@ export class RdDCombat {
switch (button) {
case '.particuliere-attaque': return await this.choixParticuliere(attackerRoll, event.currentTarget.attributes['data-mode'].value);
case '.defense-button': return this.defenseV2(attackerRoll);
case '.button-defense': return this.defenseV2(attackerRoll);
case '.parer-button': return this.parade(attackerRoll, armeParadeId);
case '.esquiver-button': return this.esquive(attackerRoll, compId, competence);
case '.encaisser-button': return this.encaisser(attackerRoll, defenderRoll);
case '.button-parade': return this.parade(attackerRoll, armeParadeId);
case '.button-esquive': return this.esquive(attackerRoll, compId, competence);
case '.button-encaisser': return this.encaisser(attackerRoll, defenderRoll);
case '.echec-total-attaque': return this._onEchecTotal(attackerRoll);
case '.appel-chance-attaque': return this.attacker.rollAppelChance(
@@ -488,11 +489,9 @@ export class RdDCombat {
() => this.defenseChanceuse(attackerRoll, defenderRoll),
() => this.afficherOptionsDefense(attackerRoll, defenderRoll, { defenseChance: true }));
case '.appel-destinee-attaque': return this.attacker.appelDestinee(
() => this.attaqueSignificative(attackerRoll),
() => { });
() => this.attaqueSignificative(attackerRoll));
case '.appel-destinee-defense': return this.defender.appelDestinee(
() => this.defenseDestinee(defenderRoll),
() => { });
() => this.defenseDestinee(defenderRoll));
}
}
@@ -969,10 +968,8 @@ export class RdDCombat {
}
async defenseV2(attackerRoll) {
// this._prepareParade(attackerRoll, arme, competence);
const rollData =
{
await this.doRollDefense({
ids: {
actorId: this.defender.id,
actorTokenId: this.defenderTokenId,
@@ -982,24 +979,26 @@ export class RdDCombat {
type: { allowed: ['defense'], current: 'defense' },
attackerRoll: RollDialogAdapter.mapActionAttaque(attackerRoll),
passeArme: attackerRoll.passeArme,
}
await RollDialog.create(rollData, {
onRollDone: (dialog) => {
// dialog.close()
},
customChatMessage: true,
callbacks: [async (roll) => {
this.removeChatMessageActionsPasseArme(roll.passeArme)
// defense: esquive / arme de parade / competence de défense
if (!RdDCombat.isParticuliere(roll)) {
await roll.active.actor.incDecItemUse(roll.current[PART_DEFENSE].defense?.id,)
}
await this._onDefense(roll)
}]
})
}
async doRollDefense(rollData) {
await RollDialog.create(rollData, {
onRollDone: (dialog) => {
if (!OptionsAvancees.isUsing(ROLL_DIALOG_V2_TEST))
dialog.close()
},
customChatMessage: true,
callbacks: [async (roll) => {
this.removeChatMessageActionsPasseArme(roll.passeArme);
// defense: esquive / arme de parade / competence de défense
if (!RdDCombat.isParticuliere(roll)) {
await roll.active.actor.incDecItemUse(roll.current[PART_DEFENSE].defense?.id);
}
await this._onDefense(roll);
}]
})
}
/* -------------------------------------------- */
_prepareParade(attackerRoll, armeParade, competenceParade) {
@@ -1369,6 +1368,3 @@ export class RdDCombat {
}
}
function newFunction(attackerRoll) {
return attackerRoll.diffLibre;
}

View File

@@ -86,6 +86,7 @@ import { RdDCombatManager, RdDCombat } from "./rdd-combat.js"
import { Migrations } from './migrations.js'
import RollDialog from "./roll/roll-dialog.mjs"
import ChatRollResult from "./roll/chat-roll-result.mjs"
/**
* RdD system
@@ -292,6 +293,7 @@ export class SystemReveDeDragon {
TMRRencontres.init()
ExportScriptarium.init()
RollDialog.init()
ChatRollResult.init()
}
initSettings() {
@@ -346,18 +348,7 @@ export class SystemReveDeDragon {
})
}
static async setupAccueil() {
let exists = game.scenes.find(j => j.name == "Accueil RdD");
if (!exists) {
const scenes = await SystemCompendiums.loadCompendium("foundryvtt-reve-de-dragon.scenes-rdd")
let newDocuments = scenes.filter(i => i.name == "Accueil RdD");
await game.scenes.documentClass.create(newDocuments);
game.scenes.find(i => i.name == "Accueil RdD").activate();
}
}
async onReady() {
/* -------------------------------------------- */
/* Foundry VTT Initialization */
/* -------------------------------------------- */
@@ -376,7 +367,8 @@ export class SystemReveDeDragon {
StatusEffects.onReady()
RdDDice.onReady()
RollDialog.onReady()
RdDStatBlockParser.parseStatBlock()
ChatRollResult.onReady()
/* -------------------------------------------- */
/* Affiche/Init le calendrier */
game.system.rdd.calendrier.display()
@@ -389,7 +381,17 @@ export class SystemReveDeDragon {
})
}
SystemReveDeDragon.setupAccueil()
this.setupAccueil()
}
async setupAccueil() {
let exists = game.scenes.find(j => j.name == "Accueil RdD");
if (!exists) {
const scenes = await SystemCompendiums.loadCompendium("foundryvtt-reve-de-dragon.scenes-rdd")
let newDocuments = scenes.filter(i => i.name == "Accueil RdD");
await game.scenes.documentClass.create(newDocuments);
game.scenes.find(i => i.name == "Accueil RdD").activate();
}
}
/* -------------------------------------------- */

View File

@@ -157,7 +157,7 @@ export class RdDResolutionTable {
/* -------------------------------------------- */
static significativeRequise(chances) {
chances.roll = Math.floor(chances.score / 2);
chances.roll = Math.min(chances.part + 1, chances.sign)
foundry.utils.mergeObject(chances, reussites.find(x => x.code == 'sign'), { overwrite: true });
}
@@ -188,7 +188,7 @@ export class RdDResolutionTable {
static computeReussite(chances, roll, diviseur) {
const reussite = reussites.find(x => x.condition(chances, roll))
if (diviseur > 1 && reussite.isSuccess) {
if (chances > roll * diviseur){
if (chances > roll * diviseur) {
return reussiteInsuffisante
}
}

View File

@@ -1,8 +1,16 @@
import { ChatUtility } from "../chat-utility.js"
import RollDialog from "./roll-dialog.mjs"
import { RdDCarac } from "../rdd-carac.js";
import { RdDCarac } from "../rdd-carac.js"
import { RdDCombat } from "../rdd-combat.js"
import { ROLL_TYPE_ATTAQUE, ROLL_TYPE_DEFENSE } from "./roll-constants.mjs"
import { RdDResolutionTable } from "../rdd-resolution-table.js"
export class ChatRollResult {
export default class ChatRollResult {
static init() {
ChatRollResult.instance = new ChatRollResult()
Hooks.on('renderChatLog', (log, html, chatLog) => ChatRollResult.instance.chatListeners(html))
}
static onReady() {
foundry.applications.handlebars.loadTemplates({
@@ -14,10 +22,7 @@ export class ChatRollResult {
}
async display(roll) {
roll.show = roll.show || {};
roll.show.chance = this.isAppelChancePossible(roll)
roll.show.encaissement = this.isShowEncaissement(roll)
roll.show.recul = this.isShowReculChoc(roll)
this.prepareDisplay(roll)
const chatMessage = await ChatUtility.createChatWithRollMode(
{
@@ -26,14 +31,18 @@ export class ChatRollResult {
roll.active.actor,
roll.current?.rollmode?.key
)
if (roll.show.chance) {
const save = RollDialog.saveParts(roll)
console.log("Store message roll", save)
ChatUtility.setMessageData(chatMessage, 'rollData', save)
}
const save = RollDialog.saveParts(roll)
ChatUtility.setMessageData(chatMessage, 'rollData', save)
return chatMessage
}
prepareDisplay(roll) {
roll.show = roll.show || {}
roll.show.chance = this.isAppelChancePossible(roll)
roll.show.encaissement = this.isShowEncaissement(roll)
roll.show.recul = this.isShowReculChoc(roll)
}
isAppelChancePossible(roll) {
return roll.active.actor.isPersonnage() &&
roll.rolled.isEchec &&
@@ -46,14 +55,87 @@ export class ChatRollResult {
}
isShowReculChoc(roll) {
return roll.rolled.isEchec &&
roll.attackerRoll &&
!roll.current.defense.isEsquive &&
(roll.attackerRoll.particuliere == 'force' || 'charge' == attackerRoll.tactique?.key)
const attaque = roll.attackerRoll
return attaque &&
(roll.rolled.isEchec || !roll.current.defense.isEsquive) &&
(attaque.particuliere == 'force' || 'charge' == attaque.tactique?.key)
}
async buildRollHtml(roll) {
const template = `systems/foundryvtt-reve-de-dragon/templates/roll/result/chat-${roll.type.current}.hbs`
return await foundry.applications.handlebars.renderTemplate(template, roll)
}
async chatListeners(html) {
$(html).on("click", '.appel-chance', event => this.onClickAppelChance(event))
$(html).on("click", '.appel-destinee', event => this.onClickAppelDestinee(event))
}
onClickAppelChance(event) {
const chatMessage = ChatUtility.getChatMessage(event)
const savedRoll = ChatUtility.getMessageData(chatMessage, 'rollData')
const actor = game.actors.get(savedRoll.ids.actorId)
actor.rollAppelChance(
() => this.onAppelChanceSuccess(savedRoll, chatMessage),
() => this.onAppelChanceEchec(savedRoll, chatMessage))
event.preventDefault()
}
getCombat(roll) {
switch (roll.type.current) {
case ROLL_TYPE_DEFENSE:
return RdDCombat.rddCombatForAttackerAndDefender(roll.ids.opponentId, roll.ids.opponentTokenId, roll.ids.actorId)
case ROLL_TYPE_ATTAQUE:
return RdDCombat.rddCombatForAttackerAndDefender(roll.ids.actorId, roll.ids.actorTokenId, roll.ids.opponentId)
}
return undefined
}
onAppelChanceSuccess(savedRoll, chatMessage) {
const reRoll = foundry.utils.duplicate(savedRoll)
reRoll.type.retry = true
// TODO: annuler les effets
switch (reRoll.type.current) {
case ROLL_TYPE_DEFENSE:
this.getCombat(reRoll)?.doRollDefense(reRoll)
break
case ROLL_TYPE_ATTAQUE:
this.getCombat(reRoll)?.doRollAttaque(reRoll)
break
default: {
RollDialog.create(reRoll)
}
}
ChatUtility.removeChatMessageId(chatMessage.id)
}
async onAppelChanceEchec(savedRoll, chatMessage) {
savedRoll.type.retry = true
await this.updateChatMessage(chatMessage, savedRoll)
}
async updateChatMessage(chatMessage, savedRoll) {
ChatUtility.setMessageData(chatMessage, 'rollData', savedRoll)
const copy = foundry.utils.duplicate(savedRoll)
RollDialog.loadRollData(copy)
this.prepareDisplay(copy)
chatMessage.update({ content: await this.buildRollHtml(copy) })
chatMessage.render(true)
}
onClickAppelDestinee(event) {
const chatMessage = ChatUtility.getChatMessage(event)
const savedRoll = ChatUtility.getMessageData(chatMessage, 'rollData')
const actor = game.actors.get(savedRoll.ids.actorId)
actor.appelDestinee(async () => {
const reRoll = foundry.utils.duplicate(savedRoll)
reRoll.type.retry = true
RdDResolutionTable.significativeRequise(reRoll.rolled)
await this.updateChatMessage(chatMessage, savedRoll)
})
event.preventDefault()
}
}

View File

@@ -41,9 +41,7 @@ export class RollBasicParts {
initFrom(rollData) {
return {
selected: {},
type: {
current: rollData.type.current
},
type: rollData.type,
ids: {
sceneId: rollData.ids.sceneId,
actorId: rollData.active.id,

View File

@@ -25,7 +25,7 @@ import { RollPartMeditation } from "./roll-part-meditation.mjs";
import { RollPartMoral } from "./roll-part-moral.mjs";
import { RollPartOpponent } from "./roll-part-opponent.mjs";
import { RollPartSurEnc } from "./roll-part-surenc.mjs";
import { RollPartTricher } from "./roll-part-tricher.mjs";
import { PART_TRICHER, RollPartTricher } from "./roll-part-tricher.mjs";
import { RollPartTache } from "./roll-part-tache.mjs";
import { RollPartOeuvre } from "./roll-part-oeuvre.mjs";
import { RollPartSort } from "./roll-part-sort.mjs";
@@ -38,7 +38,7 @@ import { RollPartDefense } from "./roll-part-defense.mjs";
import { RollDialogAdapter } from "./roll-dialog-adapter.mjs";
import { ROLLDIALOG_SECTION } from "./roll-part.mjs";
import { ROLL_TYPE_COMP } from "./roll-constants.mjs";
import { ChatRollResult } from "./chat-roll-result.mjs";
import ChatRollResult from "./chat-roll-result.mjs";
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api
@@ -286,6 +286,8 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
ROLL_PARTS.filter(p => p.isActive(rollData))
.forEach(p => p.storeClean(rollData, target))
target.attackerRoll = rollData.attackerRoll
target.rolled = rollData.rolled
target.result = rollData.result
return target
}
@@ -317,8 +319,8 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
}
getActiveParts() {
return ROLL_PARTS.filter(p => p.isActive(this.rollData))
static getActiveParts(rollData) {
return ROLL_PARTS.filter(p => p.isActive(rollData))
}
// get title() {
@@ -353,12 +355,12 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
))
Promise.all(
this.getActiveParts().map(async p => await p._onRender(this, context, options))
RollDialog.getActiveParts(this.rollData).map(async p => await p._onRender(this, context, options))
)
}
getAjustements(rollData = this.rollData) {
return this.getActiveParts()
static getAjustements(rollData) {
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)
@@ -373,19 +375,19 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
const types = ALL_ROLL_TYPES.filter(m => m.isAllowed(rollData) && m.visible(rollData))
.map(m => m.toTypeData(rollData))
BASIC_PARTS.loadSurprises(this.rollData, this.getSelectedType().code)
this.rollData.type.label = this.getSelectedType()?.title(this.rollData)
BASIC_PARTS.loadSurprises(rollData, this.getSelectedType().code)
rollData.type.label = this.getSelectedType()?.title(rollData)
//TOCHECK: set type.label ?
const visibleRollParts = this.getActiveParts()
const visibleRollParts = RollDialog.getActiveParts(rollData)
visibleRollParts.forEach(p => p.applyExternalImpacts(visibleRollParts, rollData))
this.setSpecialComp(visibleRollParts);
visibleRollParts.forEach(p => p.prepareContext(rollData))
this.calculAjustements()
RollDialog.calculAjustements(rollData)
const templates = this.getActiveParts().map(p => p.toTemplateData())
const templates = RollDialog.getActiveParts(rollData).map(p => p.toTemplateData())
const context = await super._prepareContext()
return foundry.utils.mergeObject(
{
@@ -399,14 +401,14 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
const specialComp = visibleRollParts.map(p => p.getSpecialComp(this.rollData))
.reduce((a, b) => a.concat(b))
if (specialComp.length > 0) {
const rollPartComp = this.getActiveParts()
const rollPartComp = RollDialog.getActiveParts(this.rollData)
.find(it => it.code == PART_COMP);
rollPartComp?.setSpecialComp(this.rollData, specialComp)
}
}
calculAjustements(rollData = this.rollData) {
rollData.ajustements = this.getAjustements(rollData)
static calculAjustements(rollData) {
rollData.ajustements = RollDialog.getAjustements(rollData)
rollData.ajustements.forEach(it => it.isDiff = it.diff != undefined)
rollData.current.totaldiff = rollData.ajustements
.map(adj => adj.diff)
@@ -419,12 +421,12 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
}
async roll() {
// ROLL_PARTS.filter(p => p.isActive(this.rollData))
// .forEach(p => p.validate(this.rollData))
const roll = RollDialog.saveParts(this.rollData)
RollDialog.$prepareRollData(roll)
this.calculAjustements(roll)
roll.current.resultat = this.rollData.current.resultat
roll.v2 = true
RollDialog.loadRollData(roll)
roll.current.resultat = this.rollData.current[PART_TRICHER]?.resultat ?? -1
roll.rolled = await this.$rollDice(roll)
roll.result = this.getSelectedType(roll).getResult(roll)
console.info('RollDialog.roll:', roll)
@@ -434,12 +436,18 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
this.rollOptions.onRollDone(this)
}
static loadRollData(roll) {
RollDialog.$prepareRollData(roll)
RollDialog.calculAjustements(roll)
roll.v2 = true
}
async defaultCallback(rollData, rolled) {
await rollData.active.actor.appliquerAjoutExperience(rollData)
await rollData.active.actor.appliquerAppelMoral(rollData)
}
async $rollDice(rollData) {
return await RollDialogAdapter.rollDice(rollData, this.rollTitle(rollData));
return await RollDialogAdapter.rollDice(rollData, this.rollTitle(rollData))
}
}

View File

@@ -1,4 +1,5 @@
import { SYSTEM_RDD } from "../constants.js";
import { Misc } from "../misc.js";
import { ROLLDIALOG_SECTION, RollPart } from "./roll-part.mjs";
const CONDITIONS = "conditions"
@@ -50,7 +51,7 @@ export class RollPartConditions extends RollPart {
const current = this.getCurrent(rollData)
current.min = game.settings.get(SYSTEM_RDD, this.settingMin())
current.max = game.settings.get(SYSTEM_RDD, this.settingMax())
current.value = current.value ?? 0
current.value = Misc.inRange(current.value ?? 0, current.min, current.max)
}
getAjustements(rollData) {
@@ -63,12 +64,13 @@ export class RollPartConditions extends RollPart {
async _onRender(rollDialog, context, options) {
const input = rollDialog.element.querySelector(`roll-section[name="${this.code}"] input[name="${this.code}"]`)
input?.addEventListener("change", e => {
const current = this.getCurrent(rollDialog.rollData)
current.value = parseInt(e.currentTarget.value)
rollDialog.render()
})
input?.addEventListener("input", e => this.onInputChange(e, rollDialog))
}
onInputChange(event, rollDialog) {
this.getCurrent(rollDialog.rollData).value = parseInt(event.currentTarget.value)
rollDialog.render()
}
}

View File

@@ -1,5 +1,6 @@
import { DIFF, DIFFS, ROLL_TYPE_MEDITATION, ROLL_TYPE_OEUVRE, ROLL_TYPE_SORT, ROLL_TYPE_TACHE } from "./roll-constants.mjs";
import { ROLLDIALOG_SECTION, RollPart } from "./roll-part.mjs";
import { Misc } from "../misc.js";
export const PART_DIFF = "diff"
@@ -41,8 +42,8 @@ export class RollPartDiff extends RollPart {
{
type: diffType.key,
label: diffType?.label ?? '',
value: current.value ?? 0,
disabled: !diffType.libre,
value: Misc.inRange(current.value ?? 0, -10, diffType.max),
min: -10,
max: diffType.max
},
@@ -67,11 +68,12 @@ export class RollPartDiff extends RollPart {
async _onRender(rollDialog, context, options) {
const input = rollDialog.element.querySelector(`roll-section[name="${this.code}"] input[name="${this.code}"]`)
input?.addEventListener("change", e => {
this.getCurrent(rollDialog.rollData).value = parseInt(e.currentTarget.value)
rollDialog.render()
})
input?.addEventListener("input", e => this.onInputChange(e, rollDialog))
}
onInputChange(event, rollDialog) {
this.getCurrent(rollDialog.rollData).value = parseInt(event.currentTarget.value)
rollDialog.render()
}
}

View File

@@ -1,3 +1,4 @@
import { Misc } from "../misc.js"
import { ROLLDIALOG_SECTION, RollPart } from "./roll-part.mjs"
export const PART_TRICHER = "tricher"
@@ -11,21 +12,20 @@ export class RollPartTricher extends RollPart {
prepareContext(rollData) {
const current = this.getCurrent(rollData)
if (current.resultat == undefined) {
current.resultat = -1
}
current.resultat = Misc.inRange(current.resultat == undefined ? -1 : current.resultat, -1, 100)
}
getAjustements(rollData) {
rollData.current.resultat = this.getCurrent(rollData).resultat
return []
}
async _onRender(rollDialog, context, options) {
const input = rollDialog.element.querySelector(`roll-section[name="${this.code}"] input[name="${this.code}"]`)
input?.addEventListener("change", e => {
this.getCurrent(rollDialog.rollData).resultat = parseInt(e.currentTarget.value)
})
input?.addEventListener("input", e => this.onInputChange(e, rollDialog))
}
onInputChange(event, rollDialog) {
this.getCurrent(rollDialog.rollData).resultat = parseInt(event.currentTarget.value)
}
}

View File

@@ -1,5 +1,3 @@
import { Misc } from "../misc.js"
export const ROLLDIALOG_SECTION = {
ACTION: 'action',
CARAC: 'carac',
@@ -86,6 +84,9 @@ export class RollPart {
loadRefs(rollData) { }
prepareContext(rollData) { }
/** permet de sauvegarder dans rollData les informations (cas des champs edit) */
validate(rollData) {}
/** ---- cross roll-part filtering ---- */
applyImpact(rollData, filter) { }
@@ -108,14 +109,4 @@ export class RollPart {
async _onRender(rollDialog, context, options) { }
addResult(rollData) {
const result = this.getResult(rollData)
if (result){
rollData.result[this.code] = result
}
}
getResult(rollData){
return undefined
}
}

View File

@@ -3,9 +3,11 @@ import { Misc } from "../misc.js"
export const EXPORT_CSV_SCRIPTARIUM = 'export-csv-scriptarium'
export const ROLL_DIALOG_V2 = 'roll-dialog-v2'
export const ROLL_DIALOG_V2_TEST = 'roll-dialog-v2-test'
const OPTIONS_AVANCEES = [
{ group: 'Fenêtres', name: ROLL_DIALOG_V2, descr: "Utiliser les nouvelles fenêtres de jet", default: false },
{ group: 'Fenêtres', name: ROLL_DIALOG_V2_TEST, descr: "Mode de test des nouvelles fenêtres", default: false },
{ group: 'Menus', name: EXPORT_CSV_SCRIPTARIUM, descr: "Proposer le menu d'export csv Scriptarium", default: false },
]
@@ -56,7 +58,7 @@ export class OptionsAvancees extends FormApplication {
return formData
}
static getSettingKey(name){
static getSettingKey(name) {
return `${SYSTEM_RDD}.${this._getId(name)}`
}

View File

@@ -36,7 +36,7 @@
{{/unless}}
{{else}}
{{#if (settings-get 'rdd-advanced-roll-dialog-v2')}}
<a class='chat-card-button defense-button'
<a class='chat-card-button button-defense'
data-attackerId='{{attackerId}}'
data-attackerTokenId='{{attackerToken.id}}'
data-defenderTokenId='{{defenderToken.id}}'
@@ -51,7 +51,7 @@
<br>
{{else}}
{{#each armes as |arme key|}}
<a class='chat-card-button parer-button'
<a class='chat-card-button button-parade'
data-attackerId='{{../attackerId}}' data-defenderTokenId='{{../defenderToken.id}}' data-attackerTokenId='{{../attackerToken.id}}'
data-armeid='{{arme._id}}'>
Parer avec {{arme.name}}
@@ -67,7 +67,7 @@
<br>
{{/each}}
{{#if mainsNues}}
<a class='chat-card-button parer-button'
<a class='chat-card-button button-parade'
data-attackerId='{{attackerId}}' data-defenderTokenId='{{defenderToken.id}}' data-attackerTokenId='{{attackerToken.id}}'
data-armeid='{{arme._id}}' data-competence='{{arme.system.competence}}'>
Parer à mains nues à {{diffLibre}}{{#if arme.nbUsage}} (Utilisations : {{arme.nbUsage}}){{/if}}
@@ -76,7 +76,7 @@
{{/if}}
{{#if (ne attaqueCategorie 'tir')}}
{{#each esquives as |esquive key|}}
<a class='chat-card-button esquiver-button'
<a class='chat-card-button button-esquive'
data-attackerId='{{../attackerId}}' data-defenderTokenId='{{../defenderToken.id}}' data-attackerTokenId='{{../attackerToken.id}}'
data-compid='{{esquive._id}}' data-competence='{{esquive.name}}'>
{{esquive.name}}
@@ -92,7 +92,7 @@
{{/if}}
{{/if}}
{{/unless}}
<a class='chat-card-button encaisser-button'
<a class='chat-card-button button-encaisser'
data-attackerId='{{attackerId}}' data-defenderTokenId='{{defenderToken.id}}' data-attackerTokenId='{{attackerToken.id}}'>
Encaisser à {{plusMoins dmg.total}}
{{#if (eq dmg.mortalite 'non-mortel')~}}

View File

@@ -1,3 +1,4 @@
{{log this}}
<div class="roll-chat">
<div class="chat-img">

View File

@@ -1,9 +1,9 @@
{{#if show.encaissement}}
<a class='chat-card-button encaisser-button'
data-actorId='{{ids.actorId}}'
<a class='chat-card-button button-encaisser'
{{!-- data-actorId='{{ids.actorId}}'
data-actorTokenId='{{ids.actorTokenId}}'
data-opponentId='{{ids.opponentId}}'
data-opponentTokenId='{{ids.opponentTokenId}}'
data-opponentTokenId='{{ids.opponentTokenId}}' --}}
data-tooltip="Encaisser à {{plusMoins attackerRoll.dmg.total}} {{#if (eq attackerRoll.dmg.mortalite 'non-mortel')~}}(non-mortel){{/if}}"
>
<img src="systems/foundryvtt-reve-de-dragon/assets/ui/encaisser.svg"/> Encaisser à {{plusMoins attackerRoll.dmg.total}}

View File

@@ -1,4 +1,6 @@
<input name="{{code}}" type="checkbox" {{#if current.checked}}checked{{/if}}/>
<input name="{{code}}" type="checkbox"
{{#if current.checked}}checked{{/if}}
{{#if rollData.type.retry}}disabled{{/if}}/>
<label for="{{code}}" data-tooltip="Moral: {{plusMoins refs.moral}}">
{{#if current.icon}}{{{current.icon}}}{{/if}}{{refs.label}}
</label>

View File

@@ -1,2 +1,4 @@
<input name="{{code}}" type="checkbox" {{#if current.checked}}checked{{/if}}/>
<input name="{{code}}" type="checkbox"
{{#if current.checked}}checked{{/if}}
{{#if rollData.type.retry}}disabled{{/if}}/>
<label for="{{code}}">{{refs.label}}</label>

View File

@@ -1,3 +1,5 @@
<input name="{{code}}" type="checkbox" {{#if current.checked}}checked{{/if}}/>
<input name="{{code}}" type="checkbox"
{{#if current.checked}}checked{{/if}}
{{#if rollData.type.retry}}disabled{{/if}}/>
{{#if current.icon}}{{{current.icon}}}{{/if}}
<label for="{{code}}">{{either current.label refs.label}} : {{plusMoins current.value}}</label>

View File

@@ -1,4 +1,6 @@
<input name="{{code}}" type="checkbox" {{#if current.checked}}checked{{/if}}/>
<input name="{{code}}" type="checkbox"
{{#if current.checked}}checked{{/if}}
{{#if rollData.type.retry}}disabled{{/if}}/>
<label for="{{code}}">
{{#if current.icon}}{{{current.icon}}}{{/if}}
{{current.label}}

View File

@@ -1 +0,0 @@
<span>: {{current.item.name}}</span>