From 967b2c73834855f45fe116f3e2dc7d5894adbb52 Mon Sep 17 00:00:00 2001 From: Vlyan Date: Wed, 6 Oct 2021 19:01:17 +0200 Subject: [PATCH] Some check on actor types --- system/scripts/actor.js | 4 + system/scripts/combat.js | 5 + system/scripts/gm/gm-monitor.js | 10 +- system/scripts/gm/gm-toolbox.js | 6 + system/scripts/handlebars.js | 13 +- system/scripts/preloadTemplates.js | 7 + system/templates/actors/actor-export.html | 233 ++++++++++++++++++++++ 7 files changed, 270 insertions(+), 8 deletions(-) create mode 100644 system/templates/actors/actor-export.html diff --git a/system/scripts/actor.js b/system/scripts/actor.js index 08708c0..ce612b8 100644 --- a/system/scripts/actor.js +++ b/system/scripts/actor.js @@ -254,6 +254,10 @@ export class ActorL5r5e extends Actor { * @return {boolean} */ get isPrepared() { + if (!["character", "npc"].includes(this.data.type)) { + return false; + } + const cfg = { character: game.settings.get("l5r5e", "initiative-prepared-character"), adversary: game.settings.get("l5r5e", "initiative-prepared-adversary"), diff --git a/system/scripts/combat.js b/system/scripts/combat.js index 37d1020..47aeeb8 100644 --- a/system/scripts/combat.js +++ b/system/scripts/combat.js @@ -39,6 +39,11 @@ export class CombatL5r5e extends Combat { for (const combatantId of ids) { 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 if (!messageOptions.rerollInitiative && (!combatant || !combatant.actor)) { return; diff --git a/system/scripts/gm/gm-monitor.js b/system/scripts/gm/gm-monitor.js index b69bd66..58b0ac5 100644 --- a/system/scripts/gm/gm-monitor.js +++ b/system/scripts/gm/gm-monitor.js @@ -168,12 +168,18 @@ export class GmMonitor extends FormApplication { return; } - const actor = game.actors.filter((e) => e.id === data.id); + const actor = game.actors.find((e) => e.id === data.id); if (!actor) { 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(); } diff --git a/system/scripts/gm/gm-toolbox.js b/system/scripts/gm/gm-toolbox.js index 46feaa7..e73c046 100644 --- a/system/scripts/gm/gm-toolbox.js +++ b/system/scripts/gm/gm-toolbox.js @@ -195,6 +195,12 @@ export class GmToolbox extends FormApplication { const type = $(event.currentTarget).data("type"); 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)) { continue; } diff --git a/system/scripts/handlebars.js b/system/scripts/handlebars.js index 6f05ee0..587d62f 100644 --- a/system/scripts/handlebars.js +++ b/system/scripts/handlebars.js @@ -43,21 +43,22 @@ export const RegisterHandlebars = function () { /* ------------------------------------ */ /* Utility */ /* ------------------------------------ */ - /** - * Json - Display a object in textarea (for debug) - */ + // Json - Display a object in textarea (for debug) Handlebars.registerHelper("json", function (...objects) { objects.pop(); // remove this function call return new Handlebars.SafeString(objects.map((e) => ``)); }); - /** - * 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) { 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 * {{#ifCond (ifCond advancement.type '==' 'technique') '||' (ifCond item.data.technique_type '==' 'kata')}} diff --git a/system/scripts/preloadTemplates.js b/system/scripts/preloadTemplates.js index 7d9a4b3..66ed359 100644 --- a/system/scripts/preloadTemplates.js +++ b/system/scripts/preloadTemplates.js @@ -40,24 +40,31 @@ export const PreloadTemplates = async function () { `${tpl}items/armor/armor-sheet.html`, `${tpl}items/bond/bond-entry.html`, `${tpl}items/bond/bond-sheet.html`, + `${tpl}items/bond/bond-text.html`, `${tpl}items/item/items.html`, `${tpl}items/item/item-entry.html`, `${tpl}items/item/item-value.html`, `${tpl}items/item/item-sheet.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-sheet.html`, + `${tpl}items/item-pattern/item-pattern-text.html`, `${tpl}items/peculiarity/peculiarity-entry.html`, `${tpl}items/peculiarity/peculiarity-sheet.html`, + `${tpl}items/peculiarity/peculiarity-text.html`, `${tpl}items/property/properties.html`, `${tpl}items/property/property-entry.html`, `${tpl}items/property/property-sheet.html`, `${tpl}items/signature-scroll/signature-scroll-entry.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-sheet.html`, + `${tpl}items/technique/technique-text.html`, `${tpl}items/title/title-entry.html`, `${tpl}items/title/title-sheet.html`, + `${tpl}items/title/title-text.html`, `${tpl}items/weapon/weapons.html`, `${tpl}items/weapon/weapon-entry.html`, `${tpl}items/weapon/weapon-sheet.html`, diff --git a/system/templates/actors/actor-export.html b/system/templates/actors/actor-export.html new file mode 100644 index 0000000..1867902 --- /dev/null +++ b/system/templates/actors/actor-export.html @@ -0,0 +1,233 @@ +
+
+

+ {{data.name}} +

+
+
+ {{#if data.img}}

{{/if}} + + {{!-- Sheet Header --}} +
    + {{!-- Identity --}} +
  • {{#ifCond data.data.template '==' 'pow'}}{{localize 'l5r5e.region'}}{{else}}{{localize 'l5r5e.clan'}}{{/ifCond}} : {{data.data.identity.clan}}
  • +
  • {{#ifCond data.data.template '==' 'pow'}}{{localize 'l5r5e.upbringing'}}{{else}}{{localize 'l5r5e.family'}}{{/ifCond}} : {{data.data.identity.family}}
  • +
  • {{localize 'l5r5e.schoolrank'}} : {{data.data.identity.school_rank}}
  • +
  • {{localize 'l5r5e.school'}} : {{data.data.identity.school}}
  • +
  • {{localize 'l5r5e.roles'}} : {{data.data.identity.roles}}
  • + + {{!-- Social --}} +
  • {{localize 'l5r5e.social.honor'}} : {{data.data.social.honor}}
  • +
  • {{localize 'l5r5e.social.glory'}} : {{data.data.social.glory}}
  • +
  • {{localize 'l5r5e.social.status'}} : {{data.data.social.status}}
  • + + {{!-- Rings --}} +
  • {{localize 'l5r5e.rings.earth'}} : {{data.data.rings.earth}}
  • +
  • {{localize 'l5r5e.rings.air'}} : {{data.data.rings.air}}
  • +
  • {{localize 'l5r5e.rings.water'}} : {{data.data.rings.water}}
  • +
  • {{localize 'l5r5e.rings.fire'}} : {{data.data.rings.fire}}
  • +
  • {{localize 'l5r5e.rings.void'}} : {{data.data.rings.void}}
  • + + {{!-- Attributes --}} +
  • {{localize 'l5r5e.attributes.endurance'}} : {{data.data.endurance}}
  • +
  • {{localize 'l5r5e.attributes.composure'}} : {{data.data.composure}}
  • +
  • {{localize 'l5r5e.attributes.focus'}} : {{data.data.focus}}
  • +
  • {{localize 'l5r5e.attributes.vigilance'}} : {{data.data.vigilance}}
  • +
  • {{localize 'l5r5e.attributes.voidpoints'}} : {{data.data.void_points.max}}
  • + + {{!-- Narrative : Social --}} +
  • {{localize 'l5r5e.social.ninjo'}} : {{data.data.social.ninjo}}
  • +
  • {{#ifCond data.data.template '==' 'pow'}}{{localize 'l5r5e.social.past'}}{{else}}{{localize 'l5r5e.social.giri'}}{{/ifCond}} : {{data.data.social.giri}}
  • +
  • {{localize 'l5r5e.social.bushido_tenets.paramount'}} : {{data.data.social.bushido_tenets.paramount}}
  • +
  • {{localize 'l5r5e.social.bushido_tenets.less_significant'}} : {{data.data.social.bushido_tenets.less_significant}}
  • +
  • {{localize 'l5r5e.description' }} : {{{data.data.description}}}
  • +
  • {{localize 'l5r5e.notes' }} : {{{data.data.notes}}}
  • +
+ +{{!-- a faire : Spé Skill/Ecoles pour les pnj --}} + {{!-- Skills Tab : Skills --}} +

{{localize 'l5r5e.skills.title'}}

+
    + {{#each data.data.skills as |category categoryId|}} +
  • + {{localizeSkill categoryId 'title'}} +
      + {{#each category as |skillValue skillId|}} +
    • {{localizeSkill categoryId skillId}} : {{skillValue}}
    • + {{/each}} +
    +
  • + {{/each}} +
+ + {{!-- Skills Tab : Techniques --}} +

{{localize 'l5r5e.techniques.title'}}

+
    + {{#each data.splitTechniquesList as |list techName|}} +
  • + {{localize (localize 'l5r5e.techniques.{techName}' techName=techName) }} +
      + {{#each list as |technique|}} +
    • + {{#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}} +
    • + {{/each}} +
    +
  • + {{/each}} +
+ + {{!-- Skills Tab : Signature Scrolls --}} +

{{localize 'l5r5e.advancements.signature_scroll' }}

+
    + {{#each actor.items as |scroll|}} + {{#ifCond scroll.data.type '==' 'signature_scroll'}} +
  • {{> 'systems/l5r5e/templates/items/signature-scroll/signature-scroll-text.html' data=scroll.data editable=../options.editable}}
  • + {{/ifCond}} + {{/each}} +
+ + + {{!-- Narrative : Advantages --}} +

{{localize 'l5r5e.social.advantages'}}

+
    + {{#each data.items as |item|}} + {{#ifCond '["distinction","passion"]' 'includes' item.data.peculiarity_type}} +
  • {{> 'systems/l5r5e/templates/items/peculiarity/peculiarity-text.html' data=item editable=../options.editable}}
  • + {{/ifCond}} + {{/each}} +
+ + {{!-- Narrative : Disadvantages --}} +

{{localize 'l5r5e.social.disadvantages'}}

+
    + {{#each data.items as |item|}} + {{#ifCond '["adversity","anxiety"]' 'includes' item.data.peculiarity_type}} +
  • {{> 'systems/l5r5e/templates/items/peculiarity/peculiarity-text.html' data=item editable=../options.editable}}
  • + {{/ifCond}} + {{/each}} +
+ + {{!-- Narrative : Bonds --}} +

{{localize 'l5r5e.social.bonds'}}

+
    + {{#each data.items as |bond|}} + {{#ifCond bond.type '==' 'bond'}} +
  • {{> 'systems/l5r5e/templates/items/bond/bond-text.html' data=bond editable=../options.editable}}
  • + {{/ifCond}} + {{/each}} +
+ + + {{!-- Inventory Tab --}} + {{!-- items list --}} +

{{localize 'l5r5e.equipment'}}

+
    +
  • {{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'}}
  • + {{#each data.splitItemsList as |cat type|}} +
  • + {{localize (localize 'l5r5e.{type}s.title' type=type)}} ({{cat.length}}) +
      + {{#each cat as |item|}} +
    • {{> 'systems/l5r5e/templates/items/item/item-text.html' data=item editable=../../options.editable}}
    • + {{/each}} +
    +
  • + {{/each}} +
+ + {{!-- item patterns list --}} +

{{localize 'l5r5e.advancements.item_pattern'}}

+
    + {{#each actor.items as |pattern|}} + {{#ifCond pattern.data.type '==' 'item_pattern'}} + +{{!-- json pattern.data --}} +{{!-- voir pkoi : data.linkedProperty.name --}} + +
  • {{> 'systems/l5r5e/templates/items/item-pattern/item-pattern-text.html' data=pattern.data editable=../options.editable}}
  • + {{/ifCond}} + {{/each}} +
+ + + {{!-- Experience Tab --}} +

{{localize 'l5r5e.experience'}}

+
    +
  • {{localize 'l5r5e.advancements.total'}} : {{data.data.xp_total}}
  • +
  • {{localize 'l5r5e.advancements.spent'}} : {{data.data.xp_spent}}
  • +
  • {{localize 'l5r5e.advancements.saved'}} : {{data.data.xp_saved}}
  • +
+ + {{!-- School progression --}} +

{{#if data.data.identity.school_curriculum_journal.name}}{{data.data.identity.school_curriculum_journal.name}}{{else}}{{localize 'l5r5e.school'}}{{/if}}

+ + + + + + + + {{#each data.advancementsListByRank as |rankObject|}} + + {{#each rankObject.list as |advancement|}} + + + + + + + {{/each}} + {{/each}} +
{{localize 'l5r5e.name'}}{{localize 'l5r5e.school'}}{{localize 'l5r5e.advancements.spent'}}{{localize 'l5r5e.rank'}}
{{localize 'l5r5e.rank'}} {{rankObject.rank}}
{{advancement.name}}{{#if advancement.data.in_curriculum}}✓{{/if}}{{advancement.data.xp_used}}{{advancement.data.rank}}
+ + {{!-- Others progression (does not count in school xp) --}} + {{#if data.advancementsOthers}} +

{{localize 'l5r5e.advancements.title'}}

+ + + + + + + {{#each data.advancementsOthers as |advancement|}} + + + + + + {{/each}} +
{{localize 'l5r5e.name'}}{{localize 'l5r5e.advancements.spent'}}{{localize 'l5r5e.rank'}}
{{advancement.name}}{{advancement.data.xp_used}}{{advancement.data.rank}}
+ {{/if}} + + + {{!-- 20Q --}} + {{#ifCond data.data.twenty_questions.template '==' 'pow'}} + {{setVar "suffix" "pow"}} + {{else}} + {{setVar "suffix" ""}} + {{/ifCond}} +

{{localize 'l5r5e.twenty_questions.title'}}

+
    +
  • {{localize (localize 'l5r5e.twenty_questions.part2.q4{suffix}' suffix=suffix)}} : {{data.data.twenty_questions.step4.stand_out}}
  • +
  • {{localize (localize 'l5r5e.twenty_questions.part3.q7{suffix}' suffix=suffix)}} : {{data.data.twenty_questions.step7.clan_relations}}
  • +
  • {{localize (localize 'l5r5e.twenty_questions.part3.q8{suffix}' suffix=suffix)}} : {{data.data.twenty_questions.step8.bushido}}
  • +
  • {{localize (localize 'l5r5e.twenty_questions.part4.q9{suffix}' suffix=suffix)}} : {{data.data.twenty_questions.step9.success}}
  • +
  • {{localize (localize 'l5r5e.twenty_questions.part4.q10{suffix}' suffix=suffix)}} : {{data.data.twenty_questions.step10.difficulty}}
  • +
  • {{localize (localize 'l5r5e.twenty_questions.part4.q11{suffix}' suffix=suffix)}} : {{data.data.twenty_questions.step11.calms}}
  • +
  • {{localize (localize 'l5r5e.twenty_questions.part4.q12{suffix}' suffix=suffix)}} : {{data.data.twenty_questions.step12.worries}}
  • +
  • {{localize (localize 'l5r5e.twenty_questions.part4.q13{suffix}' suffix=suffix)}} : {{data.data.twenty_questions.step13.most_learn}}
  • +
  • {{localize (localize 'l5r5e.twenty_questions.part5.q14{suffix}' suffix=suffix)}} : {{data.data.twenty_questions.step14.first_sight}}
  • +
  • {{localize (localize 'l5r5e.twenty_questions.part5.q15{suffix}' suffix=suffix)}} : {{data.data.twenty_questions.step15.stress}}
  • +
  • {{localize (localize 'l5r5e.twenty_questions.part5.q16{suffix}' suffix=suffix)}} : {{data.data.twenty_questions.step16.relations}}
  • +
  • {{localize (localize 'l5r5e.twenty_questions.part6.q17{suffix}' suffix=suffix)}} : {{data.data.twenty_questions.step17.parents_pov}}
  • +
  • {{localize (localize 'l5r5e.twenty_questions.part6.q18{suffix}' suffix=suffix)}} : {{data.data.twenty_questions.step18.heritage_name}}
  • +
  • {{localize (localize 'l5r5e.twenty_questions.part7.q20{suffix}' suffix=suffix)}} : {{data.data.twenty_questions.step20.death}}
  • +
+ +
+