Add Enemy sheet
This commit is contained in:
@@ -34,6 +34,7 @@ export default class HellbornActorSheet extends HandlebarsApplicationMixin(found
|
||||
edit: HellbornActorSheet.#onItemEdit,
|
||||
delete: HellbornActorSheet.#onItemDelete,
|
||||
updateCheckboxArray: HellbornActorSheet.#onUpdateCheckboxArray,
|
||||
toChat: HellbornActorSheet.#toChat,
|
||||
|
||||
},
|
||||
}
|
||||
@@ -138,7 +139,7 @@ export default class HellbornActorSheet extends HandlebarsApplicationMixin(found
|
||||
* @param {DragEvent} event The originating DragEvent
|
||||
* @protected
|
||||
*/
|
||||
_onDragOver(event) {}
|
||||
_onDragOver(event) { }
|
||||
|
||||
async _onDropItem(item) {
|
||||
console.log("Dropped item", item)
|
||||
@@ -193,9 +194,31 @@ export default class HellbornActorSheet extends HandlebarsApplicationMixin(found
|
||||
let dataPath = `system.mortality.${arrayName}`
|
||||
let tab = foundry.utils.duplicate(this.document.system.mortality[arrayName])
|
||||
tab[arrayIdx] = target.checked
|
||||
this.actor.update( { [dataPath]: tab } )
|
||||
// Dump
|
||||
console.log("Array name", arrayName, arrayIdx, target.checked, dataPath)
|
||||
this.actor.update({ [dataPath]: tab })
|
||||
}
|
||||
|
||||
static async #toChat(event, target) {
|
||||
const itemUuid = target.getAttribute("data-item-uuid")
|
||||
const item = fromUuidSync(itemUuid)
|
||||
if (!item) return
|
||||
let content = ""
|
||||
if (item.type === "perk") {
|
||||
content = await foundry.applications.handlebars.renderTemplate("systems/fvtt-hellborn/templates/chat-perk.hbs", item.toObject())
|
||||
}
|
||||
if (item.type === "malefica") {
|
||||
content = await foundry.applications.handlebars.renderTemplate("systems/fvtt-hellborn/templates/chat-malefica.hbs", item.toObject())
|
||||
}
|
||||
if (item.type === "ritual") {
|
||||
content = await foundry.applications.handlebars.renderTemplate("systems/fvtt-hellborn/templates/chat-ritual.hbs", item.toObject())
|
||||
}
|
||||
const chatData = {
|
||||
user: game.user.id,
|
||||
speaker: ChatMessage.getSpeaker({ actor: this.actor }),
|
||||
content: content,
|
||||
type: CONST.CHAT_MESSAGE_TYPES.OTHER,
|
||||
}
|
||||
ChatMessage.create(chatData, { renderSheet: false })
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -124,7 +124,6 @@ export default class HellbornCharacterSheet extends HellbornActorSheet {
|
||||
context.enrichedNotes = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.notes, { async: true })
|
||||
break
|
||||
}
|
||||
console.log("context", context)
|
||||
return context
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ export default class HellbornDealSheet extends HellbornItemSheet {
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext()
|
||||
context.enrichedDescription = await TextEditor.enrichHTML(this.document.system.description, { async: true })
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true })
|
||||
return context
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +1,34 @@
|
||||
import HellbornActorSheet from "./base-actor-sheet.mjs"
|
||||
|
||||
export default class HellbornCreatureSheet extends HellbornActorSheet {
|
||||
export default class HellbornEnemySheet extends HellbornActorSheet {
|
||||
/** @override */
|
||||
static DEFAULT_OPTIONS = {
|
||||
classes: ["creature"],
|
||||
classes: ["enemy"],
|
||||
position: {
|
||||
width: 860,
|
||||
height: 620,
|
||||
},
|
||||
window: {
|
||||
contentClasses: ["creature-content"],
|
||||
contentClasses: ["enemy-content"],
|
||||
},
|
||||
actions: {
|
||||
createTrait: HellbornCreatureSheet.#onCreateTrait,
|
||||
createAbility: HellbornCreatureSheet.#onCreateAbility
|
||||
createTrait: HellbornEnemySheet.#onCreateTrait,
|
||||
},
|
||||
}
|
||||
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
main: {
|
||||
template: "systems/fvtt-hellborn/templates/creature-main.hbs",
|
||||
template: "systems/fvtt-hellborn/templates/enemy-main.hbs",
|
||||
},
|
||||
tabs: {
|
||||
template: "templates/generic/tab-navigation.hbs",
|
||||
},
|
||||
traits: {
|
||||
template: "systems/fvtt-hellborn/templates/creature-sheet-trait.hbs",
|
||||
template: "systems/fvtt-hellborn/templates/enemy-trait.hbs",
|
||||
},
|
||||
biography: {
|
||||
template: "systems/fvtt-hellborn/templates/creature-biography.hbs",
|
||||
template: "systems/fvtt-hellborn/templates/enemy-biography.hbs",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -59,9 +58,6 @@ export default class HellbornCreatureSheet extends HellbornActorSheet {
|
||||
const context = await super._prepareContext()
|
||||
context.tabs = this.#getTabs()
|
||||
|
||||
context.enrichedDescription = await TextEditor.enrichHTML(this.document.system.description, { async: true })
|
||||
context.enrichedNotes = await TextEditor.enrichHTML(this.document.system.notes, { async: true })
|
||||
|
||||
return context
|
||||
}
|
||||
|
||||
@@ -73,15 +69,15 @@ export default class HellbornCreatureSheet extends HellbornActorSheet {
|
||||
break
|
||||
case "traits":
|
||||
context.tab = context.tabs.traits
|
||||
context.abilities = doc.itemTypes["creature-ability"]
|
||||
context.abilities.sort((a, b) => a.name.localeCompare(b.name))
|
||||
context.traits = doc.itemTypes["creature-trait"]
|
||||
context.traits = doc.itemTypes["species-trait"]
|
||||
context.traits.sort((a, b) => a.name.localeCompare(b.name))
|
||||
context.weapons = doc.itemTypes.weapon
|
||||
context.weapons.sort((a, b) => a.name.localeCompare(b.name))
|
||||
break
|
||||
case "biography":
|
||||
context.tab = context.tabs.biography
|
||||
context.enrichedDescription = await TextEditor.enrichHTML(doc.system.description, { async: true })
|
||||
context.enrichedNotes = await TextEditor.enrichHTML(doc.system.notes, { async: true })
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(doc.system.description, { async: true })
|
||||
context.enrichedNotes = await foundry.applications.ux.TextEditor.implementation.enrichHTML(doc.system.notes, { async: true })
|
||||
break
|
||||
}
|
||||
return context
|
||||
@@ -93,11 +89,7 @@ export default class HellbornCreatureSheet extends HellbornActorSheet {
|
||||
* @param {HTMLElement} target The current target of the event listener.
|
||||
*/
|
||||
static #onCreateTrait(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("HELLBORN.Label.newTrait"), type: "creature-trait" }])
|
||||
}
|
||||
|
||||
static #onCreateAbility(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("HELLBORN.Label.newAbility"), type: "creature-ability" }])
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("HELLBORN.Label.newTrait"), type: "trait" }])
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,27 +109,21 @@ export default class HellbornCreatureSheet extends HellbornActorSheet {
|
||||
async _onRoll(event, target) {
|
||||
const rollType = $(event.currentTarget).data("roll-type")
|
||||
let item
|
||||
let formula
|
||||
let roll
|
||||
switch (rollType) {
|
||||
case "skill":
|
||||
let skillId = $(event.currentTarget).data("skill-id");
|
||||
item = this.actor.system.skills[skillId];
|
||||
await this.document.system.roll(rollType, item)
|
||||
case "stat":
|
||||
{
|
||||
let statId = $(event.currentTarget).data("stat-id");
|
||||
item = this.actor.system.stats[statId];
|
||||
await this.document.system.roll(rollType, item)
|
||||
}
|
||||
break
|
||||
case "creature-damage":
|
||||
formula = this.actor.system.damage
|
||||
// Rolll the damage
|
||||
roll = new Roll(formula)
|
||||
await roll.evaluate()
|
||||
roll.toMessage( { flavor: `${this.actor.name} : Damage roll` })
|
||||
break
|
||||
case "creature-number":
|
||||
formula = this.actor.system.numberAppearing
|
||||
// Rolll the damage
|
||||
roll = new Roll(formula)
|
||||
await roll.evaluate()
|
||||
roll.toMessage({flavor: `${this.actor.name} : Number Appearing roll`})
|
||||
case "weapon":
|
||||
case "damage":
|
||||
{
|
||||
let li = $(event.currentTarget).parents(".item");
|
||||
item = this.actor.items.get(li.data("item-id"));
|
||||
await this.document.system.roll(rollType, item)
|
||||
}
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unknown roll type ${rollType}`)
|
||||
@@ -22,7 +22,7 @@ export default class HellbornEquipmentSheet extends HellbornItemSheet {
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext()
|
||||
context.enrichedDescription = await TextEditor.enrichHTML(this.document.system.description, { async: true })
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true })
|
||||
return context
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ export default class HellbornMaleficaSheet extends HellbornItemSheet {
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext()
|
||||
context.enrichedDescription = await TextEditor.enrichHTML(this.document.system.description, { async: true })
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true })
|
||||
return context
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ export default class HellbornPerkSheet extends HellbornItemSheet {
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext()
|
||||
context.enrichedDescription = await TextEditor.enrichHTML(this.document.system.description, { async: true })
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true })
|
||||
return context
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ export default class HellbornRitualSheet extends HellbornItemSheet {
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext()
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true })
|
||||
|
||||
return context
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ export default class HellbornSpeciesTraitSheet extends HellbornItemSheet {
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext()
|
||||
context.enrichedDescription = await TextEditor.enrichHTML(this.document.system.description, { async: true })
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true })
|
||||
return context
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,134 +0,0 @@
|
||||
import HellbornActorSheet from "./base-actor-sheet.mjs"
|
||||
|
||||
export default class HellbornVehicleSheet extends HellbornActorSheet {
|
||||
/** @override */
|
||||
static DEFAULT_OPTIONS = {
|
||||
classes: ["vehicle"],
|
||||
position: {
|
||||
width: 680,
|
||||
height: 540,
|
||||
},
|
||||
window: {
|
||||
contentClasses: ["vehicle-content"],
|
||||
},
|
||||
actions: {
|
||||
createEquipment: HellbornVehicleSheet.#onCreateEquipment,
|
||||
createWeapon: HellbornVehicleSheet.#onCreateWeapon,
|
||||
},
|
||||
}
|
||||
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
main: {
|
||||
template: "systems/fvtt-hellborn/templates/vehicle-main.hbs",
|
||||
},
|
||||
tabs: {
|
||||
template: "templates/generic/tab-navigation.hbs",
|
||||
},
|
||||
equipment: {
|
||||
template: "systems/fvtt-hellborn/templates/vehicle-equipment.hbs",
|
||||
},
|
||||
description: {
|
||||
template: "systems/fvtt-hellborn/templates/vehicle-description.hbs",
|
||||
},
|
||||
}
|
||||
|
||||
/** @override */
|
||||
tabGroups = {
|
||||
sheet: "equipment",
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare an array of form header tabs.
|
||||
* @returns {Record<string, Partial<ApplicationTab>>}
|
||||
*/
|
||||
#getTabs() {
|
||||
const tabs = {
|
||||
equipment: { id: "equipment", group: "sheet", icon: "fa-solid fa-shapes", label: "HELLBORN.Label.equipment" },
|
||||
description: { id: "description", group: "sheet", icon: "fa-solid fa-book", label: "HELLBORN.Label.description" },
|
||||
}
|
||||
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.enrichedDescription = await TextEditor.enrichHTML(this.document.system.description, { async: true })
|
||||
context.enrichedNotes = await TextEditor.enrichHTML(this.document.system.notes, { async: true })
|
||||
|
||||
return context
|
||||
}
|
||||
|
||||
_generateTooltip(type, target) {
|
||||
}
|
||||
|
||||
/** @override */
|
||||
async _preparePartContext(partId, context) {
|
||||
const doc = this.document
|
||||
switch (partId) {
|
||||
case "main":
|
||||
break
|
||||
case "equipment":
|
||||
context.tab = context.tabs.equipment
|
||||
context.weapons = doc.itemTypes.weapon
|
||||
context.weapons.sort((a, b) => a.name.localeCompare(b.name))
|
||||
context.equipments = doc.itemTypes.equipment
|
||||
context.equipments.sort((a, b) => a.name.localeCompare(b.name))
|
||||
break
|
||||
case "description":
|
||||
context.tab = context.tabs.description
|
||||
context.enrichedDescription = await TextEditor.enrichHTML(doc.system.description, { async: true })
|
||||
context.enrichedNotes = await TextEditor.enrichHTML(doc.system.notes, { async: true })
|
||||
break
|
||||
}
|
||||
return context
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new attack item directly from the sheet and embeds it into the document.
|
||||
* @param {Event} event The initiating click event.
|
||||
* @param {HTMLElement} target The current target of the event listener.
|
||||
*/
|
||||
static #onCreateEquipment(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("HELLBORN.Label.newEquipment"), type: "equipment" }])
|
||||
}
|
||||
|
||||
static #onCreateWeapon(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("HELLBORN.Label.newWeapon"), type: "weapon" }])
|
||||
}
|
||||
|
||||
async _onRoll(event, target) {
|
||||
const rollType = $(event.currentTarget).data("roll-type")
|
||||
let item
|
||||
let li
|
||||
switch (rollType) {
|
||||
case "damage":
|
||||
li = $(event.currentTarget).parents(".item");
|
||||
item = this.actor.items.get(li.data("item-id"));
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unknown roll type ${rollType}`)
|
||||
}
|
||||
await this.document.system.roll(rollType, item)
|
||||
}
|
||||
|
||||
|
||||
async _onDrop(event) {
|
||||
if (!this.isEditable || !this.isEditMode) return
|
||||
const data = TextEditor.getDragEventData(event)
|
||||
|
||||
// Handle different data types
|
||||
switch (data.type) {
|
||||
case "Item":
|
||||
const item = await fromUuid(data.uuid)
|
||||
return super._onDropItem(item)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,4 +18,10 @@ export default class HellbornWeaponSheet extends HellbornItemSheet {
|
||||
template: "systems/fvtt-hellborn/templates/weapon.hbs",
|
||||
},
|
||||
}
|
||||
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext()
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true })
|
||||
return context
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user