First round of changes
This commit is contained in:
44
system/scripts/items/arcane-sheet.js
Normal file
44
system/scripts/items/arcane-sheet.js
Normal file
@@ -0,0 +1,44 @@
|
||||
import { BaseItemSheetL5r5e } from "./base-item-sheet.js";
|
||||
|
||||
/**
|
||||
* Sheet for Arcane items (Chiaroscuro).
|
||||
* @extends {BaseItemSheetL5r5e}
|
||||
*/
|
||||
export class ArcaneSheetL5r5e extends BaseItemSheetL5r5e {
|
||||
/** @override */
|
||||
static get defaultOptions() {
|
||||
return foundry.utils.mergeObject(super.defaultOptions, {
|
||||
classes: ["l5r5e", "sheet", "arcane"],
|
||||
template: CONFIG.l5r5e.paths.templates + "items/arcane/arcane-sheet.html",
|
||||
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "attributes" }],
|
||||
});
|
||||
}
|
||||
|
||||
/** @override */
|
||||
async getData(options = {}) {
|
||||
const sheetData = await super.getData(options);
|
||||
|
||||
// Convert application array to comma-separated string for display
|
||||
const app = sheetData.data.system.application;
|
||||
sheetData.data.system.applicationDisplay = Array.isArray(app) ? app.join(", ") : (app ?? "");
|
||||
|
||||
sheetData.data.enrichedHtml = {
|
||||
description: await foundry.applications.ux.TextEditor.implementation.enrichHTML(
|
||||
sheetData.data.system.description ?? "",
|
||||
{ async: true }
|
||||
),
|
||||
};
|
||||
|
||||
return sheetData;
|
||||
}
|
||||
|
||||
/** @override */
|
||||
async _updateObject(event, formData) {
|
||||
// Convert comma-separated application string back to array
|
||||
const raw = formData["system.applicationDisplay"] ?? "";
|
||||
formData["system.application"] = raw.split(",").map((s) => s.trim()).filter(Boolean);
|
||||
delete formData["system.applicationDisplay"];
|
||||
|
||||
return super._updateObject(event, formData);
|
||||
}
|
||||
}
|
||||
@@ -11,4 +11,16 @@ export class ArmorSheetL5r5e extends ItemSheetL5r5e {
|
||||
template: CONFIG.l5r5e.paths.templates + "items/armor/armor-sheet.html",
|
||||
});
|
||||
}
|
||||
|
||||
/** @override */
|
||||
async getData(options = {}) {
|
||||
const sheetData = await super.getData(options);
|
||||
|
||||
const catObj = game.l5r5e.HelpersL5r5e.getLocalizedRawObject("chiaroscuro.armor.categories") ?? {};
|
||||
sheetData.data.armorCategories = Object.entries(catObj)
|
||||
.filter(([k]) => k !== "label")
|
||||
.map(([id, label]) => ({ id, label }));
|
||||
|
||||
return sheetData;
|
||||
}
|
||||
}
|
||||
|
||||
30
system/scripts/items/etat-sheet.js
Normal file
30
system/scripts/items/etat-sheet.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import { BaseItemSheetL5r5e } from "./base-item-sheet.js";
|
||||
|
||||
/**
|
||||
* Sheet for État items (Chiaroscuro).
|
||||
* @extends {BaseItemSheetL5r5e}
|
||||
*/
|
||||
export class EtatSheetL5r5e extends BaseItemSheetL5r5e {
|
||||
/** @override */
|
||||
static get defaultOptions() {
|
||||
return foundry.utils.mergeObject(super.defaultOptions, {
|
||||
classes: ["l5r5e", "sheet", "etat"],
|
||||
template: CONFIG.l5r5e.paths.templates + "items/etat/etat-sheet.html",
|
||||
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "attributes" }],
|
||||
});
|
||||
}
|
||||
|
||||
/** @override */
|
||||
async getData(options = {}) {
|
||||
const sheetData = await super.getData(options);
|
||||
|
||||
sheetData.data.enrichedHtml = {
|
||||
description: await foundry.applications.ux.TextEditor.implementation.enrichHTML(
|
||||
sheetData.data.system.description ?? "",
|
||||
{ async: true }
|
||||
),
|
||||
};
|
||||
|
||||
return sheetData;
|
||||
}
|
||||
}
|
||||
35
system/scripts/items/mystere-sheet.js
Normal file
35
system/scripts/items/mystere-sheet.js
Normal file
@@ -0,0 +1,35 @@
|
||||
import { BaseItemSheetL5r5e } from "./base-item-sheet.js";
|
||||
|
||||
/**
|
||||
* Sheet for Mystère items (Chiaroscuro).
|
||||
* @extends {BaseItemSheetL5r5e}
|
||||
*/
|
||||
export class MystereSheetL5r5e extends BaseItemSheetL5r5e {
|
||||
/** @override */
|
||||
static get defaultOptions() {
|
||||
return foundry.utils.mergeObject(super.defaultOptions, {
|
||||
classes: ["l5r5e", "sheet", "mystere"],
|
||||
template: CONFIG.l5r5e.paths.templates + "items/mystere/mystere-sheet.html",
|
||||
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "attributes" }],
|
||||
});
|
||||
}
|
||||
|
||||
/** @override */
|
||||
async getData(options = {}) {
|
||||
const sheetData = await super.getData(options);
|
||||
|
||||
sheetData.data.mystereTypes = [
|
||||
{ id: "mineur", label: game.i18n.localize("chiaroscuro.mystere.mineur") },
|
||||
{ id: "majeur", label: game.i18n.localize("chiaroscuro.mystere.majeur") },
|
||||
];
|
||||
|
||||
sheetData.data.enrichedHtml = {
|
||||
description: await foundry.applications.ux.TextEditor.implementation.enrichHTML(
|
||||
sheetData.data.system.description ?? "",
|
||||
{ async: true }
|
||||
),
|
||||
};
|
||||
|
||||
return sheetData;
|
||||
}
|
||||
}
|
||||
@@ -17,12 +17,27 @@ export class TechniqueSheetL5r5e extends ItemSheetL5r5e {
|
||||
const sheetData = await super.getData(options);
|
||||
|
||||
// List all available techniques type
|
||||
const types = ["core", "school", "title"];
|
||||
const types = ["core", "school", "title", "chiaroscuro"];
|
||||
if (game.settings.get(CONFIG.l5r5e.namespace, "techniques-customs")) {
|
||||
types.push("custom");
|
||||
}
|
||||
sheetData.data.techniquesList = game.l5r5e.HelpersL5r5e.getTechniquesList({ types });
|
||||
|
||||
// Invocation sub-type fields (visible only for mot_invocation)
|
||||
sheetData.data.isMotInvocation = sheetData.data.system.technique_type === "mot_invocation";
|
||||
sheetData.data.invocationTypes = [
|
||||
{ id: "general", label: game.i18n.localize("chiaroscuro.technique.invocation_types.general") },
|
||||
{ id: "neutre", label: game.i18n.localize("chiaroscuro.technique.invocation_types.neutre") },
|
||||
{ id: "precis", label: game.i18n.localize("chiaroscuro.technique.invocation_types.precis") },
|
||||
];
|
||||
sheetData.data.modeInvocationValues = [
|
||||
{ id: "-3", label: "-3" },
|
||||
{ id: "0", label: "0" },
|
||||
{ id: "3", label: "+3" },
|
||||
];
|
||||
// Convert mode_invocation to string for selectOptions matching
|
||||
sheetData.data.system.mode_invocation_str = String(sheetData.data.system.mode_invocation ?? 0);
|
||||
|
||||
// Sanitize Difficulty and Skill list
|
||||
sheetData.data.system.difficulty = TechniqueSheetL5r5e.formatDifficulty(sheetData.data.system.difficulty);
|
||||
sheetData.data.system.skill = TechniqueSheetL5r5e.translateSkillsList(
|
||||
@@ -55,6 +70,12 @@ export class TechniqueSheetL5r5e extends ItemSheetL5r5e {
|
||||
TechniqueSheetL5r5e.translateSkillsList(formData["system.skill"].split(","), true)
|
||||
).join(",");
|
||||
|
||||
// Convert mode_invocation_str back to number
|
||||
if ("system.mode_invocation_str" in formData) {
|
||||
formData["system.mode_invocation"] = parseInt(formData["system.mode_invocation_str"] ?? "0", 10);
|
||||
delete formData["system.mode_invocation_str"];
|
||||
}
|
||||
|
||||
return super._updateObject(event, formData);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,12 @@ export class WeaponSheetL5r5e extends ItemSheetL5r5e {
|
||||
label: "l5r5e.skills." + cat.toLowerCase() + "." + id.toLowerCase(),
|
||||
}));
|
||||
|
||||
// Weapon categories (Chiaroscuro)
|
||||
const catObj = game.l5r5e.HelpersL5r5e.getLocalizedRawObject("chiaroscuro.weapon.categories") ?? {};
|
||||
sheetData.data.weaponCategories = [{ id: "", label: "—" }].concat(
|
||||
Object.entries(catObj).map(([id, label]) => ({ id, label }))
|
||||
);
|
||||
|
||||
return sheetData;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user