Skip to content

Commit

Permalink
Merge pull request odota#112 from albertcui/ardm
Browse files Browse the repository at this point in the history
Ardm

Former-commit-id: 40337cc
  • Loading branch information
albertcui committed Jan 12, 2015
2 parents 27b1d92 + b5f6935 commit 0760a0d
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 28 deletions.
42 changes: 27 additions & 15 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,27 +213,39 @@ app.route('/matches/:match_id/:info?').get(function(req, res, next) {
var primary = match.players[slot].hero_id
var primary_name = app.locals.constants.heroes[primary].name
var merge = match.parsed_data.heroes[primary_name]
if (!match.players[slot].hero_ids) {
match.players[slot].hero_ids = []
}
match.players[slot].hero_ids.push(hero_id);
if (key !== primary_name) {
for (var attr in val) {
if (val[attr].constructor === Array) {
merge[attr]=merge[attr].concat(val[attr])
}
else {
for (var attr2 in val[attr]) {
if (!merge[attr][attr2]) {
merge[attr][attr2] = val[attr][attr2]
}
else {
merge[attr][attr2] += val[attr][attr2]
}
}
}
}
mergeObjects(merge, val);
}
}
}
}
}

function mergeObjects(merge, val) {
for (var attr in val) {
if (val[attr].constructor === Array) {
merge[attr] = merge[attr].concat(val[attr])
}
else if (typeof val[attr] === "object") {
mergeObjects(merge[attr], val[attr])
}
else {
//does property exist?
if (!merge[attr]) {
merge[attr] = val[attr]
}
else {
merge[attr] += val[attr]
}

}
}
}

if (info === "graphs") {
if (match.parsed_data) {
//compute graphs
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"express": "~4.8.8",
"express-session": "~1.8.2",
"hiredis": "0.1.17",
"http-auth": "~2.2.4",
"http-auth": "~2.2.5",
"http-proxy": "~1.5.3",
"jade": "~1.8.2",
"kue": "~0.8.11",
Expand Down
9 changes: 4 additions & 5 deletions parser/src/main/java/albert/stats/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public static void main(String[] args) throws Exception {
while(iter.hasNext()) {
iter.next().apply(match);
int time = (int) match.getGameTime();
int trueTime=time-gameZero;
Entity pr = match.getPlayerResource();
//EntityCollection ec = match.getEntities();

Expand Down Expand Up @@ -70,15 +71,13 @@ public static void main(String[] args) throws Exception {
initialized = true;
}

int trueTime=time-gameZero;

for (int i = 0; i < numPlayers; i++) {
String hero = pr.getProperty("m_nSelectedHeroID" + "." + PLAYER_IDS[i]).toString();
hero_to_slot.put(hero, i);
JSONObject player = doc.getJSONArray("players").getJSONObject(i);
player.put("stuns", pr.getProperty("m_fStuns" + "." + PLAYER_IDS[i]));
int handle = pr.getProperty("m_hSelectedHero" + "." + PLAYER_IDS[i]);
/*
int handle = pr.getProperty("m_hSelectedHero" + "." + PLAYER_IDS[i]);
Entity e = ec.getByHandle(handle);
System.err.println(e);
if (e!=null){
Expand All @@ -92,8 +91,7 @@ public static void main(String[] args) throws Exception {
Entity e = runes.next();
//System.err.format("rune: %s %s %s,%s %n", trueTime, e.getProperty("m_iRuneType"), e.getProperty("m_cellX"), e.getProperty("m_cellY"));
}
*/
//data points for graphs
*/
if (trueTime > nextInterval) {
doc.getJSONArray("times").put(trueTime);
for (int i = 0; i < numPlayers; i++) {
Expand Down Expand Up @@ -157,6 +155,7 @@ else if (name.equals("CUserMsg_SayText2")){
JSONArray players = doc.getJSONArray("players");
for (int i = 0;i<players.length();i++){
String playerName = players.getJSONObject(i).getString("personaname");
//todo names here don't match up with api names if unicode chars
//System.err.format("%s-%s,%s-%s %n",prefix, Arrays.toString(prefix.getBytes()), playerName, Arrays.toString(playerName.getBytes()));
if (players.getJSONObject(i).getString("personaname").equals(prefix)){
slot=i;
Expand Down
4 changes: 2 additions & 2 deletions public/js/cal-heatmap.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var cal = new CalHeatMap();
cal.init({
start: new Date(moment().subtract(11, 'month')),
range: 12,
start: new Date(moment().subtract(1, 'year')),
range: 13,
domain: "month",
subDomain: "day",
data: data,
Expand Down
10 changes: 5 additions & 5 deletions views/match_details.jade
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ append content
each player, i in match.players
tr(class = player.player_slot<64 ? "success" : "danger")
- var hero = constants.heroes[player.hero_id]
td.hero
if hero
img(src=hero.img, title=hero.localized_name)
else
=player.hero_id
- var parsedHero = match.parsed_data.heroes[hero.name]
- var parsedPlayer = match.parsed_data.players[i]
td.hero
if hero
img(src=hero.img, title=hero.localized_name)
else
=player.hero_id
td #{parsedHero.itembuys.tpscroll || "-"}
td #{parsedHero.itembuys.ward_observer*2 || "-"}
td #{parsedHero.itembuys.ward_sentry*2 || "-"}
Expand Down

0 comments on commit 0760a0d

Please sign in to comment.