added total armor calculation

This commit is contained in:
TheLastScrub
2021-03-21 00:04:13 -07:00
parent 2f91ca0aa1
commit e6ef2cd34e
2 changed files with 21 additions and 5 deletions
+4 -1
View File
@@ -56,6 +56,9 @@ export class DeltaGreenActorSheet extends ActorSheet {
const armor = [];
const weapons = [];
// total armor rating
let armorRating = 0;
// Iterate through items, allocating to containers
// let totalWeight = 0;
for (let i of sheetData.items) {
@@ -65,7 +68,7 @@ export class DeltaGreenActorSheet extends ActorSheet {
if (i.type === 'armor') {
armor.push(i);
}
// Append to features.
// Append to weapons.
else if (i.type === 'weapon') {
weapons.push(i);
}
+17 -4
View File
@@ -16,20 +16,21 @@ export class DeltaGreenActor extends Actor {
// Make separate methods for each Actor type (character, npc, etc.) to keep
// things organized.
if (actorData.type === 'agent') this._prepareAgentData(actorData);
if (actorData.type === 'agent') this._prepareAgentData(this);
}
/**
* Prepare Agent type specific data
*/
_prepareAgentData(actorData) {
_prepareAgentData(agent) {
let actorData = agent.data;
const data = actorData.data;
// Make modifications to data here. For example:
// Loop through ability scores, and add their modifiers to our sheet output.
for (let [key, statistic] of Object.entries(data.statistics)) {
// the x5 is just whatever the raw statistic is x 5 to turn it into a d100 percentile
statistic.x5 = statistic.value * 5;
}
@@ -105,8 +106,20 @@ export class DeltaGreenActor extends Actor {
else{
actorData.data.sanity.adaptations.helplessness.isAdapted = false;
}
// calculate total armor rating
let protection = 0;
for (let i of agent.items) {
if (i.type === 'armor') {
if(i.data.data.equipped === true){
protection += i.data.data.protection;
}
}
}
actorData.data.health.protection = protection;
console.log(actorData);
console.log(agent);
}
/** @override */