feat: add Settlement actor type with Overview/Buildings/Inventory tabs

- New TypeDataModel: archetype, territory, renown, currency (gp/sp/cp),
  garrison, underSiege, isCapital, founded, taxNotes, description, notes
- 3-tab ApplicationV2 sheet with drag & drop for building/weapon/armor/equipment
- Currency steppers (+/−), building constructed toggle, qty controls
- LESS-based CSS (settlement-sheet.less) + base.less updated for shared styles
- Full i18n keys in lang/en.json (8 settlement archetypes)
- system.json: registered settlement actor type

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-03-20 17:01:38 +01:00
parent b67d85c6be
commit b3fd7e1aa1
28 changed files with 966 additions and 270 deletions

View File

@@ -11,6 +11,7 @@ export { default as OathHammerTraitSheet } from "./sheets/trait-sheet.mjs"
export { default as OathHammerOathSheet } from "./sheets/oath-sheet.mjs"
export { default as OathHammerClassSheet } from "./sheets/class-sheet.mjs"
export { default as OathHammerBuildingSheet } from "./sheets/building-sheet.mjs"
export { default as OathHammerSettlementSheet } from "./sheets/settlement-sheet.mjs"
export { default as OathHammerRollDialog } from "./roll-dialog.mjs"
export { default as OathHammerWeaponDialog } from "./weapon-dialog.mjs"
export { default as OathHammerSpellDialog } from "./spell-dialog.mjs"

View File

