trucoshi 8.3.3 → 8.5.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/events.d.ts CHANGED
@@ -15,6 +15,7 @@ export declare enum EServerEvent {
15
15
  WAITING_PLAY = "WAITING_PLAY",
16
16
  KICK_PLAYER = "PLAYER_KICKED",
17
17
  UPDATE_ACTIVE_MATCHES = "UPDATE_ACTIVE_MATCHES",
18
+ UPDATE_PUBLIC_MATCHES = "UPDATE_PUBLIC_MATCHES",
18
19
  WAITING_POSSIBLE_SAY = "WAITING_POSSIBLE_SAY",
19
20
  UPDATE_CHAT = "UPDAET_CHAT",
20
21
  UPDATE_STATS = "UPDATE_STATS"
@@ -25,6 +26,7 @@ export interface ServerToClientEvents {
25
26
  [EServerEvent.UPDATE_STATS]: (room: ITrucoshiStats) => void;
26
27
  [EServerEvent.NEW_MESSAGE]: (roomId: string, message?: IChatMessage) => void;
27
28
  [EServerEvent.UPDATE_ACTIVE_MATCHES]: (activeMatches: IPublicMatchInfo[]) => void;
29
+ [EServerEvent.UPDATE_PUBLIC_MATCHES]: (publicMatches: IPublicMatchInfo[]) => void;
28
30
  [EServerEvent.UPDATE_MATCH]: (match: IPublicMatch, callback?: () => void) => void;
29
31
  [EServerEvent.KICK_PLAYER]: (match: IPublicMatch, session: string, reason?: string) => void;
30
32
  [EServerEvent.MATCH_DELETED]: (matchSessionId: string) => void;
@@ -55,10 +57,12 @@ export declare enum EClientEvent {
55
57
  JOIN_ROOM = "JOIN_ROOM",
56
58
  LEAVE_ROOM = "LEAVE_ROOM"
57
59
  }
60
+ export type SayType = "mate" | "ceba_toma_mate";
58
61
  export interface ClientToServerEvents {
59
62
  [EClientEvent.LOGOUT]: (callback: IEventCallback<{}>) => void;
60
63
  [EClientEvent.PING]: (clientTime: number) => void;
61
- [EClientEvent.CHAT]: (matchId: string, msg: string, callback: () => void) => void;
64
+ [EClientEvent.CHAT]: (matchId: string, msg: string, callback?: IEventCallback<{}>) => void;
65
+ [EClientEvent.SAY]: (matchId: string, msg: SayType, callback?: IEventCallback<{}>) => void;
62
66
  [EClientEvent.LEAVE_MATCH]: (matchId: string, callback?: IEventCallback<{}>) => void;
63
67
  [EClientEvent.CREATE_MATCH]: (callback: IEventCallback<{
64
68
  match?: IPublicMatch;
package/dist/events.js CHANGED
@@ -9,6 +9,7 @@ export var EServerEvent;
9
9
  EServerEvent["WAITING_PLAY"] = "WAITING_PLAY";
10
10
  EServerEvent["KICK_PLAYER"] = "PLAYER_KICKED";
11
11
  EServerEvent["UPDATE_ACTIVE_MATCHES"] = "UPDATE_ACTIVE_MATCHES";
12
+ EServerEvent["UPDATE_PUBLIC_MATCHES"] = "UPDATE_PUBLIC_MATCHES";
12
13
  EServerEvent["WAITING_POSSIBLE_SAY"] = "WAITING_POSSIBLE_SAY";
13
14
  EServerEvent["UPDATE_CHAT"] = "UPDAET_CHAT";
14
15
  EServerEvent["UPDATE_STATS"] = "UPDATE_STATS";
@@ -1,5 +1,11 @@
1
+ /// <reference types="lodash" />
2
+ /// <reference types="lodash" />
1
3
  import { IHand } from "../truco";
2
4
  import { ICard } from "../types";
5
+ export declare const memoizeMinute: {
6
+ <T extends (...args: any) => any>(func: T, resolver?: ((...args: Parameters<T>) => any) | undefined): T & import("lodash").MemoizedFunction;
7
+ Cache: import("lodash").MapCacheConstructor;
8
+ };
3
9
  export declare function getMaxNumberIndex<T = number>(array: Array<T>): number;
4
10
  export declare function getMinNumberIndex<T = number>(array: Array<T>): number;
5
11
  export declare function getCardValue(card: ICard): number;
package/dist/lib/utils.js CHANGED
@@ -1,4 +1,12 @@
1
1
  import { CARDS } from "./constants";
2
+ import memoize from "lodash.memoize";
3
+ import partialRight from "lodash.partialright";
4
+ export const memoizeMinute = partialRight(memoize, function memoResolver(...args) {
5
+ const time = new Date().getMinutes();
6
+ args.push({ time });
7
+ const cacheKey = JSON.stringify(args);
8
+ return cacheKey;
9
+ });
2
10
  export function getMaxNumberIndex(array) {
3
11
  return array.reduce((accumulator, current, index) => {
4
12
  return current > array[accumulator] ? index : accumulator;
package/dist/types.d.ts CHANGED
@@ -112,6 +112,7 @@ export interface IChatMessage {
112
112
  teamIdx?: 0 | 1;
113
113
  };
114
114
  system?: boolean;
115
+ hidden?: boolean;
115
116
  command?: boolean;
116
117
  card?: boolean;
117
118
  content: string;
@@ -127,7 +128,8 @@ export interface IChatRoom {
127
128
  card(user: IChatMessage["user"], card: ICard, sound?: string | boolean): void;
128
129
  command(team: 0 | 1, command: ECommand | number, sound?: string | boolean): void;
129
130
  system(message: string, sound?: string | boolean): void;
130
- emit(message?: IChatMessage): void;
131
+ sound(sound: string, toTeamIdx?: "0" | "1", fromUser?: IChatMessage['user']): void;
132
+ emit(message?: IChatMessage, teamIdxs?: string): void;
131
133
  }
132
134
  export declare enum EChatSystem {
133
135
  TEAM_0 = 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trucoshi",
3
- "version": "8.3.3",
3
+ "version": "8.5.0",
4
4
  "description": "Lightning Truco Server",
5
5
  "main": "dist/types.js",
6
6
  "license": "GPL-3.0",
@@ -42,6 +42,10 @@
42
42
  "devDependencies": {
43
43
  "@types/chai": "^4.3.4",
44
44
  "@types/expect": "^24.3.0",
45
+ "@types/lodash.debounce": "^4.0.9",
46
+ "@types/lodash.memoize": "^4.1.9",
47
+ "@types/lodash.partialright": "^4.2.9",
48
+ "@types/lodash.throttle": "^4.1.9",
45
49
  "@types/mocha": "^10.0.1",
46
50
  "@types/node": "^18.11.18",
47
51
  "chai": "^4.3.7",
@@ -67,7 +71,6 @@
67
71
  "@prisma/client": "^4.14.1",
68
72
  "@socket.io/redis-adapter": "^8.2.1",
69
73
  "@types/jsonwebtoken": "^9.0.5",
70
- "@types/lodash.debounce": "^4.0.9",
71
74
  "@types/node-forge": "^1.3.11",
72
75
  "@types/pino": "^7.0.5",
73
76
  "@types/redis": "^4.0.11",
@@ -79,6 +82,9 @@
79
82
  "jsonwebtoken": "^9.0.2",
80
83
  "lightning-accounts": "4.3.1",
81
84
  "lodash.debounce": "^4.0.8",
85
+ "lodash.memoize": "^4.1.2",
86
+ "lodash.partialright": "^4.2.1",
87
+ "lodash.throttle": "^4.1.1",
82
88
  "node-forge": "^1.3.1",
83
89
  "path-scurry": "^1.9.2",
84
90
  "pino": "^9.3.2",