Split Items by category in actor sheet (pc & npc) for better readability

Fix actor fromData
This commit is contained in:
Vlyan
2021-02-13 14:31:12 +01:00
parent db5d5b62aa
commit cb0696f662
9 changed files with 87 additions and 38 deletions

View File

@@ -19,7 +19,8 @@
- Added confirm dialog on item's deletion (Hold "ctrl" on the click, if you want to bypass it) - 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 "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 - 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 ## 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 - Added compendiums (Thanks to Stéfano Fara for the English version !) Partial for French as PoW and CR are not translated yet

View File

@@ -32,14 +32,17 @@ export class BaseSheetL5r5e extends ActorSheet {
return a.name.localeCompare(b.name); return a.name.localeCompare(b.name);
}); });
// Split techniques by types // Split Techniques by types
sheetData.data.splitTechniquesList = this._splitTechniques(sheetData); sheetData.data.splitTechniquesList = this._splitTechniques(sheetData);
// Split Items by types
sheetData.data.splitItemsList = this._splitItems(sheetData);
return sheetData; return sheetData;
} }
/** /**
* Split techniques by types for better readability * Split Techniques by types for better readability
* @private * @private
*/ */
_splitTechniques(sheetData) { _splitTechniques(sheetData) {
@@ -73,12 +76,32 @@ export class BaseSheetL5r5e extends ActorSheet {
sheetData.data.techniques["mastery_ability"] = out["mastery_ability"].length === 0; sheetData.data.techniques["mastery_ability"] = out["mastery_ability"].length === 0;
// Always display "school_ability", but display "mastery_ability" only if rank >= 5 // 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"]; delete out["mastery_ability"];
} }
return out; 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 * Return a light sheet if in "limited" state
* @override * @override
@@ -311,13 +334,23 @@ export class BaseSheetL5r5e extends ActorSheet {
item.data.data.bought_at_rank = this.actor.data.data.identity.school_rank; item.data.data.bought_at_rank = this.actor.data.data.identity.school_rank;
} }
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 // If technique, select the current type
if (item.data.type === "technique") {
const techType = $(event.currentTarget).data("tech-type"); const techType = $(event.currentTarget).data("tech-type");
if ([...CONFIG.l5r5e.techniques, ...CONFIG.l5r5e.techniques_school].includes(techType)) { if ([...CONFIG.l5r5e.techniques, ...CONFIG.l5r5e.techniques_school].includes(techType)) {
item.data.data.technique_type = techType; item.data.data.technique_type = techType;
item.data.img = `${CONFIG.l5r5e.paths.assets}/icons/techs/${techType}.svg`; item.data.img = `${CONFIG.l5r5e.paths.assets}/icons/techs/${techType}.svg`;
} }
break;
}
} }
item.sheet.render(true); item.sheet.render(true);

View File

@@ -23,7 +23,7 @@ export class RollnKeepDialog extends FormApplication {
/** /**
* The current Roll * The current Roll
* @param {Roll} roll * @param {RollL5r5e} roll
*/ */
roll = null; roll = null;

View File

@@ -336,12 +336,18 @@ export class RollL5r5e extends Roll {
roll.l5r5e = duplicate(data.l5r5e); roll.l5r5e = duplicate(data.l5r5e);
// get real Actor object // get real Actor object
if (data.l5r5e.actor && !(data.l5r5e.actor instanceof game.l5r5e.ActorL5r5e)) { 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); const actor = game.actors.get(data.l5r5e.actor.id);
if (actor) { if (actor) {
roll.l5r5e.actor = actor; roll.l5r5e.actor = actor;
} }
} }
}
return roll; return roll;
} }

View File

@@ -62,7 +62,10 @@
<input name="data.money.zeni" type="number" value="{{actor.data.money.zeni}}" data-dtype="Number" min="0" placeholder="0"/> <input name="data.money.zeni" type="number" value="{{actor.data.money.zeni}}" data-dtype="Number" min="0" placeholder="0"/>
</label> </label>
</fieldset> </fieldset>
<fieldset class="items-wrapper">
<legend>{{localize 'l5r5e.equipment' }}</legend>
{{> 'systems/l5r5e/templates/items/item/items.html' }} {{> 'systems/l5r5e/templates/items/item/items.html' }}
</fieldset>
</article> </article>
{{!-- Experience Tab --}} {{!-- Experience Tab --}}

