diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bfea2a..6647ed2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,8 @@ - Added confirm dialog on item's deletion (Hold "ctrl" on the click, if you want to bypass it) - Added "Sleep" & "Scene End" buttons in "GM ToolBox" (old "difficulty" box) - Added an option to reverse the token's bar on fatigue (thanks to Jzrzmy), and colorize in red the strife bar if compromise -- Split techniques in actor sheet for better readability +- Split Techniques & Items by category in actor sheet (pc & npc) for better readability +- Armor & Weapon added in the conflict tab now set the "eqquiped" props by default ## 1.1.2 - One Compendium to bring them all - Added compendiums (Thanks to Stéfano Fara for the English version !) Partial for French as PoW and CR are not translated yet diff --git a/system/scripts/actors/base-sheet.js b/system/scripts/actors/base-sheet.js index 6dc1830..1d6a2c8 100644 --- a/system/scripts/actors/base-sheet.js +++ b/system/scripts/actors/base-sheet.js @@ -32,14 +32,17 @@ export class BaseSheetL5r5e extends ActorSheet { return a.name.localeCompare(b.name); }); - // Split techniques by types + // Split Techniques by types sheetData.data.splitTechniquesList = this._splitTechniques(sheetData); + // Split Items by types + sheetData.data.splitItemsList = this._splitItems(sheetData); + return sheetData; } /** - * Split techniques by types for better readability + * Split Techniques by types for better readability * @private */ _splitTechniques(sheetData) { @@ -73,12 +76,32 @@ export class BaseSheetL5r5e extends ActorSheet { sheetData.data.techniques["mastery_ability"] = out["mastery_ability"].length === 0; // Always display "school_ability", but display "mastery_ability" only if rank >= 5 - if (sheetData.data.identity.school_rank < 5 && out["mastery_ability"].length === 0) { + if (sheetData.data.identity?.school_rank < 5 && out["mastery_ability"].length === 0) { delete out["mastery_ability"]; } return out; } + /** + * Split Items by types for better readability + * @private + */ + _splitItems(sheetData) { + const out = { + weapon: [], + armor: [], + item: [], + }; + + sheetData.items.forEach((item) => { + if (["item", "armor", "weapon"].includes(item.type)) { + out[item.type].push(item); + } + }); + + return out; + } + /** * Return a light sheet if in "limited" state * @override @@ -311,12 +334,22 @@ export class BaseSheetL5r5e extends ActorSheet { item.data.data.bought_at_rank = this.actor.data.data.identity.school_rank; } - // If technique, select the current type - if (item.data.type === "technique") { - const techType = $(event.currentTarget).data("tech-type"); - if ([...CONFIG.l5r5e.techniques, ...CONFIG.l5r5e.techniques_school].includes(techType)) { - item.data.data.technique_type = techType; - item.data.img = `${CONFIG.l5r5e.paths.assets}/icons/techs/${techType}.svg`; + switch (item.data.type) { + case "armor": // no break + case "weapon": + if ($(event.currentTarget).data("item-eqquiped")) { + item.data.data.equipped = true; + } + break; + + case "technique": { + // If technique, select the current type + const techType = $(event.currentTarget).data("tech-type"); + if ([...CONFIG.l5r5e.techniques, ...CONFIG.l5r5e.techniques_school].includes(techType)) { + item.data.data.technique_type = techType; + item.data.img = `${CONFIG.l5r5e.paths.assets}/icons/techs/${techType}.svg`; + } + break; } } diff --git a/system/scripts/dice/roll-n-keep-dialog.js b/system/scripts/dice/roll-n-keep-dialog.js index d22fc42..fad6b9e 100644 --- a/system/scripts/dice/roll-n-keep-dialog.js +++ b/system/scripts/dice/roll-n-keep-dialog.js @@ -23,7 +23,7 @@ export class RollnKeepDialog extends FormApplication { /** * The current Roll - * @param {Roll} roll + * @param {RollL5r5e} roll */ roll = null; diff --git a/system/scripts/dice/roll.js b/system/scripts/dice/roll.js index a2d6b47..d3eefe8 100644 --- a/system/scripts/dice/roll.js +++ b/system/scripts/dice/roll.js @@ -336,10 +336,16 @@ export class RollL5r5e extends Roll { roll.l5r5e = duplicate(data.l5r5e); // get real Actor object - if (data.l5r5e.actor && !(data.l5r5e.actor instanceof game.l5r5e.ActorL5r5e)) { - const actor = game.actors.get(data.l5r5e.actor.id); - if (actor) { - roll.l5r5e.actor = actor; + if (data.l5r5e.actor) { + if (data.l5r5e.actor instanceof game.l5r5e.ActorL5r5e) { + // duplicate break the object, relink it + roll.l5r5e.actor = data.l5r5e.actor; + } else { + // only id, get the object + const actor = game.actors.get(data.l5r5e.actor.id); + if (actor) { + roll.l5r5e.actor = actor; + } } } diff --git a/system/templates/actors/character-sheet.html b/system/templates/actors/character-sheet.html index 9b1a521..ab3d658 100644 --- a/system/templates/actors/character-sheet.html +++ b/system/templates/actors/character-sheet.html @@ -62,7 +62,10 @@ - {{> 'systems/l5r5e/templates/items/item/items.html' }} +
{{!-- Experience Tab --}} diff --git a/system/templates/actors/npc-sheet.html b/system/templates/actors/npc-sheet.html index 23b81fe..1475828 100644 --- a/system/templates/actors/npc-sheet.html +++ b/system/templates/actors/npc-sheet.html @@ -28,9 +28,15 @@ {{> 'systems/l5r5e/templates/actors/npc/narrative.html' }}