Added cancelled properties in text for props and some fixes
This commit is contained in:
@@ -75,18 +75,22 @@ export class HelpersL5r5e {
|
||||
return null;
|
||||
}
|
||||
const data = JSON.parse(json);
|
||||
if (!data) {
|
||||
return null;
|
||||
}
|
||||
return await HelpersL5r5e.getObjectGameOrPack(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the object from Game or Pack by his ID, or null if not found
|
||||
* @param {number} id
|
||||
* @param {string} type
|
||||
* @param {string|null} data
|
||||
* @param {string|null} pack
|
||||
* @param {string} id
|
||||
* @param {string} type Type (Item, JournalEntry...)
|
||||
* @param {any[]|null} data Plain data
|
||||
* @param {string|null} pack Pack name
|
||||
* @param {string|null} parentId Used to avoid an infinite loop in properties if set
|
||||
* @return {Promise<null>}
|
||||
*/
|
||||
static async getObjectGameOrPack({ id, type, data = null, pack = null }) {
|
||||
static async getObjectGameOrPack({ id, type, data = null, pack = null, parentId = null }) {
|
||||
let document = null;
|
||||
|
||||
try {
|
||||
@@ -105,9 +109,9 @@ export class HelpersL5r5e {
|
||||
}
|
||||
|
||||
if (pack) {
|
||||
const data = await game.packs.get(pack).getDocument(id);
|
||||
if (data) {
|
||||
document = HelpersL5r5e.createDocumentFromCompendium({ type, data });
|
||||
const tmpData = await game.packs.get(pack).getDocument(id);
|
||||
if (tmpData) {
|
||||
document = HelpersL5r5e.createDocumentFromCompendium({ type, data: tmpData });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -126,9 +130,9 @@ export class HelpersL5r5e {
|
||||
continue;
|
||||
}
|
||||
|
||||
const data = await comp.getDocument(id);
|
||||
if (data) {
|
||||
document = HelpersL5r5e.createDocumentFromCompendium({ type, data });
|
||||
const tmpData = await comp.getDocument(id);
|
||||
if (tmpData) {
|
||||
document = HelpersL5r5e.createDocumentFromCompendium({ type, data: tmpData });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -141,13 +145,13 @@ export class HelpersL5r5e {
|
||||
}
|
||||
|
||||
// Care to infinite loop in properties
|
||||
if (document.type !== "property") {
|
||||
if (!parentId) {
|
||||
await HelpersL5r5e.refreshItemProperties(document);
|
||||
}
|
||||
document.prepareData();
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn(err);
|
||||
console.warn("L5R5E | ", err);
|
||||
}
|
||||
return document;
|
||||
}
|
||||
@@ -195,7 +199,11 @@ export class HelpersL5r5e {
|
||||
if (document.data?.data?.properties && typeof Babele !== "undefined") {
|
||||
document.data.data.properties = await Promise.all(
|
||||
document.data.data.properties.map(async (property) => {
|
||||
const gameProp = await HelpersL5r5e.getObjectGameOrPack({ id: property.id, type: "Item" });
|
||||
const gameProp = await HelpersL5r5e.getObjectGameOrPack({
|
||||
id: property.id,
|
||||
type: "Item",
|
||||
parentId: document.data?._id || 1,
|
||||
});
|
||||
if (gameProp) {
|
||||
return { id: gameProp.id, name: gameProp.name };
|
||||
} else {
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
{{!-- Narrative Tab --}}
|
||||
<article class="tab narrative" data-group="primary" data-tab="narrative">
|
||||
{{> 'systems/l5r5e/templates/actors/character/narrative.html'}}
|
||||
{{> 'systems/l5r5e/templates/actors/npc/narrative.html'}}
|
||||
</article>
|
||||
|
||||
{{!-- Conflict Tab --}}
|
||||
|
||||
@@ -1,46 +1,88 @@
|
||||
<fieldset class="narrative-content">
|
||||
<legend class="text-block-header">
|
||||
{{localize 'l5r5e.social.npc.advantages'}}
|
||||
{{#if options.editable}}
|
||||
<a data-item-type="peculiarity" class="peculiarity-control item-add" title="{{localize 'l5r5e.global.add'}}"><i class="fas fa-plus"></i></a>
|
||||
{{/if}}
|
||||
</legend>
|
||||
<ul class="item-list">
|
||||
{{#each actor.items as |item id|}}
|
||||
{{#ifCond '["distinction","passion"]' 'includes' item.data.data.peculiarity_type}}
|
||||
{{> 'systems/l5r5e/templates/items/peculiarity/peculiarity-entry.html' peculiarity=item id=id editable=../options.editable}}
|
||||
{{/ifCond}}
|
||||
{{/each}}
|
||||
</ul>
|
||||
</fieldset>
|
||||
<fieldset class="narrative-content">
|
||||
<legend class="text-block-header">
|
||||
{{localize 'l5r5e.social.npc.disadvantages'}}
|
||||
{{#if options.editable}}
|
||||
<a data-item-type="peculiarity" class="peculiarity-control item-add" title="{{localize 'l5r5e.global.add'}}"><i class="fas fa-plus"></i></a>
|
||||
{{/if}}
|
||||
</legend>
|
||||
<ul class="item-list">
|
||||
{{#each actor.items as |item id|}}
|
||||
{{#ifCond '["adversity","anxiety"]' 'includes' item.data.data.peculiarity_type}}
|
||||
{{> 'systems/l5r5e/templates/items/peculiarity/peculiarity-entry.html' peculiarity=item id=id editable=../options.editable}}
|
||||
{{/ifCond}}
|
||||
{{/each}}
|
||||
</ul>
|
||||
</fieldset>
|
||||
{{!-- bonds --}}
|
||||
<fieldset>
|
||||
<legend class="text-block-header">
|
||||
{{localize 'l5r5e.social.bonds'}}
|
||||
{{#if options.editable}}
|
||||
<a data-item-type="bond" class="bond-control item-add" title="{{localize 'l5r5e.global.add'}}"><i class="fas fa-plus"></i></a>
|
||||
{{/if}}
|
||||
</legend>
|
||||
<ul class="item-list">
|
||||
{{#each actor.items as |bond id|}}
|
||||
{{#ifCond bond.data.type '==' 'bond'}}
|
||||
{{> 'systems/l5r5e/templates/items/bond/bond-entry.html' bond=bond id=id editable=../options.editable}}
|
||||
{{/ifCond}}
|
||||
{{/each}}
|
||||
</ul>
|
||||
</fieldset>
|
||||
<div class="narrative-content">
|
||||
{{!-- Ninjo/Giri --}}
|
||||
<fieldset>
|
||||
<legend class="text-block-header">{{localize 'l5r5e.social.title'}}</legend>
|
||||
<label class="attribute-label">
|
||||
{{localize 'l5r5e.social.ninjo'}}
|
||||
<textarea type="text" name="data.social.ninjo">{{data.data.social.ninjo}}</textarea>
|
||||
</label>
|
||||
<label class="attribute-label">
|
||||
{{localize 'l5r5e.social.giri'}} / {{localize 'l5r5e.social.past'}}
|
||||
<textarea type="text" name="data.social.giri">{{data.data.social.giri}}</textarea>
|
||||
</label>
|
||||
</fieldset>
|
||||
{{!-- Bushido Tenets --}}
|
||||
<fieldset>
|
||||
<legend class="text-block-header">{{localize 'l5r5e.social.bushido_tenets.title'}}</legend>
|
||||
<label class="attribute-label">
|
||||
{{localize 'l5r5e.social.bushido_tenets.paramount'}}
|
||||
<textarea type="text" name="data.social.bushido_tenets.paramount">{{data.data.social.bushido_tenets.paramount}}</textarea>
|
||||
</label>
|
||||
<label class="attribute-label">
|
||||
{{localize 'l5r5e.social.bushido_tenets.less_significant'}}
|
||||
<textarea type="text" name="data.social.bushido_tenets.less_significant">{{data.data.social.bushido_tenets.less_significant}}</textarea>
|
||||
</label>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="narrative-list">
|
||||
{{!-- Advantages --}}
|
||||
<fieldset>
|
||||
<legend class="text-block-header">
|
||||
{{localize 'l5r5e.social.advantages'}}
|
||||
{{#if options.editable}}
|
||||
<a data-item-type="peculiarity" class="peculiarity-control item-add" title="{{localize 'l5r5e.global.add'}}"><i class="fas fa-plus"></i></a>
|
||||
{{/if}}
|
||||
</legend>
|
||||
<ul class="item-list">
|
||||
{{#each actor.items as |item id|}}
|
||||
{{#ifCond '["distinction","passion"]' 'includes' item.data.data.peculiarity_type}}
|
||||
{{> 'systems/l5r5e/templates/items/peculiarity/peculiarity-entry.html' peculiarity=item id=id editable=../options.editable}}
|
||||
{{/ifCond}}
|
||||
{{/each}}
|
||||
</ul>
|
||||
</fieldset>
|
||||
{{!-- Disadvantages --}}
|
||||
<fieldset>
|
||||
<legend class="text-block-header">
|
||||
{{localize 'l5r5e.social.disadvantages'}}
|
||||
{{#if options.editable}}
|
||||
<a data-item-type="peculiarity" class="peculiarity-control item-add" title="{{localize 'l5r5e.global.add'}}"><i class="fas fa-plus"></i></a>
|
||||
{{/if}}
|
||||
</legend>
|
||||
<ul class="item-list">
|
||||
{{#each actor.items as |item id|}}
|
||||
{{#ifCond '["adversity","anxiety"]' 'includes' item.data.data.peculiarity_type}}
|
||||
{{> 'systems/l5r5e/templates/items/peculiarity/peculiarity-entry.html' peculiarity=item id=id editable=../options.editable}}
|
||||
{{/ifCond}}
|
||||
{{/each}}
|
||||
</ul>
|
||||
</fieldset>
|
||||
{{!-- Bonds --}}
|
||||
<fieldset>
|
||||
<legend class="text-block-header">
|
||||
{{localize 'l5r5e.social.bonds' }}
|
||||
{{#if options.editable}}
|
||||
<a data-item-type="bond" class="bond-control item-add" title="{{localize 'l5r5e.global.add'}}"><i class="fas fa-plus"></i></a>
|
||||
{{/if}}
|
||||
</legend>
|
||||
<ul class="item-list">
|
||||
{{#each actor.items as |bond id|}}
|
||||
{{#ifCond bond.data.type '==' 'bond'}}
|
||||
{{> 'systems/l5r5e/templates/items/bond/bond-entry.html' bond=bond id=id editable=../options.editable}}
|
||||
{{/ifCond}}
|
||||
{{/each}}
|
||||
</ul>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="narrative-fluff">
|
||||
{{!-- Description (public) --}}
|
||||
<fieldset class="narrative-description">
|
||||
<legend class="text-block-header">{{localize 'l5r5e.description' }}</legend>
|
||||
{{editor content=data.data.description target="data.description" button=true editable=options.editable}}
|
||||
</fieldset>
|
||||
{{!-- Notes (private) --}}
|
||||
<fieldset class="narrative-note">
|
||||
<legend class="text-block-header">{{localize 'l5r5e.notes' }}</legend>
|
||||
{{editor content=data.data.notes target="data.notes" button=true editable=options.editable}}
|
||||
</fieldset>
|
||||
</div>
|
||||
@@ -3,7 +3,11 @@
|
||||
<h2 class="item-name"><img src="{{data.img}}" title="{{data.name}}" width="36" height="36"/> {{data.name}}</h2>
|
||||
</header>
|
||||
<section class="sheet-body">
|
||||
{{!--cancelled properties--}}
|
||||
{{localize 'l5r5e.removed_properties'}} : {{#each data.data.properties as |property idx|}}{{#ifCond idx '>' 0}}, {{/ifCond}}{{property.name}}{{/each}}
|
||||
|
||||
{{!--item-infos--}}
|
||||
<br>
|
||||
{{localize 'l5r5e.description'}} : {{{data.data.description}}}
|
||||
<br>
|
||||
{{localize 'l5r5e.book_reference'}} : {{data.data.book_reference}}
|
||||
|
||||
Reference in New Issue
Block a user