Fix #29 - Stat selection
This commit is contained in:
parent
109ce4f192
commit
50f4339454
@ -12,9 +12,9 @@ export class PegasusActorCreate {
|
|||||||
type: "character"
|
type: "character"
|
||||||
});
|
});
|
||||||
this.actor.sheet.render(true)
|
this.actor.sheet.render(true)
|
||||||
|
|
||||||
this.actor.computeValue = true // To force value computation
|
this.actor.computeValue = true // To force value computation
|
||||||
|
|
||||||
const racesPack = await PegasusUtility.loadCompendium("fvtt-pegasus-rpg.race")
|
const racesPack = await PegasusUtility.loadCompendium("fvtt-pegasus-rpg.race")
|
||||||
this.races = racesPack.map(i => i.toObject())
|
this.races = racesPack.map(i => i.toObject())
|
||||||
const rolesPack = await PegasusUtility.loadCompendium("fvtt-pegasus-rpg.role")
|
const rolesPack = await PegasusUtility.loadCompendium("fvtt-pegasus-rpg.role")
|
||||||
@ -35,10 +35,10 @@ export class PegasusActorCreate {
|
|||||||
step: step,
|
step: step,
|
||||||
races: this.races,
|
races: this.races,
|
||||||
roles: this.roles,
|
roles: this.roles,
|
||||||
nboptionnal: this.raceOptionnalAbilities?.nboptionnal?? 0,
|
nboptionnal: this.raceOptionnalAbilities?.nboptionnal ?? 0,
|
||||||
optionnalabilities: this.raceOptionnalAbilities?.optionnalabilities?? [],
|
optionnalabilities: this.raceOptionnalAbilities?.optionnalabilities ?? [],
|
||||||
}
|
}
|
||||||
if ( this.raceSelectableStats ) {
|
if (this.raceSelectableStats) {
|
||||||
formData.numberstats = this.raceSelectableStats.numberstats;
|
formData.numberstats = this.raceSelectableStats.numberstats;
|
||||||
formData.statsonlyonce = this.raceSelectableStats.statsonlyonce;
|
formData.statsonlyonce = this.raceSelectableStats.statsonlyonce;
|
||||||
formData.stats = this.raceSelectableStats.stats;
|
formData.stats = this.raceSelectableStats.stats;
|
||||||
@ -47,38 +47,38 @@ export class PegasusActorCreate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
getSpecFromRoleStat( role) {
|
getSpecFromRoleStat(role) {
|
||||||
let specList = []
|
let specList = []
|
||||||
for(let stat of role.system.statincreasechoice) {
|
for (let stat of role.system.statincreasechoice) {
|
||||||
if (stat.flag) {
|
if (stat.flag) {
|
||||||
specList = specList.concat( this.specs.filter( spec => spec.system.statistic.toLowerCase() == stat.name.toLowerCase() ))
|
specList = specList.concat(this.specs.filter(spec => spec.system.statistic.toLowerCase() == stat.name.toLowerCase()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return specList
|
return specList
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
getPerksFromRole( role ) {
|
getPerksFromRole(role) {
|
||||||
let perks = this.perks.filter( perk => perk.system.category.toLowerCase() == role.system.perksrole.toLowerCase())
|
let perks = this.perks.filter(perk => perk.system.category.toLowerCase() == role.system.perksrole.toLowerCase())
|
||||||
return perks
|
return perks
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
processChatEvent( event ) {
|
processChatEvent(event) {
|
||||||
const step = $(event.currentTarget).data("step-name");
|
const step = $(event.currentTarget).data("step-name");
|
||||||
const itemId = $(event.currentTarget).data("item-id");
|
const itemId = $(event.currentTarget).data("item-id");
|
||||||
|
|
||||||
if ( step == "select-race") {
|
if (step == "select-race") {
|
||||||
let race = this.races.find( item => item._id == itemId);
|
let race = this.races.find(item => item._id == itemId);
|
||||||
this.currentRace = race;
|
this.currentRace = race;
|
||||||
this.actor.applyRace( race);
|
this.actor.applyRace(race);
|
||||||
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget));
|
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget));
|
||||||
if ( race.system.nboptionnal > 0 && race.system.optionnalabilities.length > 0) {
|
if (race.system.nboptionnal > 0 && race.system.optionnalabilities.length > 0) {
|
||||||
this.manageOptionnalAbilities(race);
|
this.manageOptionnalAbilities(race);
|
||||||
} else {
|
} else {
|
||||||
if ( race.system.selectablestats ) {
|
if (race.system.selectablestats) {
|
||||||
this.manageSelectableStats(race);
|
this.manageSelectableStats(race);
|
||||||
} else if ( race.system.perksgained) {
|
} else if (race.system.perksgained) {
|
||||||
this.manageRacePerks(race);
|
this.manageRacePerks(race);
|
||||||
} else {
|
} else {
|
||||||
this.showRoles()
|
this.showRoles()
|
||||||
@ -86,87 +86,87 @@ export class PegasusActorCreate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( step == 'select-race-optionnal') {
|
if (step == 'select-race-optionnal') {
|
||||||
let ability = this.raceOptionnalAbilities.optionnalabilities.find( item => item._id == itemId);
|
let ability = this.raceOptionnalAbilities.optionnalabilities.find(item => item._id == itemId);
|
||||||
let update = []
|
let update = []
|
||||||
this.actor.applyAbility( ability, update );
|
this.actor.applyAbility(ability, update);
|
||||||
this.actor.update( update )
|
this.actor.update(update)
|
||||||
this.actor.createEmbeddedDocuments( 'Item', [ability]);
|
this.actor.createEmbeddedDocuments('Item', [ability]);
|
||||||
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget));
|
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget));
|
||||||
this.raceOptionnalAbilities.optionnalabilities = this.raceOptionnalAbilities.optionnalabilities.filter( item => item._id != itemId);
|
this.raceOptionnalAbilities.optionnalabilities = this.raceOptionnalAbilities.optionnalabilities.filter(item => item._id != itemId);
|
||||||
this.raceOptionnalAbilities.nboptionnal -= 1;
|
this.raceOptionnalAbilities.nboptionnal -= 1;
|
||||||
this.processOptionnalAbilitiesStep();
|
this.processOptionnalAbilitiesStep();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (step == 'select-race-stats') {
|
if (step == 'select-race-stats') {
|
||||||
let statKey = $(event.currentTarget).data("stat-key");
|
let statKey = $(event.currentTarget).data("stat-key");
|
||||||
this.actor.modStat( statKey, 1);
|
this.actor.modStat(statKey, 1);
|
||||||
this.raceSelectableStats.stats[statKey].used = true;
|
this.raceSelectableStats.stats[statKey].used = true;
|
||||||
this.raceSelectableStats.numberstats -=1;
|
this.raceSelectableStats.numberstats -= 1;
|
||||||
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget));
|
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget));
|
||||||
this.processSelectableStats();
|
this.processSelectableStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (step == 'select-race-perks') {
|
if (step == 'select-race-perks') {
|
||||||
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget));
|
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget));
|
||||||
let perk = this.racePerks.find( item => item._id == itemId);
|
let perk = this.racePerks.find(item => item._id == itemId);
|
||||||
this.actor.createEmbeddedDocuments( 'Item', [perk]);
|
this.actor.createEmbeddedDocuments('Item', [perk]);
|
||||||
this.racePerks = this.racePerks.filter( item => item._id != itemId);
|
this.racePerks = this.racePerks.filter(item => item._id != itemId);
|
||||||
this.nbRacePerks -= 1;
|
this.nbRacePerks -= 1;
|
||||||
if ( this.nbRacePerks == 0 || this.racePerks.length == 0) {
|
if (this.nbRacePerks == 0 || this.racePerks.length == 0) {
|
||||||
this.showRoles()
|
this.showRoles()
|
||||||
} else {
|
|
||||||
this.manageRacePerks()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( step == 'select-role') {
|
|
||||||
let role = this.roles.find( item => item._id == itemId);
|
|
||||||
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget));
|
|
||||||
this.actor.applyRole( role );
|
|
||||||
this.currentRole = role;
|
|
||||||
this.nbRoleStat = 2;
|
|
||||||
this.roleStats = duplicate(role.system.statincreasechoice)
|
|
||||||
this.showRoleStartSpec( );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( step == 'select-role-start-spec') {
|
|
||||||
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget));
|
|
||||||
let spec = this.roleSpecStart.find( item => item._id == itemId);
|
|
||||||
this.actor.addIncSpec(spec, 1);
|
|
||||||
this.nbRoleSpecStart--;
|
|
||||||
this.roleSpecStart = this.roleSpecStart.filter( item => item._id != itemId);//Remove selected spec
|
|
||||||
if( this.nbRoleSpecStart == 0) {
|
|
||||||
this.showRoleStat( );
|
|
||||||
} else {
|
} else {
|
||||||
this.showRoleStartSpec( );
|
this.manageRacePerks()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( step == 'select-role-stat') {
|
if (step == 'select-role') {
|
||||||
|
let role = this.roles.find(item => item._id == itemId);
|
||||||
|
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget));
|
||||||
|
this.actor.applyRole(role);
|
||||||
|
this.currentRole = role;
|
||||||
|
this.nbRoleStat = 2;
|
||||||
|
this.roleStats = duplicate(role.system.statincreasechoice)
|
||||||
|
this.showRoleStartSpec();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (step == 'select-role-start-spec') {
|
||||||
|
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget));
|
||||||
|
let spec = this.roleSpecStart.find(item => item._id == itemId);
|
||||||
|
this.actor.addIncSpec(spec, 1);
|
||||||
|
this.nbRoleSpecStart--;
|
||||||
|
this.roleSpecStart = this.roleSpecStart.filter(item => item._id != itemId);//Remove selected spec
|
||||||
|
if (this.nbRoleSpecStart == 0) {
|
||||||
|
this.showRoleStat();
|
||||||
|
} else {
|
||||||
|
this.showRoleStartSpec();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (step == 'select-role-stat') {
|
||||||
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget));
|
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget));
|
||||||
let statKey = $(event.currentTarget).data("stat-key");
|
let statKey = $(event.currentTarget).data("stat-key");
|
||||||
this.actor.valueStat( statKey, 1);
|
this.actor.valueStat(statKey, 1);
|
||||||
|
|
||||||
for (let stat of this.roleStats ) {
|
for (let stat of this.roleStats) {
|
||||||
if ( stat.name.toLowerCase() == statKey.toLowerCase()) {
|
if (stat.name.toLowerCase() == statKey.toLowerCase()) {
|
||||||
stat.flag = false
|
stat.flag = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.nbRoleStat--;
|
this.nbRoleStat--;
|
||||||
if ( this.nbRoleStat == 0 || this.roleStats.length == 0) {
|
if (this.nbRoleStat == 0 || this.roleStats.length == 0) {
|
||||||
this.roleSpec = this.getSpecFromRoleStat( this.currentRole )
|
this.roleSpec = this.getSpecFromRoleStat(this.currentRole)
|
||||||
this.nbDT2 = 1;
|
this.nbDT2 = 1;
|
||||||
this.nbDT1 = 2;
|
this.nbDT1 = 2;
|
||||||
this.showRoleSpecialisations()
|
this.showRoleSpecialisations()
|
||||||
} else{
|
} else {
|
||||||
this.showRoleStat( );
|
this.showRoleStat();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (step == 'select-role-spec') {
|
if (step == 'select-role-spec') {
|
||||||
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget));
|
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget));
|
||||||
let spec = this.roleSpec.find( item => item._id == itemId);
|
let spec = this.roleSpec.find(item => item._id == itemId);
|
||||||
if (this.nbDT2 > 0) {
|
if (this.nbDT2 > 0) {
|
||||||
this.actor.addIncSpec(spec, 2)
|
this.actor.addIncSpec(spec, 2)
|
||||||
this.nbDT2--;
|
this.nbDT2--;
|
||||||
@ -174,9 +174,9 @@ export class PegasusActorCreate {
|
|||||||
this.actor.addIncSpec(spec, 1)
|
this.actor.addIncSpec(spec, 1)
|
||||||
this.nbDT1--;
|
this.nbDT1--;
|
||||||
}
|
}
|
||||||
this.roleSpec = this.roleSpec.filter( item => item._id != itemId);//Remove selected spec
|
this.roleSpec = this.roleSpec.filter(item => item._id != itemId);//Remove selected spec
|
||||||
if ( this.nbDT1 == 0 || this.roleSpec.length == 0) {
|
if (this.nbDT1 == 0 || this.roleSpec.length == 0) {
|
||||||
this.rolePerks = this.getPerksFromRole( this.currentRole ) // duplicate(this.currentRole.data.perks)
|
this.rolePerks = this.getPerksFromRole(this.currentRole) // duplicate(this.currentRole.data.perks)
|
||||||
this.nbPerks = 2;
|
this.nbPerks = 2;
|
||||||
this.showRolePerks()
|
this.showRolePerks()
|
||||||
} else {
|
} else {
|
||||||
@ -186,10 +186,10 @@ export class PegasusActorCreate {
|
|||||||
|
|
||||||
if (step == 'select-role-perk') {
|
if (step == 'select-role-perk') {
|
||||||
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget));
|
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget));
|
||||||
let perk = this.rolePerks.find( item => item._id == itemId);
|
let perk = this.rolePerks.find(item => item._id == itemId);
|
||||||
this.actor.addItemWithoutDuplicate(perk)
|
this.actor.addItemWithoutDuplicate(perk)
|
||||||
this.nbPerks--;
|
this.nbPerks--;
|
||||||
this.rolePerks = this.rolePerks.filter( item => item._id != itemId);//Remove selected perk
|
this.rolePerks = this.rolePerks.filter(item => item._id != itemId);//Remove selected perk
|
||||||
if (this.nbPerks == 0 || this.rolePerks.length == 0) {
|
if (this.nbPerks == 0 || this.rolePerks.length == 0) {
|
||||||
this.nbGlobalSpec = 5
|
this.nbGlobalSpec = 5
|
||||||
this.showGlobalSpec()
|
this.showGlobalSpec()
|
||||||
@ -200,58 +200,77 @@ export class PegasusActorCreate {
|
|||||||
|
|
||||||
if (step == 'select-global-spec') {
|
if (step == 'select-global-spec') {
|
||||||
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget));
|
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget));
|
||||||
let spec = this.specs.find( item => item._id == itemId);
|
let spec = this.specs.find(item => item._id == itemId);
|
||||||
this.actor.addIncSpec(spec, 1)
|
this.actor.addIncSpec(spec, 1)
|
||||||
this.nbGlobalSpec--;
|
this.nbGlobalSpec--;
|
||||||
if (this.nbGlobalSpec == 0 ) {
|
if (this.nbGlobalSpec == 0) {
|
||||||
this.showCharacterEnd()
|
this.nbGlobalStat = 5
|
||||||
|
this.showGlobalStat()
|
||||||
|
//this.showCharacterEnd()
|
||||||
} else {
|
} else {
|
||||||
this.showGlobalSpec()
|
this.showGlobalSpec()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (step == 'select-global-stat') {
|
||||||
|
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget))
|
||||||
|
let statKey = $(event.currentTarget).data("stat-key")
|
||||||
|
this.actor.valueStat(statKey, 1)
|
||||||
|
this.nbGlobalStat--
|
||||||
|
if (this.nbGlobalStat == 0) {
|
||||||
|
this.showCharacterEnd()
|
||||||
|
} else {
|
||||||
|
this.showGlobalStat()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async openItemView( event) {
|
async openItemView(event) {
|
||||||
let step = $(event.currentTarget).data("step");
|
let step = $(event.currentTarget).data("step");
|
||||||
let itemId = $(event.currentTarget).data("item-id");
|
let itemId = $(event.currentTarget).data("item-id");
|
||||||
let itemData
|
let itemData
|
||||||
|
|
||||||
if ( step == 'select-race') {
|
if (step == 'select-race') {
|
||||||
itemData = this.races.find( item => item._id == itemId );
|
itemData = this.races.find(item => item._id == itemId);
|
||||||
}
|
}
|
||||||
if ( step == 'select-race-optionnal') {
|
if (step == 'select-race-optionnal') {
|
||||||
itemData = this.raceOptionnalAbilities.optionnalabilities.find( item => item._id == itemId );
|
itemData = this.raceOptionnalAbilities.optionnalabilities.find(item => item._id == itemId);
|
||||||
}
|
}
|
||||||
if ( step == 'select-race-perks') {
|
if (step == 'select-race-perks') {
|
||||||
itemData = this.perks.find( item => item._id == itemId );
|
itemData = this.perks.find(item => item._id == itemId);
|
||||||
}
|
}
|
||||||
if ( step == 'select-race-perks'){
|
if (step == 'select-race-perks') {
|
||||||
itemData = this.racePerks.find( item => item._id == itemId );
|
itemData = this.racePerks.find(item => item._id == itemId);
|
||||||
}
|
}
|
||||||
if ( step == 'select-role') {
|
if (step == 'select-role') {
|
||||||
itemData = this.roles.find( item => item._id == itemId );
|
itemData = this.roles.find(item => item._id == itemId);
|
||||||
}
|
}
|
||||||
if ( step == 'select-role-start-spec') {
|
if (step == 'select-role-start-spec') {
|
||||||
itemData = this.roleSpecStart.find( item => item._id == itemId );
|
itemData = this.roleSpecStart.find(item => item._id == itemId);
|
||||||
}
|
}
|
||||||
if (step == 'select-role-spec') {
|
if (step == 'select-role-spec') {
|
||||||
itemData = this.roleSpec.find( item => item._id == itemId );
|
itemData = this.roleSpec.find(item => item._id == itemId);
|
||||||
}
|
}
|
||||||
if (step == 'select-role-perk') {
|
if (step == 'select-role-perk') {
|
||||||
itemData = this.rolePerks.find( item => item._id == itemId );
|
itemData = this.rolePerks.find(item => item._id == itemId);
|
||||||
|
}
|
||||||
|
if (step == 'select-global-spec') {
|
||||||
|
itemData = this.specs.find(item => item._id == itemId);
|
||||||
}
|
}
|
||||||
if (itemData) {
|
if (itemData) {
|
||||||
let item = await Item.create(itemData, {temporary: true});
|
let item = await Item.create(itemData, { temporary: true });
|
||||||
new PegasusItemSheet(item).render(true);
|
new PegasusItemSheet(item).render(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
manageSelectableStats( race ) {
|
manageSelectableStats(race) {
|
||||||
this.raceSelectableStats = {
|
this.raceSelectableStats = {
|
||||||
"race": race,
|
"race": race,
|
||||||
"statsonlyonce": race.data.statsonlyonce,
|
"statsonlyonce": race.data.statsonlyonce,
|
||||||
"numberstats": race.data.numberstats,
|
"numberstats": race.data.numberstats,
|
||||||
"stats": duplicate(this.actor.data.data.statistics)
|
"stats": duplicate(this.actor.data.data.statistics)
|
||||||
}
|
}
|
||||||
@ -259,61 +278,61 @@ export class PegasusActorCreate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async renderChatMessage( formData) {
|
async renderChatMessage(formData) {
|
||||||
let chatData = {
|
let chatData = {
|
||||||
user: game.user.id,
|
user: game.user.id,
|
||||||
alias : this.actor.name,
|
alias: this.actor.name,
|
||||||
rollMode: game.settings.get("core", "rollMode"),
|
rollMode: game.settings.get("core", "rollMode"),
|
||||||
whisper: [game.user.id].concat( ChatMessage.getWhisperRecipients('GM') ),
|
whisper: [game.user.id].concat(ChatMessage.getWhisperRecipients('GM')),
|
||||||
content: await renderTemplate('systems/fvtt-pegasus-rpg/templates/chat-create-actor.html', formData)
|
content: await renderTemplate('systems/fvtt-pegasus-rpg/templates/chat-create-actor.html', formData)
|
||||||
};
|
};
|
||||||
//console.log("Apply damage chat", chatData );
|
//console.log("Apply damage chat", chatData );
|
||||||
await ChatMessage.create( chatData );
|
await ChatMessage.create(chatData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------- -------------------- --------- */
|
/* --------------- -------------------- --------- */
|
||||||
manageRacePerks(race) {
|
manageRacePerks(race) {
|
||||||
if ( !this.currentRace.data.perksgained ) {
|
if (!this.currentRace.data.perksgained) {
|
||||||
this.showRoles()
|
this.showRoles()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( !this.racePerks) { // First init
|
if (!this.racePerks) { // First init
|
||||||
if ( this.currentRace.data.perksall) {
|
if (this.currentRace.data.perksall) {
|
||||||
this.racePerks = duplicate(this.perks)
|
this.racePerks = duplicate(this.perks)
|
||||||
} else {
|
} else {
|
||||||
this.racePerks = duplicate(this.currentRace.data.perks)
|
this.racePerks = duplicate(this.currentRace.data.perks)
|
||||||
}
|
}
|
||||||
this.nbRacePerks = this.currentRace.data.perksnumber;
|
this.nbRacePerks = this.currentRace.data.perksnumber;
|
||||||
}
|
}
|
||||||
let formData = this.createFormData("select-race-perks")
|
let formData = this.createFormData("select-race-perks")
|
||||||
formData.raceperks = this.racePerks;
|
formData.raceperks = this.racePerks;
|
||||||
formData.nbraceperks = this.nbRacePerks;
|
formData.nbraceperks = this.nbRacePerks;
|
||||||
this.renderChatMessage(formData)
|
this.renderChatMessage(formData)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------- -------------------- --------- */
|
/* --------------- -------------------- --------- */
|
||||||
async processSelectableStats() {
|
async processSelectableStats() {
|
||||||
// End of race options choice
|
// End of race options choice
|
||||||
if ( this.raceSelectableStats.numberstats == 0) {
|
if (this.raceSelectableStats.numberstats == 0) {
|
||||||
this.manageRacePerks();
|
this.manageRacePerks();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let formData = this.createFormData("select-race-stats")
|
let formData = this.createFormData("select-race-stats")
|
||||||
let chatData = {
|
let chatData = {
|
||||||
user: game.user.id,
|
user: game.user.id,
|
||||||
alias : this.actor.name,
|
alias: this.actor.name,
|
||||||
rollMode: game.settings.get("core", "rollMode"),
|
rollMode: game.settings.get("core", "rollMode"),
|
||||||
whisper: [game.user.id].concat( ChatMessage.getWhisperRecipients('GM') ),
|
whisper: [game.user.id].concat(ChatMessage.getWhisperRecipients('GM')),
|
||||||
content: await renderTemplate('systems/fvtt-pegasus-rpg/templates/chat-create-actor.html', formData)
|
content: await renderTemplate('systems/fvtt-pegasus-rpg/templates/chat-create-actor.html', formData)
|
||||||
};
|
};
|
||||||
//console.log("Apply damage chat", chatData );
|
//console.log("Apply damage chat", chatData );
|
||||||
await ChatMessage.create( chatData );
|
await ChatMessage.create(chatData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------- ----------------------------- */
|
/* --------------- ----------------------------- */
|
||||||
manageOptionnalAbilities( race) {
|
manageOptionnalAbilities(race) {
|
||||||
this.raceOptionnalAbilities = {
|
this.raceOptionnalAbilities = {
|
||||||
"nboptionnal": race.data.nboptionnal,
|
"nboptionnal": race.data.nboptionnal,
|
||||||
"optionnalabilities": duplicate(race.data.optionnalabilities),
|
"optionnalabilities": duplicate(race.data.optionnalabilities),
|
||||||
}
|
}
|
||||||
this.processOptionnalAbilitiesStep()
|
this.processOptionnalAbilitiesStep()
|
||||||
@ -322,57 +341,57 @@ export class PegasusActorCreate {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async processOptionnalAbilitiesStep() {
|
async processOptionnalAbilitiesStep() {
|
||||||
// End of race options choice
|
// End of race options choice
|
||||||
if ( this.raceOptionnalAbilities.nboptionnal == 0) {
|
if (this.raceOptionnalAbilities.nboptionnal == 0) {
|
||||||
if ( this.raceSelectableStats ) {
|
if (this.raceSelectableStats) {
|
||||||
this.manageSelectableStats(this.currentrace);
|
this.manageSelectableStats(this.currentrace);
|
||||||
} else if ( this.currentRace.system.perksgained) {
|
} else if (this.currentRace.system.perksgained) {
|
||||||
this.manageRacePerks(this.currentRace);
|
this.manageRacePerks(this.currentRace);
|
||||||
} else {
|
} else {
|
||||||
this.showRoles()
|
this.showRoles()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let formData = this.createFormData("select-race-optionnal")
|
let formData = this.createFormData("select-race-optionnal")
|
||||||
this.renderChatMessage( formData)
|
this.renderChatMessage(formData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async showRaces() {
|
async showRaces() {
|
||||||
let formData = this.createFormData("select-race")
|
let formData = this.createFormData("select-race")
|
||||||
this.renderChatMessage( formData)
|
this.renderChatMessage(formData)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async showRoles() {
|
async showRoles() {
|
||||||
let formData = this.createFormData("select-role")
|
let formData = this.createFormData("select-role")
|
||||||
this.renderChatMessage( formData)
|
this.renderChatMessage(formData)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------- ------------- */
|
/* ------------------------------- ------------- */
|
||||||
async showRoleStartSpec() {
|
async showRoleStartSpec() {
|
||||||
if ( !this.roleSpecStart) {
|
if (!this.roleSpecStart) {
|
||||||
this.roleSpecStart = this.specs.filter(spec => spec.system.statistic.toUpperCase() == this.currentRole.system.statincrease1.toUpperCase() || spec.system.statistic.toUpperCase() == this.currentRole.system.statincrease2.toUpperCase() )
|
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)
|
console.log("SPEC FOUND", this.roleSpecStart)
|
||||||
//this.roleSpecStart = duplicate(this.currentRole.data.specialisationsplus1)
|
//this.roleSpecStart = duplicate(this.currentRole.data.specialisationsplus1)
|
||||||
this.nbRoleSpecStart = 2;
|
this.nbRoleSpecStart = 2;
|
||||||
}
|
}
|
||||||
let formData = this.createFormData("select-role-start-spec")
|
let formData = this.createFormData("select-role-start-spec")
|
||||||
formData.rolestartspec = this.roleSpecStart
|
formData.rolestartspec = this.roleSpecStart
|
||||||
formData.nbrolespecstart = this.nbRoleSpecStart;
|
formData.nbrolespecstart = this.nbRoleSpecStart;
|
||||||
this.renderChatMessage( formData)
|
this.renderChatMessage(formData)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------- ------------- */
|
/* ------------------------------- ------------- */
|
||||||
async showRoleStat( ) {
|
async showRoleStat() {
|
||||||
let formData = this.createFormData("select-role-stat")
|
let formData = this.createFormData("select-role-stat")
|
||||||
formData.rolestats = []
|
formData.rolestats = []
|
||||||
for(let stat of this.roleStats) {
|
for (let stat of this.roleStats) {
|
||||||
if (stat.flag) {
|
if (stat.flag) {
|
||||||
formData.rolestats.push( duplicate(this.actor.system.statistics[stat.name.toLowerCase()]) )
|
formData.rolestats.push(duplicate(this.actor.system.statistics[stat.name.toLowerCase()]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//console.log("STAT", this.roleStats, formData)
|
//console.log("STAT", this.roleStats, formData)
|
||||||
this.renderChatMessage( formData)
|
this.renderChatMessage(formData)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -380,10 +399,10 @@ export class PegasusActorCreate {
|
|||||||
let formData = this.createFormData("select-role-spec")
|
let formData = this.createFormData("select-role-spec")
|
||||||
formData.rolespec = duplicate(this.roleSpec)
|
formData.rolespec = duplicate(this.roleSpec)
|
||||||
formData.dt = 1
|
formData.dt = 1
|
||||||
if (this.nbDT2 > 0 ) {
|
if (this.nbDT2 > 0) {
|
||||||
formData.dt = 2
|
formData.dt = 2
|
||||||
}
|
}
|
||||||
this.renderChatMessage( formData)
|
this.renderChatMessage(formData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -392,15 +411,15 @@ export class PegasusActorCreate {
|
|||||||
let formData = this.createFormData("select-role-perk")
|
let formData = this.createFormData("select-role-perk")
|
||||||
formData.roleperks = duplicate(this.rolePerks)
|
formData.roleperks = duplicate(this.rolePerks)
|
||||||
formData.nbperks = this.nbPerks
|
formData.nbperks = this.nbPerks
|
||||||
this.renderChatMessage( formData)
|
this.renderChatMessage(formData)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async showGlobalSpec() {
|
async showGlobalSpec() {
|
||||||
let formData = this.createFormData("select-global-spec")
|
let formData = this.createFormData("select-global-spec")
|
||||||
let excludedSpecs = this.actor.items.filter(it => it.type =="specialisation" && it.system.level >= 4)
|
let excludedSpecs = this.actor.items.filter(it => it.type == "specialisation" && it.system.level >= 4)
|
||||||
formData.specs = []
|
formData.specs = []
|
||||||
for( let spec of this.specs) {
|
for (let spec of this.specs) {
|
||||||
let isOK = true
|
let isOK = true
|
||||||
for (let excluded of excludedSpecs) {
|
for (let excluded of excludedSpecs) {
|
||||||
if (excluded.name == spec.name) {
|
if (excluded.name == spec.name) {
|
||||||
@ -411,17 +430,30 @@ export class PegasusActorCreate {
|
|||||||
if (isOK) {
|
if (isOK) {
|
||||||
formData.specs.push(spec)
|
formData.specs.push(spec)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
formData.specs.sort( function compare(a, b) { if (a.name < b.name) {return -1} else {return 1} } )
|
formData.specs.sort(function compare(a, b) { if (a.name < b.name) { return -1 } else { return 1 } })
|
||||||
this.renderChatMessage( formData )
|
this.renderChatMessage(formData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
async showGlobalStat() {
|
||||||
|
let formData = this.createFormData("select-global-stat")
|
||||||
|
formData.stats = {}
|
||||||
|
for (let key in this.actor.system.statistics) {
|
||||||
|
let stat = this.actor.system.statistics[key]
|
||||||
|
if (stat.level < 5) {
|
||||||
|
formData.stats[key] = duplicate(stat)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.renderChatMessage(formData)
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async showCharacterEnd() {
|
async showCharacterEnd() {
|
||||||
await this.actor.computeNRGHealth()
|
await this.actor.computeNRGHealth()
|
||||||
this.actor.computeValue = false // To force value computation
|
this.actor.computeValue = false // To force value computation
|
||||||
let formData = this.createFormData("character-end")
|
let formData = this.createFormData("character-end")
|
||||||
this.renderChatMessage( formData)
|
this.renderChatMessage(formData)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -147,6 +147,19 @@
|
|||||||
</table>
|
</table>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if (eq step "select-global-stat")}}
|
||||||
|
<div>Now select a Statistic at +1DT.
|
||||||
|
</div>
|
||||||
|
<table class="table-create-actor">
|
||||||
|
{{#each stats as |stat key|}}
|
||||||
|
<tr>
|
||||||
|
<td><a class="view-item-from-chat" data-step="{{@root.step}}" data-stat-key="{{key}}">{{stat.label}}</a></td>
|
||||||
|
<td><a class="chat-card-button chat-create-actor" data-step-name="{{@root.step}}" data-stat-key="{{key}}" >Select it !</a></td>
|
||||||
|
</tr>
|
||||||
|
{{/each}}
|
||||||
|
</table>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
{{#if (eq step "character-end")}}
|
{{#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>Follow the next steps from the rulebook page 50 !. You can now spend 150 CDPs to customise your character.
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user