Some check on actor types

This commit is contained in:
Vlyan
2021-10-06 19:01:17 +02:00
parent 2ca33fa104
commit 967b2c7383
7 changed files with 270 additions and 8 deletions

View File

@@ -254,6 +254,10 @@ export class ActorL5r5e extends Actor {
* @return {boolean} * @return {boolean}
*/ */
get isPrepared() { get isPrepared() {
if (!["character", "npc"].includes(this.data.type)) {
return false;
}
const cfg = { const cfg = {
character: game.settings.get("l5r5e", "initiative-prepared-character"), character: game.settings.get("l5r5e", "initiative-prepared-character"),
adversary: game.settings.get("l5r5e", "initiative-prepared-adversary"), adversary: game.settings.get("l5r5e", "initiative-prepared-adversary"),

View File

@@ -39,6 +39,11 @@ export class CombatL5r5e extends Combat {
for (const combatantId of ids) { for (const combatantId of ids) {
const combatant = game.combat.combatants.find((c) => c.id === combatantId); const combatant = game.combat.combatants.find((c) => c.id === combatantId);
// Skip non character types (army)
if (!["character", "npc"].includes(combatant.actor.data.type)) {
continue;
}
// Skip if combatant already have a initiative value // Skip if combatant already have a initiative value
if (!messageOptions.rerollInitiative && (!combatant || !combatant.actor)) { if (!messageOptions.rerollInitiative && (!combatant || !combatant.actor)) {
return; return;

View File

@@ -168,12 +168,18 @@ export class GmMonitor extends FormApplication {
return; return;
} }
const actor = game.actors.filter((e) => e.id === data.id); const actor = game.actors.find((e) => e.id === data.id);
if (!actor) { if (!actor) {
return; return;
} }
this.object.actors.push(actor[0]); // No armies allowed !
if (actor.data.type === "army") {
console.log(`L5R5E | Armies are not supported !`);
return;
}
this.object.actors.push(actor);
return this._saveActorsIds(); return this._saveActorsIds();
} }

View File

@@ -195,6 +195,12 @@ export class GmToolbox extends FormApplication {
const type = $(event.currentTarget).data("type"); const type = $(event.currentTarget).data("type");
for await (const actor of game.actors.contents) { for await (const actor of game.actors.contents) {
// Only characters types
if (!["character", "npc"].includes(actor.data.type)) {
continue;
}
// Manage left/right button
if (!isAll && (actor.data.type !== "character" || !actor.hasPlayerOwner)) { if (!isAll && (actor.data.type !== "character" || !actor.hasPlayerOwner)) {
continue; continue;
} }

View File

@@ -43,21 +43,22 @@ export const RegisterHandlebars = function () {
/* ------------------------------------ */ /* ------------------------------------ */
/* Utility */ /* Utility */
/* ------------------------------------ */ /* ------------------------------------ */
/** // Json - Display a object in textarea (for debug)
* Json - Display a object in textarea (for debug)
*/
Handlebars.registerHelper("json", function (...objects) { Handlebars.registerHelper("json", function (...objects) {
objects.pop(); // remove this function call objects.pop(); // remove this function call
return new Handlebars.SafeString(objects.map((e) => `<textarea>${JSON.stringify(e)}</textarea>`)); return new Handlebars.SafeString(objects.map((e) => `<textarea>${JSON.stringify(e)}</textarea>`));
}); });
/** // Add props "checked" if a and b are equal ({{radioChecked a b}}
* Add props "checked" if a and b are equal ({{radioChecked a b}}
*/
Handlebars.registerHelper("radioChecked", function (a, b) { Handlebars.registerHelper("radioChecked", function (a, b) {
return a === b ? new Handlebars.SafeString('checked="checked"') : ""; return a === b ? new Handlebars.SafeString('checked="checked"') : "";
}); });
// Add a setter
Handlebars.registerHelper("setVar", function (varName, varValue, options) {
options.data.root[varName] = varValue;
});
/** /**
* Utility conditional, usable in nested expression * Utility conditional, usable in nested expression
* {{#ifCond (ifCond advancement.type '==' 'technique') '||' (ifCond item.data.technique_type '==' 'kata')}} * {{#ifCond (ifCond advancement.type '==' 'technique') '||' (ifCond item.data.technique_type '==' 'kata')}}

View File

@@ -40,24 +40,31 @@ export const PreloadTemplates = async function () {
`${tpl}items/armor/armor-sheet.html`, `${tpl}items/armor/armor-sheet.html`,
`${tpl}items/bond/bond-entry.html`, `${tpl}items/bond/bond-entry.html`,
`${tpl}items/bond/bond-sheet.html`, `${tpl}items/bond/bond-sheet.html`,
`${tpl}items/bond/bond-text.html`,
`${tpl}items/item/items.html`, `${tpl}items/item/items.html`,
`${tpl}items/item/item-entry.html`, `${tpl}items/item/item-entry.html`,
`${tpl}items/item/item-value.html`, `${tpl}items/item/item-value.html`,
`${tpl}items/item/item-sheet.html`, `${tpl}items/item/item-sheet.html`,
`${tpl}items/item/item-infos.html`, `${tpl}items/item/item-infos.html`,
`${tpl}items/item/item-text.html`,
`${tpl}items/item-pattern/item-pattern-entry.html`, `${tpl}items/item-pattern/item-pattern-entry.html`,
`${tpl}items/item-pattern/item-pattern-sheet.html`, `${tpl}items/item-pattern/item-pattern-sheet.html`,
`${tpl}items/item-pattern/item-pattern-text.html`,
`${tpl}items/peculiarity/peculiarity-entry.html`, `${tpl}items/peculiarity/peculiarity-entry.html`,
`${tpl}items/peculiarity/peculiarity-sheet.html`, `${tpl}items/peculiarity/peculiarity-sheet.html`,
`${tpl}items/peculiarity/peculiarity-text.html`,
`${tpl}items/property/properties.html`, `${tpl}items/property/properties.html`,
`${tpl}items/property/property-entry.html`, `${tpl}items/property/property-entry.html`,
`${tpl}items/property/property-sheet.html`, `${tpl}items/property/property-sheet.html`,
`${tpl}items/signature-scroll/signature-scroll-entry.html`, `${tpl}items/signature-scroll/signature-scroll-entry.html`,
`${tpl}items/signature-scroll/signature-scroll-sheet.html`, `${tpl}items/signature-scroll/signature-scroll-sheet.html`,
`${tpl}items/signature-scroll/signature-scroll-text.html`,
`${tpl}items/technique/technique-entry.html`, `${tpl}items/technique/technique-entry.html`,
`${tpl}items/technique/technique-sheet.html`, `${tpl}items/technique/technique-sheet.html`,
`${tpl}items/technique/technique-text.html`,
`${tpl}items/title/title-entry.html`, `${tpl}items/title/title-entry.html`,
`${tpl}items/title/title-sheet.html`, `${tpl}items/title/title-sheet.html`,
`${tpl}items/title/title-text.html`,
`${tpl}items/weapon/weapons.html`, `${tpl}items/weapon/weapons.html`,
`${tpl}items/weapon/weapon-entry.html`, `${tpl}items/weapon/weapon-entry.html`,
`${tpl}items/weapon/weapon-sheet.html`, `${tpl}items/weapon/weapon-sheet.html`,

View File

@@ -0,0 +1,233 @@
<div class="{{cssClass}}" data-actor-id="{{data._id}}">
<header class="card-header">
<h2 class="item-name">
{{data.name}}
</h2>
</header>
<section class="sheet-body">
{{#if data.img}}<p><img src="{{data.img}}" title="{{data.name}}" /></p>{{/if}}
{{!-- Sheet Header --}}
<ul>
{{!-- Identity --}}
<li>{{#ifCond data.data.template '==' 'pow'}}{{localize 'l5r5e.region'}}{{else}}{{localize 'l5r5e.clan'}}{{/ifCond}} : {{data.data.identity.clan}}</li>
<li>{{#ifCond data.data.template '==' 'pow'}}{{localize 'l5r5e.upbringing'}}{{else}}{{localize 'l5r5e.family'}}{{/ifCond}} : {{data.data.identity.family}}</li>
<li>{{localize 'l5r5e.schoolrank'}} : {{data.data.identity.school_rank}}</li>
<li>{{localize 'l5r5e.school'}} : {{data.data.identity.school}}</li>
<li>{{localize 'l5r5e.roles'}} : {{data.data.identity.roles}}</li>
{{!-- Social --}}
<li>{{localize 'l5r5e.social.honor'}} : {{data.data.social.honor}}</li>
<li>{{localize 'l5r5e.social.glory'}} : {{data.data.social.glory}}</li>
<li>{{localize 'l5r5e.social.status'}} : {{data.data.social.status}}</li>
{{!-- Rings --}}
<li>{{localize 'l5r5e.rings.earth'}} : {{data.data.rings.earth}}</li>
<li>{{localize 'l5r5e.rings.air'}} : {{data.data.rings.air}}</li>
<li>{{localize 'l5r5e.rings.water'}} : {{data.data.rings.water}}</li>
<li>{{localize 'l5r5e.rings.fire'}} : {{data.data.rings.fire}}</li>
<li>{{localize 'l5r5e.rings.void'}} : {{data.data.rings.void}}</li>
{{!-- Attributes --}}
<li>{{localize 'l5r5e.attributes.endurance'}} : {{data.data.endurance}}</li>
<li>{{localize 'l5r5e.attributes.composure'}} : {{data.data.composure}}</li>
<li>{{localize 'l5r5e.attributes.focus'}} : {{data.data.focus}}</li>
<li>{{localize 'l5r5e.attributes.vigilance'}} : {{data.data.vigilance}}</li>
<li>{{localize 'l5r5e.attributes.voidpoints'}} : {{data.data.void_points.max}}</li>
{{!-- Narrative : Social --}}
<li>{{localize 'l5r5e.social.ninjo'}} : {{data.data.social.ninjo}}</li>
<li>{{#ifCond data.data.template '==' 'pow'}}{{localize 'l5r5e.social.past'}}{{else}}{{localize 'l5r5e.social.giri'}}{{/ifCond}} : {{data.data.social.giri}}</li>
<li>{{localize 'l5r5e.social.bushido_tenets.paramount'}} : {{data.data.social.bushido_tenets.paramount}}</li>
<li>{{localize 'l5r5e.social.bushido_tenets.less_significant'}} : {{data.data.social.bushido_tenets.less_significant}}</li>
<li>{{localize 'l5r5e.description' }} : {{{data.data.description}}}</li>
<li>{{localize 'l5r5e.notes' }} : {{{data.data.notes}}}</li>
</ul>
{{!-- a faire : Spé Skill/Ecoles pour les pnj --}}
{{!-- Skills Tab : Skills --}}
<h2>{{localize 'l5r5e.skills.title'}}</h2>
<ul>
{{#each data.data.skills as |category categoryId|}}
<li>
<strong>{{localizeSkill categoryId 'title'}}</strong>
<ul>
{{#each category as |skillValue skillId|}}
<li>{{localizeSkill categoryId skillId}} : {{skillValue}}</li>
{{/each}}
</ul>
</li>
{{/each}}
</ul>
{{!-- Skills Tab : Techniques --}}
<h2>{{localize 'l5r5e.techniques.title'}}</h2>
<ul>
{{#each data.splitTechniquesList as |list techName|}}
<li>
<strong>{{localize (localize 'l5r5e.techniques.{techName}' techName=techName) }}</strong>
<ul>
{{#each list as |technique|}}
<li>
{{#ifCond techName '==' 'title_ability'}}
{{> 'systems/l5r5e/templates/items/title/title-text.html' data=technique editable=../../options.editable}}
{{else}}
{{> 'systems/l5r5e/templates/items/technique/technique-text.html' data=technique editable=../../options.editable}}
{{/ifCond}}
</li>
{{/each}}
</ul>
</li>
{{/each}}
</ul>
{{!-- Skills Tab : Signature Scrolls --}}
<h2>{{localize 'l5r5e.advancements.signature_scroll' }}</h2>
<ul>
{{#each actor.items as |scroll|}}
{{#ifCond scroll.data.type '==' 'signature_scroll'}}
<li>{{> 'systems/l5r5e/templates/items/signature-scroll/signature-scroll-text.html' data=scroll.data editable=../options.editable}}</li>
{{/ifCond}}
{{/each}}
</ul>
{{!-- Narrative : Advantages --}}
<h2>{{localize 'l5r5e.social.advantages'}}</h2>
<ul>
{{#each data.items as |item|}}
{{#ifCond '["distinction","passion"]' 'includes' item.data.peculiarity_type}}
<li>{{> 'systems/l5r5e/templates/items/peculiarity/peculiarity-text.html' data=item editable=../options.editable}}</li>
{{/ifCond}}
{{/each}}
</ul>
{{!-- Narrative : Disadvantages --}}
<h2>{{localize 'l5r5e.social.disadvantages'}}</h2>
<ul>
{{#each data.items as |item|}}
{{#ifCond '["adversity","anxiety"]' 'includes' item.data.peculiarity_type}}
<li>{{> 'systems/l5r5e/templates/items/peculiarity/peculiarity-text.html' data=item editable=../options.editable}}</li>
{{/ifCond}}
{{/each}}
</ul>
{{!-- Narrative : Bonds --}}
<h2>{{localize 'l5r5e.social.bonds'}}</h2>
<ul>
{{#each data.items as |bond|}}
{{#ifCond bond.type '==' 'bond'}}
<li>{{> 'systems/l5r5e/templates/items/bond/bond-text.html' data=bond editable=../options.editable}}</li>
{{/ifCond}}
{{/each}}
</ul>
{{!-- Inventory Tab --}}
{{!-- items list --}}
<h2>{{localize 'l5r5e.equipment'}}</h2>
<ul>
<li>{{localize 'l5r5e.money.title'}} : {{data.data.money.koku}} {{localize 'l5r5e.money.koku'}} / {{data.data.money.bu}} {{localize 'l5r5e.money.bu'}} / {{data.data.money.zeni}} {{localize 'l5r5e.money.zeni'}}</li>
{{#each data.splitItemsList as |cat type|}}
<li>
<strong>{{localize (localize 'l5r5e.{type}s.title' type=type)}} ({{cat.length}})</strong>
<ul>
{{#each cat as |item|}}
<li>{{> 'systems/l5r5e/templates/items/item/item-text.html' data=item editable=../../options.editable}}</li>
{{/each}}
</ul>
</li>
{{/each}}
</ul>
{{!-- item patterns list --}}
<h2>{{localize 'l5r5e.advancements.item_pattern'}}</h2>
<ul>
{{#each actor.items as |pattern|}}
{{#ifCond pattern.data.type '==' 'item_pattern'}}
{{!-- json pattern.data --}}
{{!-- voir pkoi : data.linkedProperty.name --}}
<li>{{> 'systems/l5r5e/templates/items/item-pattern/item-pattern-text.html' data=pattern.data editable=../options.editable}}</li>
{{/ifCond}}
{{/each}}
</ul>
{{!-- Experience Tab --}}
<h2>{{localize 'l5r5e.experience'}}</h2>
<ul>
<li>{{localize 'l5r5e.advancements.total'}} : {{data.data.xp_total}}</li>
<li>{{localize 'l5r5e.advancements.spent'}} : {{data.data.xp_spent}}</li>
<li>{{localize 'l5r5e.advancements.saved'}} : {{data.data.xp_saved}}</li>
</ul>
{{!-- School progression --}}
<h2>{{#if data.data.identity.school_curriculum_journal.name}}{{data.data.identity.school_curriculum_journal.name}}{{else}}{{localize 'l5r5e.school'}}{{/if}}</h2>
<table>
<tr>
<th>{{localize 'l5r5e.name'}}</th>
<th>{{localize 'l5r5e.school'}}</th>
<th>{{localize 'l5r5e.advancements.spent'}}</th>
<th>{{localize 'l5r5e.rank'}}</th>
</tr>
{{#each data.advancementsListByRank as |rankObject|}}
<tr><th colspan="4">{{localize 'l5r5e.rank'}} {{rankObject.rank}}</th></tr>
{{#each rankObject.list as |advancement|}}
<tr>
<td>{{advancement.name}}</td>
<td>{{#if advancement.data.in_curriculum}}✓</i>{{/if}}</td>
<td>{{advancement.data.xp_used}}</td>
<td>{{advancement.data.rank}}</td>
</tr>
{{/each}}
{{/each}}
</table>
{{!-- Others progression (does not count in school xp) --}}
{{#if data.advancementsOthers}}
<h2>{{localize 'l5r5e.advancements.title'}}</h2>
<table>
<tr>
<th>{{localize 'l5r5e.name'}}</th>
<th>{{localize 'l5r5e.advancements.spent'}}</th>
<th>{{localize 'l5r5e.rank'}}</th>
</tr>
{{#each data.advancementsOthers as |advancement|}}
<tr>
<td>{{advancement.name}}</td>
<td>{{advancement.data.xp_used}}</td>
<td>{{advancement.data.rank}}</td>
</tr>
{{/each}}
</table>
{{/if}}
{{!-- 20Q --}}
{{#ifCond data.data.twenty_questions.template '==' 'pow'}}
{{setVar "suffix" "pow"}}
{{else}}
{{setVar "suffix" ""}}
{{/ifCond}}
<h2>{{localize 'l5r5e.twenty_questions.title'}}</h2>
<ul>
<li>{{localize (localize 'l5r5e.twenty_questions.part2.q4{suffix}' suffix=suffix)}} : {{data.data.twenty_questions.step4.stand_out}}</li>
<li>{{localize (localize 'l5r5e.twenty_questions.part3.q7{suffix}' suffix=suffix)}} : {{data.data.twenty_questions.step7.clan_relations}}</li>
<li>{{localize (localize 'l5r5e.twenty_questions.part3.q8{suffix}' suffix=suffix)}} : {{data.data.twenty_questions.step8.bushido}}</li>
<li>{{localize (localize 'l5r5e.twenty_questions.part4.q9{suffix}' suffix=suffix)}} : {{data.data.twenty_questions.step9.success}}</li>
<li>{{localize (localize 'l5r5e.twenty_questions.part4.q10{suffix}' suffix=suffix)}} : {{data.data.twenty_questions.step10.difficulty}}</li>
<li>{{localize (localize 'l5r5e.twenty_questions.part4.q11{suffix}' suffix=suffix)}} : {{data.data.twenty_questions.step11.calms}}</li>
<li>{{localize (localize 'l5r5e.twenty_questions.part4.q12{suffix}' suffix=suffix)}} : {{data.data.twenty_questions.step12.worries}}</li>
<li>{{localize (localize 'l5r5e.twenty_questions.part4.q13{suffix}' suffix=suffix)}} : {{data.data.twenty_questions.step13.most_learn}}</li>
<li>{{localize (localize 'l5r5e.twenty_questions.part5.q14{suffix}' suffix=suffix)}} : {{data.data.twenty_questions.step14.first_sight}}</li>
<li>{{localize (localize 'l5r5e.twenty_questions.part5.q15{suffix}' suffix=suffix)}} : {{data.data.twenty_questions.step15.stress}}</li>
<li>{{localize (localize 'l5r5e.twenty_questions.part5.q16{suffix}' suffix=suffix)}} : {{data.data.twenty_questions.step16.relations}}</li>
<li>{{localize (localize 'l5r5e.twenty_questions.part6.q17{suffix}' suffix=suffix)}} : {{data.data.twenty_questions.step17.parents_pov}}</li>
<li>{{localize (localize 'l5r5e.twenty_questions.part6.q18{suffix}' suffix=suffix)}} : {{data.data.twenty_questions.step18.heritage_name}}</li>
<li>{{localize (localize 'l5r5e.twenty_questions.part7.q20{suffix}' suffix=suffix)}} : {{data.data.twenty_questions.step20.death}}</li>
</ul>
</section>
</div>