Fix after testing

This commit is contained in:
2026-01-10 22:35:39 +01:00
parent b113f630bf
commit 936d525503
119 changed files with 3193 additions and 1096 deletions

View File

@@ -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",
},
}
}

View File

@@ -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",
},
}
}

View File

@@ -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",
},
}
}

View File

@@ -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",
},
}
}

View File

@@ -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

View File

@@ -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",
},
}
}

View File

@@ -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 })
}
}
}

View File

@@ -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",
},
}
}

View File

@@ -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",
},
}
}

View File

@@ -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",
},
}
}

View File

@@ -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",
},
}
}

View File

@@ -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() {

View File

@@ -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() {

View File

@@ -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",
},
}
}

View File

@@ -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",
},
}
}

View File

@@ -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",
},
}
}

View File

@@ -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
}
}