View File

@@ -28,9 +28,15 @@
{{> 'systems/l5r5e/templates/actors/npc/narrative.html' }} {{> 'systems/l5r5e/templates/actors/npc/narrative.html' }}
</article> </article>
<article> <article>
<fieldset class="items-wrapper">
<legend>{{localize 'l5r5e.armors.equipped' }}</legend>
{{> 'systems/l5r5e/templates/items/weapon/weapons.html' }} {{> 'systems/l5r5e/templates/items/weapon/weapons.html' }}
{{> 'systems/l5r5e/templates/items/armor/armors.html' }} {{> 'systems/l5r5e/templates/items/armor/armors.html' }}
</fieldset>
<fieldset class="items-wrapper">
<legend>{{localize 'l5r5e.equipment' }}</legend>
{{> 'systems/l5r5e/templates/items/item/items.html' }} {{> 'systems/l5r5e/templates/items/item/items.html' }}
</fieldset>
</article> </article>
<article> <article>
{{> 'systems/l5r5e/templates/actors/npc/techniques.html' }} {{> 'systems/l5r5e/templates/actors/npc/techniques.html' }}

View File

@@ -1,8 +1,8 @@
<fieldset class="armors-content"> <fieldset class="armors-content">
<legend class="section-header"> <legend class="section-header">
{{ localize 'l5r5e.armors.title' }} {{localize 'l5r5e.armors.title'}}
{{#if editable}} {{#if editable}}
<a data-item-type="armor" class="armor-control item-add" title="{{ localize 'l5r5e.global.add'}}"><i class="fas fa-plus"></i></a> <a data-item-type="armor" data-item-eqquiped="true" class="armor-control item-add" title="{{localize 'l5r5e.global.add'}}"><i class="fas fa-plus"></i></a>
{{/if}} {{/if}}
</legend> </legend>
<ul class="item-list"> <ul class="item-list">

View File

@@ -1,15 +1,15 @@
<fieldset class="items-content"> {{#each data.splitItemsList as |cat type|}}
<fieldset class="items-content">
<legend> <legend>
{{ localize 'l5r5e.equipment' }} {{localize (localize 'l5r5e.{type}s.title' type=type) }}
{{#if editable}} {{#if ../editable}}
<a data-item-type="item" class="item-control item-add" title="{{ localize 'l5r5e.global.add'}}"><i class="fas fa-plus"></i></a> <a data-item-type="{{type}}" class="item-control item-add" title="{{ localize 'l5r5e.global.add'}}"><i class="fas fa-plus"></i></a>
{{/if}} {{/if}}
</legend> </legend>
<ul class="item-list"> <ul class="item-list">
{{#each actor.items as |item id|}} {{#each cat as |item id|}}
{{#ifCond '["item", "armor", "weapon"]' 'includes' item.type}} {{> 'systems/l5r5e/templates/items/item/item-entry.html' item=item id=id editable=../../editable }}
{{> 'systems/l5r5e/templates/items/item/item-entry.html' item=item id=id editable=../editable }}
{{/ifCond}}
{{/each}} {{/each}}
</ul> </ul>
</fieldset> </fieldset>
{{/each}}

View File

@@ -1,8 +1,8 @@
<fieldset class="weapons-content"> <fieldset class="weapons-content">
<legend class="section-header"> <legend class="section-header">
{{ localize 'l5r5e.weapons.title' }} {{localize 'l5r5e.weapons.title'}}
{{#if editable}} {{#if editable}}
<a data-item-type="weapon" class="weapon-control item-add" title="{{ localize 'l5r5e.global.add'}}"><i class="fas fa-plus"></i></a> <a data-item-type="weapon" data-item-eqquiped="true" class="weapon-control item-add" title="{{localize 'l5r5e.global.add'}}"><i class="fas fa-plus"></i></a>
{{/if}} {{/if}}
</legend> </legend>
<ul class="item-list"> <ul class="item-list">