Latest fixes for Oath Hammer

This commit is contained in:
2026-03-12 17:29:43 +01:00
parent e8d84615c5
commit 82fddb0cb3
20 changed files with 376 additions and 97 deletions

View File

@@ -7,7 +7,8 @@ export { default as OathHammerEquipment } from "./equipment.mjs"
export { default as OathHammerSpell } from "./spell.mjs"
export { default as OathHammerMiracle } from "./miracle.mjs"
export { default as OathHammerMagicItem } from "./magic-item.mjs"
export { default as OathHammerAbility } from "./ability.mjs"
export { default as OathHammerTrait } from "./trait.mjs"
export { default as OathHammerOath } from "./oath.mjs"
export { default as OathHammerLineage } from "./lineage.mjs"
export { default as OathHammerClass } from "./class.mjs"
export { default as OathHammerBuilding } from "./building.mjs"

View File

@@ -1,33 +0,0 @@
import { SYSTEM } from "../config/system.mjs"
export default class OathHammerAbility 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 })
// lineage-trait (racial) or class-ability (starting or advancement trait)
schema.abilityType = new fields.StringField({
required: true, initial: "class-ability", choices: SYSTEM.ABILITY_TYPE_CHOICES
})
// Which class or lineage this trait belongs to (e.g. "Berserker", "Wood Elf")
schema.source = new fields.StringField({ required: true, nullable: false, initial: "" })
// When uses reset: none = passive (always on), encounter, day
schema.usagePeriod = new fields.StringField({
required: true, initial: "none", choices: SYSTEM.ABILITY_USAGE_PERIOD
})
// Maximum uses per period. 0 = passive / unlimited.
// Use a descriptive string when the limit is formula-based
// (e.g. "equal to Fate ranks") — store the note in the description.
schema.maxUses = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
return schema
}
static LOCALIZATION_PREFIXES = ["OATHHAMMER.Ability"]
}

View File

@@ -0,0 +1,44 @@
import { SYSTEM } from "../config/system.mjs"
export default class OathHammerBuilding extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields
const requiredInteger = { required: true, nullable: false, integer: true }
const schema = {}
// Narrative description and special effects
schema.description = new fields.HTMLField({ required: true, textSearch: true })
// Skill required to build (Carpentry or Masonry)
schema.skillCheck = new fields.StringField({
required: true, initial: "carpentry", choices: SYSTEM.BUILDING_SKILL_CHOICES
})
// Cost in gold pieces (after skill check SV negotiation)
schema.cost = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
// Construction duration (free text: "3 weeks", "6 months", etc.)
schema.buildTime = new fields.StringField({ required: true, nullable: false, initial: "" })
// Monthly tax revenue formula ("3d6", "2d6", "1d3", "" = none)
schema.taxRevenue = new fields.StringField({ required: true, nullable: false, initial: "" })
// Is this building currently constructed in the settlement?
schema.constructed = new fields.BooleanField({ required: true, initial: false })
// Which settlement this building belongs to (free text or settlement name)
schema.settlement = new fields.StringField({ required: true, nullable: false, initial: "" })
// Additional GM notes (special conditions, upgrades, damage, etc.)
schema.notes = new fields.HTMLField({ required: false, textSearch: true })
return schema
}
static LOCALIZATION_PREFIXES = ["OATHHAMMER.Building"]
/** Returns true if this building generates tax income */
get hasTaxRevenue() {
return this.taxRevenue.trim().length > 0
}
}

View File

@@ -31,7 +31,7 @@ export default class OathHammerMagicItem extends foundry.abstract.TypeDataModel
// Limited-use items (e.g. "once per day"); none = always active
schema.usagePeriod = new fields.StringField({
required: true, initial: "none", choices: SYSTEM.ABILITY_USAGE_PERIOD
required: true, initial: "none", choices: SYSTEM.TRAIT_USAGE_PERIOD
})
schema.maxUses = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })

43
module/models/trait.mjs Normal file
View File

@@ -0,0 +1,43 @@
import { SYSTEM } from "../config/system.mjs"
export default class OathHammerTrait 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 })
// class-trait (class-exclusive, acquirable) or special-trait (starting class trait)
schema.traitType = new fields.StringField({
required: true, initial: "special-trait", choices: SYSTEM.TRAIT_TYPE_CHOICES
})
// Which class or lineage this trait belongs to (e.g. "Berserker", "Wood Elf")
schema.source = new fields.StringField({ required: true, nullable: false, initial: "" })
// When uses reset: none = passive (always on), encounter, day
schema.usagePeriod = new fields.StringField({
required: true, initial: "none", choices: SYSTEM.TRAIT_USAGE_PERIOD
})
// Maximum uses per period. 0 = passive / unlimited.
schema.maxUses = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
return schema
}
static LOCALIZATION_PREFIXES = ["OATHHAMMER.Trait"]
static migrateData(source) {
// Migrate old abilityType field → traitType
if (source.abilityType !== undefined && source.traitType === undefined) {
const map = { "class-ability": "class-trait", "lineage-trait": "special-trait" }
source.traitType = map[source.abilityType] ?? "special-trait"
}
// Migrate old traitType values
if (source.traitType === "lineage-trait") source.traitType = "special-trait"
if (source.traitType === "class-ability") source.traitType = "class-trait"
return super.migrateData(source)
}
}