diff options
Diffstat (limited to 'js/mv')
-rw-r--r-- | js/mv/chart.js | 3 | ||||
-rw-r--r-- | js/mv/heap.js | 40 | ||||
-rw-r--r-- | js/mv/parse.js | 18 |
3 files changed, 52 insertions, 9 deletions
diff --git a/js/mv/chart.js b/js/mv/chart.js index 882caee..74d7b85 100644 --- a/js/mv/chart.js +++ b/js/mv/chart.js @@ -32,6 +32,7 @@ var mv = function(mv) { case 2: return "#6baed6"; default: throw "Definition chart: Color access key out of range!"; }}) + .filter(2) ; mv.charts.map = monoGroup(margined(wide(dc.bubbleChart("#map-chart"))), "map") .height(500) @@ -51,6 +52,8 @@ var mv = function(mv) { .title(function(d) { return "Map " + d.key; }) .renderTitle(true) ; + mv.charts.stats = trellisChart("#stat-chart", ["str", "agi", "vit", "dex", "int", "luk"].map(function(d) { mv.heap[d].name = d; return mv.heap[d]; })); + dc.renderlet(function() { mv.charts.stats(); }); dc.renderAll(); } function defLevelVerbose(level) { diff --git a/js/mv/heap.js b/js/mv/heap.js index bd1d583..a0a69be 100644 --- a/js/mv/heap.js +++ b/js/mv/heap.js @@ -1,19 +1,47 @@ var mv = function(mv) { mv.heap = function() { var heap = {}; + var statGran = 10; heap.init = function() { - function a(p, d) { return { e: p.e + d.e, j: p.j + d.j, r: p.r + 1 }; } - function s(p, d) { return { e: p.e - d.e, j: p.j - d.j, r: p.r - 1 }; } - function z(p, d) { return { e: 0, j: 0, r: 0 }; } + function ea(p, d) { p.e += d.e; p.j += d.j; p.r++; return p; } + function es(p, d) { p.e -= d.e; p.j -= d.j; p.r--; return p; } + function ez(p, d) { return { e: 0, j: 0, r: 0 }; } heap.cfdata = crossfilter(mv.parser.records); - heap.all = heap.cfdata.groupAll().reduce(a, s, z); + heap.all = heap.cfdata.groupAll().reduce(ea, es, ez); monoGroup("date", function(d) { return d3.time.hour.round(d.date); }); monoGroup("pc", function(d) { return d.pc; }); - monoGroup("map", function(d) { return d.map; }).reduce(a, s, z); + monoGroup("map", function(d) { return d.map; }).reduce(ea, es, ez); monoGroup("blvl", function(d) { return d.pcstat ? d.pcstat.blvl : 0; }); monoGroup("type", function(d) { return d.type; }); monoGroup("target", function(d) { return d.target; }); - monoGroup("wpn", function(d) { return d.wpn; }) + monoGroup("wpn", function(d) { return d.wpn; }); + function sa(p, d) { + if (!d.pcstat) return p; + p.str[d.pcstat.str]++ || (p.str[d.pcstat.str] = 1); + p.agi[d.pcstat.agi]++ || (p.agi[d.pcstat.agi] = 1); + p.vit[d.pcstat.vit]++ || (p.vit[d.pcstat.vit] = 1); + p.dex[d.pcstat.dex]++ || (p.dex[d.pcstat.dex] = 1); + p.int[d.pcstat.int]++ || (p.int[d.pcstat.int] = 1); + p.luk[d.pcstat.luk]++ || (p.luk[d.pcstat.luk] = 1); + return p; + } + function ss(p, d) { + if (!d.pcstat) return p; + --p.str[d.pcstat.str] || (p.str[d.pcstat.str] = undefined); + --p.agi[d.pcstat.agi] || (p.agi[d.pcstat.agi] = undefined); + --p.vit[d.pcstat.vit] || (p.vit[d.pcstat.vit] = undefined); + --p.dex[d.pcstat.dex] || (p.dex[d.pcstat.dex] = undefined); + --p.int[d.pcstat.int] || (p.int[d.pcstat.int] = undefined); + --p.luk[d.pcstat.luk] || (p.luk[d.pcstat.luk] = undefined); + return p; + } + function sz(p, d) { return { str: [], agi: [], vit: [], dex: [], int: [], luk: [] }; } + monoGroup("str", function(d) { return d.pcstat ? d.pcstat.str : 0; }).reduce(sa, ss, sz); + monoGroup("agi", function(d) { return d.pcstat ? d.pcstat.agi : 0; }).reduce(sa, ss, sz); + monoGroup("vit", function(d) { return d.pcstat ? d.pcstat.vit : 0; }).reduce(sa, ss, sz); + monoGroup("dex", function(d) { return d.pcstat ? d.pcstat.dex : 0; }).reduce(sa, ss, sz); + monoGroup("int", function(d) { return d.pcstat ? d.pcstat.int : 0; }).reduce(sa, ss, sz); + monoGroup("luk", function(d) { return d.pcstat ? d.pcstat.luk : 0; }).reduce(sa, ss, sz); /* Debugging group */ /* * How well defined a record is. diff --git a/js/mv/parse.js b/js/mv/parse.js index 23a0f79..c30a874 100644 --- a/js/mv/parse.js +++ b/js/mv/parse.js @@ -24,9 +24,9 @@ var mv = function(mv) { j: parseInt(d[7]), type: d[8], pcstat: pcstat[d[2]], - target: 0, - dmg: 0, - wpn: 0 + target: -1010, + dmg: -1010, + wpn: -1010 }; if (pcstat[d[2]] == undefined && (!fullyDefinedCutoff || ts > fullyDefinedCutoff)) { fullyDefinedCutoff = ts; @@ -42,8 +42,11 @@ var mv = function(mv) { softAssert(mID == parseInt(d[6]), "Integrity error: MOB ID mismatch!"); // softAssert(rec.pc == parseInt(d[2]), "Integrity error: PC ID mismatch!"); rec.target = parseInt(d[7]); + softAssert(rec.target, "Unknown target!") rec.dmg = parseInt(d[8]); rec.wpn = parseInt(d[9]); + } else { +// console.error("No match (deathblow):", spl[i - 2]); } } else { d = spl[i - 1].match(/^(\d+\.\d+) PC(\d+) (\d+):(\d+),(\d+) GAINXP (\d+) (\d+) (\w+)/); @@ -51,8 +54,11 @@ var mv = function(mv) { var clone = parser.records[parser.records.length - 1]; softAssert(rec.map == clone.map, "Integrity error: MAP ID mismatch!"); rec.target = clone.target; + softAssert(rec.target, "Unknown (cloned) target!"); rec.dmg = clone.dmg; /* FIXME: Take into account actual assist damage */ rec.wpn = clone.wpn; + } else { +// console.error("No match (clone):", spl[i - 1]); } } } @@ -70,6 +76,12 @@ var mv = function(mv) { luk: parseInt(d[7]) }; s.blvl = stat.minLevelForStats(s.str, s.agi, s.vit, s.int, s.dex, s.luk); + s.str = Math.floor(s.str / 10); + s.agi = Math.floor(s.agi / 10); + s.vit = Math.floor(s.vit / 10); + s.int = Math.floor(s.int / 10); + s.dex = Math.floor(s.dex / 10); + s.luk = Math.floor(s.luk / 10); pcstat[d[1]] = s; return; } |