Fix #28 - Spec selection
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user