refacto: harmonisation du système avec les règles Hamalron JDR
Corrections majeures : - HamalronTirageTarot extends Roll (évaluation des jets fonctionnelle) - Correction du nom de classe Langue (HamalronFaction -> HamalronLangue) - Création du template tab-navigation.hbs manquant - Type acteur 'character' -> 'personnage' dans _preCreate Types d'items corrigés (anglais -> français) : - weapon -> arme, armor -> armure, equipment -> equipement - Suppression des types inexistants (deal, malefica, ritual, perk) Modèles : - cost -> cout (armure, equipement) - Tarot : default -> initial - Sortilege : LOCALIZATION_PREFIXES corrigé - Constantes CHOICE_ADVANTAGES_DISADVANTAGES et ATTACK_MODIFIERS ajoutées - ATTACK_MODIFIERS supprimé (plus utilisé) Templates alignés sur les modèles réels : - enemy-trait : suppression champs manquants (trauma, stats, domain...) - personnage-equipement : champs alignés sur arme/armure/equipement - personnage-sortileges : suppression domain/level/rituals - enemy-main : suppression stats et flavorText - base-actor : suppression mortality, toChat limité aux tarots Jets de compétence : - Égalité = réussite (>= au lieu de >, conforme aux règles p.155) - Comparaison robuste des cartes de succès (via String()) Le Mat : - Les autres joueurs peuvent renouveler leur main (règle p.151) findTarotItem : recherche dans game.items puis compendiums await manquants ajoutés sur saveDeckState() AGENTS.md créé
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import HamalronActorSheet from "./base-actor-sheet.mjs"
|
||||
import { SYSTEM } from "../../config/system.mjs"
|
||||
import HamalronUtils from "../../utils.mjs"
|
||||
|
||||
export default class HamalronPersonnageSheet extends HamalronActorSheet {
|
||||
/** @override */
|
||||
@@ -16,11 +17,7 @@ export default class HamalronPersonnageSheet extends HamalronActorSheet {
|
||||
createEquipment: HamalronPersonnageSheet.#onCreateEquipment,
|
||||
createArmor: HamalronPersonnageSheet.#onCreateArmor,
|
||||
createWeapon: HamalronPersonnageSheet.#onCreateWeapon,
|
||||
createDeal: HamalronPersonnageSheet.#onCreateDeal,
|
||||
createMalefica: HamalronPersonnageSheet.#onCreateMalefica,
|
||||
createRitual: HamalronPersonnageSheet.#onCreateRitual,
|
||||
createPerk: HamalronPersonnageSheet.#onCreatePerk,
|
||||
modifyAmmo: HamalronPersonnageSheet.#onModifyAmmo,
|
||||
createSortilege: HamalronPersonnageSheet.#onCreateSortilege,
|
||||
modifyResistance: HamalronPersonnageSheet.#onModifyResistance,
|
||||
discardCard: HamalronPersonnageSheet.#onDiscardCard,
|
||||
rollCompetence: HamalronPersonnageSheet.#onRollCompetence,
|
||||
@@ -118,21 +115,15 @@ export default class HamalronPersonnageSheet extends HamalronActorSheet {
|
||||
case "sortileges":
|
||||
context.tab = context.tabs.sortileges
|
||||
context.sortileges = doc.itemTypes.sortilege || []
|
||||
// Sort the sortileges by system.domain and then by the system.level
|
||||
context.sortileges.sort((a, b) => {
|
||||
if (a.system.domain === b.system.domain) {
|
||||
return a.system.level.localeCompare(b.system.level)
|
||||
}
|
||||
return a.system.domain.localeCompare(b.system.domain)
|
||||
})
|
||||
context.sortileges.sort((a, b) => a.name.localeCompare(b.name))
|
||||
break
|
||||
case "equipment":
|
||||
context.tab = context.tabs.equipment
|
||||
context.weapons = doc.itemTypes.weapon || []
|
||||
context.weapons = doc.itemTypes.arme || []
|
||||
context.weapons.sort((a, b) => a.name.localeCompare(b.name))
|
||||
context.armors = doc.itemTypes.armor || []
|
||||
context.armors = doc.itemTypes.armure || []
|
||||
context.armors.sort((a, b) => a.name.localeCompare(b.name))
|
||||
context.equipments = doc.itemTypes.equipment || []
|
||||
context.equipments = doc.itemTypes.equipement || []
|
||||
context.equipments.sort((a, b) => a.name.localeCompare(b.name))
|
||||
break
|
||||
case "tarot":
|
||||
@@ -142,16 +133,14 @@ export default class HamalronPersonnageSheet extends HamalronActorSheet {
|
||||
context.handLimit = 7
|
||||
context.handSize = context.tarotCards.length
|
||||
context.isOverLimit = context.handSize > context.handLimit
|
||||
context.canAddCard = context.handSize < 8
|
||||
// Marquer les cartes de succès et enrichir les descriptions
|
||||
context.canAddCard = context.handSize < context.handLimit
|
||||
for (const card of context.tarotCards) {
|
||||
card.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(card.system.description, { async: true })
|
||||
// Vérifier si c'est une carte de succès
|
||||
if (doc.system.cartesSucces && card.system.type !== "atout") {
|
||||
card.isSuccessCard = Object.keys(doc.system.cartesSucces).some(symbole => {
|
||||
const successCardData = doc.system.cartesSucces[symbole]
|
||||
return card.system.symbole === symbole &&
|
||||
card.system.valeur === successCardData.value.toString()
|
||||
String(card.system.valeur) === String(successCardData.value)
|
||||
})
|
||||
} else {
|
||||
card.isSuccessCard = false
|
||||
@@ -160,19 +149,7 @@ export default class HamalronPersonnageSheet extends HamalronActorSheet {
|
||||
break
|
||||
case "biography":
|
||||
context.tab = context.tabs.biography
|
||||
context.deals = doc.itemTypes.deal || []
|
||||
context.enrichedBackstory = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.backstory, { async: true })
|
||||
context.enrichedAppearance = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.appearance, { async: true })
|
||||
context.enrichedScars = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.scars, { async: true })
|
||||
context.enrichedLikes = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.likes, { async: true })
|
||||
context.enrichedDislikes = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.dislikes, { async: true })
|
||||
context.enrichedFears = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.fears, { async: true })
|
||||
context.enrichedVices = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.vices, { async: true })
|
||||
context.enrichedGoals = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.goals, { async: true })
|
||||
context.enrichedAmbitions = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.ambitions, { async: true })
|
||||
context.enrichedValues = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.values, { async: true })
|
||||
context.enrichedBonds = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.bonds, { async: true })
|
||||
context.enrichedNotes = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.notes, { async: true })
|
||||
context.enrichedHistorial = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.historial, { async: true })
|
||||
break
|
||||
}
|
||||
return context
|
||||
@@ -180,44 +157,19 @@ export default class HamalronPersonnageSheet extends HamalronActorSheet {
|
||||
|
||||
|
||||
static #onCreateEquipment(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("HAMALRON.Label.newEquipment"), type: "equipment" }])
|
||||
}
|
||||
|
||||
static #onCreateDeal(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("HAMALRON.Label.newDeal"), type: "deal" }])
|
||||
}
|
||||
|
||||
static #onCreateMalefica(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("HAMALRON.Label.newMalefica"), type: "malefica" }])
|
||||
}
|
||||
|
||||
static #onCreateRitual(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("HAMALRON.Label.newRitual"), type: "ritual" }])
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("HAMALRON.Label.newEquipment"), type: "equipement" }])
|
||||
}
|
||||
|
||||
static #onCreateWeapon(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("HAMALRON.Label.newWeapon"), type: "weapon" }])
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("HAMALRON.Label.newWeapon"), type: "arme" }])
|
||||
}
|
||||
|
||||
static #onCreateArmor(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("HAMALRON.Label.newArmor"), type: "armor" }])
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("HAMALRON.Label.newArmor"), type: "armure" }])
|
||||
}
|
||||
|
||||
static #onCreatePerk(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("HAMALRON.Label.newPerk"), type: "perk" }])
|
||||
}
|
||||
|
||||
static async #onModifyAmmo(event, target) {
|
||||
const quantity = parseInt($(event.target).data("quantity"))
|
||||
const itemId = $(event.target).data("item-id")
|
||||
const item = this.document.items.get(itemId)
|
||||
if (!item) {
|
||||
console.warn(`HamalronCharacterSheet: Item with ID ${itemId} not found`)
|
||||
return
|
||||
}
|
||||
const currentAmmo = item.system.ammoQuantity || 0
|
||||
const newAmmo = Math.max(0, currentAmmo + quantity) // Ensure ammo doesn't go below 0
|
||||
await item.update({ "system.ammoQuantity": newAmmo })
|
||||
static #onCreateSortilege(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("HAMALRON.Label.newSortilege"), type: "sortilege" }])
|
||||
}
|
||||
|
||||
static async #onModifyResistance(event, target) {
|
||||
@@ -326,7 +278,7 @@ export default class HamalronPersonnageSheet extends HamalronActorSheet {
|
||||
const { default: HamalronTirageTarot } = await import("../../documents/tirage-tarot.mjs")
|
||||
await HamalronTirageTarot.handleLeMatEffect(this.document, deckManager)
|
||||
} else {
|
||||
const originalItem = game.items.get(newCard.id)
|
||||
const originalItem = await HamalronUtils.findTarotItem(newCard)
|
||||
if (originalItem) {
|
||||
await this.document.createEmbeddedDocuments("Item", [originalItem.toObject()])
|
||||
ui.notifications.info(game.i18n.localize("HAMALRON.Notifications.cardDiscardedAndDrawn") + newCard.name)
|
||||
@@ -337,7 +289,7 @@ export default class HamalronPersonnageSheet extends HamalronActorSheet {
|
||||
ui.notifications.info(game.i18n.localize("HAMALRON.Notifications.cardDiscardedNoNew"))
|
||||
}
|
||||
|
||||
deckManager.saveDeckState()
|
||||
await deckManager.saveDeckState()
|
||||
deckManager.render()
|
||||
}
|
||||
|
||||
@@ -382,14 +334,13 @@ export default class HamalronPersonnageSheet extends HamalronActorSheet {
|
||||
const { default: HamalronTirageTarot } = await import("../../documents/tirage-tarot.mjs")
|
||||
await HamalronTirageTarot.handleLeMatEffect(this.document, deckManager)
|
||||
} else {
|
||||
// Trouver l'item original pour le dupliquer
|
||||
const originalItem = game.items.get(newCard.id)
|
||||
const originalItem = await HamalronUtils.findTarotItem(newCard)
|
||||
if (originalItem) {
|
||||
await this.document.createEmbeddedDocuments("Item", [originalItem.toObject()])
|
||||
ui.notifications.info(game.i18n.localize("HAMALRON.Notifications.newCardDrawn") + newCard.name)
|
||||
}
|
||||
}
|
||||
deckManager.saveDeckState()
|
||||
await deckManager.saveDeckState()
|
||||
deckManager.render()
|
||||
}
|
||||
}
|
||||
@@ -426,7 +377,7 @@ export default class HamalronPersonnageSheet extends HamalronActorSheet {
|
||||
switch (rollType) {
|
||||
case "stat":
|
||||
statKey = $(event.currentTarget).data("stat-id");
|
||||
item = this.actor.system.stats[statKey];
|
||||
item = this.actor.system?.stats?.[statKey];
|
||||
break
|
||||
case "weapon":
|
||||
case "damage":
|
||||
@@ -436,7 +387,7 @@ export default class HamalronPersonnageSheet extends HamalronActorSheet {
|
||||
default:
|
||||
throw new Error(`Unknown roll type ${rollType}`)
|
||||
}
|
||||
await this.document.system.roll(rollType, item)
|
||||
if (item) await this.document.system.roll(rollType, item)
|
||||
}
|
||||
|
||||
async _onDrop(event) {
|
||||
@@ -456,21 +407,11 @@ export default class HamalronPersonnageSheet extends HamalronActorSheet {
|
||||
|
||||
const currentTarotCount = this.document.items.filter(i => i.type === "tarot").length
|
||||
|
||||
// Check if we already have 8 cards (hard limit)
|
||||
if (currentTarotCount >= 8) {
|
||||
if (currentTarotCount >= 7) {
|
||||
ui.notifications.warn(game.i18n.localize("HAMALRON.Notifications.tarotHandFull"))
|
||||
return
|
||||
}
|
||||
}
|
||||
if (item.type === "species-trait") {
|
||||
// Check if the item is already in the actor
|
||||
const existingTrait = this.document.items.find(i => i.type === "species-trait" && i.name === item.name)
|
||||
if (existingTrait) {
|
||||
await existingTrait.delete()
|
||||
// Display info message
|
||||
ui.notifications.info(game.i18n.localize("HAMALRON.Notifications.speciesTraitDeleted") + existingTrait.name)
|
||||
}
|
||||
}
|
||||
return super._onDropItem(item)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user