@ -21,6 +21,8 @@ export class PegasusActorCreate {
|
||||
this.roles = rolesPack.map(i => i.toObject())
|
||||
const perksPack = await PegasusUtility.loadCompendium("fvtt-pegasus-rpg.perk")
|
||||
this.perks = perksPack.map(i => i.toObject())
|
||||
const specPack = await PegasusUtility.loadCompendium("fvtt-pegasus-rpg.specialisations")
|
||||
this.specs = specPack.map(i => i.toObject())
|
||||
|
||||
this.showRaces()
|
||||
}
|
||||
@ -44,6 +46,23 @@ export class PegasusActorCreate {
|
||||
return formData;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getSpecFromRoleStat( role) {
|
||||
let specList = []
|
||||
for(let stat of role.system.statincreasechoice) {
|
||||
if (stat.flag) {
|
||||
specList = specList.concat( this.specs.filter( spec => spec.system.statistic.toLowerCase() == stat.name.toLowerCase() ))
|
||||
}
|
||||
}
|
||||
return specList
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getPerksFromRole( role ) {
|
||||
let perks = this.perks.filter( perk => perk.system.category.toLowerCase() == role.system.perksrole.toLowerCase())
|
||||
return perks
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
processChatEvent( event ) {
|
||||
const step = $(event.currentTarget).data("step-name");
|
||||
@ -54,12 +73,12 @@ export class PegasusActorCreate {
|
||||
this.currentRace = race;
|
||||
this.actor.applyRace( race);
|
||||
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget));
|
||||
if ( race.data.nboptionnal > 0 && race.data.optionnalabilities.length > 0) {
|
||||
if ( race.system.nboptionnal > 0 && race.system.optionnalabilities.length > 0) {
|
||||
this.manageOptionnalAbilities(race);
|
||||
} else {
|
||||
if ( race.data.selectablestats ) {
|
||||
if ( race.system.selectablestats ) {
|
||||
this.manageSelectableStats(race);
|
||||
} else if ( race.data.perksgained) {
|
||||
} else if ( race.system.perksgained) {
|
||||
this.manageRacePerks(race);
|
||||
} else {
|
||||
this.showRoles()
|
||||
@ -107,7 +126,7 @@ export class PegasusActorCreate {
|
||||
this.actor.applyRole( role );
|
||||
this.currentRole = role;
|
||||
this.nbRoleStat = 2;
|
||||
this.roleStats = duplicate(role.data.statincreasechoice)
|
||||
this.roleStats = duplicate(role.system.statincreasechoice)
|
||||
this.showRoleStartSpec( );
|
||||
}
|
||||
|
||||
@ -136,7 +155,7 @@ export class PegasusActorCreate {
|
||||
}
|
||||
this.nbRoleStat--;
|
||||
if ( this.nbRoleStat == 0 || this.roleStats.length == 0) {
|
||||
this.roleSpec = duplicate(this.currentRole.data.specincrease)
|
||||
this.roleSpec = this.getSpecFromRoleStat( this.currentRole )
|
||||
this.nbDT2 = 1;
|
||||
this.nbDT1 = 2;
|
||||
this.showRoleSpecialisations()
|
||||
@ -157,7 +176,7 @@ export class PegasusActorCreate {
|
||||
}
|
||||
this.roleSpec = this.roleSpec.filter( item => item._id != itemId);//Remove selected spec
|
||||
if ( this.nbDT1 == 0 || this.roleSpec.length == 0) {
|
||||
this.rolePerks = duplicate(this.currentRole.data.perks)
|
||||
this.rolePerks = this.getPerksFromRole( this.currentRole ) // duplicate(this.currentRole.data.perks)
|
||||
this.nbPerks = 2;
|
||||
this.showRolePerks()
|
||||
} else {
|
||||
@ -293,7 +312,7 @@ export class PegasusActorCreate {
|
||||
if ( this.raceOptionnalAbilities.nboptionnal == 0) {
|
||||
if ( this.raceSelectableStats ) {
|
||||
this.manageSelectableStats(this.currentrace);
|
||||
} else if ( this.currentRace.data.perksgained) {
|
||||
} else if ( this.currentRace.system.perksgained) {
|
||||
this.manageRacePerks(this.currentRace);
|
||||
} else {
|
||||
this.showRoles()
|
||||
@ -319,7 +338,9 @@ export class PegasusActorCreate {
|
||||
/* ------------------------------- ------------- */
|
||||
async showRoleStartSpec() {
|
||||
if ( !this.roleSpecStart) {
|
||||
this.roleSpecStart = duplicate(this.currentRole.data.specialisationsplus1)
|
||||
this.roleSpecStart = this.specs.filter(spec => spec.system.statistic.toUpperCase() == this.currentRole.system.statincrease1.toUpperCase() || spec.system.statistic.toUpperCase() == this.currentRole.system.statincrease2.toUpperCase() )
|
||||
console.log("SPEC FOUND", this.roleSpecStart)
|
||||
//this.roleSpecStart = duplicate(this.currentRole.data.specialisationsplus1)
|
||||
this.nbRoleSpecStart = 2;
|
||||
}
|
||||
let formData = this.createFormData("select-role-start-spec")
|
||||
@ -334,7 +355,7 @@ export class PegasusActorCreate {
|
||||
formData.rolestats = []
|
||||
for(let stat of this.roleStats) {
|
||||
if (stat.flag) {
|
||||
formData.rolestats.push( duplicate(this.actor.data.data.statistics[stat.name.toLowerCase()]) )
|
||||
formData.rolestats.push( duplicate(this.actor.system.statistics[stat.name.toLowerCase()]) )
|
||||
}
|
||||
}
|
||||
//console.log("STAT", this.roleStats, formData)
|
||||
|
Reference in New Issue
Block a user