@hellacardgames/speed 0.11.3 → 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 +22 -1
- package/dist/manager/index.d.cts.map +1 -1
- package/dist/manager/index.d.mts +22 -1
- package/dist/manager/index.d.mts.map +1 -1
- package/dist/server/index.cjs +7 -45
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +8 -17
- package/dist/server/index.d.cts.map +1 -1
- package/dist/server/index.d.mts +8 -17
- package/dist/server/index.d.mts.map +1 -1
- package/dist/server/index.mjs +7 -45
- package/dist/server/index.mjs.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"}
|
package/dist/manager/index.d.cts
CHANGED
|
@@ -87,7 +87,7 @@ declare const createManager: (logKey: string, maxGames: number, watchdogInterval
|
|
|
87
87
|
readonly success: false;
|
|
88
88
|
readonly error: "playerNotFound" | "invalidStatus" | "playerNotAdmin" | "minPlayersNotReached";
|
|
89
89
|
};
|
|
90
|
-
} & {
|
|
90
|
+
} & Readonly<{
|
|
91
91
|
drawCard: (gameId: string, playerId: string) => {
|
|
92
92
|
readonly success: true;
|
|
93
93
|
} | {
|
|
@@ -106,6 +106,27 @@ declare const createManager: (logKey: string, maxGames: number, watchdogInterval
|
|
|
106
106
|
readonly success: false;
|
|
107
107
|
readonly error: "playerNotFound" | "invalidStatus" | "canPlayAtNotReached" | "alreadyReported" | "hasPlayableCard" | "canDraw" | "gameNotFound";
|
|
108
108
|
};
|
|
109
|
+
}> & {
|
|
110
|
+
readonly gameplayActions: Readonly<{
|
|
111
|
+
drawCard: (gameId: string, playerId: string) => {
|
|
112
|
+
readonly success: true;
|
|
113
|
+
} | {
|
|
114
|
+
readonly success: false;
|
|
115
|
+
readonly error: "playerNotFound" | "invalidStatus" | "canPlayAtNotReached" | "handFull" | "drawPileEmpty" | "gameNotFound";
|
|
116
|
+
};
|
|
117
|
+
playCard: (gameId: string, playerId: string, cardId: string, isForOtherPlayerPile: boolean) => {
|
|
118
|
+
readonly success: true;
|
|
119
|
+
} | {
|
|
120
|
+
readonly success: false;
|
|
121
|
+
readonly error: "playerNotFound" | "invalidStatus" | "canPlayAtNotReached" | "cardNotFound" | "cardNotPlayable" | "gameNotFound";
|
|
122
|
+
};
|
|
123
|
+
reportNoPlayableCards: (gameId: string, playerId: string) => {
|
|
124
|
+
readonly success: true;
|
|
125
|
+
} | {
|
|
126
|
+
readonly success: false;
|
|
127
|
+
readonly error: "playerNotFound" | "invalidStatus" | "canPlayAtNotReached" | "alreadyReported" | "hasPlayableCard" | "canDraw" | "gameNotFound";
|
|
128
|
+
};
|
|
129
|
+
}>;
|
|
109
130
|
};
|
|
110
131
|
//#endregion
|
|
111
132
|
export { createManager };
|
|
@@ -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"}
|
package/dist/manager/index.d.mts
CHANGED
|
@@ -87,7 +87,7 @@ declare const createManager: (logKey: string, maxGames: number, watchdogInterval
|
|
|
87
87
|
readonly success: false;
|
|
88
88
|
readonly error: "playerNotFound" | "invalidStatus" | "playerNotAdmin" | "minPlayersNotReached";
|
|
89
89
|
};
|
|
90
|
-
} & {
|
|
90
|
+
} & Readonly<{
|
|
91
91
|
drawCard: (gameId: string, playerId: string) => {
|
|
92
92
|
readonly success: true;
|
|
93
93
|
} | {
|
|
@@ -106,6 +106,27 @@ declare const createManager: (logKey: string, maxGames: number, watchdogInterval
|
|
|
106
106
|
readonly success: false;
|
|
107
107
|
readonly error: "playerNotFound" | "invalidStatus" | "canPlayAtNotReached" | "alreadyReported" | "hasPlayableCard" | "canDraw" | "gameNotFound";
|
|
108
108
|
};
|
|
109
|
+
}> & {
|
|
110
|
+
readonly gameplayActions: Readonly<{
|
|
111
|
+
drawCard: (gameId: string, playerId: string) => {
|
|
112
|
+
readonly success: true;
|
|
113
|
+
} | {
|
|
114
|
+
readonly success: false;
|
|
115
|
+
readonly error: "playerNotFound" | "invalidStatus" | "canPlayAtNotReached" | "handFull" | "drawPileEmpty" | "gameNotFound";
|
|
116
|
+
};
|
|
117
|
+
playCard: (gameId: string, playerId: string, cardId: string, isForOtherPlayerPile: boolean) => {
|
|
118
|
+
readonly success: true;
|
|
119
|
+
} | {
|
|
120
|
+
readonly success: false;
|
|
121
|
+
readonly error: "playerNotFound" | "invalidStatus" | "canPlayAtNotReached" | "cardNotFound" | "cardNotPlayable" | "gameNotFound";
|
|
122
|
+
};
|
|
123
|
+
reportNoPlayableCards: (gameId: string, playerId: string) => {
|
|
124
|
+
readonly success: true;
|
|
125
|
+
} | {
|
|
126
|
+
readonly success: false;
|
|
127
|
+
readonly error: "playerNotFound" | "invalidStatus" | "canPlayAtNotReached" | "alreadyReported" | "hasPlayableCard" | "canDraw" | "gameNotFound";
|
|
128
|
+
};
|
|
129
|
+
}>;
|
|
109
130
|
};
|
|
110
131
|
//#endregion
|
|
111
132
|
export { createManager };
|
|
@@ -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/dist/server/index.cjs
CHANGED
|
@@ -3,20 +3,12 @@ const require_manager = require("../manager-DdpdgNfz.cjs");
|
|
|
3
3
|
let _hellacardgames_lib = require("@hellacardgames/lib");
|
|
4
4
|
let zod = require("zod");
|
|
5
5
|
//#region src/server/createServer.ts
|
|
6
|
-
const createServer = (0, _hellacardgames_lib.createServerFactory)(require_manager.createManager,
|
|
7
|
-
|
|
6
|
+
const createServer = (0, _hellacardgames_lib.createServerFactory)(require_manager.createManager, {
|
|
7
|
+
drawCard: zod.z.object({
|
|
8
8
|
gameId: zod.z.string(),
|
|
9
9
|
playerId: zod.z.string()
|
|
10
|
-
}).transform(({ gameId, playerId }) => [gameId, playerId])
|
|
11
|
-
|
|
12
|
-
const parseResult = drawCardInputSchema.safeParse(input);
|
|
13
|
-
if (!parseResult.success) return {
|
|
14
|
-
success: false,
|
|
15
|
-
error: "invalidInput"
|
|
16
|
-
};
|
|
17
|
-
return manager.drawCard(...parseResult.data);
|
|
18
|
-
}
|
|
19
|
-
const playCardInputSchema = zod.z.object({
|
|
10
|
+
}).transform(({ gameId, playerId }) => [gameId, playerId]),
|
|
11
|
+
playCard: zod.z.object({
|
|
20
12
|
gameId: zod.z.string(),
|
|
21
13
|
playerId: zod.z.string(),
|
|
22
14
|
cardId: zod.z.string(),
|
|
@@ -26,41 +18,11 @@ const createServer = (0, _hellacardgames_lib.createServerFactory)(require_manage
|
|
|
26
18
|
playerId,
|
|
27
19
|
cardId,
|
|
28
20
|
isForOtherPlayerPile
|
|
29
|
-
])
|
|
30
|
-
|
|
31
|
-
const parseResult = playCardInputSchema.safeParse(input);
|
|
32
|
-
if (!parseResult.success) return {
|
|
33
|
-
success: false,
|
|
34
|
-
error: "invalidInput"
|
|
35
|
-
};
|
|
36
|
-
return manager.playCard(...parseResult.data);
|
|
37
|
-
}
|
|
38
|
-
const reportNoPlayableCardsInputSchema = zod.z.object({
|
|
21
|
+
]),
|
|
22
|
+
reportNoPlayableCards: zod.z.object({
|
|
39
23
|
gameId: zod.z.string(),
|
|
40
24
|
playerId: zod.z.string()
|
|
41
|
-
}).transform(({ gameId, playerId }) => [gameId, playerId])
|
|
42
|
-
function reportNoPlayableCards(input) {
|
|
43
|
-
const parseResult = reportNoPlayableCardsInputSchema.safeParse(input);
|
|
44
|
-
if (!parseResult.success) return {
|
|
45
|
-
success: false,
|
|
46
|
-
error: "invalidInput"
|
|
47
|
-
};
|
|
48
|
-
return manager.reportNoPlayableCards(...parseResult.data);
|
|
49
|
-
}
|
|
50
|
-
return [
|
|
51
|
-
{
|
|
52
|
-
path: "/drawCard",
|
|
53
|
-
action: drawCard
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
path: "/playCard",
|
|
57
|
-
action: playCard
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
path: "/reportNoPlayableCards",
|
|
61
|
-
action: reportNoPlayableCards
|
|
62
|
-
}
|
|
63
|
-
];
|
|
25
|
+
}).transform(({ gameId, playerId }) => [gameId, playerId])
|
|
64
26
|
});
|
|
65
27
|
//#endregion
|
|
66
28
|
exports.createServer = createServer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["createServerFactory","createManager","z"],"sources":["../../src/server/createServer.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { createServerFactory } from \"@hellacardgames/lib\";\nimport { createManager } from \"../manager/index.js\";\n\nexport const createServer = createServerFactory(createManager,
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["createServerFactory","createManager","z"],"sources":["../../src/server/createServer.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { createServerFactory } from \"@hellacardgames/lib\";\nimport { createManager } from \"../manager/index.js\";\n\nexport const createServer = createServerFactory(createManager, {\n drawCard: z\n .object({\n gameId: z.string(),\n playerId: z.string(),\n })\n .transform(({ gameId, playerId }) => [gameId, playerId] as const),\n\n playCard: z\n .object({\n gameId: z.string(),\n playerId: z.string(),\n cardId: z.string(),\n isForOtherPlayerPile: z.boolean(),\n })\n .transform(\n ({ gameId, playerId, cardId, isForOtherPlayerPile }) =>\n [gameId, playerId, cardId, isForOtherPlayerPile] as const,\n ),\n\n reportNoPlayableCards: z\n .object({\n gameId: z.string(),\n playerId: z.string(),\n })\n .transform(({ gameId, playerId }) => [gameId, playerId] as const),\n});\n"],"mappings":";;;;;AAIA,MAAa,gBAAA,GAAeA,oBAAAA,oBAAAA,CAAoBC,gBAAAA,eAAe;CAC7D,UAAUC,IAAAA,EACP,OAAO;EACN,QAAQA,IAAAA,EAAE,OAAO;EACjB,UAAUA,IAAAA,EAAE,OAAO;CACrB,CAAC,CAAC,CACD,WAAW,EAAE,QAAQ,eAAe,CAAC,QAAQ,QAAQ,CAAU;CAElE,UAAUA,IAAAA,EACP,OAAO;EACN,QAAQA,IAAAA,EAAE,OAAO;EACjB,UAAUA,IAAAA,EAAE,OAAO;EACnB,QAAQA,IAAAA,EAAE,OAAO;EACjB,sBAAsBA,IAAAA,EAAE,QAAQ;CAClC,CAAC,CAAC,CACD,WACE,EAAE,QAAQ,UAAU,QAAQ,2BAC3B;EAAC;EAAQ;EAAU;EAAQ;CAAoB,CACnD;CAEF,uBAAuBA,IAAAA,EACpB,OAAO;EACN,QAAQA,IAAAA,EAAE,OAAO;EACjB,UAAUA,IAAAA,EAAE,OAAO;CACrB,CAAC,CAAC,CACD,WAAW,EAAE,QAAQ,eAAe,CAAC,QAAQ,QAAQ,CAAU;AACpE,CAAC"}
|
package/dist/server/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as GameEvent, t as ClientState } from "../index-89KVb2dD.cjs";
|
|
2
2
|
//#region src/server/createServer.d.ts
|
|
3
3
|
declare const createServer: (logKey: string, maxGames: number, watchdogIntervalMs: number) => {
|
|
4
|
-
readonly
|
|
4
|
+
readonly routes: readonly [{
|
|
5
5
|
readonly path: "/createGame";
|
|
6
6
|
readonly action: (userId: string, username: string) => {
|
|
7
7
|
readonly success: true;
|
|
@@ -88,40 +88,31 @@ declare const createServer: (logKey: string, maxGames: number, watchdogIntervalM
|
|
|
88
88
|
readonly success: false;
|
|
89
89
|
readonly error: "playerNotFound" | "invalidStatus" | "playerNotAdmin" | "minPlayersNotReached" | "gameNotFound";
|
|
90
90
|
};
|
|
91
|
-
}, {
|
|
91
|
+
}, ...({
|
|
92
92
|
readonly path: "/drawCard";
|
|
93
93
|
readonly action: (input: unknown) => {
|
|
94
94
|
readonly success: true;
|
|
95
95
|
} | {
|
|
96
96
|
readonly success: false;
|
|
97
|
-
readonly error: "playerNotFound" | "invalidStatus" | "canPlayAtNotReached" | "handFull" | "drawPileEmpty" | "gameNotFound";
|
|
98
|
-
} | {
|
|
99
|
-
readonly success: false;
|
|
100
|
-
readonly error: "invalidInput";
|
|
97
|
+
readonly error: "playerNotFound" | "invalidStatus" | "canPlayAtNotReached" | "handFull" | "drawPileEmpty" | "gameNotFound" | "invalidInput";
|
|
101
98
|
};
|
|
102
|
-
}
|
|
99
|
+
} | {
|
|
103
100
|
readonly path: "/playCard";
|
|
104
101
|
readonly action: (input: unknown) => {
|
|
105
102
|
readonly success: true;
|
|
106
103
|
} | {
|
|
107
104
|
readonly success: false;
|
|
108
|
-
readonly error: "playerNotFound" | "invalidStatus" | "canPlayAtNotReached" | "cardNotFound" | "cardNotPlayable" | "gameNotFound";
|
|
109
|
-
} | {
|
|
110
|
-
readonly success: false;
|
|
111
|
-
readonly error: "invalidInput";
|
|
105
|
+
readonly error: "playerNotFound" | "invalidStatus" | "canPlayAtNotReached" | "cardNotFound" | "cardNotPlayable" | "gameNotFound" | "invalidInput";
|
|
112
106
|
};
|
|
113
|
-
}
|
|
107
|
+
} | {
|
|
114
108
|
readonly path: "/reportNoPlayableCards";
|
|
115
109
|
readonly action: (input: unknown) => {
|
|
116
110
|
readonly success: true;
|
|
117
111
|
} | {
|
|
118
112
|
readonly success: false;
|
|
119
|
-
readonly error: "playerNotFound" | "invalidStatus" | "canPlayAtNotReached" | "alreadyReported" | "hasPlayableCard" | "canDraw" | "gameNotFound";
|
|
120
|
-
} | {
|
|
121
|
-
readonly success: false;
|
|
122
|
-
readonly error: "invalidInput";
|
|
113
|
+
readonly error: "playerNotFound" | "invalidStatus" | "canPlayAtNotReached" | "alreadyReported" | "hasPlayableCard" | "canDraw" | "gameNotFound" | "invalidInput";
|
|
123
114
|
};
|
|
124
|
-
}];
|
|
115
|
+
})[]];
|
|
125
116
|
};
|
|
126
117
|
//#endregion
|
|
127
118
|
export { createServer };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/server/createServer.ts"],"mappings":";;cAIa,eAAY,gBAAA,kBAAA;;;;;;;;;;;;;;;;;;sBAAZ;;;;;;;;;;;;gCAAA
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/server/createServer.ts"],"mappings":";;cAIa,eAAY,gBAAA,kBAAA;;;;;;;;;;;;;;;;;;sBAAZ;;;;;;;;;;;;gCAAA"}
|
package/dist/server/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as GameEvent, t as ClientState } from "../index-89KVb2dD.mjs";
|
|
2
2
|
//#region src/server/createServer.d.ts
|
|
3
3
|
declare const createServer: (logKey: string, maxGames: number, watchdogIntervalMs: number) => {
|
|
4
|
-
readonly
|
|
4
|
+
readonly routes: readonly [{
|
|
5
5
|
readonly path: "/createGame";
|
|
6
6
|
readonly action: (userId: string, username: string) => {
|
|
7
7
|
readonly success: true;
|
|
@@ -88,40 +88,31 @@ declare const createServer: (logKey: string, maxGames: number, watchdogIntervalM
|
|
|
88
88
|
readonly success: false;
|
|
89
89
|
readonly error: "playerNotFound" | "invalidStatus" | "playerNotAdmin" | "minPlayersNotReached" | "gameNotFound";
|
|
90
90
|
};
|
|
91
|
-
}, {
|
|
91
|
+
}, ...({
|
|
92
92
|
readonly path: "/drawCard";
|
|
93
93
|
readonly action: (input: unknown) => {
|
|
94
94
|
readonly success: true;
|
|
95
95
|
} | {
|
|
96
96
|
readonly success: false;
|
|
97
|
-
readonly error: "playerNotFound" | "invalidStatus" | "canPlayAtNotReached" | "handFull" | "drawPileEmpty" | "gameNotFound";
|
|
98
|
-
} | {
|
|
99
|
-
readonly success: false;
|
|
100
|
-
readonly error: "invalidInput";
|
|
97
|
+
readonly error: "playerNotFound" | "invalidStatus" | "canPlayAtNotReached" | "handFull" | "drawPileEmpty" | "gameNotFound" | "invalidInput";
|
|
101
98
|
};
|
|
102
|
-
}
|
|
99
|
+
} | {
|
|
103
100
|
readonly path: "/playCard";
|
|
104
101
|
readonly action: (input: unknown) => {
|
|
105
102
|
readonly success: true;
|
|
106
103
|
} | {
|
|
107
104
|
readonly success: false;
|
|
108
|
-
readonly error: "playerNotFound" | "invalidStatus" | "canPlayAtNotReached" | "cardNotFound" | "cardNotPlayable" | "gameNotFound";
|
|
109
|
-
} | {
|
|
110
|
-
readonly success: false;
|
|
111
|
-
readonly error: "invalidInput";
|
|
105
|
+
readonly error: "playerNotFound" | "invalidStatus" | "canPlayAtNotReached" | "cardNotFound" | "cardNotPlayable" | "gameNotFound" | "invalidInput";
|
|
112
106
|
};
|
|
113
|
-
}
|
|
107
|
+
} | {
|
|
114
108
|
readonly path: "/reportNoPlayableCards";
|
|
115
109
|
readonly action: (input: unknown) => {
|
|
116
110
|
readonly success: true;
|
|
117
111
|
} | {
|
|
118
112
|
readonly success: false;
|
|
119
|
-
readonly error: "playerNotFound" | "invalidStatus" | "canPlayAtNotReached" | "alreadyReported" | "hasPlayableCard" | "canDraw" | "gameNotFound";
|
|
120
|
-
} | {
|
|
121
|
-
readonly success: false;
|
|
122
|
-
readonly error: "invalidInput";
|
|
113
|
+
readonly error: "playerNotFound" | "invalidStatus" | "canPlayAtNotReached" | "alreadyReported" | "hasPlayableCard" | "canDraw" | "gameNotFound" | "invalidInput";
|
|
123
114
|
};
|
|
124
|
-
}];
|
|
115
|
+
})[]];
|
|
125
116
|
};
|
|
126
117
|
//#endregion
|
|
127
118
|
export { createServer };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/server/createServer.ts"],"mappings":";;cAIa,eAAY,gBAAA,kBAAA;;;;;;;;;;;;;;;;;;sBAAZ;;;;;;;;;;;;gCAAA
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/server/createServer.ts"],"mappings":";;cAIa,eAAY,gBAAA,kBAAA;;;;;;;;;;;;;;;;;;sBAAZ;;;;;;;;;;;;gCAAA"}
|
package/dist/server/index.mjs
CHANGED
|
@@ -2,20 +2,12 @@ import { t as createManager } from "../manager-C8wqbmrE.mjs";
|
|
|
2
2
|
import { createServerFactory } from "@hellacardgames/lib";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
//#region src/server/createServer.ts
|
|
5
|
-
const createServer = createServerFactory(createManager,
|
|
6
|
-
|
|
5
|
+
const createServer = createServerFactory(createManager, {
|
|
6
|
+
drawCard: z.object({
|
|
7
7
|
gameId: z.string(),
|
|
8
8
|
playerId: z.string()
|
|
9
|
-
}).transform(({ gameId, playerId }) => [gameId, playerId])
|
|
10
|
-
|
|
11
|
-
const parseResult = drawCardInputSchema.safeParse(input);
|
|
12
|
-
if (!parseResult.success) return {
|
|
13
|
-
success: false,
|
|
14
|
-
error: "invalidInput"
|
|
15
|
-
};
|
|
16
|
-
return manager.drawCard(...parseResult.data);
|
|
17
|
-
}
|
|
18
|
-
const playCardInputSchema = z.object({
|
|
9
|
+
}).transform(({ gameId, playerId }) => [gameId, playerId]),
|
|
10
|
+
playCard: z.object({
|
|
19
11
|
gameId: z.string(),
|
|
20
12
|
playerId: z.string(),
|
|
21
13
|
cardId: z.string(),
|
|
@@ -25,41 +17,11 @@ const createServer = createServerFactory(createManager, (manager) => {
|
|
|
25
17
|
playerId,
|
|
26
18
|
cardId,
|
|
27
19
|
isForOtherPlayerPile
|
|
28
|
-
])
|
|
29
|
-
|
|
30
|
-
const parseResult = playCardInputSchema.safeParse(input);
|
|
31
|
-
if (!parseResult.success) return {
|
|
32
|
-
success: false,
|
|
33
|
-
error: "invalidInput"
|
|
34
|
-
};
|
|
35
|
-
return manager.playCard(...parseResult.data);
|
|
36
|
-
}
|
|
37
|
-
const reportNoPlayableCardsInputSchema = z.object({
|
|
20
|
+
]),
|
|
21
|
+
reportNoPlayableCards: z.object({
|
|
38
22
|
gameId: z.string(),
|
|
39
23
|
playerId: z.string()
|
|
40
|
-
}).transform(({ gameId, playerId }) => [gameId, playerId])
|
|
41
|
-
function reportNoPlayableCards(input) {
|
|
42
|
-
const parseResult = reportNoPlayableCardsInputSchema.safeParse(input);
|
|
43
|
-
if (!parseResult.success) return {
|
|
44
|
-
success: false,
|
|
45
|
-
error: "invalidInput"
|
|
46
|
-
};
|
|
47
|
-
return manager.reportNoPlayableCards(...parseResult.data);
|
|
48
|
-
}
|
|
49
|
-
return [
|
|
50
|
-
{
|
|
51
|
-
path: "/drawCard",
|
|
52
|
-
action: drawCard
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
path: "/playCard",
|
|
56
|
-
action: playCard
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
path: "/reportNoPlayableCards",
|
|
60
|
-
action: reportNoPlayableCards
|
|
61
|
-
}
|
|
62
|
-
];
|
|
24
|
+
}).transform(({ gameId, playerId }) => [gameId, playerId])
|
|
63
25
|
});
|
|
64
26
|
//#endregion
|
|
65
27
|
export { createServer };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/server/createServer.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { createServerFactory } from \"@hellacardgames/lib\";\nimport { createManager } from \"../manager/index.js\";\n\nexport const createServer = createServerFactory(createManager,
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/server/createServer.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { createServerFactory } from \"@hellacardgames/lib\";\nimport { createManager } from \"../manager/index.js\";\n\nexport const createServer = createServerFactory(createManager, {\n drawCard: z\n .object({\n gameId: z.string(),\n playerId: z.string(),\n })\n .transform(({ gameId, playerId }) => [gameId, playerId] as const),\n\n playCard: z\n .object({\n gameId: z.string(),\n playerId: z.string(),\n cardId: z.string(),\n isForOtherPlayerPile: z.boolean(),\n })\n .transform(\n ({ gameId, playerId, cardId, isForOtherPlayerPile }) =>\n [gameId, playerId, cardId, isForOtherPlayerPile] as const,\n ),\n\n reportNoPlayableCards: z\n .object({\n gameId: z.string(),\n playerId: z.string(),\n })\n .transform(({ gameId, playerId }) => [gameId, playerId] as const),\n});\n"],"mappings":";;;;AAIA,MAAa,eAAe,oBAAoB,eAAe;CAC7D,UAAU,EACP,OAAO;EACN,QAAQ,EAAE,OAAO;EACjB,UAAU,EAAE,OAAO;CACrB,CAAC,CAAC,CACD,WAAW,EAAE,QAAQ,eAAe,CAAC,QAAQ,QAAQ,CAAU;CAElE,UAAU,EACP,OAAO;EACN,QAAQ,EAAE,OAAO;EACjB,UAAU,EAAE,OAAO;EACnB,QAAQ,EAAE,OAAO;EACjB,sBAAsB,EAAE,QAAQ;CAClC,CAAC,CAAC,CACD,WACE,EAAE,QAAQ,UAAU,QAAQ,2BAC3B;EAAC;EAAQ;EAAU;EAAQ;CAAoB,CACnD;CAEF,uBAAuB,EACpB,OAAO;EACN,QAAQ,EAAE,OAAO;EACjB,UAAU,EAAE,OAAO;CACrB,CAAC,CAAC,CACD,WAAW,EAAE,QAAQ,eAAe,CAAC,QAAQ,QAAQ,CAAU;AACpE,CAAC"}
|
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
|
}
|