Files

110 lines
4.1 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Célestopol 1922 — Système FoundryVTT
*
* Célestopol 1922 est un jeu de rôle édité par Antre-Monde Éditions.
* Ce système FoundryVTT est une implémentation indépendante et n'est pas
* affilié à Antre-Monde Éditions,
* mais a été réalisé avec l'autorisation d'Antre-Monde Éditions.
*
* @author LeRatierBretonnien
* @copyright 20252026 LeRatierBretonnien
* @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/
*/
import { SYSTEM } from "../config/system.mjs"
/** Schéma partagé pour les bonus/malus par domaine (utilisé dans anomaly/aspect). */
function skillScoresSchema() {
const fields = foundry.data.fields
const reqInt = { required: true, nullable: false, integer: true }
const scoreField = () => new fields.SchemaField({
bonus: new fields.NumberField({ ...reqInt, initial: 0 }),
malus: new fields.NumberField({ ...reqInt, initial: 0 }),
})
const statGroup = (statId) => {
const skills = SYSTEM.SKILLS[statId]
const schema = {}
for (const key of Object.keys(skills)) {
schema[key] = scoreField()
}
return new fields.SchemaField(schema)
}
return new fields.SchemaField({
ame: statGroup("ame"),
corps: statGroup("corps"),
coeur: statGroup("coeur"),
esprit: statGroup("esprit"),
})
}
export class CelestopolAnomaly extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields
const reqInt = { required: true, nullable: false, integer: true }
return {
subtype: new fields.StringField({ required: true, nullable: false, initial: "none",
choices: Object.keys(SYSTEM.ANOMALY_TYPES) }),
level: new fields.NumberField({ ...reqInt, initial: 2, min: 1, max: 4 }),
usesRemaining: new fields.NumberField({ ...reqInt, initial: 2, min: 0, max: 4 }),
technique: new fields.HTMLField({ required: true, textSearch: true }),
narratif: new fields.HTMLField({ required: true, textSearch: true }),
exemples: new fields.HTMLField({ required: true, textSearch: true }),
}
}
}
export class CelestopolAspect extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields
return {
valeur: new fields.NumberField({ required: true, integer: true, initial: 0, min: 0 }),
description: new fields.HTMLField({ required: true, textSearch: true }),
}
}
}
export class CelestopolEquipment extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields
return {
description: new fields.HTMLField({ required: true, textSearch: true }),
}
}
}
export class CelestopolWeapon extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields
const reqInt = { required: true, nullable: false, integer: true }
return {
type: new fields.StringField({ required: true, nullable: false, initial: "melee",
choices: Object.keys(SYSTEM.WEAPON_COMBAT_TYPES) }),
degats: new fields.StringField({ required: true, nullable: false, initial: "0",
choices: Object.keys(SYSTEM.WEAPON_DAMAGE_TYPES) }),
portee: new fields.StringField({ required: true, nullable: false, initial: "contact",
choices: Object.keys(SYSTEM.WEAPON_RANGE_TYPES) }),
description: new fields.HTMLField({ required: true, textSearch: true }),
}
}
}
export class CelestopolArmure extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields
const reqInt = { required: true, nullable: false, integer: true }
return {
protection: new fields.NumberField({ ...reqInt, initial: 1, min: 1, max: 2 }),
malus: new fields.NumberField({ ...reqInt, initial: 1, min: 0, max: 2 }),
equipped: new fields.BooleanField({ initial: false }),
description: new fields.HTMLField({ required: true, textSearch: true }),
}
}
prepareDerivedData() {
super.prepareDerivedData()
this.malus = this.protection
}
}