Modifications suite beta 2
This commit is contained in:
@@ -189,6 +189,9 @@ export class CharacterSheetL5r5e extends BaseCharacterSheetL5r5e {
|
||||
this._tabs
|
||||
.find((e) => e._navSelector === ".advancements-tabs")
|
||||
.activate("advancement_rank_" + (this.actor.system.identity.school_rank || 0));
|
||||
|
||||
// Arcane roll on name click
|
||||
html.find(".dice-picker-arcane").on("click", this._openDicePickerForArcane.bind(this));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -220,10 +223,49 @@ export class CharacterSheetL5r5e extends BaseCharacterSheetL5r5e {
|
||||
}
|
||||
|
||||
/**
|
||||
* Override base dice picker to open Chiaroscuro d6 dialog.
|
||||
* Open the Chiaroscuro dice dialog for an arcane item.
|
||||
* Parses `system.applicationDisplay` (comma-separated skill IDs and/or group names),
|
||||
* expands groups, pre-selects the first skill, and passes the arcane bonus.
|
||||
* @param {Event} event
|
||||
*/
|
||||
_openDicePickerForSkill(event) {
|
||||
_openDicePickerForArcane(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
if (event.clientX === 0 && event.clientY === 0) return;
|
||||
|
||||
const itemId = $(event.currentTarget).closest("[data-item-id]").data("item-id") ?? $(event.currentTarget).data("item-id");
|
||||
const item = this.actor.items.get(itemId);
|
||||
if (!item) return;
|
||||
|
||||
// Parse application array (database field) → expand skill groups
|
||||
const app = item.system.application || [];
|
||||
const rawEntries = (Array.isArray(app) ? app : app.split(","))
|
||||
.map((s) => s.trim().toLowerCase())
|
||||
.filter(Boolean);
|
||||
|
||||
const allGroupIds = new Set(CONFIG.l5r5e.skills.values());
|
||||
const skillIds = [];
|
||||
for (const entry of rawEntries) {
|
||||
if (allGroupIds.has(entry)) {
|
||||
// Expand group → all skills belonging to that group
|
||||
for (const [skillId, groupId] of CONFIG.l5r5e.skills.entries()) {
|
||||
if (groupId === entry && !skillIds.includes(skillId)) skillIds.push(skillId);
|
||||
}
|
||||
} else if (CONFIG.l5r5e.skills.has(entry) && !skillIds.includes(entry)) {
|
||||
skillIds.push(entry);
|
||||
}
|
||||
}
|
||||
|
||||
new game.l5r5e.ChiaroscuroDiceDialog({
|
||||
actor: this.actor,
|
||||
ringId: this.actor.system?.default_ring || "void",
|
||||
skillsList: skillIds,
|
||||
arcaneBonus: parseInt(item.system.bonus || 0),
|
||||
itemUuid: item.uuid,
|
||||
}).render(true);
|
||||
}
|
||||
|
||||
/**
|
||||
event.preventDefault();
|
||||
const el = $(event.currentTarget);
|
||||
const weapon = this._getWeaponInfos(el.data("weapon-id") || null);
|
||||
|
||||
@@ -24,6 +24,8 @@ export class ChiaroscuroDiceDialog extends FormApplication {
|
||||
useAspectPoint: false,
|
||||
aspectType: "solar",
|
||||
useAssistance: false,
|
||||
skillsList: [],
|
||||
arcaneBonus: 0,
|
||||
};
|
||||
|
||||
static get defaultOptions() {
|
||||
@@ -82,9 +84,17 @@ export class ChiaroscuroDiceDialog extends FormApplication {
|
||||
this.ringId = ringId;
|
||||
|
||||
// Skill
|
||||
if (options.skillId) {
|
||||
if (options.skillsList?.length > 0) {
|
||||
this.object.skillsList = options.skillsList;
|
||||
this.skillId = options.skillsList[0];
|
||||
} else if (options.skillId) {
|
||||
this.skillId = options.skillId;
|
||||
}
|
||||
|
||||
// Arcane bonus
|
||||
if (options.arcaneBonus) {
|
||||
this.object.arcaneBonus = parseInt(options.arcaneBonus) || 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,6 +149,14 @@ export class ChiaroscuroDiceDialog extends FormApplication {
|
||||
aspectsList,
|
||||
isVoidRing: this.object.ring.id === "void",
|
||||
quickInfo: this._actor?.system?.quick_info ?? "",
|
||||
hasMultipleSkills: this.object.skillsList.length > 1,
|
||||
skillsChoices: this.object.skillsList.map((id) => {
|
||||
const catId = CONFIG.l5r5e.skills.get(id.toLowerCase());
|
||||
return {
|
||||
id,
|
||||
label: catId ? game.i18n.localize(`l5r5e.skills.${catId}.${id}`) : id,
|
||||
};
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -182,6 +200,12 @@ export class ChiaroscuroDiceDialog extends FormApplication {
|
||||
this.render(false);
|
||||
});
|
||||
|
||||
// Skill selector (arcane)
|
||||
html.find("select[name='skill.id']").on("change", (event) => {
|
||||
this.skillId = event.target.value;
|
||||
this.render(false);
|
||||
});
|
||||
|
||||
// Roll button — explicit submit trigger
|
||||
html.find("button[name='roll']").on("click", (event) => {
|
||||
event.preventDefault();
|
||||
@@ -207,8 +231,9 @@ export class ChiaroscuroDiceDialog extends FormApplication {
|
||||
const wasAdjusted = diceAdjustedFlags.some(Boolean);
|
||||
|
||||
// Compute total
|
||||
const arcaneBonus = this.object.arcaneBonus || 0;
|
||||
const rawSum = adjustedResults.reduce((a, b) => a + b, 0);
|
||||
const total = rawSum + skillBonus + flatModifier;
|
||||
const total = rawSum + skillBonus + flatModifier + arcaneBonus;
|
||||
const success = total >= difficultyValue;
|
||||
const bonus = success ? total - difficultyValue : 0;
|
||||
|
||||
@@ -228,6 +253,7 @@ export class ChiaroscuroDiceDialog extends FormApplication {
|
||||
total,
|
||||
skillBonus,
|
||||
flatModifier,
|
||||
arcaneBonus,
|
||||
difficulty: difficultyObj,
|
||||
success,
|
||||
bonus,
|
||||
|
||||
Reference in New Issue
Block a user