-
Notifications
You must be signed in to change notification settings - Fork 384
/
Copy pathdps.js
489 lines (429 loc) · 21.6 KB
/
dps.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
// fiddle: http://jsfiddle.net/v1ddnsvh/8/
/* global window */
var IMAGE_PATH = '../../../resources/icon';
var EncountersArray = [];
var React = window.React;
var formatNumber = function(number) {
number = parseFloat(number, 10);
if (number >= 1000) {
return (number / 1000).toFixed(2) + 'K';
}
else if (number >= 1000000) {
return (number / 1000000).toFixed(2) + 'M';
}
return number.toFixed(2);
};
var ____Class0=React.Component;for(var ____Class0____Key in ____Class0){if(____Class0.hasOwnProperty(____Class0____Key)){CombatantCompact[____Class0____Key]=____Class0[____Class0____Key];}}var ____SuperProtoOf____Class0=____Class0===null?null:____Class0.prototype;CombatantCompact.prototype=Object.create(____SuperProtoOf____Class0);CombatantCompact.prototype.constructor=CombatantCompact;CombatantCompact.__superConstructor__=____Class0;function CombatantCompact(){"use strict";if(____Class0!==null){____Class0.apply(this,arguments);}}
Object.defineProperty(CombatantCompact.prototype,"jobImage",{writable:true,configurable:true,value:function(job) {"use strict";
if (window.JSFIDDLE) {
return window.GLOW_ICONS[job.toLowerCase()];
}
return IMAGE_PATH + '/jobs/' + job.toLowerCase() + '.png';
}});
Object.defineProperty(CombatantCompact.prototype,"render",{writable:true,configurable:true,value:function() {"use strict";
//var width = parseInt(this.props.data.damage / this.props.encounterDamage * 100, 10) + '%';
var width = Math.min(100, parseInt(this.props.total / this.props.max * 100, 10)) + '%';
return (
this.props.perSecond === '---' ? null :
React.createElement("li", {
className: 'row ' + this.props.job.toLowerCase() + (this.props.isSelf ? ' self' : ''),
onClick: this.props.onClick},
React.createElement("div", {
className: "bar",
style: {width: width}}),
React.createElement("div", {className: "text-overlay"},
React.createElement("div", {className: "stats"},
React.createElement("span", {className: "total"},
this.props.totalFormatted
),
this.props.additional ?
React.createElement("span", {className: "additional"},
"[", this.props.additional, "]"
) : null,
"(",
React.createElement("span", {className: "ps"},
this.props.perSecond, ","
),
React.createElement("span", {className: "percent"},
this.props.percentage
),
")"
),
React.createElement("div", {className: "info"},
React.createElement("span", {className: "job-icon"},
React.createElement("img", {src: this.jobImage(this.props.job)})
),
React.createElement("span", {className: "rank"},
this.props.rank, "."
),
React.createElement("span", {className: "character-name"},
this.props.characterName
),
React.createElement("span", {className: "character-job"},
this.props.job
)
)
)
)
);
}});
CombatantCompact.defaultProps = {
onClick:function() {}
};
var ____Class1=React.Component;for(var ____Class1____Key in ____Class1){if(____Class1.hasOwnProperty(____Class1____Key)){ChartView[____Class1____Key]=____Class1[____Class1____Key];}}var ____SuperProtoOf____Class1=____Class1===null?null:____Class1.prototype;ChartView.prototype=Object.create(____SuperProtoOf____Class1);ChartView.prototype.constructor=ChartView;ChartView.__superConstructor__=____Class1;function ChartView(){"use strict";if(____Class1!==null){____Class1.apply(this,arguments);}}
Object.defineProperty(ChartView.prototype,"render",{writable:true,configurable:true,value:function() {"use strict";
return (
React.createElement("div", {className: "chart-view"}
)
);
}});
var ____Class2=React.Component;for(var ____Class2____Key in ____Class2){if(____Class2.hasOwnProperty(____Class2____Key)){Header[____Class2____Key]=____Class2[____Class2____Key];}}var ____SuperProtoOf____Class2=____Class2===null?null:____Class2.prototype;Header.prototype=Object.create(____SuperProtoOf____Class2);Header.prototype.constructor=Header;Header.__superConstructor__=____Class2;
function Header(props) {"use strict";
____Class2.call(this,props);
this.state = {
expanded: false,
showEncountersList: false
};
}
Object.defineProperty(Header.prototype,"shouldComponentUpdate",{writable:true,configurable:true,value:function(nextProps) {"use strict";
if (nextProps.encounter.encdps === '---') {
return false;
}
return true;
}});
Object.defineProperty(Header.prototype,"handleExtraDetails",{writable:true,configurable:true,value:function(e) {"use strict";
this.props.onExtraDetailsClick(e);
this.setState({
expanded: !this.state.expanded
});
}});
/**
* Show dropdown for list of encounters
*/
Object.defineProperty(Header.prototype,"handleEncounterClick",{writable:true,configurable:true,value:function(e) {"use strict";
this.setState({
showEncountersList: !this.state.showEncountersList
});
}});
Object.defineProperty(Header.prototype,"render",{writable:true,configurable:true,value:function() {"use strict";
var encounter = this.props.encounter;
var rdps = parseFloat(encounter.encdps);
var rdps_max = 0;
if (!isNaN(rdps) && rdps !== Infinity) {
rdps_max = Math.max(rdps_max, rdps);
}
return (
React.createElement("div", {className: ("header " + (this.state.expanded ? '' : 'collapsed'))},
React.createElement("div", {className: "encounter-header"},
React.createElement("div", {className: "encounter-data ff-header"},
React.createElement("span", {className: "target-name dropdown-parent", onClick: this.handleEncounterClick.bind(this)},
encounter.title,
React.createElement("div", {className: ("dropdown-menu encounters-list-dropdown " + (this.state.showEncountersList ? '' : 'hidden'))},
React.createElement("div", {onClick: this.props.onSelectEncounter.bind(this, null)},
"Current Fight"
),
EncountersArray.map(function(encounter, i) {
return (
React.createElement("div", {key: i, onClick: this.props.onSelectEncounter.bind(this, i)},
encounter.Encounter.title
)
);
}.bind(this))
)
),
React.createElement("span", {className: "duration"},
"(", encounter.duration, ")"
),
React.createElement("span", {className: ("arrow " + (this.state.expanded ? 'up' : 'down')), onClick: this.handleExtraDetails.bind(this)})
),
React.createElement("div", {
className: "chart-view-switcher",
onClick: this.props.onViewChange},
this.props.currentView
)
),
React.createElement("div", {className: "extra-details"},
React.createElement("div", {className: "extra-row damage"},
React.createElement("div", {className: "cell"},
React.createElement("span", {className: "label ff-header"}, "Damage"),
React.createElement("span", {className: "value ff-text"},
formatNumber(encounter.damage)
)
),
React.createElement("div", {className: "cell"},
React.createElement("span", {className: "label ff-header"}, "DPS"),
React.createElement("span", {className: "value ff-text"},
formatNumber(encounter.encdps)
)
),
React.createElement("div", {className: "cell"},
React.createElement("span", {className: "label ff-header"}, "Crits"),
React.createElement("span", {className: "value ff-text"},
encounter['crithit%']
)
),
React.createElement("div", {className: "cell"},
React.createElement("span", {className: "label ff-header"}, "Miss"),
React.createElement("span", {className: "value ff-text"},
encounter['misses']
)
),
React.createElement("div", {className: "cell"},
React.createElement("span", {className: "label ff-header"}, "Max"),
React.createElement("span", {className: "value ff-text"},
encounter.maxhit
)
)
),
React.createElement("div", {className: "extra-row healing"},
React.createElement("div", {className: "cell"},
React.createElement("span", {className: "label ff-header"}, "Heals"),
React.createElement("span", {className: "value ff-text"},
formatNumber(encounter.healed)
)
),
React.createElement("div", {className: "cell"},
React.createElement("span", {className: "label ff-header"}, "HPS"),
React.createElement("span", {className: "value ff-text"},
formatNumber(encounter.enchps)
)
),
React.createElement("div", {className: "cell"},
React.createElement("span", {className: "label ff-header"}, "Crits"),
React.createElement("span", {className: "value ff-text"},
encounter['critheal%']
)
),
React.createElement("div", {className: "cell"},
React.createElement("span", {className: "label ff-header"}, "Max"),
React.createElement("span", {className: "value ff-text"},
encounter.maxheal
)
)
)
)
)
);
}});
Header.defaultProps = {
encounter: {},
onViewChange:function() {},
onSelectEncounter:function() {},
onExtraDetailsClick:function() {}
};
var ____Class3=React.Component;for(var ____Class3____Key in ____Class3){if(____Class3.hasOwnProperty(____Class3____Key)){Combatants[____Class3____Key]=____Class3[____Class3____Key];}}var ____SuperProtoOf____Class3=____Class3===null?null:____Class3.prototype;Combatants.prototype=Object.create(____SuperProtoOf____Class3);Combatants.prototype.constructor=Combatants;Combatants.__superConstructor__=____Class3;function Combatants(){"use strict";if(____Class3!==null){____Class3.apply(this,arguments);}}
Object.defineProperty(Combatants.prototype,"shouldComponentUpdate",{writable:true,configurable:true,value:function(nextProps) {"use strict";
// if data is empty then don't re-render
if (Object.getOwnPropertyNames(nextProps.data).length === 0) {
return false;
}
return true;
}});
Object.defineProperty(Combatants.prototype,"render",{writable:true,configurable:true,value:function() {"use strict";
var rows = [];
var maxRows = 12;
var isDataArray = _.isArray(this.props.data);
var dataArray = isDataArray ? this.props.data : Object.keys(this.props.data);
var limit = Math.max(dataArray.length, maxRows);
var names = dataArray.slice(0, maxRows-1);
var maxdps = false;
var combatant;
var row;
var isSelf;
var rank = 1;
var stats;
for (var i = 0; i < names.length; i++) {
combatant = isDataArray ? this.props.data[i] : this.props.data[names[i]];
stats = null;
isSelf = combatant.name === 'YOU' || combatant.name === 'You';
if (combatant.Job !== "") {
// should probably fix this
if (this.props.currentView === 'Healing') {
if (parseInt(combatant.healed, 10) > 0) {
if (!maxdps) {
maxdps = parseFloat(combatant.healed);
}
stats = {
job: combatant.Job || '',
characterName: combatant.name,
total: combatant.healed,
totalFormatted: formatNumber(combatant.healed),
perSecond: formatNumber(combatant.enchps),
additional: combatant['OverHealPct'],
percentage: combatant['healed%']
}
}
}
else if (this.props.currentView === 'Tanking') {
if (parseInt(combatant.damagetaken, 10) > 0) {
if (!maxdps) {
maxdps = parseFloat(combatant.damagetaken);
}
stats = {
job: combatant.Job || '',
characterName: combatant.name,
total: combatant.damagetaken,
totalFormatted: formatNumber(combatant.damagetaken),
perSecond: combatant.ParryPct,
percentage: combatant.BlockPct
}
}
}
else {
if (!maxdps) {
maxdps = parseFloat(combatant.damage);
}
stats = {
job: combatant.Job || '',
characterName: combatant.name,
total: combatant.damage,
totalFormatted: formatNumber(combatant.damage),
perSecond: formatNumber(combatant.encdps),
percentage: combatant['damage%']
}
}
if (stats) {
rows.push(
React.createElement(CombatantCompact, React.__spread({
onClick: this.props.onClick,
encounterDamage: this.props.encounterDamage,
rank: rank,
data: combatant,
isSelf: isSelf,
key: combatant.name,
max: maxdps},
stats)
)
);
rank++;
}
}
}
return (
React.createElement("ul", {className: "combatants"},
rows
)
);
}});
Combatants.defaultProps = {
onClick:function() {}
};
var ____Class4=React.Component;for(var ____Class4____Key in ____Class4){if(____Class4.hasOwnProperty(____Class4____Key)){DamageMeter[____Class4____Key]=____Class4[____Class4____Key];}}var ____SuperProtoOf____Class4=____Class4===null?null:____Class4.prototype;DamageMeter.prototype=Object.create(____SuperProtoOf____Class4);DamageMeter.prototype.constructor=DamageMeter;DamageMeter.__superConstructor__=____Class4;
function DamageMeter(props) {"use strict";
____Class4.call(this,props);
this.state = {
currentViewIndex: 0
};
}
Object.defineProperty(DamageMeter.prototype,"shouldComponentUpdate",{writable:true,configurable:true,value:function(nextProps, nextState) {"use strict";
if (nextProps.parseData.Encounter.encdps === '---') {
return false;
}
if (this.state.currentViewIndex !== nextState.currentViewIndex) {
return true;
}
if (this.state.selectedEncounter) {
return false;
}
return true;
}});
Object.defineProperty(DamageMeter.prototype,"componentWillReceiveProps",{writable:true,configurable:true,value:function(nextProps) {"use strict";
// save this encounter data
if (this.props.parseData.Encounter.title === 'Encounter' &&
nextProps.parseData.Encounter.title !== 'Encounter') {
EncountersArray.unshift({
Encounter: nextProps.parseData.Encounter,
Combatant: nextProps.parseData.Combatant
});
// Only keep the last 10 fights
if (EncountersArray.length > 10) {
EncountersArray.pop();
}
}
}});
Object.defineProperty(DamageMeter.prototype,"handleCombatRowClick",{writable:true,configurable:true,value:function(e) {"use strict";
}});
Object.defineProperty(DamageMeter.prototype,"handleClick",{writable:true,configurable:true,value:function(e) {"use strict";
}});
Object.defineProperty(DamageMeter.prototype,"handleViewChange",{writable:true,configurable:true,value:function(e) {"use strict";
var index = this.state.currentViewIndex;
if (index > this.props.chartViews.length-2) {
index = 0;
}
else {
index++;
}
this.setState({
currentViewIndex: index
});
}});
Object.defineProperty(DamageMeter.prototype,"handleSelectEncounter",{writable:true,configurable:true,value:function(index, e) {"use strict";
if (index >= 0) {
this.setState({
selectedEncounter: EncountersArray[index]
});
}
else {
this.setState({
selectedEncounter: null
});
}
this.render();
}});
Object.defineProperty(DamageMeter.prototype,"render",{writable:true,configurable:true,value:function() {"use strict";
var data = this.props.parseData.Combatant;
var encounterData = this.props.parseData.Encounter;
if (this.state.selectedEncounter) {
data = this.state.selectedEncounter.Combatant;
encounterData = this.state.selectedEncounter.Encounter;
}
else {
// Healing
// need to resort data if currentView is not damage
if (this.state.currentViewIndex === 1) {
data = _.sortBy(_.filter(data, function(d) {
return parseInt(d.healed, 10) > 0;
}), function(d) {
if (this.state.currentViewIndex === 1) {
return -parseInt(d.healed, 10);
}
}.bind(this));
}
// Tanking
else if (this.state.currentViewIndex === 2) {
data = _.sortBy(_.filter(data, function(d) {
return parseInt(d.damagetaken, 10) > 0;
}), function(d) {
if (this.state.currentViewIndex === 2) {
return -parseInt(d.damagetaken, 10);
}
}.bind(this));
}
}
return (
React.createElement("div", {
onClick: this.handleClick,
className: 'damage-meter' + (!this.props.parseData.isActive ? ' inactive' : '') + (!this.props.noJobColors ? ' show-job-colors' : '')},
React.createElement(Header, {
encounter: encounterData,
onViewChange: this.handleViewChange.bind(this),
onSelectEncounter: this.handleSelectEncounter.bind(this),
currentView: this.props.chartViews[this.state.currentViewIndex]}
),
React.createElement(Combatants, {
currentView: this.props.chartViews[this.state.currentViewIndex],
onClick: this.handleCombatRowClick,
data: data,
encounterDamage: encounterData.damage})
)
);
}});
DamageMeter.defaultProps = {
chartViews: [
'Damage',
'Healing',
'Tanking'
],
parseData: {},
noJobColors: false
};