Skip to content

Commit

Permalink
#304 Replay data now contains boss health, buff stacks, player classe…
Browse files Browse the repository at this point in the history
…s. Added boss health to ui.
  • Loading branch information
immortius committed Sep 5, 2018
1 parent 21865e5 commit 7a697d7
Show file tree
Hide file tree
Showing 16 changed files with 173 additions and 21 deletions.
1 change: 1 addition & 0 deletions analyser/analyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ def __init__(self, encounter):
if self.boss_info.gather_boss_specific_stats:
self.boss_info.gather_boss_specific_stats(events, collector.with_key(Group.CATEGORY, "combat").with_key(Group.METRICS, "mechanics"), agents, self.subgroups, self.players, bosses, self.phases, encounter_end)
buff_data = BuffPreprocessor().process_events(start_time, encounter_end, skills, players, player_src_events)
self.buff_data = buff_data

collector.with_key(Group.CATEGORY, "boss").run(self.collect_boss_key_events, events)
collector.with_key(Group.CATEGORY, "status").run(self.collect_player_status, players)
Expand Down
1 change: 0 additions & 1 deletion continuumsplit/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ textarea {

.replay-detail-item {
display: table-cell;
width: 10%;
}

.replay-bar-background {
Expand Down
1 change: 1 addition & 0 deletions continuumsplit/gorse.json

Large diffs are not rendered by default.

Binary file added continuumsplit/img/matt_arena.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added continuumsplit/img/sloth_arena.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 15 additions & 4 deletions continuumsplit/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,25 @@

<!-- Add your site or application content here -->
<p>GW2 Continuum Split</p>
<div id="replay"></canvas></div>
<div id="replay-1"></canvas></div>
<div id="replay-vg"></canvas></div>
<div id="replay-gorse"></canvas></div>
<div id="replay-sab"></canvas></div>
<div id="replay-sloth"></canvas></div>
<div id="replay-matt"></canvas></div>
<div id="replay-kc"></canvas></div>
<div id="replay-xera"></canvas></div>
<div id="replay-cairn"></canvas></div>
<div id="replay-mo"></canvas></div>
<div id="replay-sam"></canvas></div>
<div id="replay-deimos"></canvas></div>
<div id="replay-sh"></canvas></div>
<div id="replay-dhuum"></canvas></div>
<script src="js/vendor/modernizr-3.6.0.min.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-3.3.1.min.js"><\/script>')</script>
<script src="js/plugins.js"></script>
<script src="js/continuumsplit.js?10"></script>
<script src="js/main.js?5"></script>
<script src="js/continuumsplit.js?11"></script>
<script src="js/main.js?6"></script>

<!-- Google Analytics: change UA-XXXXX-Y to be your site's ID. -->
<script>
Expand Down
16 changes: 12 additions & 4 deletions continuumsplit/js/continuumsplit.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ Display:
Metrics
- Focus selection
- Cleave Dps
- Buffs
- Buffs
- Boss health
- Incoming Damage
- Phase
Expand Down Expand Up @@ -213,7 +212,7 @@ class Replay {
this.rootElement.append("<div class='replay-container'>"
+ "<div class='replay-main'><div class='replay-display'><canvas class='replay-canvas'></canvas></div>"
+ "<div class='replay-details'>"
+ "<div class='replay-detail-bossinfo'></div>"
+ "<div class='replay-detail-bossinfo'><div class='replay-boss-name'></div><div class='replay-boss-health'></div></div>"
+ "<div class='replay-detail-player-section'>"
+ "<div class='replay-detail-table'><div class='replay-detail-header-row'><div class='replay-detail-item'>Player</div><div class='replay-detail-item'>Boss DPS</div><div class='replay-detail-item'>Cleave DPS</div></div>"
+ "<div class='replay-detail-player-rows'></div></div></div></div></div>"
Expand Down Expand Up @@ -278,12 +277,16 @@ class Replay {
this.currentTime = this.rootElement.find('.replay-current-time')
this.totalTime = this.rootElement.find('.replay-total-time')

this.bossNameDisplay = this.rootElement.find('.replay-boss-name')
this.playerDetails = this.rootElement.find('.replay-detail-player-rows')
}

updateDetails() {
let frameTime = this.frameTime
$.each(this.frame, function(name, data) {
if (data.healthDisplay != null && data.health != null) {
data.healthDisplay.setValue(data.health.toFixed(2))
}
if (data.bossdpsDisplay != null) {
if (frameTime > 0) {
data.bossdpsDisplay.setValue(Math.trunc(parseInt(data["bossdamage"]) / frameTime))
Expand Down Expand Up @@ -334,14 +337,14 @@ class Replay {
}
this.mapImage.src = maps[0].image;

//this.coords = new AreaBox(-12151, -9526, 1976, -274)
this.coords = new AreaBox(maps[0].worldCoords.left, maps[0].worldCoords.right, maps[0].worldCoords.top, maps[0].worldCoords.bottom)
this.imageSrc = new AreaBox(maps[0].imageCoords.left, maps[0].imageCoords.right, maps[0].imageCoords.top, maps[0].imageCoords.bottom)
this.imageDst = this.calcDstBox()
this.duration = this.replayData.info.duration
this.seekbar.attr("max", this.duration)
this.totalTime.text(Replay.printTime(Math.trunc(this.duration)))
this.currentTime.text(Replay.printTime(0))
this.bossNameDisplay.text(this.replayData.info.encounter)
}

addPlayerDetailRows(actorData) {
Expand All @@ -362,6 +365,11 @@ class Replay {
data.cleavedpsDisplay.addClass('replay-detail-item')
row.append(data.cleavedpsDisplay)
replay.playerDetails.append(row)
} else if (data["type"] == "Boss") {
let bossHealthDisplay = replay.createDisplayBar(100)
bossHealthDisplay.setValue(100)
replay.rootElement.find('.replay-boss-health').append(bossHealthDisplay);
data.healthDisplay = bossHealthDisplay
}
})
}
Expand Down
23 changes: 19 additions & 4 deletions continuumsplit/js/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
//loadReplay('replay-canvas', 'test.json')
var replay = new Replay('#replay', 800, 400)
var replay1 = new Replay('#replay-1', 800, 400)
replay.loadReplay('test.json')
replay1.loadReplay('shtest.json')
var replayvg = new Replay('#replay-vg', 800, 400)
var replaygorse = new Replay('#replay-gorse', 800, 400)
var replaysab = new Replay('#replay-sab', 800, 400)
var replaysloth = new Replay('#replay-sloth', 800, 400)
var replaymatt = new Replay('#replay-matt', 800, 400)
var replaykc = new Replay('#replay-kc', 800, 400)
var replayxera = new Replay('#replay-xera', 800, 400)
var replaycairn = new Replay('#replay-cairn', 800, 400)
var replaymo = new Replay('#replay-mo', 800, 400)
var replaysam = new Replay('#replay-sam', 800, 400)
var replaydeimos = new Replay('#replay-deimos', 800, 400)
var replaysh = new Replay('#replay-sh', 800, 400)
var replaydhuum = new Replay('#replay-dhuum', 800, 400)
replayvg.loadReplay('vg.json')
replaysh.loadReplay('sh.json')
replaygorse.loadReplay('gorse.json')
replaysab.loadReplay('sab.json')
replaysloth.loadReplay('sloth.json')
replaymatt.loadReplay('test.json')
72 changes: 70 additions & 2 deletions continuumsplit/mapinfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,73 @@
"bottom" : -22171
}
}
]
}
],
"Gorseval" : [
{
"image" : "img/Spirit_Vale_map.jpg",
"imageCoords" : {
"left" : 391,
"top" : 428,
"right" : 617,
"bottom" : 654
},
"worldCoords" : {
"left" : -1396.5,
"right" : 4607.165,
"top" : -1483.975,
"bottom" : -7487.665
}
}
],
"Sabetha" : [
{
"image" : "img/Spirit_Vale_map.jpg",
"imageCoords" : {
"left" : 113,
"top" : 110,
"right" : 386,
"bottom" : 383
},
"worldCoords" : {
"left" : -8478.425,
"right" : -1677.995,
"top" : 6757.185,
"bottom" : -43.245
}
}
],
"Slothasor" : [
{
"image" : "img/sloth_arena.jpg",
"imageCoords" : {
"left" : 0,
"top" : 0,
"right" : 299,
"bottom" : 358
},
"worldCoords" : {
"left" : 6113.85,
"right" : 9806.5,
"top" : 1457.9,
"bottom" : -2963.4
}
}
],
"Matthias" : [
{
"image" : "img/matt_arena.jpg",
"imageCoords" : {
"left" : 0,
"top" : 0,
"right" : 244,
"bottom" : 244
},
"worldCoords" : {
"left" : -7667.88,
"right" : -4088.4,
"top" : 7675.79,
"bottom" : 4096.31
}
}
]
}
1 change: 1 addition & 0 deletions continuumsplit/sab.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions continuumsplit/sh.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion continuumsplit/shtest.json

