Latest fixes for Oath Hammer
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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"]
|
||||
}
|
||||
44
module/models/building.mjs
Normal file
44
module/models/building.mjs
Normal 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
|
||||
}
|
||||
}
|
||||
@@ -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
43
module/models/trait.mjs
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user