Fix #28 - Spec selection

This commit is contained in:
sladecraven 2022-11-26 11:05:41 +01:00
parent 9f8d9f56bd
commit 109ce4f192
2 changed files with 49 additions and 1 deletions

View File

@ -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()

View File

@ -134,6 +134,19 @@
</table>
{{/if}}
{{#if (eq step "select-global-spec")}}
<div>Now select a Specialisation at +1DT.
</div>
<table class="table-create-actor">
{{#each specs as |spec index|}}
<tr>
<td><a class="view-item-from-chat" data-step="{{@root.step}}" data-item-id="{{spec._id}}">{{spec.name}}</a></td>
<td><a class="chat-card-button chat-create-actor" data-step-name="{{@root.step}}" data-item-id="{{spec._id}}" >Select it !</a></td>
</tr>
{{/each}}
</table>
{{/if}}
{{#if (eq step "character-end")}}
<div>Follow the next steps from the rulebook page 50 !. You can now spend 150 CDPs to customise your character.
</div>