rategame-shared 1.1.494 → 1.1.495

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/constants/earnedTags.d.ts +57 -0
  2. package/dist/constants/earnedTags.js +168 -0
  3. package/dist/constants/index.d.ts +2 -0
  4. package/dist/constants/index.js +2 -0
  5. package/dist/constants/leagueSupport.js +4 -4
  6. package/dist/constants/rankedTags.d.ts +23 -0
  7. package/dist/constants/rankedTags.js +77 -0
  8. package/dist/helpers/earnedTags/aggregates.d.ts +13 -0
  9. package/dist/helpers/earnedTags/aggregates.js +95 -0
  10. package/dist/helpers/earnedTags/evaluateFinalTags.d.ts +4 -0
  11. package/dist/helpers/earnedTags/evaluateFinalTags.js +83 -0
  12. package/dist/helpers/earnedTags/evaluateRatingTags.d.ts +8 -0
  13. package/dist/helpers/earnedTags/evaluateRatingTags.js +102 -0
  14. package/dist/helpers/earnedTags/fanGroups.d.ts +8 -0
  15. package/dist/helpers/earnedTags/fanGroups.js +38 -0
  16. package/dist/helpers/earnedTags/index.d.ts +6 -0
  17. package/dist/helpers/earnedTags/index.js +22 -0
  18. package/dist/helpers/earnedTags/paths.d.ts +4 -0
  19. package/dist/helpers/earnedTags/paths.js +25 -0
  20. package/dist/helpers/earnedTags/periods.d.ts +2 -0
  21. package/dist/helpers/earnedTags/periods.js +90 -0
  22. package/dist/helpers/ratingTags.d.ts +4 -0
  23. package/dist/helpers/ratingTags.js +18 -3
  24. package/dist/index.d.ts +5 -2
  25. package/dist/index.js +5 -2
  26. package/dist/models/rankedTags.d.ts +6 -0
  27. package/dist/models/rankedTags.js +2 -0
  28. package/dist/schemas/article.d.ts +16 -16
  29. package/dist/schemas/attendance.d.ts +6 -6
  30. package/dist/schemas/communityGame.d.ts +8 -8
  31. package/dist/schemas/experience.d.ts +24 -14
  32. package/dist/schemas/experience.js +2 -0
  33. package/dist/schemas/game.d.ts +1021 -90
  34. package/dist/schemas/game.js +6 -0
  35. package/dist/schemas/miniLeague.d.ts +8 -8
  36. package/dist/schemas/notification.d.ts +6 -6
  37. package/dist/schemas/pick.d.ts +2382 -288
  38. package/dist/schemas/poll.d.ts +916 -100
  39. package/dist/schemas/rankedTags.d.ts +108 -0
  40. package/dist/schemas/rankedTags.js +31 -0
  41. package/dist/schemas/rating.d.ts +12 -12
  42. package/dist/schemas/scorePrediction.d.ts +1844 -212
  43. package/dist/schemas/stadium.d.ts +20 -10
  44. package/dist/schemas/stadium.js +2 -0
  45. package/dist/schemas/trivia.d.ts +8 -8
  46. package/dist/schemas/voting.d.ts +394 -40
  47. package/package.json +1 -1
