Char creation
This commit is contained in:
@ -483,6 +483,24 @@ export class PegasusActor extends Actor {
|
||||
await this.deleteEmbeddedDocuments( 'Item', items);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addItemWithoutDuplicate( newItem ) {
|
||||
let item = this.data.items.filter( item => item.type == newItem.type && item.name.toLowerCase() == newItem.name.toLowerCase() )
|
||||
if ( !item ) {
|
||||
await this.createEmbeddedDocuments( 'Item', [newItem]);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
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} )
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async modStat( key, inc=1) {
|
||||
let stat = duplicate(this.data.data.statistics[key])
|
||||
@ -490,6 +508,29 @@ export class PegasusActor extends Actor {
|
||||
await this.update( { [`data.statistics.${key}`] : stat } )
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async valueStat( key, inc=1) {
|
||||
key = key.toLowerCase()
|
||||
let stat = duplicate( this.data.data.statistics[key] )
|
||||
stat.value += parseInt(inc)
|
||||
await this.update( { [`data.statistics.${key}`] : stat } )
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addIncSpec( spec, inc=1) {
|
||||
console.log("Using spec : ", spec, inc)
|
||||
let specExist = this.data.items.find( item => item.type == 'specialisation' && item.name.toLowerCase() == spec.name.toLowerCase())
|
||||
if (specExist) {
|
||||
specExist = duplicate(specExist)
|
||||
specExist.data.level += inc;
|
||||
let update = { _id: specExist._id, "data.level": specExist.data.level };
|
||||
await this.updateEmbeddedDocuments('Item', [ update ]);
|
||||
} else {
|
||||
spec.data.level += inc;
|
||||
await this.createEmbeddedDocuments( 'Item', [ spec ]);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async applyRace( race ) {
|
||||
let updates = { 'data.racename':race.name }
|
||||
@ -533,6 +574,9 @@ 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.specialperk))
|
||||
|
||||
await this.update( updates )
|
||||
await this.createEmbeddedDocuments('Item', newItems)
|
||||
}
|
||||
|
Reference in New Issue
Block a user