@hellacardgames/speed 0.1.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.
Files changed (38) hide show
  1. package/README.md +9 -0
  2. package/dist/GameEvent-DDQ4jXxt.d.cts +111 -0
  3. package/dist/GameEvent-DDQ4jXxt.d.cts.map +1 -0
  4. package/dist/GameEvent-DDQ4jXxt.d.mts +111 -0
  5. package/dist/GameEvent-DDQ4jXxt.d.mts.map +1 -0
  6. package/dist/client/index.cjs +126 -0
  7. package/dist/client/index.cjs.map +1 -0
  8. package/dist/client/index.d.cts +38 -0
  9. package/dist/client/index.d.cts.map +1 -0
  10. package/dist/client/index.d.mts +38 -0
  11. package/dist/client/index.d.mts.map +1 -0
  12. package/dist/client/index.mjs +125 -0
  13. package/dist/client/index.mjs.map +1 -0
  14. package/dist/manager/index.cjs +33 -0
  15. package/dist/manager/index.cjs.map +1 -0
  16. package/dist/manager/index.d.cts +109 -0
  17. package/dist/manager/index.d.cts.map +1 -0
  18. package/dist/manager/index.d.mts +109 -0
  19. package/dist/manager/index.d.mts.map +1 -0
  20. package/dist/manager/index.mjs +22 -0
  21. package/dist/manager/index.mjs.map +1 -0
  22. package/dist/server/index.cjs +204 -0
  23. package/dist/server/index.cjs.map +1 -0
  24. package/dist/server/index.d.cts +40 -0
  25. package/dist/server/index.d.cts.map +1 -0
  26. package/dist/server/index.d.mts +40 -0
  27. package/dist/server/index.d.mts.map +1 -0
  28. package/dist/server/index.mjs +203 -0
  29. package/dist/server/index.mjs.map +1 -0
  30. package/dist/startGame-5InkAgEp.d.cts +108 -0
  31. package/dist/startGame-5InkAgEp.d.cts.map +1 -0
  32. package/dist/startGame-BC9XfFzG.mjs +815 -0
  33. package/dist/startGame-BC9XfFzG.mjs.map +1 -0
  34. package/dist/startGame-Bhk__XWk.cjs +898 -0
  35. package/dist/startGame-Bhk__XWk.cjs.map +1 -0
  36. package/dist/startGame-ayp8a-Cl.d.mts +108 -0
  37. package/dist/startGame-ayp8a-Cl.d.mts.map +1 -0
  38. package/package.json +92 -0
