nuno ревизій цього gist 2 weeks ago. До ревизії
1 file changed, 44 insertions
gistfile1.txt(файл створено)
| @@ -0,0 +1,44 @@ | |||
| 1 | + | function buildEntries(nation: Nation, week: WRankWeek): LeaderboardEntry[] { | |
| 2 | + | const wRankEntries = WRank.entriesForNation(nation, week); | |
| 3 | + | ||
| 4 | + | return wRankEntries.map((wr): LeaderboardEntry => { | |
| 5 | + | const char = wr.character; | |
| 6 | + | ||
| 7 | + | // Aggregate K/D and stats from all active slots this week | |
| 8 | + | let totalKills = 0; | |
| 9 | + | let totalDeaths = 0; | |
| 10 | + | let totalAtk = 0; | |
| 11 | + | let totalDef = 0; | |
| 12 | + | let totalHeal = 0; | |
| 13 | + | ||
| 14 | + | for (const historyKey of (week.scoreIndex[char.name] ?? [])) { | |
| 15 | + | const score = Score.get({ | |
| 16 | + | character: char, | |
| 17 | + | slot: TGKey.parse(historyKey as TGKey).slot, | |
| 18 | + | historyKey: historyKey as TGKey, | |
| 19 | + | }); | |
| 20 | + | if (!score) continue; | |
| 21 | + | totalKills += score.k ?? 0; | |
| 22 | + | totalDeaths += score.d ?? 0; | |
| 23 | + | totalAtk += score.atk ?? 0; | |
| 24 | + | totalDef += score.def ?? 0; | |
| 25 | + | totalHeal += score.heal ?? 0; | |
| 26 | + | } | |
| 27 | + | ||
| 28 | + | return { | |
| 29 | + | character: char, | |
| 30 | + | weeklyPts: wr.weeklyPoints, | |
| 31 | + | tgCount: wr.tgCount, | |
| 32 | + | totalKills, | |
| 33 | + | totalDeaths, | |
| 34 | + | stats: { | |
| 35 | + | atk: totalAtk || undefined, | |
| 36 | + | def: totalDef || undefined, | |
| 37 | + | heal: totalHeal || undefined, | |
| 38 | + | }, | |
| 39 | + | currentRank: wr.currentRank, | |
| 40 | + | previousRank: wr.previousRank, | |
| 41 | + | leavesCount: Leaves.countForChar({ characterName: char.name }), | |
| 42 | + | }; | |
| 43 | + | }); | |
| 44 | + | } | |
Новіше
Пізніше