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")}} +
{{spec.name}} | +Select it ! | +