@@ -0,0 +1,57 @@
1
+ export declare const EARNED_TAG_IDS: {
2
+ readonly instantClassic: "instant-classic";
3
+ readonly certifiedClassic: "certified-classic";
4
+ readonly stoplightGame: "stoplight-game";
5
+ readonly hiddenGem: "hidden-gem";
6
+ readonly oneManShow: "one-man-show";
7
+ readonly respectWon: "respect-won";
8
+ readonly neutralApproved: "neutral-approved";
9
+ readonly notForEveryone: "not-for-everyone";
10
+ readonly certifiedStinker: "certified-stinker";
11
+ readonly defensiveMasterclass: "defensive-masterclass";
12
+ readonly comebackClassic: "comeback-classic";
13
+ readonly nobodySawItComing: "nobody-saw-it-coming";
14
+ readonly shootout: "shootout";
15
+ readonly majorUpset: "major-upset";
16
+ readonly winnerTakeAll: "winner-take-all";
17
+ readonly titleClincher: "title-clincher";
18
+ readonly ratings1k: "1k-ratings";
19
+ readonly ratings5k: "5k-ratings";
20
+ readonly ratings10k: "10k-ratings";
21
+ };
22
+ export type EarnedTagId = (typeof EARNED_TAG_IDS)[keyof typeof EARNED_TAG_IDS];
23
+ export declare const EARNED_TAG_DISPLAY_NAMES: Record<EarnedTagId, string>;
24
+ export declare const EARNED_TAG_RARITY_ORDER: EarnedTagId[];
25
+ export declare const RATING_MILESTONE_TAGS: EarnedTagId[];
26
+ export declare const RATING_MILESTONE_THRESHOLDS: Array<{
27
+ tag: EarnedTagId;
28
+ votes: number;
29
+ }>;
30
+ export type LeagueScoreLines = {
31
+ shootout: number;
32
+ defense: number;
33
+ comeback: number;
34
+ };
35
+ export declare const DEFAULT_SOCCER_SCORE_LINES: LeagueScoreLines;
36
+ export declare const LEAGUE_SCORE_LINES: Record<string, LeagueScoreLines>;
37
+ export declare const TITLE_CLINCHER_ROUND_NAMES: Record<string, string[]>;
38
+ export declare const STORED_RATING_THRESHOLDS: {
39
+ instantClassicAvg: number;
40
+ certifiedClassicAvg: number;
41
+ hiddenGemAvg: number;
42
+ respectWonAvg: number;
43
+ neutralApprovedAvg: number;
44
+ certifiedStinkerAvg: number;
45
+ defensiveMasterclassAvg: number;
46
+ comebackClassicAvg: number;
47
+ stoplightLosingMax: number;
48
+ stoplightNeutralMin: number;
49
+ stoplightNeutralMax: number;
50
+ stoplightWinningMin: number;
51
+ notForEveryoneStdDev: number;
52
+ };
53
+ export declare const COLLEGE_LEAGUES: Set<string>;
54
+ export declare function getLeagueScoreLines(league?: string): LeagueScoreLines | null;
55
+ export declare function getEarnedTagDisplayName(tag: string): string;
56
+ export declare function isRatingMilestoneTag(tag: string): boolean;
57
+ export declare function getSortedEarnedTags(tags: string[] | undefined): string[];
@@ -0,0 +1,168 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSortedEarnedTags = exports.isRatingMilestoneTag = exports.getEarnedTagDisplayName = exports.getLeagueScoreLines = exports.COLLEGE_LEAGUES = exports.STORED_RATING_THRESHOLDS = exports.TITLE_CLINCHER_ROUND_NAMES = exports.LEAGUE_SCORE_LINES = exports.DEFAULT_SOCCER_SCORE_LINES = exports.RATING_MILESTONE_THRESHOLDS = exports.RATING_MILESTONE_TAGS = exports.EARNED_TAG_RARITY_ORDER = exports.EARNED_TAG_DISPLAY_NAMES = exports.EARNED_TAG_IDS = void 0;
4
+ exports.EARNED_TAG_IDS = {
5
+ instantClassic: "instant-classic",
6
+ certifiedClassic: "certified-classic",
7
+ stoplightGame: "stoplight-game",
8
+ hiddenGem: "hidden-gem",
9
+ oneManShow: "one-man-show",
10
+ respectWon: "respect-won",
11
+ neutralApproved: "neutral-approved",
12
+ notForEveryone: "not-for-everyone",
13
+ certifiedStinker: "certified-stinker",
14
+ defensiveMasterclass: "defensive-masterclass",
15
+ comebackClassic: "comeback-classic",
16
+ nobodySawItComing: "nobody-saw-it-coming",
17
+ shootout: "shootout",
18
+ majorUpset: "major-upset",
19
+ winnerTakeAll: "winner-take-all",
20
+ titleClincher: "title-clincher",
21
+ ratings1k: "1k-ratings",
22
+ ratings5k: "5k-ratings",
23
+ ratings10k: "10k-ratings",
24
+ };
25
+ exports.EARNED_TAG_DISPLAY_NAMES = {
26
+ "instant-classic": "Instant Classic",
27
+ "certified-classic": "Certified Classic",
28
+ "stoplight-game": "Stoplight Game",
29
+ "hidden-gem": "Hidden Gem",
30
+ "one-man-show": "One-Man Show",
31
+ "respect-won": "Respect Won",
32
+ "neutral-approved": "Neutral Approved",
33
+ "not-for-everyone": "Not for Everyone",
34
+ "certified-stinker": "Certified Stinker",
35
+ "defensive-masterclass": "Defensive Masterclass",
36
+ "comeback-classic": "Comeback Classic",
37
+ "nobody-saw-it-coming": "Nobody Saw It Coming",
38
+ shootout: "Shootout",
39
+ "major-upset": "Major Upset",
40
+ "winner-take-all": "Winner-Take-All",
41
+ "title-clincher": "Title Clincher",
42
+ "1k-ratings": "1K Ratings",
43
+ "5k-ratings": "5K Ratings",
44
+ "10k-ratings": "10K Ratings",
45
+ };
46
+ exports.EARNED_TAG_RARITY_ORDER = [
47
+ "certified-stinker",
48
+ "not-for-everyone",
49
+ "instant-classic",
50
+ "certified-classic",
51
+ "defensive-masterclass",
52
+ "stoplight-game",
53
+ "respect-won",
54
+ "neutral-approved",
55
+ "one-man-show",
56
+ "nobody-saw-it-coming",
57
+ "hidden-gem",
58
+ "shootout",
59
+ "comeback-classic",
60
+ "major-upset",
61
+ "winner-take-all",
62
+ "title-clincher",
63
+ "1k-ratings",
64
+ "5k-ratings",
65
+ "10k-ratings",
66
+ ];
67
+ exports.RATING_MILESTONE_TAGS = [
68
+ exports.EARNED_TAG_IDS.ratings1k,
69
+ exports.EARNED_TAG_IDS.ratings5k,
70
+ exports.EARNED_TAG_IDS.ratings10k,
71
+ ];
72
+ exports.RATING_MILESTONE_THRESHOLDS = [
73
+ { tag: exports.EARNED_TAG_IDS.ratings10k, votes: 10000 },
74
+ { tag: exports.EARNED_TAG_IDS.ratings5k, votes: 5000 },
75
+ { tag: exports.EARNED_TAG_IDS.ratings1k, votes: 1000 },
76
+ ];
77
+ exports.DEFAULT_SOCCER_SCORE_LINES = {
78
+ shootout: 7,
79
+ defense: 1,
80
+ comeback: 2,
81
+ };
82
+ exports.LEAGUE_SCORE_LINES = {
83
+ nfl: { shootout: 75, defense: 20, comeback: 14 },
84
+ cfb: { shootout: 86, defense: 24, comeback: 14 },
85
+ nba: { shootout: 267, defense: 190, comeback: 15 },
86
+ ncaa: { shootout: 188, defense: 115, comeback: 12 },
87
+ cbb: { shootout: 188, defense: 115, comeback: 12 },
88
+ wnba: { shootout: 209, defense: 130, comeback: 12 },
89
+ mlb: { shootout: 19, defense: 2, comeback: 4 },
90
+ nhl: { shootout: 11, defense: 3, comeback: 3 },
91
+ epl: exports.DEFAULT_SOCCER_SCORE_LINES,
92
+ mls: exports.DEFAULT_SOCCER_SCORE_LINES,
93
+ cwc: exports.DEFAULT_SOCCER_SCORE_LINES,
94
+ fifa: exports.DEFAULT_SOCCER_SCORE_LINES,
95
+ laliga: exports.DEFAULT_SOCCER_SCORE_LINES,
96
+ seriea: exports.DEFAULT_SOCCER_SCORE_LINES,
97
+ bundesliga: exports.DEFAULT_SOCCER_SCORE_LINES,
98
+ ligue1: exports.DEFAULT_SOCCER_SCORE_LINES,
99
+ ucl: exports.DEFAULT_SOCCER_SCORE_LINES,
100
+ };
101
+ exports.TITLE_CLINCHER_ROUND_NAMES = {
102
+ nfl: ["Super Bowl"],
103
+ nba: ["Finals"],
104
+ nhl: ["Finals"],
105
+ mlb: ["World Series"],
106
+ cfb: ["Championship"],
107
+ ncaa: ["FNL"],
108
+ cbb: ["FNL"],
109
+ wnba: ["Finals"],
110
+ epl: ["Final"],
111
+ mls: ["Final", "MLS Cup"],
112
+ cwc: ["Final"],
113
+ fifa: ["Final"],
114
+ laliga: ["Final"],
115
+ seriea: ["Final"],
116
+ bundesliga: ["Final"],
117
+ ligue1: ["Final"],
118
+ ucl: ["Final"],
119
+ };
120
+ exports.STORED_RATING_THRESHOLDS = {
121
+ instantClassicAvg: 95,
122
+ certifiedClassicAvg: 95,
123
+ hiddenGemAvg: 85,
124
+ respectWonAvg: 70,
125
+ neutralApprovedAvg: 90,
126
+ certifiedStinkerAvg: 25,
127
+ defensiveMasterclassAvg: 80,
128
+ comebackClassicAvg: 85,
129
+ stoplightLosingMax: 33,
130
+ stoplightNeutralMin: 34,
131
+ stoplightNeutralMax: 66,
132
+ stoplightWinningMin: 67,
133
+ notForEveryoneStdDev: 25,
134
+ };
135
+ exports.COLLEGE_LEAGUES = new Set(["cfb", "ncaa", "cbb"]);
136
+ function getLeagueScoreLines(league) {
137
+ var _a;
138
+ if (!league) {
139
+ return null;
140
+ }
141
+ return (_a = exports.LEAGUE_SCORE_LINES[league]) !== null && _a !== void 0 ? _a : null;
142
+ }
143
+ exports.getLeagueScoreLines = getLeagueScoreLines;
144
+ function getEarnedTagDisplayName(tag) {
145
+ var _a;
146
+ return (_a = exports.EARNED_TAG_DISPLAY_NAMES[tag]) !== null && _a !== void 0 ? _a : tag;
147
+ }
148
+ exports.getEarnedTagDisplayName = getEarnedTagDisplayName;
149
+ function isRatingMilestoneTag(tag) {
150
+ return exports.RATING_MILESTONE_TAGS.includes(tag);
151
+ }
152
+ exports.isRatingMilestoneTag = isRatingMilestoneTag;
153
+ function getSortedEarnedTags(tags) {
154
+ if (!(tags === null || tags === void 0 ? void 0 : tags.length)) {
155
+ return [];
156
+ }
157
+ const rarityIndex = new Map(exports.EARNED_TAG_RARITY_ORDER.map((id, index) => [id, index]));
158
+ return [...tags].sort((left, right) => {
159
+ var _a, _b;
160
+ const leftRank = (_a = rarityIndex.get(left)) !== null && _a !== void 0 ? _a : 999;
161
+ const rightRank = (_b = rarityIndex.get(right)) !== null && _b !== void 0 ? _b : 999;
162
+ if (leftRank !== rightRank) {
163
+ return leftRank - rightRank;
164
+ }
165
+ return left.localeCompare(right);
166
+ });
167
+ }
168
+ exports.getSortedEarnedTags = getSortedEarnedTags;
@@ -1,2 +1,4 @@
1
1
  export * from "./leagueSupport";
