From 109ce4f1922e8372fb91e99f15e51fa8f82fa76d Mon Sep 17 00:00:00 2001 From: sladecraven Date: Sat, 26 Nov 2022 11:05:41 +0100 Subject: [PATCH] Fix #28 - Spec selection --- modules/pegasus-create-char.js | 37 +++++++++++++++++++++++++++++++- templates/chat-create-actor.html | 13 +++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/modules/pegasus-create-char.js b/modules/pegasus-create-char.js index 32dfd32..b7359ef 100644 --- a/modules/pegasus-create-char.js +++ b/modules/pegasus-create-char.js @@ -191,11 +191,24 @@ export class PegasusActorCreate { this.nbPerks--; this.rolePerks = this.rolePerks.filter( item => item._id != itemId);//Remove selected perk if (this.nbPerks == 0 || this.rolePerks.length == 0) { - this.showCharacterEnd() + this.nbGlobalSpec = 5 + this.showGlobalSpec() } else { this.showRolePerks() } } + + if (step == 'select-global-spec') { + PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget)); + let spec = this.specs.find( item => item._id == itemId); + this.actor.addIncSpec(spec, 1) + this.nbGlobalSpec--; + if (this.nbGlobalSpec == 0 ) { + this.showCharacterEnd() + } else { + this.showGlobalSpec() + } + } } /* -------------------------------------------- */ @@ -373,6 +386,7 @@ export class PegasusActorCreate { this.renderChatMessage( formData) } + /* -------------------------------------------- */ async showRolePerks() { let formData = this.createFormData("select-role-perk") @@ -381,6 +395,27 @@ export class PegasusActorCreate { this.renderChatMessage( formData) } + /* -------------------------------------------- */ + async showGlobalSpec() { + let formData = this.createFormData("select-global-spec") + let excludedSpecs = this.actor.items.filter(it => it.type =="specialisation" && it.system.level >= 4) + formData.specs = [] + for( let spec of this.specs) { + let isOK = true + for (let excluded of excludedSpecs) { + if (excluded.name == spec.name) { + isOK = false + break + } + } + if (isOK) { + formData.specs.push(spec) + } + } + formData.specs.sort( function compare(a, b) { if (a.name < b.name) {return -1} else {return 1} } ) + this.renderChatMessage( formData ) + } + /* -------------------------------------------- */ async showCharacterEnd() { await this.actor.computeNRGHealth() diff --git a/templates/chat-create-actor.html b/templates/chat-create-actor.html index 3b2a9af..6207d68 100644 --- a/templates/chat-create-actor.html +++ b/templates/chat-create-actor.html @@ -134,6 +134,19 @@ {{/if}} + {{#if (eq step "select-global-spec")}} +
Now select a Specialisation at +1DT. +
+ + {{#each specs as |spec index|}} + + + + + {{/each}} +
{{spec.name}}Select it !
+ {{/if}} + {{#if (eq step "character-end")}}
Follow the next steps from the rulebook page 50 !. You can now spend 150 CDPs to customise your character.