ENhance and fix

This commit is contained in:
2026-05-10 23:12:21 +02:00
parent e200b5f7b0
commit 7542890232
43 changed files with 638 additions and 390 deletions
+36 -7
View File
@@ -92,11 +92,8 @@ export class CharacterSheetL5r5e extends BaseCharacterSheetL5r5e {
gaugeColor: gauge > 0 ? "#d4a855" : gauge < 0 ? "#5588aa" : "#888888",
};
// Chiaroscuro: État items active on the character
sheetData.data.etatItems = sheetData.items.filter((i) => i.type === "etat");
// Chiaroscuro: Invocations split by type (from splitTechniquesList)
const invocations = sheetData.data.splitTechniquesList["mot_invocation"] ?? [];
// Chiaroscuro: Invocations split by type (direct from items)
const invocations = sheetData.items.filter((i) => i.type === "mot_invocation");
sheetData.data.splitInvocationsList = {
general: invocations.filter((t) => !t.system.invocation_type || t.system.invocation_type === "general"),
neutre: invocations.filter((t) => t.system.invocation_type === "neutre"),
@@ -109,6 +106,9 @@ export class CharacterSheetL5r5e extends BaseCharacterSheetL5r5e {
// Chiaroscuro: Mystere items
sheetData.data.mystereItems = sheetData.items.filter((i) => i.type === "mystere");
// Chiaroscuro: Technique École items
sheetData.data.techniqueEcoleItems = sheetData.items.filter((i) => i.type === "technique_ecole");
// Chiaroscuro: Identity tabs enriched HTML
sheetData.data.enrichedHtml.identity_text1 = await foundry.applications.ux.TextEditor.implementation.enrichHTML(
this.actor.system.identity_text1 ?? "", { async: true }
@@ -191,6 +191,34 @@ export class CharacterSheetL5r5e extends BaseCharacterSheetL5r5e {
.activate("advancement_rank_" + (this.actor.system.identity.school_rank || 0));
}
/**
* Override to handle mot_invocation creation with invocation_type from the column.
* @param {Event} event
* @override
*/
async _addSubItem(event) {
const type = $(event.currentTarget).data("item-type");
if (type === "mot_invocation") {
event.preventDefault();
event.stopPropagation();
const invocationType = $(event.currentTarget).data("invocation-type") || "general";
const created = await this.actor.createEmbeddedDocuments("Item", [
{
name: game.i18n.localize(`TYPES.Item.mot_invocation`),
type: "mot_invocation",
img: `${CONFIG.l5r5e.paths.assets}icons/items/mot_invocation.svg`,
system: { invocation_type: invocationType },
},
]);
if (created?.length > 0) {
const item = this.actor.items.get(created[0].id);
item?.sheet.render(true);
}
return;
}
return super._addSubItem(event);
}
/**
* Override base dice picker to open Chiaroscuro d6 dialog.
* @param {Event} event
@@ -198,9 +226,10 @@ export class CharacterSheetL5r5e extends BaseCharacterSheetL5r5e {
_openDicePickerForSkill(event) {
event.preventDefault();
const el = $(event.currentTarget);
const skillId = el.data("skill");
const weapon = this._getWeaponInfos(el.data("weapon-id") || null);
const skillId = weapon?.skill || el.data("skill");
const ringId = el.data("ring") || this.actor.system?.default_ring || "void";
new game.l5r5e.ChiaroscuroDiceDialog({ actor: this.actor, ringId, skillId }).render(true);
new game.l5r5e.ChiaroscuroDiceDialog({ actor: this.actor, ringId, skillId, itemUuid: weapon?.uuid }).render(true);
}
/**
+3 -2
View File
@@ -124,8 +124,9 @@ export class NpcSheetL5r5e extends BaseCharacterSheetL5r5e {
_openDicePickerForSkill(event) {
event.preventDefault();
const el = $(event.currentTarget);
const skillId = el.data("skill");
const weapon = this._getWeaponInfos(el.data("weapon-id") || null);
const skillId = weapon?.skill || el.data("skill");
const ringId = el.data("ring") || this.actor.system?.default_ring || "void";
new game.l5r5e.ChiaroscuroDiceDialog({ actor: this.actor, ringId, skillId }).render(true);
new game.l5r5e.ChiaroscuroDiceDialog({ actor: this.actor, ringId, skillId, itemUuid: weapon?.uuid }).render(true);
}
}
+7 -25
View File
@@ -57,7 +57,7 @@ export class ChiaroscuroDiceDialog extends FormApplication {
}
/**
* @param options actor, actorId, ringId, skillId
* @param options actor, actorId, ringId, skillId, itemUuid
*/
constructor(options = {}) {
super({}, options);
@@ -74,6 +74,9 @@ export class ChiaroscuroDiceDialog extends FormApplication {
}
});
// Resolve item from uuid (weapon, technique, etc.)
this._item = options.itemUuid ? fromUuidSync(options.itemUuid) : null;
// Default ring: options > actor default_ring > void
const ringId = options.ringId ?? this._actor?.system?.default_ring ?? "void";
this.ringId = ringId;
@@ -272,32 +275,8 @@ export class ChiaroscuroDiceDialog extends FormApplication {
[`${aspectsPath}.solar`]: 0,
[`${aspectsPath}.lunar`]: 0,
});
// Remove all desequilibre conditions
const toRemove = this._actor.items
.filter((i) => i.type === "etat" && ["desequilibre_solaire", "desequilibre_lunaire"].includes(i.system?.condition_type))
.map((i) => i.id);
if (toRemove.length) {
await this._actor.deleteEmbeddedDocuments("Item", toRemove);
}
} else {
await this._actor.update({ [`${aspectsPath}.gauge`]: newGauge });
if (Math.abs(newGauge) >= 5) {
// Apply opposing desequilibre
const condType = this.object.aspectType === "solar" ? "desequilibre_lunaire" : "desequilibre_solaire";
const existing = this._actor.items.find(
(i) => i.type === "etat" && i.system?.condition_type === condType
);
if (!existing) {
await this._actor.createEmbeddedDocuments("Item", [
{
type: "etat",
name: game.i18n.localize(`chiaroscuro.aspects.${condType}`),
system: { condition_type: condType },
},
]);
}
}
}
}
@@ -321,6 +300,9 @@ export class ChiaroscuroDiceDialog extends FormApplication {
useAssistance: this.object.useAssistance,
modifier: this.object.modifier,
quickInfo: this._actor?.system?.quick_info ?? "",
l5r5e: {
item: this._item ?? null,
},
...rollData,
}
);
+1 -1
View File
@@ -21,7 +21,7 @@ export class ItemL5r5e extends Item {
* @memberof ClientDocumentMixin#
*/
get uuid() {
const parents = this.system.parent_id;
const parents = this.system?.parent_id;
if (!parents?.item_id) {
return super.uuid;
}
+3 -3
View File
@@ -10,8 +10,8 @@ export class AdvancementSheetL5r5e extends ItemSheetL5r5e {
static types = [
{ id: "ring", label: "l5r5e.rings.label" },
{ id: "skill", label: "l5r5e.skills.label" },
{ id: "arcane", label: "l5r5e.chiaroscuro.arcane.label" },
{ id: "mot_invocation", label: "l5r5e.chiaroscuro.technique.mot_invocation" },
{ id: "arcane", label: "chiaroscuro.arcane.label" },
{ id: "mot_invocation", label: "chiaroscuro.technique.mot_invocation" },
// others have theirs own xp count
];
@@ -30,7 +30,7 @@ export class AdvancementSheetL5r5e extends ItemSheetL5r5e {
sheetData.data.skillsList = game.l5r5e.HelpersL5r5e.getSkillsList(true);
// Invocation sub-types (Général / Neutre / Précis)
const invTypes = game.l5r5e.HelpersL5r5e.getLocalizedRawObject("l5r5e.chiaroscuro.technique.invocation_types") ?? {};
const invTypes = game.l5r5e.HelpersL5r5e.getLocalizedRawObject("chiaroscuro.technique.invocation_types") ?? {};
sheetData.data.invocationTypesList = [{ id: "", label: "—" }].concat(
Object.entries(invTypes).map(([id, label]) => ({ id, label }))
);
-30
View File
@@ -1,30 +0,0 @@
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;
}
}
+1 -1
View File
@@ -27,7 +27,7 @@ export class MotInvocationSheetL5r5e extends BaseItemSheetL5r5e {
const sheetData = await super.getData(options);
// Build invocation types list from i18n
const invTypes = game.l5r5e.HelpersL5r5e.getLocalizedRawObject("l5r5e.chiaroscuro.technique.invocation_types") ?? {};
const invTypes = game.l5r5e.HelpersL5r5e.getLocalizedRawObject("chiaroscuro.technique.invocation_types") ?? {};
sheetData.data.invocationTypesList = [{ id: "", label: "—" }].concat(
Object.entries(invTypes).map(([id, label]) => ({ id, label }))
);
-6
View File
@@ -28,7 +28,6 @@ import { WeaponSheetL5r5e } from "./items/weapon-sheet.js";
import { AdvancementSheetL5r5e } from "./items/advancement-sheet.js";
import { PeculiaritySheetL5r5e } from "./items/peculiarity-sheet.js";
import { ArcaneSheetL5r5e } from "./items/arcane-sheet.js";
import { EtatSheetL5r5e } from "./items/etat-sheet.js";
import { MystereSheetL5r5e } from "./items/mystere-sheet.js";
import { TechniqueEcoleSheetL5r5e } from "./items/technique-ecole-sheet.js";
import { MotInvocationSheetL5r5e } from "./items/mot-invocation-sheet.js";
@@ -177,11 +176,6 @@ Hooks.once("init", async () => {
label: "TYPES.Item.arcane",
makeDefault: true,
});
fdc.Items.registerSheet(L5R5E.namespace, EtatSheetL5r5e, {
types: ["etat"],
label: "TYPES.Item.etat",
makeDefault: true,
});
fdc.Items.registerSheet(L5R5E.namespace, MystereSheetL5r5e, {
types: ["mystere"],
label: "TYPES.Item.mystere",
+14 -1
View File
@@ -6,7 +6,7 @@ export class MigrationL5r5e {
* Minimum Version needed for migration stuff to trigger
* @type {string}
*/
static NEEDED_VERSION = "1.13.0";
static NEEDED_VERSION = "14.0.1";
/**
* Return true if the version need some updates
@@ -56,6 +56,19 @@ export class MigrationL5r5e {
console.error(err);
}
// ***** 14.0.1: Remove obsolete etat items *****
if (options?.force || MigrationL5r5e.needUpdate("14.0.1")) {
try {
const etatIds = actor.items.filter((i) => i.type === "etat").map((i) => i.id);
if (etatIds.length) {
console.log(`L5R5E | Migration | Removing ${etatIds.length} etat item(s) from Actor ${actor.name}`);
await actor.deleteEmbeddedDocuments("Item", etatIds);
}
} catch (err) {
console.error(`L5R5E | Migration | Failed to remove etat items from Actor ${actor.name}: ${err.message}`);
}
}
// Migrate Actor's Items
if (actor.items.size) {
console.group(`Checking within ${actor.items.size} items`);