2
2
  export * from "./soccerLeagues";
3
+ export * from "./earnedTags";
4
+ export * from "./rankedTags";
@@ -16,3 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./leagueSupport"), exports);
18
18
  __exportStar(require("./soccerLeagues"), exports);
19
+ __exportStar(require("./earnedTags"), exports);
20
+ __exportStar(require("./rankedTags"), exports);
@@ -60,7 +60,7 @@ exports.LEAGUE_CONFIG = {
60
60
  cwc: {
61
61
  playersPath: "leagues/cwc/teams",
62
62
  votingEnabled: false,
63
- displayName: "Cricket World Cup",
63
+ displayName: "Club World Cup",
64
64
  },
65
65
  fifa: {
66
66
  playersPath: "leagues/fifa/teams",
@@ -95,17 +95,17 @@ exports.LEAGUE_CONFIG = {
95
95
  cbb: {
96
96
  playersPath: "leagues/cbb/teams",
97
97
  votingEnabled: false,
98
- displayName: "College Basketball",
98
+ displayName: "CBB",
99
99
  },
100
100
  ncaa: {
101
101
  playersPath: "leagues/cbb/teams",
102
102
  votingEnabled: false,
103
- displayName: "College Basketball",
103
+ displayName: "NCAA Basketball",
104
104
  },
105
105
  cfb: {
106
106
  playersPath: "leagues/cfb/teams",
107
107
  votingEnabled: false,
108
- displayName: "College Football",
108
+ displayName: "CFB",
109
109
  },
110
110
  wnba: {
111
111
  playersPath: "leagues/wnba/teams",
@@ -0,0 +1,23 @@
1
+ export declare const RANKED_TAG_IDS: {
2
+ readonly mostRated: "mostRated";
3
+ readonly topRated: "topRated";
4
+ };
5
+ export type RankedTagId = (typeof RANKED_TAG_IDS)[keyof typeof RANKED_TAG_IDS];
6
+ export declare const RANKED_TAG_SEASON_GROUPS: readonly ["combined", "playoffs"];
7
+ export type RankedTagSeasonGroup = (typeof RANKED_TAG_SEASON_GROUPS)[number];
8
+ export declare const RANKED_TAG_LIMIT = 10;
9
+ export declare const EMPTY_RANKED_TAG_LISTS: Record<RankedTagId, Array<{
10
+ gameId: string;
11
+ rank: number;
12
+ }>>;
13
+ export declare const RANKED_TAG_TITLES: Record<RankedTagId, string>;
14
+ export declare function getRankedTagLeagues(): string[];
15
+ export declare function getRankedTagLeagueLabel(league: string): string;
16
+ export declare function isRankedTagId(slug: string): slug is RankedTagId;
17
+ export declare function isRankedTagSeasonGroup(value: string): value is RankedTagSeasonGroup;
18
+ export declare function getRankedTagListDocId(league: string, season: string, seasonGroup: RankedTagSeasonGroup): string;
19
+ export declare function getRankedTagFieldKey(sort: RankedTagId, season: string, seasonGroup: RankedTagSeasonGroup): string;
20
+ export declare function getRankedTagGameIds(lists: Partial<typeof EMPTY_RANKED_TAG_LISTS> | undefined, slug: string): string[];
21
+ export declare function getRankedTagPath(slug: string, league: string, season: string, seasonGroup: string): string;
22
+ export declare function getRankedTagPageTitle(slug: string, league?: string, season?: string, seasonGroup?: string): string;
23
+ export declare function buildRankedTagLabel(sort: RankedTagId, rank: number, league: string, season: string, seasonGroup: RankedTagSeasonGroup): string;
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildRankedTagLabel = exports.getRankedTagPageTitle = exports.getRankedTagPath = exports.getRankedTagGameIds = exports.getRankedTagFieldKey = exports.getRankedTagListDocId = exports.isRankedTagSeasonGroup = exports.isRankedTagId = exports.getRankedTagLeagueLabel = exports.getRankedTagLeagues = exports.RANKED_TAG_TITLES = exports.EMPTY_RANKED_TAG_LISTS = exports.RANKED_TAG_LIMIT = exports.RANKED_TAG_SEASON_GROUPS = exports.RANKED_TAG_IDS = void 0;
4
+ const leagueSupport_1 = require("./leagueSupport");
5
+ exports.RANKED_TAG_IDS = {
6
+ mostRated: "mostRated",
7
+ topRated: "topRated",
8
+ };
9
+ exports.RANKED_TAG_SEASON_GROUPS = ["combined", "playoffs"];
10
+ exports.RANKED_TAG_LIMIT = 10;
11
+ exports.EMPTY_RANKED_TAG_LISTS = {
12
+ mostRated: [],
13
+ topRated: [],
14
+ };
15
+ exports.RANKED_TAG_TITLES = {
16
+ mostRated: "Most Rated",
17
+ topRated: "Top Rated",
18
+ };
19
+ function getRankedTagLeagues() {
20
+ return Object.keys(leagueSupport_1.LEAGUE_CONFIG).filter((league) => league !== "global" && league !== "cbb");
21
+ }
22
+ exports.getRankedTagLeagues = getRankedTagLeagues;
23
+ function getRankedTagLeagueLabel(league) {
24
+ var _a, _b;
25
+ return ((_b = (_a = leagueSupport_1.LEAGUE_CONFIG[league]) === null || _a === void 0 ? void 0 : _a.displayName) !== null && _b !== void 0 ? _b : league.toUpperCase());
26
+ }
27
+ exports.getRankedTagLeagueLabel = getRankedTagLeagueLabel;
28
+ function isRankedTagId(slug) {
29
+ return Object.values(exports.RANKED_TAG_IDS).includes(slug);
30
+ }
31
+ exports.isRankedTagId = isRankedTagId;
32
+ function isRankedTagSeasonGroup(value) {
33
+ return exports.RANKED_TAG_SEASON_GROUPS.includes(value);
34
+ }
35
+ exports.isRankedTagSeasonGroup = isRankedTagSeasonGroup;
36
+ function getRankedTagListDocId(league, season, seasonGroup) {
37
+ return `${league}_${season.replace("/", "-")}_${seasonGroup}`;
38
+ }
39
+ exports.getRankedTagListDocId = getRankedTagListDocId;
40
+ function getRankedTagFieldKey(sort, season, seasonGroup) {
41
+ return `${sort}_${seasonGroup}_${season.replace("/", "-")}`;
42
+ }
43
+ exports.getRankedTagFieldKey = getRankedTagFieldKey;
44
+ function getRankedTagGameIds(lists, slug) {
45
+ var _a;
46
+ if (!lists || !isRankedTagId(slug)) {
47
+ return [];
48
+ }
49
+ return ((_a = lists[slug]) !== null && _a !== void 0 ? _a : []).map((entry) => entry.gameId).filter(Boolean);
50
+ }
51
+ exports.getRankedTagGameIds = getRankedTagGameIds;
52
+ function getRankedTagPath(slug, league, season, seasonGroup) {
53
+ return `/games/ranked/${encodeURIComponent(slug)}?league=${encodeURIComponent(league)}&season=${encodeURIComponent(season)}&seasonGroup=${encodeURIComponent(seasonGroup)}`;
54
+ }
55
+ exports.getRankedTagPath = getRankedTagPath;
56
+ function getRankedTagPageTitle(slug, league, season, seasonGroup) {
57
+ const title = isRankedTagId(slug) ? exports.RANKED_TAG_TITLES[slug] : slug;
58
+ const parts = [title];
59
+ if (league) {
60
+ const leagueLabel = getRankedTagLeagueLabel(league);
61
+ parts.push(seasonGroup === "playoffs" ? `${leagueLabel} Playoffs` : leagueLabel);
62
+ }
63
+ if (season) {
64
+ parts.push(season);
65
+ }
66
+ return parts.join(" • ");
67
+ }
68
+ exports.getRankedTagPageTitle = getRankedTagPageTitle;
69
+ function buildRankedTagLabel(sort, rank, league, season, seasonGroup) {
70
+ const leagueLabel = getRankedTagLeagueLabel(league);
71
+ const prefix = exports.RANKED_TAG_TITLES[sort];
72
+ if (seasonGroup === "playoffs") {
73
+ return `#${rank} ${prefix} • ${leagueLabel} Playoffs • ${season}`;
74
+ }
75
+ return `#${rank} ${prefix} • ${leagueLabel} • ${season}`;
76
+ }
77
+ exports.buildRankedTagLabel = buildRankedTagLabel;
@@ -0,0 +1,13 @@
1
+ import { GameRatingAggregate, UnionGame, WeightedRatingAggregate } from "../../models/game";
2
+ export declare function getVoteCount(game: UnionGame): number;
3
+ export declare function getWeightedAvg(game: UnionGame): number;
4
+ export declare function getCombinedScore(game: UnionGame): number;
5
+ export declare function getGroupVoteCount(group: WeightedRatingAggregate | undefined): number;
6
+ export declare function getGroupAvg(group: WeightedRatingAggregate | undefined): number;
7
+ export declare function hasDecidedWinner(game: UnionGame): boolean;
8
+ export declare function isHomeWinner(game: UnionGame): boolean;
9
+ export declare function getWinnerPickShare(game: UnionGame): number | null;
10
+ export declare function getTotalPickCount(game: UnionGame): number;
11
+ export declare function getRatingStdDev(rating: GameRatingAggregate | undefined): number;
12
+ export declare function minutesSinceFinish(game: UnionGame, now?: number): number;
13
+ export declare function daysSinceFinish(game: UnionGame, now?: number): number;
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.daysSinceFinish = exports.minutesSinceFinish = exports.getRatingStdDev = exports.getTotalPickCount = exports.getWinnerPickShare = exports.isHomeWinner = exports.hasDecidedWinner = exports.getGroupAvg = exports.getGroupVoteCount = exports.getCombinedScore = exports.getWeightedAvg = exports.getVoteCount = void 0;
4
+ function getVoteCount(game) {
5
+ var _a, _b, _c, _d;
6
+ return (_d = (_c = (_b = (_a = game.ratings) === null || _a === void 0 ? void 0 : _a.weightedRating) === null || _b === void 0 ? void 0 : _b.votes) === null || _c === void 0 ? void 0 : _c.total) !== null && _d !== void 0 ? _d : 0;
7
+ }
8
+ exports.getVoteCount = getVoteCount;
9
+ function getWeightedAvg(game) {
10
+ var _a, _b, _c;
11
+ return (_c = (_b = (_a = game.ratings) === null || _a === void 0 ? void 0 : _a.weightedRating) === null || _b === void 0 ? void 0 : _b.avg) !== null && _c !== void 0 ? _c : 0;
12
+ }
13
+ exports.getWeightedAvg = getWeightedAvg;
14
+ function getCombinedScore(game) {
15
+ var _a, _b, _c, _d;
16
+ return ((_b = (_a = game.homeTeam) === null || _a === void 0 ? void 0 : _a.score) !== null && _b !== void 0 ? _b : 0) + ((_d = (_c = game.awayTeam) === null || _c === void 0 ? void 0 : _c.score) !== null && _d !== void 0 ? _d : 0);
17
+ }
18
+ exports.getCombinedScore = getCombinedScore;
19
+ function getGroupVoteCount(group) {
20
+ var _a, _b;
21
+ return (_b = (_a = group === null || group === void 0 ? void 0 : group.votes) === null || _a === void 0 ? void 0 : _a.total) !== null && _b !== void 0 ? _b : 0;
22
+ }
23
+ exports.getGroupVoteCount = getGroupVoteCount;
24
+ function getGroupAvg(group) {
25
+ var _a;
26
+ return (_a = group === null || group === void 0 ? void 0 : group.avg) !== null && _a !== void 0 ? _a : 0;
27
+ }
28
+ exports.getGroupAvg = getGroupAvg;
29
+ function hasDecidedWinner(game) {
30
+ var _a, _b, _c, _d, _e, _f;
31
+ const homeScore = (_b = (_a = game.homeTeam) === null || _a === void 0 ? void 0 : _a.score) !== null && _b !== void 0 ? _b : 0;
32
+ const awayScore = (_d = (_c = game.awayTeam) === null || _c === void 0 ? void 0 : _c.score) !== null && _d !== void 0 ? _d : 0;
33
+ if (((_e = game.homeTeam) === null || _e === void 0 ? void 0 : _e.isWinner) || ((_f = game.awayTeam) === null || _f === void 0 ? void 0 : _f.isWinner)) {
34
+ return true;
35
+ }
36
+ return homeScore !== awayScore;
37
+ }
38
+ exports.hasDecidedWinner = hasDecidedWinner;
39
+ function isHomeWinner(game) {
40
+ var _a, _b, _c, _d, _e, _f;
41
+ if ((_a = game.homeTeam) === null || _a === void 0 ? void 0 : _a.isWinner) {
42
+ return true;
43
+ }
44
+ if ((_b = game.awayTeam) === null || _b === void 0 ? void 0 : _b.isWinner) {
45
+ return false;
46
+ }
47
+ return ((_d = (_c = game.homeTeam) === null || _c === void 0 ? void 0 : _c.score) !== null && _d !== void 0 ? _d : 0) > ((_f = (_e = game.awayTeam) === null || _e === void 0 ? void 0 : _e.score) !== null && _f !== void 0 ? _f : 0);
48
+ }
49
+ exports.isHomeWinner = isHomeWinner;
50
+ function getWinnerPickShare(game) {
51
+ var _a, _b, _c, _d;
52
+ const homePicks = (_b = (_a = game.homeTeam) === null || _a === void 0 ? void 0 : _a.pickCount) !== null && _b !== void 0 ? _b : 0;
53
+ const awayPicks = (_d = (_c = game.awayTeam) === null || _c === void 0 ? void 0 : _c.pickCount) !== null && _d !== void 0 ? _d : 0;
54
+ const totalPicks = homePicks + awayPicks;
55
+ if (totalPicks <= 0) {
56
+ return null;
57
+ }
58
+ const winnerPicks = isHomeWinner(game) ? homePicks : awayPicks;
59
+ return winnerPicks / totalPicks;
60
+ }
61
+ exports.getWinnerPickShare = getWinnerPickShare;
62
+ function getTotalPickCount(game) {
63
+ var _a, _b, _c, _d;
64
+ return ((_b = (_a = game.homeTeam) === null || _a === void 0 ? void 0 : _a.pickCount) !== null && _b !== void 0 ? _b : 0) + ((_d = (_c = game.awayTeam) === null || _c === void 0 ? void 0 : _c.pickCount) !== null && _d !== void 0 ? _d : 0);
65
+ }
66
+ exports.getTotalPickCount = getTotalPickCount;
67
+ function getRatingStdDev(rating) {
68
+ var _a;
69
+ const votes = rating === null || rating === void 0 ? void 0 : rating.votes;
70
+ if (!(votes === null || votes === void 0 ? void 0 : votes.total) || votes.total < 2) {
71
+ return 0;
72
+ }
73
+ const mean = (_a = rating === null || rating === void 0 ? void 0 : rating.avg) !== null && _a !== void 0 ? _a : 0;
74
+ let varianceSum = 0;
75
+ for (const [storedValue, count] of Object.entries(votes.options || {})) {
76
+ const delta = Number(storedValue) - mean;
77
+ varianceSum += count * delta * delta;
78
+ }
79
+ return Math.sqrt(varianceSum / votes.total);
80
+ }
81
+ exports.getRatingStdDev = getRatingStdDev;
82
+ function minutesSinceFinish(game, now = Date.now()) {
83
+ if (!game.finishedAt) {
84
+ return Number.POSITIVE_INFINITY;
85
+ }
86
+ return (now - game.finishedAt) / (60 * 1000);
87
+ }
88
+ exports.minutesSinceFinish = minutesSinceFinish;
89
+ function daysSinceFinish(game, now = Date.now()) {
90
+ if (!game.finishedAt) {
91
+ return 0;
92
+ }
93
+ return (now - game.finishedAt) / (24 * 60 * 60 * 1000);
94
+ }
95
+ exports.daysSinceFinish = daysSinceFinish;
@@ -0,0 +1,4 @@
1
+ import { type EarnedTagId } from "../../constants/earnedTags";
2
+ import { UnionGame } from "../../models/game";
3
+ export declare function alreadyHas(game: UnionGame, tag: EarnedTagId): boolean;
4
+ export declare function evaluateFinalEarnedTags(game: UnionGame): EarnedTagId[];
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.evaluateFinalEarnedTags = exports.alreadyHas = void 0;
4
+ const earnedTags_1 = require("../../constants/earnedTags");
5
+ const aggregates_1 = require("./aggregates");
6
+ function alreadyHas(game, tag) {
7
+ var _a;
8
+ return ((_a = game.earnedTags) !== null && _a !== void 0 ? _a : []).includes(tag);
9
+ }
10
+ exports.alreadyHas = alreadyHas;
11
+ function isLastGameOfSeries(game) {
12
+ const seriesInfo = game.seriesInfo;
13
+ if ((seriesInfo === null || seriesInfo === void 0 ? void 0 : seriesInfo.gameNumber) == null || (seriesInfo === null || seriesInfo === void 0 ? void 0 : seriesInfo.maxLength) == null) {
14
+ return false;
15
+ }
16
+ return seriesInfo.gameNumber === seriesInfo.maxLength;
17
+ }
18
+ function evaluateMajorUpset(game) {
19
+ var _a, _b, _c, _d;
20
+ if (!(0, aggregates_1.hasDecidedWinner)(game)) {
21
+ return false;
22
+ }
23
+ const homeSeed = (_b = (_a = game.homeTeam) === null || _a === void 0 ? void 0 : _a.seed) !== null && _b !== void 0 ? _b : null;
24
+ const awaySeed = (_d = (_c = game.awayTeam) === null || _c === void 0 ? void 0 : _c.seed) !== null && _d !== void 0 ? _d : null;
25
+ const winnerSeed = (0, aggregates_1.isHomeWinner)(game) ? homeSeed : awaySeed;
26
+ const loserSeed = (0, aggregates_1.isHomeWinner)(game) ? awaySeed : homeSeed;
27
+ const isCollege = earnedTags_1.COLLEGE_LEAGUES.has(game.league || "");
28
+ if (isCollege) {
29
+ if (winnerSeed == null && loserSeed != null && loserSeed <= 10) {
30
+ return true;
31
+ }
32
+ if (winnerSeed != null &&
33
+ loserSeed != null &&
34
+ winnerSeed - loserSeed >= 4) {
35
+ return true;
36
+ }
37
+ return false;
38
+ }
39
+ if (winnerSeed != null && loserSeed != null && winnerSeed - loserSeed >= 4) {
40
+ return true;
41
+ }
42
+ if ((game === null || game === void 0 ? void 0 : game.seasonType) === 1) {
43
+ const pickShare = (0, aggregates_1.getWinnerPickShare)(game);
44
+ return ((0, aggregates_1.getTotalPickCount)(game) >= 25 && pickShare != null && pickShare < 0.25);
45
+ }
46
+ return false;
47
+ }
48
+ function evaluateFinalEarnedTags(game) {
49
+ const earned = [];
50
+ if ((0, aggregates_1.hasDecidedWinner)(game) &&
51
+ !alreadyHas(game, earnedTags_1.EARNED_TAG_IDS.nobodySawItComing)) {
52
+ const pickShare = (0, aggregates_1.getWinnerPickShare)(game);
53
+ if ((0, aggregates_1.getTotalPickCount)(game) >= 25 &&
54
+ pickShare != null &&
55
+ pickShare <= 0.15) {
56
+ earned.push(earnedTags_1.EARNED_TAG_IDS.nobodySawItComing);
57
+ }
58
+ }
59
+ const scoreLines = (0, earnedTags_1.getLeagueScoreLines)(game.league);
60
+ if (scoreLines &&
61
+ !alreadyHas(game, earnedTags_1.EARNED_TAG_IDS.shootout) &&
62
+ (0, aggregates_1.getCombinedScore)(game) >= scoreLines.shootout) {
63
+ earned.push(earnedTags_1.EARNED_TAG_IDS.shootout);
64
+ }
65
+ if (!alreadyHas(game, earnedTags_1.EARNED_TAG_IDS.majorUpset) &&
66
+ evaluateMajorUpset(game)) {
67
+ earned.push(earnedTags_1.EARNED_TAG_IDS.majorUpset);
68
+ }
69
+ if (!alreadyHas(game, earnedTags_1.EARNED_TAG_IDS.winnerTakeAll) &&
70
+ isLastGameOfSeries(game)) {
71
+ earned.push(earnedTags_1.EARNED_TAG_IDS.winnerTakeAll);
72
+ }
73
+ const championshipNames = earnedTags_1.TITLE_CLINCHER_ROUND_NAMES[game.league || ""] || [];
74
+ if (!alreadyHas(game, earnedTags_1.EARNED_TAG_IDS.titleClincher) &&
75
+ game.roundName &&
76
+ championshipNames.includes(game.roundName)) {
77
+ if (!game.seriesInfo || isLastGameOfSeries(game)) {
78
+ earned.push(earnedTags_1.EARNED_TAG_IDS.titleClincher);
79
+ }
80
+ }
81
+ return earned;
82
+ }
83
+ exports.evaluateFinalEarnedTags = evaluateFinalEarnedTags;
@@ -0,0 +1,8 @@
1
+ import { type EarnedTagId } from "../../constants/earnedTags";
2
+ import { UnionGame } from "../../models/game";
3
+ export type RatingEarnedTagExtras = {
4
+ now?: number;
5
+ topPlayerVoteShare?: number | null;
6
+ playerVoteCount?: number;
7
+ };
8
+ export declare function evaluateRatingEarnedTags(game: UnionGame, extras?: RatingEarnedTagExtras): EarnedTagId[];