Files
fvtt-hamalron/module/models/personnage.mjs
T
uberwald 68b3079da8 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éé
2026-07-10 18:52:20 +02:00

82 lines
3.0 KiB
JavaScript

import { SYSTEM } from "../config/system.mjs"
import HamalronTirageTarot from "../documents/tirage-tarot.mjs"
export default class HamalronPersonnage extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields
const requiredInteger = { required: true, nullable: false, integer: true }
const schema = {}
// Stats
const symboleCarte = (label) => {
const schema = {
label: new fields.StringField({ required: true, initial: label }),
value: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
max: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
}
return new fields.SchemaField(schema, { label })
}
schema.cartesSucces = new fields.SchemaField(
Object.values(SYSTEM.TAROT_SYMBOLES).reduce((obj, stat) => {
obj[stat.id] = symboleCarte(stat.label)
return obj
}, {}),
)
schema.resistances = new fields.SchemaField(
Object.values(SYSTEM.TAROT_SYMBOLES).reduce((obj, stat) => {
obj[stat.id] = symboleCarte(stat.label)
return obj
}, {}),
)
schema.historial = new fields.HTMLField({ required: true, textSearch: true })
schema.progression = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
schema.biodata = new fields.SchemaField({
age: new fields.StringField({ required: true, nullable: false, initial: "" }),
gender: new fields.StringField({ required: true, nullable: false, initial: "" }),
height: new fields.StringField({ required: true, nullable: false, initial: "" }),
eyes: new fields.StringField({ required: true, nullable: false, initial: "" }),
birthplace: new fields.StringField({ required: true, nullable: false, initial: "" }),
hair: new fields.StringField({ required: true, nullable: false, initial: "" }),
home: new fields.StringField({ required: true, nullable: false, initial: "" }),
weight: new fields.StringField({ required: true, nullable: false, initial: "" }),
origineSociale: new fields.StringField({ required: true, nullable: false, initial: "" }),
})
return schema
}
/** @override */
static LOCALIZATION_PREFIXES = ["HAMALRON.Personnage"]
prepareDerivedData() {
super.prepareDerivedData();
}
/** */
/**
* Rolls a dice for a character.
* @param {("save"|"resource|damage")} rollType The type of the roll.
* @param {number} rollItem The target value for the roll. Which caracteristic or resource. If the roll is a damage roll, this is the id of the item.
* @returns {Promise<null>} - A promise that resolves to null if the roll is cancelled.
*/
async roll(rollType, rollItem) {
let roll = await HamalronTirageTarot.prompt({
rollType,
rollItem,
actorId: this.parent.id,
actorName: this.parent.name,
actorImage: this.parent.img,
hasTarget: false,
})
if (!roll) return null
await roll.toMessage({}, { rollMode: roll.options.rollMode })
}
}