2bd236fb29
- Dialogue de récupération accessible depuis la feuille personnage - Coupe/Denier : test difficulté 7 (1x/jour), +1 si réussi - Épée : +1 manuel (repos/soins) ou test guérison rapide - Bâton : +1 manuel (appréciation MJ) - Suivi des dates de dernière récupération par symbole - Désactive le test si déjà fait aujourd'hui - Bouton d'accès intégré dans la section résistances (icône lit) - Réutilise HamalronTirageTarot.prompt pour les tests
84 lines
3.3 KiB
JavaScript
84 lines
3.3 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.rangMagie = new fields.StringField({ required: true, initial: "initie", choices: Object.fromEntries(Object.entries(SYSTEM.RANG_MAGICIEN).map(([key, val]) => [key, val.label])) })
|
|
schema.resistanceRecovery = new fields.ObjectField({ required: false, initial: {} })
|
|
|
|
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 })
|
|
}
|
|
}
|