-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsuzumod_vertical.js
163 lines (140 loc) · 6.09 KB
/
suzumod_vertical.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
const boxDpsHTML = `
<div class="container">
<div style="width: 100%"></div>
<div class="nameplate">{icon}<span class="name">{name}</span></div>
<div class="crdh">{crithit%}! {DirectHitPct}+ {CritDirectHitPct}!! {deaths}d</div>
<div style="width: 100%"></div>
<div class="dps" style="flex-grow: 1">{encdps} ({damage%})</div>
<div class="maxhit">{maxhit}</div>
<div style="width: 100%"></div>
<div class="lightbar"></div>
</div>
`;
const boxHpsHTML = `
<div id="hpsbar" style="">{name} {effhps}<br>({enchps} -{OverHealPct})</div>
<div class="lightbar"></div>
`;
let dpsAverage = 0;
let totalHPS = 0.0;
let topDps = 0.0;
// Statistics for Average DPS and Total HPS
function suzuMod(data) {
let dpsList = [];
duration = data.Encounter.DURATION;
totalHPS = 0.0;
topDps = 0.0;
for (let combatantName in data.Combatant){
let combatant = data.Combatant[combatantName];
if (isNaN(combatant["enchps"])) {
combatant["effhps"] = "---";
}
else {
let effhps = parseFloat(combatant["enchps"]) * (1.0 - parseFloat(combatant["OverHealPct"].slice(0, -1)) / 100);
combatant["effhps"] = effhps.toFixed(2).toString();
totalHPS += effhps;
}
if (roleDPSes.indexOf(combatant["Job"]) > -1) {
dpsList.push(parseFloat(combatant["encdps"]));
}
if (parseFloat(combatant["encdps"]) > topDps) {
topDps = parseFloat(combatant["encdps"]);
}
}
if (dpsList.length >= 1) {
dpsAverage = dpsList.reduce((i, j) => {return i + j; }) / dpsList.length;
} else {
dpsAverage = 0;
}
dpsAverage = dpsAverage.toFixed(2);
}
// Update encounter title
function updateEncounter(data) {
let encounterElem = document.getElementById('encounter');
encounterElem.innerText = parseActFormat(encounterTitle, data.Encounter);
}
function updateCombatantList(data) {
let tableD = document.getElementById("table_d");
let tableH = document.getElementById("table_h");
let tbodyDOld = tableD.tBodies.namedItem('tableBody_d');
let tbodyHOld = tableH.tBodies.namedItem('tableBody_h');
let tbodyDNew = document.createElement('tbody');
let tbodyHNew = document.createElement('tbody');
tbodyDNew.id = 'tableBody_d';
tbodyHNew.id = 'tableBody_h';
let tRowHps = tbodyHNew.insertRow(0);
let combatantIdx = 0;
let healerIdx = 0;
for (let combatant_name in data.Combatant)
{
// DPS bar
let tRowDps = tbodyDNew.insertRow(tbodyDNew.length);
let combatant = data.Combatant[combatant_name];
let boxCell = tRowDps.insertCell(0);
boxCell.innerHTML = parseActFormat(boxDpsHTML, combatant);
let lightBar = boxCell.getElementsByClassName("lightbar")[0];
lightBar.style.backgroundColor = lightBarColors[combatantIdx % 8];
lightBar.style.boxShadow = "0 -1px 4px " + lightBarColors[combatantIdx % 8];
lightBar.style.width = Math.round(100 * parseFloat(combatant["encdps"]) / topDps).toString() + "%";
if (combatant_name === "YOU") {
boxCell.childNodes[1].style.backgroundImage = "linear-gradient(to right, rgba(255, 255, 255, 0.43), rgba(255, 255, 255, 0))";
}
let nametag = boxCell.getElementsByClassName("name")[0];
if (combatant['deaths'] > 0) {
nametag.style.color = "#FFA0A0";
nametag.style.textShadow = "-1px 0 3px #802020, 0 1px 3px #802020, 1px 0 3px #802020, 0 -1px 3px #802020";
}
++combatantIdx;
let dpsMeter = boxCell.getElementsByClassName('dps')[0];
if ((dpsAverage > 0) && (duration > config.duration)) {
if ((combatant["encdps"] < dpsAverage * config.dpsLower / 100) && roleDPSes.indexOf(combatant["Job"]) > -1) {
// colorRed
dpsMeter.style.color = "#FFA0A0";
dpsMeter.style.textShadow = "-1px 0 3px #802020, 0 1px 3px #802020, 1px 0 3px #802020, 0 -1px 3px #802020";
}
// T+H
if ((combatant["encdps"] >= dpsAverage * config.dpsTank / 100 && roleTanks.indexOf(combatant["Job"]) > -1) ||
(combatant["encdps"] >= dpsAverage * config.dpsHealer / 100 && roleHealers.indexOf(combatant["Job"]) > -1)) {
// colorPurple
dpsMeter.style.color = "#EE82EE";
dpsMeter.style.textShadow = "-1px 0 3px #8A2BE2, 0 1px 3px #8A2BE2, 1px 0 3px #8A2BE2, 0 -1px 3px #8A2BE2";
}
// Common
if (combatant["encdps"] >= dpsAverage * config.dpsUpper / 100) {
// colorGold
dpsMeter.style.color = "#FFD700";
dpsMeter.style.textShadow = "-1px 0 3px #FFA500, 0 1px 3px #FFA500, 1px 0 3px #FFA500, 0 -1px 3px #FFA500";
}
}
// HPS bar
if (roleHealers.indexOf(combatant["Job"]) > -1)
{
let boxCell = tRowHps.insertCell(healerIdx);
boxCell.innerHTML = parseActFormat(boxHpsHTML, combatant);
if (totalHPS > 0)
boxCell.style.width = Math.round(combatant["effhps"] * 100 / totalHPS).toString() + "%";
else
boxCell.style.width = "0%";
let lightBar = boxCell.getElementsByClassName("lightbar")[0];
lightBar.style.backgroundColor = lightBarColors[(healerIdx + 3) % 8];
lightBar.style.height = "2px";
lightBar.style.opacity = "0.5";
lightBar.style.boxShadow = "0 -1px 2px " + lightBarColors[(healerIdx + 3) % 8];
++healerIdx;
}
}
if (healerIdx == 2) {
tRowHps.childNodes[1].style.textAlign = "right";
}
if (tbodyDOld != void(0)) {
tableD.replaceChild(tbodyDNew, tbodyDOld);
}
else {
tableD.appendChild(tbodyDNew);
}
if (tbodyHOld != void(0)) {
tableH.replaceChild(tbodyHNew, tbodyHOld);
}
else {
tableH.appendChild(tbodyHNew);
}
}