@@ -67,7 +67,7 @@ export default class OathHammerArmorDialog {
)
const result = await foundry.applications.api.DialogV2.wait({
window: { title: game.i18n.format("OATHHAMMER.Dialog.ArmorRollTitle", { armor: armor.name }) },
window: { title: game.i18n.format("OATHHAMMER.Dialog.ArmorRollTitle", { armor: armor.name }), resizable: true },
classes: ["fvtt-oath-hammer"],
position: { width: 420 },
content,

View File

@@ -68,7 +68,7 @@ export default class OathHammerDefenseDialog {
)
const result = await foundry.applications.api.DialogV2.wait({
window: { title: game.i18n.format("OATHHAMMER.Dialog.DefenseTitle", { actor: actor.name }) },
window: { title: game.i18n.format("OATHHAMMER.Dialog.DefenseTitle", { actor: actor.name }), resizable: true },
classes: ["fvtt-oath-hammer"],
position: { width: 420 },
content,

View File

@@ -30,6 +30,15 @@ export default class OathHammerMiracleDialog {
return { value: v, label: v > 0 ? `+${v}` : String(v), selected: v === 0 }
})
const availableLuck = actorSys.luck?.value ?? 0
const isHuman = (actorSys.lineage?.name ?? "").toLowerCase() === "human"
const luckDicePerPoint = isHuman ? 3 : 2
const luckOptions = Array.from({ length: availableLuck + 1 }, (_, i) => ({
value: i,
label: i === 0 ? "0" : `${i} (+${i * luckDicePerPoint}d)`,
selected: i === 0,
}))
const rollModes = foundry.utils.duplicate(CONFIG.Dice.rollModes)
const context = {
@@ -47,6 +56,9 @@ export default class OathHammerMiracleDialog {
basePool,
miracleCountOptions,
bonusOptions,
availableLuck,
isHuman,
luckOptions,
rollModes,
visibility: game.settings.get("core", "rollMode"),
}
@@ -84,6 +96,8 @@ export default class OathHammerMiracleDialog {
bonus: parseInt(result.bonus) || 0,
visibility: result.visibility ?? game.settings.get("core", "rollMode"),
explodeOn5: result.explodeOn5 === "true",
luckSpend: Math.min(Math.max(0, parseInt(result.luckSpend) || 0), availableLuck),
luckIsHuman: result.luckIsHuman === "true",
}
}
}

View File

@@ -124,7 +124,7 @@ export default class OathHammerRollDialog {
const title = game.i18n.format("OATHHAMMER.Dialog.SkillCheckTitle", { skill: context.skillLabel })
const result = await foundry.applications.api.DialogV2.wait({
window: { title },
window: { title, resizable: true },
classes: ["fvtt-oath-hammer"],
position: { width: 420 },
content,

View File

@@ -37,6 +37,8 @@ export default class OathHammerCharacterSheet extends OathHammerActorSheet {
rollInitiative: OathHammerCharacterSheet.#onRollInitiative,
adjustQty: OathHammerCharacterSheet.#onAdjustQty,
adjustCurrency: OathHammerCharacterSheet.#onAdjustCurrency,
adjustStress: OathHammerCharacterSheet.#onAdjustStress,
clearStress: OathHammerCharacterSheet.#onClearStress,
},
}
@@ -201,6 +203,7 @@ export default class OathHammerCharacterSheet extends OathHammerActorSheet {
break
case "magic":
context.tab = context.tabs.magic
context.stressBlocked = doc.system.arcaneStress.value >= doc.system.arcaneStress.threshold
context.spells = doc.itemTypes.spell.map(s => ({
id: s.id, uuid: s.uuid, img: s.img, name: s.name, system: s.system,
_descTooltip: _stripHtml(s.system.effect)
@@ -404,6 +407,17 @@ export default class OathHammerCharacterSheet extends OathHammerActorSheet {
const current = foundry.utils.getProperty(this.document, field) ?? 0
await this.document.update({ [field]: Math.max(0, current + delta) })
}
static async #onAdjustStress(event, target) {
const delta = parseInt(target.dataset.delta, 10)
const current = this.document.system.arcaneStress.value ?? 0
const max = this.document.system.arcaneStress.threshold
await this.document.update({ "system.arcaneStress.value": Math.max(0, Math.min(max, current + delta)) })
}
static async #onClearStress(_event, _target) {
await this.document.update({ "system.arcaneStress.value": 0 })
}
}
/** Strip HTML tags and collapse whitespace for use in data-tooltip attributes. */

View File

@@ -0,0 +1,132 @@
import OathHammerActorSheet from "./base-actor-sheet.mjs"
const ALLOWED_ITEM_TYPES = new Set(["building", "equipment", "weapon", "armor"])
export default class OathHammerSettlementSheet extends OathHammerActorSheet {
/** @override */
static DEFAULT_OPTIONS = {
classes: ["settlement"],
position: {
width: 840,
height: "auto",
},
window: {
contentClasses: ["settlement-content"],
},
actions: {
adjustCurrency: OathHammerSettlementSheet.#onAdjustCurrency,
adjustQty: OathHammerSettlementSheet.#onAdjustQty,
toggleConstructed: OathHammerSettlementSheet.#onToggleConstructed,
},
}
/** @override */
static PARTS = {
main: {
template: "systems/fvtt-oath-hammer/templates/actor/settlement-sheet.hbs",
},
tabs: {
template: "templates/generic/tab-navigation.hbs",
},
overview: {
template: "systems/fvtt-oath-hammer/templates/actor/settlement-overview.hbs",
},
buildings: {
template: "systems/fvtt-oath-hammer/templates/actor/settlement-buildings.hbs",
},
inventory: {
template: "systems/fvtt-oath-hammer/templates/actor/settlement-inventory.hbs",
},
}
/** @override */
tabGroups = {
sheet: "overview",
}
#getTabs() {
const tabs = {
overview: { id: "overview", group: "sheet", icon: "fa-solid fa-city", label: "OATHHAMMER.Tab.Overview" },
buildings: { id: "buildings", group: "sheet", icon: "fa-solid fa-building", label: "OATHHAMMER.Tab.Buildings" },
inventory: { id: "inventory", group: "sheet", icon: "fa-solid fa-boxes-stacked", label: "OATHHAMMER.Tab.Inventory" },
}
for (const v of Object.values(tabs)) {
v.active = this.tabGroups[v.group] === v.id
v.cssClass = v.active ? "active" : ""
}
return tabs
}
/** @override */
async _prepareContext() {
const context = await super._prepareContext()
context.tabs = this.#getTabs()
context.archetypeChoices = Object.fromEntries(
Object.entries(SYSTEM.SETTLEMENT_ARCHETYPES).map(([k, v]) => [k, game.i18n.localize(v)])
)
return context
}
/** @override */
async _preparePartContext(partId, context) {
const doc = this.document
switch (partId) {
case "main":
break
case "overview":
context.tab = context.tabs.overview
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(
doc.system.description, { async: true }
)
break
case "buildings":
context.tab = context.tabs.buildings
context.buildings = doc.itemTypes.building
break
case "inventory": {
context.tab = context.tabs.inventory
context.weapons = doc.itemTypes.weapon
context.armors = doc.itemTypes.armor
context.equipments = doc.itemTypes.equipment
break
}
}
return context
}
/** @override */
async _onDrop(event) {
if (!this.isEditable || !this.isEditMode) return
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event)
if (data.type !== "Item") return
const item = await fromUuid(data.uuid)
if (!item || !ALLOWED_ITEM_TYPES.has(item.type)) return
return this._onDropItem(item)
}
static async #onAdjustCurrency(event, target) {
const field = target.dataset.field
const delta = parseInt(target.dataset.delta, 10)
if (!field || isNaN(delta)) return
const current = foundry.utils.getProperty(this.document, field) ?? 0
await this.document.update({ [field]: Math.max(0, current + delta) })
}
static async #onAdjustQty(event, target) {
const itemId = target.dataset.itemId
const delta = parseInt(target.dataset.delta, 10)
if (!itemId || isNaN(delta)) return
const item = this.document.items.get(itemId)
if (!item) return
const current = item.system.quantity ?? 0
await item.update({ "system.quantity": Math.max(0, current + delta) })
}
static async #onToggleConstructed(event, target) {
const itemId = target.dataset.itemId
if (!itemId) return
const item = this.document.items.get(itemId)
if (!item) return
await item.update({ "system.constructed": !item.system.constructed })
}
}

