Последняя активность 2 weeks ago

Версия f3fd5104d112345920b64ed1eec4b37e55b7936c

gistfile1.txt Исходник
1 function buildRows(historyKey: TGKey): ResultRow[] {
2 const { slot } = TGKey.parse(historyKey);
3 let players: UserKey[] = Attendance.players(historyKey);
4 const rows: ResultRow[] = [];
5
6 // Fallback — read from history file directly
7 if (players.length === 0) {
8 const history = Store.read<{ scores: TGScore[] }>(TGKey.toHistoryPath(historyKey));
9 if (history?.scores) {
10 players = [...new Set(history.scores.map((s: TGScore) => s.userKey))];
11 }
12 }
13
14 for (const userKey of players) {
15 const chars = CharacterRegistry.forUser(userKey);
16 // Find which character this user played in this TG
17 // by checking score history
18 for (const char of chars) {
19 const score = Score.get({ character: char, slot });
20 if (!score && chars.indexOf(char) < chars.length - 1) continue;
21
22 const wrEntry = WRank.entry(char.name, char.nation);
23 rows.push({
24 character: char,
25 score: score ?? undefined,
26 position: wrEntry ? {
27 currentRank: wrEntry.currentRank,
28 previousRank: wrEntry.previousRank,
29 } : undefined,
30 leavesCount: Leaves.countForChar({ characterName: char.name }),
31 });
32 break;
33 }
34 }
35
36 return rows;
37 }