Initial import with skill sheet worning

This commit is contained in:
2024-11-30 08:38:13 +01:00
parent 2e96b256fb
commit df8995f8b7
52 changed files with 6986 additions and 2189 deletions

View File

@ -1,10 +1,11 @@
export { default as LethalFantasyCharacterSheet } from "./sheets/character-sheet.mjs"
export { default as LethalFantasyCharacterSheet } from "./sheets/character-sheet.mjs";
export { default as LethalFantasyOpponentSheet } from "./sheets/opponent-sheet.mjs"
export { default as LethalFantasyPathSheet } from "./sheets/path-sheet.mjs"
export { default as LethalFantasyTalentSheet } from "./sheets/talent-sheet.mjs"
export { default as LethalFantasyWeaponSheet } from "./sheets/weapon-sheet.mjs"
export { default as LethalFantasySkillSheet } from "./sheets/skill-sheet.mjs"
export { default as LethalFantasyGiftSheet } from "./sheets/gift-sheet.mjs"
export { default as LethalFantasyVulnerabilitySheet } from "./sheets/vulnerability-sheet.mjs"
export { default as LethalFantasySaveSheet } from "./sheets/save-sheet.mjs"
export { default as LethalFantasyArmorSheet } from "./sheets/armor-sheet.mjs"
export { default as LethalFantasySpellSheet } from "./sheets/spell-sheet.mjs"
export { default as LethalFantasyAttackSheet } from "./sheets/attack-sheet.mjs"
export { default as LethalFantasyFortune } from "./fortune.mjs"
export { default as LethalFantasyEquipmentSheet } from "./sheets/equipment-sheet.mjs"
export { default as LethalFantasyManager } from "./manager.mjs"

View File

@ -1,156 +0,0 @@
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api
import { SYSTEM } from "../config/system.mjs"
/**
* An application for configuring the permissions which are available to each User role.
* @extends ApplicationV2
* @mixes HandlebarsApplication
* @alias PermissionConfig
*/
export default class LethalFantasyFortune extends HandlebarsApplicationMixin(ApplicationV2) {
/** @inheritDoc */
static DEFAULT_OPTIONS = {
id: "tenebris-application-fortune",
tag: "form",
window: {
contentClasses: ["tenebris-fortune"],
title: "TENEBRIS.Fortune.title",
controls: [],
},
position: {
width: 200,
height: 200,
top: 80,
left: 150,
},
form: {
closeOnSubmit: true,
},
actions: {
fortune: LethalFantasyFortune.#requestFortune,
increaseFortune: LethalFantasyFortune.#increaseFortune,
decreaseFortune: LethalFantasyFortune.#decreaseFortune,
},
}
/** @override */
_getHeaderControls() {
const controls = []
if (game.user.isGM) {
controls.push(
{
action: "increaseFortune",
icon: "fa fa-plus",
label: "Augmenter",
},
{
action: "decreaseFortune",
icon: "fa fa-minus",
label: "Diminuer",
},
)
}
return controls
}
/** @override */
static PARTS = {
main: {
template: "systems/fvtt-lethal-fantasy/templates/fortune.hbs",
},
}
/* -------------------------------------------- */
/* Rendering */
/* -------------------------------------------- */
/** @override */
async _prepareContext(_options = {}) {
return {
fortune: game.settings.get("tenebris", "fortune"),
userId: game.user.id,
isGM: game.user.isGM,
}
}
/**
* Handles the request for a fortune.
*
* @param {Event} event The event that triggered the request.
* @param {Object} target The target object for the request.
* @private
*/
static #requestFortune(event, target) {
console.debug("request Fortune, event, target")
game.socket.emit(`system.${SYSTEM.id}`, {
action: "fortune",
data: {
userId: game.user.id,
},
})
}
static async #increaseFortune(event, target) {
console.log("increase Fortune", event, target)
const currentValue = game.settings.get("tenebris", "fortune")
const newValue = currentValue + 1
await game.settings.set("tenebris", "fortune", newValue)
}
static async #decreaseFortune(event, target) {
console.log("decrease Fortune", event, target)
const currentValue = game.settings.get("tenebris", "fortune")
if (currentValue > 0) {
const newValue = currentValue - 1
await game.settings.set("tenebris", "fortune", newValue)
}
}
/**
* Handles the fortune spcket event for a given user.
*
* @param {Object} [options] The options object.
* @param {string} [options.userId] The ID of the user.
* @returns {Promise<ChatMessage>} - The created chat message.
*/
static async handleSocketEvent({ userId } = {}) {
console.debug(`handleSocketEvent Fortune from ${userId} !`)
const origin = game.users.get(userId)
const chatData = {
name: origin.name,
actingCharImg: origin.character?.img,
origin: origin,
user: game.user,
isGM: game.user.isGM,
}
const content = await renderTemplate("systems/fvtt-lethal-fantasy/templates/chat-fortune.hbs", chatData)
const messageData = {
style: CONST.CHAT_MESSAGE_STYLES.OTHER,
user: origin,
speaker: { user: origin },
content: content,
flags: { tenebris: { typeMessage: "fortune", accepted: false } },
}
ChatMessage.applyRollMode(messageData, CONST.DICE_ROLL_MODES.PRIVATE)
return ChatMessage.implementation.create(messageData)
}
/**
* Handles the acceptance of a request event in the chat message by the GM
*
* @param {Event} event The event object that triggered the request.
* @param {HTMLElement} html The HTML element associated with the event.
* @param {Object} data Additional data related to the event.
* @returns {Promise<void>} A promise that resolves when the request has been processed.
*/
static async acceptRequest(event, html, data) {
console.debug("acceptRequest Fortune", event, html, data)
const currentValue = game.settings.get("tenebris", "fortune")
if (currentValue > 0) {
const newValue = currentValue - 1
await game.settings.set("tenebris", "fortune", newValue)
}
let message = game.messages.get(data.message._id)
message.update({ "flags.tenebris.accepted": true })
}
}

