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 )