@hellacardgames/speed 0.12.0 → 0.13.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.
- package/dist/client/index.cjs +18 -161
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +26 -26
- package/dist/client/index.d.cts.map +1 -1
- package/dist/client/index.d.mts +26 -26
- package/dist/client/index.d.mts.map +1 -1
- package/dist/client/index.mjs +19 -161
- package/dist/client/index.mjs.map +1 -1
- package/dist/manager/index.d.cts.map +1 -1
- package/dist/manager/index.d.mts.map +1 -1
- package/package.json +2 -2
package/dist/client/index.cjs
CHANGED
|
@@ -1,165 +1,22 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
//#region src/client/
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
async drawCard(gameId, playerId) {
|
|
20
|
-
const result = await (await fetch(`${this.baseUrl}/drawCard`, {
|
|
21
|
-
method: "POST",
|
|
22
|
-
headers: { "Content-Type": "application/json" },
|
|
23
|
-
body: JSON.stringify({
|
|
24
|
-
gameId,
|
|
25
|
-
playerId
|
|
26
|
-
})
|
|
27
|
-
})).json();
|
|
28
|
-
if (!result.success) return {
|
|
29
|
-
success: false,
|
|
30
|
-
error: result.error
|
|
31
|
-
};
|
|
32
|
-
return result;
|
|
33
|
-
}
|
|
34
|
-
async getClientStateAndClearEvents(gameId, playerId) {
|
|
35
|
-
const result = await (await fetch(`${this.baseUrl}/getClientStateAndClearEvents`, {
|
|
36
|
-
method: "POST",
|
|
37
|
-
headers: { "Content-Type": "application/json" },
|
|
38
|
-
body: JSON.stringify({
|
|
39
|
-
gameId,
|
|
40
|
-
playerId
|
|
41
|
-
})
|
|
42
|
-
})).json();
|
|
43
|
-
if (!result.success) return {
|
|
44
|
-
success: false,
|
|
45
|
-
error: result.error
|
|
46
|
-
};
|
|
47
|
-
return result;
|
|
48
|
-
}
|
|
49
|
-
async getEventsAndClearAcknowledged(gameId, playerId, lastReadId) {
|
|
50
|
-
const result = await (await fetch(`${this.baseUrl}/getEventsAndClearAcknowledged`, {
|
|
51
|
-
method: "POST",
|
|
52
|
-
headers: { "Content-Type": "application/json" },
|
|
53
|
-
body: JSON.stringify({
|
|
54
|
-
gameId,
|
|
55
|
-
playerId,
|
|
56
|
-
lastReadId
|
|
57
|
-
})
|
|
58
|
-
})).json();
|
|
59
|
-
if (!result.success) return {
|
|
60
|
-
success: false,
|
|
61
|
-
error: result.error
|
|
62
|
-
};
|
|
63
|
-
return result;
|
|
64
|
-
}
|
|
65
|
-
async getJoinableGames() {
|
|
66
|
-
return await (await fetch(`${this.baseUrl}/getJoinableGames`, { method: "POST" })).json();
|
|
67
|
-
}
|
|
68
|
-
async joinGame(gameId, accessToken) {
|
|
69
|
-
const result = await (await fetch(`${this.baseUrl}/joinGame`, {
|
|
70
|
-
method: "POST",
|
|
71
|
-
headers: {
|
|
72
|
-
Authorization: `Bearer ${accessToken}`,
|
|
73
|
-
"Content-Type": "application/json"
|
|
74
|
-
},
|
|
75
|
-
body: JSON.stringify({ gameId })
|
|
76
|
-
})).json();
|
|
77
|
-
if (!result.success) return {
|
|
78
|
-
success: false,
|
|
79
|
-
error: result.error
|
|
80
|
-
};
|
|
81
|
-
return result;
|
|
82
|
-
}
|
|
83
|
-
async leaveGame(gameId, playerId) {
|
|
84
|
-
const result = await (await fetch(`${this.baseUrl}/leaveGame`, {
|
|
85
|
-
method: "POST",
|
|
86
|
-
headers: { "Content-Type": "application/json" },
|
|
87
|
-
body: JSON.stringify({
|
|
88
|
-
gameId,
|
|
89
|
-
playerId
|
|
90
|
-
})
|
|
91
|
-
})).json();
|
|
92
|
-
if (!result.success) return {
|
|
93
|
-
success: false,
|
|
94
|
-
error: result.error
|
|
95
|
-
};
|
|
96
|
-
return result;
|
|
97
|
-
}
|
|
98
|
-
async playCard(gameId, playerId, cardId, isForOtherPlayerPile) {
|
|
99
|
-
const result = await (await fetch(`${this.baseUrl}/playCard`, {
|
|
100
|
-
method: "POST",
|
|
101
|
-
headers: { "Content-Type": "application/json" },
|
|
102
|
-
body: JSON.stringify({
|
|
103
|
-
gameId,
|
|
104
|
-
playerId,
|
|
105
|
-
cardId,
|
|
106
|
-
isForOtherPlayerPile
|
|
107
|
-
})
|
|
108
|
-
})).json();
|
|
109
|
-
if (!result.success) return {
|
|
110
|
-
success: false,
|
|
111
|
-
error: result.error
|
|
112
|
-
};
|
|
113
|
-
return result;
|
|
114
|
-
}
|
|
115
|
-
async reportNoPlayableCards(gameId, playerId) {
|
|
116
|
-
const result = await (await fetch(`${this.baseUrl}/reportNoPlayableCards`, {
|
|
117
|
-
method: "POST",
|
|
118
|
-
headers: { "Content-Type": "application/json" },
|
|
119
|
-
body: JSON.stringify({
|
|
120
|
-
gameId,
|
|
121
|
-
playerId
|
|
122
|
-
})
|
|
123
|
-
})).json();
|
|
124
|
-
if (!result.success) return {
|
|
125
|
-
success: false,
|
|
126
|
-
error: result.error
|
|
127
|
-
};
|
|
128
|
-
return result;
|
|
129
|
-
}
|
|
130
|
-
async sendChat(gameId, playerId, text) {
|
|
131
|
-
const result = await (await fetch(`${this.baseUrl}/sendChat`, {
|
|
132
|
-
method: "POST",
|
|
133
|
-
headers: { "Content-Type": "application/json" },
|
|
134
|
-
body: JSON.stringify({
|
|
135
|
-
gameId,
|
|
136
|
-
playerId,
|
|
137
|
-
text
|
|
138
|
-
})
|
|
139
|
-
})).json();
|
|
140
|
-
if (!result.success) return {
|
|
141
|
-
success: false,
|
|
142
|
-
error: result.error
|
|
143
|
-
};
|
|
144
|
-
return result;
|
|
145
|
-
}
|
|
146
|
-
async startGame(gameId, playerId) {
|
|
147
|
-
const result = await (await fetch(`${this.baseUrl}/startGame`, {
|
|
148
|
-
method: "POST",
|
|
149
|
-
headers: { "Content-Type": "application/json" },
|
|
150
|
-
body: JSON.stringify({
|
|
151
|
-
gameId,
|
|
152
|
-
playerId
|
|
153
|
-
})
|
|
154
|
-
})).json();
|
|
155
|
-
if (!result.success) return {
|
|
156
|
-
success: false,
|
|
157
|
-
error: result.error
|
|
158
|
-
};
|
|
159
|
-
return result;
|
|
160
|
-
}
|
|
161
|
-
};
|
|
2
|
+
//#region src/client/createClient.ts
|
|
3
|
+
const createClient = (0, require("@hellacardgames/lib").createClientFactory)({
|
|
4
|
+
drawCard: (gameId, playerId) => ({
|
|
5
|
+
gameId,
|
|
6
|
+
playerId
|
|
7
|
+
}),
|
|
8
|
+
playCard: (gameId, playerId, cardId, isForOtherPlayerPile) => ({
|
|
9
|
+
gameId,
|
|
10
|
+
playerId,
|
|
11
|
+
cardId,
|
|
12
|
+
isForOtherPlayerPile
|
|
13
|
+
}),
|
|
14
|
+
reportNoPlayableCards: (gameId, playerId) => ({
|
|
15
|
+
gameId,
|
|
16
|
+
playerId
|
|
17
|
+
})
|
|
18
|
+
});
|
|
162
19
|
//#endregion
|
|
163
|
-
exports.
|
|
20
|
+
exports.createClient = createClient;
|
|
164
21
|
|
|
165
22
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":[],"sources":["../../src/client/
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["createClientFactory"],"sources":["../../src/client/createClient.ts"],"sourcesContent":["import { createClientFactory } from \"@hellacardgames/lib\";\nimport type { createManager } from \"../manager/createManager.js\";\nimport type { createServer } from \"../server/createServer.js\";\n\nexport const createClient = createClientFactory<\n ReturnType<typeof createServer>,\n ReturnType<typeof createManager>\n>({\n drawCard: (gameId: string, playerId: string) => ({\n gameId,\n playerId,\n }),\n playCard: (\n gameId: string,\n playerId: string,\n cardId: string,\n isForOtherPlayerPile: boolean,\n ) => ({\n gameId,\n playerId,\n cardId,\n isForOtherPlayerPile,\n }),\n reportNoPlayableCards: (gameId: string, playerId: string) => ({\n gameId,\n playerId,\n }),\n});\n"],"mappings":";;AAIA,MAAa,gBAAA,gCAAeA,CAAAA,CAAAA,oBAAAA,CAG1B;CACA,WAAW,QAAgB,cAAsB;EAC/C;EACA;CACF;CACA,WACE,QACA,UACA,QACA,0BACI;EACJ;EACA;EACA;EACA;CACF;CACA,wBAAwB,QAAgB,cAAsB;EAC5D;EACA;CACF;AACF,CAAC"}
|
package/dist/client/index.d.cts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { i as Card, n as GameEvent, r as ChatMessage, t as ClientState } from "../index-89KVb2dD.cjs";
|
|
2
|
-
//#region src/client/
|
|
3
|
-
declare
|
|
4
|
-
|
|
5
|
-
constructor(baseUrl: string);
|
|
6
|
-
createGame(accessToken: string): Promise<{
|
|
2
|
+
//#region src/client/createClient.d.ts
|
|
3
|
+
declare const createClient: (baseUrl: string) => {
|
|
4
|
+
readonly createGame: (accessToken: string) => Promise<{
|
|
7
5
|
readonly success: true;
|
|
8
6
|
readonly gameId: string;
|
|
9
7
|
readonly playerId: string;
|
|
@@ -11,72 +9,74 @@ declare class Client {
|
|
|
11
9
|
readonly success: false;
|
|
12
10
|
readonly error: "maxGamesReached";
|
|
13
11
|
}>;
|
|
14
|
-
|
|
15
|
-
readonly success: true;
|
|
16
|
-
} | {
|
|
17
|
-
readonly success: false;
|
|
18
|
-
readonly error: "playerNotFound" | "invalidStatus" | "canPlayAtNotReached" | "handFull" | "drawPileEmpty" | "gameNotFound" | "invalidInput";
|
|
19
|
-
}>;
|
|
20
|
-
getClientStateAndClearEvents(gameId: string, playerId: string): Promise<{
|
|
12
|
+
readonly getClientStateAndClearEvents: (gameId: string, playerId: string) => Promise<{
|
|
21
13
|
readonly success: true;
|
|
22
14
|
readonly state: ClientState;
|
|
23
15
|
} | {
|
|
24
16
|
readonly success: false;
|
|
25
17
|
readonly error: "playerNotFound" | "gameNotFound" | "invalidInput";
|
|
26
18
|
}>;
|
|
27
|
-
getEventsAndClearAcknowledged(gameId: string, playerId: string, lastReadId: string | null)
|
|
19
|
+
readonly getEventsAndClearAcknowledged: (gameId: string, playerId: string, lastReadId: string | null) => Promise<{
|
|
28
20
|
readonly success: true;
|
|
29
21
|
readonly events: readonly GameEvent[];
|
|
30
22
|
} | {
|
|
31
23
|
readonly success: false;
|
|
32
24
|
readonly error: "playerNotFound" | "gameNotFound" | "invalidInput";
|
|
33
25
|
}>;
|
|
34
|
-
getJoinableGames()
|
|
26
|
+
readonly getJoinableGames: () => Promise<{
|
|
35
27
|
readonly games: readonly {
|
|
36
28
|
readonly id: string;
|
|
37
29
|
readonly numPlayers: number;
|
|
38
30
|
}[];
|
|
39
31
|
}>;
|
|
40
|
-
joinGame(gameId: string, accessToken: string)
|
|
32
|
+
readonly joinGame: (gameId: string, accessToken: string) => Promise<{
|
|
41
33
|
readonly success: true;
|
|
42
34
|
readonly playerId: string;
|
|
43
35
|
} | {
|
|
44
36
|
readonly success: false;
|
|
45
37
|
readonly error: "invalidStatus" | "maxPlayersReached" | "alreadyInGame" | "gameNotFound" | "invalidInput";
|
|
46
38
|
}>;
|
|
47
|
-
leaveGame(gameId: string, playerId: string)
|
|
39
|
+
readonly leaveGame: (gameId: string, playerId: string) => Promise<{
|
|
48
40
|
readonly success: true;
|
|
49
41
|
} | {
|
|
50
42
|
readonly success: false;
|
|
51
43
|
readonly error: "playerNotFound" | "gameNotFound" | "invalidInput";
|
|
52
44
|
}>;
|
|
53
|
-
|
|
45
|
+
readonly sendChat: (gameId: string, playerId: string, text: string) => Promise<{
|
|
54
46
|
readonly success: true;
|
|
55
47
|
} | {
|
|
56
48
|
readonly success: false;
|
|
57
|
-
readonly error: "playerNotFound" | "
|
|
49
|
+
readonly error: "playerNotFound" | "gameNotFound" | "invalidInput";
|
|
58
50
|
}>;
|
|
59
|
-
|
|
51
|
+
readonly startGame: (gameId: string, playerId: string) => Promise<{
|
|
60
52
|
readonly success: true;
|
|
61
53
|
} | {
|
|
62
54
|
readonly success: false;
|
|
63
|
-
readonly error: "playerNotFound" | "invalidStatus" | "
|
|
55
|
+
readonly error: "playerNotFound" | "invalidStatus" | "playerNotAdmin" | "minPlayersNotReached" | "gameNotFound" | "invalidInput";
|
|
64
56
|
}>;
|
|
65
|
-
|
|
57
|
+
} & Readonly<{
|
|
58
|
+
drawCard: (gameId: string, playerId: string) => Promise<{
|
|
66
59
|
readonly success: true;
|
|
67
60
|
} | {
|
|
68
61
|
readonly success: false;
|
|
69
|
-
readonly error: "playerNotFound" | "gameNotFound" | "invalidInput";
|
|
62
|
+
readonly error: "playerNotFound" | "invalidStatus" | "canPlayAtNotReached" | "handFull" | "drawPileEmpty" | "gameNotFound" | "invalidInput";
|
|
70
63
|
}>;
|
|
71
|
-
|
|
64
|
+
playCard: (gameId: string, playerId: string, cardId: string, isForOtherPlayerPile: boolean) => Promise<{
|
|
72
65
|
readonly success: true;
|
|
73
66
|
} | {
|
|
74
67
|
readonly success: false;
|
|
75
|
-
readonly error: "playerNotFound" | "invalidStatus" | "
|
|
68
|
+
readonly error: "playerNotFound" | "invalidStatus" | "canPlayAtNotReached" | "cardNotFound" | "cardNotPlayable" | "gameNotFound" | "invalidInput";
|
|
69
|
+
}>;
|
|
70
|
+
reportNoPlayableCards: (gameId: string, playerId: string) => Promise<{
|
|
71
|
+
readonly success: true;
|
|
72
|
+
} | {
|
|
73
|
+
readonly success: false;
|
|
74
|
+
readonly error: "playerNotFound" | "invalidStatus" | "canPlayAtNotReached" | "alreadyReported" | "hasPlayableCard" | "canDraw" | "gameNotFound" | "invalidInput";
|
|
76
75
|
}>;
|
|
77
|
-
}
|
|
76
|
+
}>;
|
|
78
77
|
//#endregion
|
|
79
78
|
//#region src/client/index.d.ts
|
|
79
|
+
type Client = ReturnType<typeof createClient>;
|
|
80
80
|
type CreateGameResult = Awaited<ReturnType<Client["createGame"]>>;
|
|
81
81
|
type DrawCardResult = Awaited<ReturnType<Client["drawCard"]>>;
|
|
82
82
|
type GetClientStateAndClearEventsResult = Awaited<ReturnType<Client["getClientStateAndClearEvents"]>>;
|
|
@@ -89,5 +89,5 @@ type ReportNoPlayableCards = Awaited<ReturnType<Client["reportNoPlayableCards"]>
|
|
|
89
89
|
type SendChatResult = Awaited<ReturnType<Client["sendChat"]>>;
|
|
90
90
|
type StartGameResult = Awaited<ReturnType<Client["startGame"]>>;
|
|
91
91
|
//#endregion
|
|
92
|
-
export { type Card, type ChatMessage,
|
|
92
|
+
export { type Card, type ChatMessage, type ClientState, CreateGameResult, DrawCardResult, type GameEvent, GetClientStateAndClearEventsResult, GetEventsAndClearAcknowledgedResult, GetJoinableGamesResult, JoinGameResult, LeaveGameResult, PlayCardResult, ReportNoPlayableCards, SendChatResult, StartGameResult, createClient };
|
|
93
93
|
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/client/
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/client/createClient.ts","../../src/client/index.ts"],"mappings":";;cAIa,eAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KCDpB,SAAS,kBAAkB;KAEpB,mBAAmB,QAAQ,WAAW;KACtC,iBAAiB,QAAQ,WAAW;KACpC,qCAAqC,QAC/C,WAAW;KAED,sCAAsC,QAChD,WAAW;KAED,yBAAyB,QACnC,WAAW;KAED,iBAAiB,QAAQ,WAAW;KACpC,kBAAkB,QAAQ,WAAW;KACrC,iBAAiB,QAAQ,WAAW;KACpC,wBAAwB,QAClC,WAAW;KAED,iBAAiB,QAAQ,WAAW;KACpC,kBAAkB,QAAQ,WAAW"}
|
package/dist/client/index.d.mts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { i as Card, n as GameEvent, r as ChatMessage, t as ClientState } from "../index-89KVb2dD.mjs";
|
|
2
|
-
//#region src/client/
|
|
3
|
-
declare
|
|
4
|
-
|
|
5
|
-
constructor(baseUrl: string);
|
|
6
|
-
createGame(accessToken: string): Promise<{
|
|
2
|
+
//#region src/client/createClient.d.ts
|
|
3
|
+
declare const createClient: (baseUrl: string) => {
|
|
4
|
+
readonly createGame: (accessToken: string) => Promise<{
|
|
7
5
|
readonly success: true;
|
|
8
6
|
readonly gameId: string;
|
|
9
7
|
readonly playerId: string;
|
|
@@ -11,72 +9,74 @@ declare class Client {
|
|
|
11
9
|
readonly success: false;
|
|
12
10
|
readonly error: "maxGamesReached";
|
|
13
11
|
}>;
|
|
14
|
-
|
|
15
|
-
readonly success: true;
|
|
16
|
-
} | {
|
|
17
|
-
readonly success: false;
|
|
18
|
-
readonly error: "playerNotFound" | "invalidStatus" | "canPlayAtNotReached" | "handFull" | "drawPileEmpty" | "gameNotFound" | "invalidInput";
|
|
19
|
-
}>;
|
|
20
|
-
getClientStateAndClearEvents(gameId: string, playerId: string): Promise<{
|
|
12
|
+
readonly getClientStateAndClearEvents: (gameId: string, playerId: string) => Promise<{
|
|
21
13
|
readonly success: true;
|
|
22
14
|
readonly state: ClientState;
|
|
23
15
|
} | {
|
|
24
16
|
readonly success: false;
|
|
25
17
|
readonly error: "playerNotFound" | "gameNotFound" | "invalidInput";
|
|
26
18
|
}>;
|
|
27
|
-
getEventsAndClearAcknowledged(gameId: string, playerId: string, lastReadId: string | null)
|
|
19
|
+
readonly getEventsAndClearAcknowledged: (gameId: string, playerId: string, lastReadId: string | null) => Promise<{
|
|
28
20
|
readonly success: true;
|
|
29
21
|
readonly events: readonly GameEvent[];
|
|
30
22
|
} | {
|
|
31
23
|
readonly success: false;
|
|
32
24
|
readonly error: "playerNotFound" | "gameNotFound" | "invalidInput";
|
|
33
25
|
}>;
|
|
34
|
-
getJoinableGames()
|
|
26
|
+
readonly getJoinableGames: () => Promise<{
|
|
35
27
|
readonly games: readonly {
|
|
36
28
|
readonly id: string;
|
|
37
29
|
readonly numPlayers: number;
|
|
38
30
|
}[];
|
|
39
31
|
}>;
|
|
40
|
-
joinGame(gameId: string, accessToken: string)
|
|
32
|
+
readonly joinGame: (gameId: string, accessToken: string) => Promise<{
|
|
41
33
|
readonly success: true;
|
|
42
34
|
readonly playerId: string;
|
|
43
35
|
} | {
|
|
44
36
|
readonly success: false;
|
|
45
37
|
readonly error: "invalidStatus" | "maxPlayersReached" | "alreadyInGame" | "gameNotFound" | "invalidInput";
|
|
46
38
|
}>;
|
|
47
|
-
leaveGame(gameId: string, playerId: string)
|
|
39
|
+
readonly leaveGame: (gameId: string, playerId: string) => Promise<{
|
|
48
40
|
readonly success: true;
|
|
49
41
|
} | {
|
|
50
42
|
readonly success: false;
|
|
51
43
|
readonly error: "playerNotFound" | "gameNotFound" | "invalidInput";
|
|
52
44
|
}>;
|
|
53
|
-
|
|
45
|
+
readonly sendChat: (gameId: string, playerId: string, text: string) => Promise<{
|
|
54
46
|
readonly success: true;
|
|
55
47
|
} | {
|
|
56
48
|
readonly success: false;
|
|
57
|
-
readonly error: "playerNotFound" | "
|
|
49
|
+
readonly error: "playerNotFound" | "gameNotFound" | "invalidInput";
|
|
58
50
|
}>;
|
|
59
|
-
|
|
51
|
+
readonly startGame: (gameId: string, playerId: string) => Promise<{
|
|
60
52
|
readonly success: true;
|
|
61
53
|
} | {
|
|
62
54
|
readonly success: false;
|
|
63
|
-
readonly error: "playerNotFound" | "invalidStatus" | "
|
|
55
|
+
readonly error: "playerNotFound" | "invalidStatus" | "playerNotAdmin" | "minPlayersNotReached" | "gameNotFound" | "invalidInput";
|
|
64
56
|
}>;
|
|
65
|
-
|
|
57
|
+
} & Readonly<{
|
|
58
|
+
drawCard: (gameId: string, playerId: string) => Promise<{
|
|
66
59
|
readonly success: true;
|
|
67
60
|
} | {
|
|
68
61
|
readonly success: false;
|
|
69
|
-
readonly error: "playerNotFound" | "gameNotFound" | "invalidInput";
|
|
62
|
+
readonly error: "playerNotFound" | "invalidStatus" | "canPlayAtNotReached" | "handFull" | "drawPileEmpty" | "gameNotFound" | "invalidInput";
|
|
70
63
|
}>;
|
|
71
|
-
|
|
64
|
+
playCard: (gameId: string, playerId: string, cardId: string, isForOtherPlayerPile: boolean) => Promise<{
|
|
72
65
|
readonly success: true;
|
|
73
66
|
} | {
|
|
74
67
|
readonly success: false;
|
|
75
|
-
readonly error: "playerNotFound" | "invalidStatus" | "
|
|
68
|
+
readonly error: "playerNotFound" | "invalidStatus" | "canPlayAtNotReached" | "cardNotFound" | "cardNotPlayable" | "gameNotFound" | "invalidInput";
|
|
69
|
+
}>;
|
|
70
|
+
reportNoPlayableCards: (gameId: string, playerId: string) => Promise<{
|
|
71
|
+
readonly success: true;
|
|
72
|
+
} | {
|
|
73
|
+
readonly success: false;
|
|
74
|
+
readonly error: "playerNotFound" | "invalidStatus" | "canPlayAtNotReached" | "alreadyReported" | "hasPlayableCard" | "canDraw" | "gameNotFound" | "invalidInput";
|
|
76
75
|
}>;
|
|
77
|
-
}
|
|
76
|
+
}>;
|
|
78
77
|
//#endregion
|
|
79
78
|
//#region src/client/index.d.ts
|
|
79
|
+
type Client = ReturnType<typeof createClient>;
|
|
80
80
|
type CreateGameResult = Awaited<ReturnType<Client["createGame"]>>;
|
|
81
81
|
type DrawCardResult = Awaited<ReturnType<Client["drawCard"]>>;
|
|
82
82
|
type GetClientStateAndClearEventsResult = Awaited<ReturnType<Client["getClientStateAndClearEvents"]>>;
|
|
@@ -89,5 +89,5 @@ type ReportNoPlayableCards = Awaited<ReturnType<Client["reportNoPlayableCards"]>
|
|
|
89
89
|
type SendChatResult = Awaited<ReturnType<Client["sendChat"]>>;
|
|
90
90
|
type StartGameResult = Awaited<ReturnType<Client["startGame"]>>;
|
|
91
91
|
//#endregion
|
|
92
|
-
export { type Card, type ChatMessage,
|
|
92
|
+
export { type Card, type ChatMessage, type ClientState, CreateGameResult, DrawCardResult, type GameEvent, GetClientStateAndClearEventsResult, GetEventsAndClearAcknowledgedResult, GetJoinableGamesResult, JoinGameResult, LeaveGameResult, PlayCardResult, ReportNoPlayableCards, SendChatResult, StartGameResult, createClient };
|
|
93
93
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/client/
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/client/createClient.ts","../../src/client/index.ts"],"mappings":";;cAIa,eAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KCDpB,SAAS,kBAAkB;KAEpB,mBAAmB,QAAQ,WAAW;KACtC,iBAAiB,QAAQ,WAAW;KACpC,qCAAqC,QAC/C,WAAW;KAED,sCAAsC,QAChD,WAAW;KAED,yBAAyB,QACnC,WAAW;KAED,iBAAiB,QAAQ,WAAW;KACpC,kBAAkB,QAAQ,WAAW;KACrC,iBAAiB,QAAQ,WAAW;KACpC,wBAAwB,QAClC,WAAW;KAED,iBAAiB,QAAQ,WAAW;KACpC,kBAAkB,QAAQ,WAAW"}
|
package/dist/client/index.mjs
CHANGED
|
@@ -1,164 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const result = await (await fetch(`${this.baseUrl}/drawCard`, {
|
|
20
|
-
method: "POST",
|
|
21
|
-
headers: { "Content-Type": "application/json" },
|
|
22
|
-
body: JSON.stringify({
|
|
23
|
-
gameId,
|
|
24
|
-
playerId
|
|
25
|
-
})
|
|
26
|
-
})).json();
|
|
27
|
-
if (!result.success) return {
|
|
28
|
-
success: false,
|
|
29
|
-
error: result.error
|
|
30
|
-
};
|
|
31
|
-
return result;
|
|
32
|
-
}
|
|
33
|
-
async getClientStateAndClearEvents(gameId, playerId) {
|
|
34
|
-
const result = await (await fetch(`${this.baseUrl}/getClientStateAndClearEvents`, {
|
|
35
|
-
method: "POST",
|
|
36
|
-
headers: { "Content-Type": "application/json" },
|
|
37
|
-
body: JSON.stringify({
|
|
38
|
-
gameId,
|
|
39
|
-
playerId
|
|
40
|
-
})
|
|
41
|
-
})).json();
|
|
42
|
-
if (!result.success) return {
|
|
43
|
-
success: false,
|
|
44
|
-
error: result.error
|
|
45
|
-
};
|
|
46
|
-
return result;
|
|
47
|
-
}
|
|
48
|
-
async getEventsAndClearAcknowledged(gameId, playerId, lastReadId) {
|
|
49
|
-
const result = await (await fetch(`${this.baseUrl}/getEventsAndClearAcknowledged`, {
|
|
50
|
-
method: "POST",
|
|
51
|
-
headers: { "Content-Type": "application/json" },
|
|
52
|
-
body: JSON.stringify({
|
|
53
|
-
gameId,
|
|
54
|
-
playerId,
|
|
55
|
-
lastReadId
|
|
56
|
-
})
|
|
57
|
-
})).json();
|
|
58
|
-
if (!result.success) return {
|
|
59
|
-
success: false,
|
|
60
|
-
error: result.error
|
|
61
|
-
};
|
|
62
|
-
return result;
|
|
63
|
-
}
|
|
64
|
-
async getJoinableGames() {
|
|
65
|
-
return await (await fetch(`${this.baseUrl}/getJoinableGames`, { method: "POST" })).json();
|
|
66
|
-
}
|
|
67
|
-
async joinGame(gameId, accessToken) {
|
|
68
|
-
const result = await (await fetch(`${this.baseUrl}/joinGame`, {
|
|
69
|
-
method: "POST",
|
|
70
|
-
headers: {
|
|
71
|
-
Authorization: `Bearer ${accessToken}`,
|
|
72
|
-
"Content-Type": "application/json"
|
|
73
|
-
},
|
|
74
|
-
body: JSON.stringify({ gameId })
|
|
75
|
-
})).json();
|
|
76
|
-
if (!result.success) return {
|
|
77
|
-
success: false,
|
|
78
|
-
error: result.error
|
|
79
|
-
};
|
|
80
|
-
return result;
|
|
81
|
-
}
|
|
82
|
-
async leaveGame(gameId, playerId) {
|
|
83
|
-
const result = await (await fetch(`${this.baseUrl}/leaveGame`, {
|
|
84
|
-
method: "POST",
|
|
85
|
-
headers: { "Content-Type": "application/json" },
|
|
86
|
-
body: JSON.stringify({
|
|
87
|
-
gameId,
|
|
88
|
-
playerId
|
|
89
|
-
})
|
|
90
|
-
})).json();
|
|
91
|
-
if (!result.success) return {
|
|
92
|
-
success: false,
|
|
93
|
-
error: result.error
|
|
94
|
-
};
|
|
95
|
-
return result;
|
|
96
|
-
}
|
|
97
|
-
async playCard(gameId, playerId, cardId, isForOtherPlayerPile) {
|
|
98
|
-
const result = await (await fetch(`${this.baseUrl}/playCard`, {
|
|
99
|
-
method: "POST",
|
|
100
|
-
headers: { "Content-Type": "application/json" },
|
|
101
|
-
body: JSON.stringify({
|
|
102
|
-
gameId,
|
|
103
|
-
playerId,
|
|
104
|
-
cardId,
|
|
105
|
-
isForOtherPlayerPile
|
|
106
|
-
})
|
|
107
|
-
})).json();
|
|
108
|
-
if (!result.success) return {
|
|
109
|
-
success: false,
|
|
110
|
-
error: result.error
|
|
111
|
-
};
|
|
112
|
-
return result;
|
|
113
|
-
}
|
|
114
|
-
async reportNoPlayableCards(gameId, playerId) {
|
|
115
|
-
const result = await (await fetch(`${this.baseUrl}/reportNoPlayableCards`, {
|
|
116
|
-
method: "POST",
|
|
117
|
-
headers: { "Content-Type": "application/json" },
|
|
118
|
-
body: JSON.stringify({
|
|
119
|
-
gameId,
|
|
120
|
-
playerId
|
|
121
|
-
})
|
|
122
|
-
})).json();
|
|
123
|
-
if (!result.success) return {
|
|
124
|
-
success: false,
|
|
125
|
-
error: result.error
|
|
126
|
-
};
|
|
127
|
-
return result;
|
|
128
|
-
}
|
|
129
|
-
async sendChat(gameId, playerId, text) {
|
|
130
|
-
const result = await (await fetch(`${this.baseUrl}/sendChat`, {
|
|
131
|
-
method: "POST",
|
|
132
|
-
headers: { "Content-Type": "application/json" },
|
|
133
|
-
body: JSON.stringify({
|
|
134
|
-
gameId,
|
|
135
|
-
playerId,
|
|
136
|
-
text
|
|
137
|
-
})
|
|
138
|
-
})).json();
|
|
139
|
-
if (!result.success) return {
|
|
140
|
-
success: false,
|
|
141
|
-
error: result.error
|
|
142
|
-
};
|
|
143
|
-
return result;
|
|
144
|
-
}
|
|
145
|
-
async startGame(gameId, playerId) {
|
|
146
|
-
const result = await (await fetch(`${this.baseUrl}/startGame`, {
|
|
147
|
-
method: "POST",
|
|
148
|
-
headers: { "Content-Type": "application/json" },
|
|
149
|
-
body: JSON.stringify({
|
|
150
|
-
gameId,
|
|
151
|
-
playerId
|
|
152
|
-
})
|
|
153
|
-
})).json();
|
|
154
|
-
if (!result.success) return {
|
|
155
|
-
success: false,
|
|
156
|
-
error: result.error
|
|
157
|
-
};
|
|
158
|
-
return result;
|
|
159
|
-
}
|
|
160
|
-
};
|
|
1
|
+
import { createClientFactory } from "@hellacardgames/lib";
|
|
2
|
+
//#region src/client/createClient.ts
|
|
3
|
+
const createClient = createClientFactory({
|
|
4
|
+
drawCard: (gameId, playerId) => ({
|
|
5
|
+
gameId,
|
|
6
|
+
playerId
|
|
7
|
+
}),
|
|
8
|
+
playCard: (gameId, playerId, cardId, isForOtherPlayerPile) => ({
|
|
9
|
+
gameId,
|
|
10
|
+
playerId,
|
|
11
|
+
cardId,
|
|
12
|
+
isForOtherPlayerPile
|
|
13
|
+
}),
|
|
14
|
+
reportNoPlayableCards: (gameId, playerId) => ({
|
|
15
|
+
gameId,
|
|
16
|
+
playerId
|
|
17
|
+
})
|
|
18
|
+
});
|
|
161
19
|
//#endregion
|
|
162
|
-
export {
|
|
20
|
+
export { createClient };
|
|
163
21
|
|
|
164
22
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/client/
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/client/createClient.ts"],"sourcesContent":["import { createClientFactory } from \"@hellacardgames/lib\";\nimport type { createManager } from \"../manager/createManager.js\";\nimport type { createServer } from \"../server/createServer.js\";\n\nexport const createClient = createClientFactory<\n ReturnType<typeof createServer>,\n ReturnType<typeof createManager>\n>({\n drawCard: (gameId: string, playerId: string) => ({\n gameId,\n playerId,\n }),\n playCard: (\n gameId: string,\n playerId: string,\n cardId: string,\n isForOtherPlayerPile: boolean,\n ) => ({\n gameId,\n playerId,\n cardId,\n isForOtherPlayerPile,\n }),\n reportNoPlayableCards: (gameId: string, playerId: string) => ({\n gameId,\n playerId,\n }),\n});\n"],"mappings":";;AAIA,MAAa,eAAe,oBAG1B;CACA,WAAW,QAAgB,cAAsB;EAC/C;EACA;CACF;CACA,WACE,QACA,UACA,QACA,0BACI;EACJ;EACA;EACA;EACA;CACF;CACA,wBAAwB,QAAgB,cAAsB;EAC5D;EACA;CACF;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/manager/createManager.ts"],"mappings":";;cAea,gBAAa,gBAAA,kBAAA;;;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/manager/createManager.ts"],"mappings":";;cAea,gBAAa,gBAAA,kBAAA;;;;aAeo3c;aAA+B;;;;;aAA4H;;;;;;;;;;;;oBAf5hd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/manager/createManager.ts"],"mappings":";;cAea,gBAAa,gBAAA,kBAAA;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/manager/createManager.ts"],"mappings":";;cAea,gBAAa,gBAAA,kBAAA;;;;aAeo3c;aAA+B;;;;;aAA4H;;;;;;;;;;;;oBAf5hd"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hellacardgames/speed",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "A TypeScript library implementing the Speed card game.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"vitest": "^4.1.9"
|
|
87
87
|
},
|
|
88
88
|
"dependencies": {
|
|
89
|
-
"@hellacardgames/lib": "^0.
|
|
89
|
+
"@hellacardgames/lib": "^0.17.0",
|
|
90
90
|
"zod": "^4.4.3"
|
|
91
91
|
}
|
|
92
92
|
}
|