This file was deleted.

1 change: 1 addition & 0 deletions continuumsplit/sloth.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion continuumsplit/test.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions continuumsplit/vg.json

Large diffs are not rendered by default.

54 changes: 50 additions & 4 deletions replay/replaywriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from evtcparser import *
import pandas as pd
import numpy as np
from analyser.analyser import LogType
import analyser as ana
from functools import reduce
import json
import ctypes
Expand Down Expand Up @@ -50,22 +50,35 @@ def __init__(self, encounter, analyser):
self.start_time = analyser.start_time
self.end_time = analyser.end_time
self.events['time'] = self.events['time'].apply(lambda x : (x - self.start_time) / 1000.0)
self.damage_events = self.events[(self.events.state_change == 0)&((self.events.type == LogType.POWER)|(self.events.type == LogType.CONDI))]
self.damage_events = self.events[(self.events.state_change == 0)&((self.events.type == ana.analyser.LogType.POWER)|(self.events.type == ana.analyser.LogType.CONDI))]
self.damage_events = self.damage_events.assign(damage =
np.where(self.damage_events.type == LogType.POWER,
np.where(self.damage_events.type == ana.analyser.LogType.POWER,
self.damage_events['value'],
self.damage_events['buff_dmg']))
self.damage_events = self.damage_events[self.damage_events.damage > 0]
self.buff_data = analyser.buff_data.copy()
self.buff_data['time'] = self.buff_data['time'].apply(lambda x : (x - self.start_time) / 1000.0)


def writePlayerData(self, agentId, dataOut):
self.writeAgentData(agentId, dataOut)
agent = self.agents.loc[agentId]
dataOut["base-state"][str(agentId)]["color"] = "#BBDDFF"
dataOut["base-state"][str(agentId)]["state"] = 'Up'
dataOut["base-state"][str(agentId)]["type"] = "Player"
elite = 0
if agent.elite == 0:
elite = 0
elif agent.elite < 55:
elite = 1
else:
elite = 2
dataOut["base-state"][str(agentId)]["class"] = ana.analyser.SPECIALISATIONS[ana.analyser.Profession(agent.prof), elite]


self.writeBossDamageTrack(agentId, dataOut)
self.writeCleaveDamageTrack(agentId, dataOut)
self.writeBuffTracks(agentId, dataOut)

stateChangeEvents = self.events[(self.events.src_instid == agentId) & ((self.events.state_change == 3)|(self.events.state_change == 4)|(self.events.state_change == 5))]
if len(stateChangeEvents) > 0:
Expand All @@ -77,6 +90,7 @@ def writePlayerData(self, agentId, dataOut):

def writeBossData(self, agentId, dataOut):
self.writeAgentData(agentId, dataOut)
self.writeHealthUpdates(agentId, dataOut)
dataOut["base-state"][str(agentId)]["color"] = "#FF0000"
dataOut["base-state"][str(agentId)]["type"] = "Boss"

Expand All @@ -93,6 +107,38 @@ def writeAgentData(self, agentId, dataOut):
self.writePositionTracks(agentId, dataOut)
self.writeDirectionTrack(agentId, dataOut)

def writeBuffTracks(self, agentId, dataOut):
dataOut["base-state"][str(agentId)]["buff"] = {}
for buffType in ana.buffs.BUFF_TYPES:
buffData = self.buff_data[(self.buff_data.dst_instid == agentId)&(self.buff_data.buff == buffType.code)]
if len(buffData) > 0:
dataOut["base-state"][str(agentId)]["buff"][buffType.code] = 0
track = {"path" : [str(agentId), "buff", buffType.code], "data-type" : "numeric", "update-type" : "delta", "interpolation" : "floor"}
track["data"] = []
dataOut["tracks"] += [track]
for event in buffData[['time', 'stacks']].itertuples():
track["data"] += [{'time' : event[1], 'value' : int(event[2])}]

def writeHealthUpdates(self, agentId, dataOut):
agent = self.agents.loc[agentId]

healthEvents = self.events[(self.events.src_instid == agentId) & (self.events.state_change == 8)]

if len(healthEvents) > 0:
dataOut["base-state"][str(agentId)]["health"] = 100
trackHealth = {"path" : [str(agentId), "health"], "data-type" : "numeric", "update-type" : "delta", "interpolation" : "lerp"}
trackHealth["data"] = []
dataOut["tracks"] += [trackHealth]
gap = 5
lastTime = 0
lastValue = 100.0
for event in healthEvents[['time', 'dst_agent']].itertuples():
if event[1] - lastTime > gap:
trackHealth["data"] += [{'time': event[1] - 0.1, 'value': lastValue}]
trackHealth["data"] += [{'time' : event[1], 'value' : event[2]/100.0}]
lastTime = event[1]
lastValue = event[2] / 100.0

def writeDirectionTrack(self, agentId, dataOut):
agent = self.agents.loc[agentId]

Expand Down Expand Up @@ -164,7 +210,7 @@ def writePositionTracks(self, agentId, dataOut):

def writeBossDamageTrack(self, agentId, dataOut):
agent = self.agents.loc[agentId]
trackDamage = {"path" : [str(agentId), "bossdamage"], "data-type" : "numeric", "update-type" : "delta", "interpolation" : "floor"}
trackDamage = {"path" : [str(agentId), "bossdamage"], "data-type" : "numeric", "update-type" : "delta", "interpolation" : "lerp"}
events = self.damage_events[(self.damage_events.ult_src_instid == agentId) & (self.damage_events.damage > 0) & (self.damage_events.iff == 1) & (self.damage_events.dst_instid.isin(self.boss_instids))]
events['bossdamagesum'] = events.value.cumsum() + events.buff_dmg.cumsum()

Expand Down

0 comments on commit 7a697d7

Please sign in to comment.