diff --git a/Shadowrun5thEdition/Shadowrun5thEdition.css b/Shadowrun5thEdition/Shadowrun5thEdition.css
index deb9d89eb1..32b962c60d 100644
--- a/Shadowrun5thEdition/Shadowrun5thEdition.css
+++ b/Shadowrun5thEdition/Shadowrun5thEdition.css
@@ -412,6 +412,14 @@
.sheet-core-combat h3 {
margin-right: 0px;}
+ .sheet-flag-primary + div {display: none;}
+
+ .sheet-flag-primary[value="primary"] + div {
+ display: inline;
+ margin-right: -5%;}
+
+ .sheet-flag-primary + div > span {font-family: "pictos";}
+
/***** PRIMARY ARMOR *****/
.sheet-cc-arm button[type="roll"] {
padding: 2px 3px;
diff --git a/Shadowrun5thEdition/Shadowrun5thEdition.html b/Shadowrun5thEdition/Shadowrun5thEdition.html
index 16c28746ab..a8cc84f019 100644
--- a/Shadowrun5thEdition/Shadowrun5thEdition.html
+++ b/Shadowrun5thEdition/Shadowrun5thEdition.html
@@ -906,7 +906,10 @@
-
+
@@ -3214,7 +3223,7 @@
//SOAK POOLS
var update_soak = function () {
- getAttrs(["body", "armor_rating", "soak_modifier", "soak_temp"], function(v){
+ getAttrs(["body", "armor_rating", "soak_modifier", "soak_temp"], function(v) {
const bod = parseInt(v.body) || 0;
const arm = parseInt(v.armor_rating) || 0;
const mod = parseInt(v.soak_modifier) || 0;
@@ -3225,25 +3234,76 @@
});
};
- //Set Primary Armor when the star is selected
- on("change:repeating_armor", function() {
- getAttrs(["repeating_armor_name", "repeating_armor_rating", "repeating_armor_acid_modifier", "repeating_armor_electrical_modifier", "repeating_armor_cold_modifier", "repeating_armor_fire_modifier", "repeating_armor_radiation_modifier", "repeating_armor_primary", "repeating_armor_dicepool_modifier"], function(v) {
- let update = {};
+ //This function checks changes to repeating_armor and updates the Primary Armor if needed
+ on("change:repeating_armor", function(eventInfo) {
+ const source = eventInfo.sourceAttribute;
+ const newV = eventInfo.newValue;
+ const arm = ["repeating_armor"];
- if (v.repeating_armor_primary === "primary") {
- update["armor_name"] = v.repeating_armor_name;
- if (v.repeating_armor_rating) {update["armor_rating"] = v.repeating_armor_rating};
- if (v.repeating_armor_dicepool_modifier) {update["soak_modifier"] = v.repeating_armor_dicepool_modifier};
- if (v.repeating_armor_acid_modifier) {update["acid_modifier"] = v.repeating_armor_acid_modifier};
- if (v.repeating_armor_cold_modifier) {update["cold_modifier"] = v.repeating_armor_cold_modifier};
- if (v.repeating_armor_electrical_modifier) {update["electrical_modifier"] = v.repeating_armor_electrical_modifier};
- if (v.repeating_armor_fire_modifier) {update["fire_modifier"] = v.repeating_armor_fire_modifier};
- if (v.repeating_armor_radiation_modifier) {update["radiation_modifier"] = v.repeating_armor_radiation_modifier};
+ //Check if the event was related to the primary flag
+ if (source.includes('primary')) {
+ //Check if the primary flag is set to primary
+ if (newV === 'primary') {
+ //Get attributes from the repeating_armor
+ getAttrs([`${arm}_name`, `${arm}_rating`, `${arm}_acid_modifier`, `${arm}_electrical_modifier`, `${arm}_cold_modifier`,`${arm}_fire_modifier`, `${arm}_radiation_modifier`, `${arm}_dicepool_modifier`], function(v) {
+ let update = {};
+ //Update the hidden static Primary Armor attributes with the repeating_armor attributes
+ update["armor_name"] = v[`${arm}_name`];
+ if (v[`${arm}_rating`]) {update["armor_rating"] = v[`${arm}_rating`]};
+ if (v[`${arm}_dicepool_modifier`]) {update["soak_modifier"] = v[`${arm}_dicepool_modifier`]};
+ if (v[`${arm}_acid_modifier`]) {update["acid_modifier"] = v[`${arm}_acid_modifier`]};
+ if (v[`${arm}_cold_modifier`]) {update["cold_modifier"] = v[`${arm}_cold_modifier`]};
+ if (v[`${arm}_electrical_modifier`]) {update["electrical_modifier"] = v[`${arm}_electrical_modifier`]};
+ if (v[`${arm}_fire_modifier`]) {update["fire_modifier"] = v[`${arm}_fire_modifier`]};
+ if (v[`${arm}_radiation_modifier`]) {update["radiation_modifier"] = v[`${arm}_radiation_modifier`]};
+
+ 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}`], function(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);
};
-
- setAttrs(update);
});
- });
+ } else {
+ console.log("CHANGE NOT RELEVENT Primary Armor");
+ };
+ });
var update_liftCarry = function () {
getAttrs(["body", "strength", "lift_carry_modifier"], function(v) {