trucoshi 4.0.1 → 4.0.3

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.
@@ -0,0 +1,94 @@
1
+ import { EMatchState } from "@trucoshi/prisma";
2
+ import { SocketError } from "./server";
3
+ import { IAccountDetails, IChatMessage, ILobbyOptions, IMatchDetails, IMatchPreviousHand, IPlayedCard, IPublicChatRoom, IPublicMatch, IPublicMatchInfo, ISaidCommand, IUserData, IWaitingPlayData, IWaitingSayData } from "./types";
4
+ import { User } from "lightning-accounts";
5
+ export type IEventCallback<T = {}> = (args: {
6
+ success: boolean;
7
+ error?: SocketError;
8
+ } & T) => void;
9
+ export declare enum EServerEvent {
10
+ PONG = "PONG",
11
+ SET_SESSION = "SET_SESSION",
12
+ PREVIOUS_HAND = "PREVIOUS_HAND",
13
+ UPDATE_MATCH = "UPDATE_MATCH",
14
+ MATCH_DELETED = "MATCH_DELETED",
15
+ WAITING_PLAY = "WAITING_PLAY",
16
+ KICK_PLAYER = "PLAYER_KICKED",
17
+ UPDATE_ACTIVE_MATCHES = "UPDATE_ACTIVE_MATCHES",
18
+ PLAYER_USED_CARD = "PLAYER_USED_CARD",
19
+ PLAYER_SAID_COMMAND = "PLAYER_SAID_COMMAND",
20
+ WAITING_POSSIBLE_SAY = "WAITING_POSSIBLE_SAY",
21
+ UPDATE_CHAT = "UPDAET_CHAT"
22
+ }
23
+ export interface ServerToClientEvents {
24
+ [EServerEvent.PONG]: (serverTime: number, clientTime: number) => void;
25
+ [EServerEvent.PREVIOUS_HAND]: (value: IMatchPreviousHand, callback: () => void) => void;
26
+ [EServerEvent.UPDATE_CHAT]: (room: IPublicChatRoom, message?: IChatMessage) => void;
27
+ [EServerEvent.UPDATE_ACTIVE_MATCHES]: (activeMatches: IPublicMatchInfo[]) => void;
28
+ [EServerEvent.UPDATE_MATCH]: (match: IPublicMatch, callback?: () => void) => void;
29
+ [EServerEvent.PLAYER_USED_CARD]: (match: IPublicMatch, card: IPlayedCard) => void;
30
+ [EServerEvent.PLAYER_SAID_COMMAND]: (match: IPublicMatch, command: ISaidCommand) => void;
31
+ [EServerEvent.KICK_PLAYER]: (match: IPublicMatch, session: string, reason?: string) => void;
32
+ [EServerEvent.MATCH_DELETED]: (matchSessionId: string) => void;
33
+ [EServerEvent.SET_SESSION]: (userData: IUserData, serverVersion: string, activeMatches: Array<IPublicMatchInfo>) => void;
34
+ [EServerEvent.WAITING_POSSIBLE_SAY]: (match: IPublicMatch, callback: (data: IWaitingSayData) => void) => void;
35
+ [EServerEvent.WAITING_PLAY]: (match: IPublicMatch, callback: (data: IWaitingPlayData) => void) => void;
36
+ }
37
+ export declare enum EClientEvent {
38
+ LOGIN = "LOGIN",
39
+ LOGOUT = "LOGOUT",
40
+ LEAVE_MATCH = "LEAVE_MATCH",
41
+ CREATE_MATCH = "CREATE_MATCH",
42
+ FETCH_ACCOUNT_DETAILS = "FETCH_ACCOUNT_DETAILS",
43
+ FETCH_MATCH_DETAILS = "FETCH_MATCH_DETAILS",
44
+ SET_MATCH_OPTIONS = "SET_MATCH_OPTIONS",
45
+ LIST_MATCHES = "LIST_MATCHES",
46
+ JOIN_MATCH = "JOIN_MATCH",
47
+ START_MATCH = "START_MATCH",
48
+ SET_PLAYER_READY = "SET_PLAYER_READY",
49
+ FETCH_MATCH = "FETCH_MATCH",
50
+ KICK_PLAYER = "KICK_PLAYER",
51
+ CHAT = "CHAT",
52
+ PING = "PING",
53
+ SAY = "SAY"
54
+ }
55
+ export interface ClientToServerEvents {
56
+ [EClientEvent.LOGOUT]: (callback: IEventCallback<{}>) => void;
57
+ [EClientEvent.PING]: (clientTime: number) => void;
58
+ [EClientEvent.CHAT]: (matchId: string, msg: string, callback: () => void) => void;
59
+ [EClientEvent.LEAVE_MATCH]: (matchId: string, callback?: IEventCallback<{}>) => void;
60
+ [EClientEvent.CREATE_MATCH]: (callback: IEventCallback<{
61
+ match?: IPublicMatch;
62
+ activeMatches?: IPublicMatchInfo[];
63
+ }>) => void;
64
+ [EClientEvent.SET_MATCH_OPTIONS]: (identityJwt: string | null, matchSessionId: string, options: Partial<ILobbyOptions>, callback: IEventCallback<{
65
+ match?: IPublicMatch;
66
+ activeMatches?: IPublicMatchInfo[];
67
+ }>) => void;
68
+ [EClientEvent.SET_PLAYER_READY]: (matchSessionId: string, ready: boolean, callback: IEventCallback<{
69
+ match?: IPublicMatch;
70
+ }>) => void;
71
+ [EClientEvent.JOIN_MATCH]: (matchSessionId: string, teamIdx: 0 | 1 | undefined, callback: IEventCallback<{
72
+ match?: IPublicMatch;
73
+ activeMatches?: IPublicMatchInfo[];
74
+ }>) => void;
75
+ [EClientEvent.START_MATCH]: (identityJwt: string | null, matchSessionId: string, callback: IEventCallback<{
76
+ matchSessionId?: string;
77
+ }>) => void;
78
+ [EClientEvent.KICK_PLAYER]: (matchSessionId: string, key: string, callback: IEventCallback) => void;
79
+ [EClientEvent.FETCH_MATCH]: (matchSessionId: string, callback: IEventCallback<{
80
+ match: IPublicMatch | null;
81
+ }>) => void;
82
+ [EClientEvent.FETCH_MATCH_DETAILS]: (matchId: number, callback: IEventCallback<{
83
+ match: IMatchDetails | null;
84
+ }>) => void;
85
+ [EClientEvent.FETCH_ACCOUNT_DETAILS]: (accountId: number, callback: IEventCallback<IAccountDetails>) => void;
86
+ [EClientEvent.LIST_MATCHES]: (filters: {
87
+ state?: Array<EMatchState>;
88
+ }, callback: IEventCallback<{
89
+ matches: Array<IPublicMatchInfo>;
90
+ }>) => void;
91
+ [EClientEvent.LOGIN]: (user: User, identityToken: string, callback: IEventCallback<{
92
+ activeMatches?: IPublicMatchInfo[];
93
+ }>) => void;
94
+ }
package/dist/events.js ADDED
@@ -0,0 +1,34 @@
1
+ export var EServerEvent;
2
+ (function (EServerEvent) {
3
+ EServerEvent["PONG"] = "PONG";
4
+ EServerEvent["SET_SESSION"] = "SET_SESSION";
5
+ EServerEvent["PREVIOUS_HAND"] = "PREVIOUS_HAND";
6
+ EServerEvent["UPDATE_MATCH"] = "UPDATE_MATCH";
7
+ EServerEvent["MATCH_DELETED"] = "MATCH_DELETED";
8
+ EServerEvent["WAITING_PLAY"] = "WAITING_PLAY";
9
+ EServerEvent["KICK_PLAYER"] = "PLAYER_KICKED";
10
+ EServerEvent["UPDATE_ACTIVE_MATCHES"] = "UPDATE_ACTIVE_MATCHES";
11
+ EServerEvent["PLAYER_USED_CARD"] = "PLAYER_USED_CARD";
12
+ EServerEvent["PLAYER_SAID_COMMAND"] = "PLAYER_SAID_COMMAND";
13
+ EServerEvent["WAITING_POSSIBLE_SAY"] = "WAITING_POSSIBLE_SAY";
14
+ EServerEvent["UPDATE_CHAT"] = "UPDAET_CHAT";
15
+ })(EServerEvent || (EServerEvent = {}));
16
+ export var EClientEvent;
17
+ (function (EClientEvent) {
18
+ EClientEvent["LOGIN"] = "LOGIN";
19
+ EClientEvent["LOGOUT"] = "LOGOUT";
20
+ EClientEvent["LEAVE_MATCH"] = "LEAVE_MATCH";
21
+ EClientEvent["CREATE_MATCH"] = "CREATE_MATCH";
22
+ EClientEvent["FETCH_ACCOUNT_DETAILS"] = "FETCH_ACCOUNT_DETAILS";
23
+ EClientEvent["FETCH_MATCH_DETAILS"] = "FETCH_MATCH_DETAILS";
24
+ EClientEvent["SET_MATCH_OPTIONS"] = "SET_MATCH_OPTIONS";
25
+ EClientEvent["LIST_MATCHES"] = "LIST_MATCHES";
26
+ EClientEvent["JOIN_MATCH"] = "JOIN_MATCH";
27
+ EClientEvent["START_MATCH"] = "START_MATCH";
28
+ EClientEvent["SET_PLAYER_READY"] = "SET_PLAYER_READY";
29
+ EClientEvent["FETCH_MATCH"] = "FETCH_MATCH";
30
+ EClientEvent["KICK_PLAYER"] = "KICK_PLAYER";
31
+ EClientEvent["CHAT"] = "CHAT";
32
+ EClientEvent["PING"] = "PING";
33
+ EClientEvent["SAY"] = "SAY";
34
+ })(EClientEvent || (EClientEvent = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trucoshi",
3
- "version": "4.0.1",
3
+ "version": "4.0.3",
4
4
  "description": "Lightning Truco Server",
5
5
  "main": "dist/types.js",
6
6
  "license": "GPL-3.0",
@@ -53,6 +53,8 @@
53
53
  "dist/lib/constants.d.ts",
54
54
  "dist/types.js",
55
55
  "dist/types.d.ts",
56
+ "dist/events.js",
57
+ "dist/events.d.ts",
56
58
  "dist/server/constants.js",
57
59
  "dist/server/constants.d.ts",
58
60
  "prisma/client/index.js",