primary
modifier
notes
@@ -3275,12 +3275,8 @@
-
-
-
-
-
-
+
+
@@ -3455,7 +3451,11 @@ const sheetAttributes = {
rangeAttributes: ['dicepool', 'weapon', 'damage', 'acc', 'ap', 'skill', 'ammo', 'mode', 'recoil'],
meleeAttributes: ['dicepool', 'weapon', 'damage', 'acc', 'ap', 'skill', 'reach'],
- spellTypes: ['spell', 'preps', 'ritual', 'forms']
+ spellTypes: ['spell', 'preps', 'ritual', 'forms'],
+
+ armorAttributes: ['name', 'rating', 'acid_modifier', 'electrical_modifier', 'cold_modifier', 'fire_modifier', 'radiation_modifier', 'dicepool_modifier'],
+ armorSoak: ['dicepool_modifier', 'rating'],
+ armorProtections: ['acid', 'electrical', 'cold', 'fire', 'radiation']
}
class PrimaryWeapon {
@@ -3487,22 +3487,41 @@ class PrimaryMeleeWeapon extends PrimaryWeapon {
}
+class PrimaryArmor {
+ constructor(name) {
+ this.armor_name = name || 'select a Primary in Arms',
+ this.soak = 0,
+ this.armor_rating = 0,
+ this.acid_protection = 0,
+ this.cold_protection = 0,
+ this.fire_protection = 0,
+ this.radiation_protection = 0,
+ this.electrical_protection = 0
+ }
+}
+
+
+
const processingFunctions = {
convertIntegerNegative: number => number > 0 ? -Math.abs(number) : number,
convertIntegersNegatives: numbers => {
for (let [key, value] of Object.entries(numbers)) {
numbers[key] = processingFunctions.convertIntegerNegative(value);
- }calculateConditionTracks
+ }
return numbers
},
findRepeatingField: trigger => trigger.split('_')[1],
//Roll20 does not allow for Promises
//getAttributes: array => new Promise((resolve, reject) => array ? getAttrs(array, v => resolve(v)) : reject(errorMessage('Function failed'))),
- getReprowid: trigger => {calculateConditionTracks
+ getReprowid: trigger => {
const split = trigger.split('_');
return `${split[0]}_${split[1]}_${split[2]}`
},
+ getReprowAttribute: key => {
+ const getReprowid = processingFunctions.getReprowid(key)
+ return key.split(`${getReprowid}_`)[1]
+ },
getTranslations: translationKeys => {
let translations = {}
translationKeys.forEach(key => translations[`${key}`] = getTranslationByKey(key))
@@ -3609,6 +3628,14 @@ const processingFunctions = {
attrs.essence ? Math.ceil(attrs.essence) || 0 : false;
return processingFunctions.shadowrun.calculateLimitTotal(Object.values(attrs))
},
+ resetPrimaryArmor: () => {
+ const resetPrimary = new PrimaryArmor()
+ let update = {}
+ for (let [key, value] of Object.entries(resetPrimary)) {
+ update[key] = value
+ }
+ return update
+ },
resetPrimaryWeapon: type => {
const resetPrimary = type === 'range' ? new PrimaryRangeWeapon(type) : new PrimaryMeleeWeapon(type)
let update = {}
@@ -3617,12 +3644,30 @@ const processingFunctions = {
}
return update
},
+ updatePrimaryArmor: attrs => {
+ let update = {}
+
+ for (let [key, value] of Object.entries(attrs)) {
+ const repRowID = processingFunctions.getReprowid(key)
+ if (key.includes('name')) {
+ update['armor_name'] = attrs[`${repRowID}_name`]
+ } else if (key.includes('rating')) {
+ update['armor_rating'] = value
+ } else if (key.includes('dicepool_modifier')) {
+ update['soak_modifier'] = value
+ } else {
+ const type = key.split('_')[3]
+ update[`${type}_modifier`] = value
+ }
+ }
+
+ return update
+ },
updatePrimaryWeapons: attrs => {
let update = {}
for (let [key, value] of Object.entries(attrs)) {
const type = processingFunctions.findRepeatingField(key)
- const getReprowid = processingFunctions.getReprowid(key)
- const weaponAttribute = key.split(`${getReprowid}_`)[1]
+ const weaponAttribute = processingFunctions.getReprowAttribute(key)
const primaryAttributeName = key.includes('weapon') ? `primary_${type}_weapon` : `primary_${type}_weapon_${weaponAttribute}`
update[primaryAttributeName] = value
@@ -3674,11 +3719,18 @@ const updateSpellsDicepool = eventinfo => {
const resetNpcCondition = () => setAttributes({physical: 0, stun: 0, matrix: 0})
-const updatePrimaryWeapon = eventinfo => {
+const updatePrimary = eventinfo => {
const repRowID = processingFunctions.getReprowid(eventinfo.triggerName)
getAttrs([`${repRowID}_primary`], attrs => {
if (attrs[`${repRowID}_primary`] === 'primary') {
- let update = processingFunctions.shadowrun.updatePrimaryWeapons({[eventinfo.triggerName]: eventinfo.newValue})
+ let update = {}
+
+ if (repRowID.includes('armor')) {
+ update = processingFunctions.shadowrun.updatePrimaryArmor({[eventinfo.triggerName]: eventinfo.newValue})
+ } else {
+ update = processingFunctions.shadowrun.updatePrimaryWeapons({[eventinfo.triggerName]: eventinfo.newValue})
+ }
+
processingFunctions.setAttributes(update)
}
})
@@ -3699,6 +3751,21 @@ const updateRepeatingWeaponPrimary = (eventinfo, type) => {
}
}
+const updateRepeatingArmorPrimary = eventinfo => {
+ const repRowID = processingFunctions.getReprowid(eventinfo.triggerName)
+ if (eventinfo.newValue === 'primary') {
+ const constructedArmorAttributes = processingFunctions.shadowrun.addRepRow(repRowID, sheetAttributes.armorAttributes)
+ getAttrs(constructedArmorAttributes, attrs => {
+ const update = processingFunctions.shadowrun.updatePrimaryArmor(attrs)
+ processingFunctions.setAttributes(update)
+ })
+ processingFunctions.shadowrun.resetRepeatingFieldsPrimaries(`repeating_armor`, repRowID)
+ } else {
+ const update = processingFunctions.shadowrun.resetPrimaryArmor()
+ processingFunctions.setAttributes(update)
+ }
+}
+
const updateRepeatingWeaponDicepool = trigger => {
const repRowID = processingFunctions.getReprowid(trigger)
getAttrs([`${repRowID}_dicepool_modifier`, `${repRowID}_specialization`], attrs => {
@@ -3859,113 +3926,24 @@ const updateDerivedAttribute = derivedAttribute => {
})
}
+const updateInitiativeDice = () => {
+ getAttrs(["initiative_dice_modifier", "edge_toggle", "initiative_dice_temp", "initiative_dice_temp_flag"], values => {
+ const edgeFlag = values.edge_toggle === "@{edge}" ? true : false;
+ values = processingFunctions.shadowrun.processTempFlags(values)
+ values = processingFunctions.parseIntegers(values)
+ const bonus = processingFunctions.shadowrun.calculateBonuses(values)
+ const total = Math.min(values.bonus+1,5)
+ processingFunctions.setAttributes({
+ initiative_dice: edgeFlag ? 5 : total
+ })
+ })
+}
-
+const resetConditionTrack = eventinfo => {
+ const attr = eventinfo.triggerName.split("_").pop();
+ processingFunctions.setAttributes({[`${attr}`] : 0})
+}
- //This function checks changes to repeating_armor and updates the Primary Armor if needed
- on("change:repeating_armor", (eventInfo) => {
- const source = eventInfo.sourceAttribute;
- const newV = eventInfo.newValue;
- const arm = ["repeating_armor"];
- const armors = [`${arm}_name`, `${arm}_rating`, `${arm}_acid_modifier`, `${arm}_electrical_modifier`, `${arm}_cold_modifier`,`${arm}_fire_modifier`, `${arm}_radiation_modifier`, `${arm}_dicepool_modifier`];
-
- //Check if the event was related to the primary flag & armor is set to primary
- if (source.includes('primary') && newV === 'primary') {
- //Get attributes from the repeating_armor
- getAttrs(armors, (v) => {
- let update = {};
- //Update the hidden static Primary Armor attributes with the repeating_armor attributes
- _.each(armors, (armor) => {
- const name = (armor.includes("name") || armor.includes("rating")) ? armor.split("repeating_")[1] : armor.split(`${arm}_`)[1];
- update[`${name}`] = v[`${armor}`];
- });
-
- setAttrs(update);
- });
-
- //Set the other repeating_armor primary flags to 0 aka unchecked
- getSectionIDs(`${arm}`, function(ids) {
- let IDs = [];
- let update = {};
-
- for(var i=0; i < ids.length; i++) {
- IDs.push(`${arm}_` + ids[i] + "_primary");
- };
-
- IDs.forEach(id => {
- if (id != source) {
- update[`${id}`] = 0;
- };
- });
-
- setAttrs(update);
- });
- //Check if the event was for a relevant Primary Armor attribute
- } else if (source.includes('name') || source.includes('rating') || source.includes('dicepool') || source.includes('acid') || source.includes('cold') || source.includes('electrical') || source.includes('fire') || source.includes('radiation')) {
- //Get the primary flag attribute for this armor. Also get the repeating_armor attribute we'll need for an update, doing it now is more efficient.
- getAttrs([`${arm}_primary`, `${source}`], (v) => {
- //Check if this armor is the designated Primary Armor.
- if (v[`${arm}_primary`] === 'primary') {
- let update = {};
- //Apply the repeating_armor attribute to its static counterpart
- switch (true) {
- case /name/.test(source) : update["armor_name"] = v[`${source}`]; break;
- case /rating/.test(source) : update["armor_rating"] = v[`${source}`]; break;
- case /dicepool/.test(source) : update["soak_modifier"] = v[`${source}`]; break;
- case /acid/.test(source) : update["acid_modifier"] = v[`${source}`]; break;
- case /cold/.test(source) : update["cold_modifier"] = v[`${source}`]; break;
- case /electrical/.test(source): update["electrical_modifier"] = v[`${source}`]; break;
- case /fire/.test(source) : update["fire_modifier"] = v[`${source}`]; break;
- case /radiation/.test(source) : update["radiation_modifier"] = v[`${source}`]; break;
- default: console.log(`Source ${source} was invalid`);}
-
- setAttrs(update);
- };
- });
- } else {
- console.log("CHANGE NOT RELEVENT Primary Armor");
- };
- });
-
- const updateInitiativeDice = () => {
- getAttrs(["initiative_dice_modifier", "edge_toggle", "initiative_dice_temp", "initiative_dice_temp_flag"], values => {
- console.log(values)
- const edgeFlag = values.edge_toggle === "@{edge}" ? true : false;
-
- values = processingFunctions.shadowrun.processTempFlags(values)
- values = processingFunctions.parseIntegers(values)
-
- const bonus = processingFunctions.shadowrun.calculateBonuses(values)
- const total = Math.min(values.bonus+1,5);
- setAttrs({
- initiative_dice: edgeFlag ? 5 : total
- });
- });
- };
-
- //Calculate Astral Initiatve
- const updateAstralInitiative = () => {
- getAttrs(["intuition", "astral_mod_modifier"], v => {
- v = processingFunctions.parseIntegers(v);
- const base = v.intuition * 2, bonus = v.astral_mod_modifier, total = base + bonus;
-
- setAttrs({
- ["astral_mod"]: total,
- ["display_astral_mod"]: bonus === 0 ? base : `${base} (${total})`
- });
- });
- };
-
- const updateAstralInitiativeDice = () => {
- getAttrs(["astral_dice_modifier", "edge_toggle"], v => {
- const edgeFlag = v.edge_toggle === "@{edge}" ? true : false;
- const bonus = parseInt(v.astral_dice_modifier) || 0;
-
- setAttrs({
- astral_dice: edgeFlag ? 5 : Math.min(bonus+3,5)
- });
- });
- };
//Calculate Matrix Initiatve.
const updateMatrixInitiative = () => {
@@ -3988,12 +3966,6 @@ const updateDerivedAttribute = derivedAttribute => {
});
};
- const resetConditionTrack = eventinfo => {
- const attr = eventinfo.triggerName.split("_").pop();
- setAttrs({
- [`${attr}`] : 0
- });
- }
//Weapon displays set into an Array
// Builder function to display details properly
@@ -4339,9 +4311,13 @@ const onepointthreefive = () => {
on(`change:repeating_${type}:primary`, eventinfo => updateRepeatingWeaponPrimary(eventinfo, type))
})
- sheetAttributes.rangeAttributes.forEach(attr => on(`change:repeating_range:${attr}`, eventinfo => updatePrimaryWeapon(eventinfo)))
+ sheetAttributes.rangeAttributes.forEach(attr => on(`change:repeating_range:${attr}`, eventinfo => updatePrimary(eventinfo)))
- sheetAttributes.meleeAttributes.forEach(attr => on(`change:repeating_melee:${attr}`, eventinfo => updatePrimaryWeapon(eventinfo)))
+ sheetAttributes.meleeAttributes.forEach(attr => on(`change:repeating_melee:${attr}`, eventinfo => updatePrimary(eventinfo)))
+
+ sheetAttributes.armorAttributes.forEach(attr => on(`change:repeating_armor:${attr}`, eventinfo => updatePrimary(eventinfo)))
+
+ on("change:repeating_armor:primary", eventinfo => updateRepeatingArmorPrimary(eventinfo))
on(`change:repeating_active:skill`, eventinfo => updateRepeatingSkillName(eventinfo))
@@ -4367,6 +4343,8 @@ const onepointthreefive = () => {
on("change:host_rating", eventinfo => updateHostAttributes(eventinfo.newValue))
+
+
//IMPORTERS
const importHeroLab = (character) => {
diff --git a/Shadowrun5thEdition/Shadowrun5thEdition.pug b/Shadowrun5thEdition/Shadowrun5thEdition.pug
index b0316af753..29faac12f8 100644
--- a/Shadowrun5thEdition/Shadowrun5thEdition.pug
+++ b/Shadowrun5thEdition/Shadowrun5thEdition.pug
@@ -315,14 +315,14 @@ include src/pug/_variables.pug
each val, key in pcArmorObject
- const attrName = key === 'Name' || key === 'Rating' ? key.toLowerCase() : `${key.toLowerCase()}_modifier`;
label(data-i18n-title=key.toLowerCase() title=key.toLowerCase())
- input(name=`attr_${attrName}` placeholder=val['placeholder'] title=`@{repeating_armor_`+'${x}'+`_${attrName}}` type=val['type'] value='')
+ input(name=`attr_${attrName}` placeholder=val['placeholder'] title=`@{${armorRepeatingSection}_${attrName}}` type=val['type'] value='')
.row
h3(data-i18n='primary') primary
label(data-i18n-title='primary' title='Primary')
- input(name='attr_primary' type='checkbox' title=`${armorRepeatingSection}_primary}` value='primary')
+ input(name='attr_primary' type='checkbox' title=`@{${armorRepeatingSection}_primary}` value='primary')
h3(data-i18n='modifier') modifier
label(data-i18n-title='modifier' title='modifier')
- input(name='attr_dicepool_modifier' placeholder='0' title=`${armorRepeatingSection}_dicepool_modifier}` type='number' value='0')
+ input(name='attr_dicepool_modifier' placeholder='0' title=`@{${armorRepeatingSection}_dicepool_modifier}` type='number' value='0')
+repeatingSectionNotes('armor')
//- AUGS TAB
@@ -649,6 +649,7 @@ script(type="text/worker")
include src/js/attributes.js
include src/js/Classes/PrimaryWeapon.js
+ include src/js/Classes/PrimaryArmor.js
include src/js/processingFunctions.js
diff --git a/Shadowrun5thEdition/images/Blackbackground.jpg b/Shadowrun5thEdition/images/Blackbackground.jpg
deleted file mode 100644
index 1cb8c34f05..0000000000
Binary files a/Shadowrun5thEdition/images/Blackbackground.jpg and /dev/null differ
diff --git a/Shadowrun5thEdition/images/EProd_Emerald_Gloss.png b/Shadowrun5thEdition/images/EProd_Emerald_Gloss.png
deleted file mode 100644
index 5f1fa90a44..0000000000
Binary files a/Shadowrun5thEdition/images/EProd_Emerald_Gloss.png and /dev/null differ
diff --git a/Shadowrun5thEdition/images/EProd_Title_Green.jpg b/Shadowrun5thEdition/images/EProd_Title_Green.jpg
deleted file mode 100644
index 5cef8d391e..0000000000
Binary files a/Shadowrun5thEdition/images/EProd_Title_Green.jpg and /dev/null differ
diff --git a/Shadowrun5thEdition/images/ShadowrunLogo.png b/Shadowrun5thEdition/images/ShadowrunLogo.png
deleted file mode 100644
index 0773340e97..0000000000
Binary files a/Shadowrun5thEdition/images/ShadowrunLogo.png and /dev/null differ
diff --git a/Shadowrun5thEdition/images/gun.png b/Shadowrun5thEdition/images/gun.png
deleted file mode 100644
index f1566799ae..0000000000
Binary files a/Shadowrun5thEdition/images/gun.png and /dev/null differ
diff --git a/Shadowrun5thEdition/src/html/hidden.html b/Shadowrun5thEdition/src/html/hidden.html
index c9454cf9b4..d53ae95e76 100644
--- a/Shadowrun5thEdition/src/html/hidden.html
+++ b/Shadowrun5thEdition/src/html/hidden.html
@@ -4,12 +4,8 @@
-
-
-
-
-
-
+
+
diff --git a/Shadowrun5thEdition/src/js/Classes/PrimaryArmor.js b/Shadowrun5thEdition/src/js/Classes/PrimaryArmor.js
new file mode 100644
index 0000000000..b9dc122792
--- /dev/null
+++ b/Shadowrun5thEdition/src/js/Classes/PrimaryArmor.js
@@ -0,0 +1,16 @@
+
+class PrimaryArmor {
+ constructor(name) {
+ this.armor_name = name || 'select a Primary in Arms',
+ this.soak = 0,
+ this.soak_modifier = 0,
+ this.armor_rating = 0,
+ this.acid_modifier = 0,
+ this.cold_modifier = 0,
+ this.fire_modifier = 0,
+ this.radiation_modifier = 0,
+ this.electrical_modifier = 0
+ }
+}
+
+
diff --git a/Shadowrun5thEdition/src/js/attributes.js b/Shadowrun5thEdition/src/js/attributes.js
index bfee2a223f..0c8ec5e658 100644
--- a/Shadowrun5thEdition/src/js/attributes.js
+++ b/Shadowrun5thEdition/src/js/attributes.js
@@ -41,6 +41,10 @@ const sheetAttributes = {
rangeAttributes: ['dicepool', 'weapon', 'damage', 'acc', 'ap', 'skill', 'ammo', 'mode', 'recoil'],
meleeAttributes: ['dicepool', 'weapon', 'damage', 'acc', 'ap', 'skill', 'reach'],
- spellTypes: ['spell', 'preps', 'ritual', 'forms']
+ spellTypes: ['spell', 'preps', 'ritual', 'forms'],
+
+ armorAttributes: ['name', 'rating', 'acid_modifier', 'electrical_modifier', 'cold_modifier', 'fire_modifier', 'radiation_modifier', 'dicepool_modifier'],
+ armorSoak: ['dicepool_modifier', 'rating'],
+ armorProtections: ['acid', 'electrical', 'cold', 'fire', 'radiation']
}
diff --git a/Shadowrun5thEdition/src/js/eventhandlers.js b/Shadowrun5thEdition/src/js/eventhandlers.js
index 996a57af3d..8ab87ba6ac 100644
--- a/Shadowrun5thEdition/src/js/eventhandlers.js
+++ b/Shadowrun5thEdition/src/js/eventhandlers.js
@@ -50,9 +50,13 @@
on(`change:repeating_${type}:primary`, eventinfo => updateRepeatingWeaponPrimary(eventinfo, type))
})
- sheetAttributes.rangeAttributes.forEach(attr => on(`change:repeating_range:${attr}`, eventinfo => updatePrimaryWeapon(eventinfo)))
+ sheetAttributes.rangeAttributes.forEach(attr => on(`change:repeating_range:${attr}`, eventinfo => updatePrimary(eventinfo)))
- sheetAttributes.meleeAttributes.forEach(attr => on(`change:repeating_melee:${attr}`, eventinfo => updatePrimaryWeapon(eventinfo)))
+ sheetAttributes.meleeAttributes.forEach(attr => on(`change:repeating_melee:${attr}`, eventinfo => updatePrimary(eventinfo)))
+
+ sheetAttributes.armorAttributes.forEach(attr => on(`change:repeating_armor:${attr}`, eventinfo => updatePrimary(eventinfo)))
+
+ on("change:repeating_armor:primary", eventinfo => updateRepeatingArmorPrimary(eventinfo))
on(`change:repeating_active:skill`, eventinfo => updateRepeatingSkillName(eventinfo))
@@ -78,3 +82,5 @@
on("change:host_rating", eventinfo => updateHostAttributes(eventinfo.newValue))
+
+
diff --git a/Shadowrun5thEdition/src/js/newScripts.js b/Shadowrun5thEdition/src/js/newScripts.js
index 53b53f5cb7..b471cfd075 100644
--- a/Shadowrun5thEdition/src/js/newScripts.js
+++ b/Shadowrun5thEdition/src/js/newScripts.js
@@ -33,11 +33,18 @@ const updateSpellsDicepool = eventinfo => {
const resetNpcCondition = () => setAttributes({physical: 0, stun: 0, matrix: 0})
-const updatePrimaryWeapon = eventinfo => {
+const updatePrimary = eventinfo => {
const repRowID = processingFunctions.getReprowid(eventinfo.triggerName)
getAttrs([`${repRowID}_primary`], attrs => {
if (attrs[`${repRowID}_primary`] === 'primary') {
- let update = processingFunctions.shadowrun.updatePrimaryWeapons({[eventinfo.triggerName]: eventinfo.newValue})
+ let update = {}
+
+ if (repRowID.includes('armor')) {
+ update = processingFunctions.shadowrun.updatePrimaryArmor({[eventinfo.triggerName]: eventinfo.newValue})
+ } else {
+ update = processingFunctions.shadowrun.updatePrimaryWeapons({[eventinfo.triggerName]: eventinfo.newValue})
+ }
+
processingFunctions.setAttributes(update)
}
})
@@ -58,6 +65,21 @@ const updateRepeatingWeaponPrimary = (eventinfo, type) => {
}
}
+const updateRepeatingArmorPrimary = eventinfo => {
+ const repRowID = processingFunctions.getReprowid(eventinfo.triggerName)
+ if (eventinfo.newValue === 'primary') {
+ const constructedArmorAttributes = processingFunctions.shadowrun.addRepRow(repRowID, sheetAttributes.armorAttributes)
+ getAttrs(constructedArmorAttributes, attrs => {
+ const update = processingFunctions.shadowrun.updatePrimaryArmor(attrs)
+ processingFunctions.setAttributes(update)
+ })
+ processingFunctions.shadowrun.resetRepeatingFieldsPrimaries(`repeating_armor`, repRowID)
+ } else {
+ const update = processingFunctions.shadowrun.resetPrimaryArmor()
+ processingFunctions.setAttributes(update)
+ }
+}
+
const updateRepeatingWeaponDicepool = trigger => {
const repRowID = processingFunctions.getReprowid(trigger)
getAttrs([`${repRowID}_dicepool_modifier`, `${repRowID}_specialization`], attrs => {
@@ -218,4 +240,20 @@ const updateDerivedAttribute = derivedAttribute => {
})
}
+const updateInitiativeDice = () => {
+ getAttrs(["initiative_dice_modifier", "edge_toggle", "initiative_dice_temp", "initiative_dice_temp_flag"], values => {
+ const edgeFlag = values.edge_toggle === "@{edge}" ? true : false;
+ values = processingFunctions.shadowrun.processTempFlags(values)
+ values = processingFunctions.parseIntegers(values)
+ const bonus = processingFunctions.shadowrun.calculateBonuses(values)
+ const total = Math.min(values.bonus+1,5)
+ processingFunctions.setAttributes({
+ initiative_dice: edgeFlag ? 5 : total
+ })
+ })
+}
+const resetConditionTrack = eventinfo => {
+ const attr = eventinfo.triggerName.split("_").pop();
+ processingFunctions.setAttributes({[`${attr}`] : 0})
+}
\ No newline at end of file
diff --git a/Shadowrun5thEdition/src/js/processingFunctions.js b/Shadowrun5thEdition/src/js/processingFunctions.js
index 464fafa019..d97728664c 100644
--- a/Shadowrun5thEdition/src/js/processingFunctions.js
+++ b/Shadowrun5thEdition/src/js/processingFunctions.js
@@ -5,16 +5,20 @@ const processingFunctions = {
convertIntegersNegatives: numbers => {
for (let [key, value] of Object.entries(numbers)) {
numbers[key] = processingFunctions.convertIntegerNegative(value);
- }calculateConditionTracks
+ }
return numbers
},
findRepeatingField: trigger => trigger.split('_')[1],
//Roll20 does not allow for Promises
//getAttributes: array => new Promise((resolve, reject) => array ? getAttrs(array, v => resolve(v)) : reject(errorMessage('Function failed'))),
- getReprowid: trigger => {calculateConditionTracks
+ getReprowid: trigger => {
const split = trigger.split('_');
return `${split[0]}_${split[1]}_${split[2]}`
},
+ getReprowAttribute: key => {
+ const getReprowid = processingFunctions.getReprowid(key)
+ return key.split(`${getReprowid}_`)[1]
+ },
getTranslations: translationKeys => {
let translations = {}
translationKeys.forEach(key => translations[`${key}`] = getTranslationByKey(key))
@@ -121,6 +125,14 @@ const processingFunctions = {
attrs.essence ? Math.ceil(attrs.essence) || 0 : false;
return processingFunctions.shadowrun.calculateLimitTotal(Object.values(attrs))
},
+ resetPrimaryArmor: () => {
+ const resetPrimary = new PrimaryArmor()
+ let update = {}
+ for (let [key, value] of Object.entries(resetPrimary)) {
+ update[key] = value
+ }
+ return update
+ },
resetPrimaryWeapon: type => {
const resetPrimary = type === 'range' ? new PrimaryRangeWeapon(type) : new PrimaryMeleeWeapon(type)
let update = {}
@@ -129,12 +141,30 @@ const processingFunctions = {
}
return update
},
+ updatePrimaryArmor: attrs => {
+ let update = {}
+
+ for (let [key, value] of Object.entries(attrs)) {
+ const repRowID = processingFunctions.getReprowid(key)
+ if (key.includes('name')) {
+ update['armor_name'] = attrs[`${repRowID}_name`]
+ } else if (key.includes('rating')) {
+ update['armor_rating'] = value
+ } else if (key.includes('dicepool_modifier')) {
+ update['soak_modifier'] = value
+ } else {
+ const type = key.split('_')[3]
+ update[`${type}_modifier`] = value
+ }
+ }
+
+ return update
+ },
updatePrimaryWeapons: attrs => {
let update = {}
for (let [key, value] of Object.entries(attrs)) {
const type = processingFunctions.findRepeatingField(key)
- const getReprowid = processingFunctions.getReprowid(key)
- const weaponAttribute = key.split(`${getReprowid}_`)[1]
+ const weaponAttribute = processingFunctions.getReprowAttribute(key)
const primaryAttributeName = key.includes('weapon') ? `primary_${type}_weapon` : `primary_${type}_weapon_${weaponAttribute}`
update[primaryAttributeName] = value
diff --git a/Shadowrun5thEdition/src/js/scripts.js b/Shadowrun5thEdition/src/js/scripts.js
index 5133a51a7a..155fccd58a 100644
--- a/Shadowrun5thEdition/src/js/scripts.js
+++ b/Shadowrun5thEdition/src/js/scripts.js
@@ -1,108 +1,4 @@
- //This function checks changes to repeating_armor and updates the Primary Armor if needed
- on("change:repeating_armor", (eventInfo) => {
- const source = eventInfo.sourceAttribute;
- const newV = eventInfo.newValue;
- const arm = ["repeating_armor"];
- const armors = [`${arm}_name`, `${arm}_rating`, `${arm}_acid_modifier`, `${arm}_electrical_modifier`, `${arm}_cold_modifier`,`${arm}_fire_modifier`, `${arm}_radiation_modifier`, `${arm}_dicepool_modifier`];
-
- //Check if the event was related to the primary flag & armor is set to primary
- if (source.includes('primary') && newV === 'primary') {
- //Get attributes from the repeating_armor
- getAttrs(armors, (v) => {
- let update = {};
- //Update the hidden static Primary Armor attributes with the repeating_armor attributes
- _.each(armors, (armor) => {
- const name = (armor.includes("name") || armor.includes("rating")) ? armor.split("repeating_")[1] : armor.split(`${arm}_`)[1];
- update[`${name}`] = v[`${armor}`];
- });
-
- setAttrs(update);
- });
-
- //Set the other repeating_armor primary flags to 0 aka unchecked
- getSectionIDs(`${arm}`, function(ids) {
- let IDs = [];
- let update = {};
-
- for(var i=0; i < ids.length; i++) {
- IDs.push(`${arm}_` + ids[i] + "_primary");
- };
-
- IDs.forEach(id => {
- if (id != source) {
- update[`${id}`] = 0;
- };
- });
-
- setAttrs(update);
- });
- //Check if the event was for a relevant Primary Armor attribute
- } else if (source.includes('name') || source.includes('rating') || source.includes('dicepool') || source.includes('acid') || source.includes('cold') || source.includes('electrical') || source.includes('fire') || source.includes('radiation')) {
- //Get the primary flag attribute for this armor. Also get the repeating_armor attribute we'll need for an update, doing it now is more efficient.
- getAttrs([`${arm}_primary`, `${source}`], (v) => {
- //Check if this armor is the designated Primary Armor.
- if (v[`${arm}_primary`] === 'primary') {
- let update = {};
- //Apply the repeating_armor attribute to its static counterpart
- switch (true) {
- case /name/.test(source) : update["armor_name"] = v[`${source}`]; break;
- case /rating/.test(source) : update["armor_rating"] = v[`${source}`]; break;
- case /dicepool/.test(source) : update["soak_modifier"] = v[`${source}`]; break;
- case /acid/.test(source) : update["acid_modifier"] = v[`${source}`]; break;
- case /cold/.test(source) : update["cold_modifier"] = v[`${source}`]; break;
- case /electrical/.test(source): update["electrical_modifier"] = v[`${source}`]; break;
- case /fire/.test(source) : update["fire_modifier"] = v[`${source}`]; break;
- case /radiation/.test(source) : update["radiation_modifier"] = v[`${source}`]; break;
- default: console.log(`Source ${source} was invalid`);}
-
- setAttrs(update);
- };
- });
- } else {
- console.log("CHANGE NOT RELEVENT Primary Armor");
- };
- });
-
- const updateInitiativeDice = () => {
- getAttrs(["initiative_dice_modifier", "edge_toggle", "initiative_dice_temp", "initiative_dice_temp_flag"], values => {
- console.log(values)
- const edgeFlag = values.edge_toggle === "@{edge}" ? true : false;
-
- values = processingFunctions.shadowrun.processTempFlags(values)
- values = processingFunctions.parseIntegers(values)
-
- const bonus = processingFunctions.shadowrun.calculateBonuses(values)
- const total = Math.min(values.bonus+1,5);
- setAttrs({
- initiative_dice: edgeFlag ? 5 : total
- });
- });
- };
-
- //Calculate Astral Initiatve
- const updateAstralInitiative = () => {
- getAttrs(["intuition", "astral_mod_modifier"], v => {
- v = processingFunctions.parseIntegers(v);
- const base = v.intuition * 2, bonus = v.astral_mod_modifier, total = base + bonus;
-
- setAttrs({
- ["astral_mod"]: total,
- ["display_astral_mod"]: bonus === 0 ? base : `${base} (${total})`
- });
- });
- };
-
- const updateAstralInitiativeDice = () => {
- getAttrs(["astral_dice_modifier", "edge_toggle"], v => {
- const edgeFlag = v.edge_toggle === "@{edge}" ? true : false;
- const bonus = parseInt(v.astral_dice_modifier) || 0;
-
- setAttrs({
- astral_dice: edgeFlag ? 5 : Math.min(bonus+3,5)
- });
- });
- };
//Calculate Matrix Initiatve.
const updateMatrixInitiative = () => {
@@ -125,12 +21,6 @@
});
};
- const resetConditionTrack = eventinfo => {
- const attr = eventinfo.triggerName.split("_").pop();
- setAttrs({
- [`${attr}`] : 0
- });
- }
//Weapon displays set into an Array
// Builder function to display details properly
diff --git a/Shadowrun5thEdition/src/static.html b/Shadowrun5thEdition/src/static.html
index 6d271210d1..b1b6cd0f2a 100644
--- a/Shadowrun5thEdition/src/static.html
+++ b/Shadowrun5thEdition/src/static.html
@@ -37,7 +37,7 @@
x
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
diff --git a/Shadowrun5thEdition/src/test/Processing_tests.js b/Shadowrun5thEdition/src/test/Processing_tests.js
index 5d38455c7d..770de5c84c 100644
--- a/Shadowrun5thEdition/src/test/Processing_tests.js
+++ b/Shadowrun5thEdition/src/test/Processing_tests.js
@@ -292,5 +292,3 @@ describe('Shadowrun updatePrimaryWeapons', () => {
assert.deepStrictEqual(actual, {"primary_range_weapon_ammo": 12, "primary_range_weapon_ammo_max": 12})
})
})
-
-