package/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # @hellacardgames/speed
2
+
3
+ A TypeScript library implementing the Speed card game.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @hellacardgames/speed
9
+ ```
@@ -0,0 +1,111 @@
1
+ //#region src/manager/types/Card.d.ts
2
+ type Card = {
3
+ readonly id: string;
4
+ readonly rank: 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14;
5
+ readonly suite: "clubs" | "diamonds" | "hearts" | "spades";
6
+ };
7
+ //#endregion
8
+ //#region src/manager/types/ChatMessage.d.ts
9
+ type ChatMessage = {
10
+ readonly id: string;
11
+ readonly username: string;
12
+ readonly text: string;
13
+ };
14
+ //#endregion
15
+ //#region src/manager/types/ClientState.d.ts
16
+ type ClientState = {
17
+ readonly status: "open" | "started" | "completed" | "forfeited";
18
+ readonly gameId: string;
19
+ readonly playerId: string;
20
+ readonly username: string;
21
+ readonly players: readonly Player[];
22
+ readonly expiresAt: number;
23
+ readonly chatMessages: readonly ChatMessage[];
24
+ readonly hand: readonly Card[];
25
+ readonly canPlayAt: number | null;
26
+ };
27
+ type Player = {
28
+ readonly username: string;
29
+ readonly handSize: number;
30
+ readonly drawPileSize: number;
31
+ readonly sidePileSize: number;
32
+ readonly centerPileTopCard: Card | null;
33
+ };
34
+ //#endregion
35
+ //#region src/manager/types/GameEvent.d.ts
36
+ type GameEvent = {
37
+ readonly type: "canPlayAtUpdated";
38
+ readonly id: string;
39
+ readonly canPlayAt: number;
40
+ } | {
41
+ readonly type: "cardDrawnFromSidePileToCenterPile";
42
+ readonly id: string;
43
+ readonly username: string;
44
+ readonly card: Card;
45
+ } | {
46
+ readonly type: "cardPlayed";
47
+ readonly id: string;
48
+ readonly username: string;
49
+ readonly card: Card;
50
+ readonly isForOtherPlayerPile: boolean;
51
+ } | {
52
+ readonly type: "chat";
53
+ readonly id: string;
54
+ readonly message: ChatMessage;
55
+ } | {
56
+ readonly type: "drewCard";
57
+ readonly id: string;
58
+ readonly card: Card;
59
+ } | {
60
+ readonly type: "expirationUpdated";
61
+ readonly id: string;
62
+ readonly expiresAt: number;
63
+ } | {
64
+ readonly type: "gameCompleted";
65
+ readonly id: string;
66
+ } | {
67
+ readonly type: "gameForfeited";
68
+ readonly id: string;
69
+ } | {
70
+ readonly type: "gameStarted";
71
+ readonly id: string;
72
+ } | {
73
+ readonly type: "handInitialized";
74
+ readonly id: string;
75
+ readonly cards: readonly Card[];
76
+ } | {
77
+ readonly type: "playerCenterPileInitialized";
78
+ readonly id: string;
79
+ readonly username: string;
80
+ readonly card: Card;
81
+ } | {
82
+ readonly type: "playerDrawPileInitialized";
83
+ readonly id: string;
84
+ readonly username: string;
85
+ readonly numCards: number;
86
+ } | {
87
+ readonly type: "playerDrewCard";
88
+ readonly id: string;
89
+ readonly username: string;
90
+ } | {
91
+ readonly type: "playerHandInitialized";
92
+ readonly id: string;
93
+ readonly username: string;
94
+ readonly numCards: number;
95
+ } | {
96
+ readonly type: "playerJoined";
97
+ readonly id: string;
98
+ readonly username: string;
99
+ } | {
100
+ readonly type: "playerLeft";
101
+ readonly id: string;
102
+ readonly username: string;
103
+ } | {
104
+ readonly type: "playerSidePileInitialized";
105
+ readonly id: string;
106
+ readonly username: string;
107
+ readonly numCards: number;
108
+ };
109
+ //#endregion
110
+ export { Card as i, ClientState as n, ChatMessage as r, GameEvent as t };
111
+ //# sourceMappingURL=GameEvent-DDQ4jXxt.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GameEvent-DDQ4jXxt.d.cts","names":[],"sources":["../src/manager/types/Card.ts","../src/manager/types/ChatMessage.ts","../src/manager/types/ClientState.ts","../src/manager/types/GameEvent.ts"],"mappings":";KAAY,IAAA;EAAA,SACD,EAAA;EAAA,SACA,IAAA;EAAA,SACA,KAAA;AAAA;;;KCHC,WAAA;EAAA,SACD,EAAA;EAAA,SACA,QAA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AAAA;EAAA,SAGA,IAAA;EAAA,SACA,EAAA;EAAA,SACA,QAAA;EAAA,SACA,QAAA;AAAA;EAAA,SAGA,IAAA;EAAA,SACA,EAAA;EAAA,SACA,QAAA;AAAA;EAAA,SAGA,IAAA;EAAA,SACA,EAAA;EAAA,SACA,QAAA;AAAA;EAAA,SAGA,IAAA;EAAA,SACA,EAAA;EAAA,SACA,QAAA;EAAA,SACA,QAAA;AAAA"}
@@ -0,0 +1,111 @@
1
+ //#region src/manager/types/Card.d.ts
2
+ type Card = {
3
+ readonly id: string;
4
+ readonly rank: 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14;
5
+ readonly suite: "clubs" | "diamonds" | "hearts" | "spades";
6
+ };
7
+ //#endregion
8
+ //#region src/manager/types/ChatMessage.d.ts
9
+ type ChatMessage = {
10
+ readonly id: string;
11
+ readonly username: string;
12
+ readonly text: string;
13
+ };
14
+ //#endregion
15
+ //#region src/manager/types/ClientState.d.ts
16
+ type ClientState = {
17
+ readonly status: "open" | "started" | "completed" | "forfeited";
18
+ readonly gameId: string;
19
+ readonly playerId: string;
20
+ readonly username: string;
21
+ readonly players: readonly Player[];
22
+ readonly expiresAt: number;
23
+ readonly chatMessages: readonly ChatMessage[];
24
+ readonly hand: readonly Card[];
25
+ readonly canPlayAt: number | null;
26
+ };
27
+ type Player = {
28
+ readonly username: string;
29
+ readonly handSize: number;
30
+ readonly drawPileSize: number;
31
+ readonly sidePileSize: number;
32
+ readonly centerPileTopCard: Card | null;
33
+ };
34
+ //#endregion
35
+ //#region src/manager/types/GameEvent.d.ts
36
+ type GameEvent = {
37
+ readonly type: "canPlayAtUpdated";
38
+ readonly id: string;
39
+ readonly canPlayAt: number;
40
+ } | {
41
+ readonly type: "cardDrawnFromSidePileToCenterPile";
42
+ readonly id: string;
43
+ readonly username: string;
44
+ readonly card: Card;
45
+ } | {
46
+ readonly type: "cardPlayed";
47
+ readonly id: string;
48
+ readonly username: string;
49
+ readonly card: Card;
50
+ readonly isForOtherPlayerPile: boolean;
51
+ } | {
52
+ readonly type: "chat";
53
+ readonly id: string;
54
+ readonly message: ChatMessage;
55
+ } | {
56
+ readonly type: "drewCard";
57
+ readonly id: string;
58
+ readonly card: Card;
59
+ } | {
60
+ readonly type: "expirationUpdated";
61
+ readonly id: string;
62
+ readonly expiresAt: number;
63
+ } | {
64
+ readonly type: "gameCompleted";
65
+ readonly id: string;
66
+ } | {
67
+ readonly type: "gameForfeited";
68
+ readonly id: string;
69
+ } | {
70
+ readonly type: "gameStarted";
71
+ readonly id: string;
72
+ } | {
73
+ readonly type: "handInitialized";
74
+ readonly id: string;
75
+ readonly cards: readonly Card[];
76
+ } | {
77
+ readonly type: "playerCenterPileInitialized";
78
+ readonly id: string;
79
+ readonly username: string;
80
+ readonly card: Card;
81
+ } | {
82
+ readonly type: "playerDrawPileInitialized";
83
+ readonly id: string;
84
+ readonly username: string;
85
+ readonly numCards: number;
86
+ } | {
87
+ readonly type: "playerDrewCard";
88
+ readonly id: string;
89
+ readonly username: string;
90
+ } | {
91
+ readonly type: "playerHandInitialized";
92
+ readonly id: string;
93
+ readonly username: string;
94
+ readonly numCards: number;
95
+ } | {
96
+ readonly type: "playerJoined";
97
+ readonly id: string;
98
+ readonly username: string;
99
+ } | {
100
+ readonly type: "playerLeft";
101
+ readonly id: string;
102
+ readonly username: string;
103
+ } | {
104
+ readonly type: "playerSidePileInitialized";
105
+ readonly id: string;
106
+ readonly username: string;
107
+ readonly numCards: number;
108
+ };
109
+ //#endregion
110
+ export { Card as i, ClientState as n, ChatMessage as r, GameEvent as t };
111
+ //# sourceMappingURL=GameEvent-DDQ4jXxt.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GameEvent-DDQ4jXxt.d.mts","names":[],"sources":["../src/manager/types/Card.ts","../src/manager/types/ChatMessage.ts","../src/manager/types/ClientState.ts","../src/manager/types/GameEvent.ts"],"mappings":";KAAY,IAAA;EAAA,SACD,EAAA;EAAA,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AAA;EAAA,SACA,QAAA;AAAA;EAAA,SAGA,IAAA;EAAA,SACA,EAAA;EAAA,SACA,QAAA;AAAA;EAAA,SAGA,IAAA;EAAA,SACA,EAAA;EAAA,SACA,QAAA;EAAA,SACA,QAAA;AAAA;EAAA,SAGA,IAAA;EAAA,SACA,EAAA;EAAA,SACA,QAAA;AAAA;EAAA,SAGA,IAAA;EAAA,SACA,EAAA;EAAA,SACA,QAAA;AAAA;EAAA,SAGA,IAAA;EAAA,SACA,EAAA;EAAA,SACA,QAAA;EAAA,SACA,QAAA;AAAA"}
@@ -0,0 +1,126 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/client/Client.ts
3
+ var Client = class {
4
+ actionUrls;
5
+ constructor(config) {
6
+ this.actionUrls = {
7
+ createGame: `${config.baseUrl}${config.actionUrls.createGame}`,
8
+ drawCard: `${config.baseUrl}${config.actionUrls.drawCard}`,
9
+ getClientStateAndClearEvents: `${config.baseUrl}${config.actionUrls.getClientStateAndClearEvents}`,
10
+ getEventsAndClearAcknowledged: `${config.baseUrl}${config.actionUrls.getEventsAndClearAcknowledged}`,
11
+ getJoinableGames: `${config.baseUrl}${config.actionUrls.getJoinableGames}`,
12
+ joinGame: `${config.baseUrl}${config.actionUrls.joinGame}`,
13
+ leaveGame: `${config.baseUrl}${config.actionUrls.leaveGame}`,
14
+ playCard: `${config.baseUrl}${config.actionUrls.playCard}`,
15
+ reportNoPlayableCards: `${config.baseUrl}${config.actionUrls.reportNoPlayableCards}`,
16
+ sendChat: `${config.baseUrl}${config.actionUrls.sendChat}`,
17
+ startGame: `${config.baseUrl}${config.actionUrls.startGame}`
18
+ };
19
+ }
20
+ async createGame(accessToken) {
21
+ return await (await fetch(`${this.actionUrls.createGame}`, {
22
+ method: "POST",
23
+ headers: { Authorization: `Bearer ${accessToken}` }
24
+ })).json();
25
+ }
26
+ async drawCard(gameId, playerId) {
27
+ return await (await fetch(`${this.actionUrls.drawCard}`, {
28
+ method: "POST",
29
+ headers: { "Content-Type": "application/json" },
30
+ body: JSON.stringify({
31
+ gameId,
32
+ playerId
33
+ })
34
+ })).json();
35
+ }
36
+ async getClientStateAndClearEvents(gameId, playerId) {
37
+ return await (await fetch(`${this.actionUrls.getClientStateAndClearEvents}`, {
38
+ method: "POST",
39
+ headers: { "Content-Type": "application/json" },
40
+ body: JSON.stringify({
41
+ gameId,
42
+ playerId
43
+ })
44
+ })).json();
45
+ }
46
+ async getEventsAndClearAcknowledged(gameId, playerId, lastReadId) {
47
+ return await (await fetch(`${this.actionUrls.getEventsAndClearAcknowledged}`, {
48
+ method: "POST",
49
+ headers: { "Content-Type": "application/json" },
50
+ body: JSON.stringify({
51
+ gameId,
52
+ playerId,
53
+ lastReadId
54
+ })
55
+ })).json();
56
+ }
57
+ async getJoinableGames() {
58
+ return await (await fetch(`${this.actionUrls.getJoinableGames}`, { method: "POST" })).json();
59
+ }
60
+ async joinGame(gameId, accessToken) {
61
+ return await (await fetch(`${this.actionUrls.joinGame}`, {
62
+ method: "POST",
63
+ headers: {
64
+ Authorization: `Bearer ${accessToken}`,
65
+ "Content-Type": "application/json"
66
+ },
67
+ body: JSON.stringify({ gameId })
68
+ })).json();
69
+ }
70
+ async leaveGame(gameId, playerId) {
71
+ return await (await fetch(`${this.actionUrls.leaveGame}`, {
72
+ method: "POST",
73
+ headers: { "Content-Type": "application/json" },
74
+ body: JSON.stringify({
75
+ gameId,
76
+ playerId
77
+ })
78
+ })).json();
79
+ }
80
+ async playCard(gameId, playerId, cardId) {
81
+ return await (await fetch(`${this.actionUrls.playCard}`, {
82
+ method: "POST",
83
+ headers: { "Content-Type": "application/json" },
84
+ body: JSON.stringify({
85
+ gameId,
86
+ playerId,
87
+ cardId
88
+ })
89
+ })).json();
90
+ }
91
+ async reportNoPlayableCards(gameId, playerId) {
92
+ return await (await fetch(`${this.actionUrls.reportNoPlayableCards}`, {
93
+ method: "POST",
94
+ headers: { "Content-Type": "application/json" },
95
+ body: JSON.stringify({
96
+ gameId,
97
+ playerId
98
+ })
99
+ })).json();
100
+ }
101
+ async sendChat(gameId, playerId, text) {
102
+ return await (await fetch(`${this.actionUrls.sendChat}`, {
103
+ method: "POST",
104
+ headers: { "Content-Type": "application/json" },
105
+ body: JSON.stringify({
106
+ gameId,
107
+ playerId,
108
+ text
109
+ })
110
+ })).json();
111
+ }
112
+ async startGame(gameId, playerId) {
113
+ return await (await fetch(`${this.actionUrls.startGame}`, {
114
+ method: "POST",
115
+ headers: { "Content-Type": "application/json" },
116
+ body: JSON.stringify({
117
+ gameId,
118
+ playerId
119
+ })
120
+ })).json();
121
+ }
122
+ };
123
+ //#endregion
124
+ exports.Client = Client;
125
+
126
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../src/client/Client.ts"],"sourcesContent":["import type { CreateGameResult } from \"../server/actions/createGame.js\";\nimport type { DrawCardResult } from \"../server/actions/drawCard.js\";\nimport type { GetClientStateAndClearEventsResult } from \"../server/actions/getClientStateAndClearEvents.js\";\nimport type { GetEventsAndClearAcknowledgedResult } from \"../server/actions/getEventsAndClearAcknowledged.js\";\nimport type { GetJoinableGamesResult } from \"../server/actions/getJoinableGames.js\";\nimport type { JoinGameResult } from \"../server/actions/joinGame.js\";\nimport type { LeaveGameResult } from \"../server/actions/leaveGame.js\";\nimport type { PlayCardResult } from \"../server/actions/playCard.js\";\nimport type { ReportNoPlayableCardsResult } from \"../server/actions/reportNoPlayableCards.js\";\nimport type { SendChatResult } from \"../server/actions/sendChat.js\";\nimport type { StartGameResult } from \"../server/actions/startGame.js\";\nimport type { Card } from \"../manager/types/Card.js\";\nimport type { ChatMessage } from \"../manager/types/ChatMessage.js\";\nimport type { ClientState } from \"../manager/types/ClientState.js\";\nimport type { GameEvent } from \"../manager/types/GameEvent.js\";\n\nexport type {\n CreateGameResult,\n DrawCardResult,\n GetClientStateAndClearEventsResult,\n GetEventsAndClearAcknowledgedResult,\n GetJoinableGamesResult,\n JoinGameResult,\n LeaveGameResult,\n PlayCardResult,\n ReportNoPlayableCardsResult,\n SendChatResult,\n StartGameResult,\n Card,\n ChatMessage,\n ClientState,\n GameEvent,\n};\n\ntype ClientConfig = {\n readonly baseUrl: string;\n readonly actionUrls: {\n readonly createGame: string;\n readonly drawCard: string;\n readonly getClientStateAndClearEvents: string;\n readonly getEventsAndClearAcknowledged: string;\n readonly getJoinableGames: string;\n readonly joinGame: string;\n readonly leaveGame: string;\n readonly playCard: string;\n readonly reportNoPlayableCards: string;\n readonly sendChat: string;\n readonly startGame: string;\n };\n};\n\nexport class Client {\n private readonly actionUrls: ClientConfig[\"actionUrls\"];\n\n constructor(config: ClientConfig) {\n this.actionUrls = {\n createGame: `${config.baseUrl}${config.actionUrls.createGame}`,\n drawCard: `${config.baseUrl}${config.actionUrls.drawCard}`,\n getClientStateAndClearEvents: `${config.baseUrl}${config.actionUrls.getClientStateAndClearEvents}`,\n getEventsAndClearAcknowledged: `${config.baseUrl}${config.actionUrls.getEventsAndClearAcknowledged}`,\n getJoinableGames: `${config.baseUrl}${config.actionUrls.getJoinableGames}`,\n joinGame: `${config.baseUrl}${config.actionUrls.joinGame}`,\n leaveGame: `${config.baseUrl}${config.actionUrls.leaveGame}`,\n playCard: `${config.baseUrl}${config.actionUrls.playCard}`,\n reportNoPlayableCards: `${config.baseUrl}${config.actionUrls.reportNoPlayableCards}`,\n sendChat: `${config.baseUrl}${config.actionUrls.sendChat}`,\n startGame: `${config.baseUrl}${config.actionUrls.startGame}`,\n };\n }\n\n async createGame(accessToken: string): Promise<CreateGameResult> {\n const response = await fetch(`${this.actionUrls.createGame}`, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${accessToken}`,\n },\n });\n const result = await response.json();\n return result;\n }\n\n async drawCard(gameId: string, playerId: string): Promise<DrawCardResult> {\n const response = await fetch(`${this.actionUrls.drawCard}`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId }),\n });\n const result = await response.json();\n return result;\n }\n\n async getClientStateAndClearEvents(\n gameId: string,\n playerId: string,\n ): Promise<GetClientStateAndClearEventsResult> {\n const response = await fetch(\n `${this.actionUrls.getClientStateAndClearEvents}`,\n {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId }),\n },\n );\n const result = await response.json();\n return result;\n }\n\n async getEventsAndClearAcknowledged(\n gameId: string,\n playerId: string,\n lastReadId: string | null,\n ): Promise<GetEventsAndClearAcknowledgedResult> {\n const response = await fetch(\n `${this.actionUrls.getEventsAndClearAcknowledged}`,\n {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId, lastReadId }),\n },\n );\n const result = await response.json();\n return result;\n }\n\n async getJoinableGames(): Promise<GetJoinableGamesResult> {\n const response = await fetch(`${this.actionUrls.getJoinableGames}`, {\n method: \"POST\",\n });\n const result = await response.json();\n return result;\n }\n\n async joinGame(gameId: string, accessToken: string): Promise<JoinGameResult> {\n const response = await fetch(`${this.actionUrls.joinGame}`, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${accessToken}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId }),\n });\n const result = await response.json();\n return result;\n }\n\n async leaveGame(gameId: string, playerId: string): Promise<LeaveGameResult> {\n const response = await fetch(`${this.actionUrls.leaveGame}`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId }),\n });\n const result = await response.json();\n return result;\n }\n\n async playCard(\n gameId: string,\n playerId: string,\n cardId: string,\n ): Promise<PlayCardResult> {\n const response = await fetch(`${this.actionUrls.playCard}`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId, cardId }),\n });\n const result = await response.json();\n return result;\n }\n\n async reportNoPlayableCards(\n gameId: string,\n playerId: string,\n ): Promise<ReportNoPlayableCardsResult> {\n const response = await fetch(`${this.actionUrls.reportNoPlayableCards}`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId }),\n });\n const result = await response.json();\n return result;\n }\n\n async sendChat(\n gameId: string,\n playerId: string,\n text: string,\n ): Promise<SendChatResult> {\n const response = await fetch(`${this.actionUrls.sendChat}`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId, text }),\n });\n const result = await response.json();\n return result;\n }\n\n async startGame(gameId: string, playerId: string): Promise<StartGameResult> {\n const response = await fetch(`${this.actionUrls.startGame}`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId }),\n });\n const result = await response.json();\n return result;\n }\n}\n"],"mappings":";;AAmDA,IAAa,SAAb,MAAoB;CAClB;CAEA,YAAY,QAAsB;EAChC,KAAK,aAAa;GAChB,YAAY,GAAG,OAAO,UAAU,OAAO,WAAW;GAClD,UAAU,GAAG,OAAO,UAAU,OAAO,WAAW;GAChD,8BAA8B,GAAG,OAAO,UAAU,OAAO,WAAW;GACpE,+BAA+B,GAAG,OAAO,UAAU,OAAO,WAAW;GACrE,kBAAkB,GAAG,OAAO,UAAU,OAAO,WAAW;GACxD,UAAU,GAAG,OAAO,UAAU,OAAO,WAAW;GAChD,WAAW,GAAG,OAAO,UAAU,OAAO,WAAW;GACjD,UAAU,GAAG,OAAO,UAAU,OAAO,WAAW;GAChD,uBAAuB,GAAG,OAAO,UAAU,OAAO,WAAW;GAC7D,UAAU,GAAG,OAAO,UAAU,OAAO,WAAW;GAChD,WAAW,GAAG,OAAO,UAAU,OAAO,WAAW;EACnD;CACF;CAEA,MAAM,WAAW,aAAgD;EAQ/D,OAAO,OADc,MANE,MAAM,GAAG,KAAK,WAAW,cAAc;GAC5D,QAAQ;GACR,SAAS,EACP,eAAe,UAAU,cAC3B;EACF,CAAC,EAAA,CAC6B,K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K;CAErC;CAEA,MAAM,SACJ,QACA,UACA,QACyB;EASzB,OAAO,OADc,MAPE,MAAM,GAAG,KAAK,WAAW,YAAY;GAC1D,QAAQ;GACR,SAAS,EACP,gBAAgB,mBAClB;GACA,MAAM,KAAK,UAAU;IAAE;IAAQ;IAAU;GAAO,CAAC;EACnD,CAAC,EAAA,CAC6B,KAAK;CAErC;CAEA,MAAM,sBACJ,QACA,UACsC;EAStC,OAAO,OADc,MAPE,MAAM,GAAG,KAAK,WAAW,yBAAyB;GACvE,QAAQ;GACR,SAAS,EACP,gBAAgB,mBAClB;GACA,MAAM,KAAK,UAAU;IAAE;IAAQ;GAAS,CAAC;EAC3C,CAAC,EAAA,CAC6B,KAAK;CAErC;CAEA,MAAM,SACJ,QACA,UACA,MACyB;EASzB,OAAO,OADc,MAPE,MAAM,GAAG,KAAK,WAAW,YAAY;GAC1D,QAAQ;GACR,SAAS,EACP,gBAAgB,mBAClB;GACA,MAAM,KAAK,UAAU;IAAE;IAAQ;IAAU;GAAK,CAAC;EACjD,CAAC,EAAA,CAC6B,KAAK;CAErC;CAEA,MAAM,UAAU,QAAgB,UAA4C;EAS1E,OAAO,OADc,MAPE,MAAM,GAAG,KAAK,WAAW,aAAa;GAC3D,QAAQ;GACR,SAAS,EACP,gBAAgB,mBAClB;GACA,MAAM,KAAK,UAAU;IAAE;IAAQ;GAAS,CAAC;EAC3C,CAAC,EAAA,CAC6B,KAAK;CAErC;AACF"}
@@ -0,0 +1,38 @@
1
+ import { _ as GetClientStateAndClearEventsResult, a as ReportNoPlayableCardsResult, d as JoinGameResult, h as GetEventsAndClearAcknowledgedResult, l as LeaveGameResult, p as GetJoinableGamesResult, r as SendChatResult, s as PlayCardResult, t as StartGameResult, x as CreateGameResult, y as DrawCardResult } from "../startGame-5InkAgEp.cjs";
2
+ import { i as Card, n as ClientState, r as ChatMessage, t as GameEvent } from "../GameEvent-DDQ4jXxt.cjs";
3
+
4
+ //#region src/client/Client.d.ts
5
+ type ClientConfig = {
6
+ readonly baseUrl: string;
7
+ readonly actionUrls: {
8
+ readonly createGame: string;
9
+ readonly drawCard: string;
10
+ readonly getClientStateAndClearEvents: string;
11
+ readonly getEventsAndClearAcknowledged: string;
12
+ readonly getJoinableGames: string;
13
+ readonly joinGame: string;
14
+ readonly leaveGame: string;
15
+ readonly playCard: string;
16
+ readonly reportNoPlayableCards: string;
17
+ readonly sendChat: string;
18
+ readonly startGame: string;
19
+ };
20
+ };
21
+ declare class Client {
22
+ private readonly actionUrls;
23
+ constructor(config: ClientConfig);
24
+ createGame(accessToken: string): Promise<CreateGameResult>;
25
+ drawCard(gameId: string, playerId: string): Promise<DrawCardResult>;
26
+ getClientStateAndClearEvents(gameId: string, playerId: string): Promise<GetClientStateAndClearEventsResult>;
27
+ getEventsAndClearAcknowledged(gameId: string, playerId: string, lastReadId: string | null): Promise<GetEventsAndClearAcknowledgedResult>;
28
+ getJoinableGames(): Promise<GetJoinableGamesResult>;
29
+ joinGame(gameId: string, accessToken: string): Promise<JoinGameResult>;
30
+ leaveGame(gameId: string, playerId: string): Promise<LeaveGameResult>;
31
+ playCard(gameId: string, playerId: string, cardId: string): Promise<PlayCardResult>;
32
+ reportNoPlayableCards(gameId: string, playerId: string): Promise<ReportNoPlayableCardsResult>;
33
+ sendChat(gameId: string, playerId: string, text: string): Promise<SendChatResult>;
34
+ startGame(gameId: string, playerId: string): Promise<StartGameResult>;
35
+ }
36
+ //#endregion
37
+ export { type Card, type ChatMessage, Client, type ClientState, type CreateGameResult, type DrawCardResult, type GameEvent, type GetClientStateAndClearEventsResult, type GetEventsAndClearAcknowledgedResult, type GetJoinableGamesResult, type JoinGameResult, type LeaveGameResult, type PlayCardResult, type ReportNoPlayableCardsResult, type SendChatResult, type StartGameResult };
38
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/client/Client.ts"],"mappings":";;;;KAkCK,YAAA;EAAA,SACM,OAAA;EAAA,SACA,UAAA;IAAA,SACE,UAAA;IAAA,SACA,QAAA;IAAA,SACA,4BAAA;IAAA,SACA,6BAAA;IAAA,SACA,gBAAA;IAAA,SACA,QAAA;IAAA,SACA,SAAA;IAAA,SACA,QAAA;IAAA,SACA,qBAAA;IAAA,SACA,QAAA;IAAA,SACA,SAAA;EAAA;AAAA;AAAA,cAIA,MAAA;EAAA,iBACM,UAAA;cAEL,MAAA,EAAQ,YAAA;EAgBd,UAAA,CAAW,WAAA,WAAsB,OAAA,CAAQ,gBAAA;EAWzC,QAAA,CAAS,MAAA,UAAgB,QAAA,WAAmB,OAAA,CAAQ,cAAA;EAYpD,4BAAA,CACJ,MAAA,UACA,QAAA,WACC,OAAA,CAAQ,kCAAA;EAeL,6BAAA,CACJ,MAAA,UACA,QAAA,UACA,UAAA,kBACC,OAAA,CAAQ,mCAAA;EAeL,gBAAA,IAAoB,OAAA,CAAQ,sBAAA;EAQ5B,QAAA,CAAS,MAAA,UAAgB,WAAA,WAAsB,OAAA,CAAQ,cAAA;EAavD,SAAA,CAAU,MAAA,UAAgB,QAAA,WAAmB,OAAA,CAAQ,eAAA;EAYrD,QAAA,CACJ,MAAA,UACA,QAAA,UACA,MAAA,WACC,OAAA,CAAQ,cAAA;EAYL,qBAAA,CACJ,MAAA,UACA,QAAA,WACC,OAAA,CAAQ,2BAAA;EAYL,QAAA,CACJ,MAAA,UACA,QAAA,UACA,IAAA,WACC,OAAA,CAAQ,cAAA;EAYL,SAAA,CAAU,MAAA,UAAgB,QAAA,WAAmB,OAAA,CAAQ,eAAA;AAAA"}
@@ -0,0 +1,38 @@
1
+ import { _ as GetClientStateAndClearEventsResult, a as ReportNoPlayableCardsResult, d as JoinGameResult, h as GetEventsAndClearAcknowledgedResult, l as LeaveGameResult, p as GetJoinableGamesResult, r as SendChatResult, s as PlayCardResult, t as StartGameResult, x as CreateGameResult, y as DrawCardResult } from "../startGame-ayp8a-Cl.mjs";
2
+ import { i as Card, n as ClientState, r as ChatMessage, t as GameEvent } from "../GameEvent-DDQ4jXxt.mjs";
3
+
4
+ //#region src/client/Client.d.ts
5
+ type ClientConfig = {
6
+ readonly baseUrl: string;
7
+ readonly actionUrls: {
8
+ readonly createGame: string;
9
+ readonly drawCard: string;
10
+ readonly getClientStateAndClearEvents: string;
11
+ readonly getEventsAndClearAcknowledged: string;
12
+ readonly getJoinableGames: string;
13
+ readonly joinGame: string;
14
+ readonly leaveGame: string;
15
+ readonly playCard: string;
16
+ readonly reportNoPlayableCards: string;
17
+ readonly sendChat: string;
18
+ readonly startGame: string;
19
+ };
20
+ };
21
+ declare class Client {
22
+ private readonly actionUrls;
23
+ constructor(config: ClientConfig);
24
+ createGame(accessToken: string): Promise<CreateGameResult>;
25
+ drawCard(gameId: string, playerId: string): Promise<DrawCardResult>;
26
+ getClientStateAndClearEvents(gameId: string, playerId: string): Promise<GetClientStateAndClearEventsResult>;
27
+ getEventsAndClearAcknowledged(gameId: string, playerId: string, lastReadId: string | null): Promise<GetEventsAndClearAcknowledgedResult>;
28
+ getJoinableGames(): Promise<GetJoinableGamesResult>;
29
+ joinGame(gameId: string, accessToken: string): Promise<JoinGameResult>;
30
+ leaveGame(gameId: string, playerId: string): Promise<LeaveGameResult>;
31
+ playCard(gameId: string, playerId: string, cardId: string): Promise<PlayCardResult>;
32
+ reportNoPlayableCards(gameId: string, playerId: string): Promise<ReportNoPlayableCardsResult>;
33
+ sendChat(gameId: string, playerId: string, text: string): Promise<SendChatResult>;
34
+ startGame(gameId: string, playerId: string): Promise<StartGameResult>;
35
+ }
36
+ //#endregion
37
+ export { type Card, type ChatMessage, Client, type ClientState, type CreateGameResult, type DrawCardResult, type GameEvent, type GetClientStateAndClearEventsResult, type GetEventsAndClearAcknowledgedResult, type GetJoinableGamesResult, type JoinGameResult, type LeaveGameResult, type PlayCardResult, type ReportNoPlayableCardsResult, type SendChatResult, type StartGameResult };
38
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/client/Client.ts"],"mappings":";;;;KAkCK,YAAA;EAAA,SACM,OAAA;EAAA,SACA,UAAA;IAAA,SACE,UAAA;IAAA,SACA,QAAA;IAAA,SACA,4BAAA;IAAA,SACA,6BAAA;IAAA,SACA,gBAAA;IAAA,SACA,QAAA;IAAA,SACA,SAAA;IAAA,SACA,QAAA;IAAA,SACA,qBAAA;IAAA,SACA,QAAA;IAAA,SACA,SAAA;EAAA;AAAA;AAAA,cAIA,MAAA;EAAA,iBACM,UAAA;cAEL,MAAA,EAAQ,YAAA;EAgBd,UAAA,CAAW,WAAA,WAAsB,OAAA,CAAQ,gBAAA;EAWzC,QAAA,CAAS,MAAA,UAAgB,QAAA,WAAmB,OAAA,CAAQ,cAAA;EAYpD,4BAAA,CACJ,MAAA,UACA,QAAA,WACC,OAAA,CAAQ,kCAAA;EAeL,6BAAA,CACJ,MAAA,UACA,QAAA,UACA,UAAA,kBACC,OAAA,CAAQ,mCAAA;EAeL,gBAAA,IAAoB,OAAA,CAAQ,sBAAA;EAQ5B,QAAA,CAAS,MAAA,UAAgB,WAAA,WAAsB,OAAA,CAAQ,cAAA;EAavD,SAAA,CAAU,MAAA,UAAgB,QAAA,WAAmB,OAAA,CAAQ,eAAA;EAYrD,QAAA,CACJ,MAAA,UACA,QAAA,UACA,MAAA,WACC,OAAA,CAAQ,cAAA;EAYL,qBAAA,CACJ,MAAA,UACA,QAAA,WACC,OAAA,CAAQ,2BAAA;EAYL,QAAA,CACJ,MAAA,UACA,QAAA,UACA,IAAA,WACC,OAAA,CAAQ,cAAA;EAYL,SAAA,CAAU,MAAA,UAAgB,QAAA,WAAmB,OAAA,CAAQ,eAAA;AAAA"}
@@ -0,0 +1,125 @@
1
+ //#region src/client/Client.ts
2
+ var Client = class {
3
+ actionUrls;
4
+ constructor(config) {
5
+ this.actionUrls = {
6
+ createGame: `${config.baseUrl}${config.actionUrls.createGame}`,
7
+ drawCard: `${config.baseUrl}${config.actionUrls.drawCard}`,
8
+ getClientStateAndClearEvents: `${config.baseUrl}${config.actionUrls.getClientStateAndClearEvents}`,
9
+ getEventsAndClearAcknowledged: `${config.baseUrl}${config.actionUrls.getEventsAndClearAcknowledged}`,
10
+ getJoinableGames: `${config.baseUrl}${config.actionUrls.getJoinableGames}`,
11
+ joinGame: `${config.baseUrl}${config.actionUrls.joinGame}`,
12
+ leaveGame: `${config.baseUrl}${config.actionUrls.leaveGame}`,
13
+ playCard: `${config.baseUrl}${config.actionUrls.playCard}`,
14
+ reportNoPlayableCards: `${config.baseUrl}${config.actionUrls.reportNoPlayableCards}`,
15
+ sendChat: `${config.baseUrl}${config.actionUrls.sendChat}`,
16
+ startGame: `${config.baseUrl}${config.actionUrls.startGame}`
17
+ };
18
+ }
19
+ async createGame(accessToken) {
20
+ return await (await fetch(`${this.actionUrls.createGame}`, {
21
+ method: "POST",
22
+ headers: { Authorization: `Bearer ${accessToken}` }
23
+ })).json();
24
+ }
25
+ async drawCard(gameId, playerId) {
26
+ return await (await fetch(`${this.actionUrls.drawCard}`, {
27
+ method: "POST",
28
+ headers: { "Content-Type": "application/json" },
29
+ body: JSON.stringify({
30
+ gameId,
31
+ playerId
32
+ })
33
+ })).json();
34
+ }
35
+ async getClientStateAndClearEvents(gameId, playerId) {
36
+ return await (await fetch(`${this.actionUrls.getClientStateAndClearEvents}`, {
37
+ method: "POST",
38
+ headers: { "Content-Type": "application/json" },
39
+ body: JSON.stringify({
40
+ gameId,
41
+ playerId
42
+ })
43
+ })).json();
44
+ }
45
+ async getEventsAndClearAcknowledged(gameId, playerId, lastReadId) {
46
+ return await (await fetch(`${this.actionUrls.getEventsAndClearAcknowledged}`, {
47
+ method: "POST",
48
+ headers: { "Content-Type": "application/json" },
49
+ body: JSON.stringify({
50
+ gameId,
51
+ playerId,
52
+ lastReadId
53
+ })
54
+ })).json();
55
+ }
56
+ async getJoinableGames() {
57
+ return await (await fetch(`${this.actionUrls.getJoinableGames}`, { method: "POST" })).json();
58
+ }
59
+ async joinGame(gameId, accessToken) {
60
+ return await (await fetch(`${this.actionUrls.joinGame}`, {
61
+ method: "POST",
62
+ headers: {
63
+ Authorization: `Bearer ${accessToken}`,
64
+ "Content-Type": "application/json"
65
+ },
66
+ body: JSON.stringify({ gameId })
67
+ })).json();
68
+ }
69
+ async leaveGame(gameId, playerId) {
70
+ return await (await fetch(`${this.actionUrls.leaveGame}`, {
71
+ method: "POST",
72
+ headers: { "Content-Type": "application/json" },
73
+ body: JSON.stringify({
74
+ gameId,
75
+ playerId
76
+ })
77
+ })).json();
78
+ }
79
+ async playCard(gameId, playerId, cardId) {
80
+ return await (await fetch(`${this.actionUrls.playCard}`, {
81
+ method: "POST",
82
+ headers: { "Content-Type": "application/json" },
83
+ body: JSON.stringify({
84
+ gameId,
85
+ playerId,
86
+ cardId
87
+ })
88
+ })).json();
89
+ }
90
+ async reportNoPlayableCards(gameId, playerId) {
91
+ return await (await fetch(`${this.actionUrls.reportNoPlayableCards}`, {
92
+ method: "POST",
93
+ headers: { "Content-Type": "application/json" },
94
+ body: JSON.stringify({
95
+ gameId,
96
+ playerId
97
+ })
98
+ })).json();
99
+ }
100
+ async sendChat(gameId, playerId, text) {
101
+ return await (await fetch(`${this.actionUrls.sendChat}`, {
102
+ method: "POST",
103
+ headers: { "Content-Type": "application/json" },
104
+ body: JSON.stringify({
105
+ gameId,
106
+ playerId,
107
+ text
108
+ })
109
+ })).json();
110
+ }
111
+ async startGame(gameId, playerId) {
112
+ return await (await fetch(`${this.actionUrls.startGame}`, {
113
+ method: "POST",
114
+ headers: { "Content-Type": "application/json" },
115
+ body: JSON.stringify({
116
+ gameId,
117
+ playerId
118
+ })
119
+ })).json();
120
+ }
121
+ };
122
+ //#endregion
123
+ export { Client };
124
+
125
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/client/Client.ts"],"sourcesContent":["import type { CreateGameResult } from \"../server/actions/createGame.js\";\nimport type { DrawCardResult } from \"../server/actions/drawCard.js\";\nimport type { GetClientStateAndClearEventsResult } from \"../server/actions/getClientStateAndClearEvents.js\";\nimport type { GetEventsAndClearAcknowledgedResult } from \"../server/actions/getEventsAndClearAcknowledged.js\";\nimport type { GetJoinableGamesResult } from \"../server/actions/getJoinableGames.js\";\nimport type { JoinGameResult } from \"../server/actions/joinGame.js\";\nimport type { LeaveGameResult } from \"../server/actions/leaveGame.js\";\nimport type { PlayCardResult } from \"../server/actions/playCard.js\";\nimport type { ReportNoPlayableCardsResult } from \"../server/actions/reportNoPlayableCards.js\";\nimport type { SendChatResult } from \"../server/actions/sendChat.js\";\nimport type { StartGameResult } from \"../server/actions/startGame.js\";\nimport type { Card } from \"../manager/types/Card.js\";\nimport type { ChatMessage } from \"../manager/types/ChatMessage.js\";\nimport type { ClientState } from \"../manager/types/ClientState.js\";\nimport type { GameEvent } from \"../manager/types/GameEvent.js\";\n\nexport type {\n CreateGameResult,\n DrawCardResult,\n GetClientStateAndClearEventsResult,\n GetEventsAndClearAcknowledgedResult,\n GetJoinableGamesResult,\n JoinGameResult,\n LeaveGameResult,\n PlayCardResult,\n ReportNoPlayableCardsResult,\n SendChatResult,\n StartGameResult,\n Card,\n ChatMessage,\n ClientState,\n GameEvent,\n};\n\ntype ClientConfig = {\n readonly baseUrl: string;\n readonly actionUrls: {\n readonly createGame: string;\n readonly drawCard: string;\n readonly getClientStateAndClearEvents: string;\n readonly getEventsAndClearAcknowledged: string;\n readonly getJoinableGames: string;\n readonly joinGame: string;\n readonly leaveGame: string;\n readonly playCard: string;\n readonly reportNoPlayableCards: string;\n readonly sendChat: string;\n readonly startGame: string;\n };\n};\n\nexport class Client {\n private readonly actionUrls: ClientConfig[\"actionUrls\"];\n\n constructor(config: ClientConfig) {\n this.actionUrls = {\n createGame: `${config.baseUrl}${config.actionUrls.createGame}`,\n drawCard: `${config.baseUrl}${config.actionUrls.drawCard}`,\n getClientStateAndClearEvents: `${config.baseUrl}${config.actionUrls.getClientStateAndClearEvents}`,\n getEventsAndClearAcknowledged: `${config.baseUrl}${config.actionUrls.getEventsAndClearAcknowledged}`,\n getJoinableGames: `${config.baseUrl}${config.actionUrls.getJoinableGames}`,\n joinGame: `${config.baseUrl}${config.actionUrls.joinGame}`,\n leaveGame: `${config.baseUrl}${config.actionUrls.leaveGame}`,\n playCard: `${config.baseUrl}${config.actionUrls.playCard}`,\n reportNoPlayableCards: `${config.baseUrl}${config.actionUrls.reportNoPlayableCards}`,\n sendChat: `${config.baseUrl}${config.actionUrls.sendChat}`,\n startGame: `${config.baseUrl}${config.actionUrls.startGame}`,\n };\n }\n\n async createGame(accessToken: string): Promise<CreateGameResult> {\n const response = await fetch(`${this.actionUrls.createGame}`, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${accessToken}`,\n },\n });\n const result = await response.json();\n return result;\n }\n\n async drawCard(gameId: string, playerId: string): Promise<DrawCardResult> {\n const response = await fetch(`${this.actionUrls.drawCard}`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId }),\n });\n const result = await response.json();\n return result;\n }\n\n async getClientStateAndClearEvents(\n gameId: string,\n playerId: string,\n ): Promise<GetClientStateAndClearEventsResult> {\n const response = await fetch(\n `${this.actionUrls.getClientStateAndClearEvents}`,\n {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId }),\n },\n );\n const result = await response.json();\n return result;\n }\n\n async getEventsAndClearAcknowledged(\n gameId: string,\n playerId: string,\n lastReadId: string | null,\n ): Promise<GetEventsAndClearAcknowledgedResult> {\n const response = await fetch(\n `${this.actionUrls.getEventsAndClearAcknowledged}`,\n {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId, lastReadId }),\n },\n );\n const result = await response.json();\n return result;\n }\n\n async getJoinableGames(): Promise<GetJoinableGamesResult> {\n const response = await fetch(`${this.actionUrls.getJoinableGames}`, {\n method: \"POST\",\n });\n const result = await response.json();\n return result;\n }\n\n async joinGame(gameId: string, accessToken: string): Promise<JoinGameResult> {\n const response = await fetch(`${this.actionUrls.joinGame}`, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${accessToken}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId }),\n });\n const result = await response.json();\n return result;\n }\n\n async leaveGame(gameId: string, playerId: string): Promise<LeaveGameResult> {\n const response = await fetch(`${this.actionUrls.leaveGame}`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId }),\n });\n const result = await response.json();\n return result;\n }\n\n async playCard(\n gameId: string,\n playerId: string,\n cardId: string,\n ): Promise<PlayCardResult> {\n const response = await fetch(`${this.actionUrls.playCard}`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId, cardId }),\n });\n const result = await response.json();\n return result;\n }\n\n async reportNoPlayableCards(\n gameId: string,\n playerId: string,\n ): Promise<ReportNoPlayableCardsResult> {\n const response = await fetch(`${this.actionUrls.reportNoPlayableCards}`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId }),\n });\n const result = await response.json();\n return result;\n }\n\n async sendChat(\n gameId: string,\n playerId: string,\n text: string,\n ): Promise<SendChatResult> {\n const response = await fetch(`${this.actionUrls.sendChat}`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId, text }),\n });\n const result = await response.json();\n return result;\n }\n\n async startGame(gameId: string, playerId: string): Promise<StartGameResult> {\n const response = await fetch(`${this.actionUrls.startGame}`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ gameId, playerId }),\n });\n const result = await response.json();\n return result;\n }\n}\n"],"mappings":";AAmDA,IAAa,SAAb,MAAoB;CAClB;CAEA,YAAY,QAAsB;EAChC,KAAK,aAA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,KAAK,UAAU;IAAE;IAAQ;IAAU;GAAK,CAAC;EACjD,CAAC,EAAA,CAC6B,KAAK;CAErC;CAEA,MAAM,UAAU,QAAgB,UAA4C;EAS1E,OAAO,OADc,MAPE,MAAM,GAAG,KAAK,WAAW,aAAa;GAC3D,QAAQ;GACR,SAAS,EACP,gBAAgB,mBAClB;GACA,MAAM,KAAK,UAAU;IAAE;IAAQ;GAAS,CAAC;EAC3C,CAAC,EAAA,CAC6B,KAAK;CAErC;AACF"}
@@ -0,0 +1,33 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_startGame = require("../startGame-Bhk__XWk.cjs");
3
+ //#region src/manager/watchdog.ts
4
+ var Watchdog = class {
5
+ start() {
6
+ console.log(`watchdog start at ${Date.now()} (${require_startGame.GAME_KEY})`);
7
+ setInterval(() => this.wakeUp(), require_startGame.WATCHDOG_INTERVAL_MS);
8
+ }
9
+ wakeUp() {
10
+ const now = Date.now();
11
+ for (const game of require_startGame.games.values()) if (game.expiresAt <= now) {
12
+ require_startGame.games.delete(game.id);
13
+ console.log(`watchdog purged ${game.id} (${require_startGame.GAME_KEY})`);
14
+ }
15
+ }
16
+ };
17
+ //#endregion
18
+ //#region src/manager/index.ts
19
+ new Watchdog().start();
20
+ //#endregion
21
+ exports.createGame = require_startGame.createGame;
22
+ exports.drawCard = require_startGame.drawCard;
23
+ exports.getClientStateAndClearEvents = require_startGame.getClientStateAndClearEvents;
24
+ exports.getEventsAndClearAcknowledged = require_startGame.getEventsAndClearAcknowledged;
25
+ exports.getJoinableGames = require_startGame.getJoinableGames;
26
+ exports.joinGame = require_startGame.joinGame;
27
+ exports.leaveGame = require_startGame.leaveGame;
28
+ exports.playCard = require_startGame.playCard;
29
+ exports.reportNoPlayableCards = require_startGame.reportNoPlayableCards;
30
+ exports.sendChat = require_startGame.sendChat;
31
+ exports.startGame = require_startGame.startGame;
32
+
33
+ //# sourceMappingURL=index.cjs.map