View File

@ -9,11 +9,11 @@ import { SYSTEM } from "../config/system.mjs"
*/
export default class LethalFantasyManager extends HandlebarsApplicationMixin(ApplicationV2) {
static DEFAULT_OPTIONS = {
id: "tenebris-application-manager",
id: "lethalfantasy-application-manager",
tag: "form",
window: {
contentClasses: ["tenebris-manager"],
title: "TENEBRIS.Manager.title",
contentClasses: ["lethalfantasy-manager"],
title: "LETHALFANTASY.Manager.title",
resizable: true,
},
position: {
@ -82,22 +82,22 @@ export default class LethalFantasyManager extends HandlebarsApplicationMixin(App
}
static async askRollForAll(type, value, title = null, avantage = null) {
let label = game.i18n.localize(`TENEBRIS.Manager.${value}`)
let text = game.i18n.format("TENEBRIS.Chat.askRollForAll", { value: label })
let label = game.i18n.localize(`LETHALFANTASY.Manager.${value}`)
let text = game.i18n.format("LETHALFANTASY.Chat.askRollForAll", { value: label })
if (avantage) {
switch (avantage) {
case "++":
text += ` ${game.i18n.localize("TENEBRIS.Roll.doubleAvantage")}`
text += ` ${game.i18n.localize("LETHALFANTASY.Roll.doubleAvantage")}`
break
case "+":
text += ` ${game.i18n.localize("TENEBRIS.Roll.avantage")}`
text += ` ${game.i18n.localize("LETHALFANTASY.Roll.avantage")}`
break
case "-":
text += ` ${game.i18n.localize("TENEBRIS.Roll.desavantage")}`
text += ` ${game.i18n.localize("LETHALFANTASY.Roll.desavantage")}`
break
case "--":
text += ` ${game.i18n.localize("TENEBRIS.Roll.doubleDesavantage")}`
text += ` ${game.i18n.localize("LETHALFANTASY.Roll.doubleDesavantage")}`
break
default:
break
@ -118,8 +118,8 @@ export default class LethalFantasyManager extends HandlebarsApplicationMixin(App
}
static async askRollForOne(type, value, recipient, name) {
let label = game.i18n.localize(`TENEBRIS.Manager.${value}`)
const text = game.i18n.format("TENEBRIS.Chat.askRollForOne", { value: label, name: name })
let label = game.i18n.localize(`LETHALFANTASY.Manager.${value}`)
const text = game.i18n.format("LETHALFANTASY.Chat.askRollForOne", { value: label, name: name })
game.socket.emit(`system.${SYSTEM.id}`, {
action: "askRoll",

View File

@ -16,7 +16,7 @@ export default class LethalFantasyActorSheet extends HandlebarsApplicationMixin(
/** @override */
static DEFAULT_OPTIONS = {
classes: ["tenebris", "actor"],
classes: ["lethalfantasy", "actor"],
position: {
width: 1400,
height: "auto",

View File

@ -16,7 +16,7 @@ export default class LethalFantasyItemSheet extends HandlebarsApplicationMixin(f
/** @override */
static DEFAULT_OPTIONS = {
classes: ["tenebris", "item"],
classes: ["lethalfantasy", "item"],
position: {
width: 600,
height: "auto",

View File

@ -1,21 +1,21 @@
import LethalFantasyItemSheet from "./base-item-sheet.mjs"
export default class LethalFantasyAttackSheet extends LethalFantasyItemSheet {
export default class LethalFantasyEquipmentSheet extends LethalFantasyItemSheet {
/** @override */
static DEFAULT_OPTIONS = {
classes: ["attack"],
classes: ["equipment"],
position: {
width: 600,
},
window: {
contentClasses: ["attack-content"],
contentClasses: ["equipment-content"],
},
}
/** @override */
static PARTS = {
main: {
template: "systems/fvtt-lethal-fantasy/templates/attack.hbs",
template: "systems/fvtt-lethal-fantasy/templates/equipment.hbs",
},
}

View File

@ -1,21 +1,21 @@
import LethalFantasyItemSheet from "./base-item-sheet.mjs"
export default class LethalFantasyTalentSheet extends LethalFantasyItemSheet {
export default class LethalFantasyGiftSheet extends LethalFantasyItemSheet {
/** @override */
static DEFAULT_OPTIONS = {
classes: ["talent"],
classes: ["gift"],
position: {
width: 600,
},
window: {
contentClasses: ["talent-content"],
contentClasses: ["gift-content"],
},
}
/** @override */
static PARTS = {
main: {
template: "systems/fvtt-lethal-fantasy/templates/talent.hbs",
template: "systems/fvtt-lethal-fantasy/templates/gift.hbs",
},
}
@ -23,7 +23,6 @@ export default class LethalFantasyTalentSheet extends LethalFantasyItemSheet {
async _prepareContext() {
const context = await super._prepareContext()
context.enrichedDescription = await TextEditor.enrichHTML(this.document.system.improvedDescription, { async: true })
context.canProgress = this.document.system.canProgress
return context
}
}

View File

@ -1,141 +0,0 @@
import LethalFantasyItemSheet from "./base-item-sheet.mjs"
export default class LethalFantasyPathSheet extends LethalFantasyItemSheet {
/** @override */
static DEFAULT_OPTIONS = {
classes: ["path"],
position: {
width: 1400,
},
window: {
contentClasses: ["path-content"],
},
dragDrop: [{ dragSelector: "[data-drag]", dropSelector: null }],
actions: {
edit: LethalFantasyPathSheet.#onTalentEdit,
delete: LethalFantasyPathSheet.#onTalentDelete,
},
}
/** @override */
static PARTS = {
header: {
template: "systems/fvtt-lethal-fantasy/templates/path-header.hbs",
},
tabs: {
template: "templates/generic/tab-navigation.hbs",
},
main: {
template: "systems/fvtt-lethal-fantasy/templates/path-main.hbs",
},
talents: {
template: "systems/fvtt-lethal-fantasy/templates/path-talents.hbs",
},
}
/** @override */
tabGroups = {
sheet: "main",
}
/**
* Prepare an array of form header tabs.
* @returns {Record<string, Partial<ApplicationTab>>}
*/
#getTabs() {
const tabs = {
main: { id: "main", group: "sheet", icon: "fa-solid fa-user", label: "TENEBRIS.Label.profil" },
talents: { id: "talents", group: "sheet", icon: "fa-solid fa-book", label: "TENEBRIS.Label.talents" },
}
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()
return context
}
/** @override */
async _preparePartContext(partId, context) {
const doc = this.document
switch (partId) {
case "main":
context.tab = context.tabs.main
context.enrichedBiens = await TextEditor.enrichHTML(this.document.system.biens, { async: true })
context.enrichedLangues = await TextEditor.enrichHTML(this.document.system.langues, { async: true })
break
case "talents":
context.tab = context.tabs.talents
const talentItems = []
for (const talent of this.item.system.talents) {
const talentItem = await fromUuid(talent)
if (talentItem) talentItems.push(talentItem)
}
context.talents = talentItems
context.talents.sort((a, b) => a.name.localeCompare(b.name, game.i18n.lang))
break
}
return context
}
/**
* Callback actions which occur when a dragged element is dropped on a target.
* Seul un item de type Talent peut être déposé sur une voie.
* @param {DragEvent} event The originating DragEvent
* @protected
*/
async _onDrop(event) {
const data = TextEditor.getDragEventData(event)
switch (data.type) {
case "Item":
if (this.isPlayMode) return
const item = await fromUuid(data.uuid)
if (item.type !== "talent") return
console.debug("dropped item", item)
const talents = this.item.toObject().system.talents
talents.push(item.uuid)
this.item.update({ "system.talents": talents })
}
}
// #region Actions
/**
* Edit an existing talent within the path item
* Use the uuid to display the talent sheet (from world or compendium)
* @param {PointerEvent} event The originating click event
* @param {HTMLElement} target the capturing HTML element which defined a [data-action]
*/
static async #onTalentEdit(event, target) {
const itemUuid = target.getAttribute("data-item-uuid")
const talent = await fromUuid(itemUuid)
talent.sheet.render(true)
}
/**
* Delete an existing talent within the path item
* Use the uuid to remove it form the array of talents
* @param {PointerEvent} event The originating click event
* @param {HTMLElement} target the capturing HTML element which defined a [data-action]
*/
static async #onTalentDelete(event, target) {
const itemUuid = target.getAttribute("data-item-uuid")
const talents = this.item.toObject().system.talents
const index = talents.indexOf(itemUuid)
talents.splice(index, 1)
this.item.update({ "system.talents": talents })
}
// #endregion
}

View File

@ -0,0 +1,28 @@
import LethalFantasyItemSheet from "./base-item-sheet.mjs"
export default class LethalFantasyGiftSheet extends LethalFantasyItemSheet {
/** @override */
static DEFAULT_OPTIONS = {
classes: ["save"],
position: {
width: 600,
},
window: {
contentClasses: ["save-content"],
},
}
/** @override */
static PARTS = {
main: {
template: "systems/fvtt-lethal-fantasy/templates/save.hbs",
},
}
/** @override */
async _prepareContext() {
const context = await super._prepareContext()
context.enrichedDescription = await TextEditor.enrichHTML(this.document.system.description, { async: true })
return context
}
}

View File

@ -0,0 +1,28 @@
import LethalFantasyItemSheet from "./base-item-sheet.mjs"
export default class LethalFantasySkillSheet extends LethalFantasyItemSheet {
/** @override */
static DEFAULT_OPTIONS = {
classes: ["skill"],
position: {
width: 600,
},
window: {
contentClasses: ["skill-content"],
},
}
/** @override */
static PARTS = {
main: {
template: "systems/fvtt-lethal-fantasy/templates/skill.hbs",
},
}
/** @override */
async _prepareContext() {
const context = await super._prepareContext()
context.enrichedDescription = await TextEditor.enrichHTML(this.document.system.description, { async: true })
return context
}
}

View File

@ -0,0 +1,28 @@
import LethalFantasyItemSheet from "./base-item-sheet.mjs"
export default class LethalFantasyVulnerabilitySheet extends LethalFantasyItemSheet {
/** @override */
static DEFAULT_OPTIONS = {
classes: ["vulnerability"],
position: {
width: 600,
},
window: {
contentClasses: ["vulnerability-content"],
},
}
/** @override */
static PARTS = {
main: {
template: "systems/fvtt-lethal-fantasy/templates/vulnerability.hbs",
},
}
/** @override */
async _prepareContext() {
const context = await super._prepareContext()
context.enrichedDescription = await TextEditor.enrichHTML(this.document.system.description, { async: true })
return context
}
}