Initial release for FoundryVTT
This commit is contained in:
223
modules/applications/donjon-et-cie-roll-dialog.mjs
Normal file
223
modules/applications/donjon-et-cie-roll-dialog.mjs
Normal file
@@ -0,0 +1,223 @@
|
||||
import { DonjonEtCieRolls } from "../donjon-et-cie-rolls.mjs";
|
||||
import { DonjonEtCieUtility } from "../donjon-et-cie-utility.mjs";
|
||||
|
||||
export class DonjonEtCieRollDialog {
|
||||
static async createInitiative(actor) {
|
||||
const content = await foundry.applications.handlebars.renderTemplate(
|
||||
"systems/fvtt-donjon-et-cie/templates/dialogs/initiative-roll.hbs",
|
||||
{
|
||||
actorName: actor.name,
|
||||
dex: actor.system.caracteristiques?.dexterite?.value ?? 0,
|
||||
initiativeBonus: actor.system.combat?.initiativeBonus ?? 0
|
||||
}
|
||||
);
|
||||
|
||||
return foundry.applications.api.DialogV2.wait({
|
||||
window: { title: game.i18n.localize("DNC.Roll.Initiative"), icon: "fa-solid fa-bolt" },
|
||||
classes: ["dnc-roll-dialog"],
|
||||
content,
|
||||
modal: false,
|
||||
buttons: [
|
||||
{
|
||||
action: "roll",
|
||||
label: "Lancer",
|
||||
icon: "fa-solid fa-bolt",
|
||||
default: true,
|
||||
callback: async (event, button) => {
|
||||
const form = button.form.elements;
|
||||
return DonjonEtCieRolls.rollInitiative(actor, {
|
||||
mode: form.mode?.value ?? "normal"
|
||||
});
|
||||
}
|
||||
}
|
||||
],
|
||||
rejectClose: false
|
||||
});
|
||||
}
|
||||
|
||||
static async createCharacteristic(actor, characteristicKey) {
|
||||
const characteristic = actor.system.caracteristiques?.[characteristicKey];
|
||||
if (!characteristic) return;
|
||||
|
||||
const content = await foundry.applications.handlebars.renderTemplate(
|
||||
"systems/fvtt-donjon-et-cie/templates/dialogs/characteristic-roll.hbs",
|
||||
{
|
||||
actorName: actor.name,
|
||||
characteristic,
|
||||
characteristicKey,
|
||||
favorOptions: DonjonEtCieUtility.getAvailableFavorOptions(actor),
|
||||
hasFavorOptions: DonjonEtCieUtility.getAvailableFavorOptions(actor).length > 0
|
||||
}
|
||||
);
|
||||
|
||||
return foundry.applications.api.DialogV2.wait({
|
||||
window: { title: game.i18n.localize("DNC.Roll.Characteristic"), icon: "fa-solid fa-dice-d20" },
|
||||
classes: ["dnc-roll-dialog"],
|
||||
content,
|
||||
modal: false,
|
||||
buttons: [
|
||||
{
|
||||
action: "roll",
|
||||
label: "Lancer",
|
||||
icon: "fa-solid fa-dice-d20",
|
||||
default: true,
|
||||
callback: async (event, button) => {
|
||||
const form = button.form.elements;
|
||||
return DonjonEtCieRolls.rollCharacteristic(actor, characteristicKey, {
|
||||
mode: form.mode?.value ?? "normal",
|
||||
favorKey: form.favorDepartment?.value ?? ""
|
||||
});
|
||||
}
|
||||
}
|
||||
],
|
||||
rejectClose: false
|
||||
});
|
||||
}
|
||||
|
||||
static async createWeapon(actor, item) {
|
||||
const content = await foundry.applications.handlebars.renderTemplate(
|
||||
"systems/fvtt-donjon-et-cie/templates/dialogs/weapon-roll.hbs",
|
||||
{
|
||||
actorName: actor.name,
|
||||
item,
|
||||
characteristicLabel: DonjonEtCieUtility.getWeaponCharacteristicLabel(item.system.categorie),
|
||||
characteristicValue: actor.system.caracteristiques?.[DonjonEtCieUtility.getWeaponCharacteristicKey(item.system.categorie)]?.value ?? 0,
|
||||
favorOptions: DonjonEtCieUtility.getAvailableFavorOptions(actor),
|
||||
hasFavorOptions: DonjonEtCieUtility.getAvailableFavorOptions(actor).length > 0
|
||||
}
|
||||
);
|
||||
|
||||
return foundry.applications.api.DialogV2.wait({
|
||||
window: { title: game.i18n.localize("DNC.Roll.Attack"), icon: "fa-solid fa-sword" },
|
||||
classes: ["dnc-roll-dialog"],
|
||||
content,
|
||||
modal: false,
|
||||
buttons: [
|
||||
{
|
||||
action: "roll",
|
||||
label: "Attaquer",
|
||||
icon: "fa-solid fa-sword",
|
||||
default: true,
|
||||
callback: async (event, button) => {
|
||||
const form = button.form.elements;
|
||||
return DonjonEtCieRolls.rollWeapon(actor, item, {
|
||||
mode: form.mode?.value ?? "normal",
|
||||
favorKey: form.favorDepartment?.value ?? ""
|
||||
});
|
||||
}
|
||||
}
|
||||
],
|
||||
rejectClose: false
|
||||
});
|
||||
}
|
||||
|
||||
static async createSpell(actor, item) {
|
||||
const characteristicKey = item.system.caracteristique || "intelligence";
|
||||
const characteristic = actor.system.caracteristiques?.[characteristicKey];
|
||||
const magicResources = DonjonEtCieUtility.getMagicResourceContext(actor);
|
||||
const content = await foundry.applications.handlebars.renderTemplate(
|
||||
"systems/fvtt-donjon-et-cie/templates/dialogs/spell-roll.hbs",
|
||||
{
|
||||
actorName: actor.name,
|
||||
item,
|
||||
characteristic,
|
||||
rank: magicResources.rank,
|
||||
currentPv: actor.system.sante?.pv?.value ?? 0,
|
||||
focusLabel: magicResources.focusLabel,
|
||||
focusDisplay: magicResources.focusDisplay,
|
||||
focusIsActive: magicResources.focusIsActive,
|
||||
chaosLabel: magicResources.chaosLabel,
|
||||
autoDisadvantage: Number(item.system.coutPv ?? 0) > magicResources.rank,
|
||||
favorOptions: DonjonEtCieUtility.getAvailableFavorOptions(actor),
|
||||
hasFavorOptions: DonjonEtCieUtility.getAvailableFavorOptions(actor).length > 0
|
||||
}
|
||||
);
|
||||
|
||||
return foundry.applications.api.DialogV2.wait({
|
||||
window: { title: game.i18n.localize("DNC.Roll.Spell"), icon: "fa-solid fa-wand-magic-sparkles" },
|
||||
classes: ["dnc-roll-dialog"],
|
||||
content,
|
||||
modal: false,
|
||||
buttons: [
|
||||
{
|
||||
action: "roll",
|
||||
label: "Lancer",
|
||||
icon: "fa-solid fa-wand-magic-sparkles",
|
||||
default: true,
|
||||
callback: async (event, button) => {
|
||||
const form = button.form.elements;
|
||||
return DonjonEtCieRolls.rollSpell(actor, item, {
|
||||
mode: form.mode?.value ?? "normal",
|
||||
favorKey: form.favorDepartment?.value ?? ""
|
||||
});
|
||||
}
|
||||
}
|
||||
],
|
||||
rejectClose: false
|
||||
});
|
||||
}
|
||||
|
||||
static async createUsage(item) {
|
||||
const content = await foundry.applications.handlebars.renderTemplate(
|
||||
"systems/fvtt-donjon-et-cie/templates/dialogs/usage-roll.hbs",
|
||||
{
|
||||
item
|
||||
}
|
||||
);
|
||||
|
||||
return foundry.applications.api.DialogV2.wait({
|
||||
window: { title: game.i18n.localize("DNC.Roll.Usage"), icon: "fa-solid fa-hourglass-half" },
|
||||
classes: ["dnc-roll-dialog"],
|
||||
content,
|
||||
modal: false,
|
||||
buttons: [
|
||||
{
|
||||
action: "roll",
|
||||
label: "Utiliser",
|
||||
icon: "fa-solid fa-hourglass-half",
|
||||
default: true,
|
||||
callback: async (event, button) => {
|
||||
const form = button.form.elements;
|
||||
return DonjonEtCieRolls.rollUsage(item, {
|
||||
mode: form.mode?.value ?? "normal"
|
||||
});
|
||||
}
|
||||
}
|
||||
],
|
||||
rejectClose: false
|
||||
});
|
||||
}
|
||||
|
||||
static async createDamage(actor, item) {
|
||||
const content = await foundry.applications.handlebars.renderTemplate(
|
||||
"systems/fvtt-donjon-et-cie/templates/dialogs/damage-roll.hbs",
|
||||
{
|
||||
actorName: actor?.name ?? item.actor?.name ?? "",
|
||||
item,
|
||||
actorBonus: actor?.system?.combat?.degatsBonus ?? 0
|
||||
}
|
||||
);
|
||||
|
||||
return foundry.applications.api.DialogV2.wait({
|
||||
window: { title: game.i18n.localize("DNC.Roll.Damage"), icon: "fa-solid fa-burst" },
|
||||
classes: ["dnc-roll-dialog"],
|
||||
content,
|
||||
modal: false,
|
||||
buttons: [
|
||||
{
|
||||
action: "roll",
|
||||
label: "Lancer",
|
||||
icon: "fa-solid fa-burst",
|
||||
default: true,
|
||||
callback: async (event, button) => {
|
||||
const form = button.form.elements;
|
||||
return DonjonEtCieRolls.rollDamage(actor, item, {
|
||||
mode: form.mode?.value ?? "normal"
|
||||
});
|
||||
}
|
||||
}
|
||||
],
|
||||
rejectClose: false
|
||||
});
|
||||
}
|
||||
}
|
||||
3
modules/applications/sheets/_module.mjs
Normal file
3
modules/applications/sheets/_module.mjs
Normal file
@@ -0,0 +1,3 @@
|
||||
export { default as DonjonEtCieItemSheet } from "./base-item-sheet.mjs";
|
||||
export { default as DonjonEtCieEmployeSheet } from "./donjon-et-cie-employe-sheet.mjs";
|
||||
export { default as DonjonEtCiePNJSheet } from "./donjon-et-cie-pnj-sheet.mjs";
|
||||
225
modules/applications/sheets/base-actor-sheet.mjs
Normal file
225
modules/applications/sheets/base-actor-sheet.mjs
Normal file
@@ -0,0 +1,225 @@
|
||||
const { HandlebarsApplicationMixin } = foundry.applications.api;
|
||||
|
||||
export default class DonjonEtCieActorSheet extends HandlebarsApplicationMixin(foundry.applications.sheets.ActorSheetV2) {
|
||||
static DEFAULT_OPTIONS = {
|
||||
classes: ["fvtt-donjon-et-cie", "sheet", "actor"],
|
||||
position: { width: 920, height: 820 },
|
||||
form: {
|
||||
submitOnChange: true,
|
||||
closeOnSubmit: false
|
||||
},
|
||||
window: {
|
||||
resizable: true
|
||||
},
|
||||
dragDrop: [{ dragSelector: ".item-list .item", dropSelector: ".item-dropzone" }],
|
||||
actions: {
|
||||
editImage: DonjonEtCieActorSheet.#onEditImage,
|
||||
setTab: DonjonEtCieActorSheet.#onSetTab,
|
||||
createItem: DonjonEtCieActorSheet.#onCreateItem,
|
||||
editItem: DonjonEtCieActorSheet.#onEditItem,
|
||||
deleteItem: DonjonEtCieActorSheet.#onDeleteItem,
|
||||
rollHitDice: DonjonEtCieActorSheet.#onRollHitDice,
|
||||
rollInitiative: DonjonEtCieActorSheet.#onRollInitiative,
|
||||
rollCharacteristic: DonjonEtCieActorSheet.#onRollCharacteristic,
|
||||
rollWeapon: DonjonEtCieActorSheet.#onRollWeapon,
|
||||
rollDamage: DonjonEtCieActorSheet.#onRollDamage,
|
||||
rollSpell: DonjonEtCieActorSheet.#onRollSpell,
|
||||
rollUsage: DonjonEtCieActorSheet.#onRollUsage,
|
||||
useFavorService: DonjonEtCieActorSheet.#onUseFavorService,
|
||||
postItem: DonjonEtCieActorSheet.#onPostItem,
|
||||
adjustCounter: DonjonEtCieActorSheet.#onAdjustCounter
|
||||
}
|
||||
};
|
||||
|
||||
async _prepareContext() {
|
||||
const actor = this.document;
|
||||
return {
|
||||
actor,
|
||||
system: actor.system,
|
||||
source: actor.toObject(),
|
||||
config: game.system.donjonEtCie.config,
|
||||
characteristics: actor.getCharacteristicEntries(),
|
||||
sections: actor.getSectionData(),
|
||||
fields: actor.schema.fields,
|
||||
systemFields: actor.system.schema.fields,
|
||||
activeTab: this._activeTab ?? "combat"
|
||||
};
|
||||
}
|
||||
|
||||
_onRender(context, options) {
|
||||
super._onRender(context, options);
|
||||
this.#fixWindowShell();
|
||||
this._applyActiveTab();
|
||||
}
|
||||
|
||||
#fixWindowShell() {
|
||||
const app = this.element?.matches?.(".application") ? this.element : this.element?.closest(".application");
|
||||
const content = app?.querySelector(":scope > .window-content") ?? app?.querySelector(".window-content");
|
||||
const header = app?.querySelector(".window-header");
|
||||
|
||||
if (app) {
|
||||
app.style.display = "flex";
|
||||
app.style.flexDirection = "column";
|
||||
app.style.paddingTop = "0";
|
||||
app.style.overflow = "hidden";
|
||||
}
|
||||
|
||||
if (header) {
|
||||
header.style.width = "100%";
|
||||
header.style.flex = "0 0 auto";
|
||||
header.style.position = "relative";
|
||||
header.style.zIndex = "3";
|
||||
}
|
||||
|
||||
if (content) {
|
||||
content.style.width = "100%";
|
||||
content.style.flex = "1 1 auto";
|
||||
content.style.minHeight = "0";
|
||||
content.style.overflowY = "auto";
|
||||
content.style.overflowX = "hidden";
|
||||
}
|
||||
}
|
||||
|
||||
_canDragStart() {
|
||||
return this.isEditable;
|
||||
}
|
||||
|
||||
_canDragDrop() {
|
||||
return this.isEditable;
|
||||
}
|
||||
|
||||
_onDragStart(event) {
|
||||
const itemElement = event.currentTarget.closest(".item");
|
||||
if (!itemElement) return;
|
||||
|
||||
const itemId = itemElement.dataset.itemId;
|
||||
const item = this.document.items.get(itemId);
|
||||
if (!item) return;
|
||||
|
||||
event.dataTransfer.setData("text/plain", JSON.stringify({ type: "Item", uuid: item.uuid }));
|
||||
}
|
||||
|
||||
_onDragOver(event) {
|
||||
const dropTarget = event.target.closest(".item-section");
|
||||
this.#setDropTarget(dropTarget);
|
||||
}
|
||||
|
||||
async _onDrop(event) {
|
||||
this.#setDropTarget(null);
|
||||
return super._onDrop(event);
|
||||
}
|
||||
|
||||
#setDropTarget(target) {
|
||||
this.element.querySelectorAll(".item-section.is-dragover").forEach((section) => section.classList.remove("is-dragover"));
|
||||
if (target instanceof HTMLElement) {
|
||||
target.classList.add("is-dragover");
|
||||
}
|
||||
}
|
||||
|
||||
_applyActiveTab() {
|
||||
const activeTab = this._activeTab ?? "combat";
|
||||
this.element.querySelectorAll("[data-tab-button]").forEach((button) => {
|
||||
const isActive = button.dataset.tab === activeTab;
|
||||
button.classList.toggle("active", isActive);
|
||||
button.setAttribute("aria-pressed", isActive ? "true" : "false");
|
||||
});
|
||||
|
||||
this.element.querySelectorAll("[data-tab-panel]").forEach((panel) => {
|
||||
const isActive = panel.dataset.tabPanel === activeTab;
|
||||
panel.classList.toggle("active", isActive);
|
||||
panel.toggleAttribute("hidden", !isActive);
|
||||
});
|
||||
}
|
||||
|
||||
static async #onEditImage(event) {
|
||||
event.preventDefault();
|
||||
const picker = new FilePicker({
|
||||
type: "image",
|
||||
current: this.document.img,
|
||||
callback: (path) => this.document.update({ img: path })
|
||||
});
|
||||
return picker.browse();
|
||||
}
|
||||
|
||||
static async #onCreateItem(event, target) {
|
||||
event.preventDefault();
|
||||
const type = target.dataset.type;
|
||||
if (!type) return;
|
||||
return this.document.createEmbeddedDocuments("Item", [{ name: `Nouveau ${type}`, type }], { renderSheet: true });
|
||||
}
|
||||
|
||||
static async #onSetTab(event, target) {
|
||||
event.preventDefault();
|
||||
const tab = target.dataset.tab;
|
||||
if (!tab) return;
|
||||
this._activeTab = tab;
|
||||
this._applyActiveTab();
|
||||
}
|
||||
|
||||
static async #onEditItem(event, target) {
|
||||
event.preventDefault();
|
||||
const item = this.document.items.get(target.closest("[data-item-id]")?.dataset.itemId);
|
||||
return item?.sheet.render(true);
|
||||
}
|
||||
|
||||
static async #onDeleteItem(event, target) {
|
||||
event.preventDefault();
|
||||
const itemId = target.closest("[data-item-id]")?.dataset.itemId;
|
||||
if (!itemId) return;
|
||||
return this.document.deleteEmbeddedDocuments("Item", [itemId]);
|
||||
}
|
||||
|
||||
static async #onRollCharacteristic(event, target) {
|
||||
event.preventDefault();
|
||||
return this.document.rollCharacteristic(target.dataset.characteristic);
|
||||
}
|
||||
|
||||
static async #onRollInitiative(event) {
|
||||
event.preventDefault();
|
||||
return this.document.rollInitiative();
|
||||
}
|
||||
|
||||
static async #onRollHitDice(event) {
|
||||
event.preventDefault();
|
||||
return this.document.rollHitDice();
|
||||
}
|
||||
|
||||
static async #onRollWeapon(event, target) {
|
||||
event.preventDefault();
|
||||
return this.document.rollWeapon(target.closest("[data-item-id]")?.dataset.itemId);
|
||||
}
|
||||
|
||||
static async #onRollDamage(event, target) {
|
||||
event.preventDefault();
|
||||
return this.document.rollDamage(target.closest("[data-item-id]")?.dataset.itemId);
|
||||
}
|
||||
|
||||
static async #onRollSpell(event, target) {
|
||||
event.preventDefault();
|
||||
return this.document.rollSpell(target.closest("[data-item-id]")?.dataset.itemId);
|
||||
}
|
||||
|
||||
static async #onRollUsage(event, target) {
|
||||
event.preventDefault();
|
||||
return this.document.rollUsage(target.closest("[data-item-id]")?.dataset.itemId);
|
||||
}
|
||||
|
||||
static async #onUseFavorService(event, target) {
|
||||
event.preventDefault();
|
||||
return this.document.useFavorService(target.dataset.department);
|
||||
}
|
||||
|
||||
static async #onPostItem(event, target) {
|
||||
event.preventDefault();
|
||||
const item = this.document.items.get(target.closest("[data-item-id]")?.dataset.itemId);
|
||||
return item?.postToChat();
|
||||
}
|
||||
|
||||
static async #onAdjustCounter(event, target) {
|
||||
event.preventDefault();
|
||||
const path = target.dataset.path;
|
||||
const delta = Number(target.dataset.delta ?? 0);
|
||||
if (!path || Number.isNaN(delta)) return;
|
||||
return this.document.adjustNumericField(path, delta);
|
||||
}
|
||||
}
|
||||
110
modules/applications/sheets/base-item-sheet.mjs
Normal file
110
modules/applications/sheets/base-item-sheet.mjs
Normal file
@@ -0,0 +1,110 @@
|
||||
import { DonjonEtCieUtility } from "../../donjon-et-cie-utility.mjs";
|
||||
|
||||
const { HandlebarsApplicationMixin } = foundry.applications.api;
|
||||
|
||||
export default class DonjonEtCieItemSheet extends HandlebarsApplicationMixin(foundry.applications.sheets.ItemSheetV2) {
|
||||
static DEFAULT_OPTIONS = {
|
||||
classes: ["fvtt-donjon-et-cie", "sheet", "item"],
|
||||
position: { width: 640, height: 700 },
|
||||
form: {
|
||||
submitOnChange: true,
|
||||
closeOnSubmit: false
|
||||
},
|
||||
window: {
|
||||
resizable: true
|
||||
},
|
||||
actions: {
|
||||
editImage: DonjonEtCieItemSheet.#onEditImage,
|
||||
postItem: DonjonEtCieItemSheet.#onPostItem,
|
||||
rollItem: DonjonEtCieItemSheet.#onRollItem,
|
||||
rollDamageItem: DonjonEtCieItemSheet.#onRollDamageItem
|
||||
}
|
||||
};
|
||||
|
||||
static PARTS = {
|
||||
main: { template: "systems/fvtt-donjon-et-cie/templates/items/item-sheet.hbs" }
|
||||
};
|
||||
|
||||
async _prepareContext() {
|
||||
const item = this.document;
|
||||
return {
|
||||
item,
|
||||
system: item.system,
|
||||
source: item.toObject(),
|
||||
config: game.system.donjonEtCie.config,
|
||||
fields: item.schema.fields,
|
||||
systemFields: item.system.schema.fields,
|
||||
isWeapon: item.type === "arme",
|
||||
isArmor: item.type === "armure",
|
||||
isConsumable: item.type === "consommable",
|
||||
isSpell: item.type === "sortilege",
|
||||
canRollDamage: Boolean(item.system.degats),
|
||||
isEquipment: item.type === "equipement",
|
||||
isCapacity: item.type === "capacite",
|
||||
isLanguage: item.type === "langue",
|
||||
isTrait: item.type === "trait",
|
||||
armorProtectionDisplay: Number(item.system.resultatProtection ?? 0) > 0 ? item.system.resultatProtection : "—",
|
||||
weaponCharacteristicLabel: item.type === "arme" ? DonjonEtCieUtility.getWeaponCharacteristicLabel(item.system.categorie) : null,
|
||||
enrichedDescription: await foundry.applications.ux.TextEditor.implementation.enrichHTML(item.system.description ?? "", { async: true }),
|
||||
enrichedNotes: await foundry.applications.ux.TextEditor.implementation.enrichHTML(item.system.notes ?? "", { async: true })
|
||||
};
|
||||
}
|
||||
|
||||
_onRender(context, options) {
|
||||
super._onRender(context, options);
|
||||
this.#fixWindowShell();
|
||||
}
|
||||
|
||||
#fixWindowShell() {
|
||||
const content = this.element?.closest(".window-content") ?? this.element?.parentElement;
|
||||
const app = content?.closest(".application") ?? this.element?.closest(".application");
|
||||
const header = app?.querySelector(".window-header");
|
||||
|
||||
if (app) {
|
||||
app.style.display = "flex";
|
||||
app.style.flexDirection = "column";
|
||||
app.style.paddingTop = "0";
|
||||
app.style.overflow = "hidden";
|
||||
}
|
||||
|
||||
if (header) {
|
||||
header.style.width = "100%";
|
||||
header.style.flex = "0 0 auto";
|
||||
header.style.position = "relative";
|
||||
header.style.zIndex = "3";
|
||||
}
|
||||
|
||||
if (content) {
|
||||
content.style.width = "100%";
|
||||
content.style.flex = "1 1 auto";
|
||||
content.style.minHeight = "0";
|
||||
content.style.overflowY = "auto";
|
||||
content.style.overflowX = "hidden";
|
||||
}
|
||||
}
|
||||
|
||||
static async #onEditImage(event) {
|
||||
event.preventDefault();
|
||||
const picker = new FilePicker({
|
||||
type: "image",
|
||||
current: this.document.img,
|
||||
callback: (path) => this.document.update({ img: path })
|
||||
});
|
||||
return picker.browse();
|
||||
}
|
||||
|
||||
static async #onPostItem(event) {
|
||||
event.preventDefault();
|
||||
return this.document.postToChat();
|
||||
}
|
||||
|
||||
static async #onRollItem(event) {
|
||||
event.preventDefault();
|
||||
return this.document.roll();
|
||||
}
|
||||
|
||||
static async #onRollDamageItem(event) {
|
||||
event.preventDefault();
|
||||
return this.document.rollDamage();
|
||||
}
|
||||
}
|
||||
37
modules/applications/sheets/donjon-et-cie-employe-sheet.mjs
Normal file
37
modules/applications/sheets/donjon-et-cie-employe-sheet.mjs
Normal file
@@ -0,0 +1,37 @@
|
||||
import DonjonEtCieActorSheet from "./base-actor-sheet.mjs";
|
||||
import { DonjonEtCieUtility } from "../../donjon-et-cie-utility.mjs";
|
||||
|
||||
export default class DonjonEtCieEmployeSheet extends DonjonEtCieActorSheet {
|
||||
static DEFAULT_OPTIONS = {
|
||||
...super.DEFAULT_OPTIONS,
|
||||
classes: [...super.DEFAULT_OPTIONS.classes, "employe"],
|
||||
position: { width: 980, height: 860 }
|
||||
};
|
||||
|
||||
static PARTS = {
|
||||
main: { template: "systems/fvtt-donjon-et-cie/templates/actors/employe-sheet.hbs" }
|
||||
};
|
||||
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext();
|
||||
const indexedSections = Object.fromEntries(context.sections.map((section) => [section.key, section]));
|
||||
const getSection = (key) => indexedSections[key] ?? {
|
||||
key,
|
||||
label: context.config.actorSections[key]?.label ?? key,
|
||||
createType: context.config.actorSections[key]?.createType ?? key,
|
||||
items: []
|
||||
};
|
||||
|
||||
return {
|
||||
...context,
|
||||
magicResources: DonjonEtCieUtility.getMagicResourceContext(this.document),
|
||||
favorEntries: this.document.getFavorEntries(),
|
||||
chaosTable: DonjonEtCieUtility.getChaosTableEntries(),
|
||||
traitsSection: getSection("traits"),
|
||||
combatSections: ["armes", "armures", "consommables", "equipements"].map(getSection),
|
||||
spellSection: getSection("sortileges"),
|
||||
capacitySection: getSection("capacites"),
|
||||
profileSections: ["langues"].map(getSection)
|
||||
};
|
||||
}
|
||||
}
|
||||
57
modules/applications/sheets/donjon-et-cie-pnj-sheet.mjs
Normal file
57
modules/applications/sheets/donjon-et-cie-pnj-sheet.mjs
Normal file
@@ -0,0 +1,57 @@
|
||||
import DonjonEtCieActorSheet from "./base-actor-sheet.mjs";
|
||||
import { DonjonEtCieUtility } from "../../donjon-et-cie-utility.mjs";
|
||||
|
||||
export default class DonjonEtCiePNJSheet extends DonjonEtCieActorSheet {
|
||||
static DEFAULT_OPTIONS = {
|
||||
...super.DEFAULT_OPTIONS,
|
||||
classes: [...super.DEFAULT_OPTIONS.classes, "pnj"],
|
||||
position: { width: 840, height: 760 },
|
||||
actions: {
|
||||
...super.DEFAULT_OPTIONS.actions,
|
||||
rollPnjArmor: DonjonEtCiePNJSheet.#onRollPnjArmor,
|
||||
rollPnjCourage: DonjonEtCiePNJSheet.#onRollPnjCourage,
|
||||
rollPnjAttackDamage: DonjonEtCiePNJSheet.#onRollPnjAttackDamage
|
||||
}
|
||||
};
|
||||
|
||||
static PARTS = {
|
||||
main: { template: "systems/fvtt-donjon-et-cie/templates/actors/pnj-sheet.hbs" }
|
||||
};
|
||||
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext();
|
||||
const system = this.document.system;
|
||||
const indexedSections = Object.fromEntries(context.sections.map((section) => [section.key, section]));
|
||||
const getSection = (key) => indexedSections[key] ?? {
|
||||
key,
|
||||
label: context.config.actorSections[key]?.label ?? key,
|
||||
createType: context.config.actorSections[key]?.createType ?? key,
|
||||
items: []
|
||||
};
|
||||
|
||||
return {
|
||||
...context,
|
||||
capacitySection: getSection("capacites"),
|
||||
spellSection: getSection("sortileges"),
|
||||
armorDisplay: Number(system.defense?.armure?.delta ?? 0) ? `Δ${system.defense.armure.delta}` : "—",
|
||||
storedArmor: Number(system.defense?.armure?.resultatProtection ?? 0) > 0 ? system.defense.armure.resultatProtection : "—",
|
||||
courageDisplay: Number(system.defense?.courage?.delta ?? 0) ? `Δ${system.defense.courage.delta}` : "—",
|
||||
hasAttackDamage: Boolean(system.attaque?.degats)
|
||||
};
|
||||
}
|
||||
|
||||
static async #onRollPnjArmor(event) {
|
||||
event.preventDefault();
|
||||
return this.document.rollPnjArmor();
|
||||
}
|
||||
|
||||
static async #onRollPnjCourage(event) {
|
||||
event.preventDefault();
|
||||
return this.document.rollPnjCourage();
|
||||
}
|
||||
|
||||
static async #onRollPnjAttackDamage(event) {
|
||||
event.preventDefault();
|
||||
return this.document.rollPnjAttackDamage();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user