Fix after testing
This commit is contained in:
@@ -29,26 +29,16 @@ export class HeritiersRollDialog {
|
||||
// Préparer les boutons selon le mode et le niveau
|
||||
const buttons = this._prepareButtons(rollData)
|
||||
|
||||
// Lancer le dialog de manière asynchrone (sans attendre)
|
||||
setTimeout(() => {
|
||||
foundry.applications.api.DialogV2.wait({
|
||||
window: { title: "Test de Capacité", icon: "fa-solid fa-dice" },
|
||||
classes: ["heritiers-roll-dialog"],
|
||||
position: { width: 420, height: 'fit-content' },
|
||||
modal: false,
|
||||
content,
|
||||
buttons,
|
||||
rejectClose: false,
|
||||
render: (event, html) => {
|
||||
this._activateListeners(html, rollData)
|
||||
}
|
||||
})
|
||||
}, 0)
|
||||
|
||||
// Retourner un objet avec une méthode render() vide pour compatibilité
|
||||
return {
|
||||
render: () => {} // No-op for compatibility with old code
|
||||
}
|
||||
// Utiliser DialogV2.wait avec le HTML rendu
|
||||
return foundry.applications.api.DialogV2.wait({
|
||||
window: { title: "Test de Capacité", icon: "fa-solid fa-dice" },
|
||||
classes: ["heritiers-roll-dialog"],
|
||||
position: { width: 420 },
|
||||
modal: false,
|
||||
content,
|
||||
buttons,
|
||||
rejectClose: false
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,7 +53,7 @@ export class HeritiersRollDialog {
|
||||
// Bouton d8 toujours disponible
|
||||
buttons.push({
|
||||
action: "rolld8",
|
||||
label: "Lancer 1d8",
|
||||
label: "1d8",
|
||||
icon: "fa-solid fa-dice-d8",
|
||||
default: true,
|
||||
callback: (event, button, dialog) => {
|
||||
@@ -77,7 +67,7 @@ export class HeritiersRollDialog {
|
||||
if (enableD10) {
|
||||
buttons.push({
|
||||
action: "rolld10",
|
||||
label: "Lancer 1d10",
|
||||
label: "1d10",
|
||||
icon: "fa-solid fa-dice-d10",
|
||||
callback: (event, button, dialog) => {
|
||||
this._updateRollDataFromForm(rollData, button.form.elements)
|
||||
@@ -91,7 +81,7 @@ export class HeritiersRollDialog {
|
||||
if (enableD12) {
|
||||
buttons.push({
|
||||
action: "rolld12",
|
||||
label: "Lancer 1d12",
|
||||
label: "1d12",
|
||||
icon: "fa-solid fa-dice-d12",
|
||||
callback: (event, button, dialog) => {
|
||||
this._updateRollDataFromForm(rollData, button.form.elements)
|
||||
@@ -104,7 +94,7 @@ export class HeritiersRollDialog {
|
||||
if (rollData.tricherie) {
|
||||
buttons.push({
|
||||
action: "rollTricherie",
|
||||
label: "Lancer avec 1 Point de Tricherie",
|
||||
label: "Lancer 1 Tricherie",
|
||||
icon: "fa-solid fa-mask",
|
||||
callback: (event, button, dialog) => {
|
||||
this._updateRollDataFromForm(rollData, button.form.elements)
|
||||
@@ -117,7 +107,7 @@ export class HeritiersRollDialog {
|
||||
if (rollData.heritage) {
|
||||
buttons.push({
|
||||
action: "rollHeritage",
|
||||
label: "Lancer avec 1 Point d'Héritage",
|
||||
label: "Lancer 1 Héritage",
|
||||
icon: "fa-solid fa-crown",
|
||||
callback: (event, button, dialog) => {
|
||||
this._updateRollDataFromForm(rollData, button.form.elements)
|
||||
@@ -145,94 +135,6 @@ export class HeritiersRollDialog {
|
||||
return buttons
|
||||
}
|
||||
|
||||
/**
|
||||
* Activer les listeners sur le formulaire
|
||||
* @param {HTMLElement} html - L'élément HTML du dialog
|
||||
* @param {Object} rollData - Data for the roll
|
||||
* @private
|
||||
*/
|
||||
static _activateListeners(html, rollData) {
|
||||
// Seuil de Difficulté
|
||||
const sdValue = html.querySelector('#sdValue')
|
||||
if (sdValue) {
|
||||
sdValue.addEventListener('change', (event) => {
|
||||
rollData.sdValue = Number(event.currentTarget.value)
|
||||
})
|
||||
}
|
||||
|
||||
// Caractéristique
|
||||
const caracKey = html.querySelector('#caracKey')
|
||||
if (caracKey) {
|
||||
caracKey.addEventListener('change', (event) => {
|
||||
rollData.caracKey = String(event.currentTarget.value)
|
||||
})
|
||||
}
|
||||
|
||||
// Bonus/Malus contextuel
|
||||
const bonusMalusContext = html.querySelector('#bonus-malus-context')
|
||||
if (bonusMalusContext) {
|
||||
bonusMalusContext.addEventListener('change', (event) => {
|
||||
rollData.bonusMalusContext = Number(event.currentTarget.value)
|
||||
})
|
||||
}
|
||||
|
||||
// Attaque à plusieurs
|
||||
const bonusAttaquePlusieurs = html.querySelector('#bonus-attaque-plusieurs')
|
||||
if (bonusAttaquePlusieurs) {
|
||||
bonusAttaquePlusieurs.addEventListener('change', (event) => {
|
||||
rollData.bonusAttaquePlusieurs = Number(event.currentTarget.value)
|
||||
})
|
||||
}
|
||||
|
||||
// Spécialité
|
||||
const useSpecialite = html.querySelector('#useSpecialite')
|
||||
if (useSpecialite) {
|
||||
useSpecialite.addEventListener('change', (event) => {
|
||||
rollData.useSpecialite = event.currentTarget.checked
|
||||
})
|
||||
}
|
||||
|
||||
// Points d'usage du pouvoir
|
||||
const pouvoirPointsUsage = html.querySelector('#pouvoirPointsUsage')
|
||||
if (pouvoirPointsUsage) {
|
||||
pouvoirPointsUsage.addEventListener('change', (event) => {
|
||||
rollData.pouvoirPointsUsage = Number(event.currentTarget.value)
|
||||
})
|
||||
}
|
||||
|
||||
// Attaque dans le dos
|
||||
const attaqueDos = html.querySelector('#attaqueDos')
|
||||
if (attaqueDos) {
|
||||
attaqueDos.addEventListener('change', (event) => {
|
||||
rollData.attaqueDos = event.currentTarget.checked
|
||||
})
|
||||
}
|
||||
|
||||
// Seconde arme
|
||||
const secondeArme = html.querySelector('#bonus-attaque-seconde-arme')
|
||||
if (secondeArme) {
|
||||
secondeArme.addEventListener('change', (event) => {
|
||||
rollData.secondeArme = String(event.currentTarget.value)
|
||||
})
|
||||
}
|
||||
|
||||
// Attaque ciblée
|
||||
const attaqueCible = html.querySelector('#attaque-cible')
|
||||
if (attaqueCible) {
|
||||
attaqueCible.addEventListener('change', (event) => {
|
||||
rollData.attaqueCible = String(event.currentTarget.value)
|
||||
})
|
||||
}
|
||||
|
||||
// Attaque à deux armes
|
||||
const attaqueDeuxArmes = html.querySelector('#bonus-attaque-deux-armes')
|
||||
if (attaqueDeuxArmes) {
|
||||
attaqueDeuxArmes.addEventListener('change', (event) => {
|
||||
rollData.attaqueDeuxArmes = Number(event.currentTarget.value)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mettre à jour rollData avec les valeurs du formulaire
|
||||
* @param {Object} rollData - L'objet rollData à mettre à jour
|
||||
@@ -305,7 +207,7 @@ export class HeritiersRollDialog {
|
||||
} else {
|
||||
rollData.mainDice = dice
|
||||
}
|
||||
|
||||
|
||||
HeritiersUtility.rollHeritiers(rollData)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ export default class HeritiersAccessoireSheet extends HeritiersItemSheet {
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
sheet: {
|
||||
template: "systems/fvtt-les-heritiers/templates/item-accessoire-sheet.html",
|
||||
template: "systems/fvtt-les-heritiers/templates/item-accessoire-sheet.hbs",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ export default class HeritiersArmeSheet extends HeritiersItemSheet {
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
sheet: {
|
||||
template: "systems/fvtt-les-heritiers/templates/item-arme-sheet.html",
|
||||
template: "systems/fvtt-les-heritiers/templates/item-arme-sheet.hbs",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ export default class HeritiersAtoutFeeriqueSheet extends HeritiersItemSheet {
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
sheet: {
|
||||
template: "systems/fvtt-les-heritiers/templates/item-atoutfeerique-sheet.html",
|
||||
template: "systems/fvtt-les-heritiers/templates/item-atoutfeerique-sheet.hbs",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ export default class HeritiersAvantageSheet extends HeritiersItemSheet {
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
sheet: {
|
||||
template: "systems/fvtt-les-heritiers/templates/item-avantage-sheet.html",
|
||||
template: "systems/fvtt-les-heritiers/templates/item-avantage-sheet.hbs",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,10 @@ export default class HeritiersActorSheet extends HandlebarsApplicationMixin(foun
|
||||
createItem: HeritiersActorSheet.#onCreateItem,
|
||||
equipItem: HeritiersActorSheet.#onEquipItem,
|
||||
modifyQuantity: HeritiersActorSheet.#onModifyQuantity,
|
||||
quantityIncrease: HeritiersActorSheet.#onQuantityIncrease,
|
||||
quantityDecrease: HeritiersActorSheet.#onQuantityDecrease,
|
||||
pvIncrease: HeritiersActorSheet.#onPvIncrease,
|
||||
pvDecrease: HeritiersActorSheet.#onPvDecrease,
|
||||
rollInitiative: HeritiersActorSheet.#onRollInitiative,
|
||||
rollCarac: HeritiersActorSheet.#onRollCarac,
|
||||
rollRang: HeritiersActorSheet.#onRollRang,
|
||||
@@ -78,7 +82,7 @@ export default class HeritiersActorSheet extends HandlebarsApplicationMixin(foun
|
||||
* Tab groups state
|
||||
* @type {object}
|
||||
*/
|
||||
tabGroups = { primary: "stats" }
|
||||
tabGroups = { primary: "competences" }
|
||||
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
@@ -370,18 +374,18 @@ export default class HeritiersActorSheet extends HandlebarsApplicationMixin(foun
|
||||
*/
|
||||
static async #onCreateItem(event, target) {
|
||||
const itemType = target.dataset.type
|
||||
|
||||
|
||||
// Cas spécial pour les sorts avec une compétence spécifique
|
||||
if (itemType === "sort" && target.dataset.sortCompetence) {
|
||||
const sortCompetence = target.dataset.sortCompetence
|
||||
await this.actor.createEmbeddedDocuments('Item', [{
|
||||
name: `Nouveau ${itemType} de ${sortCompetence}`,
|
||||
type: itemType,
|
||||
system: { competence: sortCompetence }
|
||||
await this.actor.createEmbeddedDocuments('Item', [{
|
||||
name: `Nouveau ${itemType} de ${sortCompetence}`,
|
||||
type: itemType,
|
||||
system: { competence: sortCompetence }
|
||||
}], { renderSheet: true })
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
await this.actor.createEmbeddedDocuments("Item", [{ name: `Nouveau ${itemType}`, type: itemType }], { renderSheet: true })
|
||||
}
|
||||
|
||||
@@ -415,6 +419,59 @@ export default class HeritiersActorSheet extends HandlebarsApplicationMixin(foun
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Increase item quantity
|
||||
* @param {Event} event
|
||||
* @param {HTMLElement} target
|
||||
* @private
|
||||
*/
|
||||
static async #onQuantityIncrease(event, target) {
|
||||
const li = target.closest(".item")
|
||||
const itemId = li?.dataset.itemId
|
||||
if (itemId) {
|
||||
await this.actor.incDecQuantity(itemId, 1)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrease item quantity
|
||||
* @param {Event} event
|
||||
* @param {HTMLElement} target
|
||||
* @private
|
||||
*/
|
||||
static async #onQuantityDecrease(event, target) {
|
||||
const li = target.closest(".item")
|
||||
const itemId = li?.dataset.itemId
|
||||
if (itemId) {
|
||||
await this.actor.incDecQuantity(itemId, -1)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Increase PV
|
||||
* @param {Event} event
|
||||
* @param {HTMLElement} target
|
||||
* @private
|
||||
*/
|
||||
static async #onPvIncrease(event, target) {
|
||||
const currentPv = this.actor.system.pv.value || 0
|
||||
const maxPv = this.actor.system.pv.max || 0
|
||||
const newPv = Math.min(currentPv + 1, maxPv)
|
||||
await this.actor.update({ 'system.pv.value': newPv })
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrease PV
|
||||
* @param {Event} event
|
||||
* @param {HTMLElement} target
|
||||
* @private
|
||||
*/
|
||||
static async #onPvDecrease(event, target) {
|
||||
const currentPv = this.actor.system.pv.value || 0
|
||||
const newPv = Math.max(currentPv - 1, 0)
|
||||
await this.actor.update({ 'system.pv.value': newPv })
|
||||
}
|
||||
|
||||
/**
|
||||
* Roll initiative
|
||||
* @param {Event} event
|
||||
|
||||
@@ -13,7 +13,7 @@ export default class HeritiersCapaciteNaturelleSheet extends HeritiersItemSheet
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
sheet: {
|
||||
template: "systems/fvtt-les-heritiers/templates/item-capacitenaturelle-sheet.html",
|
||||
template: "systems/fvtt-les-heritiers/templates/item-capacitenaturelle-sheet.hbs",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,12 +8,58 @@ export default class HeritiersCompetenceSheet extends HeritiersItemSheet {
|
||||
...super.DEFAULT_OPTIONS.window,
|
||||
title: "SHEETS.Item.competence",
|
||||
},
|
||||
actions: {
|
||||
addSpecialite: HeritiersCompetenceSheet.#onAddSpecialite,
|
||||
deleteSpecialite: HeritiersCompetenceSheet.#onDeleteSpecialite,
|
||||
editSpecialite: HeritiersCompetenceSheet.#onEditSpecialite,
|
||||
editSpecialiteDescription: HeritiersCompetenceSheet.#onEditSpecialiteDescription,
|
||||
}
|
||||
}
|
||||
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
sheet: {
|
||||
template: "systems/fvtt-les-heritiers/templates/item-competence-sheet.html",
|
||||
template: "systems/fvtt-les-heritiers/templates/item-competence-sheet.hbs",
|
||||
},
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* Event Handlers */
|
||||
/* -------------------------------------------- */
|
||||
|
||||
static async #onAddSpecialite(event, target) {
|
||||
let spec = foundry.utils.duplicate(this.item.system.specialites) || []
|
||||
spec.push({ name: "Nouvelle Spécialité", id: foundry.utils.randomID(16), used: false })
|
||||
await this.item.update({ 'system.specialites': spec })
|
||||
}
|
||||
|
||||
static async #onDeleteSpecialite(event, target) {
|
||||
const li = target.closest(".specialite-item")
|
||||
let index = parseInt(li.dataset.specialiteIndex)
|
||||
let spec = foundry.utils.duplicate(this.item.system.specialites) || []
|
||||
spec.splice(index, 1)
|
||||
await this.item.update({ 'system.specialites': spec })
|
||||
}
|
||||
|
||||
static async #onEditSpecialite(event, target) {
|
||||
const li = target.closest(".specialite-item")
|
||||
let index = parseInt(li.dataset.specialiteIndex)
|
||||
let spec = foundry.utils.duplicate(this.item.system.specialites) || []
|
||||
if (spec[index]) {
|
||||
spec[index].name = target.value
|
||||
spec[index].id = spec[index].id || foundry.utils.randomID(16)
|
||||
await this.item.update({ 'system.specialites': spec })
|
||||
}
|
||||
}
|
||||
|
||||
static async #onEditSpecialiteDescription(event, target) {
|
||||
const li = target.closest(".specialite-item")
|
||||
let index = parseInt(li.dataset.specialiteIndex)
|
||||
let spec = foundry.utils.duplicate(this.item.system.specialites) || []
|
||||
if (spec[index]) {
|
||||
spec[index].description = target.value
|
||||
spec[index].id = spec[index].id || foundry.utils.randomID(16)
|
||||
await this.item.update({ 'system.specialites': spec })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ export default class HeritiersContactSheet extends HeritiersItemSheet {
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
sheet: {
|
||||
template: "systems/fvtt-les-heritiers/templates/item-contact-sheet.html",
|
||||
template: "systems/fvtt-les-heritiers/templates/item-contact-sheet.hbs",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ export default class HeritiersDesavantageSheet extends HeritiersItemSheet {
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
sheet: {
|
||||
template: "systems/fvtt-les-heritiers/templates/item-desavantage-sheet.html",
|
||||
template: "systems/fvtt-les-heritiers/templates/item-desavantage-sheet.hbs",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ export default class HeritiersEquipementSheet extends HeritiersItemSheet {
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
sheet: {
|
||||
template: "systems/fvtt-les-heritiers/templates/item-equipement-sheet.html",
|
||||
template: "systems/fvtt-les-heritiers/templates/item-equipement-sheet.hbs",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ export default class HeritiersFeeSheet extends HeritiersItemSheet {
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
sheet: {
|
||||
template: "systems/fvtt-les-heritiers/templates/item-fee-sheet.html",
|
||||
template: "systems/fvtt-les-heritiers/templates/item-fee-sheet.hbs",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,12 +17,12 @@ export default class HeritiersPersonnageSheet extends HeritiersActorSheet {
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
sheet: {
|
||||
template: "systems/fvtt-les-heritiers/templates/actor-sheet.html",
|
||||
template: "systems/fvtt-les-heritiers/templates/actor-sheet.hbs",
|
||||
},
|
||||
}
|
||||
|
||||
/** @override */
|
||||
tabGroups = { primary: "stats" }
|
||||
tabGroups = { primary: "competences" }
|
||||
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
|
||||
@@ -17,12 +17,12 @@ export default class HeritiersPnjSheet extends HeritiersActorSheet {
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
sheet: {
|
||||
template: "systems/fvtt-les-heritiers/templates/actor-pnj-sheet.html",
|
||||
template: "systems/fvtt-les-heritiers/templates/actor-pnj-sheet.hbs",
|
||||
},
|
||||
}
|
||||
|
||||
/** @override */
|
||||
tabGroups = { primary: "stats" }
|
||||
tabGroups = { primary: "competences" }
|
||||
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
|
||||
@@ -13,7 +13,7 @@ export default class HeritiersPouvoirSheet extends HeritiersItemSheet {
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
sheet: {
|
||||
template: "systems/fvtt-les-heritiers/templates/item-pouvoir-sheet.html",
|
||||
template: "systems/fvtt-les-heritiers/templates/item-pouvoir-sheet.hbs",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ export default class HeritiersProfilSheet extends HeritiersItemSheet {
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
sheet: {
|
||||
template: "systems/fvtt-les-heritiers/templates/item-profil-sheet.html",
|
||||
template: "systems/fvtt-les-heritiers/templates/item-profil-sheet.hbs",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ export default class HeritiersProtectionSheet extends HeritiersItemSheet {
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
sheet: {
|
||||
template: "systems/fvtt-les-heritiers/templates/item-protection-sheet.html",
|
||||
template: "systems/fvtt-les-heritiers/templates/item-protection-sheet.hbs",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import HeritiersItemSheet from "./base-item-sheet.mjs"
|
||||
import { HeritiersUtility } from "../../heritiers-utility.js"
|
||||
|
||||
export default class HeritiersSortSheet extends HeritiersItemSheet {
|
||||
/** @override */
|
||||
@@ -13,7 +14,14 @@ export default class HeritiersSortSheet extends HeritiersItemSheet {
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
sheet: {
|
||||
template: "systems/fvtt-les-heritiers/templates/item-sort-sheet.html",
|
||||
template: "systems/fvtt-les-heritiers/templates/item-sort-sheet.hbs",
|
||||
},
|
||||
}
|
||||
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext()
|
||||
context.competencesMagie = HeritiersUtility.getCompetencesMagie() || []
|
||||
return context
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user