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
|
import * as maps from './maps/maps';
const MODES = [ 'casual_aral', 'blitz_pvp_ranked' ];
const POPULAR_THRESHOLD = 0.1;
export default class ReportService {
constructor() {
this.report = require('../data/98aae7f0/report.json')
.filter((entry) => entry.Actor != undefined); // bad data from API downtime
this.reports = {};
this.totalPicks = {};
this.top10Relevancy = {};
this.topPicks = {};
this.topWins = {};
this.topRareWins = {};
this.topEpicWins = {};
this.topLegendaryWins = {};
this.topLeveledUp = {};
this.topLeveledDown = {};
this.topUnpopularWins = {};
this.actors = [];
this.modes = MODES;
for(let mode of MODES) {
const relevancy = (entry) => (entry.Count / this.totalPicks[mode]) * (entry.Winner / entry.Count);
this.reports[mode] = this.report.filter((entry) => entry.Mode == mode);
this.totalPicks[mode] = this.report.map((entry) => entry.Count).reduce((agg, cur) => agg + cur, 0);
this.top10Relevancy[mode] = this.reports[mode].sort((entry1, entry2) => relevancy(entry2) - relevancy(entry1)).slice(0, 10);
this.topPicks[mode] = this.reports[mode].sort((entry1, entry2) => entry2.Count - entry1.Count)[0];
this.topWins[mode] = this.reports[mode]
.filter((entry) => 100 * 6 * entry.Count / this.totalPicks[mode] > POPULAR_THRESHOLD)
.sort((entry1, entry2) => entry2.Winner - entry1.Winner)[0];
this.topUnpopularWins[mode] = this.reports[mode]
.filter((entry) => 100 * 6 * entry.Count / this.totalPicks[mode] <= POPULAR_THRESHOLD)
.sort((entry1, entry2) => entry2.Winner - entry1.Winner)[0];
this.topRareWins[mode] = this.reports[mode]
.filter((entry) => maps.getTalentRarity(entry.Talent) == 'Rare' && 100 * 6 * entry.Count / this.totalPicks[mode] > POPULAR_THRESHOLD)
.sort((entry1, entry2) => entry2.Winner - entry1.Winner)[0];
this.topEpicWins[mode] = this.reports[mode]
.filter((entry) => maps.getTalentRarity(entry.Talent) == 'Epic' && 100 * 6 * entry.Count / this.totalPicks[mode] > POPULAR_THRESHOLD)
.sort((entry1, entry2) => entry2.Winner - entry1.Winner)[0];
this.topLegendaryWins[mode] = this.reports[mode]
.filter((entry) => maps.getTalentRarity(entry.Talent) == 'Legendary' && 100 * 6 * entry.Count / this.totalPicks[mode] > POPULAR_THRESHOLD)
.sort((entry1, entry2) => entry2.Winner - entry1.Winner)[0];
this.topLeveledUp[mode] = this.reports[mode].sort((entry1, entry2) => {
if (!entry1.Level) return 1;
if (!entry2.Level) return -1;
return entry1.Level < entry2.Level ? 1 : -1;
})[0];
this.topLeveledDown[mode] = this.reports[mode].sort((entry1, entry2) => {
if (!entry1.Level) return 1;
if (!entry2.Level) return -1;
return entry1.Level < entry2.Level ? -1 : 1;
})[0];
if (this.actors.length == 0) {
this.actors = [...new Set(this.reports[mode].map((entry) => entry.Actor))];
}
}
}
getReport(mode) {
return this.reports[mode];
}
getTotalPicks(mode) {
return this.totalPicks[mode];
}
getTopPick(mode) {
return this.topPicks[mode];
}
getTop10Picks(mode) {
return this.top10Relevancy[mode];
}
getHighestLevelAvg(mode) {
return this.topLeveledUp[mode];
}
getLowestLevelAvg(mode) {
return this.topLeveledDown[mode];
}
getTopWin(mode) {
return this.topWins[mode];
}
getTopUnpopularWin(mode) {
return this.topUnpopularWins[mode];
}
getTopRareWins(mode) {
return this.topRareWins[mode];
}
getTopEpicWins(mode) {
return this.topEpicWins[mode];
}
getTopLegendaryWins(mode) {
return this.topLegendaryWins[mode];
}
getBestUnpopular(mode) {
return this.topUnpopular[mode];
}
getActors() {
return this.actors;
}
getModes() {
return this.modes;
}
}
|