View File

@@ -52,6 +52,22 @@ export default class OathHammerSpellDialog {
return { value: v, label: v > 0 ? `+${v}` : String(v), selected: v === 0 }
})
const availableLuck = actorSys.luck?.value ?? 0
const isHuman = (actorSys.lineage?.name ?? "").toLowerCase() === "human"
const luckDicePerPoint = isHuman ? 3 : 2
const luckOptions = Array.from({ length: availableLuck + 1 }, (_, i) => ({
value: i,
label: i === 0 ? "0" : `${i} (+${i * luckDicePerPoint}d)`,
selected: i === 0,
}))
// Pool size selector: casters may roll fewer dice to reduce Arcane Stress (p.101)
const poolSizeOptions = Array.from({ length: basePool }, (_, i) => ({
value: i + 1,
label: `${i + 1}d`,
selected: i + 1 === basePool,
}))
const rollModes = foundry.utils.duplicate(CONFIG.Dice.rollModes)
const context = {
@@ -70,11 +86,15 @@ export default class OathHammerSpellDialog {
intRank,
magicRank,
basePool,
poolSizeOptions,
currentStress,
stressThreshold,
isOverThreshold,
enhancementOptions,
bonusOptions,
availableLuck,
isHuman,
luckOptions,
rollModes,
visibility: game.settings.get("core", "rollMode"),
}
@@ -116,9 +136,12 @@ export default class OathHammerSpellDialog {
noStress: enh.noStress,
elementalBonus: parseInt(result.elementalBonus) || 0,
bonus: parseInt(result.bonus) || 0,
poolSize: Math.min(Math.max(1, parseInt(result.poolSize) || basePool), basePool),
grimPenalty: parseInt(result.noGrimoire) || 0,
visibility: result.visibility ?? game.settings.get("core", "rollMode"),
explodeOn5: result.explodeOn5 === "true",
luckSpend: Math.min(Math.max(0, parseInt(result.luckSpend) || 0), availableLuck),
luckIsHuman: result.luckIsHuman === "true",
}
}
}

View File

@@ -120,7 +120,7 @@ export default class OathHammerWeaponDialog {
)
const result = await foundry.applications.api.DialogV2.wait({
window: { title: game.i18n.format("OATHHAMMER.Dialog.AttackTitle", { weapon: weapon.name }) },
window: { title: game.i18n.format("OATHHAMMER.Dialog.AttackTitle", { weapon: weapon.name }), resizable: true },
classes: ["fvtt-oath-hammer"],
position: { width: 420 },
content,
@@ -268,7 +268,7 @@ export default class OathHammerWeaponDialog {
)
const result = await foundry.applications.api.DialogV2.wait({
window: { title: game.i18n.format("OATHHAMMER.Dialog.WeaponDefenseTitle", { weapon: weapon.name }) },
window: { title: game.i18n.format("OATHHAMMER.Dialog.WeaponDefenseTitle", { weapon: weapon.name }), resizable: true },
classes: ["fvtt-oath-hammer"],
position: { width: 420 },
content,
@@ -375,7 +375,7 @@ export default class OathHammerWeaponDialog {
)
const result = await foundry.applications.api.DialogV2.wait({
window: { title: game.i18n.format("OATHHAMMER.Dialog.DamageTitle", { weapon: weapon.name }) },
window: { title: game.i18n.format("OATHHAMMER.Dialog.DamageTitle", { weapon: weapon.name }), resizable: true },
classes: ["fvtt-oath-hammer"],
position: { width: 420 },
content,