Skip to content

Commit

Permalink
extract ward entityLeft events
Browse files Browse the repository at this point in the history
  • Loading branch information
howardchung committed Jun 22, 2016
1 parent cfbb3b9 commit 74f2640
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 42 deletions.
66 changes: 43 additions & 23 deletions java_parser/src/main/java/yasp/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import skadistats.clarity.model.s1.GameRulesStateType;
import skadistats.clarity.processor.entities.Entities;
import skadistats.clarity.processor.entities.OnEntityEntered;
import skadistats.clarity.processor.entities.OnEntityLeft;
import skadistats.clarity.processor.entities.UsesEntities;
import skadistats.clarity.processor.gameevents.CombatLog;
import skadistats.clarity.processor.gameevents.OnCombatLogEntry;
Expand Down Expand Up @@ -78,6 +79,7 @@ private class Entry {
public Integer xp;
public Integer x;
public Integer y;
public Integer z;
public Float stuns;
public Integer hero_id;
public Integer life_state;
Expand All @@ -87,7 +89,9 @@ private class Entry {
public Integer assists;
public Integer denies;
//public Boolean hasPredictedVictory;

public Boolean entityleft;
public Integer ehandle;

public Entry() {
}

Expand Down Expand Up @@ -255,28 +259,12 @@ public void onCombatLogEntry(Context ctx, CombatLogEntry cle) {

@OnEntityEntered
public void onEntityEntered(Context ctx, Entity e) {
//CDOTA_NPC_Observer_Ward
//CDOTA_NPC_Observer_Ward_TrueSight
//s1 "DT_DOTA_NPC_Observer_Ward"
//s1 "DT_DOTA_NPC_Observer_Ward_TrueSight"
boolean isObserver = e.getDtClass().getDtName().equals("CDOTA_NPC_Observer_Ward");
boolean isSentry = e.getDtClass().getDtName().equals("CDOTA_NPC_Observer_Ward_TrueSight");
if (isObserver || isSentry) {
//System.err.println(e);
Entry entry = new Entry(time);
Integer x = getEntityProperty(e, "CBodyComponent.m_cellX", null);
Integer y = getEntityProperty(e, "CBodyComponent.m_cellY", null);
Integer[] pos = {x, y};
entry.type = isObserver ? "obs" : "sen";
entry.key = Arrays.toString(pos);
//System.err.println(entry.key);
Integer owner = getEntityProperty(e, "m_hOwnerEntity", null);
Entity ownerEntity = ctx.getProcessor(Entities.class).getByHandle(owner);
entry.slot = ownerEntity != null ? (Integer) getEntityProperty(ownerEntity, "m_iPlayerID", null) : null;
//2/3 radiant/dire
//entry.team = e.getProperty("m_iTeamNum");
output(entry);
}
processWardEntity(ctx, e, false);
}

@OnEntityLeft
public void onEntityLeft(Context ctx, Entity e) {
processWardEntity(ctx, e, true);
}

@UsesEntities
Expand Down Expand Up @@ -448,6 +436,38 @@ public <T> T getEntityProperty(Entity e, String property, Integer idx) {
FieldPath fp = e.getDtClass().getFieldPathForName(property);
return e.getPropertyForFieldPath(fp);
}

public void processWardEntity(Context ctx, Entity e, boolean entityLeft)
{
//CDOTA_NPC_Observer_Ward
//CDOTA_NPC_Observer_Ward_TrueSight
//s1 "DT_DOTA_NPC_Observer_Ward"
//s1 "DT_DOTA_NPC_Observer_Ward_TrueSight"
boolean isObserver = e.getDtClass().getDtName().equals("CDOTA_NPC_Observer_Ward");
boolean isSentry = e.getDtClass().getDtName().equals("CDOTA_NPC_Observer_Ward_TrueSight");
if (isObserver || isSentry) {
//System.err.println(e);
Entry entry = new Entry(time);
Integer x = getEntityProperty(e, "CBodyComponent.m_cellX", null);
Integer y = getEntityProperty(e, "CBodyComponent.m_cellY", null);
Integer z = getEntityProperty(e, "CBodyComponent.m_cellZ", null);
Integer[] pos = {x, y};
entry.x = x;
entry.y = y;
entry.z = z;
entry.type = isObserver ? "obs" : "sen";
entry.key = Arrays.toString(pos);
entry.entityleft = entityLeft;
entry.ehandle = e.getHandle();
//System.err.println(entry.key);
Integer owner = getEntityProperty(e, "m_hOwnerEntity", null);
Entity ownerEntity = ctx.getProcessor(Entities.class).getByHandle(owner);
entry.slot = ownerEntity != null ? (Integer) getEntityProperty(ownerEntity, "m_iPlayerID", null) : null;
//2/3 radiant/dire
//entry.team = e.getProperty("m_iTeamNum");
output(entry);
}
}

public void run(String[] args) throws Exception {
long tStart = System.currentTimeMillis();
Expand Down
3 changes: 3 additions & 0 deletions processors/populate.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ function populate(e, container)
case 'player_slot':
container.players[e.key].player_slot = e.value;
break;
case 'log':
container.log.push(JSON.parse(JSON.stringify(e)));
break;
case 'chat':
container.chat.push(JSON.parse(JSON.stringify(e)));
break;
Expand Down
24 changes: 15 additions & 9 deletions processors/processExpand.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,24 +425,30 @@ function processExpand(entries, meta)
},
"obs": function(e)
{
//key is a JSON array of position data
e.key = JSON.parse(e.key);
e.posData = true;
expand(e);
var e2 = JSON.parse(JSON.stringify(e));
e2.posData = false;
e2.type = "obs_log";
expand(e2);
var e4 = JSON.parse(JSON.stringify(e));
e4.type = "log";
expand(e4);
var e3 = JSON.parse(JSON.stringify(e));
//key is a JSON array of position data
e3.key = JSON.parse(e3.key);
e3.posData = true;
expand(e3);
},
"sen": function(e)
{
e.key = JSON.parse(e.key);
e.posData = true;
expand(e);
var e2 = JSON.parse(JSON.stringify(e));
e2.posData = false;
e2.type = "sen_log";
expand(e2);
var e4 = JSON.parse(JSON.stringify(e));
e4.type = "log";
expand(e4);
var e3 = JSON.parse(JSON.stringify(e));
e3.key = JSON.parse(e3.key);
e3.posData = true;
expand(e3);
}
};
//define the types we want to put into each array
Expand Down
1 change: 1 addition & 0 deletions sql/cassandra.cql
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ CREATE TABLE matches (
radiant_xp_adv text,
teamfights text,
version int,
log text,
);

CREATE TABLE player_matches (
Expand Down
3 changes: 2 additions & 1 deletion sql/create_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ CREATE TABLE matches (
radiant_gold_adv integer[],
radiant_xp_adv integer[],
teamfights json[],
version integer
version integer,
log json[]
);

CREATE TABLE player_matches (
Expand Down
20 changes: 17 additions & 3 deletions util/analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
**/
var util = require('util');
var constants = require('../constants.js');

function generatePlayerAnalysis(match, pm)
{
//define condition check for each advice point
Expand Down Expand Up @@ -150,7 +151,8 @@ function generatePlayerAnalysis(match, pm)
{
var flying_available = 180;
var time;
if (pm.purchase && pm.first_purchase_time && pm.first_purchase_time.flying_courier) {
if (pm.purchase && pm.first_purchase_time && pm.first_purchase_time.flying_courier)
{
time = pm.first_purchase_time.flying_courier;
}
return {
Expand All @@ -172,7 +174,7 @@ function generatePlayerAnalysis(match, pm)
wards: function(m, pm)
{
var ward_cooldown = 60 * 7;
var wards = pm.obs_log ? pm.obs_log.length : 0;
var wards = getObsWardsPlaced(pm);
//divide game length by ward cooldown
//2 wards respawn every interval
//split responsibility between 2 supports
Expand Down Expand Up @@ -304,7 +306,19 @@ function generatePlayerAnalysis(match, pm)

function isSupport(pm)
{
return pm.obs_log && pm.obs_log.length >= 2 && pm.lh_t && pm.lh_t[10] < 20;
return getObsWardsPlaced(pm) >= 2 && pm.lh_t && pm.lh_t[10] < 20;
}

function getObsWardsPlaced(pm)
{
if (!pm.obs_log)
{
return 0;
}
return pm.obs_log.filter(function(l)
{
return !l.entityleft;
}).length;
}

function isRoshHero(pm)
Expand Down
1 change: 1 addition & 0 deletions util/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ function getParseSchema()
"teamfights": [],
"objectives": [],
"chat": [],
"log": [],
"radiant_gold_adv": [],
"radiant_xp_adv": [],
"players": Array.apply(null, new Array(10)).map(function()
Expand Down
4 changes: 0 additions & 4 deletions views/match/match_performances.jade
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ block match_content
tr
th: abbr(title=tooltips.hero_id) Hero
th: abbr(title=tooltips.lane) Lane
//th: abbr(title=tooltips.used_ward_observer) Observer
//th: abbr(title=tooltips.used_ward_sentry) Sentry
th: abbr(title=tooltips.lane_efficiency) EFF@10
th: abbr(title=tooltips.lhten) LH@10
th: abbr(title=tooltips.stuns) Stuns
Expand All @@ -19,8 +17,6 @@ block match_content
tr.activate(data-index=i, data-type="lane_pos", class = player.isRadiant ? "radiant" : "dire")
+hero_td(player)
td #{constants.lane_ids[player.lane] || "-"} (#{constants.lane_role[player.lane_role] || "-"})
//td.activate(data-index=i, data-type="obs") #{player.obs_log.length || "-"}
//td.activate(data-index=i, data-type="sen") #{player.sen_log.length || "-"}
td.rankable #{(Number(player.lane_efficiency)*100).toFixed(2)}
td.rankable #{player.lh_t && player.lh_t[10] ? player.lh_t[10] : "-"}
td.rankable #{Number(Math.max(player.stuns, 0)).toFixed(2)}
Expand Down
4 changes: 2 additions & 2 deletions views/match/match_vision.jade
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ block match_content
tr(class = player.isRadiant ? "radiant" : "dire", data-index=ind, data-type="obs").activate
+hero_td(player)
td.rankable.lane-position #{player.purchase_ward_observer || "-"}
td.rankable.lane-position #{player.obs_log && player.obs_log.length ? player.obs_log.length : "-"}
td.rankable.lane-position #{player.obs_log && player.obs_log.length ? player.obs_log.filter(function(l){return !l.entityleft;}).length : "-"}
td.rankable.lane-position #{player.observer_kills || "-"}

.col-md-4
Expand All @@ -29,7 +29,7 @@ block match_content
tr(class = player.isRadiant ? "radiant" : "dire", data-index=ind, data-type="sen").activate
+hero_td(player)
td.rankable.lane-position #{player.purchase_ward_sentry || "-"}
td.rankable.lane-position #{player.sen_log && player.sen_log.length ? player.sen_log.length : "-"}
td.rankable.lane-position #{player.sen_log && player.sen_log.length ? player.sen_log.filter(function(l){return !l.entityleft;}).length : "-"}
td.rankable.lane-position #{player.sentry_kills || "-"}

.col-md-4
Expand Down

0 comments on commit 74f2640

Please sign in to comment.