76 lines
3.4 KiB
JavaScript
76 lines
3.4 KiB
JavaScript
import { SYSTEM } from "../config/system.mjs"
|
|
|
|
export default class OathHammerWeapon extends foundry.abstract.TypeDataModel {
|
|
static defineSchema() {
|
|
const fields = foundry.data.fields
|
|
const requiredInteger = { required: true, nullable: false, integer: true }
|
|
const schema = {}
|
|
|
|
schema.description = new fields.HTMLField({ required: true, textSearch: true })
|
|
|
|
// Proficiency group (Common, Dueling, Heavy, Polearms, Bows, Throwing)
|
|
schema.proficiencyGroup = new fields.StringField({
|
|
required: true, initial: "common", choices: SYSTEM.WEAPON_PROFICIENCY_GROUPS
|
|
})
|
|
|
|
// Damage: melee = Might rank + damageMod dice; bows = baseDice (fixed, no Might)
|
|
// usesMight=true → formula displayed as "M+2", "M-1", etc.
|
|
// usesMight=false → formula displayed as e.g. "6" (fixed dice for bows)
|
|
schema.usesMight = new fields.BooleanField({ required: true, initial: true })
|
|
schema.damageMod = new fields.NumberField({ ...requiredInteger, initial: 0, min: -4, max: 5 })
|
|
|
|
// AP (Armor Penetration): penalty imposed on armor/defense rolls
|
|
schema.ap = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0, max: 6 })
|
|
|
|
// Reach (melee, in ft: 5 / 10 / 15) — ignored for ranged/throwing
|
|
schema.reach = new fields.NumberField({ ...requiredInteger, initial: 5, min: 5 })
|
|
|
|
// Range (ranged & throwing, in ft): short and long
|
|
schema.shortRange = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
|
|
schema.longRange = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
|
|
|
|
// Traits — stored as a Set of trait keys (Block, Brutal, Nimble, Parry, etc.)
|
|
schema.traits = new fields.SetField(
|
|
new fields.StringField({ choices: SYSTEM.WEAPON_TRAITS }),
|
|
{ required: true, initial: [] }
|
|
)
|
|
|
|
// Item slots (when stowed; 0 = does not occupy slots)
|
|
schema.slots = new fields.NumberField({ ...requiredInteger, initial: 1, min: 0 })
|
|
|
|
// Rarity (DV for Fortune check to find item for sale)
|
|
schema.rarity = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0, max: 5 })
|
|
|
|
schema.equipped = new fields.BooleanField({ required: true, initial: false })
|
|
schema.cost = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
|
|
schema.currency = new fields.StringField({ required: true, initial: "gp", choices: SYSTEM.CURRENCY_CHOICES })
|
|
|
|
// --- Magic properties (only relevant when isMagic = true) ---
|
|
schema.isMagic = new fields.BooleanField({ initial: false })
|
|
schema.magicQuality = new fields.StringField({
|
|
required: false, nullable: true, initial: null, choices: SYSTEM.MAGIC_QUALITY_CHOICES
|
|
})
|
|
schema.isCursed = new fields.BooleanField({ initial: false })
|
|
// Enchantment description (displayed when isMagic is true)
|
|
schema.magicEffect = new fields.HTMLField({ required: false, textSearch: true })
|
|
// Class/lineage restriction, e.g. "Dwarves only" (empty = no restriction)
|
|
schema.classRestriction = new fields.StringField({ required: true, nullable: false, initial: "" })
|
|
|
|
return schema
|
|
}
|
|
|
|
static LOCALIZATION_PREFIXES = ["OATHHAMMER.Weapon"]
|
|
|
|
/**
|
|
* Human-readable damage formula for display, e.g. "M+2", "M-1", "6"
|
|
*/
|
|
get damageLabel() {
|
|
if (this.usesMight) {
|
|
const mod = this.damageMod
|
|
if (mod === 0) return "M+0"
|
|
return mod > 0 ? `M+${mod}` : `M${mod}`
|
|
}
|
|
return String(this.damageMod) // bows: store base dice count in damageMod
|
|
}
|
|
}
|