trucoshi 2.1.1 → 2.3.1

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/types.d.ts CHANGED
@@ -1,7 +1,18 @@
1
1
  import { User } from "lightning-accounts";
2
2
  import { CARDS, IHand } from "./lib";
3
3
  import { IUserData } from "./server";
4
+ import { SocketError } from "./server/classes/SocketError";
5
+ import { Match, MatchHand, MatchPlayer, UserStats } from "@prisma/client";
4
6
  export { CARDS, CARDS_HUMAN_READABLE, BURNT_CARD } from "./lib/constants";
7
+ export interface IMatchDetails extends Match {
8
+ players: Array<Pick<MatchPlayer, "id" | "accountId" | "teamIdx" | "name" | "idx">>;
9
+ hands: Array<MatchHand>;
10
+ }
11
+ export interface IAccountDetails {
12
+ stats: UserStats | null;
13
+ account: User | null;
14
+ matches: Array<Match>;
15
+ }
5
16
  export declare enum EMatchState {
6
17
  UNREADY = "UNREADY",
7
18
  READY = "READY",
@@ -114,6 +125,7 @@ export type IHandCommands = {
114
125
  };
115
126
  export type IEventCallback<T = {}> = (args: {
116
127
  success: boolean;
128
+ error?: SocketError;
117
129
  } & T) => void;
118
130
  export declare enum EServerEvent {
119
131
  PONG = "PONG",
@@ -148,6 +160,8 @@ export declare enum EClientEvent {
148
160
  LOGOUT = "LOGOUT",
149
161
  LEAVE_MATCH = "LEAVE_MATCH",
150
162
  CREATE_MATCH = "CREATE_MATCH",
163
+ FETCH_ACCOUNT_DETAILS = "FETCH_ACCOUNT_DETAILS",
164
+ FETCH_MATCH_DETAILS = "FETCH_MATCH_DETAILS",
151
165
  SET_MATCH_OPTIONS = "SET_MATCH_OPTIONS",
152
166
  LIST_MATCHES = "LIST_MATCHES",
153
167
  JOIN_MATCH = "JOIN_MATCH",
@@ -178,12 +192,16 @@ export interface ClientToServerEvents {
178
192
  match?: IPublicMatch;
179
193
  activeMatches?: IPublicMatchInfo[];
180
194
  }>) => void;
181
- [EClientEvent.START_MATCH]: (identityJwt: string | null, matchId: string, callback: IEventCallback<{
195
+ [EClientEvent.START_MATCH]: (identityJwt: string | null, matchSessionId: string, callback: IEventCallback<{
182
196
  matchSessionId?: string;
183
197
  }>) => void;
184
- [EClientEvent.FETCH_MATCH]: (matchId: string, callback: IEventCallback<{
198
+ [EClientEvent.FETCH_MATCH]: (matchSessionId: string, callback: IEventCallback<{
185
199
  match: IPublicMatch | null;
186
200
  }>) => void;
201
+ [EClientEvent.FETCH_MATCH_DETAILS]: (matchId: number, callback: IEventCallback<{
202
+ match: IMatchDetails | null;
203
+ }>) => void;
204
+ [EClientEvent.FETCH_ACCOUNT_DETAILS]: (accountId: number, callback: IEventCallback<IAccountDetails>) => void;
187
205
  [EClientEvent.LIST_MATCHES]: (filters: {
188
206
  state?: Array<EMatchState>;
189
207
  }, callback: IEventCallback<{
@@ -208,6 +226,9 @@ export declare class TMap<K, V> extends Map<K, V> {
208
226
  getOrThrow(key?: K): NonNullable<V>;
209
227
  }
210
228
  export declare enum GAME_ERROR {
229
+ UNEXPECTED_ERROR = "UNEXPECTED_ERROR",
230
+ FORBIDDEN = "FORBIDDEN",
231
+ NOT_FOUND = "NOT_FOUND",
211
232
  MATCH_ALREADY_STARTED = "MATCH_ALREADY_STARTED",
212
233
  LOBBY_IS_FULL = "LOBBY_IS_FULL",
213
234
  UNEXPECTED_TEAM_SIZE = "UNEXPECTED_TEAM_SIZE",
package/dist/types.js CHANGED
@@ -71,6 +71,8 @@ export var EClientEvent;
71
71
  EClientEvent["LOGOUT"] = "LOGOUT";
72
72
  EClientEvent["LEAVE_MATCH"] = "LEAVE_MATCH";
73
73
  EClientEvent["CREATE_MATCH"] = "CREATE_MATCH";
74
+ EClientEvent["FETCH_ACCOUNT_DETAILS"] = "FETCH_ACCOUNT_DETAILS";
75
+ EClientEvent["FETCH_MATCH_DETAILS"] = "FETCH_MATCH_DETAILS";
74
76
  EClientEvent["SET_MATCH_OPTIONS"] = "SET_MATCH_OPTIONS";
75
77
  EClientEvent["LIST_MATCHES"] = "LIST_MATCHES";
76
78
  EClientEvent["JOIN_MATCH"] = "JOIN_MATCH";
@@ -105,6 +107,9 @@ export class TMap extends Map {
105
107
  }
106
108
  export var GAME_ERROR;
107
109
  (function (GAME_ERROR) {
110
+ GAME_ERROR["UNEXPECTED_ERROR"] = "UNEXPECTED_ERROR";
111
+ GAME_ERROR["FORBIDDEN"] = "FORBIDDEN";
112
+ GAME_ERROR["NOT_FOUND"] = "NOT_FOUND";
108
113
  GAME_ERROR["MATCH_ALREADY_STARTED"] = "MATCH_ALREADY_STARTED";
109
114
  GAME_ERROR["LOBBY_IS_FULL"] = "LOBBY_IS_FULL";
110
115
  GAME_ERROR["UNEXPECTED_TEAM_SIZE"] = "UNEXPECTED_TEAM_SIZE";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trucoshi",
3
- "version": "2.1.1",
3
+ "version": "2.3.1",
4
4
  "description": "Lightning Truco Server",
5
5
  "main": "dist/types.js",
6
6
  "license": "GPL-3.0",
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "scripts": {
18
18
  "start": "nodemon",
19
- "start:e2e": "dotenv -e .env.e2e -- nodemon",
19
+ "start:e2e": "yarn build && dotenv -e .env.e2e -- node ./bin/trucoshi-server ",
20
20
  "profiler": "yarn build && node --prof ./bin/trucoshi-server",
21
21
  "build": "yarn run rimraf ./build && yarn run tsc --project . && yarn build:dist",
22
22
  "build:dist": "yarn run rimraf ./dist && yarn run tsc --project ./tsconfig.dist.json",
@@ -66,7 +66,7 @@
66
66
  "dotenv-cli": "^7.3.0",
67
67
  "form-data": "^4.0.0",
68
68
  "jsonwebtoken": "^9.0.2",
69
- "lightning-accounts": "2.0.1",
69
+ "lightning-accounts": "2.2.0",
70
70
  "path-scurry": "^1.9.2",
71
71
  "pino": "^8.11.0",
72
72
  "pino-pretty": "^10.0.0",