diff --git a/Wrath and Glory API/wrath_and_glory_api.html b/Wrath and Glory API/wrath_and_glory_api.html
index 7bd53315b6..80c44b493d 100644
--- a/Wrath and Glory API/wrath_and_glory_api.html
+++ b/Wrath and Glory API/wrath_and_glory_api.html
@@ -1,5 +1,7 @@
-
+
+
+
-
@@ -403,58 +411,6 @@
-
-
-
-
@@ -473,7 +429,7 @@
Assist |
- Athletics |
+ Athletics |
|
|
- Awareness |
+ Awareness |
|
|
- Ballistic Skill |
+ Ballistic Skill |
|
|
- Cunning |
+ Cunning |
|
|
- Deception |
+ Deception |
|
|
- Insight |
+ Insight |
|
|
- Intimidation |
+ Intimidation |
|
|
- Investigation |
+ Investigation |
|
|
- Leadership |
+ Leadership |
|
|
- Medicae |
+ Medicae |
|
|
- Persuasion |
+ Persuasion |
|
|
- Pilot |
+ Pilot |
|
|
- Psychic Mastery |
+ Psychic Mastery |
|
|
- Scholar |
+ Scholar |
|
|
- Stealth |
+ Stealth |
|
|
- Survival |
+ Survival |
|
|
- Tech |
+ Tech |
|
|
- Weapon Skill |
+ Weapon Skill |
|
|
-
-
@@ -2384,15 +2390,15 @@
|
- |
- Mel? |
- W DR |
- +Str |
+ NB |
+ Mel? |
+ Frc? |
+ Base DR |
DR |
+ED |
AP |
- Salvo |
- Empty? |
+ Salvo |
+ EMTY? |
Rng |
|
Rating |
@@ -2405,62 +2411,62 @@
+
+
@@ -3049,11 +3055,12 @@
-
+ Value A
+ Value B
+ Value C
+ Value D
+ Value E
+ Value F -->
@@ -3121,22 +3128,130 @@
//******************************** Open Sheet ************************************************
//********************************************************************************************
-
+
// EXECUTE: When the sheet is opened, update score fields for anyone using an older sheet.
on('sheet:opened',function(){
- // Update corruption labels
- getAttrs(["corrbase"], function(values) {
- var corruption = (values.corrbase)*1;
- corruption = Math.max(0,corruption); // corruption does not go below 0; throws an error on the lookup if below 0
- corruption = Math.min(30,corruption); // corruption does not go above 30; throws an error on the lookup if above 30
- var label = lookup_corruption_lvl(corruption);
- var dn = lookup_corruption_dn(corruption);
-
- setAttrs({CorrLevel:label});
- setAttrs({CorrResistDN:dn});
+ getAttrs(["sheetversion"], function(values) {
+ var version = (values.sheetversion)*1;
+ // section 2.2 and lower update
+ if(version < 2.2) {
+
+ // Update corruption labels
+ getAttrs(["corrbase"], function(values) {
+ var corruption = (values.corrbase)*1;
+ corruption = Math.max(0,corruption); // corruption does not go below 0; throws an error on the lookup if below 0
+ corruption = Math.min(30,corruption); // corruption does not go above 30; throws an error on the lookup if above 30
+ var label = lookup_corruption_lvl(corruption);
+ var dn = lookup_corruption_dn(corruption);
+ setAttrs({CorrLevel:label});
+ setAttrs({CorrResistDN:dn});
+ });
+
+ // handle changes to wound and shock changes to enable token max + set Heavy and Light wound levels
+ getAttrs(["shockcurrent","woundscurrent","tier","tghbase","tghmod","woundsmod","customtier","willbase","willmod","shockmod"], function(values) {
+ var sc = (values.shockcurrent*1);
+ var wc = (values.woundscurrent*1);
+
+ // set current wounds and shock = to old values
+ setAttrs({wounds:wc});
+ setAttrs({shock:sc});
+
+
+ // calculate wound max and shock max
+ var t = (values.tier)*1;
+ var tgh = ((values.tghbase)*1)+((values.tghmod)*1);
+ var wm = (values.woundsmod)*1;
+ var will = ((values.willbase)*1)+((values.willmod)*1);
+ var sm = (values.shockmod)*1;
+ var ct = (values.customtier)*1;
+ var totalw = tgh + t + wm;
+ var totals = will + t + sm;
+
+ if(t === 6) {
+ totalw = tgh + ct + wm;
+ totals = will + ct + sm;
+ }
+ if(t < 6) {
+ setAttrs({customtier:0});
+ }
+
+ // set new max values
+ setAttrs({shock_max:totals});
+ setAttrs({wounds_max:totalw});
+ // set old values to new totals
+ setAttrs({shockcurrent:totals});
+ setAttrs({woundscurrent:totalw});
+
+ var maxwnd = totalw*1;
+ var wndl = 0;
+ var wndh = 0;
+
+ // calculate and set lighly wounded and heavily wounded
+ if(maxwnd > 1) {
+ wndl = Math.ceil(.5*maxwnd);
+ wndh = wndl + 1;
+ }
+
+ setAttrs({lightwound: wndl});
+ setAttrs({heavywound: wndh});
+
+ });
+
+ // update weapon DR
+ getAttrs(["strbase","strmod","willbase","willmod","keywordpsyker"], function(values) {
+ var ispsyker = (values.keywordpsyker)*1;
+ var str = (values.strbase)*1 + (values.strmod)*1;
+ var will = (values.willbase)*1 + (values.willmod)*1;
+
+ var newdr = 0;
+ var ismelee = 0;
+ var isforce = 0;
+
+ // get all repeating rows and retrieve melee, force, and dr for all weapons
+ getSectionIDs("repeating_weapon", function(IDArray) {
+ var fieldNames = [];
+ _.each(IDArray, function(currentID, i) {
+ fieldNames.push("repeating_weapon_" + currentID + "_meleewpn");
+ fieldNames.push("repeating_weapon_" + currentID + "_forcewpn");
+ fieldNames.push("repeating_weapon_" + currentID + "_wpnbasedr");
+ fieldNames.push("repeating_weapon_" + currentID + "_wpndr");
+ });
+
+ // for each check if it is checked, if checked then set drstrmod
+ getAttrs(fieldNames, function(values) {
+ _.each(IDArray, function(currentID) {
+ newdr = parseInt((values["repeating_weapon_" + currentID + "_wpnbasedr"]));
+ ismelee = parseInt((values["repeating_weapon_" + currentID + "_meleewpn"]));
+ isforce = parseInt((values["repeating_weapon_" + currentID + "_forcewpn"]));
+
+ if(ismelee === 1) {
+ newdr = newdr + str;
+ }
+
+ if(isforce === 1) {
+ if(ispsyker === 1) {
+ newdr = newdr + Math.ceil(.5*will);
+ }
+ else {
+ newdr = Math.max(0, newdr - 2);
+ }
+ }
+
+ setAttrs({["repeating_weapon_" + currentID + "_wpndr"]: newdr});
+ });
+ });
+ });
+ });
+ // end of update weapon DR
+
+ } // END OF section 2.2 and lower update
+ });
+ // Update Version = to current release
+ getAttrs(["release","sheetversion"], function(values) {
+ var release = (values.release)*1;
+ setAttrs({sheetversion: release});
});
});
-
//******************************** Update Corruption Labels **********************************
//********************************************************************************************
on("change:corrbase", function() {
@@ -3151,53 +3266,150 @@
setAttrs({CorrResistDN:dn});
});
});
-
- //******************************** Update WPN +STR if weapon is melee ************************
+
+ //******************************** Update Custom when Tier <> 6 ******************************
//********************************************************************************************
- on("change:repeating_weapon:meleewpn", function() {
- getAttrs(["repeating_weapon_meleewpn","strbase","strmod"], function(values) {
- var checked = parseInt(values.repeating_weapon_meleewpn);
- var sb = (values.strbase)*1;
- var sm = (values.strmod)*1;
-
- if(checked === 1) {
- setAttrs({repeating_weapon_drstrmod: (sb+sm)});
- }
- else {
- setAttrs({repeating_weapon_drstrmod: 0});
+ on("change:tier", function() {
+ getAttrs(["tier"], function(values) {
+ var tier = (values.tier)*1;
+
+ if(tier < 6) {
+ setAttrs({customtier:0});
}
});
});
-
- //Update All Melee WPNS if StrAdj changes
- on("change:strbase change:strmod", function() {
- getAttrs(["strbase","strmod"], function(values) {
- var sb = (values.strbase)*1;
- var sm = (values.strmod)*1;
- var newstradj = 0;
- var checked = 0;
+ //******************************** AutoCalc Wounds and Shock *********************************
+ //********************************************************************************************
+ on("change:tier change:tghbase change:tghmod change:woundsmod change:customtier", function() {
+ getAttrs(["tier","tghbase","tghmod","woundsmod","customtier"], function(values) {
+ var t = (values.tier)*1;
+ var tgh = ((values.tghbase)*1)+((values.tghmod)*1);
+ var wm = (values.woundsmod)*1;
+ var ct = (values.customtier)*1;
+ var total = tgh + t + wm;
+ if(t === 6) {
+ total = tgh + ct + wm;
+ }
- // get all repeating rows and retrieve checked
+ setAttrs({wounds_max:total});
+ setAttrs({wounds:total});
+ });
+ });
+
+ on("change:tier change:willbase change:willmod change:shockmod change:customtier", function() {
+ getAttrs(["tier","willbase","willmod","shockmod","customtier"], function(values) {
+ var t = (values.tier)*1;
+ var will = ((values.willbase)*1)+((values.willmod)*1);
+ var sm = (values.shockmod)*1;
+ var ct = (values.customtier)*1;
+ var total = will + t + sm;
+
+ if(t === 6) {
+ total = will + ct + sm;
+ }
+
+ setAttrs({shock_max:total});
+ setAttrs({shock:total});
+ });
+ });
+ //******************************** Auto Calculate Weapon DR **********************************
+ //********************************************************************************************
+ // initiate on a change to: psyker keyword, willpower (base or mod), strength (base or mod), is a force weapon, is a melee weapon, weapon base DR
+ on("change:repeating_weapon:wpnbasedr change:repeating_weapon:meleewpn change:repeating_weapon:forcewpn", function() {
+ getAttrs(["repeating_weapon_meleewpn","repeating_weapon_forcewpn","repeating_weapon_wpnbasedr","strbase","strmod","willbase","willmod","keywordpsyker"], function(values) {
+ var ismelee = parseInt(values.repeating_weapon_meleewpn);
+ var isforce = parseInt(values.repeating_weapon_forcewpn);
+ var ispsyker = (values.keywordpsyker)*1;
+
+ var newdr = (values.repeating_weapon_wpnbasedr)*1;
+ var str = (values.strbase)*1 + (values.strmod)*1;
+ var will = (values.willbase)*1 + (values.willmod)*1;
+
+ if(ismelee === 1) {
+ newdr = newdr + str;
+ }
+
+ if(isforce === 1) {
+ if(ispsyker === 1) {
+ newdr = newdr + Math.ceil(.5*will);
+ }
+ else {
+ newdr = Math.max(0, newdr - 2);
+ }
+ }
+
+ setAttrs({repeating_weapon_wpndr: newdr});
+ });
+ });
+
+ //Update All Melee WPNS if Str, Willpower or Keyword Psyker changes
+ on("change:keywordpsyker change:willbase change:willmod change:strbase change:strmod", function() {
+ getAttrs(["strbase","strmod","willbase","willmod","keywordpsyker"], function(values) {
+ var ispsyker = (values.keywordpsyker)*1;
+ var str = (values.strbase)*1 + (values.strmod)*1;
+ var will = (values.willbase)*1 + (values.willmod)*1;
+
+ var newdr = 0;
+ var ismelee = 0;
+ var isforce = 0;
+
+ // get all repeating rows and retrieve melee, force, and dr for all weapons
getSectionIDs("repeating_weapon", function(IDArray) {
var fieldNames = [];
_.each(IDArray, function(currentID, i) {
fieldNames.push("repeating_weapon_" + currentID + "_meleewpn");
+ fieldNames.push("repeating_weapon_" + currentID + "_forcewpn");
+ fieldNames.push("repeating_weapon_" + currentID + "_wpnbasedr");
+ fieldNames.push("repeating_weapon_" + currentID + "_wpndr");
});
// for each check if it is checked, if checked then set drstrmod
getAttrs(fieldNames, function(values) {
_.each(IDArray, function(currentID) {
- newstradj = 0; //need to ensure the next iteration is 0
- checked = (values["repeating_weapon_" + currentID + "_meleewpn"]);
- checked = parseInt(checked);
- if(checked === 1) {newstradj = sb + sm;};
- setAttrs({["repeating_weapon_" + currentID + "_drstrmod"]: newstradj});
+ newdr = parseInt((values["repeating_weapon_" + currentID + "_wpnbasedr"]));
+ ismelee = parseInt((values["repeating_weapon_" + currentID + "_meleewpn"]));
+ isforce = parseInt((values["repeating_weapon_" + currentID + "_forcewpn"]));
+
+ if(ismelee === 1) {
+ newdr = newdr + str;
+ }
+
+ if(isforce === 1) {
+ if(ispsyker === 1) {
+ newdr = newdr + Math.ceil(.5*will);
+ }
+ else {
+ newdr = Math.max(0, newdr - 2);
+ }
+ }
+
+ setAttrs({["repeating_weapon_" + currentID + "_wpndr"]: newdr});
});
});
});
});
});
-
+ //******************************** Generate Wound Levels *************************************
+ //********************************************************************************************
+ on("change:wounds_max change:woundsmod", function() {
+ getAttrs(["wounds_max"], function(values) {
+ var wnd = (values.wounds_max)*1;
+ var wndl = 0;
+ var wndh = 0;
+
+ if(wnd < 2) {
+ wndl=0;
+ wndh=0;
+ }
+ else {
+ wndl = Math.ceil(.5*wnd);
+ wndh = wndl + 1;
+ }
+
+ setAttrs({lightwound: wndl});
+ setAttrs({heavywound: wndh});
+ });
+ });
//******************************** SUM XP EARNED & SPENT *************************************
//********************************************************************************************
@@ -3359,5 +3571,5 @@
case "default": return "--";
};
};
-
+