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
}
}

View File

@ -1,50 +1,57 @@
export const CHARACTERISTICS = Object.freeze({
rob: {
id: "rob",
label: "LETHALFANTASY.Character.rob.label",
abbreviation: "LETHALFANTASY.Character.rob.short",
},
dex: {
id: "dex",
label: "LETHALFANTASY.Character.dex.label",
abbreviation: "LETHALFANTASY.Character.dex.short",
str: {
id: "str",
label: "LETHALFANTASY.Character.str.label"
},
int: {
id: "int",
label: "LETHALFANTASY.Character.int.label",
abbreviation: "LETHALFANTASY.Character.int.short",
label: "LETHALFANTASY.Character.int.label"
},
per: {
id: "per",
label: "LETHALFANTASY.Character.per.label",
abbreviation: "LETHALFANTASY.Character.per.short",
wis: {
id: "wis",
label: "LETHALFANTASY.Character.wis.label"
},
vol: {
id: "vol",
label: "LETHALFANTASY.Character.vol.label",
abbreviation: "LETHALFANTASY.Character.vol.short",
dex: {
id: "dex",
label: "LETHALFANTASY.Character.dex.label"
},
con: {
id: "con",
label: "LETHALFANTASY.Character.con.label"
},
cha: {
id: "cha",
label: "LETHALFANTASY.Character.cha.label"
},
app: {
id: "app",
label: "LETHALFANTASY.Character.app.label"
},
})
export const RESOURCES = Object.freeze({
san: {
id: "san",
label: "LETHALFANTASY.Character.san.label",
export const SAVES = Object.freeze({
str: {
id: "str",
label: "LETHALFANTASY.Character.str.label"
},
oeil: {
id: "oeil",
label: "LETHALFANTASY.Character.oeil.label",
agility: {
id: "agility",
label: "LETHALFANTASY.Character.agility.label"
},
verbe: {
id: "verbe",
label: "LETHALFANTASY.Character.verbe.label",
dying: {
id: "dying",
label: "LETHALFANTASY.Character.dying.label"
},
bourse: {
id: "bourse",
label: "LETHALFANTASY.Character.bourse.label",
will: {
id: "will",
label: "LETHALFANTASY.Character.will.label"
},
magie: {
id: "magie",
label: "LETHALFANTASY.Character.magie.label",
dodge: {
id: "dodge",
label: "LETHALFANTASY.Character.dodge.label"
},
toughness: {
id: "toughness",
label: "LETHALFANTASY.Character.toughness.label"
}
})

22
module/config/skill.mjs Normal file
View File

@ -0,0 +1,22 @@
export const CATEGORY = Object.freeze({
layperson: {
id: "layperson",
label: "LETHALFANTASY.Skill.Category.layperson",
},
professional: {
id: "professional",
label: "LETHALFANTASY.Skill.Category.professional",
},
weapon: {
id: "weapon",
label: "LETHALFANTASY.Skill.Category.weapon",
},
armor: {
id: "armor",
label: "LETHALFANTASY.Skill.Category.armor",
},
resist: {
id: "resist",
label: "LETHALFANTASY.Skill.Category.resist",
}
})

View File

@ -2,19 +2,11 @@ import * as CHARACTER from "./character.mjs"
import * as WEAPON from "./weapon.mjs"
import * as ARMOR from "./armor.mjs"
import * as SPELL from "./spell.mjs"
import * as SKILL from "./skill.mjs"
export const SYSTEM_ID = "tenebris"
export const SYSTEM_ID = "fvtt-lethal-fantasy"
export const DEV_MODE = false
export const RESOURCE_VALUE = Object.freeze({
ZERO: "0",
D4: "d4",
D6: "d6",
D8: "d8",
D10: "d10",
D12: "d12",
})
export const DICE_VALUE = Object.freeze({
D4: "d4",
D6: "d6",
@ -32,55 +24,50 @@ export const ROLL_TYPE = Object.freeze({
ATTACK: "attack",
})
export const MINOR_PATH = Object.freeze({
epee: {
onze: "rob",
neuf: {
main: "per",
plume: "vol",
livre: "int",
},
export const MONEY = {
tinbit: {
id: "tinbit",
abbrev: "tb",
label: "LETHALFANTASY.Money.Tinbits",
valuetb: 1
},
main: {
onze: "dex",
neuf: {
chene: "rob",
plume: "vol",
livre: "int",
},
copper: {
id: "copper",
abbrev: "cp",
label: "LETHALFANTASY.Money.Coppers",
valuetb: 10
},
plume: {
onze: "int",
neuf: {
chene: "rob",
main: "per",
epee: "dex",
},
silver: {
id: "silver",
abbrev: "sp",
label: "LETHALFANTASY.Money.Silvers",
valuetb: 100
},
chene: {
onze: "per",
neuf: {
plume: "vol",
livre: "int",
epee: "dex",
},
gold: {
id: "gold",
abbrev: "gp",
label: "LETHALFANTASY.Money.Golds",
valuetb: 1000
},
livre: {
onze: "vol",
neuf: {
chene: "rob",
main: "per",
epee: "dex",
},
},
})
platinum: {
id: "platinum",
abbrev: "pp",
label: "LETHALFANTASY.Money.Platinums",
valuetb: 10000
}
}
export const ASCII = `
██████ ████████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████████ ███████ ███ ██ ███████ ██████ ██████ ██ ███████
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ███████ ██ ██ ██ ███████ ██ ██ ██ █████ ██ ██ ██ █████ ██████ ██████ ██ ███████
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██████ ██ ██ ██ ██████ ███████ ██ ██ ██████ ██ ███████ ██ ████ ███████ ██████ ██ ██ ██ ███████ `
······················································································································
: :
:@@@ @@@@@@@@ @@@@@@@ @@@ @@@ @@@@@@ @@@ @@@@@@@@ @@@@@@ @@@ @@@ @@@@@@@ @@@@@@ @@@@@@ @@@ @@@ :
:@@! @@! @!! @@! @@@ @@! @@@ @@! @@! @@! @@@ @@!@!@@@ @!! @@! @@@ !@@ @@! !@@ :
:@!! @!!!:! @!! @!@!@!@! @!@!@!@! @!! @!!!:! @!@!@!@! @!@@!!@! @!! @!@!@!@! !@@!! !@!@! :
:!!: !!: !!: !!: !!! !!: !!! !!: !!: !!: !!! !!: !!! !!: !!: !!! !:! !!: :
:: ::.: : : :: :: : : : : : : : : ::.: : : : : : :: : : : : : ::.: : .: :
: :
······················································································································
`
/**
* Include all constant definitions within the SYSTEM global export
@ -90,13 +77,14 @@ export const SYSTEM = {
id: SYSTEM_ID,
CHARACTERISTICS: CHARACTER.CHARACTERISTICS,
RESOURCES: CHARACTER.RESOURCES,
RESOURCE_VALUE,
SAVES: CHARACTER.SAVES,
SKILL_CATEGORY: SKILL.CATEGORY,
WEAPON_CATEGORY: WEAPON.CATEGORY,
WEAPON_DAMAGE: WEAPON.DAMAGE,
ARMOR_CATEGORY: ARMOR.CATEGORY,
SPELL_RANGE: SPELL.RANGE,
MONEY,
ASCII,
MINOR_PATH,
ROLL_TYPE,
DEV_MODE,
}

View File

@ -15,199 +15,6 @@ export default class LethalFantasyActor extends Actor {
}
}
/**
* Adds a path to the character.
* First path added is the major path, second path added is the minor path.
* Create all talents of the path and add them to the character.
* Add the path to the character.
*
* @param {Object} item The item to add as a path.
* @returns {Promise<void>} - A promise that resolves when the path is added.
*/
async addPath(item) {
if (this.type !== "character") return
let itemData = item.toObject()
if (this.system.hasVoieMajeure && this.system.hasVoieMineure) {
ui.notifications.warn(game.i18n.localize("TENEBRIS.Warning.dejaDeuxVoies"))
return
}
// Voie mineure
if (this.system.hasVoieMajeure) {
if (this.system.voies.majeure.nom === item.name) {
ui.notifications.warn(game.i18n.localize("TENEBRIS.Warning.dejaVoieMajeure"))
return
}
// Voie de base
const isBasePath = itemData.system.key !== "" && this.system.voies.majeure.key !== ""
let dropNotification
let neufModifie
let onze
let neuf
if (isBasePath) {
onze = game.system.CONST.MINOR_PATH[itemData.system.key].onze
const labelOnze = game.i18n.localize(`TENEBRIS.Character.FIELDS.caracteristiques.${onze}.valeur.label`)
dropNotification = `La valeur de ${labelOnze} va être modifiée pour 11`
neuf = game.system.CONST.MINOR_PATH[itemData.system.key].neuf[this.system.voies.majeure.key]
if (neuf) {
neufModifie = true
const labelNeuf = game.i18n.localize(`TENEBRIS.Character.FIELDS.caracteristiques.${neuf}.valeur.label`)
dropNotification += `<br> La valeur de ${labelNeuf} va être modifiée pour 9`
}
} else {
dropNotification = "Vous devez modifier manuellement les caractéristiques selon la voie ajoutée"
}
dropNotification += `<br>Vous pouvez renoncer à des biens de la voie majeure pour ceux de la voie mineure`
dropNotification += `<br> Vous pouvez renoncer à des langues de la voie majeure pour celles de la voie mineure`
const proceed = await foundry.applications.api.DialogV2.confirm({
window: { title: game.i18n.localize("TENEBRIS.Dialog.ajoutVoieMineureTitre") },
content: dropNotification,
rejectClose: false,
modal: true,
})
if (!proceed) return
let voie
// Création de la voie
voie = await this.createEmbeddedDocuments("Item", [itemData], { renderSheet: false })
if (isBasePath) {
await this.update({
"system.voies.mineure.nom": item.name,
"system.voies.mineure.id": voie[0].id,
"system.voies.mineure.key": item.system.key,
[`system.caracteristiques.${onze}.valeur`]: 11,
"system.langues": `${this.system.langues} <br>${item.name} : ${item.system.langues}`,
"system.biens": `${this.system.biens} <br>${item.name} : ${item.system.biens}`,
})
if (neufModifie) {
await this.update({
[`system.caracteristiques.${neuf}.valeur`]: 9,
})
}
} else {
await this.update({
"system.voies.mineure.nom": item.name,
"system.voies.mineure.id": voie[0].id,
"system.voies.mineure.key": item.system.key,
"system.langues": `${this.system.langues} <br>${item.name} : ${item.system.langues}`,
"system.biens": `${this.system.biens} <br>${item.name} : ${item.system.biens}`,
})
}
// Création des talents
let newTalents = []
for (const talent of itemData.system.talents) {
const talentItem = await fromUuid(talent)
if (talentItem) {
const newTalent = await this.createEmbeddedDocuments("Item", [talentItem.toObject()])
// Modification de la voie du talent
await newTalent[0].update({ "system.path": voie[0].uuid })
newTalents.push(newTalent[0].uuid)
}
}
// Mise à jour de la voie avec les nouveaux talents
await voie[0].update({ "system.talents": newTalents })
return ui.notifications.info(game.i18n.localize("TENEBRIS.Warning.voieMineureAjoutee"))
}
// Voie majeure
else {
const proceed = await foundry.applications.api.DialogV2.confirm({
window: { title: game.i18n.localize("TENEBRIS.Dialog.ajoutVoieMajeureTitre") },
content: game.i18n.localize("TENEBRIS.Dialog.ajoutVoieMajeure"),
rejectClose: false,
modal: true,
})
if (!proceed) return
// Création de la voie
const voie = await this.createEmbeddedDocuments("Item", [itemData], { renderSheet: false })
// Création des talents
let newTalents = []
for (const talent of itemData.system.talents) {
const talentItem = await fromUuid(talent)
if (talentItem) {
const newTalent = await this.createEmbeddedDocuments("Item", [talentItem.toObject()])
// Modification de la voie du talent
await newTalent[0].update({ "system.path": voie[0].uuid })
newTalents.push(newTalent[0].uuid)
}
}
// Mise à jour de la voie avec les nouveaux talents
await voie[0].update({ "system.talents": newTalents })
await this.update({
"system.voies.majeure.id": voie[0].id,
"system.voies.majeure.nom": item.name,
"system.voies.majeure.key": item.system.key,
"system.caracteristiques.rob": item.system.caracteristiques.rob,
"system.caracteristiques.dex": item.system.caracteristiques.dex,
"system.caracteristiques.int": item.system.caracteristiques.int,
"system.caracteristiques.per": item.system.caracteristiques.per,
"system.caracteristiques.vol": item.system.caracteristiques.vol,
"system.ressources.san": item.system.ressources.san,
"system.ressources.oeil": item.system.ressources.oeil,
"system.ressources.verbe": item.system.ressources.verbe,
"system.ressources.bourse": item.system.ressources.bourse,
"system.ressources.magie": item.system.ressources.magie,
"system.dv": item.system.dv,
"system.dmax.valeur": item.system.dmax,
"system.langues": `${item.name} : ${item.system.langues}`,
"system.biens": `${item.name} : ${item.system.biens}`,
})
return ui.notifications.info(game.i18n.localize("TENEBRIS.Warning.voieMajeureAjoutee"))
}
}
/**
* Deletes a specified path and its associated talents.
*
* @param {Object} path The path object to be deleted.
* @param {boolean} isMajor Indicates if the path is a major path, elswise it is a minor path.
* @returns {Promise<void>} A promise that resolves when the deletion is complete.
* @throws {Error} Throws an error if the type is not "character".
*/
async deletePath(path, isMajor) {
if (this.type !== "character") return
// Delete all talents linked to the path
let toDelete = path.system.talents.map((talent) => foundry.utils.parseUuid(talent).id)
toDelete.push(path.id)
await this.deleteEmbeddedDocuments("Item", toDelete)
// Voie majeure
if (isMajor) {
await this.update({ "system.voies.majeure.nom": "", "system.voies.majeure.id": null, "system.voies.majeure.key": "" })
ui.notifications.info(game.i18n.localize("TENEBRIS.Warning.voieMajeureSupprimee"))
}
// Voie mineure
else {
await this.update({ "system.voies.mineure.nom": "", "system.voies.mineure.id": null, "system.voies.mineure.key": "" })
ui.notifications.info(game.i18n.localize("TENEBRIS.Warning.voieMineureSupprimee"))
}
}
/**
* Adds an attack to the actor if the actor type is "opponent".
*
* @param {Object} attack The attack object to be added.
* @returns {Promise<void>} A promise that resolves when the attack has been added.
*/
async addAttack(attack) {
if (this.type !== "opponent") return
await this.createEmbeddedDocuments("Item", [attack])
}
async rollResource(resource) {
if (this.type !== "character") return
await this.system.roll(ROLL_TYPE.RESOURCE, resource)

View File

@ -278,7 +278,7 @@ export default class LethalFantasyRoll extends Roll {
const label = game.i18n.localize("TENEBRIS.Roll.roll")
const rollContext = await foundry.applications.api.DialogV2.wait({
window: { title: title },
classes: ["tenebris"],
classes: ["lethalfantasy"],
content,
buttons: [
{

View File

@ -1,8 +1,9 @@
export { default as LethalFantasyCharacter } from "./character.mjs"
export { default as LethalFantasyOpponent } from "./opponent.mjs"
export { default as LethalFantasyPath } from "./path.mjs"
export { default as LethalFantasyTalent } from "./talent.mjs"
export { default as LethalFantasyArmor } from "./armor.mjs"
export { default as LethalFantasyWeapon } from "./weapon.mjs"
export { default as LethalFantasySpell } from "./spell.mjs"
export { default as LethalFantasyAttack } from "./attack.mjs"
export { default as LethalFantasySkill } from "./skill.mjs"
export { default as LethalFantasyArmor } from "./armor.mjs"
export { default as LethalFantasyGift } from "./gift.mjs"
export { default as LethalFantasyVulnerability } from "./vulnerability.mjs"
export { default as LethalFantasySave } from "./save.mjs"

View File

@ -1,34 +1,25 @@
import { SYSTEM } from "../config/system.mjs"
import { CATEGORY } from "../config/armor.mjs"
export default class LethalFantasyArmor extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields
const requiredInteger = { required: true, nullable: false, integer: true }
const schema = {}
schema.description = new fields.HTMLField({ required: true, textSearch: true })
schema.categorie = new fields.StringField({ required: true, initial: "sommaire", choices: SYSTEM.ARMOR_CATEGORY })
schema.valeur = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
schema.malus = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
schema.category = new fields.StringField({ required: true, initial: "melee", choices: SYSTEM.ARMOR_CATEGORY })
schema.protection = new fields.StringField({
required: true,
initial: ""
})
schema.cost = new fields.NumberField({ required: true, initial: 0, min: 0 })
schema.money = new fields.StringField({ required: true, initial: "tinbit", choices: SYSTEM.MONEY })
return schema
}
/** @override */
static LOCALIZATION_PREFIXES = ["TENEBRIS.Armor"]
static LOCALIZATION_PREFIXES = ["LETHALFANTASY.Armor"]
get armorCategory() {
return game.i18n.localize(CATEGORY[this.categorie].label)
}
get details() {
return game.i18n.format("TENEBRIS.Armor.details", {
valeur: this.valeur,
malus: this.malus,
})
get weaponCategory() {
return game.i18n.localize(CATEGORY[this.category].label)
}
}

View File

@ -1,18 +0,0 @@
export default class LethalFantasy extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields
const schema = {}
schema.description = new fields.HTMLField({ required: true, textSearch: true })
schema.degats = new fields.StringField({ required: false, nullable: true, blank: true })
return schema
}
/** @override */
static LOCALIZATION_PREFIXES = ["TENEBRIS.Attack"]
get toolTip() {
return this.description || ""
}
}

View File

@ -9,108 +9,83 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
const schema = {}
schema.description = new fields.HTMLField({ required: true, textSearch: true })
schema.langues = new fields.HTMLField({ required: true, textSearch: true })
schema.notes = new fields.HTMLField({ required: true, textSearch: true })
schema.biens = new fields.HTMLField({ required: true, textSearch: true })
// Caractéristiques
// Carac
const characteristicField = (label) => {
const schema = {
valeur: new fields.NumberField({ ...requiredInteger, initial: 10, min: 0 }),
progression: new fields.SchemaField({
experience: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
progres: new fields.BooleanField(),
}),
value: new fields.NumberField({ ...requiredInteger, initial: 3, min: 0 }),
percent: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0, max: 100 }),
attackMod: new fields.NumberField({ ...requiredInteger, initial: 0 }),
defenseMod: new fields.NumberField({ ...requiredInteger, initial: 0 })
}
return new fields.SchemaField(schema, { label })
}
schema.caracteristiques = new fields.SchemaField(
schema.characteristics = new fields.SchemaField(
Object.values(SYSTEM.CHARACTERISTICS).reduce((obj, characteristic) => {
obj[characteristic.id] = characteristicField(characteristic.label)
return obj
}, {}),
)
// Ressources
const resourceField = (label) => {
// Carac
const saveField = (label) => {
const schema = {
valeur: new fields.StringField({
required: true,
nullable: false,
initial: SYSTEM.RESOURCE_VALUE.ZERO,
choices: Object.fromEntries(Object.entries(SYSTEM.RESOURCE_VALUE).map(([key, value]) => [value, { label: `${value}` }])),
blank: true,
}),
max: new fields.StringField({
required: true,
nullable: false,
initial: SYSTEM.RESOURCE_VALUE.ZERO,
choices: Object.fromEntries(Object.entries(SYSTEM.RESOURCE_VALUE).map(([key, value]) => [value, { label: `${value}` }])),
blank: true,
}),
experience: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
value: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
}
return new fields.SchemaField(schema, { label })
}
schema.ressources = new fields.SchemaField(
Object.values(SYSTEM.RESOURCES).reduce((obj, resource) => {
obj[resource.id] = resourceField(resource.label)
schema.saves = new fields.SchemaField(
Object.values(SYSTEM.SAVES).reduce((obj, save) => {
obj[save.id] = saveField(save.label)
return obj
}, {}),
)
schema.commanditaire = new fields.StringField({})
schema.dv = new fields.StringField({
required: true,
nullable: false,
initial: SYSTEM.RESOURCE_VALUE.ZERO,
choices: Object.fromEntries(Object.entries(SYSTEM.RESOURCE_VALUE).map(([key, value]) => [value, { label: `${value}` }])),
})
schema.pv = new fields.SchemaField({
schema.hp = new fields.SchemaField({
value: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
max: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
})
schema.dmax = new fields.SchemaField({
valeur: new fields.StringField({
required: true,
nullable: false,
initial: SYSTEM.RESOURCE_VALUE.ZERO,
choices: Object.fromEntries(Object.entries(SYSTEM.RESOURCE_VALUE).map(([key, value]) => [value, { label: `${value}` }])),
}),
experience: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
schema.perception = new fields.SchemaField({
value: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
bonus: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
})
schema.voies = new fields.SchemaField({
majeure: new fields.SchemaField({
id: new fields.DocumentIdField(),
key: new fields.StringField({ required: true }),
nom: new fields.StringField({ required: true }),
}),
mineure: new fields.SchemaField({
id: new fields.DocumentIdField(),
key: new fields.StringField({ required: true }),
nom: new fields.StringField({ required: true }),
}),
schema.grit = new fields.SchemaField({
earned: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
current: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
})
schema.luck = new fields.SchemaField({
earned: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
current: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
})
schema.movement = new fields.SchemaField({
walk: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
jog: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
sprint: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
run: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
armorAdjust: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
})
schema.biodata = new fields.SchemaField({
class: new fields.StringField({ required: true, nullable: false, initial: "" }),
level: new fields.NumberField({ ...requiredInteger, initial: 1, min: 1 }),
mortal: new fields.StringField({ required: true, nullable: false, initial: "" }),
alignment: new fields.StringField({ required: true, nullable: false, initial: "" }),
age: new fields.NumberField({ ...requiredInteger, initial: 15, min: 6 }),
height: new fields.NumberField({ ...requiredInteger, initial: 170, min: 50 }),
eyes: new fields.StringField({ required: true, nullable: false, initial: "" }),
hair: new fields.StringField({ required: true, nullable: false, initial: "" })
})
schema.developmentPoints = new fields.SchemaField({
total: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
remaining: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
})
return schema
}
/** @override */
static LOCALIZATION_PREFIXES = ["TENEBRIS.Character"]
get hasVoieMajeure() {
return !!this.voies.majeure.id
}
get hasVoieMineure() {
return !!this.voies.mineure.id
}
static LOCALIZATION_PREFIXES = ["LETHALFANTASY.Character"]
/**
* Rolls a dice for a character.
@ -127,9 +102,6 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
rollValue = this.caracteristiques[rollTarget].valeur
opponentTarget = game.user.targets.first()
break
case ROLL_TYPE.RESOURCE:
rollValue = this.ressources[rollTarget].valeur
break
case ROLL_TYPE.DAMAGE:
rollValue = this.parent.items.get(rollTarget).system.degats
opponentTarget = game.user.targets.first()
@ -165,12 +137,6 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
})
if (!roll) return null
// Perte de ressouces
if (rollType === ROLL_TYPE.RESOURCE && roll.resultType === "failure") {
const value = this.ressources[rollTarget].valeur
const newValue = LethalFantasyUtils.findLowerDice(value)
await this.parent.update({ [`system.ressources.${rollTarget}.valeur`]: newValue })
}
await roll.toMessage({}, { rollMode: roll.options.rollMode })
}
}

View File

@ -0,0 +1,27 @@
import { SYSTEM } from "../config/system.mjs"
import { CATEGORY } from "../config/weapon.mjs"
export default class LethalFantasyEquipment extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields
const schema = {}
const requiredInteger = { required: true, nullable: false, integer: true }
schema.description = new fields.HTMLField({ required: true, textSearch: true })
schema.category = new fields.StringField({ required: true, initial: "melee", choices: SYSTEM.WEAPON_CATEGORY })
schema.damages = new fields.StringField({
required: true,
initial: ""
})
schema.cost = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
schema.money = new fields.StringField({ required: true, initial: "tinbit", choices: SYSTEM.MONEY })
return schema
}
/** @override */
static LOCALIZATION_PREFIXES = ["LETHALFANTASY.Equipment"]
get weaponCategory() {
return game.i18n.localize(CATEGORY[this.category].label)
}
}

16
module/models/gift.mjs Normal file
View File

@ -0,0 +1,16 @@
export default class LethalFantasyGift extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields
const requiredInteger = { required: true, nullable: false, integer: true }
const schema = {}
schema.description = new fields.HTMLField({ required: true, textSearch: true })
schema.cost = new fields.NumberField({ required: true, initial: 0, min: 0 })
return schema
}
/** @override */
static LOCALIZATION_PREFIXES = ["LETHALFANTASY.Gift"]
}

View File

@ -22,7 +22,7 @@ export default class LethalFantasyOpponent extends foundry.abstract.TypeDataMode
}
/** @override */
static LOCALIZATION_PREFIXES = ["TENEBRIS.Opponent"]
static LOCALIZATION_PREFIXES = ["LETHALFANTSY.Opponent"]
/**
* Rolls a dice attack for an opponent.

View File

@ -1,83 +0,0 @@
import { SYSTEM } from "../config/system.mjs"
export default class LethalFantasyPath extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields
const schema = {}
schema.key = new fields.StringField({ required: true, nullable: false, initial: "" })
// Caractéristiques
const characteristicField = (label) => {
const schema = {
valeur: new fields.NumberField({
required: true,
nullable: false,
integer: true,
initial: 10,
min: 0,
}),
}
return new fields.SchemaField(schema, { label })
}
schema.caracteristiques = new fields.SchemaField(
Object.values(SYSTEM.CHARACTERISTICS).reduce((obj, characteristic) => {
obj[characteristic.id] = characteristicField(characteristic.label)
return obj
}, {}),
)
// Ressources
const resourceField = (label) => {
const schema = {
valeur: new fields.StringField({
required: true,
initial: SYSTEM.RESOURCE_VALUE.ZERO,
choices: Object.fromEntries(Object.entries(SYSTEM.RESOURCE_VALUE).map(([key, value]) => [value, { label: `${value}` }])),
}),
}
return new fields.SchemaField(schema, { label })
}
schema.ressources = new fields.SchemaField(
Object.values(SYSTEM.RESOURCES).reduce((obj, resource) => {
obj[resource.id] = resourceField(resource.label)
return obj
}, {}),
)
schema.dv = new fields.StringField({
required: true,
initial: SYSTEM.RESOURCE_VALUE.ZERO,
choices: Object.fromEntries(Object.entries(SYSTEM.RESOURCE_VALUE).map(([key, value]) => [value, { label: `${value}` }])),
})
schema.dmax = new fields.StringField({
required: true,
initial: SYSTEM.RESOURCE_VALUE.ZERO,
choices: Object.fromEntries(Object.entries(SYSTEM.RESOURCE_VALUE).map(([key, value]) => [value, { label: `${value}` }])),
})
schema.description = new fields.HTMLField({ required: true, textSearch: true })
schema.biens = new fields.HTMLField({ required: true, textSearch: true })
schema.langues = new fields.HTMLField({ required: true, textSearch: true })
schema.talents = new fields.ArrayField(new fields.DocumentUUIDField())
return schema
}
/** @override */
static LOCALIZATION_PREFIXES = ["TENEBRIS.Path"]
async getAllTalents() {
const talents = []
this.talents.forEach(async (element) => {
const talent = await fromUuid(element)
if (talent) talents.push(talent)
})
return talents
}
}

17
module/models/save.mjs Normal file
View File

@ -0,0 +1,17 @@
export default class LethalFantasySave extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields
const requiredInteger = { required: true, nullable: false, integer: true }
const schema = {}
schema.description = new fields.HTMLField({ required: true, textSearch: true })
schema.cost = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
schema.value = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
return schema
}
/** @override */
static LOCALIZATION_PREFIXES = ["LETHALFANTASY.Save"]
}

24
module/models/skill.mjs Normal file
View File

@ -0,0 +1,24 @@
import { SYSTEM } from "../config/system.mjs"
import { CATEGORY } from "../config/skill.mjs"
export default class LethalFantasySkill extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields
const schema = {}
const requiredInteger = { required: true, nullable: false, integer: true }
schema.description = new fields.HTMLField({ required: true, textSearch: true })
schema.category = new fields.StringField({ required: true, initial: "layperson", choices: SYSTEM.SKILL_CATEGORY })
schema.base = new fields.StringField({ required: true, initial: "WIS" })
schema.bonus = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
schema.cost = new fields.NumberField({ ...requiredInteger,required: true, initial: 0, min: 0 })
return schema
}
/** @override */
static LOCALIZATION_PREFIXES = ["LETHALFANTASY.Skill"]
get skillCategory() {
return game.i18n.localize(CATEGORY[this.category].label)
}
}

View File

@ -11,17 +11,16 @@ export default class LethalFantasySpell extends foundry.abstract.TypeDataModel {
initial: "",
textSearch: true,
})
schema.preparation = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
schema.cible = new fields.StringField({ required: true })
schema.portee = new fields.StringField({ required: true, initial: "contact", choices: SYSTEM.SPELL_RANGE })
schema.duree = new fields.StringField({ required: true })
schema.consequenceA = new fields.StringField({ required: true })
schema.consequenceB = new fields.StringField({ required: true })
schema.level = new fields.NumberField({
...requiredInteger,
initial: 1,
min: 1,
max: 20,
})
return schema
}
/** @override */
static LOCALIZATION_PREFIXES = ["TENEBRIS.Spell"]
static LOCALIZATION_PREFIXES = ["LETHALFANTASY.Spell"]
}

View File

@ -1,44 +0,0 @@
export default class LethalFantasyTalent extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields
const requiredInteger = { required: true, nullable: false, integer: true }
const schema = {}
schema.description = new fields.HTMLField({ required: true, textSearch: true })
schema.appris = new fields.BooleanField()
schema.progression = new fields.BooleanField()
schema.niveau = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0, max: 3 })
schema.path = new fields.DocumentUUIDField()
return schema
}
/** @override */
static LOCALIZATION_PREFIXES = ["TENEBRIS.Talent"]
get canProgress() {
return this.progression
}
get isLearned() {
return this.appris
}
get improvedDescription() {
return this.description.replace(/#niveau\b/g, this.niveau)
}
get details() {
if (this.progression)
return game.i18n.format("TENEBRIS.Talent.details", {
niveau: this.niveau,
})
return ""
}
async getPathName() {
const path = await fromUuid(this.path)
return path ? path.name : ""
}
}

View File

@ -0,0 +1,16 @@
export default class LethalFantasyVulnerability extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields
const requiredInteger = { required: true, nullable: false, integer: true }
const schema = {}
schema.description = new fields.HTMLField({ required: true, textSearch: true })
schema.cost = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
return schema
}
/** @override */
static LOCALIZATION_PREFIXES = ["LETHALFANTASY.Vulnerability"]
}

View File

@ -1,24 +1,27 @@
import { SYSTEM } from "../config/system.mjs"
import { CATEGORY } from "../config/weapon.mjs"
export default class LethalFantasyWeapon extends foundry.abstract.TypeDataModel {
export default class LethalFantasySkill extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields
const schema = {}
const requiredInteger = { required: true, nullable: false, integer: true }
schema.description = new fields.HTMLField({ required: true, textSearch: true })
schema.categorie = new fields.StringField({ required: true, initial: "mains", choices: SYSTEM.WEAPON_CATEGORY })
schema.degats = new fields.StringField({
schema.category = new fields.StringField({ required: true, initial: "melee", choices: SYSTEM.WEAPON_CATEGORY })
schema.damages = new fields.StringField({
required: true,
initial: SYSTEM.WEAPON_DAMAGE.UN,
choices: Object.fromEntries(Object.entries(SYSTEM.WEAPON_DAMAGE).map(([key, value]) => [value, { label: `${value}` }])),
initial: ""
})
schema.cost = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
schema.money = new fields.StringField({ required: true, initial: "tinbit", choices: SYSTEM.MONEY })
return schema
}
/** @override */
static LOCALIZATION_PREFIXES = ["TENEBRIS.Weapon"]
static LOCALIZATION_PREFIXES = ["LETHALFANTASY.Weapon"]
get weaponCategory() {
return game.i18n.localize(CATEGORY[this.categorie].label)
return game.i18n.localize(CATEGORY[this.category].label)
}
}

View File

@ -1,4 +1,3 @@
import LethalFantasyFortune from "./applications/fortune.mjs"
/**
* Handles socket events based on the provided action.