Step 4 - Hindrance on health/delirium
This commit is contained in:
@ -66,10 +66,6 @@ export class PegasusActor extends Actor {
|
||||
for (let key in this.data.data.statistics) {
|
||||
let attr = this.data.data.statistics[key];
|
||||
}
|
||||
/*if ( h != this.data.data.secondary.health.max) {
|
||||
this.data.data.secondary.health.max = h;
|
||||
updates.push( {'data.secondary.health.max': h} );
|
||||
}*/
|
||||
if (updates.length > 0) {
|
||||
this.update(updates);
|
||||
}
|
||||
@ -262,11 +258,11 @@ export class PegasusActor extends Actor {
|
||||
this.applyRace(item.data)
|
||||
} else if ( item.data.type == 'ability') {
|
||||
this.applyAbility(item.data, [], true)
|
||||
await this.createEmbeddedDocuments('Item', [item.data] )
|
||||
if ( !onDrop) {
|
||||
await this.createEmbeddedDocuments('Item', [item.data] )
|
||||
}
|
||||
} else {
|
||||
if ( onDrop) {
|
||||
await super._onDropItem(event, dragData)
|
||||
} else {
|
||||
if ( !onDrop) {
|
||||
await this.createEmbeddedDocuments('Item', [item.data] )
|
||||
}
|
||||
}
|
||||
@ -428,6 +424,16 @@ export class PegasusActor extends Actor {
|
||||
//console.log("UPD", updates, this.data.data.biodata)
|
||||
await this.update(updates)
|
||||
}
|
||||
|
||||
// Update current hindrance level
|
||||
let hindrance = this.data.data.combat.hindrancedice
|
||||
if ( this.data.data.secondary.health.value < 0) {
|
||||
hindrance += Math.abs(this.data.data.secondary.health.value)
|
||||
}
|
||||
if ( this.data.data.secondary.delirium.value < 0) {
|
||||
hindrance += Math.abs(this.data.data.secondary.delirium.value)
|
||||
}
|
||||
this.data.data.combat.hindrancedice = hindrance
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -470,17 +476,63 @@ export class PegasusActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
applyAbility(ability, updates = [], directUpdate = false) {
|
||||
async applyAbility(ability, updates = [], directUpdate = false) {
|
||||
// manage stat bonus
|
||||
if (ability.data.affectedstat != "notapplicable") {
|
||||
let stat = duplicate(this.data.data.statistics[ability.data.affectedstat])
|
||||
stat.value += parseInt(ability.data.statlevelincrease)
|
||||
stat.mod += parseInt(ability.data.statmodifier)
|
||||
stat.mod += Number(ability.data.statmodifier)
|
||||
updates[`data.statistics.${ability.data.affectedstat}`] = stat
|
||||
if(directUpdate) {
|
||||
this.update(updates)
|
||||
}
|
||||
// manage status bonus
|
||||
if (ability.data.statusaffected != "notapplicable") {
|
||||
if ( ability.data.statusaffected == 'nrg' ) {
|
||||
let nrg = duplicate( this.data.data.nrg)
|
||||
nrg.mod += Number(ability.data.statusmodifier)
|
||||
updates[`data.nrg`] = nrg
|
||||
}
|
||||
if ( ability.data.statusaffected == 'health' ) {
|
||||
let health = duplicate( this.data.data.secondary.health)
|
||||
health.bonus += Number(ability.data.statusmodifier)
|
||||
updates[`data.secondary.health`] = health
|
||||
}
|
||||
if ( ability.data.statusaffected == 'delirium' ) {
|
||||
let delirium = duplicate( this.data.data.secondary.delirium)
|
||||
delirium.bonus += Number(ability.data.statusmodifier)
|
||||
updates[`data.secondary.delirium`] = delirium
|
||||
}
|
||||
}
|
||||
if ( directUpdate ) {
|
||||
await this.update(updates)
|
||||
}
|
||||
let newItems = []
|
||||
if (ability.data.effectsgained) {
|
||||
for (let effect of ability.data.effectsgained) {
|
||||
newItems.push(effect);
|
||||
}
|
||||
}
|
||||
if (ability.data.powersgained) {
|
||||
for (let power of ability.data.powersgained) {
|
||||
newItems.push(power);
|
||||
}
|
||||
}
|
||||
if (ability.data.specialisations) {
|
||||
for (let spec of ability.data.specialisations) {
|
||||
newItems.push(spec);
|
||||
}
|
||||
}
|
||||
if (ability.data.attackgained) {
|
||||
for (let weapon of ability.data.attackgained) {
|
||||
newItems.push(weapon);
|
||||
}
|
||||
}
|
||||
if (ability.data.armorgained) {
|
||||
for (let armor of ability.data.armorgained) {
|
||||
newItems.push(armor);
|
||||
}
|
||||
}
|
||||
await this.createEmbeddedDocuments('Item', newItems)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async applyRace(race) {
|
||||
let updates = { 'data.biodata.racename': race.name }
|
||||
@ -492,26 +544,11 @@ export class PegasusActor extends Actor {
|
||||
newItems.push(ability)
|
||||
this.applyAbility(ability, updates)
|
||||
}
|
||||
if (race.data.powersgained) {
|
||||
for (let power of race.data.powersgained) {
|
||||
if (race.data.perksgained) {
|
||||
for (let power of race.data.perks) {
|
||||
newItems.push(power);
|
||||
}
|
||||
}
|
||||
if (race.data.specialisations) {
|
||||
for (let spec of race.data.specialisations) {
|
||||
newItems.push(spec);
|
||||
}
|
||||
}
|
||||
if (race.data.attackgained) {
|
||||
for (let weapon of race.data.attackgained) {
|
||||
newItems.push(weapon);
|
||||
}
|
||||
}
|
||||
if (race.data.armorgained) {
|
||||
for (let armor of race.data.armorgained) {
|
||||
newItems.push(armor);
|
||||
}
|
||||
}
|
||||
|
||||
await this.update(updates)
|
||||
await this.createEmbeddedDocuments('Item', newItems)
|
||||
@ -551,6 +588,9 @@ export class PegasusActor extends Actor {
|
||||
if (this.data.data.combat.stunlevel > 0) {
|
||||
effectsList.push( { label: "Stun Hindrance", type: "hindrance", applied: false, value: this.data.data.combat.stunlevel } )
|
||||
}
|
||||
if (this.data.data.combat.hindrancedice > 0) {
|
||||
effectsList.push( { label: "Health/Delirium Hindrance", type: "hindrance", applied: false, value: this.data.data.combat.hindrancedice } )
|
||||
}
|
||||
let effects = this.data.items.filter( item => item.type == 'effect' )
|
||||
for( let effect of effects) {
|
||||
effect = duplicate(effect)
|
||||
@ -576,6 +616,7 @@ export class PegasusActor extends Actor {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
addArmorsShields( rollData, statKey = "none", useShield = false) {
|
||||
if (statKey == 'phy') {
|
||||
|
Reference in New Issue
Block a user