First round of changes

This commit is contained in:
2026-04-23 14:27:33 +02:00
parent f72230dd39
commit abe35cb537
45 changed files with 1860 additions and 56 deletions

View File

@@ -64,6 +64,52 @@ export class CharacterSheetL5r5e extends BaseCharacterSheetL5r5e {
parseInt(sheetData.data.system.xp_total) - parseInt(sheetData.data.system.xp_spent)
);
// Chiaroscuro: Skill ranks list for <select>
sheetData.data.skillRanksList = Object.keys(CONFIG.l5r5e.skillRanks).map((id) => ({
id,
label: game.i18n.localize(`chiaroscuro.skill_ranks.${id}`),
}));
// Chiaroscuro: Normalize skill values 0 (number) → "0" (string) for selectOptions matching
for (const category of Object.values(sheetData.data.system.skills)) {
for (const [key, value] of Object.entries(category)) {
if (value === 0) category[key] = "0";
}
}
// Chiaroscuro: Aspects gauge data
const aspectsData = sheetData.data.system.aspects?.aspects ?? {};
const gauge = aspectsData.gauge ?? 0;
sheetData.data.aspectsData = {
solar: aspectsData.solar ?? 0,
lunar: aspectsData.lunar ?? 0,
gauge,
gaugePercent: ((gauge + 10) / 20) * 100,
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"] ?? [];
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"),
precis: invocations.filter((t) => t.system.invocation_type === "precis"),
};
// Chiaroscuro: Arcane items
sheetData.data.arcaneItems = sheetData.items.filter((i) => i.type === "arcane");
// Chiaroscuro: Identity tabs enriched HTML
sheetData.data.enrichedHtml.identity_text1 = await foundry.applications.ux.TextEditor.implementation.enrichHTML(
this.actor.system.identity_text1 ?? "", { async: true }
);
sheetData.data.enrichedHtml.identity_text2 = await foundry.applications.ux.TextEditor.implementation.enrichHTML(
this.actor.system.identity_text2 ?? "", { async: true }
);
return sheetData;
}
@@ -120,6 +166,14 @@ export class CharacterSheetL5r5e extends BaseCharacterSheetL5r5e {
// XP +/-
html.find(".xp-control").on("click", this._modifyXP.bind(this));
// Chiaroscuro: set default ring on ring-name click
html.find(".ring-set-default").on("click", (event) => {
event.preventDefault();
const ring = $(event.currentTarget).data("ring");
this.actor.update({ "system.default_ring": ring });
});
// Advancements Tab to current rank onload
// TODO class "Active" Bug on load, dunno why :/
this._tabs
@@ -127,6 +181,18 @@ export class CharacterSheetL5r5e extends BaseCharacterSheetL5r5e {
.activate("advancement_rank_" + (this.actor.system.identity.school_rank || 0));
}
/**
* Override base dice picker to open Chiaroscuro d6 dialog.
* @param {Event} event
*/
_openDicePickerForSkill(event) {
event.preventDefault();
const el = $(event.currentTarget);
const skillId = 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);
}
/**
* Split the school advancement, calculate the total xp spent and the current total xp spent by rank
*/
@@ -218,6 +284,13 @@ export class CharacterSheetL5r5e extends BaseCharacterSheetL5r5e {
delete formData["system.money.zeni"];
}
// Chiaroscuro: convert skill rank "0" (string from <select>) back to 0 (number)
for (const [key, value] of Object.entries(formData)) {
if (key.startsWith("system.skills.") && value === "0") {
formData[key] = 0;
}
}
// Save computed values
const currentData = this.object.system;
formData["system.focus"] = currentData.focus;

View File

@@ -50,6 +50,21 @@ export class NpcSheetL5r5e extends BaseCharacterSheetL5r5e {
label: game.i18n.localize("l5r5e.character_types." + e),
}));
// Danger levels for martial/social danger selects
const dangerLevels = ["simple", "moyenne", "assez_difficile", "difficile"];
sheetData.data.dangerList = dangerLevels.map((id) => ({
id,
label: game.i18n.localize(`chiaroscuro.danger.${id}`),
}));
// Invocations list (mot_invocation techniques, split by type like character sheet)
const invocations = sheetData.data.splitTechniquesList?.["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"),
precis: invocations.filter((t) => t.system.invocation_type === "precis"),
};
return sheetData;
}
@@ -101,4 +116,16 @@ export class NpcSheetL5r5e extends BaseCharacterSheetL5r5e {
return super._updateObject(event, formData);
}
/**
* Override base dice picker to open Chiaroscuro d6 dialog.
* @param {Event} event
*/
_openDicePickerForSkill(event) {
event.preventDefault();
const el = $(event.currentTarget);
const skillId = 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);
}
}