Enhance sheets and add skill+effects

This commit is contained in:
2026-05-22 20:14:28 +02:00
parent 78fa804dc5
commit e3f9dedcf6
18 changed files with 459 additions and 35 deletions
+2
View File
@@ -8,3 +8,5 @@ export { default as AwEBackgroundSheet } from "./sheets/background-sheet.mjs"
export { default as AwEKitSheet } from "./sheets/kit-sheet.mjs"
export { default as AwEWeaponSheet } from "./sheets/weapon-sheet.mjs"
export { default as AwEEquipmentSheet } from "./sheets/equipment-sheet.mjs"
export { default as AwESkillSheet } from "./sheets/skill-sheet.mjs"
export { default as AwEEffectSheet } from "./sheets/effect-sheet.mjs"
@@ -14,6 +14,8 @@ export default class AwECharacterSheet extends AwEActorSheet {
},
actions: {
createAbility: AwECharacterSheet.#onCreateAbility,
createSkill: AwECharacterSheet.#onCreateSkill,
createEffect: AwECharacterSheet.#onCreateEffect,
createWeapon: AwECharacterSheet.#onCreateWeapon,
createKit: AwECharacterSheet.#onCreateKit,
createEquipment: AwECharacterSheet.#onCreateEquipment,
@@ -94,6 +96,20 @@ export default class AwECharacterSheet extends AwEActorSheet {
usedToday: item.system.usedToday
}))
context.hasUsedAbilities = context.abilities.some(a => a.usedToday)
context.skills = doc.itemTypes.skill.map(item => ({
id: item.id,
uuid: item.uuid,
name: item.name,
img: item.img,
system: item.system
}))
context.effects = doc.itemTypes.effect.map(item => ({
id: item.id,
uuid: item.uuid,
name: item.name,
img: item.img,
system: item.system
}))
context.conditions = Object.values(SYSTEM.CONDITIONS).map(c => ({
...c,
label: game.i18n.localize(c.label),
@@ -188,6 +204,26 @@ export default class AwECharacterSheet extends AwEActorSheet {
this.document.createEmbeddedDocuments("Item", [{ name: CONFIG.Item.documentClass.defaultName({ type }), type }])
}
/**
* Create a new skill item.
* @param {Event} event - The triggering event.
* @param {HTMLElement} target - The target element.
*/
static #onCreateSkill(event, target) {
const type = "skill"
this.document.createEmbeddedDocuments("Item", [{ name: CONFIG.Item.documentClass.defaultName({ type }), type }])
}
/**
* Create a new effect item.
* @param {Event} event - The triggering event.
* @param {HTMLElement} target - The target element.
*/
static #onCreateEffect(event, target) {
const type = "effect"
this.document.createEmbeddedDocuments("Item", [{ name: CONFIG.Item.documentClass.defaultName({ type }), type }])
}
/**
* Create a new weapon item.
* @param {Event} event - The triggering event.
+106 -3
View File
@@ -1,4 +1,5 @@
import AwEActorSheet from "./base-actor-sheet.mjs"
import { SYSTEM } from "../../config/system.mjs"
export default class AwECreatureSheet extends AwEActorSheet {
/** @override */
@@ -10,6 +11,16 @@ export default class AwECreatureSheet extends AwEActorSheet {
},
window: {
contentClasses: ["creature-content"]
},
actions: {
createAbility: AwECreatureSheet.#onCreateAbility,
createSkill: AwECreatureSheet.#onCreateSkill,
createEffect: AwECreatureSheet.#onCreateEffect,
createWeapon: AwECreatureSheet.#onCreateWeapon,
createKit: AwECreatureSheet.#onCreateKit,
createEquipment: AwECreatureSheet.#onCreateEquipment,
rollWeapon: AwECreatureSheet.#onRollWeapon,
rollDamage: AwECreatureSheet.#onRollDamage
}
}
@@ -24,6 +35,9 @@ export default class AwECreatureSheet extends AwEActorSheet {
main: {
template: "systems/fvtt-adventures-with-emmy/templates/creature-main.hbs"
},
inventory: {
template: "systems/fvtt-adventures-with-emmy/templates/creature-inventory.hbs"
},
description: {
template: "systems/fvtt-adventures-with-emmy/templates/creature-description.hbs"
},
@@ -39,9 +53,10 @@ export default class AwECreatureSheet extends AwEActorSheet {
#getTabs() {
const tabs = {
main: { id: "main", group: "sheet", icon: "fa-solid fa-dragon", label: "AWEMMY.Sheet.Tab.Main" },
description: { id: "description", group: "sheet", icon: "fa-solid fa-scroll", label: "AWEMMY.Sheet.Tab.Description" },
eureka: { id: "eureka", group: "sheet", icon: "fa-solid fa-lightbulb", label: "AWEMMY.Sheet.Tab.Eureka" }
main: { id: "main", group: "sheet", icon: "fa-solid fa-dragon", label: "AWEMMY.Sheet.Tab.Main" },
inventory: { id: "inventory", group: "sheet", icon: "fa-solid fa-backpack", label: "AWEMMY.Sheet.Tab.Inventory" },
description: { id: "description", group: "sheet", icon: "fa-solid fa-scroll", label: "AWEMMY.Sheet.Tab.Description" },
eureka: { id: "eureka", group: "sheet", icon: "fa-solid fa-lightbulb", label: "AWEMMY.Sheet.Tab.Eureka" }
}
for (const v of Object.values(tabs)) {
v.active = this.tabGroups[v.group] === v.id
@@ -65,6 +80,34 @@ export default class AwECreatureSheet extends AwEActorSheet {
switch (partId) {
case "main":
context.tab = context.tabs.main
context.abilities = this.document.itemTypes.ability.map(item => ({
id: item.id,
uuid: item.uuid,
name: item.name,
img: item.img,
system: item.system,
costLabel: game.i18n.localize(SYSTEM.ABILITY_COST[item.system.cost]?.label ?? item.system.cost)
}))
context.skills = this.document.itemTypes.skill.map(item => ({
id: item.id,
uuid: item.uuid,
name: item.name,
img: item.img,
system: item.system
}))
context.effects = this.document.itemTypes.effect.map(item => ({
id: item.id,
uuid: item.uuid,
name: item.name,
img: item.img,
system: item.system
}))
break
case "inventory":
context.tab = context.tabs.inventory
context.kits = this.document.itemTypes.kit
context.weapons = this.document.itemTypes.weapon
context.equipments = this.document.itemTypes.equipment
break
case "description":
context.tab = context.tabs.description
@@ -75,4 +118,64 @@ export default class AwECreatureSheet extends AwEActorSheet {
}
return context
}
/** @override */
async _onDrop(event) {
if (!this.isEditable) return
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event)
if (data.type === "Item") {
const item = await fromUuid(data.uuid)
return this._onDropItem(item)
}
}
/** @override */
async _onDropItem(item) {
if (!item) return
return super._onDropItem(item)
}
static #onCreateAbility(event, target) {
const type = "ability"
this.document.createEmbeddedDocuments("Item", [{ name: CONFIG.Item.documentClass.defaultName({ type }), type }])
}
static #onCreateSkill(event, target) {
const type = "skill"
this.document.createEmbeddedDocuments("Item", [{ name: CONFIG.Item.documentClass.defaultName({ type }), type }])
}
static #onCreateEffect(event, target) {
const type = "effect"
this.document.createEmbeddedDocuments("Item", [{ name: CONFIG.Item.documentClass.defaultName({ type }), type }])
}
static #onCreateWeapon(event, target) {
const type = "weapon"
this.document.createEmbeddedDocuments("Item", [{ name: CONFIG.Item.documentClass.defaultName({ type }), type }])
}
static #onCreateKit(event, target) {
const type = "kit"
this.document.createEmbeddedDocuments("Item", [{ name: CONFIG.Item.documentClass.defaultName({ type }), type }])
}
static #onCreateEquipment(event, target) {
const type = "equipment"
this.document.createEmbeddedDocuments("Item", [{ name: CONFIG.Item.documentClass.defaultName({ type }), type }])
}
static async #onRollWeapon(event, target) {
const itemId = target.closest("[data-item-id]")?.dataset.itemId
const item = this.document.items.get(itemId)
if (!item) return
await this.document.rollWeapon(item)
}
static async #onRollDamage(event, target) {
const itemId = target.closest("[data-item-id]")?.dataset.itemId
const item = this.document.items.get(itemId)
if (!item) return
await this.document.rollDamage(item)
}
}
@@ -0,0 +1,17 @@
import AwEItemSheet from "./base-item-sheet.mjs"
export default class AwEEffectSheet extends AwEItemSheet {
/** @override */
static DEFAULT_OPTIONS = {
classes: ["effect"],
position: { width: 500 },
window: { contentClasses: ["effect-content"] }
}
/** @override */
static PARTS = {
main: {
template: "systems/fvtt-adventures-with-emmy/templates/effect.hbs"
}
}
}
@@ -0,0 +1,17 @@
import AwEItemSheet from "./base-item-sheet.mjs"
export default class AwESkillSheet extends AwEItemSheet {
/** @override */
static DEFAULT_OPTIONS = {
classes: ["skill"],
position: { width: 500 },
window: { contentClasses: ["skill-content"] }
}
/** @override */
static PARTS = {
main: {
template: "systems/fvtt-adventures-with-emmy/templates/skill.hbs"
}
}
}