Workable system, firt step

This commit is contained in:
2026-01-02 20:30:29 +01:00
parent 70d1720176
commit 8a27cef9a4
69 changed files with 6081 additions and 1767 deletions
+250 -35
View File
@@ -1,4 +1,5 @@
import HamalronActorSheet from "./base-actor-sheet.mjs"
import { SYSTEM } from "../../config/system.mjs"
export default class HamalronPersonnageSheet extends HamalronActorSheet {
/** @override */
@@ -20,6 +21,12 @@ export default class HamalronPersonnageSheet extends HamalronActorSheet {
createRitual: HamalronPersonnageSheet.#onCreateRitual,
createPerk: HamalronPersonnageSheet.#onCreatePerk,
modifyAmmo: HamalronPersonnageSheet.#onModifyAmmo,
modifyResistance: HamalronPersonnageSheet.#onModifyResistance,
discardCard: HamalronPersonnageSheet.#onDiscardCard,
rollCompetence: HamalronPersonnageSheet.#onRollCompetence,
drawCard: HamalronPersonnageSheet.#onDrawCard,
selectCard: HamalronPersonnageSheet.#onSelectCard,
discardAndDraw: HamalronPersonnageSheet.#onDiscardAndDraw,
},
}
@@ -31,18 +38,18 @@ export default class HamalronPersonnageSheet extends HamalronActorSheet {
tabs: {
template: "templates/generic/tab-navigation.hbs",
},
status: {
competences: {
template: "systems/fvtt-hamalron/templates/personnage-status.hbs",
},
maleficas: {
tarot: {
template: "systems/fvtt-hamalron/templates/personnage-tarot.hbs",
},
sortileges: {
template: "systems/fvtt-hamalron/templates/personnage-sortileges.hbs",
},
equipment: {
template: "systems/fvtt-hamalron/templates/personnage-equipement.hbs",
},
tarot: {
template: "systems/fvtt-hamalron/templates/personnage-tarot.hbs",
},
biography: {
template: "systems/fvtt-hamalron/templates/personnage-biographie.hbs",
},
@@ -50,7 +57,7 @@ export default class HamalronPersonnageSheet extends HamalronActorSheet {
/** @override */
tabGroups = {
sheet: "status",
sheet: "competences",
}
/**
@@ -59,10 +66,10 @@ export default class HamalronPersonnageSheet extends HamalronActorSheet {
*/
#getTabs() {
const tabs = {
status: { id: "status", group: "sheet", icon: "fa-solid fa-compass", label: "HAMALRON.Label.status" },
maleficas: { id: "maleficas", group: "sheet", icon: "fa-solid fa-compass", label: "HAMALRON.Label.maleficas" },
equipment: { id: "equipment", group: "sheet", icon: "fa-solid fa-shapes", label: "HAMALRON.Label.equipment" },
competences: { id: "competences", group: "sheet", icon: "fa-solid fa-list-check", label: "HAMALRON.Label.competences" },
tarot: { id: "tarot", group: "sheet", icon: "fa-solid fa-cards", label: "HAMALRON.Label.tarot" },
sortileges: { id: "sortileges", group: "sheet", icon: "fa-solid fa-wand-magic-sparkles", label: "HAMALRON.Label.sortileges" },
equipment: { id: "equipment", group: "sheet", icon: "fa-solid fa-shapes", label: "HAMALRON.Label.equipment" },
biography: { id: "biography", group: "sheet", icon: "fa-solid fa-book", label: "HAMALRON.Label.biography" },
}
for (const v of Object.values(tabs)) {
@@ -78,9 +85,6 @@ export default class HamalronPersonnageSheet extends HamalronActorSheet {
context.tabs = this.#getTabs()
const doc = this.document
context.trait = doc.itemTypes['species-trait']?.[0]
context.upright = doc.itemTypes.tarot.find(t => t.system.orientation === "Upright")
context.downright = doc.itemTypes.tarot.find(t => t.system.orientation === "Downright")
return context
}
@@ -91,30 +95,36 @@ export default class HamalronPersonnageSheet extends HamalronActorSheet {
context.systemFields = this.document.system.schema.fields
switch (partId) {
case "main":
// Get peuple and faction items (only one of each allowed)
context.peuple = doc.itemTypes.peuple?.[0] || null
context.faction = doc.itemTypes.faction?.[0] || null
context.isEditMode = this.isEditMode
context.isPlayMode = this.isPlayMode
break
case "status":
context.tab = context.tabs.status
context.perks = doc.itemTypes.perk || []
// Sort the perks by system.role and then by the system.level
context.perks.sort((a, b) => {
if (a.system.role === b.system.role) {
return a.system.level.localeCompare(b.system.level)
}
return a.system.role.localeCompare(b.system.role)
case "competences":
context.tab = context.tabs.competences
const allCompetences = doc.itemTypes.competence || []
// Ajouter les données de niveau enrichies à chaque compétence
allCompetences.forEach(c => {
const niveauData = SYSTEM.NIVEAU_COMPETENCES[c.system.niveau]
c.niveauName = niveauData?.name || c.system.niveau
c.niveauModificateur = niveauData?.modificateur ?? 0
})
// Grouper les compétences par type et trier par nom dans chaque groupe
context.competencesCommunes = allCompetences.filter(c => c.system.type === 'commune').sort((a, b) => a.name.localeCompare(b.name))
context.competencesPeuple = allCompetences.filter(c => c.system.type === 'peuple').sort((a, b) => a.name.localeCompare(b.name))
context.competencesFaction = allCompetences.filter(c => c.system.type === 'faction').sort((a, b) => a.name.localeCompare(b.name))
break;
case "maleficas":
context.tab = context.tabs.maleficas
context.maleficas = doc.itemTypes.malefica || []
// Sort the maleficas by system.domain and then by the system.level
context.maleficas.sort((a, b) => {
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.rituals = doc.itemTypes.ritual || []
context.rituals.sort((a, b) => a.name.localeCompare(b.name))
break
case "equipment":
context.tab = context.tabs.equipment
@@ -129,9 +139,23 @@ export default class HamalronPersonnageSheet extends HamalronActorSheet {
context.tab = context.tabs.tarot
context.tarotCards = doc.itemTypes.tarot || []
context.tarotCards.sort((a, b) => a.name.localeCompare(b.name))
// Enrich descriptions for each tarot card
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
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()
})
} else {
card.isSuccessCard = false
}
}
break
case "biography":
@@ -196,6 +220,190 @@ export default class HamalronPersonnageSheet extends HamalronActorSheet {
await item.update({ "system.ammoQuantity": newAmmo })
}
static async #onModifyResistance(event, target) {
const symbole = target.dataset.symbole
const delta = Number.parseInt(target.dataset.delta)
if (!symbole || isNaN(delta)) {
console.warn(`HamalronPersonnageSheet: Invalid resistance modification parameters`)
return
}
const resistance = this.document.system.resistances[symbole]
if (!resistance) {
console.warn(`HamalronPersonnageSheet: Resistance ${symbole} not found`)
return
}
const newValue = Math.max(0, Math.min(resistance.max, resistance.value + delta))
await this.document.update({ [`system.resistances.${symbole}.value`]: newValue })
}
static async #onDiscardCard(event, target) {
const itemId = $(event.target).data("item-id")
const item = this.document.items.get(itemId)
if (!item || item.type !== "tarot") {
console.warn(`HamalronPersonnageSheet: Tarot card with ID ${itemId} not found`)
return
}
// Supprimer la carte du personnage
await item.delete()
ui.notifications.info(game.i18n.localize("HAMALRON.Notifications.cardDiscarded") + item.name)
}
static async #onSelectCard(event, target) {
const cardWrapper = $(target).closest(".tarot-card-wrapper")
const wasSelected = cardWrapper.hasClass("selected")
// Désélectionner toutes les cartes
$(".tarot-card-wrapper").removeClass("selected")
// Sélectionner la carte cliquée si elle n'était pas déjà sélectionnée
if (!wasSelected) {
cardWrapper.addClass("selected")
}
}
static async #onDiscardAndDraw(event, target) {
const itemId = $(target).data("item-id")
const item = this.document.items.get(itemId)
if (!item || item.type !== "tarot") {
console.warn(`HamalronPersonnageSheet: Tarot card with ID ${itemId} not found`)
return
}
// Dialog de confirmation
const confirmed = await foundry.applications.api.DialogV2.confirm({
window: {
title: game.i18n.localize("HAMALRON.Dialog.discardCardTitle"),
},
content: `<p>${game.i18n.format("HAMALRON.Dialog.discardCardContent", { cardName: item.name })}</p>`,
rejectClose: false,
modal: true,
})
if (!confirmed) return
// Récupérer le deck manager
const module = await import("../tarot-deck-manager.mjs")
const HamalronTarotDeckManager = module.default
if (!HamalronTarotDeckManager._instance) {
HamalronTarotDeckManager._instance = new HamalronTarotDeckManager()
}
const deckManager = HamalronTarotDeckManager._instance
if (!deckManager) {
ui.notifications.warn(game.i18n.localize("HAMALRON.Notifications.deckManagerNotAvailable"))
return
}
// Ajouter la carte à la défausse
deckManager.addToDiscard({
id: item.id,
name: item.name,
img: item.img,
symbole: item.system.symbole,
valeur: item.system.valeur,
type: item.system.type,
description: item.system.description,
})
// Supprimer la carte du personnage
await item.delete()
// Tirer une nouvelle carte si le deck n'est pas vide
if (deckManager.deck.length > 0) {
const newCards = deckManager.drawCards(1)
if (newCards.length > 0) {
const newCard = newCards[0]
// Cas spécial : Le Mat
if (newCard.valeur === "lemat") {
console.log("Le Mat drawn! Executing special rules...")
const { default: HamalronTirageTarot } = await import("../../documents/tirage-tarot.mjs")
await HamalronTirageTarot.handleLeMatEffect(this.document, deckManager)
} else {
const originalItem = game.items.get(newCard.id)
if (originalItem) {
await this.document.createEmbeddedDocuments("Item", [originalItem.toObject()])
ui.notifications.info(game.i18n.localize("HAMALRON.Notifications.cardDiscardedAndDrawn") + newCard.name)
}
}
}
} else {
ui.notifications.info(game.i18n.localize("HAMALRON.Notifications.cardDiscardedNoNew"))
}
deckManager.saveDeckState()
deckManager.render()
}
static async #onDrawCard(event, target) {
const currentTarotCount = this.document.items.filter(i => i.type === "tarot").length
// Vérifier que le joueur a moins de 7 cartes
if (currentTarotCount >= 7) {
ui.notifications.warn(game.i18n.localize("HAMALRON.Notifications.cannotDrawCard"))
return
}
// Récupérer le deck manager singleton
const module = await import("../tarot-deck-manager.mjs")
const HamalronTarotDeckManager = module.default
// Vérifier si l'instance existe, sinon la créer
if (!HamalronTarotDeckManager._instance) {
HamalronTarotDeckManager._instance = new HamalronTarotDeckManager()
}
const deckManager = HamalronTarotDeckManager._instance
if (!deckManager) {
ui.notifications.warn(game.i18n.localize("HAMALRON.Notifications.deckManagerNotAvailable"))
return
}
if (deckManager.deck.length === 0) {
ui.notifications.warn(game.i18n.localize("HAMALRON.Notifications.deckEmpty"))
return
}
// Tirer une nouvelle carte
const newCards = deckManager.drawCards(1)
if (newCards.length > 0) {
const newCard = newCards[0]
// Cas spécial : Le Mat
if (newCard.valeur === "lemat") {
console.log("Le Mat drawn! Executing special rules...")
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)
if (originalItem) {
await this.document.createEmbeddedDocuments("Item", [originalItem.toObject()])
ui.notifications.info(game.i18n.localize("HAMALRON.Notifications.newCardDrawn") + newCard.name)
}
}
deckManager.saveDeckState()
deckManager.render()
}
}
static async #onRollCompetence(event, target) {
const itemId = $(target).data("item-id")
const item = this.document.items.get(itemId)
if (!item || item.type !== "competence") {
console.warn(`HamalronPersonnageSheet: Competence with ID ${itemId} not found`)
return
}
await this.document.system.roll("competence", item)
}
/**
* Handles the roll action triggered by user interaction.
*
@@ -239,12 +447,19 @@ export default class HamalronPersonnageSheet extends HamalronActorSheet {
if (data.type === "Item") {
const item = await fromUuid(data.uuid)
if (item.type === "tarot") {
// Delete the existing tarot item
const existingTarot = this.document.items.find(i => i.type === "tarot" && i.system.orientation === item.system.orientation)
if (existingTarot) {
await existingTarot.delete()
// Display info message
ui.notifications.info(game.i18n.localize("HAMALRON.Notifications.tarotDeleted") + existingTarot.name)
// Check if a card with the same name already exists
const existingCard = this.document.items.find(i => i.type === "tarot" && i.name === item.name)
if (existingCard) {
ui.notifications.warn(game.i18n.localize("HAMALRON.Notifications.tarotCardAlreadyExists") + item.name)
return
}
const currentTarotCount = this.document.items.filter(i => i.type === "tarot").length
// Check if we already have 8 cards (hard limit)
if (currentTarotCount >= 8) {
ui.notifications.warn(game.i18n.localize("HAMALRON.Notifications.tarotHandFull"))
return
}
}
if (item.type === "species-trait") {
+347 -7
View File
@@ -4,8 +4,8 @@ export default class HamalronTarotDeckManager extends HandlebarsApplicationMixin
constructor(options = {}) {
super(options)
this.deck = []
this.drawnCards = []
this.resetDeck()
this.discard = []
this.loadDeckState()
}
/** @override */
@@ -26,6 +26,10 @@ export default class HamalronTarotDeckManager extends HandlebarsApplicationMixin
resetDeck: HamalronTarotDeckManager.#onResetDeck,
drawCard: HamalronTarotDeckManager.#onDrawCard,
drawMultiple: HamalronTarotDeckManager.#onDrawMultiple,
shuffleDiscard: HamalronTarotDeckManager.#onShuffleDiscard,
collectHands: HamalronTarotDeckManager.#onCollectHands,
distributeCards: HamalronTarotDeckManager.#onDistributeCards,
drawTension: HamalronTarotDeckManager.#onDrawTension,
},
}
@@ -36,12 +40,39 @@ export default class HamalronTarotDeckManager extends HandlebarsApplicationMixin
},
}
/**
* Save the current deck state to settings
*/
async saveDeckState() {
const state = {
deck: this.deck,
discard: this.discard,
}
await game.settings.set("fvtt-hamalron", "tarotDeckState", state)
console.log("Deck state saved:", state)
}
/**
* Load the deck state from settings
*/
loadDeckState() {
const state = game.settings.get("fvtt-hamalron", "tarotDeckState")
if (state && state.deck && state.deck.length > 0) {
this.deck = state.deck
this.discard = state.discard || []
console.log("Deck state loaded:", state)
} else {
// Si aucun état sauvegardé, initialiser un nouveau deck
this.resetDeck()
}
}
/**
* Reset the deck to a full tarot deck
*/
resetDeck() {
this.deck = []
this.drawnCards = []
this.discard = []
// Créer toutes les cartes du jeu de tarot
const items = game.items.filter(i => i.type === "tarot")
@@ -63,6 +94,7 @@ export default class HamalronTarotDeckManager extends HandlebarsApplicationMixin
// Mélanger le deck
this.shuffleDeck()
this.saveDeckState()
this.render()
}
@@ -90,7 +122,6 @@ export default class HamalronTarotDeckManager extends HandlebarsApplicationMixin
const drawn = []
for (let i = 0; i < count && this.deck.length > 0; i++) {
const card = this.deck.shift()
this.drawnCards.push(card)
drawn.push(card)
}
@@ -130,10 +161,10 @@ export default class HamalronTarotDeckManager extends HandlebarsApplicationMixin
const context = await super._prepareContext(options)
context.deckCount = this.deck.length
context.drawnCount = this.drawnCards.length
context.totalCards = this.deck.length + this.drawnCards.length
context.discardCount = this.discard.length
context.totalCards = this.deck.length + this.discard.length
context.hasCards = this.deck.length > 0
context.drawnCards = this.drawnCards.slice(-5).reverse() // Show last 5 drawn cards
context.hasDiscard = this.discard.length > 0
return context
}
@@ -166,6 +197,9 @@ export default class HamalronTarotDeckManager extends HandlebarsApplicationMixin
const cards = this.drawCards(1)
if (cards.length > 0) {
await this.sendCardsToChat(cards)
// Ajouter les cartes directement à la défausse
cards.forEach(card => this.addToDiscard(card))
this.saveDeckState()
this.render()
}
}
@@ -180,10 +214,316 @@ export default class HamalronTarotDeckManager extends HandlebarsApplicationMixin
const cards = this.drawCards(count)
if (cards.length > 0) {
await this.sendCardsToChat(cards)
// Ajouter les cartes directement à la défausse
cards.forEach(card => this.addToDiscard(card))
this.saveDeckState()
this.render()
}
}
/**
* Add a card to the discard pile
* @param {Object} card - Card to add to discard
*/
addToDiscard(card) {
// Vérifier que la carte n'est pas déjà dans la défausse
const cardExists = this.discard.some(c => c.id === card.id)
if (!cardExists) {
this.discard.push(card)
this.saveDeckState()
this.render()
}
}
/**
* Collect all tarot cards from player characters and return them to the deck
* @param {Event} event
* @param {HTMLElement} target
*/
static async #onCollectHands(event, target) {
const confirmed = await foundry.applications.api.DialogV2.confirm({
window: { title: game.i18n.localize("HAMALRON.TarotDeck.CollectHandsConfirm") },
content: `<p>${game.i18n.localize("HAMALRON.TarotDeck.CollectHandsWarning")}</p>`,
rejectClose: false,
modal: true,
})
if (!confirmed) return
let totalCollected = 0
// Récupérer tous les acteurs de type personnage (incluant tous, pas seulement ceux avec propriété joueur)
const playerCharacters = game.actors.filter(a => a.type === "personnage")
console.log("Found characters:", playerCharacters.length)
// Collecter toutes les cartes de tarot de tous les personnages
for (const actor of playerCharacters) {
const tarotCards = actor.items.filter(i => i.type === "tarot")
console.log(`Actor ${actor.name} has ${tarotCards.length} tarot cards`)
if (tarotCards.length > 0) {
// Supprimer les cartes de l'acteur
const cardIds = tarotCards.map(c => c.id)
console.log(`Deleting ${cardIds.length} cards from ${actor.name}`)
await actor.deleteEmbeddedDocuments("Item", cardIds)
console.log(`Deleted cards from ${actor.name}`)
totalCollected += tarotCards.length
}
}
// Réinitialiser le deck avec toutes les cartes de tarot disponibles
this.deck = []
this.discard = []
const items = game.items.filter(i => i.type === "tarot")
if (items.length > 0) {
// Créer un Map pour éviter les doublons (utiliser l'ID unique)
const uniqueCards = new Map()
items.forEach(item => {
const key = `${item.system.symbole}_${item.system.valeur}_${item.system.type}`
if (!uniqueCards.has(key)) {
uniqueCards.set(key, {
id: item.id,
name: item.name,
img: item.img,
symbole: item.system.symbole,
valeur: item.system.valeur,
type: item.system.type,
description: item.system.description,
})
}
})
this.deck = Array.from(uniqueCards.values())
}
// Mélanger le deck
this.shuffleDeck()
this.saveDeckState()
ui.notifications.info(
game.i18n.format("HAMALRON.TarotDeck.HandsCollected", {
collected: totalCollected,
deckSize: this.deck.length
})
)
this.render()
}
/**
* Distribute 8 cards to all connected players
* @param {Event} event
* @param {HTMLElement} target
*/
static async #onDistributeCards(event, target) {
if (this.deck.length < 8) {
ui.notifications.warn(game.i18n.localize("HAMALRON.TarotDeck.NotEnoughCards"))
return
}
const confirmed = await foundry.applications.api.DialogV2.confirm({
window: { title: game.i18n.localize("HAMALRON.TarotDeck.DistributeConfirm") },
content: `<p>${game.i18n.localize("HAMALRON.TarotDeck.DistributeWarning")}</p>`,
rejectClose: false,
modal: true,
})
if (!confirmed) return
let distributedCount = 0
let playersCount = 0
// Récupérer tous les utilisateurs connectés (sauf le GM)
const connectedPlayers = game.users.filter(u => u.active && !u.isGM)
for (const user of connectedPlayers) {
// Trouver le personnage du joueur (premier actor de type personnage dont il est propriétaire)
const playerCharacter = game.actors.find(a =>
a.type === "personnage" &&
a.testUserPermission(user, "OWNER")
)
if (playerCharacter) {
// Tirer 8 cartes pour ce personnage
const cardsToDistribute = []
for (let i = 0; i < 8 && this.deck.length > 0; i++) {
const card = this.deck.shift()
cardsToDistribute.push(card)
}
// Créer les items sur l'acteur
for (const card of cardsToDistribute) {
const originalItem = game.items.get(card.id)
if (originalItem) {
await playerCharacter.createEmbeddedDocuments("Item", [originalItem.toObject()])
distributedCount++
// Cas spécial : Le Mat
if (card.valeur === "lemat") {
console.log(`Le Mat distributed to ${playerCharacter.name}! Executing special rules...`)
// Import de TirageTarot pour accéder à la fonction helper
const { default: HamalronTirageTarot } = await import("../documents/tirage-tarot.mjs")
await HamalronTirageTarot.handleLeMatEffect(playerCharacter, this)
}
}
}
playersCount++
}
}
this.saveDeckState()
ui.notifications.info(
game.i18n.format("HAMALRON.TarotDeck.CardsDistributed", {
cards: distributedCount,
players: playersCount
})
)
this.render()
}
/**
* Shuffle discard pile back into deck
* @param {Event} event
* @param {HTMLElement} target
*/
static async #onShuffleDiscard(event, target) {
if (this.discard.length === 0) {
ui.notifications.warn(game.i18n.localize("HAMALRON.TarotDeck.NoDiscard"))
return
}
// Ajouter toutes les cartes de la défausse au deck
this.deck.push(...this.discard)
this.discard = []
// Mélanger le deck
this.shuffleDeck()
this.saveDeckState()
ui.notifications.info(game.i18n.localize("HAMALRON.TarotDeck.DiscardShuffled"))
this.render()
}
/**
* Handle draw tension action
* @param {Event} event
* @param {HTMLElement} target
*/
static async #onDrawTension(event, target) {
// Import system config
const { DIFFICULTY_CHOICES } = await import('../config/system.mjs')
// Créer les options de difficulté
const difficulties = Object.entries(DIFFICULTY_CHOICES)
.filter(([key]) => key !== 'soustension_oppose')
.map(([key, value]) => ({
value: key,
label: value.label
}))
// Créer le contenu HTML du dialogue
const selectOptions = difficulties.map(d =>
`<option value="${d.value}">${d.label}</option>`
).join('')
const content = `
<div class="form-group">
<label>{{localize "HAMALRON.Label.difficulty"}}</label>
<select id="tension-difficulty" style="width: 100%;">
${selectOptions}
</select>
</div>
`
// Afficher le dialogue
const result = await foundry.applications.api.DialogV2.wait({
window: { title: game.i18n.localize("HAMALRON.TarotDeck.SelectDifficulty") },
content: content,
buttons: [
{
action: "draw",
label: game.i18n.localize("HAMALRON.TarotDeck.DrawCard"),
default: true,
callback: (event, button, dialog) => {
const select = button.form.elements["tension-difficulty"]
return select.value
}
},
{
action: "cancel",
label: game.i18n.localize("Cancel")
}
],
rejectClose: false,
modal: true
})
if (!result) return
// Tirer une carte
const cards = this.drawCards(1)
if (cards.length === 0) return
const card = cards[0]
const difficultyKey = result
const difficulty = DIFFICULTY_CHOICES[difficultyKey]
// Récupérer la valeur numérique de la carte
const { TAROT_VALEURS } = await import('../config/system.mjs')
const cardValue = TAROT_VALEURS[card.valeur]?.value || 0
const tensionBonus = difficulty.soustension || 0
const totalScore = cardValue + tensionBonus
// Afficher dans le chat
await this.sendTensionDrawToChat(card, difficulty, cardValue, tensionBonus, totalScore)
// Ajouter à la défausse
this.addToDiscard(card)
this.saveDeckState()
this.render()
}
/**
* Send tension draw to chat
* @param {Object} card - The drawn card
* @param {Object} difficulty - The selected difficulty
* @param {number} cardValue - Card numeric value
* @param {number} tensionBonus - Tension modifier
* @param {number} totalScore - Total score
*/
async sendTensionDrawToChat(card, difficulty, cardValue, tensionBonus, totalScore) {
const speaker = ChatMessage.getSpeaker({ alias: "Maître du Jeu" })
const content = await foundry.applications.handlebars.renderTemplate(
"systems/fvtt-hamalron/templates/chat-tarot-tension.hbs",
{
card: card,
symboleLabel: game.i18n.localize(`HAMALRON.Tarot.FIELDS.symbole.${card.symbole}`),
valeurLabel: game.i18n.localize(`HAMALRON.Tarot.FIELDS.valeur.${card.valeur}`),
typeLabel: game.i18n.localize(`HAMALRON.Tarot.FIELDS.type.${card.type}`),
difficulty: difficulty,
cardValue: cardValue,
tensionBonus: tensionBonus,
totalScore: totalScore
}
)
await ChatMessage.create({
speaker: speaker,
content: content,
type: CONST.CHAT_MESSAGE_TYPES.OTHER,
})
}
/**
* Open the Tarot Deck Manager application
* @returns {HamalronTarotDeckManager}
+52 -1
View File
@@ -23,10 +23,23 @@ export const TAROT_TYPES = {
}
export const TAROT_VALEURS = {
"11": { id: "11", label: "11", value: 11 },
"12": { id: "12", label: "12", value: 12 },
"13": { id: "13", label: "13", value: 13 },
"14": { id: "14", label: "14", value: 14 },
"15": { id: "15", label: "15", value: 15 },
"16": { id: "16", label: "16", value: 16 },
"17": { id: "17", label: "17", value: 17 },
"18": { id: "18", label: "18", value: 18 },
"19": { id: "19", label: "19", value: 19 },
"20": { id: "20", label: "20", value: 20 },
"21": { id: "21", label: "21", value: 21 },
"22": { id: "22", label: "22", value: 22 },
"roi": { id: "roi", label: "Roi", value: 14 },
"reine": { id: "reine", label: "Reine", value: 13 },
"cavalier": { id: "cavalier", label: "Cavalier", value: 12 },
"valet": { id: "valet", label: "Valet", value: 11 },
"lemat": { id: "lemat", label: "Le Mat", value: 23 },
"10": { id: "10", label: "10", value: 10 },
"9": { id: "9", label: "9", value: 9 },
"8": { id: "8", label: "8", value: 8 },
@@ -40,6 +53,7 @@ export const TAROT_VALEURS = {
}
export const DIFFICULTY_CHOICES = {
"soustension_oppose": { id: "soustension_oppose", label: "Sous Tension ou Opposé", standard: null, "soustension": null },
"tresfacile": { id: "tresfacile", label: "Très Facile", standard: 3, "soustension": -4 },
"facile": { id: "facile", label: "Facile", standard: 5, "soustension": -2 },
"moyenne": { id: "moyenne", label: "Moyenne", standard: 7, "soustension": 0 },
@@ -54,7 +68,7 @@ export const WEAPON_TYPES = {
}
export const COMPETENCE_TYPES = {
"generale": { id: "generale", label: "Générale" },
"commune": { id: "commune", label: "Commune" },
"faction": { id: "faction", label: "Faction" },
"peuple": { id: "peuple", label: "Peuple" },
}
@@ -70,6 +84,42 @@ export const SORTILEGE_CATEGORIES = {
"ritual": { id: "ritual", label: "Rituel" },
}
export const NIVEAU_COMPETENCES = {
"inexperimente": {
"name": "Inexpérimenté",
"id": "inexperimente",
"abreviation": "I",
"modificateur": 0,
"cout_acquisition_points": 0,
"description": "Niveau de départ par défaut pour toutes les compétences non apprises."
},
"amateur": {
"name": "Amateur",
"id": "amateur",
"abreviation": "A",
"modificateur": 1,
"cout_acquisition_points": 1,
"description": "Le personnage possède des notions de base dans la compétence."
},
"competent": {
"name": "Compétent",
"id": "competent",
"abreviation": "C",
"modificateur": 3,
"cout_acquisition_points": 3,
"cout_progression_depuis_amateur": 2,
"description": "Le personnage maîtrise la compétence et résiste mieux aux actions adverses."
},
"expert": {
"name": "Expert",
"abreviation": "E",
"modificateur": 5,
"cout_acquisition_points": 5,
"cout_progression_depuis_competent": 2,
"description": "Le personnage est un maître absolu dans son domaine."
}
}
/**
* Include all constant definitions within the SYSTEM global export
* @type {Object}
@@ -84,5 +134,6 @@ export const SYSTEM = {
COMPETENCE_TYPES: COMPETENCE_TYPES,
ENEMY_TYPES: ENEMY_TYPES,
SORTILEGE_CATEGORIES: SORTILEGE_CATEGORIES,
NIVEAU_COMPETENCES: NIVEAU_COMPETENCES,
ASCII
}
+10 -10
View File
@@ -1,14 +1,14 @@
export const defaultItemImg = {
arme: "systems/fvtt-hamalron/assets/icons/arme.webp",
armure: "systems/fvtt-hamalron/assets/icons/armure.webp",
competence: "systems/fvtt-hamalron/assets/icons/competence.webp",
equipement: "systems/fvtt-hamalron/assets/icons/equipement.webp",
faction: "systems/fvtt-hamalron/assets/icons/faction.webp",
langue: "systems/fvtt-hamalron/assets/icons/langue.webp",
peuple: "systems/fvtt-hamalron/assets/icons/peuple.webp",
region: "systems/fvtt-hamalron/assets/icons/region.webp",
sortilege: "systems/fvtt-hamalron/assets/icons/sortilege.webp",
tarot: "systems/fvtt-hamalron/assets/icons/tarot.webp",
arme: "systems/fvtt-hamalron/assets/icons/arme.svg",
armure: "systems/fvtt-hamalron/assets/icons/armure.svg",
competence: "systems/fvtt-hamalron/assets/icons/competence.svg",
equipement: "systems/fvtt-hamalron/assets/icons/equipement.svg",
faction: "systems/fvtt-hamalron/assets/icons/faction.svg",
langue: "systems/fvtt-hamalron/assets/icons/langue.svg",
peuple: "systems/fvtt-hamalron/assets/icons/peuple.svg",
region: "systems/fvtt-hamalron/assets/icons/region.svg",
sortilege: "systems/fvtt-hamalron/assets/icons/sortilege.svg",
tarot: "systems/fvtt-hamalron/assets/icons/tarot.svg",
}
export default class HamalronItem extends Item {
+396 -4
View File
@@ -8,6 +8,57 @@ export default class HamalronTirageTarot {
*/
static CHAT_TEMPLATE = "systems/fvtt-hamalron/templates/chat-message.hbs"
/**
* Handle Le Mat special effect when distributed to a player
* @param {Actor} actor - The actor who received Le Mat
* @param {HamalronTarotDeckManager} deckManager - The deck manager instance
*/
static async handleLeMatEffect(actor, deckManager) {
// 1. Défausser toutes les cartes du joueur
const allTarotCards = actor.items.filter(i => i.type === "tarot")
if (allTarotCards.length > 0) {
const cardIds = allTarotCards.map(c => c.id)
await actor.deleteEmbeddedDocuments("Item", cardIds)
console.log(`Discarded ${cardIds.length} cards from player`)
// Ajouter toutes les cartes à la défausse
for (const card of allTarotCards) {
deckManager.addToDiscard({
id: card.id,
name: card.name,
img: card.img,
symbole: card.system.symbole,
valeur: card.system.valeur,
type: card.system.type,
description: card.system.description,
})
}
}
// 2. Tirer 7 nouvelles cartes pour le joueur
for (let i = 0; i < 7; i++) {
if (deckManager.deck.length > 0) {
const newCards = deckManager.drawCards(1)
if (newCards.length > 0) {
const newCard = newCards[0]
const originalItem = game.items.get(newCard.id)
if (originalItem) {
await actor.createEmbeddedDocuments("Item", [originalItem.toObject()])
}
}
}
}
// 3. Regrouper la défausse et le deck, puis mélanger
deckManager.deck.push(...deckManager.discard)
deckManager.discard = []
deckManager.shuffleDeck()
await deckManager.saveDeckState()
deckManager.render()
ui.notifications.info(`Le Mat ! Toutes vos cartes ont été défaussées et vous recevez 7 nouvelles cartes. Le deck a été mélangé.`)
}
static async prompt(options = {}) {
let formula = `3D6 + 0D6KH - 0D6KH + ${options?.rollItem?.value}`
@@ -15,6 +66,34 @@ export default class HamalronTirageTarot {
switch (options.rollType) {
case "stat":
break
case "competence":
{
// Récupérer les cartes de tarot du personnage
options.tarotCards = actor.items.filter(i => i.type === "tarot")
// Récupérer le modificateur de compétence depuis NIVEAU_COMPETENCES
const niveauData = SYSTEM.NIVEAU_COMPETENCES[options.rollItem.system.niveau]
options.competenceModifier = niveauData ? niveauData.modificateur : 0
// Marquer les cartes de succès
if (options.tarotCards && actor.system.cartesSucces) {
options.tarotCards = options.tarotCards.map(card => {
const isSuccessCard = card.system.type !== "atout" && Object.keys(actor.system.cartesSucces).some(symbole => {
const successCardData = actor.system.cartesSucces[symbole]
return card.system.symbole === symbole &&
card.system.valeur === successCardData.value.toString()
})
// Créer un objet simple avec toutes les propriétés nécessaires
return {
id: card.id,
name: card.name,
img: card.img,
system: card.system,
isSuccessCard: isSuccessCard
}
})
}
}
break
case "damage":
{
let formula = options.rollItem.system.damage
@@ -56,6 +135,7 @@ export default class HamalronTirageTarot {
let dialogContext = {
actorId: options.actorId,
actorName: options.actorName,
actorImage: options.actorImage,
rollType: options.rollType,
rollItem: foundry.utils.duplicate(options.rollItem), // Object only, no class
weapon: options?.weapon,
@@ -69,23 +149,45 @@ export default class HamalronTirageTarot {
difficulty: "0",
nbAdvantages: "0",
nbDisadvantages: "0",
tarotCards: options.tarotCards || [],
competenceModifier: options.competenceModifier || 0,
difficultyChoices: Object.fromEntries(Object.entries(SYSTEM.DIFFICULTY_CHOICES).map(([key, val]) => [key, val.label])),
}
const content = await foundry.applications.handlebars.renderTemplate("systems/fvtt-hamalron/templates/roll-dialog.hbs", dialogContext)
const title = HamalronRoll.createTitle(options.rollType, options.rollTarget)
const title = HamalronTirageTarot.createTitle(options.rollType, options.rollTarget)
const label = game.i18n.localize("HAMALRON.Roll.roll")
const cancelLabel = game.i18n.localize("HAMALRON.Roll.cancel")
const rollContext = await foundry.applications.api.DialogV2.wait({
window: { title: title },
classes: ["fvtt-hamalron"],
position: { width: 420 },
content,
buttons: [
{
action: "cancel",
label: cancelLabel,
default: false,
},
{
action: "roll",
label: label,
default: true,
disabled: options.rollType === "competence",
callback: (event, button, dialog) => {
const output = Array.from(button.form.elements).reduce((obj, input) => {
if (input.name) obj[input.name] = input.value
return obj
}, {})
// Ajouter les données de sélection de carte pour les compétences
if (options.rollType === "competence") {
console.log("DEBUG CALLBACK: options.selectedCardId =", options.selectedCardId, "options.selectedCardValue =", options.selectedCardValue)
output.selectedCardId = options.selectedCardId
output.selectedCardValue = options.selectedCardValue
output.selectedDifficulty = options.selectedDifficulty
output.targetScore = options.targetScore
console.log("DEBUG CALLBACK: output =", output)
}
return output
},
},
@@ -96,11 +198,11 @@ export default class HamalronTirageTarot {
render: (event, dialog) => {
$(".roll-stat-advantages").change(event => {
options.nbAdvantages = Number(event.target.value)
HamalronRoll.updateFullFormula(options)
HamalronTirageTarot.updateFullFormula(options)
})
$(".roll-stat-disadvantages").change(event => {
options.nbDisadvantages = Number(event.target.value)
HamalronRoll.updateFullFormula(options)
HamalronTirageTarot.updateFullFormula(options)
})
$(".select-combat-option").change(event => {
let field = $(event.target).data("field")
@@ -110,14 +212,302 @@ export default class HamalronTirageTarot {
} else {
options.numericModifier -= modifier
}
HamalronRoll.updateFullFormula(options)
HamalronTirageTarot.updateFullFormula(options)
})
// Gestion de la sélection de carte pour les compétences
if (options.rollType === "competence") {
let selectedCardId = null
options.selectedDifficulty = "soustension_oppose"
options.targetScore = null
// Calculer et afficher les valeurs pour chaque carte
const competenceSymbole = options.rollItem.system.carteSymbole
$(".tarot-card-select").each(function () {
const cardSymbole = $(this).data("card-symbole")
const cardValeur = $(this).data("card-valeur")
const cardType = $(this).data("card-type")
const valeurData = SYSTEM.TAROT_VALEURS[cardValeur]
const baseValue = valeurData ? valeurData.value : 0
let calculatedValue = 0
if (cardType === "atout") {
calculatedValue = baseValue
} else if (cardSymbole === competenceSymbole) {
calculatedValue = baseValue
} else {
calculatedValue = Math.ceil(baseValue / 2)
}
$(this).find(".card-values").text(`${baseValue}${calculatedValue}`)
})
// Gestion du changement de difficulté
$(".difficulty-select").change(function () {
const difficultyKey = $(this).val()
options.selectedDifficulty = difficultyKey
const difficultyData = SYSTEM.DIFFICULTY_CHOICES[difficultyKey]
if (difficultyData.standard === null) {
// Sous tension ou opposé - pas de score cible
options.targetScore = null
$("#target-score").text("-")
} else {
options.targetScore = difficultyData.standard
$("#target-score").text(options.targetScore)
}
})
$(".tarot-card-select").click(function () {
// Désélectionner toutes les cartes
$(".tarot-card-select").removeClass("selected")
// Sélectionner la carte cliquée
$(this).addClass("selected")
selectedCardId = $(this).data("card-id")
console.log("DEBUG CLICK: selectedCardId =", selectedCardId)
const cardSymbole = $(this).data("card-symbole")
const cardValeur = $(this).data("card-valeur")
const cardType = $(this).data("card-type")
// Calculer la valeur de la carte
const competenceSymbole = options.rollItem.system.carteSymbole
let cardValue = 0
// Récupérer la valeur numérique de la carte depuis TAROT_VALEURS
const valeurData = SYSTEM.TAROT_VALEURS[cardValeur]
const baseValue = valeurData ? valeurData.value : 0
if (cardType === "atout") {
// Si c'est un atout, prendre directement la valeur
cardValue = baseValue
} else if (cardSymbole === competenceSymbole) {
// Si le symbole correspond, prendre la valeur complète
cardValue = baseValue
} else {
// Sinon, diviser par 2 arrondi au supérieur
cardValue = Math.ceil(baseValue / 2)
}
// Stocker la carte sélectionnée et sa valeur calculée
options.selectedCardId = selectedCardId
options.selectedCardValue = cardValue
console.log("DEBUG CLICK END: options.selectedCardId =", options.selectedCardId, "options.selectedCardValue =", options.selectedCardValue)
// Mettre à jour l'affichage
$("#card-value-display").text(`+ ${cardValue}`)
$("#total-value").text(options.competenceModifier + cardValue)
// Activer le bouton de lancement
$("button[data-action='roll']").prop("disabled", false)
})
// Permettre de désélectionner en cliquant à nouveau
$(".tarot-card-select").dblclick(function () {
$(this).removeClass("selected")
options.selectedCardId = null
options.selectedCardValue = 0
$("#card-value-display").text("+ 0")
$("#total-value").text(options.competenceModifier)
// Désactiver le bouton de lancement
$("button[data-action='roll']").prop("disabled", true)
})
}
}
})
// If the user cancels the dialog, exit
if (rollContext === null) return
// Fusionner les données du dialogue dans options
Object.assign(options, rollContext)
// Gestion spéciale pour les compétences (pas de dés)
if (options.rollType === "competence") {
const totalValue = options.competenceModifier + (options.selectedCardValue || 0)
// Récupérer la carte sélectionnée si elle existe
let selectedCard = null
let cardSymboleMatch = false
let isAutomaticSuccess = false
if (options.selectedCardId) {
selectedCard = actor.items.get(options.selectedCardId)
if (selectedCard) {
cardSymboleMatch = selectedCard.system.symbole === options.rollItem.system.carteSymbole
// Vérifier si c'est une carte de succès (les atouts ne peuvent jamais être des cartes de succès)
if (actor.system.cartesSucces && selectedCard.system.type !== "atout") {
isAutomaticSuccess = Object.keys(actor.system.cartesSucces).some(symbole => {
const successCardData = actor.system.cartesSucces[symbole]
return selectedCard.system.symbole === symbole &&
selectedCard.system.valeur === successCardData.value.toString()
})
}
}
}
// Préparer les données pour le chat
const difficultyData = SYSTEM.DIFFICULTY_CHOICES[options.selectedDifficulty || "moyenne"]
const isSousTensionOppose = options.selectedDifficulty === "soustension_oppose"
const isSuccess = isAutomaticSuccess || totalValue > options.targetScore
// Détecter si la carte est un valet
const isValet = selectedCard?.system.valeur === "valet"
// Détecter si la carte est un cavalier
const isCavalier = selectedCard?.system.valeur === "cavalier"
// Détecter si la carte est une reine
const isReine = selectedCard?.system.valeur === "reine"
// Détecter si la carte est un roi
const isRoi = selectedCard?.system.valeur === "roi"
// Détecter si la carte est un atout
const isAtout = selectedCard?.system.type === "atout"
// Si c'est un cavalier et un échec, transformer en égalité
const isEquality = isCavalier && !isSuccess && !isSousTensionOppose
const chatData = {
cssClass: [SYSTEM.id, "competence-roll"].join(" "),
actingCharImg: options.actorImage,
actingCharName: options.actorName,
actorName: options.actorName,
competence: options.rollItem,
competenceModifier: options.competenceModifier,
selectedCard: selectedCard,
cardBonus: options.selectedCardValue || 0,
cardSymboleMatch: cardSymboleMatch,
totalValue: totalValue,
difficulty: difficultyData.label,
targetScore: options.targetScore,
isSuccess: isSuccess,
isAutomaticSuccess: isAutomaticSuccess,
isSousTensionOppose: isSousTensionOppose,
isValet: isValet,
isCavalier: isCavalier,
isReine: isReine,
isRoi: isRoi,
isAtout: isAtout,
isEquality: isEquality,
}
// Créer le message de chat
const content = await foundry.applications.handlebars.renderTemplate(
"systems/fvtt-hamalron/templates/chat-competence.hbs",
chatData
)
const messageData = {
user: game.user.id,
speaker: ChatMessage.getSpeaker({ actor }),
content: content,
style: CONST.CHAT_MESSAGE_STYLES.OTHER,
}
// Appliquer le mode de visibilité
ChatMessage.applyRollMode(messageData, rollContext.visibility)
await ChatMessage.create(messageData)
// Gérer la carte utilisée
console.log("DEBUG: selectedCard =", selectedCard, "options.selectedCardId =", options.selectedCardId)
if (selectedCard) {
console.log("Managing used card:", selectedCard.name)
// Supprimer la carte de l'acteur
const cardItem = actor.items.get(selectedCard.id)
if (cardItem) {
await actor.deleteEmbeddedDocuments("Item", [selectedCard.id])
console.log("Card deleted from actor")
}
// Récupérer le deck manager singleton
const module = await import("../applications/tarot-deck-manager.mjs")
const HamalronTarotDeckManager = module.default
let deckManager = HamalronTarotDeckManager._instance
// Si le deck manager n'existe pas, le créer
if (!deckManager) {
console.log("Deck manager not initialized, creating new instance...")
deckManager = new HamalronTarotDeckManager()
await deckManager.resetDeck()
}
console.log("Deck manager instance:", deckManager)
if (deckManager) {
console.log("Deck manager is available")
// Ajouter la carte à la défausse
deckManager.addToDiscard({
id: selectedCard.id,
name: selectedCard.name,
img: selectedCard.img,
symbole: selectedCard.system.symbole,
valeur: selectedCard.system.valeur,
type: selectedCard.system.type,
description: selectedCard.system.description,
})
console.log("Card added to discard")
// Tirer une nouvelle carte automatiquement
console.log("Attempting to draw new card. Deck length:", deckManager.deck.length)
if (deckManager.deck.length > 0) {
const newCards = deckManager.drawCards(1)
console.log("Cards drawn:", newCards)
if (newCards.length > 0) {
const newCard = newCards[0]
console.log("New card to add:", newCard)
// Trouver l'item tarot dans game.items
let originalItem = game.items.get(newCard.id)
console.log("Original item found by ID:", originalItem)
// Si pas trouvé dans game.items, chercher dans tous les items disponibles
if (!originalItem) {
console.log("Searching for card in game.items by properties...")
originalItem = game.items.find(i =>
i.type === "tarot" &&
i.name === newCard.name &&
i.system.symbole === newCard.symbole &&
i.system.valeur === newCard.valeur
)
console.log("Original item found by search:", originalItem)
}
if (originalItem) {
// Cas spécial : Le Mat
if (newCard.valeur === "lemat") {
console.log("Le Mat drawn! Executing special rules...")
await HamalronTirageTarot.handleLeMatEffect(actor, deckManager)
} else {
console.log("Creating embedded document for actor...")
await actor.createEmbeddedDocuments("Item", [originalItem.toObject()])
console.log("New card added to actor")
ui.notifications.info(`${game.i18n.localize("HAMALRON.Notifications.newCardDrawn")}: ${newCard.name}`)
}
} else {
console.warn("Original item not found for card:", newCard)
}
} else {
console.log("No cards were drawn (empty result)")
}
} else {
console.log("Deck is empty, cannot draw new card")
}
deckManager.saveDeckState()
deckManager.render()
ui.notifications.info(`${game.i18n.localize("HAMALRON.Notifications.cardUsed")}: ${selectedCard.name}`)
}
}
return null
}
// Code existant pour les autres types de jets
let rollData = foundry.utils.mergeObject(foundry.utils.duplicate(options), rollContext)
rollData.rollMode = rollContext.visibility
rollData.targetScore = 8
@@ -203,6 +593,8 @@ export default class HamalronTirageTarot {
return `${game.i18n.localize("HAMALRON.Label.titleStat")}`
case "weapon":
return `${game.i18n.localize("HAMALRON.Label.titleWeapon")}`
case "competence":
return `${game.i18n.localize("HAMALRON.Label.titleCompetence")}`
default:
return game.i18n.localize("HAMALRON.Label.titleStandard")
}
+4 -2
View File
@@ -6,9 +6,11 @@ export default class HamalronCompetence extends foundry.abstract.TypeDataModel {
const schema = {};
schema.description = new fields.HTMLField({ required: true, textSearch: true })
schema.type = new fields.StringField({ required: true, initial: "generale", choices: Object.fromEntries(Object.entries(SYSTEM.COMPETENCE_TYPES).map(([key, val]) => [key, val.label])) });
schema.type = new fields.StringField({ required: true, initial: "commune", choices: Object.fromEntries(Object.entries(SYSTEM.COMPETENCE_TYPES).map(([key, val]) => [key, val.label])) });
schema.carteSymbole = new fields.StringField({ required: true, initial: "coupe", choices: Object.fromEntries(Object.entries(SYSTEM.TAROT_SYMBOLES).map(([key, val]) => [key, val.label])) });
schema.niveau = new fields.NumberField({ required: true, initial: 0, min: 0, integer: true });
schema.niveau = new fields.StringField({ required: true, initial: "inexperimente", choices: Object.fromEntries(Object.entries(SYSTEM.NIVEAU_COMPETENCES).map(([key, val]) => [key, val.name])) });
schema.faction = new fields.StringField({ required: false, initial: "" });
schema.peuple = new fields.StringField({ required: false, initial: "" });
return schema;
}
+10 -1
View File
@@ -128,6 +128,15 @@ export default class HamalronUtils {
Handlebars.registerHelper('add', function (a, b) {
return parseInt(a) + parseInt(b);
})
Handlebars.registerHelper('tarotValue', function (valeur) {
// Pour les valeurs numériques simples, retourner directement
const numValue = Number.parseInt(valeur);
if (!Number.isNaN(numValue)) return numValue;
// Pour les figures et atouts, récupérer depuis SYSTEM
const valeurData = SYSTEM.TAROT_VALEURS[valeur];
return valeurData ? valeurData.value : valeur;
});
Handlebars.registerHelper('mul', function (a, b) {
return parseInt(a) * parseInt(b);
@@ -169,7 +178,7 @@ export default class HamalronUtils {
return key === "creature" || key === "daemon";
})
Handlebars.registerHelper('getRomanLevel', function (level) {
if (level=== "highpowers") return "High";
if (level === "highpowers") return "High";
if (level === "mastery") return "Mastery";
level = parseInt(level);
if (level === 0) return "0";