@hellacardgames/speed 0.2.0 → 0.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.
@@ -1,30 +1,18 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  //#region src/client/Client.ts
3
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
- };
4
+ baseUrl;
5
+ constructor(baseUrl) {
6
+ this.baseUrl = baseUrl;
19
7
  }
20
8
  async createGame(accessToken) {
21
- return await (await fetch(`${this.actionUrls.createGame}`, {
9
+ return await (await fetch(`${this.baseUrl}/createGame`, {
22
10
  method: "POST",
23
11
  headers: { Authorization: `Bearer ${accessToken}` }
24
12
  })).json();
25
13
  }
26
14
  async drawCard(gameId, playerId) {
27
- return await (await fetch(`${this.actionUrls.drawCard}`, {
15
+ return await (await fetch(`${this.baseUrl}/drawCard`, {
28
16
  method: "POST",
29
17
  headers: { "Content-Type": "application/json" },
30
18
  body: JSON.stringify({
@@ -34,7 +22,7 @@ var Client = class {
34
22
  })).json();
35
23
  }
36
24
  async getClientStateAndClearEvents(gameId, playerId) {
37
- return await (await fetch(`${this.actionUrls.getClientStateAndClearEvents}`, {
25
+ return await (await fetch(`${this.baseUrl}/getClientStateAndClearEvents`, {
38
26
  method: "POST",
39
27
  headers: { "Content-Type": "application/json" },
40
28
  body: JSON.stringify({
@@ -44,7 +32,7 @@ var Client = class {
44
32
  })).json();
45
33
  }
46
34
  async getEventsAndClearAcknowledged(gameId, playerId, lastReadId) {
47
- return await (await fetch(`${this.actionUrls.getEventsAndClearAcknowledged}`, {
35
+ return await (await fetch(`${this.baseUrl}/getEventsAndClearAcknowledged`, {
48
36
  method: "POST",
49
37
  headers: { "Content-Type": "application/json" },
50
38
  body: JSON.stringify({
@@ -55,10 +43,10 @@ var Client = class {
55
43
  })).json();
56
44
  }
57
45
  async getJoinableGames() {
58
- return await (await fetch(`${this.actionUrls.getJoinableGames}`, { method: "POST" })).json();
46
+ return await (await fetch(`${this.baseUrl}/getJoinableGames`, { method: "POST" })).json();
59
47
  }
60
48
  async joinGame(gameId, accessToken) {
61
- return await (await fetch(`${this.actionUrls.joinGame}`, {
49
+ return await (await fetch(`${this.baseUrl}/joinGame`, {
62
50
  method: "POST",
63
51
  headers: {
64
52
  Authorization: `Bearer ${accessToken}`,
@@ -68,7 +56,7 @@ var Client = class {
68
56
  })).json();
69
57
  }
70
58
  async leaveGame(gameId, playerId) {
71
- return await (await fetch(`${this.actionUrls.leaveGame}`, {
59
+ return await (await fetch(`${this.baseUrl}/leaveGame`, {
72
60
  method: "POST",
73
61
  headers: { "Content-Type": "application/json" },
74
62
  body: JSON.stringify({
@@ -78,7 +66,7 @@ var Client = class {
78
66
  })).json();
79
67
  }
80
68
  async playCard(gameId, playerId, cardId) {
81
- return await (await fetch(`${this.actionUrls.playCard}`, {
69
+ return await (await fetch(`${this.baseUrl}/playCard`, {
82
70
  method: "POST",
83
71
  headers: { "Content-Type": "application/json" },
84
72
  body: JSON.stringify({
@@ -89,7 +77,7 @@ var Client = class {
89
77
  })).json();
90
78
  }
91
79
  async reportNoPlayableCards(gameId, playerId) {
92
- return await (await fetch(`${this.actionUrls.reportNoPlayableCards}`, {
80
+ return await (await fetch(`${this.baseUrl}/reportNoPlayableCards`, {
93
81
  method: "POST",
94
82
  headers: { "Content-Type": "application/json" },
95
83
  body: JSON.stringify({
@@ -99,7 +87,7 @@ var Client = class {
99
87
  })).json();
100
88
  }
101
89
  async sendChat(gameId, playerId, text) {
102
- return await (await fetch(`${this.actionUrls.sendChat}`, {
90
+ return await (await fetch(`${this.baseUrl}/sendChat`, {
103
91
  method: "POST",
104
92
  headers: { "Content-Type": "application/json" },
105
93
  body: JSON.stringify({
@@ -110,7 +98,7 @@ var Client = class {
110
98
  })).json();
111
99
  }
112
100
  async startGame(gameId, playerId) {
113
- return await (await fetch(`${this.actionUrls.startGame}`, {
101
+ return await (await fetch(`${this.baseUrl}/startGame`, {
114
102
  method: "POST",
115
103
  headers: { "Content-Type": "application/json" },
116
104
  body: JSON.stringify({
@@ -1 +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,WAA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K,WAAW,aAAa;GAC3D,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,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"}
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\nexport class Client {\n private readonly baseUrl: string;\n\n constructor(baseUrl: string) {\n this.baseUrl = baseUrl;\n }\n\n async createGame(accessToken: string): Promise<CreateGameResult> {\n const response = await fetch(`${this.baseUrl}/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.baseUrl}/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.baseUrl}/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.baseUrl}/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.baseUrl}/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.baseUrl}/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.baseUrl}/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.baseUrl}/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.baseUrl}/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.baseUrl}/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.baseUrl}/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":";;AAkCA,IAAa,SAAb,MAAoB;CAClB;CAEA,YAAY,SAAiB;EAC3B,KAAK,UAAU;CACjB;CAEA,MAAM,WAAW,aAAgD;EAQ/D,OAAO,OADc,MANE,MAAM,GAAG,KAAK,QAAQ,cAAc;GACzD,QAAQ;GACR,SAAS,EACP,eAAe,UAAU,cAC3B;EACF,CAAC,EAAA,CAC6B,KAAK;CAErC;CAEA,MAAM,SAAS,QAAgB,UAA2C;EASxE,OAAO,OADc,MAPE,MAAM,GAAG,KAAK,QAAQ,YAAY;GACvD,QAAQ;GACR,SAAS,EACP,gBAAgB,mBAClB;GACA,MAAM,KAAK,UAAU;IAAE;IAAQ;GAAS,CAAC;EAC3C,CAAC,EAAA,CAC6B,KAAK;CAErC;CAEA,MAAM,6BACJ,QACA,UAC6C;EAY7C,OAAO,OADc,MAVE,MACrB,GAAG,KAAK,QAAQ,gCAChB;GACE,QAAQ;GACR,SAAS,EACP,gBAAgB,mBAClB;GACA,MAAM,KAAK,UAAU;IAAE;IAAQ;GAAS,CAAC;EAC3C,CACF,EAAA,CAC8B,KAAK;CAErC;CAEA,MAAM,8BACJ,QACA,UACA,YAC8C;EAY9C,OAAO,OADc,MAVE,MACrB,GAAG,KAAK,QAAQ,iCAChB;GACE,QAAQ;GACR,SAAS,EACP,gBAAgB,mBAClB;GACA,MAAM,KAAK,UAAU;IAAE;IAAQ;IAAU;GAAW,CAAC;EACvD,CACF,EAAA,CAC8B,KAAK;C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KAAK;CAErC;CAEA,MAAM,UAAU,QAAgB,UAA4C;EAS1E,OAAO,OADc,MAPE,MAAM,GAAG,KAAK,QAAQ,aAAa;GACxD,QAAQ;GACR,SAAS,EACP,gBAAgB,mBAClB;GACA,MAAM,KAAK,UAAU;IAAE;IAAQ;GAAS,CAAC;EAC3C,CAAC,EAAA,CAC6B,KAAK;CAErC;AACF"}
@@ -2,25 +2,9 @@ import { _ as GetClientStateAndClearEventsResult, a as ReportNoPlayableCardsResu
2
2
  import { i as Card, n as ClientState, r as ChatMessage, t as GameEvent } from "../GameEvent-DDQ4jXxt.cjs";
3
3
 
4
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
5
  declare class Client {
22
- private readonly actionUrls;
23
- constructor(config: ClientConfig);
6
+ private readonly baseUrl;
7
+ constructor(baseUrl: string);
24
8
  createGame(accessToken: string): Promise<CreateGameResult>;
25
9
  drawCard(gameId: string, playerId: string): Promise<DrawCardResult>;
26
10
  getClientStateAndClearEvents(gameId: string, playerId: string): Promise<GetClientStateAndClearEventsResult>;
@@ -1 +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;EA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AA;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"}
@@ -2,25 +2,9 @@ import { _ as GetClientStateAndClearEventsResult, a as ReportNoPlayableCardsResu
2
2
  import { i as Card, n as ClientState, r as ChatMessage, t as GameEvent } from "../GameEvent-DDQ4jXxt.mjs";
3
3
 
4
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
5
  declare class Client {
22
- private readonly actionUrls;
23
- constructor(config: ClientConfig);
6
+ private readonly baseUrl;
7
+ constructor(baseUrl: string);
24
8
  createGame(accessToken: string): Promise<CreateGameResult>;
25
9
  drawCard(gameId: string, playerId: string): Promise<DrawCardResult>;
26
10
  getClientStateAndClearEvents(gameId: string, playerId: string): Promise<GetClientStateAndClearEventsResult>;
@@ -1 +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;I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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"}
@@ -1,29 +1,17 @@
1
1
  //#region src/client/Client.ts
2
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
- };
3
+ baseUrl;
4
+ constructor(baseUrl) {
5
+ this.baseUrl = baseUrl;
18
6
  }
19
7
  async createGame(accessToken) {
20
- return await (await fetch(`${this.actionUrls.createGame}`, {
8
+ return await (await fetch(`${this.baseUrl}/createGame`, {
21
9
  method: "POST",
22
10
  headers: { Authorization: `Bearer ${accessToken}` }
23
11
  })).json();
24
12
  }
25
13
  async drawCard(gameId, playerId) {
26
- return await (await fetch(`${this.actionUrls.drawCard}`, {
14
+ return await (await fetch(`${this.baseUrl}/drawCard`, {
27
15
  method: "POST",
28
16
  headers: { "Content-Type": "application/json" },
29
17
  body: JSON.stringify({
@@ -33,7 +21,7 @@ var Client = class {
33
21
  })).json();
34
22
  }
35
23
  async getClientStateAndClearEvents(gameId, playerId) {
36
- return await (await fetch(`${this.actionUrls.getClientStateAndClearEvents}`, {
24
+ return await (await fetch(`${this.baseUrl}/getClientStateAndClearEvents`, {
37
25
  method: "POST",
38
26
  headers: { "Content-Type": "application/json" },
39
27
  body: JSON.stringify({
@@ -43,7 +31,7 @@ var Client = class {
43
31
  })).json();
44
32
  }
45
33
  async getEventsAndClearAcknowledged(gameId, playerId, lastReadId) {
46
- return await (await fetch(`${this.actionUrls.getEventsAndClearAcknowledged}`, {
34
+ return await (await fetch(`${this.baseUrl}/getEventsAndClearAcknowledged`, {
47
35
  method: "POST",
48
36
  headers: { "Content-Type": "application/json" },
49
37
  body: JSON.stringify({
@@ -54,10 +42,10 @@ var Client = class {
54
42
  })).json();
55
43
  }
56
44
  async getJoinableGames() {
57
- return await (await fetch(`${this.actionUrls.getJoinableGames}`, { method: "POST" })).json();
45
+ return await (await fetch(`${this.baseUrl}/getJoinableGames`, { method: "POST" })).json();
58
46
  }
59
47
  async joinGame(gameId, accessToken) {
60
- return await (await fetch(`${this.actionUrls.joinGame}`, {
48
+ return await (await fetch(`${this.baseUrl}/joinGame`, {
61
49
  method: "POST",
62
50
  headers: {
63
51
  Authorization: `Bearer ${accessToken}`,
@@ -67,7 +55,7 @@ var Client = class {
67
55
  })).json();
68
56
  }
69
57
  async leaveGame(gameId, playerId) {
70
- return await (await fetch(`${this.actionUrls.leaveGame}`, {
58
+ return await (await fetch(`${this.baseUrl}/leaveGame`, {
71
59
  method: "POST",
72
60
  headers: { "Content-Type": "application/json" },
73
61
  body: JSON.stringify({
@@ -77,7 +65,7 @@ var Client = class {
77
65
  })).json();
78
66
  }
79
67
  async playCard(gameId, playerId, cardId) {
80
- return await (await fetch(`${this.actionUrls.playCard}`, {
68
+ return await (await fetch(`${this.baseUrl}/playCard`, {
81
69
  method: "POST",
82
70
  headers: { "Content-Type": "application/json" },
83
71
  body: JSON.stringify({
@@ -88,7 +76,7 @@ var Client = class {
88
76
  })).json();
89
77
  }
90
78
  async reportNoPlayableCards(gameId, playerId) {
91
- return await (await fetch(`${this.actionUrls.reportNoPlayableCards}`, {
79
+ return await (await fetch(`${this.baseUrl}/reportNoPlayableCards`, {
92
80
  method: "POST",
93
81
  headers: { "Content-Type": "application/json" },
94
82
  body: JSON.stringify({
@@ -98,7 +86,7 @@ var Client = class {
98
86
  })).json();
99
87
  }
100
88
  async sendChat(gameId, playerId, text) {
101
- return await (await fetch(`${this.actionUrls.sendChat}`, {
89
+ return await (await fetch(`${this.baseUrl}/sendChat`, {
102
90
  method: "POST",
103
91
  headers: { "Content-Type": "application/json" },
104
92
  body: JSON.stringify({
@@ -109,7 +97,7 @@ var Client = class {
109
97
  })).json();
110
98
  }
111
99
  async startGame(gameId, playerId) {
112
- return await (await fetch(`${this.actionUrls.startGame}`, {
100
+ return await (await fetch(`${this.baseUrl}/startGame`, {
113
101
  method: "POST",
114
102
  headers: { "Content-Type": "application/json" },
115
103
  body: JSON.stringify({
@@ -1 +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,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,WA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A,MAAM,KAAK,UAAU;IAAE;IAAQ;GAAS,CAAC;EAC3C,CAAC,EAAA,CAC6B,KAAK;CAErC;AACF"}
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\nexport class Client {\n private readonly baseUrl: string;\n\n constructor(baseUrl: string) {\n this.baseUrl = baseUrl;\n }\n\n async createGame(accessToken: string): Promise<CreateGameResult> {\n const response = await fetch(`${this.baseUrl}/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.baseUrl}/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.baseUrl}/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.baseUrl}/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.baseUrl}/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.baseUrl}/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.baseUrl}/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.baseUrl}/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.baseUrl}/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.baseUrl}/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.baseUrl}/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":";AAkCA,IAAa,SAAb,MAAoB;CAClB;CAEA,YAAY,SAAiB;EAC3B,KAAK,UAAU;CACjB;CAEA,MAAM,WAAW,aAAgD;EAQ/D,OAAO,OADc,MANE,MAAM,GAAG,KAAK,QAAQ,cAAc;GACzD,QAAQ;GACR,SAAS,EACP,eAAe,UAAU,cAC3B;EACF,CAAC,EAAA,CAC6B,KAAK;CAErC;CAEA,MAAM,SAAS,QAAgB,UAA2C;EASxE,OAAO,OADc,MAPE,MAAM,GAAG,KAAK,QAAQ,YAAY;GACvD,QAAQ;GACR,SAAS,EACP,gBAAgB,mBAClB;GACA,MAAM,KAAK,UAAU;IAAE;IAAQ;GAAS,CAAC;EAC3C,CAAC,EAAA,CAC6B,KAAK;CAErC;CAEA,MAAM,6BACJ,QACA,UAC6C;EAY7C,OAAO,OADc,MAVE,MACrB,GAAG,KAAK,QAAQ,gCAChB;GACE,QAAQ;GACR,SAAS,EACP,gBAAgB,mBAClB;GACA,MAAM,KAAK,UAAU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AK,UAAU;IAAE;IAAQ;GAAS,CAAC;EAC3C,CAAC,EAAA,CAC6B,KAAK;CAErC;CAEA,MAAM,SACJ,QACA,UACA,MACyB;EASzB,OAAO,OADc,MAPE,MAAM,GAAG,KAAK,QAAQ,YAAY;GACvD,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,QAAQ,aAAa;GACxD,QAAQ;GACR,SAAS,EACP,gBAAgB,mBAClB;GACA,MAAM,KAAK,UAAU;IAAE;IAAQ;GAAS,CAAC;EAC3C,CAAC,EAAA,CAC6B,KAAK;CAErC;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hellacardgames/speed",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "A TypeScript library implementing the Speed card game.",
5
5
  "type": "module",
6
6
  "license": "MIT",