@hellacardgames/speed 0.8.1 → 0.9.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/ClientState-Dx8UvhMt.d.cts +111 -0
- package/dist/ClientState-Dx8UvhMt.d.cts.map +1 -0
- package/dist/ClientState-Dx8UvhMt.d.mts +111 -0
- package/dist/ClientState-Dx8UvhMt.d.mts.map +1 -0
- package/dist/client/index.cjs +60 -10
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +89 -14
- package/dist/client/index.d.cts.map +1 -1
- package/dist/client/index.d.mts +89 -14
- package/dist/client/index.d.mts.map +1 -1
- package/dist/client/index.mjs +60 -10
- package/dist/client/index.mjs.map +1 -1
- package/dist/manager/index.cjs +2 -2
- package/dist/manager/index.d.cts +140 -2
- package/dist/manager/index.d.cts.map +1 -0
- package/dist/manager/index.d.mts +140 -2
- package/dist/manager/index.d.mts.map +1 -0
- package/dist/manager/index.mjs +2 -2
- package/dist/{manager-0r8lvLRR.cjs → manager-B7gHPSPL.cjs} +70 -154
- package/dist/manager-B7gHPSPL.cjs.map +1 -0
- package/dist/{manager-B32oi0dB.mjs → manager-C6kRM9IW.mjs} +70 -154
- package/dist/manager-C6kRM9IW.mjs.map +1 -0
- package/dist/server/index.cjs +45 -165
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +149 -3
- package/dist/server/index.d.cts.map +1 -0
- package/dist/server/index.d.mts +149 -3
- package/dist/server/index.d.mts.map +1 -0
- package/dist/server/index.mjs +45 -165
- package/dist/server/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/index-CVbiOmI3.d.mts +0 -125
- package/dist/index-CVbiOmI3.d.mts.map +0 -1
- package/dist/index-DOimW07r.d.cts +0 -125
- package/dist/index-DOimW07r.d.cts.map +0 -1
- package/dist/index-DlRknHKq.d.cts +0 -247
- package/dist/index-DlRknHKq.d.cts.map +0 -1
- package/dist/index-DlRknHKq.d.mts +0 -247
- package/dist/index-DlRknHKq.d.mts.map +0 -1
- package/dist/manager-0r8lvLRR.cjs.map +0 -1
- package/dist/manager-B32oi0dB.mjs.map +0 -1
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
//#region src/game/types/Card.d.ts
|
|
2
|
+
type Card = {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly rank: 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14;
|
|
5
|
+
readonly suite: "clubs" | "diamonds" | "hearts" | "spades";
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/game/types/ChatMessage.d.ts
|
|
9
|
+
type ChatMessage = {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly username: string;
|
|
12
|
+
readonly text: string;
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/game/types/GameEvent.d.ts
|
|
16
|
+
type GameEvent = {
|
|
17
|
+
readonly type: "canPlayAtUpdated";
|
|
18
|
+
readonly id: string;
|
|
19
|
+
readonly canPlayAt: number;
|
|
20
|
+
} | {
|
|
21
|
+
readonly type: "cardDrawnFromSidePileToCenterPile";
|
|
22
|
+
readonly id: string;
|
|
23
|
+
readonly username: string;
|
|
24
|
+
readonly card: Card;
|
|
25
|
+
} | {
|
|
26
|
+
readonly type: "cardPlayed";
|
|
27
|
+
readonly id: string;
|
|
28
|
+
readonly username: string;
|
|
29
|
+
readonly card: Card;
|
|
30
|
+
readonly isForOtherPlayerPile: boolean;
|
|
31
|
+
} | {
|
|
32
|
+
readonly type: "chat";
|
|
33
|
+
readonly id: string;
|
|
34
|
+
readonly message: ChatMessage;
|
|
35
|
+
} | {
|
|
36
|
+
readonly type: "drewCard";
|
|
37
|
+
readonly id: string;
|
|
38
|
+
readonly card: Card;
|
|
39
|
+
} | {
|
|
40
|
+
readonly type: "expirationUpdated";
|
|
41
|
+
readonly id: string;
|
|
42
|
+
readonly expiresAt: number;
|
|
43
|
+
} | {
|
|
44
|
+
readonly type: "gameCompleted";
|
|
45
|
+
readonly id: string;
|
|
46
|
+
} | {
|
|
47
|
+
readonly type: "gameForfeited";
|
|
48
|
+
readonly id: string;
|
|
49
|
+
} | {
|
|
50
|
+
readonly type: "gameStarted";
|
|
51
|
+
readonly id: string;
|
|
52
|
+
} | {
|
|
53
|
+
readonly type: "handInitialized";
|
|
54
|
+
readonly id: string;
|
|
55
|
+
readonly cards: readonly Card[];
|
|
56
|
+
} | {
|
|
57
|
+
readonly type: "playerCenterPileInitialized";
|
|
58
|
+
readonly id: string;
|
|
59
|
+
readonly username: string;
|
|
60
|
+
readonly card: Card;
|
|
61
|
+
} | {
|
|
62
|
+
readonly type: "playerDrawPileInitialized";
|
|
63
|
+
readonly id: string;
|
|
64
|
+
readonly username: string;
|
|
65
|
+
readonly numCards: number;
|
|
66
|
+
} | {
|
|
67
|
+
readonly type: "playerDrewCard";
|
|
68
|
+
readonly id: string;
|
|
69
|
+
readonly username: string;
|
|
70
|
+
} | {
|
|
71
|
+
readonly type: "playerHandInitialized";
|
|
72
|
+
readonly id: string;
|
|
73
|
+
readonly username: string;
|
|
74
|
+
readonly numCards: number;
|
|
75
|
+
} | {
|
|
76
|
+
readonly type: "playerJoined";
|
|
77
|
+
readonly id: string;
|
|
78
|
+
readonly username: string;
|
|
79
|
+
} | {
|
|
80
|
+
readonly type: "playerLeft";
|
|
81
|
+
readonly id: string;
|
|
82
|
+
readonly username: string;
|
|
83
|
+
} | {
|
|
84
|
+
readonly type: "playerSidePileInitialized";
|
|
85
|
+
readonly id: string;
|
|
86
|
+
readonly username: string;
|
|
87
|
+
readonly numCards: number;
|
|
88
|
+
};
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/game/types/ClientState.d.ts
|
|
91
|
+
type ClientState = {
|
|
92
|
+
readonly status: "created" | "started" | "completed" | "forfeited";
|
|
93
|
+
readonly gameId: string;
|
|
94
|
+
readonly playerId: string;
|
|
95
|
+
readonly username: string;
|
|
96
|
+
readonly players: readonly Player[];
|
|
97
|
+
readonly expiresAt: number;
|
|
98
|
+
readonly chatMessages: readonly ChatMessage[];
|
|
99
|
+
readonly hand: readonly Card[];
|
|
100
|
+
readonly canPlayAt: number | null;
|
|
101
|
+
};
|
|
102
|
+
type Player = {
|
|
103
|
+
readonly username: string;
|
|
104
|
+
readonly handSize: number;
|
|
105
|
+
readonly drawPileSize: number;
|
|
106
|
+
readonly sidePileSize: number;
|
|
107
|
+
readonly centerPileTopCard: Card | null;
|
|
108
|
+
};
|
|
109
|
+
//#endregion
|
|
110
|
+
export { Card as i, GameEvent as n, ChatMessage as r, ClientState as t };
|
|
111
|
+
//# sourceMappingURL=ClientState-Dx8UvhMt.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientState-Dx8UvhMt.d.cts","names":[],"sources":["../src/game/types/Card.ts","../src/game/types/ChatMessage.ts","../src/game/types/GameEvent.ts","../src/game/types/ClientState.ts"],"mappings":";KAAY;WACD;WACA;WACA;;;;KCHC;WACD;WACA;WACA;;;;KCAC;WAEG;WACA;WACA;;WAGA;WACA;WACA;WACA,MAAM;;WAGN;WACA;WACA;WACA,MAAM;WACN;;WAGA;WACA;WACA,SAAS;;WAGT;WACA;WACA,MAAM;;WAGN;WACA;WACA;;WAGA;WACA;;WAGA;WACA;;WAGA;WACA;;WAGA;WACA;WACA,gBAAgB;;WAGhB;WACA;WACA;WACA,MAAM;;WAGN;WACA;WACA;WACA;;WAGA;WACA;WACA;;WAGA;WACA;WACA;WACA;;WAGA;WACA;WACA;;WAGA;WACA;WACA;;WAGA;WACA;WACA;WACA;;;;KCxFH;WACD;WACA;WACA;WACA;WACA,kBAAkB;WAClB;WACA,uBAAuB;WACvB,eAAe;WACf;;KAGN;WACM;WACA;WACA;WACA;WACA,mBAAmB"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
//#region src/game/types/Card.d.ts
|
|
2
|
+
type Card = {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly rank: 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14;
|
|
5
|
+
readonly suite: "clubs" | "diamonds" | "hearts" | "spades";
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/game/types/ChatMessage.d.ts
|
|
9
|
+
type ChatMessage = {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly username: string;
|
|
12
|
+
readonly text: string;
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/game/types/GameEvent.d.ts
|
|
16
|
+
type GameEvent = {
|
|
17
|
+
readonly type: "canPlayAtUpdated";
|
|
18
|
+
readonly id: string;
|
|
19
|
+
readonly canPlayAt: number;
|
|
20
|
+
} | {
|
|
21
|
+
readonly type: "cardDrawnFromSidePileToCenterPile";
|
|
22
|
+
readonly id: string;
|
|
23
|
+
readonly username: string;
|
|
24
|
+
readonly card: Card;
|
|
25
|
+
} | {
|
|
26
|
+
readonly type: "cardPlayed";
|
|
27
|
+
readonly id: string;
|
|
28
|
+
readonly username: string;
|
|
29
|
+
readonly card: Card;
|
|
30
|
+
readonly isForOtherPlayerPile: boolean;
|
|
31
|
+
} | {
|
|
32
|
+
readonly type: "chat";
|
|
33
|
+
readonly id: string;
|
|
34
|
+
readonly message: ChatMessage;
|
|
35
|
+
} | {
|
|
36
|
+
readonly type: "drewCard";
|
|
37
|
+
readonly id: string;
|
|
38
|
+
readonly card: Card;
|
|
39
|
+
} | {
|
|
40
|
+
readonly type: "expirationUpdated";
|
|
41
|
+
readonly id: string;
|
|
42
|
+
readonly expiresAt: number;
|
|
43
|
+
} | {
|
|
44
|
+
readonly type: "gameCompleted";
|
|
45
|
+
readonly id: string;
|
|
46
|
+
} | {
|
|
47
|
+
readonly type: "gameForfeited";
|
|
48
|
+
readonly id: string;
|
|
49
|
+
} | {
|
|
50
|
+
readonly type: "gameStarted";
|
|
51
|
+
readonly id: string;
|
|
52
|
+
} | {
|
|
53
|
+
readonly type: "handInitialized";
|
|
54
|
+
readonly id: string;
|
|
55
|
+
readonly cards: readonly Card[];
|
|
56
|
+
} | {
|
|
57
|
+
readonly type: "playerCenterPileInitialized";
|
|
58
|
+
readonly id: string;
|
|
59
|
+
readonly username: string;
|
|
60
|
+
readonly card: Card;
|
|
61
|
+
} | {
|
|
62
|
+
readonly type: "playerDrawPileInitialized";
|
|
63
|
+
readonly id: string;
|
|
64
|
+
readonly username: string;
|
|
65
|
+
readonly numCards: number;
|
|
66
|
+
} | {
|
|
67
|
+
readonly type: "playerDrewCard";
|
|
68
|
+
readonly id: string;
|
|
69
|
+
readonly username: string;
|
|
70
|
+
} | {
|
|
71
|
+
readonly type: "playerHandInitialized";
|
|
72
|
+
readonly id: string;
|
|
73
|
+
readonly username: string;
|
|
74
|
+
readonly numCards: number;
|
|
75
|
+
} | {
|
|
76
|
+
readonly type: "playerJoined";
|
|
77
|
+
readonly id: string;
|
|
78
|
+
readonly username: string;
|
|
79
|
+
} | {
|
|
80
|
+
readonly type: "playerLeft";
|
|
81
|
+
readonly id: string;
|
|
82
|
+
readonly username: string;
|
|
83
|
+
} | {
|
|
84
|
+
readonly type: "playerSidePileInitialized";
|
|
85
|
+
readonly id: string;
|
|
86
|
+
readonly username: string;
|
|
87
|
+
readonly numCards: number;
|
|
88
|
+
};
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/game/types/ClientState.d.ts
|
|
91
|
+
type ClientState = {
|
|
92
|
+
readonly status: "created" | "started" | "completed" | "forfeited";
|
|
93
|
+
readonly gameId: string;
|
|
94
|
+
readonly playerId: string;
|
|
95
|
+
readonly username: string;
|
|
96
|
+
readonly players: readonly Player[];
|
|
97
|
+
readonly expiresAt: number;
|
|
98
|
+
readonly chatMessages: readonly ChatMessage[];
|
|
99
|
+
readonly hand: readonly Card[];
|
|
100
|
+
readonly canPlayAt: number | null;
|
|
101
|
+
};
|
|
102
|
+
type Player = {
|
|
103
|
+
readonly username: string;
|
|
104
|
+
readonly handSize: number;
|
|
105
|
+
readonly drawPileSize: number;
|
|
106
|
+
readonly sidePileSize: number;
|
|
107
|
+
readonly centerPileTopCard: Card | null;
|
|
108
|
+
};
|
|
109
|
+
//#endregion
|
|
110
|
+
export { Card as i, GameEvent as n, ChatMessage as r, ClientState as t };
|
|
111
|
+
//# sourceMappingURL=ClientState-Dx8UvhMt.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientState-Dx8UvhMt.d.mts","names":[],"sources":["../src/game/types/Card.ts","../src/game/types/ChatMessage.ts","../src/game/types/GameEvent.ts","../src/game/types/ClientState.ts"],"mappings":";KAAY;WACD;WACA;WACA;;;;KCHC;WACD;WACA;WACA;;;;KCAC;WAEG;WACA;WACA;;WAGA;WACA;WACA;WACA,MAAM;;WAGN;WACA;WACA;WACA,MAAM;WACN;;WAGA;WACA;WACA,SAAS;;WAGT;WACA;WACA,MAAM;;WAGN;WACA;WACA;;WAGA;WACA;;WAGA;WACA;;WAGA;WACA;;WAGA;WACA;WACA,gBAAgB;;WAGhB;WACA;WACA;WACA,MAAM;;WAGN;WACA;WACA;WACA;;WAGA;WACA;WACA;;WAGA;WACA;WACA;WACA;;WAGA;WACA;WACA;;WAGA;WACA;WACA;;WAGA;WACA;WACA;WACA;;;;KCxFH;WACD;WACA;WACA;WACA;WACA,kBAAkB;WAClB;WACA,uBAAuB;WACvB,eAAe;WACf;;KAGN;WACM;WACA;WACA;WACA;WACA,mBAAmB"}
|
package/dist/client/index.cjs
CHANGED
|
@@ -6,13 +6,18 @@ var Client = class {
|
|
|
6
6
|
this.baseUrl = baseUrl;
|
|
7
7
|
}
|
|
8
8
|
async createGame(accessToken) {
|
|
9
|
-
|
|
9
|
+
const result = await (await fetch(`${this.baseUrl}/createGame`, {
|
|
10
10
|
method: "POST",
|
|
11
11
|
headers: { Authorization: `Bearer ${accessToken}` }
|
|
12
12
|
})).json();
|
|
13
|
+
if (!result.success) return {
|
|
14
|
+
success: false,
|
|
15
|
+
error: result.error
|
|
16
|
+
};
|
|
17
|
+
return result;
|
|
13
18
|
}
|
|
14
19
|
async drawCard(gameId, playerId) {
|
|
15
|
-
|
|
20
|
+
const result = await (await fetch(`${this.baseUrl}/drawCard`, {
|
|
16
21
|
method: "POST",
|
|
17
22
|
headers: { "Content-Type": "application/json" },
|
|
18
23
|
body: JSON.stringify({
|
|
@@ -20,9 +25,14 @@ var Client = class {
|
|
|
20
25
|
playerId
|
|
21
26
|
})
|
|
22
27
|
})).json();
|
|
28
|
+
if (!result.success) return {
|
|
29
|
+
success: false,
|
|
30
|
+
error: result.error
|
|
31
|
+
};
|
|
32
|
+
return result;
|
|
23
33
|
}
|
|
24
34
|
async getClientStateAndClearEvents(gameId, playerId) {
|
|
25
|
-
|
|
35
|
+
const result = await (await fetch(`${this.baseUrl}/getClientStateAndClearEvents`, {
|
|
26
36
|
method: "POST",
|
|
27
37
|
headers: { "Content-Type": "application/json" },
|
|
28
38
|
body: JSON.stringify({
|
|
@@ -30,9 +40,14 @@ var Client = class {
|
|
|
30
40
|
playerId
|
|
31
41
|
})
|
|
32
42
|
})).json();
|
|
43
|
+
if (!result.success) return {
|
|
44
|
+
success: false,
|
|
45
|
+
error: result.error
|
|
46
|
+
};
|
|
47
|
+
return result;
|
|
33
48
|
}
|
|
34
49
|
async getEventsAndClearAcknowledged(gameId, playerId, lastReadId) {
|
|
35
|
-
|
|
50
|
+
const result = await (await fetch(`${this.baseUrl}/getEventsAndClearAcknowledged`, {
|
|
36
51
|
method: "POST",
|
|
37
52
|
headers: { "Content-Type": "application/json" },
|
|
38
53
|
body: JSON.stringify({
|
|
@@ -41,12 +56,17 @@ var Client = class {
|
|
|
41
56
|
lastReadId
|
|
42
57
|
})
|
|
43
58
|
})).json();
|
|
59
|
+
if (!result.success) return {
|
|
60
|
+
success: false,
|
|
61
|
+
error: result.error
|
|
62
|
+
};
|
|
63
|
+
return result;
|
|
44
64
|
}
|
|
45
65
|
async getJoinableGames() {
|
|
46
66
|
return await (await fetch(`${this.baseUrl}/getJoinableGames`, { method: "POST" })).json();
|
|
47
67
|
}
|
|
48
68
|
async joinGame(gameId, accessToken) {
|
|
49
|
-
|
|
69
|
+
const result = await (await fetch(`${this.baseUrl}/joinGame`, {
|
|
50
70
|
method: "POST",
|
|
51
71
|
headers: {
|
|
52
72
|
Authorization: `Bearer ${accessToken}`,
|
|
@@ -54,9 +74,14 @@ var Client = class {
|
|
|
54
74
|
},
|
|
55
75
|
body: JSON.stringify({ gameId })
|
|
56
76
|
})).json();
|
|
77
|
+
if (!result.success) return {
|
|
78
|
+
success: false,
|
|
79
|
+
error: result.error
|
|
80
|
+
};
|
|
81
|
+
return result;
|
|
57
82
|
}
|
|
58
83
|
async leaveGame(gameId, playerId) {
|
|
59
|
-
|
|
84
|
+
const result = await (await fetch(`${this.baseUrl}/leaveGame`, {
|
|
60
85
|
method: "POST",
|
|
61
86
|
headers: { "Content-Type": "application/json" },
|
|
62
87
|
body: JSON.stringify({
|
|
@@ -64,9 +89,14 @@ var Client = class {
|
|
|
64
89
|
playerId
|
|
65
90
|
})
|
|
66
91
|
})).json();
|
|
92
|
+
if (!result.success) return {
|
|
93
|
+
success: false,
|
|
94
|
+
error: result.error
|
|
95
|
+
};
|
|
96
|
+
return result;
|
|
67
97
|
}
|
|
68
98
|
async playCard(gameId, playerId, cardId, isForOtherPlayerPile) {
|
|
69
|
-
|
|
99
|
+
const result = await (await fetch(`${this.baseUrl}/playCard`, {
|
|
70
100
|
method: "POST",
|
|
71
101
|
headers: { "Content-Type": "application/json" },
|
|
72
102
|
body: JSON.stringify({
|
|
@@ -76,9 +106,14 @@ var Client = class {
|
|
|
76
106
|
isForOtherPlayerPile
|
|
77
107
|
})
|
|
78
108
|
})).json();
|
|
109
|
+
if (!result.success) return {
|
|
110
|
+
success: false,
|
|
111
|
+
error: result.error
|
|
112
|
+
};
|
|
113
|
+
return result;
|
|
79
114
|
}
|
|
80
115
|
async reportNoPlayableCards(gameId, playerId) {
|
|
81
|
-
|
|
116
|
+
const result = await (await fetch(`${this.baseUrl}/reportNoPlayableCards`, {
|
|
82
117
|
method: "POST",
|
|
83
118
|
headers: { "Content-Type": "application/json" },
|
|
84
119
|
body: JSON.stringify({
|
|
@@ -86,9 +121,14 @@ var Client = class {
|
|
|
86
121
|
playerId
|
|
87
122
|
})
|
|
88
123
|
})).json();
|
|
124
|
+
if (!result.success) return {
|
|
125
|
+
success: false,
|
|
126
|
+
error: result.error
|
|
127
|
+
};
|
|
128
|
+
return result;
|
|
89
129
|
}
|
|
90
130
|
async sendChat(gameId, playerId, text) {
|
|
91
|
-
|
|
131
|
+
const result = await (await fetch(`${this.baseUrl}/sendChat`, {
|
|
92
132
|
method: "POST",
|
|
93
133
|
headers: { "Content-Type": "application/json" },
|
|
94
134
|
body: JSON.stringify({
|
|
@@ -97,9 +137,14 @@ var Client = class {
|
|
|
97
137
|
text
|
|
98
138
|
})
|
|
99
139
|
})).json();
|
|
140
|
+
if (!result.success) return {
|
|
141
|
+
success: false,
|
|
142
|
+
error: result.error
|
|
143
|
+
};
|
|
144
|
+
return result;
|
|
100
145
|
}
|
|
101
146
|
async startGame(gameId, playerId) {
|
|
102
|
-
|
|
147
|
+
const result = await (await fetch(`${this.baseUrl}/startGame`, {
|
|
103
148
|
method: "POST",
|
|
104
149
|
headers: { "Content-Type": "application/json" },
|
|
105
150
|
body: JSON.stringify({
|
|
@@ -107,6 +152,11 @@ var Client = class {
|
|
|
107
152
|
playerId
|
|
108
153
|
})
|
|
109
154
|
})).json();
|
|
155
|
+
if (!result.success) return {
|
|
156
|
+
success: false,
|
|
157
|
+
error: result.error
|
|
158
|
+
};
|
|
159
|
+
return result;
|
|
110
160
|
}
|
|
111
161
|
};
|
|
112
162
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":[],"sources":["../../src/client/Client.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../../src/client/Client.ts"],"sourcesContent":["import type { createServer } from \"../server/index.js\";\n\ntype Server = ReturnType<typeof createServer>;\n\ntype ServerResult<\n TServer extends {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n actions: readonly { path: string; action: (...args: any[]) => any }[];\n },\n TPath extends TServer[\"actions\"][number][\"path\"],\n> = ReturnType<Extract<TServer[\"actions\"][number], { path: TPath }>[\"action\"]>;\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) {\n const response = await fetch(`${this.baseUrl}/createGame`, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${accessToken}`,\n },\n });\n const result: ServerResult<Server, \"/createGame\"> = await response.json();\n if (!result.success) {\n return { success: false, error: result.error } as const;\n }\n return result;\n }\n\n async drawCard(gameId: string, playerId: string) {\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: ServerResult<Server, \"/drawCard\"> = await response.json();\n if (!result.success) {\n return { success: false, error: result.error } as const;\n }\n return result;\n }\n\n async getClientStateAndClearEvents(gameId: string, playerId: string) {\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: ServerResult<Server, \"/getClientStateAndClearEvents\"> =\n await response.json();\n if (!result.success) {\n return { success: false, error: result.error } as const;\n }\n return result;\n }\n\n async getEventsAndClearAcknowledged(\n gameId: string,\n playerId: string,\n lastReadId: string | null,\n ) {\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: ServerResult<Server, \"/getEventsAndClearAcknowledged\"> =\n await response.json();\n if (!result.success) {\n return { success: false, error: result.error } as const;\n }\n return result;\n }\n\n async getJoinableGames() {\n const response = await fetch(`${this.baseUrl}/getJoinableGames`, {\n method: \"POST\",\n });\n const result: ServerResult<Server, \"/getJoinableGames\"> =\n await response.json();\n return result;\n }\n\n async joinGame(gameId: string, accessToken: string) {\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: ServerResult<Server, \"/joinGame\"> = await response.json();\n if (!result.success) {\n return { success: false, error: result.error } as const;\n }\n return result;\n }\n\n async leaveGame(gameId: string, playerId: string) {\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: ServerResult<Server, \"/leaveGame\"> = await response.json();\n if (!result.success) {\n return { success: false, error: result.error } as const;\n }\n return result;\n }\n\n async playCard(\n gameId: string,\n playerId: string,\n cardId: string,\n isForOtherPlayerPile: boolean,\n ) {\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, isForOtherPlayerPile }),\n });\n const result: ServerResult<Server, \"/playCard\"> = await response.json();\n if (!result.success) {\n return { success: false, error: result.error } as const;\n }\n return result;\n }\n\n async reportNoPlayableCards(gameId: string, playerId: string) {\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: ServerResult<Server, \"/reportNoPlayableCards\"> =\n await response.json();\n if (!result.success) {\n return { success: false, error: result.error } as const;\n }\n return result;\n }\n\n async sendChat(gameId: string, playerId: string, text: string) {\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: ServerResult<Server, \"/sendChat\"> = await response.json();\n if (!result.success) {\n return { success: false, error: result.error } as const;\n }\n return result;\n }\n\n async startGame(gameId: string, playerId: string) {\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: ServerResult<Server, \"/startGame\"> = await response.json();\n if (!result.success) {\n return { success: false, error: result.error } as const;\n }\n return result;\n }\n}\n"],"mappings":";;AAYA,IAAa,SAAb,MAAoB;CAClB;CAEA,YAAY,SAAiB;EAC3B,KAAK,UAAU;CACjB;CAEA,MAAM,WAAW,aAAqB;EAOpC,MAAM,SAA8C,OAAM,MANnC,MAAM,GAAG,KAAK,QAAQ,cAAc;GACzD,QAAQ;GACR,SAAS,EACP,eAAe,UAAU,cAC3B;EACF,CAAC,EAAA,CACkE,KAAK;EACxE,IAAI,CAAC,OAAO,SACV,OAAO;GAAE,SAAS;GAAO,OAAO,OAAO;EAAM;EAE/C,OAAO;CACT;CAEA,MAAM,SAAS,QAAgB,UAAkB;EAQ/C,MAAM,SAA4C,OAAM,MAPjC,MAAM,GAAG,KAAK,QAAQ,YAAY;GACvD,QAAQ;GACR,SAAS,EACP,gBAAgB,mBAClB;GACA,MAAM,KAAK,UAAU;IAAE;IAAQ;GAAS,CAAC;EAC3C,CAAC,EAAA,CACgE,KAAK;EACtE,IAAI,CAAC,OAAO,SACV,OAAO;GAAE,SAAS;GAAO,OAAO,OAAO;EAAM;EAE/C,OAAO;CACT;CAEA,MAAM,6BAA6B,QAAgB,UAAkB;EAWnE,MAAM,SACJ,OAAM,MAXe,MACrB,GAAG,KAAK,QAAQ,gCAChB;GACE,QAAQ;GACR,SAAS,EACP,gBAAgB,mBAClB;GACA,MAAM,KAAK,UAAU;IAAE;IAAQ;GAAS,CAAC;EAC3C,CACF,EAAA,CAEiB,KAAK;EACtB,IAA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1,21 +1,96 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as GetJoinableGamesResult, c as PlayCardResult, f as StartGameResult, i as GetEventsAndClearAcknowledgedResult, l as ReportNoPlayableCardsResult, n as DrawCardResult, o as JoinGameResult, r as GetClientStateAndClearEventsResult, s as LeaveGameResult, t as CreateGameResult, u as SendChatResult } from "../index-DOimW07r.cjs";
|
|
1
|
+
import { i as Card, n as GameEvent, r as ChatMessage, t as ClientState } from "../ClientState-Dx8UvhMt.cjs";
|
|
3
2
|
//#region src/client/Client.d.ts
|
|
4
3
|
declare class Client {
|
|
5
4
|
private readonly baseUrl;
|
|
6
5
|
constructor(baseUrl: string);
|
|
7
|
-
createGame(accessToken: string): Promise<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
6
|
+
createGame(accessToken: string): Promise<{
|
|
7
|
+
readonly success: true;
|
|
8
|
+
readonly gameId: string;
|
|
9
|
+
readonly playerId: string;
|
|
10
|
+
} | {
|
|
11
|
+
readonly success: false;
|
|
12
|
+
readonly error: "maxGamesReached";
|
|
13
|
+
}>;
|
|
14
|
+
drawCard(gameId: string, playerId: string): Promise<{
|
|
15
|
+
readonly success: true;
|
|
16
|
+
readonly error?: never;
|
|
17
|
+
} | {
|
|
18
|
+
readonly success: false;
|
|
19
|
+
readonly error: "playerNotFound" | "gameNotFound" | "invalidStatus" | "canPlayAtNotReached" | "handFull" | "drawPileEmpty" | "invalidInput";
|
|
20
|
+
}>;
|
|
21
|
+
getClientStateAndClearEvents(gameId: string, playerId: string): Promise<{
|
|
22
|
+
readonly success: true;
|
|
23
|
+
readonly state: ClientState;
|
|
24
|
+
} | {
|
|
25
|
+
readonly success: false;
|
|
26
|
+
readonly error: "playerNotFound" | "gameNotFound" | "invalidInput";
|
|
27
|
+
}>;
|
|
28
|
+
getEventsAndClearAcknowledged(gameId: string, playerId: string, lastReadId: string | null): Promise<{
|
|
29
|
+
readonly success: true;
|
|
30
|
+
readonly events: readonly GameEvent[];
|
|
31
|
+
} | {
|
|
32
|
+
readonly success: false;
|
|
33
|
+
readonly error: "playerNotFound" | "gameNotFound" | "invalidInput";
|
|
34
|
+
}>;
|
|
35
|
+
getJoinableGames(): Promise<{
|
|
36
|
+
readonly games: readonly {
|
|
37
|
+
readonly id: string;
|
|
38
|
+
readonly numPlayers: number;
|
|
39
|
+
}[];
|
|
40
|
+
}>;
|
|
41
|
+
joinGame(gameId: string, accessToken: string): Promise<{
|
|
42
|
+
readonly success: true;
|
|
43
|
+
readonly playerId: string;
|
|
44
|
+
} | {
|
|
45
|
+
readonly success: false;
|
|
46
|
+
readonly error: "maxPlayersReached" | "alreadyInGame" | "gameNotFound" | "invalidStatus" | "invalidInput";
|
|
47
|
+
}>;
|
|
48
|
+
leaveGame(gameId: string, playerId: string): Promise<{
|
|
49
|
+
readonly success: true;
|
|
50
|
+
} | {
|
|
51
|
+
readonly success: false;
|
|
52
|
+
readonly error: "playerNotFound" | "gameNotFound" | "invalidInput";
|
|
53
|
+
}>;
|
|
54
|
+
playCard(gameId: string, playerId: string, cardId: string, isForOtherPlayerPile: boolean): Promise<{
|
|
55
|
+
readonly success: true;
|
|
56
|
+
readonly error?: never;
|
|
57
|
+
} | {
|
|
58
|
+
readonly success: false;
|
|
59
|
+
readonly error: "playerNotFound" | "gameNotFound" | "invalidStatus" | "canPlayAtNotReached" | "cardNotFound" | "cardNotPlayable" | "invalidInput";
|
|
60
|
+
}>;
|
|
61
|
+
reportNoPlayableCards(gameId: string, playerId: string): Promise<{
|
|
62
|
+
readonly success: true;
|
|
63
|
+
readonly error?: never;
|
|
64
|
+
} | {
|
|
65
|
+
readonly success: false;
|
|
66
|
+
readonly error: "playerNotFound" | "gameNotFound" | "invalidStatus" | "canPlayAtNotReached" | "alreadyReported" | "hasPlayableCard" | "canDraw" | "invalidInput";
|
|
67
|
+
}>;
|
|
68
|
+
sendChat(gameId: string, playerId: string, text: string): Promise<{
|
|
69
|
+
readonly success: true;
|
|
70
|
+
} | {
|
|
71
|
+
readonly success: false;
|
|
72
|
+
readonly error: "playerNotFound" | "gameNotFound" | "invalidInput";
|
|
73
|
+
}>;
|
|
74
|
+
startGame(gameId: string, playerId: string): Promise<{
|
|
75
|
+
readonly success: true;
|
|
76
|
+
} | {
|
|
77
|
+
readonly success: false;
|
|
78
|
+
readonly error: "playerNotFound" | "playerNotAdmin" | "minPlayersNotReached" | "gameNotFound" | "invalidStatus" | "invalidInput";
|
|
79
|
+
}>;
|
|
18
80
|
}
|
|
19
81
|
//#endregion
|
|
20
|
-
|
|
82
|
+
//#region src/client/index.d.ts
|
|
83
|
+
type CreateGameResult = Awaited<ReturnType<Client["createGame"]>>;
|
|
84
|
+
type DrawCardResult = Awaited<ReturnType<Client["drawCard"]>>;
|
|
85
|
+
type GetClientStateAndClearEventsResult = Awaited<ReturnType<Client["getClientStateAndClearEvents"]>>;
|
|
86
|
+
type GetEventsAndClearAcknowledgedResult = Awaited<ReturnType<Client["getEventsAndClearAcknowledged"]>>;
|
|
87
|
+
type GetJoinableGamesResult = Awaited<ReturnType<Client["getJoinableGames"]>>;
|
|
88
|
+
type JoinGameResult = Awaited<ReturnType<Client["joinGame"]>>;
|
|
89
|
+
type LeaveGameResult = Awaited<ReturnType<Client["leaveGame"]>>;
|
|
90
|
+
type PlayCardResult = Awaited<ReturnType<Client["playCard"]>>;
|
|
91
|
+
type ReportNoPlayableCards = Awaited<ReturnType<Client["reportNoPlayableCards"]>>;
|
|
92
|
+
type SendChatResult = Awaited<ReturnType<Client["sendChat"]>>;
|
|
93
|
+
type StartGameResult = Awaited<ReturnType<Client["startGame"]>>;
|
|
94
|
+
//#endregion
|
|
95
|
+
export { type Card, type ChatMessage, Client, type ClientState, CreateGameResult, DrawCardResult, type GameEvent, GetClientStateAndClearEventsResult, GetEventsAndClearAcknowledgedResult, GetJoinableGamesResult, JoinGameResult, LeaveGameResult, PlayCardResult, ReportNoPlayableCards, SendChatResult, StartGameResult };
|
|
21
96
|
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/client/Client.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/client/Client.ts","../../src/client/index.ts"],"mappings":";;cAYa;mBACM;EAEL,YAAA;EAIN,WAAW,sBAAmB;;;;;;;;EAc9B,SAAS,gBAAgB,mBAAgB;;;;;;;EAezC,6BAA6B,gBAAgB,mBAAgB;;oBAfpB;;;;;EAkCzC,8BACJ,gBACA,kBACA,4BAAyB;;8BAtBwC;;;;;EA0C7D,oBAAgB;;;;;;EAShB,SAAS,gBAAgB,sBAAmB;;;;;;;EAgB5C,UAAU,gBAAgB,mBAAgB;;;;;;EAe1C,SACJ,gBACA,kBACA,gBACA,gCAA6B;;;;;;;EAgBzB,sBAAsB,gBAAgB,mBAAgB;;;;;;;EAgBtD,SAAS,gBAAgB,kBAAkB,eAAY;;;;;;EAevD,UAAU,gBAAgB,mBAAgB;;;;;;;;;KClLtC,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"}
|