trucoshi 0.6.7 → 2.0.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.
@@ -43,7 +43,7 @@ export declare const CARDS: {
43
43
  "4b": number;
44
44
  "4c": number;
45
45
  };
46
- export declare const BURNT_CARD: "1e" | "1b" | "7e" | "7o" | "3e" | "3o" | "3b" | "3c" | "2e" | "2o" | "2b" | "2c" | "1o" | "1c" | "re" | "ro" | "rb" | "rc" | "ce" | "co" | "cb" | "cc" | "pe" | "po" | "pb" | "pc" | "7b" | "7c" | "6e" | "6o" | "6b" | "6c" | "5e" | "5o" | "5b" | "5c" | "4e" | "4o" | "4b" | "4c";
46
+ export declare const BURNT_CARD: "rb" | "1e" | "1b" | "7e" | "7o" | "3e" | "3o" | "3b" | "3c" | "2e" | "2o" | "2b" | "2c" | "1o" | "1c" | "re" | "ro" | "rc" | "ce" | "co" | "cb" | "cc" | "pe" | "po" | "pb" | "pc" | "7b" | "7c" | "6e" | "6o" | "6b" | "6c" | "5e" | "5o" | "5b" | "5c" | "4e" | "4o" | "4b" | "4c";
47
47
  export declare const CARDS_HUMAN_READABLE: {
48
48
  "1e": string;
49
49
  "1b": string;
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TEAM_SIZE_VALUES = exports.CARDS_HUMAN_READABLE = exports.BURNT_CARD = exports.CARDS = exports.PREVIOUS_HAND_ACK_TIMEOUT = exports.PLAYER_TURN_TIMEOUT = exports.PLAYER_ABANDON_TIMEOUT = void 0;
4
- exports.PLAYER_ABANDON_TIMEOUT = 1000 * 45;
5
- exports.PLAYER_TURN_TIMEOUT = 1000 * 30;
6
- exports.PREVIOUS_HAND_ACK_TIMEOUT = 1000 * 5;
7
- exports.CARDS = {
1
+ export const PLAYER_ABANDON_TIMEOUT = 1000 * 45;
2
+ export const PLAYER_TURN_TIMEOUT = 1000 * 30;
3
+ export const PREVIOUS_HAND_ACK_TIMEOUT = 1000 * 5;
4
+ export const CARDS = {
8
5
  "1e": 13,
9
6
  "1b": 12,
10
7
  "7e": 11,
@@ -46,8 +43,8 @@ exports.CARDS = {
46
43
  "4b": 0,
47
44
  "4c": 0,
48
45
  };
49
- exports.BURNT_CARD = "xx";
50
- exports.CARDS_HUMAN_READABLE = {
46
+ export const BURNT_CARD = "xx";
47
+ export const CARDS_HUMAN_READABLE = {
51
48
  "1e": "1🗡️",
52
49
  "1b": "1🌵",
53
50
  "7e": "7🗡️",
@@ -89,4 +86,4 @@ exports.CARDS_HUMAN_READABLE = {
89
86
  "4b": "4🌵",
90
87
  "4c": "4🍷",
91
88
  };
92
- exports.TEAM_SIZE_VALUES = [1, 2, 3];
89
+ export const TEAM_SIZE_VALUES = [1, 2, 3];
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MATCH_FINISHED_CLEANUP_TIMEOUT = exports.PLAYER_LOBBY_TIMEOUT = exports.PLAYER_TIMEOUT_GRACE = void 0;
4
- exports.PLAYER_TIMEOUT_GRACE = 500;
5
- exports.PLAYER_LOBBY_TIMEOUT = 1000 * 10;
6
- exports.MATCH_FINISHED_CLEANUP_TIMEOUT = 1000 * 60 * 2;
1
+ export const PLAYER_TIMEOUT_GRACE = 500;
2
+ export const PLAYER_LOBBY_TIMEOUT = 1000 * 10;
3
+ export const MATCH_FINISHED_CLEANUP_TIMEOUT = 1000 * 60 * 2;
package/dist/types.d.ts CHANGED
@@ -1,12 +1,9 @@
1
- import { IHand } from "./lib";
2
- import { CARDS, CARDS_HUMAN_READABLE } from "./lib/constants";
3
- export { CARDS, CARDS_HUMAN_READABLE };
4
- export declare enum EMatchState {
5
- UNREADY = "UNREADY",
6
- READY = "READY",
7
- STARTED = "STARTED",
8
- FINISHED = "FINISHED"
9
- }
1
+ import { User } from "lightning-accounts";
2
+ import { CARDS, IHand } from "./lib";
3
+ import { IUserData } from "./server";
4
+ import { EMatchState } from "@prisma/client";
5
+ export { CARDS, CARDS_HUMAN_READABLE, BURNT_CARD } from "./lib/constants";
6
+ export { EMatchState };
10
7
  export interface ILobbyOptions {
11
8
  maxPlayers: 2 | 4 | 6;
12
9
  faltaEnvido: 1 | 2;
@@ -15,6 +12,7 @@ export interface ILobbyOptions {
15
12
  handAckTime: number;
16
13
  turnTime: number;
17
14
  abandonTime: number;
15
+ satsPerPlayer: number;
18
16
  }
19
17
  export interface ISaidCommand {
20
18
  player: IPlayer | IPublicPlayer;
@@ -50,7 +48,7 @@ export interface IChatMessage {
50
48
  id: string;
51
49
  date: number;
52
50
  user: {
53
- id: string;
51
+ name: string;
54
52
  key: string;
55
53
  };
56
54
  system?: boolean;
@@ -110,56 +108,76 @@ export type ECommand = ESayCommand | EEnvidoCommand | EAnswerCommand | EEnvidoAn
110
108
  export type IHandCommands = {
111
109
  [key in ECommand]: (hand: IHand, player: IPlayer) => void;
112
110
  };
111
+ export type IEventCallback<T = {}> = (args: {
112
+ success: boolean;
113
+ } & T) => void;
113
114
  export declare enum EServerEvent {
114
115
  PONG = "PONG",
116
+ SET_SESSION = "SET_SESSION",
115
117
  PREVIOUS_HAND = "PREVIOUS_HAND",
116
118
  UPDATE_MATCH = "UPDATE_MATCH",
119
+ MATCH_DELETED = "MATCH_DELETED",
117
120
  WAITING_PLAY = "WAITING_PLAY",
121
+ KICK_PLAYER = "PLAYER_KICKED",
118
122
  UPDATE_ACTIVE_MATCHES = "UPDATE_ACTIVE_MATCHES",
119
123
  PLAYER_USED_CARD = "PLAYER_USED_CARD",
120
124
  PLAYER_SAID_COMMAND = "PLAYER_SAID_COMMAND",
121
125
  WAITING_POSSIBLE_SAY = "WAITING_POSSIBLE_SAY",
122
126
  UPDATE_CHAT = "UPDAET_CHAT"
123
127
  }
124
- export declare enum EClientEvent {
125
- PING = "PING",
126
- SAY = "SAY",
127
- LEAVE_MATCH = "LEAVE_MATCH",
128
- CREATE_MATCH = "CREATE_MATCH",
129
- LIST_MATCHES = "LIST_MATCHES",
130
- JOIN_MATCH = "JOIN_MATCH",
131
- START_MATCH = "START_MATCH",
132
- SET_PLAYER_READY = "SET_PLAYER_READY",
133
- SET_SESSION = "SET_SESSION",
134
- FETCH_MATCH = "FETCH_MATCH",
135
- CHAT = "CHAT"
136
- }
137
- export type IEventCallback<T = {}> = (args: {
138
- success: boolean;
139
- } & T) => void;
140
128
  export interface ServerToClientEvents {
141
129
  [EServerEvent.PONG]: (serverTime: number, clientTime: number) => void;
142
- [EServerEvent.WAITING_POSSIBLE_SAY]: (match: IPublicMatch, callback: (data: IWaitingSayData) => void) => void;
143
130
  [EServerEvent.PREVIOUS_HAND]: (value: IMatchPreviousHand, callback: () => void) => void;
144
131
  [EServerEvent.UPDATE_CHAT]: (room: IPublicChatRoom, message?: IChatMessage) => void;
145
132
  [EServerEvent.UPDATE_ACTIVE_MATCHES]: (activeMatches: IPublicMatchInfo[]) => void;
146
133
  [EServerEvent.UPDATE_MATCH]: (match: IPublicMatch, callback?: () => void) => void;
147
134
  [EServerEvent.PLAYER_USED_CARD]: (match: IPublicMatch, card: IPlayedCard) => void;
148
135
  [EServerEvent.PLAYER_SAID_COMMAND]: (match: IPublicMatch, command: ISaidCommand) => void;
136
+ [EServerEvent.KICK_PLAYER]: (match: IPublicMatch, session: string, reason?: string) => void;
137
+ [EServerEvent.MATCH_DELETED]: (matchSessionId: string) => void;
138
+ [EServerEvent.SET_SESSION]: (userData: IUserData, serverVersion: string, activeMatches: Array<IPublicMatchInfo>) => void;
139
+ [EServerEvent.WAITING_POSSIBLE_SAY]: (match: IPublicMatch, callback: (data: IWaitingSayData) => void) => void;
149
140
  [EServerEvent.WAITING_PLAY]: (match: IPublicMatch, callback: (data: IWaitingPlayData) => void) => void;
150
141
  }
142
+ export declare enum EClientEvent {
143
+ LOGIN = "LOGIN",
144
+ LOGOUT = "LOGOUT",
145
+ LEAVE_MATCH = "LEAVE_MATCH",
146
+ CREATE_MATCH = "CREATE_MATCH",
147
+ SET_MATCH_OPTIONS = "SET_MATCH_OPTIONS",
148
+ LIST_MATCHES = "LIST_MATCHES",
149
+ JOIN_MATCH = "JOIN_MATCH",
150
+ START_MATCH = "START_MATCH",
151
+ SET_PLAYER_READY = "SET_PLAYER_READY",
152
+ FETCH_MATCH = "FETCH_MATCH",
153
+ CHAT = "CHAT",
154
+ PING = "PING",
155
+ SAY = "SAY"
156
+ }
151
157
  export interface ClientToServerEvents {
158
+ [EClientEvent.LOGOUT]: (callback: IEventCallback<{}>) => void;
152
159
  [EClientEvent.PING]: (clientTime: number) => void;
153
160
  [EClientEvent.CHAT]: (matchId: string, msg: string, callback: () => void) => void;
154
- [EClientEvent.LEAVE_MATCH]: (matchId: string) => void;
161
+ [EClientEvent.LEAVE_MATCH]: (matchId: string, callback?: IEventCallback<{}>) => void;
155
162
  [EClientEvent.CREATE_MATCH]: (callback: IEventCallback<{
156
163
  match?: IPublicMatch;
157
164
  activeMatches?: IPublicMatchInfo[];
158
165
  }>) => void;
159
- [EClientEvent.START_MATCH]: (matchId: string, callback: IEventCallback<{
166
+ [EClientEvent.SET_MATCH_OPTIONS]: (identityJwt: string | null, matchSessionId: string, options: Partial<ILobbyOptions>, callback: IEventCallback<{
167
+ match?: IPublicMatch;
168
+ activeMatches?: IPublicMatchInfo[];
169
+ }>) => void;
170
+ [EClientEvent.SET_PLAYER_READY]: (matchSessionId: string, ready: boolean, callback: IEventCallback<{
171
+ match?: IPublicMatch;
172
+ }>) => void;
173
+ [EClientEvent.JOIN_MATCH]: (matchSessionId: string, teamIdx: 0 | 1 | undefined, callback: IEventCallback<{
174
+ match?: IPublicMatch;
175
+ activeMatches?: IPublicMatchInfo[];
176
+ }>) => void;
177
+ [EClientEvent.START_MATCH]: (identityJwt: string | null, matchId: string, callback: IEventCallback<{
160
178
  matchSessionId?: string;
161
179
  }>) => void;
162
- [EClientEvent.FETCH_MATCH]: (session: string | null, matchId: string, callback: IEventCallback<{
180
+ [EClientEvent.FETCH_MATCH]: (matchId: string, callback: IEventCallback<{
163
181
  match: IPublicMatch | null;
164
182
  }>) => void;
165
183
  [EClientEvent.LIST_MATCHES]: (filters: {
@@ -167,16 +185,7 @@ export interface ClientToServerEvents {
167
185
  }, callback: IEventCallback<{
168
186
  matches: Array<IPublicMatchInfo>;
169
187
  }>) => void;
170
- [EClientEvent.SET_PLAYER_READY]: (matchSessionId: string, ready: boolean, callback: IEventCallback<{
171
- match?: IPublicMatch;
172
- }>) => void;
173
- [EClientEvent.SET_SESSION]: (id: string | null, session: string | null, callback?: IEventCallback<{
174
- session?: string;
175
- serverVersion: string;
176
- activeMatches: Array<IPublicMatchInfo>;
177
- }>) => void;
178
- [EClientEvent.JOIN_MATCH]: (matchSessionId: string, teamIdx: 0 | 1 | undefined, callback: IEventCallback<{
179
- match?: IPublicMatch;
188
+ [EClientEvent.LOGIN]: (user: User, identityToken: string, callback: IEventCallback<{
180
189
  activeMatches?: IPublicMatchInfo[];
181
190
  }>) => void;
182
191
  }
@@ -202,7 +211,9 @@ export declare enum GAME_ERROR {
202
211
  TEAM_IS_FULL = "TEAM_IS_FULL",
203
212
  INVALID_ENVIDO_POINTS = "INVALID_ENVIDO_POINTS",
204
213
  ENVIDO_NOT_ACCEPTED = "ENVIDO_NOT_ACCEPTED",
205
- INVALID_COMAND = "INVALID_COMAND"
214
+ INVALID_COMAND = "INVALID_COMAND",
215
+ INSUFFICIENT_BALANCE = "INSUFFICIENT_BALANCE",
216
+ GAME_REQUIRES_ACCOUNT = "GAME_REQUIRES_ACCOUNT"
206
217
  }
207
218
  export interface EnvidoState {
208
219
  accept: number;
@@ -243,31 +254,37 @@ export interface IHandPoints {
243
254
  0: number;
244
255
  1: number;
245
256
  }
246
- export type IPublicPlayer = Pick<IPlayer, "id" | "key" | "disabled" | "abandoned" | "ready" | "hand" | "usedHand" | "prevHand" | "teamIdx" | "isTurn" | "turnExpiresAt" | "turnExtensionExpiresAt" | "isEnvidoTurn" | "isOwner"> & ({
257
+ export type IPublicPlayer = Pick<IPlayer, "name" | "key" | "disabled" | "abandoned" | "ready" | "hand" | "usedHand" | "prevHand" | "teamIdx" | "isTurn" | "turnExpiresAt" | "turnExtensionExpiresAt" | "isEnvidoTurn" | "isOwner"> & ({
247
258
  isMe?: true;
248
259
  commands: IPlayer["commands"];
249
260
  hasFlor: IPlayer["hasFlor"];
250
261
  envido: IPlayer["envido"];
262
+ payRequestId?: IPlayer["payRequestId"];
251
263
  } | {
252
264
  isMe?: false;
253
265
  commands?: undefined;
254
266
  hasFlor?: undefined;
255
267
  envido?: undefined;
268
+ payRequestId?: undefined;
256
269
  });
257
270
  export type IPublicTeam = Pick<ITeam, "points" | "id" | "name"> & {
258
271
  players: Array<IPublicPlayer>;
259
272
  };
260
273
  export interface IPlayer {
274
+ idx: number;
261
275
  teamIdx: number;
262
- id: string;
276
+ accountId: number | undefined;
277
+ matchPlayerId: number | undefined;
278
+ name: string;
263
279
  key: string;
264
280
  session: string;
281
+ payRequestId?: number;
265
282
  hand: Array<ICard>;
283
+ usedHand: Array<ICard>;
284
+ prevHand: Array<ICard>;
266
285
  envido: Array<number>;
267
286
  _commands: Set<ECommand>;
268
287
  get commands(): Array<ECommand>;
269
- usedHand: Array<ICard>;
270
- prevHand: Array<ICard>;
271
288
  isTurn: boolean;
272
289
  turnExpiresAt: number | null;
273
290
  turnExtensionExpiresAt: number | null;
@@ -279,6 +296,9 @@ export interface IPlayer {
279
296
  ready: boolean;
280
297
  resetCommands(): void;
281
298
  calculateEnvido(): Array<number>;
299
+ setIdx(idx: number): void;
300
+ setPayRequest(id?: number): void;
301
+ setMatchPlayerId(id?: number): void;
282
302
  setTurn(turn: boolean): void;
283
303
  setTurnExpiration(...args: [number, number | null] | [null, null]): void;
284
304
  setEnvidoTurn(turn: boolean): void;
@@ -310,3 +330,4 @@ export interface ITeamPoints {
310
330
  malas: number;
311
331
  winner: boolean;
312
332
  }
333
+ export type IPublicUser = Pick<User, "id" | "email" | "name" | "role">;
package/dist/types.js CHANGED
@@ -1,87 +1,82 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GAME_ERROR = exports.TMap = exports.EClientEvent = exports.EServerEvent = exports.EHandState = exports.EEnvidoCommand = exports.EEnvidoAnswerCommand = exports.EAnswerCommand = exports.ETrucoCommand = exports.EFlorCommand = exports.ESayCommand = exports.EChatSystem = exports.EMatchState = exports.CARDS_HUMAN_READABLE = exports.CARDS = void 0;
4
- const constants_1 = require("./lib/constants");
5
- Object.defineProperty(exports, "CARDS", { enumerable: true, get: function () { return constants_1.CARDS; } });
6
- Object.defineProperty(exports, "CARDS_HUMAN_READABLE", { enumerable: true, get: function () { return constants_1.CARDS_HUMAN_READABLE; } });
7
- var EMatchState;
8
- (function (EMatchState) {
9
- EMatchState["UNREADY"] = "UNREADY";
10
- EMatchState["READY"] = "READY";
11
- EMatchState["STARTED"] = "STARTED";
12
- EMatchState["FINISHED"] = "FINISHED";
13
- })(EMatchState = exports.EMatchState || (exports.EMatchState = {}));
14
- var EChatSystem;
1
+ import { EMatchState } from "@prisma/client";
2
+ export { CARDS, CARDS_HUMAN_READABLE, BURNT_CARD } from "./lib/constants";
3
+ export { EMatchState };
4
+ export var EChatSystem;
15
5
  (function (EChatSystem) {
16
6
  EChatSystem[EChatSystem["TEAM_0"] = 0] = "TEAM_0";
17
7
  EChatSystem[EChatSystem["TEAM_1"] = 1] = "TEAM_1";
18
8
  EChatSystem["SYSTEM"] = "SYSTEM";
19
- })(EChatSystem = exports.EChatSystem || (exports.EChatSystem = {}));
20
- var ESayCommand;
9
+ })(EChatSystem || (EChatSystem = {}));
10
+ export var ESayCommand;
21
11
  (function (ESayCommand) {
22
12
  ESayCommand["MAZO"] = "MAZO";
23
- })(ESayCommand = exports.ESayCommand || (exports.ESayCommand = {}));
24
- var EFlorCommand;
13
+ })(ESayCommand || (ESayCommand = {}));
14
+ export var EFlorCommand;
25
15
  (function (EFlorCommand) {
26
16
  EFlorCommand["FLOR"] = "FLOR";
27
17
  EFlorCommand["CONTRAFLOR"] = "CONTRAFLOR";
28
- })(EFlorCommand = exports.EFlorCommand || (exports.EFlorCommand = {}));
29
- var ETrucoCommand;
18
+ })(EFlorCommand || (EFlorCommand = {}));
19
+ export var ETrucoCommand;
30
20
  (function (ETrucoCommand) {
31
21
  ETrucoCommand["TRUCO"] = "TRUCO";
32
22
  ETrucoCommand["RE_TRUCO"] = "RE_TRUCO";
33
23
  ETrucoCommand["VALE_CUATRO"] = "VALE_CUATRO";
34
- })(ETrucoCommand = exports.ETrucoCommand || (exports.ETrucoCommand = {}));
35
- var EAnswerCommand;
24
+ })(ETrucoCommand || (ETrucoCommand = {}));
25
+ export var EAnswerCommand;
36
26
  (function (EAnswerCommand) {
37
27
  EAnswerCommand["QUIERO"] = "QUIERO";
38
28
  EAnswerCommand["NO_QUIERO"] = "NO_QUIERO";
39
- })(EAnswerCommand = exports.EAnswerCommand || (exports.EAnswerCommand = {}));
40
- var EEnvidoAnswerCommand;
29
+ })(EAnswerCommand || (EAnswerCommand = {}));
30
+ export var EEnvidoAnswerCommand;
41
31
  (function (EEnvidoAnswerCommand) {
42
32
  EEnvidoAnswerCommand["SON_BUENAS"] = "SON_BUENAS";
43
- })(EEnvidoAnswerCommand = exports.EEnvidoAnswerCommand || (exports.EEnvidoAnswerCommand = {}));
44
- var EEnvidoCommand;
33
+ })(EEnvidoAnswerCommand || (EEnvidoAnswerCommand = {}));
34
+ export var EEnvidoCommand;
45
35
  (function (EEnvidoCommand) {
46
36
  EEnvidoCommand["ENVIDO"] = "ENVIDO";
47
37
  EEnvidoCommand["REAL_ENVIDO"] = "REAL_ENVIDO";
48
38
  EEnvidoCommand["FALTA_ENVIDO"] = "FALTA_ENVIDO";
49
- })(EEnvidoCommand = exports.EEnvidoCommand || (exports.EEnvidoCommand = {}));
50
- var EHandState;
39
+ })(EEnvidoCommand || (EEnvidoCommand = {}));
40
+ export var EHandState;
51
41
  (function (EHandState) {
52
42
  EHandState["WAITING_PLAY"] = "WAITING_PLAY";
53
43
  EHandState["WAITING_FOR_TRUCO_ANSWER"] = "WAITING_FOR_TRUCO_ANSWER";
54
44
  EHandState["WAITING_ENVIDO_ANSWER"] = "WAITING_ENVIDO_ANSWER";
55
45
  EHandState["WAITING_ENVIDO_POINTS_ANSWER"] = "WAITING_ENVIDO_POINTS_ANSWER";
56
46
  EHandState["FINISHED"] = "FINISHED";
57
- })(EHandState = exports.EHandState || (exports.EHandState = {}));
58
- var EServerEvent;
47
+ })(EHandState || (EHandState = {}));
48
+ export var EServerEvent;
59
49
  (function (EServerEvent) {
60
50
  EServerEvent["PONG"] = "PONG";
51
+ EServerEvent["SET_SESSION"] = "SET_SESSION";
61
52
  EServerEvent["PREVIOUS_HAND"] = "PREVIOUS_HAND";
62
53
  EServerEvent["UPDATE_MATCH"] = "UPDATE_MATCH";
54
+ EServerEvent["MATCH_DELETED"] = "MATCH_DELETED";
63
55
  EServerEvent["WAITING_PLAY"] = "WAITING_PLAY";
56
+ EServerEvent["KICK_PLAYER"] = "PLAYER_KICKED";
64
57
  EServerEvent["UPDATE_ACTIVE_MATCHES"] = "UPDATE_ACTIVE_MATCHES";
65
58
  EServerEvent["PLAYER_USED_CARD"] = "PLAYER_USED_CARD";
66
59
  EServerEvent["PLAYER_SAID_COMMAND"] = "PLAYER_SAID_COMMAND";
67
60
  EServerEvent["WAITING_POSSIBLE_SAY"] = "WAITING_POSSIBLE_SAY";
68
61
  EServerEvent["UPDATE_CHAT"] = "UPDAET_CHAT";
69
- })(EServerEvent = exports.EServerEvent || (exports.EServerEvent = {}));
70
- var EClientEvent;
62
+ })(EServerEvent || (EServerEvent = {}));
63
+ export var EClientEvent;
71
64
  (function (EClientEvent) {
72
- EClientEvent["PING"] = "PING";
73
- EClientEvent["SAY"] = "SAY";
65
+ EClientEvent["LOGIN"] = "LOGIN";
66
+ EClientEvent["LOGOUT"] = "LOGOUT";
74
67
  EClientEvent["LEAVE_MATCH"] = "LEAVE_MATCH";
75
68
  EClientEvent["CREATE_MATCH"] = "CREATE_MATCH";
69
+ EClientEvent["SET_MATCH_OPTIONS"] = "SET_MATCH_OPTIONS";
76
70
  EClientEvent["LIST_MATCHES"] = "LIST_MATCHES";
77
71
  EClientEvent["JOIN_MATCH"] = "JOIN_MATCH";
78
72
  EClientEvent["START_MATCH"] = "START_MATCH";
79
73
  EClientEvent["SET_PLAYER_READY"] = "SET_PLAYER_READY";
80
- EClientEvent["SET_SESSION"] = "SET_SESSION";
81
74
  EClientEvent["FETCH_MATCH"] = "FETCH_MATCH";
82
75
  EClientEvent["CHAT"] = "CHAT";
83
- })(EClientEvent = exports.EClientEvent || (exports.EClientEvent = {}));
84
- class TMap extends Map {
76
+ EClientEvent["PING"] = "PING";
77
+ EClientEvent["SAY"] = "SAY";
78
+ })(EClientEvent || (EClientEvent = {}));
79
+ export class TMap extends Map {
85
80
  find(finder) {
86
81
  let result = undefined;
87
82
  for (let value of this.values()) {
@@ -103,8 +98,7 @@ class TMap extends Map {
103
98
  return result;
104
99
  }
105
100
  }
106
- exports.TMap = TMap;
107
- var GAME_ERROR;
101
+ export var GAME_ERROR;
108
102
  (function (GAME_ERROR) {
109
103
  GAME_ERROR["MATCH_ALREADY_STARTED"] = "MATCH_ALREADY_STARTED";
110
104
  GAME_ERROR["LOBBY_IS_FULL"] = "LOBBY_IS_FULL";
@@ -114,4 +108,6 @@ var GAME_ERROR;
114
108
  GAME_ERROR["INVALID_ENVIDO_POINTS"] = "INVALID_ENVIDO_POINTS";
115
109
  GAME_ERROR["ENVIDO_NOT_ACCEPTED"] = "ENVIDO_NOT_ACCEPTED";
116
110
  GAME_ERROR["INVALID_COMAND"] = "INVALID_COMAND";
117
- })(GAME_ERROR = exports.GAME_ERROR || (exports.GAME_ERROR = {}));
111
+ GAME_ERROR["INSUFFICIENT_BALANCE"] = "INSUFFICIENT_BALANCE";
112
+ GAME_ERROR["GAME_REQUIRES_ACCOUNT"] = "GAME_REQUIRES_ACCOUNT";
113
+ })(GAME_ERROR || (GAME_ERROR = {}));
package/package.json CHANGED
@@ -1,16 +1,29 @@
1
1
  {
2
2
  "name": "trucoshi",
3
- "version": "0.6.7",
3
+ "version": "2.0.1",
4
4
  "main": "dist/types.js",
5
5
  "license": "GPL-3.0",
6
+ "paths": {
7
+ "trucoshi": [
8
+ "./"
9
+ ]
10
+ },
6
11
  "scripts": {
7
12
  "start": "nodemon",
13
+ "start:e2e": "dotenv -e .env.e2e -- nodemon",
8
14
  "profiler": "yarn build && node --prof ./bin/trucoshi-server",
9
- "build": "yarn run rimraf ./dist && yarn run tsc --project .",
10
- "prepublishOnly": "yarn test && yarn build",
11
- "test": "NODE_DEBUG_LEVEL=error ts-mocha --exit ./test/**/*.ts",
15
+ "build": "yarn run rimraf ./build && yarn run tsc --project . && yarn build:dist",
16
+ "build:dist": "yarn run rimraf ./dist && yarn run tsc --project ./tsconfig.dist.json",
17
+ "prepublishOnly": "yarn test && yarn build:dist",
18
+ "test": "dotenv -e .env.e2e -- yarn db:e2e:push --force-reset && dotenv -e .env.e2e -- ts-mocha --exit ./test/**/*.ts -t 50000",
12
19
  "cli:autoplay": "yarn run ts-node src/cli/autoplay",
13
- "cli:play": "yarn run ts-node src/cli/play"
20
+ "cli:play": "yarn run ts-node src/cli/play",
21
+ "db:push": "prisma db push",
22
+ "db:studio": "prisma studio",
23
+ "db:migrate": "prisma migrate dev",
24
+ "db:e2e:push": "dotenv -e .env.e2e -- prisma db push",
25
+ "db:e2e:studio": "dotenv -e .env.e2e -- prisma studio",
26
+ "db:e2e:migrate": "dotenv -e .env.e2e -- prisma migrate dev"
14
27
  },
15
28
  "devDependencies": {
16
29
  "@types/chai": "^4.3.4",
@@ -20,11 +33,12 @@
20
33
  "chai": "^4.3.7",
21
34
  "mocha": "^10.2.0",
22
35
  "nodemon": "^2.0.20",
23
- "prisma": "^4.13.0",
36
+ "prisma": "^4.14.1",
24
37
  "socket.io-client": "^4.5.4",
25
38
  "ts-mocha": "^10.0.0"
26
39
  },
27
40
  "files": [
41
+ "node_modules/.prisma/client/*",
28
42
  "dist/lib/constants.js",
29
43
  "dist/lib/constants.d.ts",
30
44
  "dist/types.js",
@@ -33,9 +47,19 @@
33
47
  "dist/server/constants.d.ts"
34
48
  ],
35
49
  "dependencies": {
36
- "@prisma/client": "4.13.0",
50
+ "@prisma/client": "^4.14.1",
51
+ "@socket.io/redis-adapter": "^8.2.1",
52
+ "@types/jsonwebtoken": "^9.0.5",
37
53
  "@types/pino": "^7.0.5",
54
+ "@types/redis": "^4.0.11",
55
+ "axios": "^1.6.3",
56
+ "axios-cookiejar-support": "^5.0.0",
38
57
  "dotenv": "^16.0.3",
58
+ "dotenv-cli": "^7.3.0",
59
+ "form-data": "^4.0.0",
60
+ "jsonwebtoken": "^9.0.2",
61
+ "lightning-accounts": "2.0.1",
62
+ "path-scurry": "^1.9.2",
39
63
  "pino": "^8.11.0",
40
64
  "pino-pretty": "^10.0.0",
41
65
  "rimraf": "^4.1.1",