-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
71 lines (59 loc) · 1.69 KB
/
main.ts
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
import {
setAllPlayersToBench,
startPlayer,
} from "./src/page/page-interaction.ts";
import { lineupHasChanges } from "./src/page/page-querying.ts";
import { getPlayers } from "./src/page/get-players.ts";
import {
stylePlayerAsPossiblyInjured,
stylePlayerAsUnableToStart,
} from "./src/page/page-manipulation.ts";
import { verifyPage } from "./src/sanity-checks.ts";
import { prioritizePlayers } from "./src/prioritization/prioritization.ts";
setLineup();
async function setLineup() {
try {
if (!verifyPage()) {
return;
}
console.clear();
const players = await getPlayers();
setAllPlayersToBench(players);
let numPlayersStarted = 0;
prioritizePlayers(players).forEach(({ player, score, debugInfo }) => {
// For now, this is done on page load
// insertPlayerPredictedScore(player, score, { debugInfo });
// if (player.refinedPlayerStatus) {
// insertRefinedPlayerStatus(player, player.refinedPlayerStatus);
// }
if (!player.setPositionDropdown) {
return;
}
if (numPlayersStarted >= 9) {
return;
}
if (player.isTaxi || player.isIr) {
stylePlayerAsUnableToStart(player);
return;
}
const isInjured =
player.playerStatus === "DTD" || player.playerStatus === "OUT";
if (isInjured) {
stylePlayerAsPossiblyInjured(player);
}
const playerStarted = startPlayer(player, {
isAlternate: numPlayersStarted >= 9,
});
if (playerStarted) {
numPlayersStarted++;
}
});
if (lineupHasChanges()) {
// saveLineup();
}
} catch (error) {
console.error(error);
alert(error);
throw error;
}
}