Fix lethargy + charaster race
All checks were successful
Release Creation / build (release) Successful in 43s

This commit is contained in:
2025-04-06 09:52:48 +02:00
parent bd0b734c68
commit b029aba2b6
29 changed files with 118 additions and 234 deletions

View File

@ -9,5 +9,4 @@ export { default as LethalFantasySpellSheet } from "./sheets/spell-sheet.mjs"
export { default as LethalFantasyEquipmentSheet } from "./sheets/equipment-sheet.mjs"
export { default as LethalFantasyShieldSheet } from "./sheets/shield-sheet.mjs"
export { default as LethalFantasyMiracleSheet } from "./sheets/miracle-sheet.mjs"
export { default as LethalFantasyManager } from "./manager.mjs"

View File

@ -1,142 +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 LethalFantasyManager extends HandlebarsApplicationMixin(ApplicationV2) {
static DEFAULT_OPTIONS = {
id: "lethalfantasy-application-manager",
tag: "form",
window: {
contentClasses: ["lethalfantasy-manager"],
title: "LETHALFANTASY.Manager.title",
resizable: true,
},
position: {
width: "auto",
height: "auto",
top: 80,
left: 400,
},
form: {
closeOnSubmit: true,
},
actions: {
resourceAll: LethalFantasyManager.#onResourceAll,
resourceOne: LethalFantasyManager.#onResourceOne,
saveAll: LethalFantasyManager.#onSaveAll,
saveOne: LethalFantasyManager.#onSaveOne,
openSheet: LethalFantasyManager.#onOpenSheet,
},
}
/** @override */
static PARTS = {
main: {
template: "systems/fvtt-lethal-fantasy/templates/manager.hbs",
},
}
/* -------------------------------------------- */
/* Rendering */
/* -------------------------------------------- */
/** @override */
async _prepareContext(_options = {}) {
return {
players: game.users.filter((u) => u.hasPlayerOwner && u.active),
}
}
static async #onResourceAll(event, target) {
const value = event.target.dataset.resource
LethalFantasyManager.askRollForAll("resource", value)
}
static async #onSaveAll(event, target) {
const value = event.target.dataset.save
LethalFantasyManager.askRollForAll("save", value)
}
static #onResourceOne(event, target) {
const value = event.target.dataset.resource
const recipient = event.target.parentElement.dataset.userId
const name = event.target.parentElement.dataset.characterName
LethalFantasyManager.askRollForOne("resource", value, recipient, name)
}
static async #onSaveOne(event, target) {
const value = event.target.dataset.save
const recipient = event.target.parentElement.dataset.userId
const name = event.target.parentElement.dataset.characterName
LethalFantasyManager.askRollForOne("save", value, recipient, name)
}
static #onOpenSheet(event, target) {
const characterId = event.target.dataset.characterId
game.actors.get(characterId).sheet.render(true)
}
static async askRollForAll(type, value, title = null, avantage = null) {
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("LETHALFANTASY.Roll.doubleAvantage")}`
break
case "+":
text += ` ${game.i18n.localize("LETHALFANTASY.Roll.avantage")}`
break
case "-":
text += ` ${game.i18n.localize("LETHALFANTASY.Roll.desavantage")}`
break
case "--":
text += ` ${game.i18n.localize("LETHALFANTASY.Roll.doubleDesavantage")}`
break
default:
break
}
}
ChatMessage.create({
user: game.user.id,
content: await renderTemplate(`systems/fvtt-lethal-fantasy/templates/chat-ask-roll.hbs`, {
title: title !== null ? title : "",
text: text,
rollType: type,
value: value,
avantage: avantage,
}),
flags: { tenebris: { typeMessage: "askRoll" } },
})
}
static async askRollForOne(type, value, recipient, 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",
data: {
userId: recipient,
},
})
ChatMessage.create({
user: game.user.id,
content: await renderTemplate(`systems/fvtt-lethal-fantasy/templates/chat-ask-roll.hbs`, {
text: text,
rollType: type,
value: value,
}),
whisper: [recipient],
flags: { tenebris: { typeMessage: "askRoll" } },
})
}
}

View File

@ -51,6 +51,13 @@ export const MORTAL_CHOICES = {
"halforc": {label: "Half-Orc", value: "Half-Orc", defenseBonus: 0},
"gnome": {label: "Gnome", value: "Gnome", defenseBonus: 2},
"shirefolk": {label: "Shire Folk", value: "Shire Folk", defenseBonus: 2},
"Elf": {label: "Elf", value: "Elf", defenseBonus: 0},
"Half-orc": {label: "Half-Orc", value: "Half-Orc", defenseBonus: 0},
"Dwarf": {label: "Dwarf", value: "Dwarf", defenseBonus: 0},
"Half-elf": {label: "Half-Elf", value: "Half-Elf", defenseBonus: 0},
"Gnome": {label: "Gnome", value: "Gnome", defenseBonus: 2},
"Shire Folk": {label: "Shire Folk", value: "Shire Folk", defenseBonus: 2},
"Mankind": {label: "Human", value: "Human", defenseBonus: 0},
}
export const FAVOR_CHOICES = {
@ -96,6 +103,14 @@ export const ATTACKER_AIM_CHOICES = {
"focused": {label: "Focused (-8)", value: "-8"}
}
export const SPELL_LETHARGY_DICE = {
"spellLevel1": {dice: "D6", level: "1-5", value: "6"},
"spellLevel6": {dice: "D8", level: "6-10", value: "8"},
"spellLevel11": {dice: "D10", value: "10", level: "11-15"},
"spellLevel16": {dice: "D12", value: "12", level: "16-20"},
"spellLevel21": {dice: "D20", value: "20", level: "21-25"}
}
export const INITIATIVE_DICE_CHOICES_PER_CLASS = {
"untrained": [
{ "name": "Asleep or totally distracted (2D12)", "value": "2D12" },
@ -300,5 +315,6 @@ export const SYSTEM = {
ATTACKER_AIM_CHOICES,
MORTAL_CHOICES,
SPELL_CRITICAL,
MIRACLE_TYPES
MIRACLE_TYPES,
SPELL_LETHARGY_DICE
}

View File

@ -617,8 +617,6 @@ export default class LethalFantasyRoll extends Roll {
...options
}
console.log("CTX PROGRESSION", dialogContext)
const content = await renderTemplate("systems/fvtt-lethal-fantasy/templates/roll-progression-dice-dialog.hbs", dialogContext)
const label = game.i18n.localize("LETHALFANTASY.Label.rollProgressionDice")
@ -649,7 +647,7 @@ export default class LethalFantasyRoll extends Roll {
rejectClose: false // Click on Close button will not launch an error
})
console.log("RollContext", rollContext)
console.log("RollContext", dialogContext,rollContext)
if (rollContext === null || !rollContext?.progressionDiceId) {
let combat = game.combats.get(options.combatId)
let combatant = combat.combatants.get(options.combatantId)
@ -673,8 +671,30 @@ export default class LethalFantasyRoll extends Roll {
searchId = searchId.replace("focusedAim", "")
rangedMode = "focusedAim"
}
if (searchId.match("spellLevel")) {
let spellConfig = SYSTEM.SPELL_LETHARGY_DICE[searchId]
let formula = spellConfig.dice
let roll = new Roll(formula)
await roll.evaluate()
let message
if (options.rollProgressionCount <= roll.total ) {
message = `Spell Lethargy ongoing ... (${roll.total}/${options.rollProgressionCount}, spell level ${spellConfig.level})`
} else {
let combat = game.combats.get(options.combatId)
combat.resetProgression(options.combatantId)
message = `Spell Lethargy ended ! (${roll.total}/${options.rollProgressionCount}, spell level ${spellConfig.level})`
}
let msg = await roll.toMessage({ flavor: message }, { rollMode: rollContext.visibility })
if (game?.dice3d) {
await game.dice3d.waitFor3DAnimationByMessageID(msg.id)
}
return
}
let weapon = actor.items.find(i => i.type === "weapon" && i.id === searchId)
let formula = weapon.system.combatProgressionDice
let rangedLoad
if (rangedMode) {
let toSplit = weapon.system.speed[rangedMode]

View File

@ -295,6 +295,14 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
weaponsChoices.push({ id: `${w.id}carefulAim`, name: `${w.name} (Careful Aim: ${w.system.speed.carefulAim.toUpperCase()})`, combatProgressionDice: w.system.speed.carefulAim.toUpperCase() })
weaponsChoices.push({ id: `${w.id}focusedAim`, name: `${w.name} (Focused Aim: ${w.system.speed.focusedAim.toUpperCase()})`, combatProgressionDice: w.system.speed.focusedAim.toUpperCase() })
}
if (this.biodata.magicUser || this.biodata.clericUser) {
// Get the max level of the spells owned
weaponsChoices.push({ id: "spellLevel1", name: `Level 1-5 Spell/Miracle (D6)`, combatProgressionDice: "1D6" })
weaponsChoices.push({ id: "spellLevel6", name: `Level 6-10 Spell/Miracle (D8)`, combatProgressionDice: "1D8" })
weaponsChoices.push({ id: "spellLevel11", name: `Level 11-15 Spell/Miracle (D10)`, combatProgressionDice: "1D10" })
weaponsChoices.push({ id: "spellLevel16", name: `Level 16-20 Spell/Miracle (D12)`, combatProgressionDice: "1D12" })
weaponsChoices.push({ id: "spellLevel21", name: `Level 21-25 Spell/Miracle (D20)`, combatProgressionDice: "1D20" })
}
let roll = await LethalFantasyRoll.promptProgressionDice({
actorId: this.parent.id,