trucoshi 0.1.8 → 0.2.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,4 +1,3 @@
1
- import { Socket } from "socket.io";
2
1
  import { ICard, IHandPoints, IPlayedCard, IPlayer, IPublicPlayer, IPublicTeam, ITeam } from "./lib";
3
2
  export interface IPublicMatch {
4
3
  state: EMatchTableState;
@@ -11,6 +10,12 @@ export interface IPublicMatch {
11
10
  prevRounds: IPlayedCard[][] | null;
12
11
  prevHandPoints?: IHandPoints | null;
13
12
  }
13
+ export interface IPublicMatchInfo {
14
+ matchSessionId: string;
15
+ players: number;
16
+ maxPlayers: number;
17
+ state: EMatchTableState;
18
+ }
14
19
  export declare enum EMatchTableState {
15
20
  UNREADY = 0,
16
21
  READY = 1,
@@ -69,21 +74,53 @@ export declare enum EClientEvent {
69
74
  PING = "PING",
70
75
  PLAY = "PLAY",
71
76
  CREATE_MATCH = "CREATE_MATCH",
72
- GET_MATCH = "GET_MATCH",
73
77
  LIST_MATCHES = "LIST_MATCHES",
74
78
  JOIN_MATCH = "JOIN_MATCH",
75
79
  START_MATCH = "START_MATCH",
76
80
  SET_PLAYER_READY = "SET_PLAYER_READY",
77
- SET_SESSION = "SET_SESSION"
81
+ SET_SESSION = "SET_SESSION",
82
+ FETCH_MATCH = "FETCH_MATCH"
83
+ }
84
+ export type IEventCallback<T = {}> = (args: {
85
+ success: boolean;
86
+ } & T) => void;
87
+ export interface ServerToClientEvents {
88
+ [EServerEvent.PONG]: (msg: string) => void;
89
+ [EServerEvent.UPDATE_MATCH]: (match: IPublicMatch) => void;
90
+ [EServerEvent.WAITING_PLAY]: (match: IPublicMatch, callback: (data: IWaitingPlayData) => void) => void;
91
+ }
92
+ export interface ClientToServerEvents {
93
+ [EClientEvent.PING]: (msg: string) => void;
94
+ [EClientEvent.CREATE_MATCH]: (callback: IEventCallback<{
95
+ match?: IPublicMatch;
96
+ }>) => void;
97
+ [EClientEvent.START_MATCH]: (callback: IEventCallback<{
98
+ matchSessionId?: string;
99
+ }>) => void;
100
+ [EClientEvent.FETCH_MATCH]: (session: string | null, matchId: string, callback: IEventCallback<{
101
+ match?: IPublicMatch | null;
102
+ }>) => void;
103
+ [EClientEvent.LIST_MATCHES]: (filters: {
104
+ state?: Array<EMatchTableState>;
105
+ }, callback: IEventCallback<{
106
+ matches: Array<IPublicMatchInfo>;
107
+ }>) => void;
108
+ [EClientEvent.SET_PLAYER_READY]: (matchSessionId: string, ready: boolean, callback: IEventCallback<{
109
+ match?: IPublicMatch;
110
+ }>) => void;
111
+ [EClientEvent.SET_SESSION]: (session: string | null, id: string | null, callback?: IEventCallback<{
112
+ session?: string;
113
+ activeMatches: Array<IPublicMatchInfo>;
114
+ }>) => void;
115
+ [EClientEvent.JOIN_MATCH]: (matchSessionId: string, teamIdx: 0 | 1 | undefined, callback: IEventCallback<{
116
+ match?: IPublicMatch;
117
+ }>) => void;
78
118
  }
79
119
  export declare enum EServerEvent {
80
120
  PONG = "PONG",
81
121
  UPDATE_MATCH = "UPDATE_MATCH",
82
122
  WAITING_PLAY = "WAITING_PLAY"
83
123
  }
84
- export interface TrucoshiSocket extends Socket {
85
- session?: string;
86
- }
87
124
  export declare enum ETrucoshiMatchState {
88
125
  UNREADY = 0,
89
126
  STARTED = 1,
package/dist/types.js CHANGED
@@ -44,12 +44,12 @@ var EClientEvent;
44
44
  EClientEvent["PING"] = "PING";
45
45
  EClientEvent["PLAY"] = "PLAY";
46
46
  EClientEvent["CREATE_MATCH"] = "CREATE_MATCH";
47
- EClientEvent["GET_MATCH"] = "GET_MATCH";
48
47
  EClientEvent["LIST_MATCHES"] = "LIST_MATCHES";
49
48
  EClientEvent["JOIN_MATCH"] = "JOIN_MATCH";
50
49
  EClientEvent["START_MATCH"] = "START_MATCH";
51
50
  EClientEvent["SET_PLAYER_READY"] = "SET_PLAYER_READY";
52
51
  EClientEvent["SET_SESSION"] = "SET_SESSION";
52
+ EClientEvent["FETCH_MATCH"] = "FETCH_MATCH";
53
53
  })(EClientEvent = exports.EClientEvent || (exports.EClientEvent = {}));
54
54
  var EServerEvent;
55
55
  (function (EServerEvent) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trucoshi",
3
- "version": "0.1.8",
3
+ "version": "0.2.1",
4
4
  "main": "dist/index.js",
5
5
  "license": "GPL-3.0",
6
6
  "scripts": {