160 lines
4.1 KiB
JavaScript
160 lines
4.1 KiB
JavaScript
/**
|
|
* Class data model for Prism RPG
|
|
*
|
|
* Classes in Prism provide:
|
|
* - Archetype classification (Faith, Mana, Wanderer, Warrior)
|
|
* - Class features gained at different levels
|
|
* - Proficiencies and abilities
|
|
* - Characters can have up to 3 classes simultaneously
|
|
*/
|
|
import { SYSTEM } from "../config/system.mjs"
|
|
|
|
export default class PrismRPGClass extends foundry.abstract.TypeDataModel {
|
|
static defineSchema() {
|
|
const fields = foundry.data.fields
|
|
const schema = {}
|
|
|
|
schema.description = new fields.HTMLField({
|
|
required: true,
|
|
textSearch: true,
|
|
initial: ""
|
|
})
|
|
|
|
// Archetype (Faith, Mana, Wanderer, Warrior)
|
|
schema.archetype = new fields.StringField({
|
|
required: true,
|
|
initial: "wanderer",
|
|
choices: SYSTEM.CLASS_ARCHETYPE,
|
|
label: "Archetype"
|
|
})
|
|
|
|
// Is this a Core Class or Continental Class?
|
|
schema.classType = new fields.StringField({
|
|
required: true,
|
|
initial: "core",
|
|
choices: SYSTEM.CLASS_TYPE,
|
|
label: "Class Type"
|
|
})
|
|
|
|
// For Continental Classes, specify the continent
|
|
schema.continent = new fields.StringField({
|
|
required: false,
|
|
initial: "",
|
|
label: "Continent"
|
|
})
|
|
|
|
// Current level in this class (for tracking progression)
|
|
schema.level = new fields.NumberField({
|
|
required: true,
|
|
nullable: false,
|
|
integer: true,
|
|
initial: 1,
|
|
min: 1,
|
|
max: 10,
|
|
label: "Class Level"
|
|
})
|
|
|
|
// Class Features (structured data for features gained at each level)
|
|
schema.features = new fields.SchemaField({
|
|
level1: new fields.HTMLField({ initial: "" }),
|
|
level2: new fields.HTMLField({ initial: "" }),
|
|
level3: new fields.HTMLField({ initial: "" }),
|
|
level4: new fields.HTMLField({ initial: "" }),
|
|
level5: new fields.HTMLField({ initial: "" }),
|
|
level6: new fields.HTMLField({ initial: "" }),
|
|
level7: new fields.HTMLField({ initial: "" }),
|
|
level8: new fields.HTMLField({ initial: "" }),
|
|
level9: new fields.HTMLField({ initial: "" }),
|
|
level10: new fields.HTMLField({ initial: "" })
|
|
})
|
|
|
|
// Proficiencies granted by this class
|
|
schema.weaponProficiencies = new fields.StringField({
|
|
required: true,
|
|
initial: "",
|
|
label: "Weapon Proficiencies"
|
|
})
|
|
|
|
schema.armorProficiencies = new fields.StringField({
|
|
required: true,
|
|
initial: "",
|
|
label: "Armor Proficiencies"
|
|
})
|
|
|
|
// Special abilities
|
|
schema.spellcasting = new fields.BooleanField({
|
|
required: true,
|
|
initial: false,
|
|
label: "Has Spellcasting"
|
|
})
|
|
|
|
schema.spellcastingType = new fields.StringField({
|
|
required: false,
|
|
nullable: true,
|
|
initial: null,
|
|
blank: true,
|
|
choices: SYSTEM.CLASS_SPELLCASTING_TYPE,
|
|
label: "Spellcasting Type"
|
|
})
|
|
|
|
// Attribute bonuses
|
|
schema.attributeBonuses = new fields.HTMLField({
|
|
required: true,
|
|
initial: "",
|
|
label: "Attribute Bonuses"
|
|
})
|
|
|
|
// Additional notes
|
|
schema.notes = new fields.HTMLField({
|
|
required: true,
|
|
initial: "",
|
|
label: "Notes"
|
|
})
|
|
|
|
return schema
|
|
}
|
|
|
|
/** @override */
|
|
static LOCALIZATION_PREFIXES = ["PRISMRPG.Class"]
|
|
|
|
/**
|
|
* Clean up data before validation
|
|
* @override
|
|
*/
|
|
static cleanData(source = {}, options = {}) {
|
|
// Convert empty string to null for spellcastingType
|
|
if (source.spellcastingType === "") {
|
|
source.spellcastingType = null
|
|
}
|
|
return super.cleanData(source, options)
|
|
}
|
|
|
|
/**
|
|
* Get the localized archetype label
|
|
*/
|
|
get archetypeLabel() {
|
|
return game.i18n.localize(`PRISMRPG.Class.Archetype.${this.archetype}`)
|
|
}
|
|
|
|
/**
|
|
* Get the current level's features
|
|
*/
|
|
get currentLevelFeatures() {
|
|
return this.features[`level${this.level}`] || ""
|
|
}
|
|
|
|
/**
|
|
* Get all features up to current level
|
|
*/
|
|
get allFeaturesUpToLevel() {
|
|
const features = []
|
|
for (let i = 1; i <= this.level; i++) {
|
|
const feature = this.features[`level${i}`]
|
|
if (feature) {
|
|
features.push({ level: i, description: feature })
|
|
}
|
|
}
|
|
return features
|
|
}
|
|
}
|