@sportsbroker/firebase-structure 8.2.0 → 8.3.0

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.
@@ -19,7 +19,9 @@ export enum GameEngineEnum {
19
19
  MATCH_PREDICTOR = "match-predictor",
20
20
  EDGE = "edge",
21
21
  /** Golden Coin: an in-play table game, settled once at full time. Question-less. */
22
- COIN_PASS = "coin-pass"
22
+ COIN_PASS = "coin-pass",
23
+ /** Bingo: an in-play card game. Tiles cross off the live feed; settled at full time. */
24
+ BINGO = "bingo"
23
25
  }
24
26
 
25
27
  /**
@@ -23,6 +23,19 @@ export type Bet = {
23
23
  * bets are immutable once placed, so a single placement timestamp is enough.
24
24
  */
25
25
  betPlaceDate: ISODate;
26
+ /**
27
+ * What this bet was PAID when its pool settled, in the pool's currency. Present only once the bet is
28
+ * settled (`won` / `lost`), which is the only time it means anything: a bet still being played has
29
+ * not been paid, and publishing 0 for it would be indistinguishable from a bet that won nothing.
30
+ *
31
+ * It is here rather than on the leaderboard because a leaderboard shows a handful of positions while
32
+ * every player needs to be told what THEY got - including a player who took a prize without finishing
33
+ * anywhere near the top, which is exactly what a line prize is.
34
+ *
35
+ * A refunded pool pays each entry its own stake back and is reported the same way, so a client always
36
+ * has one number to show and never has to work out which case it is in.
37
+ */
38
+ prize?: number;
26
39
  };
27
40
 
28
41
  export enum BetStatusEnum {
@@ -10,7 +10,7 @@ import type { ISODate, UUID } from "../common";
10
10
  * An event document, in whichever shape its engine projects. Narrow on `engine` before reading:
11
11
  * a Golden Coin event carries no questions and a prediction event carries no coin state.
12
12
  */
13
- export type AnyEvent = Event | CoinEvent;
13
+ export type AnyEvent = Event | CoinEvent | BingoEvent;
14
14
 
15
15
  export type Event = {
16
16
  id: UUID;
@@ -71,6 +71,76 @@ export type CoinEventState = {
71
71
  fullTimePassCount: number | null;
72
72
  };
73
73
 
74
+ /**
75
+ * A Bingo event document. Everything here is a MATCH-level fact shared by every pool of the match: the
76
+ * shape of the card the game deals, how the pot is cut, and what the live feed has confirmed so far.
77
+ * The per-player card lives on the bet document and the per-pool claims on the pool document, so a
78
+ * client reads this one to know what the game IS and what the match has done.
79
+ */
80
+ export type BingoEvent = {
81
+ id: UUID;
82
+ startDate: ISODate;
83
+ status: BetEventStatusType;
84
+ bettingStatus: BetEventBettingStatusType;
85
+ engine: GameEngineEnum.BINGO;
86
+ name: string;
87
+ resultsUpdateReason: string | null;
88
+ matchIds?: UUID[];
89
+ bingo: BingoEventState;
90
+ };
91
+
92
+ export type BingoEventState = {
93
+ /** Cards are `gridSize` x `gridSize`. */
94
+ gridSize: number;
95
+ /** Which runs of crossed tiles count as a line. */
96
+ linesRule: string;
97
+ /** How many tiles of each rarity every card holds. The three add up to the card exactly. */
98
+ rarityMixture: BingoRarityMixture;
99
+ /** Fewest players for the game to be played; below it every stake goes back in full. */
100
+ minCardsPerPool: number;
101
+ /** A cap on entries per pool, or null for no cap. */
102
+ maxCardsPerPool: number | null;
103
+ /**
104
+ * What completing lines pays, cheapest first: one entry per prize, each naming how many lines it is
105
+ * for and its share of the pot. A game with a single entry is the classic one-line game; two entries
106
+ * give the hall game everybody knows (one line, two lines, full house).
107
+ */
108
+ linePrizes: BingoLinePrize[];
109
+ /** Percent of the pot for the full house. The leaderboard takes whatever is left after all of it. */
110
+ fullHousePrizePercent: number;
111
+ /** Where the full house prize goes when nobody fills a card. */
112
+ unclaimedHouseShare: "closest-card" | "roll-to-leaderboard";
113
+ /**
114
+ * How many confirmed feed snapshots have moved the match on. Every crossing on every card is
115
+ * judged against this sequence, so a client can tell a stale view from a settled one.
116
+ */
117
+ seq: number;
118
+ /**
119
+ * What the feed has confirmed for each stat this game's tiles are written against, keyed by the
120
+ * stat's own key. A tile crosses when its rule is met by these numbers, so the same values explain
121
+ * every card on screen.
122
+ */
123
+ stats: Record<string, BingoSidedCount>;
124
+ };
125
+
126
+ export type BingoLinePrize = {
127
+ /** How many completed lines this prize is for. */
128
+ lines: number;
129
+ /** Its share of the pot, as a percentage. */
130
+ percent: number;
131
+ };
132
+
133
+ export type BingoRarityMixture = {
134
+ common: number;
135
+ uncommon: number;
136
+ rare: number;
137
+ };
138
+
139
+ export type BingoSidedCount = {
140
+ home: number;
141
+ away: number;
142
+ };
143
+
74
144
  export type EventQuestion = {
75
145
  eventQuestionId: UUID;
76
146
  questionType: QuestionTypeEnum;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sportsbroker/firebase-structure",
3
- "version": "8.2.0",
3
+ "version": "8.3.0",
4
4
  "description": "Firebase structure typings",
5
5
  "main": "index.d.ts",
6
6
  "repository": {