All fixes'

This commit is contained in:
2022-01-10 08:00:27 +01:00
parent 9fbbd93a2e
commit 6387426b73
9 changed files with 184 additions and 47 deletions

View File

@@ -493,7 +493,7 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */
async addItemWithoutDuplicate( newItem ) {
let item = this.data.items.filter( item => item.type == newItem.type && item.name.toLowerCase() == newItem.name.toLowerCase() )
let item = this.data.items.find( item => item.type == newItem.type && item.name.toLowerCase() == newItem.name.toLowerCase() )
if ( !item ) {
await this.createEmbeddedDocuments( 'Item', [newItem]);
}
@@ -501,12 +501,16 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */
computeNRGHealth( ) {
let focValue = this.data.data.statistics.foc.value;
this.update( {'data.secondary.nrg.max': focValue, 'data.secondary.nrg.value': focValue} )
let phyValue = this.data.data.statistics.phy.value;
this.update( {'data.secondary.health.max': phyValue, 'data.secondary.health.value': phyValue} )
let mndValue = this.data.data.statistics.mnd.value;
this.update( {'data.secondary.delirium.max': mndValue, 'data.secondary.delirium.value': mndValue} )
let focDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.foc.value);
this.update( {'data.secondary.nrg.max': focDiceValue, 'data.secondary.nrg.value': focDiceValue} )
let phyDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.phy.value);
this.update( {'data.secondary.health.max': phyDiceValue, 'data.secondary.health.value': phyDiceValue} )
let mndDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.mnd.value);
this.update( {'data.secondary.delirium.max': mndDiceValue, 'data.secondary.delirium.value': mndDiceValue} )
let stlDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.stl.value);
this.update( {'data.secondary.stealthhealth.max': stlDiceValue, 'data.secondary.stealthhealth.value': stlDiceValue} )
let socDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.soc.value);
this.update( {'data.secondary.socialhealth.max': socDiceValue, 'data.secondary.socialhealth.value': socDiceValue} )
}
/* -------------------------------------------- */
@@ -556,17 +560,25 @@ export class PegasusActor extends Actor {
stat.mod += parseInt(ability.data.statmodifier)
updates[`data.statistics.${ability.data.affectedstat}`] = stat
}
for (let power of race.data.powersgained) {
newItems.push(power);
if ( race.data.powersgained) {
for (let power of race.data.powersgained) {
newItems.push(power);
}
}
for (let spec of race.data.specialisations) {
newItems.push(spec);
if ( race.data.specialisations) {
for (let spec of race.data.specialisations) {
newItems.push(spec);
}
}
for (let weapon of race.data.attackgained) {
newItems.push(weapon);
if ( race.data.attackgained) {
for (let weapon of race.data.attackgained) {
newItems.push(weapon);
}
}
for (let armor of race.data.armorgained) {
newItems.push(armor);
if ( race.data.armorgained) {
for (let armor of race.data.armorgained) {
newItems.push(armor);
}
}
}
await this.update( updates )
@@ -594,7 +606,7 @@ export class PegasusActor extends Actor {
this.getIncreaseStatValue( updates, role.data.statincrease1)
this.getIncreaseStatValue( updates, role.data.statincrease2)
newItems = newItems.concat(duplicate(role.data.specialisationsplus1))
//newItems = newItems.concat(duplicate(role.data.specialisationsplus1))
newItems = newItems.concat(duplicate(role.data.specialperk))
await this.update( updates )

View File

@@ -105,7 +105,20 @@ export class PegasusActorCreate {
this.currentRole = role;
this.nbRoleStat = 2;
this.roleStats = duplicate(role.data.statincreasechoice)
this.showRoleStat( );
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') {
@@ -261,7 +274,19 @@ export class PegasusActorCreate {
this.renderChatMessage( formData)
}
/* -------------------------------------------- */
/* ------------------------------- ------------- */
async showRoleStartSpec() {
if ( !this.roleSpecStart) {
this.roleSpecStart = duplicate(this.currentRole.data.specialisationsplus1)
this.nbRoleSpecStart = 2;
}
let formData = this.createFormData("select-role-start-spec")
formData.rolestartspec = this.roleSpecStart
formData.nbrolespecstart = this.nbRoleSpecStart;
this.renderChatMessage( formData)
}
/* ------------------------------- ------------- */
async showRoleStat( ) {
let formData = this.createFormData("select-role-stat")
formData.rolestats = []

View File

@@ -4,6 +4,7 @@ import { PegasusActorCreate } from "./pegasus-create-char.js";
/* -------------------------------------------- */
const __level2Dice = [ "d0", "d4", "d6", "d8", "d10", "d12" ];
const __level2DiceValue = [ 0, 4, 6, 8, 10, 12 ];
/* -------------------------------------------- */
export class PegasusUtility {
@@ -179,6 +180,18 @@ export class PegasusUtility {
return it;
}
/* -------------------------------------------- */
static getDiceValue( level = 0) {
let locLevel = level
let diceValue = 0
while (locLevel > 0) {
let idx = locLevel % __level2Dice.length
diceValue += __level2DiceValue[idx]
locLevel -= idx
}
return diceValue
}
/* -------------------------------------------- */
static getDiceFromLevel(level = 0) {
level = Number(level)