Nombreuses corrections sur les fiches settlement/NPC
This commit is contained in:
80
module/applications/sheets/regiment-sheet.mjs
Normal file
80
module/applications/sheets/regiment-sheet.mjs
Normal file
@@ -0,0 +1,80 @@
|
||||
import OathHammerItemSheet from "./base-item-sheet.mjs"
|
||||
import { SYSTEM } from "../../config/system.mjs"
|
||||
|
||||
export default class OathHammerRegimentSheet extends OathHammerItemSheet {
|
||||
/** @override */
|
||||
static DEFAULT_OPTIONS = {
|
||||
classes: ["regiment"],
|
||||
position: { width: 560, height: "auto" },
|
||||
window: { contentClasses: ["regiment-content"] },
|
||||
actions: {
|
||||
addSkill: OathHammerRegimentSheet.#onAddSkill,
|
||||
removeSkill: OathHammerRegimentSheet.#onRemoveSkill,
|
||||
addAttack: OathHammerRegimentSheet.#onAddAttack,
|
||||
removeAttack:OathHammerRegimentSheet.#onRemoveAttack,
|
||||
addTrait: OathHammerRegimentSheet.#onAddTrait,
|
||||
removeTrait: OathHammerRegimentSheet.#onRemoveTrait,
|
||||
},
|
||||
}
|
||||
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
main: { template: "systems/fvtt-oath-hammer/templates/item/regiment-sheet.hbs" },
|
||||
}
|
||||
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext()
|
||||
context.colorChoices = Object.fromEntries(
|
||||
Object.entries(SYSTEM.DICE_COLOR_TYPES).map(([k, v]) => [k, game.i18n.localize(v)])
|
||||
)
|
||||
context.dicePoolChoices = Object.fromEntries(
|
||||
Array.from({ length: 21 }, (_, i) => [i, String(i)])
|
||||
)
|
||||
context.apChoices = Object.fromEntries(
|
||||
Array.from({ length: 7 }, (_, i) => [i, String(i)])
|
||||
)
|
||||
return context
|
||||
}
|
||||
|
||||
// ── Array helpers ────────────────────────────────────────────────────────────
|
||||
|
||||
static async #onAddSkill() {
|
||||
const skills = foundry.utils.deepClone(this.document.system.skills ?? [])
|
||||
skills.push({ name: "", value: 2, colorDiceType: "white" })
|
||||
await this.document.update({ "system.skills": skills })
|
||||
}
|
||||
|
||||
static async #onRemoveSkill(event, target) {
|
||||
const idx = parseInt(target.dataset.idx, 10)
|
||||
const skills = foundry.utils.deepClone(this.document.system.skills ?? [])
|
||||
skills.splice(idx, 1)
|
||||
await this.document.update({ "system.skills": skills })
|
||||
}
|
||||
|
||||
static async #onAddAttack() {
|
||||
const attacks = foundry.utils.deepClone(this.document.system.attacks ?? [])
|
||||
attacks.push({ name: "", damageDice: 6, colorDiceType: "white", ap: 0, special: "" })
|
||||
await this.document.update({ "system.attacks": attacks })
|
||||
}
|
||||
|
||||
static async #onRemoveAttack(event, target) {
|
||||
const idx = parseInt(target.dataset.idx, 10)
|
||||
const attacks = foundry.utils.deepClone(this.document.system.attacks ?? [])
|
||||
attacks.splice(idx, 1)
|
||||
await this.document.update({ "system.attacks": attacks })
|
||||
}
|
||||
|
||||
static async #onAddTrait() {
|
||||
const traits = foundry.utils.deepClone(this.document.system.traits ?? [])
|
||||
traits.push({ name: "", description: "" })
|
||||
await this.document.update({ "system.traits": traits })
|
||||
}
|
||||
|
||||
static async #onRemoveTrait(event, target) {
|
||||
const idx = parseInt(target.dataset.idx, 10)
|
||||
const traits = foundry.utils.deepClone(this.document.system.traits ?? [])
|
||||
traits.splice(idx, 1)
|
||||
await this.document.update({ "system.traits": traits })
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user