Skip to content

Commit

Permalink
#304 Implemented buff display
Browse files Browse the repository at this point in the history
  • Loading branch information
immortius committed Sep 15, 2018
1 parent 4a13b50 commit 0f4ca0c
Show file tree
Hide file tree
Showing 3 changed files with 212 additions and 14 deletions.
145 changes: 140 additions & 5 deletions continuumsplit/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ textarea {
width: 175px;
}

.replay-detail-main {
display: flex;
}

.replay-detail-cleave-dps-column,
.replay-detail-cleave {
width: 95px;
Expand All @@ -150,11 +154,6 @@ textarea {
display: flex;
}

.replay-detail-row {
display: flex;
flex-wrap: wrap;
}

.replay-detail-player-column {
width: 195px;
}
Expand Down Expand Up @@ -186,6 +185,19 @@ textarea {
line-height: 20px;
margin-left: 10px;
}
.replay-buff-bar {
display: flex;
}

.replay-buff-count {
font-size: 12px;
font-weight: bold;
color: black;
text-shadow: 1px 1px 2px white;
position: relative;
padding: 5px 3px 0px 0px;
text-align: right;
}

.replay-detail-bossinfo {
margin-bottom: 10px;
Expand All @@ -199,6 +211,11 @@ textarea {
font-weight: bold;
}

/* ==========================================================================
GW2 classes
========================================================================== */


.replay-class-necromancer {
width: 20px;
height: 20px;
Expand Down Expand Up @@ -388,6 +405,11 @@ textarea {
background-position: -160px -72px;
}

/* ==========================================================================
GW2 buffs
========================================================================== */


.replay-buff-fury {
width: 20px;
height: 20px;
Expand Down Expand Up @@ -423,6 +445,119 @@ textarea {
background-position: -80px -92px;
}

.replay-buff-spirit_of_frost {
width: 20px;
height: 20px;
background-image: url('../img/icons.png');
background-position: -100px -92px;
}

.replay-buff-spotter {
width: 20px;
height: 20px;
background-image: url('../img/icons.png');
background-position: -120px -92px;
}

.replay-buff-stab {
width: 20px;
height: 20px;
background-image: url('../img/icons.png');
background-position: -140px -92px;
}

.replay-buff-stone_spirit {
width: 20px;
height: 20px;
background-image: url('../img/icons.png');
background-position: -160px -92px;
}

.replay-buff-storm_spirit {
width: 20px;
height: 20px;
background-image: url('../img/icons.png');
background-position: -180px -92px;
}

.replay-buff-sun_spirit {
width: 20px;
height: 20px;
background-image: url('../img/icons.png');
background-position: -200px -92px;
}

.replay-buff-swift {
width: 20px;
height: 20px;
background-image: url('../img/icons.png');
background-position: -220px -92px;
}

.replay-buff-vigor {
width: 20px;
height: 20px;
background-image: url('../img/icons.png');
background-position: -240px -92px;
}

.replay-buff-banner_defense {
width: 20px;
height: 20px;
background-image: url('../img/icons.png');
background-position: -260px -92px;
}

.replay-buff-banner_discipline {
width: 20px;
height: 20px;
background-image: url('../img/icons.png');
background-position: -280px -92px;
}

.replay-buff-banner_strength {
width: 20px;
height: 20px;
background-image: url('../img/icons.png');
background-position: -300px -92px;
}

.replay-buff-banner_tactics {
width: 20px;
height: 20px;
background-image: url('../img/icons.png');
background-position: -320px -92px;
}

.replay-buff-quickness {
width: 20px;
height: 20px;
background-image: url('../img/icons.png');
background-position: -340px -92px;
}

.replay-buff-regen {
width: 20px;
height: 20px;
background-image: url('../img/icons.png');
background-position: -360px -92px;
}

.replay-buff-resist {
width: 20px;
height: 20px;
background-image: url('../img/icons.png');
background-position: -380px -92px;
}

.replay-buff-retaliation {
width: 20px;
height: 20px;
background-image: url('../img/icons.png');
background-position: -400px -92px;
}


/* ==========================================================================
Helper classes
========================================================================== */
Expand Down
Binary file modified continuumsplit/img/icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 72 additions & 9 deletions continuumsplit/js/continuumsplit.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,22 +171,26 @@ var Replay;
this.element = $(document.createElement('div'))
this.element.addClass('replay-detail-row')

let mainBar = $(document.createElement('div'))
mainBar.addClass('replay-detail-main')
this.element.append(mainBar);

let classIcon = $(document.createElement('div'))
classIcon.addClass('replay-class-' + playerData["class"].toLowerCase())
this.element.append(classIcon)
mainBar.append(classIcon)

let nameDisplay = $(document.createElement('div'))
nameDisplay.addClass('replay-detail-item')
nameDisplay.addClass('replay-detail-name')
nameDisplay.text(playerData["name"])
this.element.append(nameDisplay)
mainBar.append(nameDisplay)

let bossDpsBar = createDisplayBar(maxDps)
let dpsItem = $(document.createElement('div'))
dpsItem.addClass('replay-detail-item')
dpsItem.addClass('replay-detail-dps')
dpsItem.append(bossDpsBar)
this.element.append(dpsItem)
mainBar.append(dpsItem)

this.setBossDps = function(amount) {
bossDpsBar.setValue(amount)
Expand All @@ -197,15 +201,46 @@ var Replay;
cleaveItem.addClass('replay-detail-item')
cleaveItem.addClass('replay-detail-cleave')
cleaveItem.append(cleaveDpsBar)
this.element.append(cleaveItem)
mainBar.append(cleaveItem)

this.setCleave = function(amount) {
cleaveDpsBar.setValue(amount)
}

/*let protectionBuff = $(document.createElement('div'))
protectionBuff.addClass('replay-buff-protection')
row.append(protectionBuff)*/
this.buffsBar = $(document.createElement('div'))
this.buffsBar.addClass('replay-buff-bar')
this.buffsBar.addClass('hidden')
this.element.append(this.buffsBar)

this.buffs = {}

this.setBuff = function(name, amount) {
if (!this.buffs[name]) {
let buff = $(document.createElement('div'))
buff.addClass('replay-buff')
buff.addClass('replay-buff-' + name)
let buffCount = $(document.createElement('div'))
buffCount.addClass('replay-buff-count');
buffCount.addClass('hidden')
buff.append(buffCount);
this.buffsBar.append(buff)
this.buffs[name] = buff
}

let buff = this.buffs[name]
if (amount > 0) {
buff.toggleClass('hidden', false)
if (amount > 1) {
let buffCounter = $(buff.find('.replay-buff-count')[0])
buffCounter.toggleClass('hidden', false)
buffCounter.text(amount)
} else {
buff.find('.replay-buff-count').toggleClass('hidden', true)
}
} else {
buff.toggleClass('hidden', true)
}
}

this.element.on("click", function () {
replay.selectActor(playerId);
Expand Down Expand Up @@ -393,12 +428,15 @@ var Replay;
}

addPlayerDetailRows(actorData) {
let maxDps = this.calculateMaxDamage("cleavedamage")
console.log("MaxDps: " + maxDps);

let replay = this;
this.playerDetails.html("")
replay.detailsLookup = {}
$.each(actorData, function(name, data) {
if (data["type"] == "Player") {
let playerDetail = new PlayerDetail(name, data, replay, 50000, 50000)
let playerDetail = new PlayerDetail(name, data, replay, maxDps, maxDps)
replay.playerDetails.append(playerDetail.element)
replay.detailsLookup[name] = playerDetail;
} else if (data["type"] == "Boss") {
Expand All @@ -412,6 +450,24 @@ var Replay;
})
}

calculateMaxDamage(targetTrack) {
let replay = this;
let max = 0;
$.each(this.replayData.tracks, function(trackIndex, track) {
if (targetTrack == track.path[1]) {
$.each(track.data, function(index, dataPair) {
if (dataPair.time > 5) {
let value = dataPair.value / dataPair.time;
if (value > max) {
max = value;
}
}
})
}
});
return max;
}



// Private: Configures tracks after load
Expand Down Expand Up @@ -467,6 +523,8 @@ var Replay;
this.canvas.height = this.windowH
this.rootElement.css("width", this.windowW)

$('.replay-buff-bar').toggleClass('hidden', true)

$.each(this.maps, function(index, map) {
map.imageDst = replay.calcDstBox(map, index, replay.maps.length)
});
Expand Down Expand Up @@ -494,6 +552,8 @@ var Replay;
map.imageDst = replay.calcDstBox(map, index, replay.maps.length)
});

$('.replay-buff-bar').toggleClass('hidden', false)

this.setFrame(this.frameTime)
}
}
Expand Down Expand Up @@ -652,11 +712,14 @@ var Replay;
data.detailDisplay.setBossDps(0)
data.detailDisplay.setCleave(0);
}
$.each(data.buff, function(name, value) {
data.detailDisplay.setBuff(name, value);
})
}
})

let newSort = this.playerDetails.children().sort(function(a, b) {
return parseInt($($(b).children()[2]).text()) - parseInt($($(a).children()[2]).text());
return parseInt($(b).find('.replay-detail-dps').text()) - parseInt($(a).find('.replay-detail-dps').text());
});

let matches = true;
Expand Down

0 comments on commit 0f4ca0c

Please sign in to comment.