Add D30, spells, miracles and ranged defense roll
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import LethalFantasyActorSheet from "./base-actor-sheet.mjs"
|
||||
import LethalFantasyRoll from "../../documents/roll.mjs"
|
||||
|
||||
export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet {
|
||||
/** @override */
|
||||
@ -13,6 +14,7 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
|
||||
},
|
||||
actions: {
|
||||
createEquipment: LethalFantasyCharacterSheet.#onCreateEquipment,
|
||||
rangedAttackDefense: LethalFantasyCharacterSheet.#onRangedAttackDefense,
|
||||
},
|
||||
}
|
||||
|
||||
@ -48,12 +50,15 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
|
||||
* @returns {Record<string, Partial<ApplicationTab>>}
|
||||
*/
|
||||
#getTabs() {
|
||||
const tabs = {
|
||||
let tabs = {
|
||||
skills: { id: "skills", group: "sheet", icon: "fa-solid fa-shapes", label: "LETHALFANTASY.Label.skills" },
|
||||
weapons: { id: "weapons", group: "sheet", icon: "fa-solid fa-swords", label: "LETHALFANTASY.Label.weapons" },
|
||||
spells: { id: "spells", group: "sheet", icon: "fa-sharp-duotone fa-solid fa-wand-magic-sparkles", label: "LETHALFANTASY.Label.spells" },
|
||||
biography: { id: "biography", group: "sheet", icon: "fa-solid fa-book", label: "LETHALFANTASY.Label.biography" },
|
||||
}
|
||||
if (this.actor.system.biodata.magicUser) {
|
||||
tabs.spells = { id: "spells", group: "sheet", icon: "fa-sharp-duotone fa-solid fa-wand-magic-sparkles", label: "LETHALFANTASY.Label.spells" }
|
||||
}
|
||||
|
||||
for (const v of Object.values(tabs)) {
|
||||
v.active = this.tabGroups[v.group] === v.id
|
||||
v.cssClass = v.active ? "active" : ""
|
||||
@ -95,6 +100,7 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
|
||||
case "spells":
|
||||
context.tab = context.tabs.spells
|
||||
context.spells = doc.itemTypes.spell
|
||||
context.miracles = doc.itemTypes.miracle
|
||||
context.hasSpells = context.spells.length > 0
|
||||
break
|
||||
case "weapons":
|
||||
@ -135,21 +141,20 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
|
||||
await this.document.addPath(item)
|
||||
}
|
||||
|
||||
static async #onRangedAttackDefense(event, target) {
|
||||
const hasTarget = false
|
||||
let roll = await LethalFantasyRoll.promptRangedDefense({
|
||||
actorId: this.actor.id,
|
||||
actorName: this.actor.name,
|
||||
actorImage: this.actor.img
|
||||
})
|
||||
if (!roll) return null
|
||||
|
||||
await roll.toMessage({}, { rollMode: roll.options.rollMode })
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
// Création d'une armure
|
||||
if (event.shiftKey) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("LETHALFANTASY.Label.newArmor"), type: "armor" }])
|
||||
}
|
||||
// Création d'une arme
|
||||
else {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("LETHALFANTASY.Label.newWeapon"), type: "weapon" }])
|
||||
}
|
||||
}
|
||||
|
||||
getBestWeaponClassSkill(skills, rollType, multiplier = 1.0) {
|
||||
@ -168,7 +173,7 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
|
||||
goodSkill = s
|
||||
}
|
||||
}
|
||||
if (rollType.includes("weapon-damage") ) {
|
||||
if (rollType.includes("weapon-damage")) {
|
||||
if (s.system.weaponBonus.damage > maxValue) {
|
||||
maxValue = Number(s.system.weaponBonus.damage)
|
||||
goodSkill = s
|
||||
@ -209,6 +214,14 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
|
||||
rollTarget.rollKey = rollKey
|
||||
rollTarget.rollDice = event.target.dataset?.rollDice
|
||||
break
|
||||
case "spell":
|
||||
rollTarget = this.actor.items.find((i) => i.type === "spell" && i.id === rollKey)
|
||||
rollTarget.rollKey = rollKey
|
||||
break
|
||||
case "miracle":
|
||||
rollTarget = this.actor.items.find((i) => i.type === "miracle" && i.id === rollKey)
|
||||
rollTarget.rollKey = rollKey
|
||||
break
|
||||
case "skill":
|
||||
rollTarget = this.actor.items.find((i) => i.type === "skill" && i.id === rollKey)
|
||||
rollTarget.rollKey = rollKey
|
||||
@ -260,6 +273,11 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
|
||||
ui.notifications.error(game.i18n.localize("LETHALFANTASY.Notifications.rollTypeNotFound") + String(rollType))
|
||||
break
|
||||
}
|
||||
|
||||
// In all cases
|
||||
rollTarget.magicUser = this.actor.system.biodata.magicUser
|
||||
rollTarget.actorModifiers = foundry.utils.duplicate(this.actor.system.modifiers)
|
||||
|
||||
await this.document.system.roll(rollType, rollTarget)
|
||||
}
|
||||
// #endregion
|
||||
|
Reference in New Issue
Block a user