trucoshi 7.3.1 → 7.4.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/events.d.ts +1 -3
- package/dist/events.js +0 -1
- package/dist/lib/constants.js +1 -1
- package/dist/lib/utils.d.ts +2 -2
- package/dist/lib/utils.js +5 -1
- package/dist/types.d.ts +3 -1
- package/dist/types.js +1 -1
- package/package.json +1 -1
package/dist/events.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EMatchState } from "@trucoshi/prisma";
|
|
2
2
|
import { SocketError } from "./server";
|
|
3
|
-
import { IAccountDetails, IChatMessage, ILobbyOptions, IMatchDetails,
|
|
3
|
+
import { IAccountDetails, IChatMessage, ILobbyOptions, IMatchDetails, IPlayerRanking, IPublicChatRoom, IPublicMatch, IPublicMatchInfo, IUserData, IWaitingPlayData, IWaitingSayData } from "./types";
|
|
4
4
|
import { User } from "lightning-accounts";
|
|
5
5
|
export type IEventCallback<T = {}> = (args: {
|
|
6
6
|
success: boolean;
|
|
@@ -11,7 +11,6 @@ export declare enum EServerEvent {
|
|
|
11
11
|
NEW_MESSAGE = "NEW_MESSAGE",
|
|
12
12
|
SET_SESSION = "SET_SESSION",
|
|
13
13
|
REFRESH_IDENTITY = "REFRESH_IDENTITY",
|
|
14
|
-
PREVIOUS_HAND = "PREVIOUS_HAND",
|
|
15
14
|
UPDATE_MATCH = "UPDATE_MATCH",
|
|
16
15
|
MATCH_DELETED = "MATCH_DELETED",
|
|
17
16
|
WAITING_PLAY = "WAITING_PLAY",
|
|
@@ -22,7 +21,6 @@ export declare enum EServerEvent {
|
|
|
22
21
|
}
|
|
23
22
|
export interface ServerToClientEvents {
|
|
24
23
|
[EServerEvent.PONG]: (serverTime: number, clientTime: number) => void;
|
|
25
|
-
[EServerEvent.PREVIOUS_HAND]: (value: IMatchPreviousHand, callback: () => void) => void;
|
|
26
24
|
[EServerEvent.UPDATE_CHAT]: (room: IPublicChatRoom) => void;
|
|
27
25
|
[EServerEvent.NEW_MESSAGE]: (roomId: string, message?: IChatMessage) => void;
|
|
28
26
|
[EServerEvent.UPDATE_ACTIVE_MATCHES]: (activeMatches: IPublicMatchInfo[]) => void;
|
package/dist/events.js
CHANGED
|
@@ -4,7 +4,6 @@ export var EServerEvent;
|
|
|
4
4
|
EServerEvent["NEW_MESSAGE"] = "NEW_MESSAGE";
|
|
5
5
|
EServerEvent["SET_SESSION"] = "SET_SESSION";
|
|
6
6
|
EServerEvent["REFRESH_IDENTITY"] = "REFRESH_IDENTITY";
|
|
7
|
-
EServerEvent["PREVIOUS_HAND"] = "PREVIOUS_HAND";
|
|
8
7
|
EServerEvent["UPDATE_MATCH"] = "UPDATE_MATCH";
|
|
9
8
|
EServerEvent["MATCH_DELETED"] = "MATCH_DELETED";
|
|
10
9
|
EServerEvent["WAITING_PLAY"] = "WAITING_PLAY";
|
package/dist/lib/constants.js
CHANGED
package/dist/lib/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IHand } from "../truco";
|
|
2
2
|
import { ICard } from "../types";
|
|
3
3
|
export declare function getMaxNumberIndex<T = number>(array: Array<T>): number;
|
|
4
4
|
export declare function getMinNumberIndex<T = number>(array: Array<T>): number;
|
|
5
5
|
export declare function getCardValue(card: ICard): number;
|
|
6
|
-
export declare function checkHandWinner(
|
|
6
|
+
export declare function checkHandWinner(hand: IHand, forehandTeamIdx: 0 | 1): null | 0 | 1;
|
package/dist/lib/utils.js
CHANGED
|
@@ -12,13 +12,17 @@ export function getMinNumberIndex(array) {
|
|
|
12
12
|
export function getCardValue(card) {
|
|
13
13
|
return CARDS[card] !== undefined ? CARDS[card] : -2;
|
|
14
14
|
}
|
|
15
|
-
export function checkHandWinner(
|
|
15
|
+
export function checkHandWinner(hand, forehandTeamIdx) {
|
|
16
16
|
var _a, _b, _c, _d;
|
|
17
17
|
const roundsWon = {
|
|
18
18
|
0: 0,
|
|
19
19
|
1: 0,
|
|
20
20
|
ties: 0,
|
|
21
21
|
};
|
|
22
|
+
const rounds = hand.rounds;
|
|
23
|
+
if (hand.flor.winner && hand.flor.state === 5) {
|
|
24
|
+
return hand.flor.winner.id;
|
|
25
|
+
}
|
|
22
26
|
for (let i = 0; i < rounds.length; i++) {
|
|
23
27
|
const round = rounds[i];
|
|
24
28
|
if (round.tie) {
|
package/dist/types.d.ts
CHANGED
|
@@ -78,6 +78,7 @@ export interface IPublicMatch {
|
|
|
78
78
|
state: EMatchState;
|
|
79
79
|
handState: EHandState | null;
|
|
80
80
|
florBattle: IMatchFlorBattle | null;
|
|
81
|
+
previousHand: IMatchPreviousHand | null;
|
|
81
82
|
winner: ITeam | null;
|
|
82
83
|
matchSessionId: string;
|
|
83
84
|
forehandIdx: number;
|
|
@@ -163,7 +164,7 @@ export declare enum EHandState {
|
|
|
163
164
|
WAITING_ENVIDO_POINTS_ANSWER = "WAITING_ENVIDO_POINTS_ANSWER",
|
|
164
165
|
WAITING_FLOR_ANSWER = "WAITING_FLOR_ANSWER",
|
|
165
166
|
DISPLAY_FLOR_BATTLE = "DISPLAY_FLOR_BATTLE",
|
|
166
|
-
|
|
167
|
+
DISPLAY_PREVIOUS_HAND = "DISPLAY_PREVIOUS_HAND",
|
|
167
168
|
FINISHED = "FINISHED"
|
|
168
169
|
}
|
|
169
170
|
export type ECommand = ESayCommand | EEnvidoCommand | EAnswerCommand | EEnvidoAnswerCommand | ETrucoCommand | EFlorCommand;
|
|
@@ -340,6 +341,7 @@ export interface ITeam {
|
|
|
340
341
|
name: string;
|
|
341
342
|
players: Array<IPlayer>;
|
|
342
343
|
points: ITeamPoints;
|
|
344
|
+
get activePlayers(): IPlayer[];
|
|
343
345
|
setPlayers(players: IPlayer[]): ITeam;
|
|
344
346
|
pointsToWin(matchPoint: number): number;
|
|
345
347
|
getPublicTeam(playerSession?: string): IPublicTeam;
|
package/dist/types.js
CHANGED
|
@@ -53,7 +53,7 @@ export var EHandState;
|
|
|
53
53
|
EHandState["WAITING_ENVIDO_POINTS_ANSWER"] = "WAITING_ENVIDO_POINTS_ANSWER";
|
|
54
54
|
EHandState["WAITING_FLOR_ANSWER"] = "WAITING_FLOR_ANSWER";
|
|
55
55
|
EHandState["DISPLAY_FLOR_BATTLE"] = "DISPLAY_FLOR_BATTLE";
|
|
56
|
-
EHandState["
|
|
56
|
+
EHandState["DISPLAY_PREVIOUS_HAND"] = "DISPLAY_PREVIOUS_HAND";
|
|
57
57
|
EHandState["FINISHED"] = "FINISHED";
|
|
58
58
|
})(EHandState || (EHandState = {}));
|
|
59
59
|
export var GAME_ERROR;
|