Add in health data for passthrough.

Sasky [04-21-15 - 05:53]
Add in health data for passthrough.

Looks like there aren't any depenent on both, so should probably remove it from fitting when it isn't necessary.
Also formula display needs some work.
Filename
html/skillData.js
html/skillFormulas.html
scripts/dumpSetsJson.lua
scripts/dumpSkillDataJson.lua
scripts/inc/extract.lua
diff --git a/html/skillData.js b/html/skillData.js
index e7e8a2f..65ae6b7 100644
--- a/html/skillData.js
+++ b/html/skillData.js
@@ -140,6 +140,18 @@ SkillData.directive('skillDesc', function() {
 		}
 	};
 });
+
+SkillData.directive('formulaPart', function() {
+  return {
+	  restrict: 'E',
+	  scope: {
+		  label: '@',
+		  value: '@'
+	  },
+	  template: '<span ng-show="{{value > 0.0001}}"><span class="coef">{{value}}</span> &times; <span class="var">{{label}}</span> +</span>'
+  }
+})
+
 SkillData.directive("rsq", function() {
 	return {
 		scope: {
diff --git a/html/skillFormulas.html b/html/skillFormulas.html
index e9b172a..9de963c 100644
--- a/html/skillFormulas.html
+++ b/html/skillFormulas.html
@@ -53,8 +53,10 @@
             <h3 ng-show="{{skill.fit.length}} > 0">Formulas</h3>
             <div class="formula" ng-repeat="(id,fit) in skill.fit">
                 <span class="formulaID">{{id}}</span><div class="eqn">=
-                	<span class="coef">{{fit.mainCoef|number:6}}</span> &times; <span class="var">MainStat</span>
-                    + <span class="coef">{{fit.powerCoef|number:5}}</span> &times; <span class="var">Power</span></div>
+                	<formula-part value="{{fit.mainCoef|number:4}}" label="MainStat"></formula-part>
+                	<formula-part value="{{fit.healthCoef|number:4}}" label="Health"></formula-part>
+                	<formula-part value="{{fit.powerCoef|number:5}}" label="Power"></formula-part>
+                    <span class="coef">{{fit.intercept|number:2}}</span>
                 	<span class="rsq label {{fit.rsq|fitQualityClass}}">R<sup>2</sup>: {{fit.rsq|number:4}}</span>
             </div>
         </div>
diff --git a/scripts/dumpSetsJson.lua b/scripts/dumpSetsJson.lua
index b36deae..e79e2d2 100644
--- a/scripts/dumpSetsJson.lua
+++ b/scripts/dumpSetsJson.lua
@@ -42,7 +42,6 @@ local function addItemToSet(item)
 end

 local f = assert(io.open("gearSets.json", "w"))
-local i=1
 for _,item in pairs(setdata.items) do
     addItemToSet(item)
 end
diff --git a/scripts/dumpSkillDataJson.lua b/scripts/dumpSkillDataJson.lua
index e3da07f..4c22fe0 100644
--- a/scripts/dumpSkillDataJson.lua
+++ b/scripts/dumpSkillDataJson.lua
@@ -46,68 +46,72 @@ local outfile = {
 for skill_lvl,numbers in pairs(skilldata) do
     local skill = skill_lvl:gsub("..$","")
     local ref = skillref[skill]
-    local data = skillfull[ref.type][ref.line][skill]
+    if ref then
+        local data = skillfull[ref.type][ref.line][skill]

-    local skillInfo = {
-        name=skill,
-        type=ref.type,
-        line=ref.line,
-        rank=data.rank or 4, --Hardcoding rank 4, though possible want different ranks later
-        description=data.description,
-        descriptionHeader=data.descriptionHeader,
-        mechanic=u.getMechanicName(data.mechanic),
-        cost=data.cost,
-        target=data.targetDescription,
-        minRange=data.minRangeCM,
-        maxRange=data.maxRangeCM,
-        radius=data.radiusCM,
-        distance=data.distanceCM,
-        channeled=data.channeled,
-        castTime=data.castTime,
-        channelTime=data.channelTime,
-        durationMS=data.durationMS,
-    }
+        local skillInfo = {
+            name=skill,
+            type=ref.type,
+            line=ref.line,
+            rank=data.rank or 4, --Hardcoding rank 4, though possible want different ranks later
+            description=data.description,
+            descriptionHeader=data.descriptionHeader,
+            mechanic=u.getMechanicName(data.mechanic),
+            cost=data.cost,
+            target=data.targetDescription,
+            minRange=data.minRangeCM,
+            maxRange=data.maxRangeCM,
+            radius=data.radiusCM,
+            distance=data.distanceCM,
+            channeled=data.channeled,
+            castTime=data.castTime,
+            channelTime=data.channelTime,
+            durationMS=data.durationMS,
+        }

-    local lastFindPos = 1
-    local formulaNum = 1
-    local formulae = {}
-    skillInfo.fit = {}
-    for _,rawnumbers in ipairs(numbers) do
-        local fit = r:getFitData(rawnumbers)
-        local delta = 1E-5
-        if fit.main < delta then fit.main = 0 end
-        if fit.power < delta then fit.power = 0 end
-        if (fit.health or 0) < delta then fit.health = 0 end
-        if fit.int < delta then fit.int = 0 end
+        local lastFindPos = 1
+        local formulaNum = 1
+        local formulae = {}
+        skillInfo.fit = {}
+        for _,rawnumbers in ipairs(numbers) do
+            local fit = r:getFitData(rawnumbers)
+            local delta = 1E-5
+            if fit.main < delta then fit.main = 0 end
+            if fit.power < delta then fit.power = 0 end
+            if (fit.health or 0) < delta then fit.health = 0 end
+            if fit.int < delta then fit.int = 0 end

-        local desc = skillInfo.description
-        local start = desc:find("|c")
-        local _,fin = desc:find("|r")
-        local toReplace = desc:sub(start,fin)
+            local desc = skillInfo.description
+            local start = desc:find("|c")
+            local _,fin = desc:find("|r")
+            local toReplace = desc:sub(start,fin)

-        local formulasig = u.makeKey(fit.main, fit.power, fit.health, fit.int, fit.rsq)
-        if fit.const then
-            skillInfo.description = r:replaceNumberInDescription(desc, toReplace, fit.int)
-        else
-            if not formulae[formulasig] then
-                formulae[formulasig] = "##f" .. formulaNum .. "##"
-                skillInfo.fit[formulae[formulasig]] = {
-                    mainCoef=fit.main,
-                    powerCoef=fit.power,
-                    healthCoef=fit.health,
-                    intercept=fit.int,
-                    rsq=fit.rsq,
-                }
-                formulaNum = formulaNum + 1
-            end
+            local formulasig = u.makeKey(fit.main, fit.power, fit.health, fit.int, fit.rsq)
+            if fit.const then
+                skillInfo.description = r:replaceNumberInDescription(desc, toReplace, fit.int)
+            else
+                if not formulae[formulasig] then
+                    formulae[formulasig] = "##f" .. formulaNum .. "##"
+                    skillInfo.fit[formulae[formulasig]] = {
+                        mainCoef=fit.main,
+                        powerCoef=fit.power,
+                        healthCoef=fit.health,
+                        intercept=fit.int,
+                        rsq=fit.rsq,
+                    }
+                    formulaNum = formulaNum + 1
+                end

-            skillInfo.description = r:replaceNumberInDescription(desc, toReplace, formulae[formulasig])
+                skillInfo.description = r:replaceNumberInDescription(desc, toReplace, formulae[formulasig])
+            end
         end
-    end

-    outfile.skills[skill] = skillInfo
-    u.makeDepth(outfile.lines, { ref.type, ref.line });
-    table.insert(outfile.lines[ref.type][ref.line], skill)
+        outfile.skills[skill] = skillInfo
+        u.makeDepth(outfile.lines, { ref.type, ref.line });
+        table.insert(outfile.lines[ref.type][ref.line], skill)
+    else
+        print("No lookup found for: " .. skill)
+    end
 end

 print("Writing results to: skilldata.json")
diff --git a/scripts/inc/extract.lua b/scripts/inc/extract.lua
index 0ba2fb0..f5cade2 100644
--- a/scripts/inc/extract.lua
+++ b/scripts/inc/extract.lua
@@ -13,10 +13,10 @@ function T:getFitData(data)
     local health_array = {}
     local type = "Unknown"
     for k,v in pairs(data) do
-        local msu, primary, power, health = k:match("([MSU])([0-9.]+)P([0-9.]+)")--H?([0-9.]+)?
+        local msu, primary, power, health = k:match("([MSU])([0-9.]+)P([0-9.]+)H?([0-9.]*)")
         table.insert(mainstat_array, tonumber(primary))
         table.insert(power_array, tonumber(power))
-        table.insert(health_array, tonumber(0)) --health
+        table.insert(health_array, tonumber(health or 0) or 0) --health
         table.insert(value_array, tonumber(v))
         type = self.types[msu] or "Unknown"
     end
@@ -27,6 +27,11 @@ function T:getFitData(data)
     r["Values"] = value_array
     r["Health"] = health_array

+    if #health_array ~= #mainstat_array then
+        u.dump(health_array)
+        u.dump(mainstat_array)
+    end
+
     --First check if it's actually constant
     r("valconst <- max(Values) == min(Values)")
     if r["valconst"][1] then