trucoshi 0.3.4 → 0.3.51
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/LICENSE +674 -674
- package/README.md +60 -60
- package/dist/index.d.ts +2 -2
- package/dist/index.js +18 -18
- package/dist/lib/classes/Deck.d.ts +17 -17
- package/dist/lib/classes/Deck.js +41 -41
- package/dist/lib/classes/Envido.d.ts +34 -34
- package/dist/lib/classes/Envido.js +168 -167
- package/dist/lib/classes/Flor.js +1 -1
- package/dist/lib/classes/GameLoop.d.ts +28 -26
- package/dist/lib/classes/GameLoop.js +115 -105
- package/dist/lib/classes/Hand.d.ts +43 -43
- package/dist/lib/classes/Hand.js +295 -295
- package/dist/lib/classes/Lobby.d.ts +27 -27
- package/dist/lib/classes/Lobby.js +113 -113
- package/dist/lib/classes/Match.d.ts +21 -21
- package/dist/lib/classes/Match.js +90 -88
- package/dist/lib/classes/Play.d.ts +22 -22
- package/dist/lib/classes/Play.js +44 -44
- package/dist/lib/classes/Player.d.ts +35 -35
- package/dist/lib/classes/Player.js +114 -126
- package/dist/lib/classes/Round.d.ts +17 -17
- package/dist/lib/classes/Round.js +33 -33
- package/dist/lib/classes/Table.d.ts +12 -12
- package/dist/lib/classes/Table.js +38 -38
- package/dist/lib/classes/Team.d.ts +20 -20
- package/dist/lib/classes/Team.js +59 -59
- package/dist/lib/classes/Truco.d.ts +30 -30
- package/dist/lib/classes/Truco.js +97 -97
- package/dist/lib/classes/index.d.ts +11 -11
- package/dist/lib/classes/index.js +27 -27
- package/dist/lib/constants.d.ts +43 -43
- package/dist/lib/constants.js +46 -46
- package/dist/lib/index.d.ts +2 -2
- package/dist/lib/index.js +18 -18
- package/dist/lib/types.d.ts +44 -44
- package/dist/lib/types.js +21 -21
- package/dist/lib/utils.d.ts +5 -5
- package/dist/lib/utils.js +58 -58
- package/dist/types.d.ts +195 -184
- package/dist/types.js +123 -121
- package/package.json +1 -1
package/dist/lib/types.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GAME_ERROR = exports.EHandState = void 0;
|
|
4
|
-
var EHandState;
|
|
5
|
-
(function (EHandState) {
|
|
6
|
-
EHandState["WAITING_PLAY"] = "WAITING_PLAY";
|
|
7
|
-
EHandState["WAITING_FOR_TRUCO_ANSWER"] = "WAITING_FOR_TRUCO_ANSWER";
|
|
8
|
-
EHandState["WAITING_ENVIDO_ANSWER"] = "WAITING_ENVIDO_ANSWER";
|
|
9
|
-
EHandState["FINISHED"] = "FINISHED";
|
|
10
|
-
})(EHandState = exports.EHandState || (exports.EHandState = {}));
|
|
11
|
-
var GAME_ERROR;
|
|
12
|
-
(function (GAME_ERROR) {
|
|
13
|
-
GAME_ERROR["MATCH_ALREADY_STARTED"] = "MATCH_ALREADY_STARTED";
|
|
14
|
-
GAME_ERROR["LOBBY_IS_FULL"] = "LOBBY_IS_FULL";
|
|
15
|
-
GAME_ERROR["UNEXPECTED_TEAM_SIZE"] = "UNEXPECTED_TEAM_SIZE";
|
|
16
|
-
GAME_ERROR["TEAM_NOT_READY"] = "TEAM_NOT_READY";
|
|
17
|
-
GAME_ERROR["TEAM_IS_FULL"] = "TEAM_IS_FULL";
|
|
18
|
-
GAME_ERROR["INVALID_ENVIDO_POINTS"] = "INVALID_ENVIDO_POINTS";
|
|
19
|
-
GAME_ERROR["ENVIDO_NOT_ACCEPTED"] = "ENVIDO_NOT_ACCEPTED";
|
|
20
|
-
GAME_ERROR["INVALID_COMAND"] = "INVALID_COMAND";
|
|
21
|
-
})(GAME_ERROR = exports.GAME_ERROR || (exports.GAME_ERROR = {}));
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GAME_ERROR = exports.EHandState = void 0;
|
|
4
|
+
var EHandState;
|
|
5
|
+
(function (EHandState) {
|
|
6
|
+
EHandState["WAITING_PLAY"] = "WAITING_PLAY";
|
|
7
|
+
EHandState["WAITING_FOR_TRUCO_ANSWER"] = "WAITING_FOR_TRUCO_ANSWER";
|
|
8
|
+
EHandState["WAITING_ENVIDO_ANSWER"] = "WAITING_ENVIDO_ANSWER";
|
|
9
|
+
EHandState["FINISHED"] = "FINISHED";
|
|
10
|
+
})(EHandState = exports.EHandState || (exports.EHandState = {}));
|
|
11
|
+
var GAME_ERROR;
|
|
12
|
+
(function (GAME_ERROR) {
|
|
13
|
+
GAME_ERROR["MATCH_ALREADY_STARTED"] = "MATCH_ALREADY_STARTED";
|
|
14
|
+
GAME_ERROR["LOBBY_IS_FULL"] = "LOBBY_IS_FULL";
|
|
15
|
+
GAME_ERROR["UNEXPECTED_TEAM_SIZE"] = "UNEXPECTED_TEAM_SIZE";
|
|
16
|
+
GAME_ERROR["TEAM_NOT_READY"] = "TEAM_NOT_READY";
|
|
17
|
+
GAME_ERROR["TEAM_IS_FULL"] = "TEAM_IS_FULL";
|
|
18
|
+
GAME_ERROR["INVALID_ENVIDO_POINTS"] = "INVALID_ENVIDO_POINTS";
|
|
19
|
+
GAME_ERROR["ENVIDO_NOT_ACCEPTED"] = "ENVIDO_NOT_ACCEPTED";
|
|
20
|
+
GAME_ERROR["INVALID_COMAND"] = "INVALID_COMAND";
|
|
21
|
+
})(GAME_ERROR = exports.GAME_ERROR || (exports.GAME_ERROR = {}));
|
package/dist/lib/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ICard, IRound } from "./classes";
|
|
2
|
-
export declare function getMaxNumberIndex<T = number>(array: Array<T>): number;
|
|
3
|
-
export declare function getCardValue(card: ICard): number;
|
|
4
|
-
export declare function shuffleArray<T = unknown>(array: Array<T>): T[];
|
|
5
|
-
export declare function checkHandWinner(rounds: Array<IRound>, forehandTeamIdx: 0 | 1): null | 0 | 1;
|
|
1
|
+
import { ICard, IRound } from "./classes";
|
|
2
|
+
export declare function getMaxNumberIndex<T = number>(array: Array<T>): number;
|
|
3
|
+
export declare function getCardValue(card: ICard): number;
|
|
4
|
+
export declare function shuffleArray<T = unknown>(array: Array<T>): T[];
|
|
5
|
+
export declare function checkHandWinner(rounds: Array<IRound>, forehandTeamIdx: 0 | 1): null | 0 | 1;
|
package/dist/lib/utils.js
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkHandWinner = exports.shuffleArray = exports.getCardValue = exports.getMaxNumberIndex = void 0;
|
|
4
|
-
const constants_1 = require("./constants");
|
|
5
|
-
function getMaxNumberIndex(array) {
|
|
6
|
-
return array.reduce((accumulator, current, index) => {
|
|
7
|
-
return current > array[accumulator] ? index : accumulator;
|
|
8
|
-
}, 0);
|
|
9
|
-
}
|
|
10
|
-
exports.getMaxNumberIndex = getMaxNumberIndex;
|
|
11
|
-
function getCardValue(card) {
|
|
12
|
-
return constants_1.CARDS[card] || -1;
|
|
13
|
-
}
|
|
14
|
-
exports.getCardValue = getCardValue;
|
|
15
|
-
function shuffleArray(array) {
|
|
16
|
-
let currentIndex = array.length, randomIndex;
|
|
17
|
-
while (currentIndex != 0) {
|
|
18
|
-
randomIndex = Math.floor(Math.random() * currentIndex);
|
|
19
|
-
currentIndex--;
|
|
20
|
-
[array[currentIndex], array[randomIndex]] = [array[randomIndex], array[currentIndex]];
|
|
21
|
-
}
|
|
22
|
-
return array;
|
|
23
|
-
}
|
|
24
|
-
exports.shuffleArray = shuffleArray;
|
|
25
|
-
function checkHandWinner(rounds, forehandTeamIdx) {
|
|
26
|
-
var _a, _b;
|
|
27
|
-
const roundsWon = {
|
|
28
|
-
0: 0,
|
|
29
|
-
1: 0,
|
|
30
|
-
ties: 0,
|
|
31
|
-
};
|
|
32
|
-
for (let i = 0; i < rounds.length; i++) {
|
|
33
|
-
const round = rounds[i];
|
|
34
|
-
if (round.tie) {
|
|
35
|
-
roundsWon[0] += 1;
|
|
36
|
-
roundsWon[1] += 1;
|
|
37
|
-
roundsWon.ties = roundsWon.ties + 1;
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
if (((_a = round.winner) === null || _a === void 0 ? void 0 : _a.teamIdx) === 0) {
|
|
41
|
-
roundsWon[0] += 1;
|
|
42
|
-
}
|
|
43
|
-
if (((_b = round.winner) === null || _b === void 0 ? void 0 : _b.teamIdx) === 1) {
|
|
44
|
-
roundsWon[1] += 1;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
if ((roundsWon[0] > 2 && roundsWon[1] > 2) || (rounds.length > 2 && roundsWon.ties > 0)) {
|
|
48
|
-
return forehandTeamIdx;
|
|
49
|
-
}
|
|
50
|
-
if (roundsWon[0] >= 2 && roundsWon[1] < 2) {
|
|
51
|
-
return 0;
|
|
52
|
-
}
|
|
53
|
-
if (roundsWon[1] >= 2 && roundsWon[0] < 2) {
|
|
54
|
-
return 1;
|
|
55
|
-
}
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
exports.checkHandWinner = checkHandWinner;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkHandWinner = exports.shuffleArray = exports.getCardValue = exports.getMaxNumberIndex = void 0;
|
|
4
|
+
const constants_1 = require("./constants");
|
|
5
|
+
function getMaxNumberIndex(array) {
|
|
6
|
+
return array.reduce((accumulator, current, index) => {
|
|
7
|
+
return current > array[accumulator] ? index : accumulator;
|
|
8
|
+
}, 0);
|
|
9
|
+
}
|
|
10
|
+
exports.getMaxNumberIndex = getMaxNumberIndex;
|
|
11
|
+
function getCardValue(card) {
|
|
12
|
+
return constants_1.CARDS[card] || -1;
|
|
13
|
+
}
|
|
14
|
+
exports.getCardValue = getCardValue;
|
|
15
|
+
function shuffleArray(array) {
|
|
16
|
+
let currentIndex = array.length, randomIndex;
|
|
17
|
+
while (currentIndex != 0) {
|
|
18
|
+
randomIndex = Math.floor(Math.random() * currentIndex);
|
|
19
|
+
currentIndex--;
|
|
20
|
+
[array[currentIndex], array[randomIndex]] = [array[randomIndex], array[currentIndex]];
|
|
21
|
+
}
|
|
22
|
+
return array;
|
|
23
|
+
}
|
|
24
|
+
exports.shuffleArray = shuffleArray;
|
|
25
|
+
function checkHandWinner(rounds, forehandTeamIdx) {
|
|
26
|
+
var _a, _b;
|
|
27
|
+
const roundsWon = {
|
|
28
|
+
0: 0,
|
|
29
|
+
1: 0,
|
|
30
|
+
ties: 0,
|
|
31
|
+
};
|
|
32
|
+
for (let i = 0; i < rounds.length; i++) {
|
|
33
|
+
const round = rounds[i];
|
|
34
|
+
if (round.tie) {
|
|
35
|
+
roundsWon[0] += 1;
|
|
36
|
+
roundsWon[1] += 1;
|
|
37
|
+
roundsWon.ties = roundsWon.ties + 1;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (((_a = round.winner) === null || _a === void 0 ? void 0 : _a.teamIdx) === 0) {
|
|
41
|
+
roundsWon[0] += 1;
|
|
42
|
+
}
|
|
43
|
+
if (((_b = round.winner) === null || _b === void 0 ? void 0 : _b.teamIdx) === 1) {
|
|
44
|
+
roundsWon[1] += 1;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if ((roundsWon[0] > 2 && roundsWon[1] > 2) || (rounds.length > 2 && roundsWon.ties > 0)) {
|
|
48
|
+
return forehandTeamIdx;
|
|
49
|
+
}
|
|
50
|
+
if (roundsWon[0] >= 2 && roundsWon[1] < 2) {
|
|
51
|
+
return 0;
|
|
52
|
+
}
|
|
53
|
+
if (roundsWon[1] >= 2 && roundsWon[0] < 2) {
|
|
54
|
+
return 1;
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
exports.checkHandWinner = checkHandWinner;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,184 +1,195 @@
|
|
|
1
|
-
import { ICard, IHandPoints, IPlayedCard, IPlayer, IPublicPlayer, IPublicTeam, ITeam } from "./lib";
|
|
2
|
-
export interface
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
export declare enum
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
export declare enum
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
export
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
export
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
};
|
|
107
|
-
export
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
[
|
|
142
|
-
[
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
[
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
[EClientEvent.
|
|
155
|
-
match?: IPublicMatch;
|
|
156
|
-
}>) => void;
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
1
|
+
import { ICard, IHandPoints, IPlayedCard, IPlayer, IPublicPlayer, IPublicTeam, ITeam } from "./lib";
|
|
2
|
+
export interface ISaidCommand {
|
|
3
|
+
player: IPlayer | IPublicPlayer;
|
|
4
|
+
command: ECommand | number;
|
|
5
|
+
}
|
|
6
|
+
export interface IMatchPreviousHand {
|
|
7
|
+
rounds: IPlayedCard[][];
|
|
8
|
+
points: IHandPoints;
|
|
9
|
+
matchSessionId: string;
|
|
10
|
+
}
|
|
11
|
+
export interface IPublicMatch {
|
|
12
|
+
state: EMatchTableState;
|
|
13
|
+
winner: ITeam | null;
|
|
14
|
+
matchSessionId: string;
|
|
15
|
+
teams: Array<IPublicTeam>;
|
|
16
|
+
players: Array<IPublicPlayer>;
|
|
17
|
+
me: IPublicPlayer | null;
|
|
18
|
+
isNewHand: boolean;
|
|
19
|
+
rounds: IPlayedCard[][];
|
|
20
|
+
}
|
|
21
|
+
export interface IPublicMatchInfo {
|
|
22
|
+
ownerId: string;
|
|
23
|
+
matchSessionId: string;
|
|
24
|
+
players: number;
|
|
25
|
+
maxPlayers: number;
|
|
26
|
+
state: EMatchTableState;
|
|
27
|
+
}
|
|
28
|
+
export type IPublicChatRoom = Pick<IChatRoom, "id" | "messages">;
|
|
29
|
+
export interface IChatMessage {
|
|
30
|
+
date: number;
|
|
31
|
+
user: {
|
|
32
|
+
id: string;
|
|
33
|
+
key: string;
|
|
34
|
+
};
|
|
35
|
+
system?: boolean;
|
|
36
|
+
command?: boolean;
|
|
37
|
+
card?: boolean;
|
|
38
|
+
content: string;
|
|
39
|
+
}
|
|
40
|
+
export interface IChatRoom {
|
|
41
|
+
id: string;
|
|
42
|
+
messages: Array<IChatMessage>;
|
|
43
|
+
send(user: IChatMessage["user"], message: string): void;
|
|
44
|
+
card(user: IChatMessage["user"], command: ICard): void;
|
|
45
|
+
command(team: 0 | 1, command: ECommand | number): void;
|
|
46
|
+
system(message: string): void;
|
|
47
|
+
emit(message?: IChatMessage): void;
|
|
48
|
+
}
|
|
49
|
+
export declare enum EChatSystem {
|
|
50
|
+
TEAM_0 = 0,
|
|
51
|
+
TEAM_1 = 1,
|
|
52
|
+
SYSTEM = "SYSTEM"
|
|
53
|
+
}
|
|
54
|
+
export declare enum EMatchTableState {
|
|
55
|
+
UNREADY = 0,
|
|
56
|
+
READY = 1,
|
|
57
|
+
STARTED = 2,
|
|
58
|
+
FINISHED = 3
|
|
59
|
+
}
|
|
60
|
+
export declare enum ESayCommand {
|
|
61
|
+
MAZO = "MAZO"
|
|
62
|
+
}
|
|
63
|
+
export declare enum EFlorCommand {
|
|
64
|
+
FLOR = "FLOR",
|
|
65
|
+
CONTRAFLOR = "CONTRAFLOR"
|
|
66
|
+
}
|
|
67
|
+
export declare enum ETrucoCommand {
|
|
68
|
+
TRUCO = "TRUCO",
|
|
69
|
+
RE_TRUCO = "RE_TRUCO",
|
|
70
|
+
VALE_CUATRO = "VALE_CUATRO"
|
|
71
|
+
}
|
|
72
|
+
export declare enum EAnswerCommand {
|
|
73
|
+
QUIERO = "QUIERO",
|
|
74
|
+
NO_QUIERO = "NO_QUIERO"
|
|
75
|
+
}
|
|
76
|
+
export declare enum EEnvidoAnswerCommand {
|
|
77
|
+
SON_BUENAS = "SON_BUENAS"
|
|
78
|
+
}
|
|
79
|
+
export declare enum EEnvidoCommand {
|
|
80
|
+
ENVIDO = "ENVIDO",
|
|
81
|
+
REAL_ENVIDO = "REAL_ENVIDO",
|
|
82
|
+
FALTA_ENVIDO = "FALTA_ENVIDO"
|
|
83
|
+
}
|
|
84
|
+
export declare enum EHandState {
|
|
85
|
+
WAITING_PLAY = "WAITING_PLAY",
|
|
86
|
+
WAITING_FOR_TRUCO_ANSWER = "WAITING_FOR_TRUCO_ANSWER",
|
|
87
|
+
WAITING_ENVIDO_ANSWER = "WAITING_ENVIDO_ANSWER",
|
|
88
|
+
WAITING_ENVIDO_POINTS_ANSWER = "WAITING_ENVIDO_POINTS_ANSWER",
|
|
89
|
+
FINISHED = "FINISHED"
|
|
90
|
+
}
|
|
91
|
+
export type ECommand = ESayCommand | EEnvidoCommand | EAnswerCommand | EEnvidoAnswerCommand | ETrucoCommand | EFlorCommand;
|
|
92
|
+
export declare enum GAME_ERROR {
|
|
93
|
+
MATCH_ALREADY_STARTED = "MATCH_ALREADY_STARTED",
|
|
94
|
+
LOBBY_IS_FULL = "LOBBY_IS_FULL",
|
|
95
|
+
UNEXPECTED_TEAM_SIZE = "UNEXPECTED_TEAM_SIZE",
|
|
96
|
+
TEAM_NOT_READY = "TEAM_NOT_READY",
|
|
97
|
+
TEAM_IS_FULL = "TEAM_IS_FULL"
|
|
98
|
+
}
|
|
99
|
+
export type IHandCommands = {
|
|
100
|
+
[key in ECommand]: (player: IPlayer) => void;
|
|
101
|
+
};
|
|
102
|
+
export type IEnvidoCalculatorResult = {
|
|
103
|
+
accept: number;
|
|
104
|
+
decline: number;
|
|
105
|
+
next: Array<ECommand>;
|
|
106
|
+
};
|
|
107
|
+
export type IEnvidoCalculatorArgs = {
|
|
108
|
+
teams: [ITeam, ITeam];
|
|
109
|
+
matchPoint: number;
|
|
110
|
+
};
|
|
111
|
+
export type IEnvidoCalculator = {
|
|
112
|
+
[key in EEnvidoCommand]: (args?: IEnvidoCalculatorArgs) => IEnvidoCalculatorResult;
|
|
113
|
+
};
|
|
114
|
+
export declare enum EServerEvent {
|
|
115
|
+
PONG = "PONG",
|
|
116
|
+
PREVIOUS_HAND = "PREVIOUS_HAND",
|
|
117
|
+
UPDATE_MATCH = "UPDATE_MATCH",
|
|
118
|
+
WAITING_PLAY = "WAITING_PLAY",
|
|
119
|
+
PLAYER_USED_CARD = "PLAYER_USED_CARD",
|
|
120
|
+
PLAYER_SAID_COMMAND = "PLAYER_SAID_COMMAND",
|
|
121
|
+
WAITING_POSSIBLE_SAY = "WAITING_POSSIBLE_SAY",
|
|
122
|
+
UPDATE_CHAT = "UPDAET_CHAT"
|
|
123
|
+
}
|
|
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
|
+
export interface ServerToClientEvents {
|
|
141
|
+
[EServerEvent.PONG]: (msg: string) => void;
|
|
142
|
+
[EServerEvent.WAITING_POSSIBLE_SAY]: (match: IPublicMatch, callback: (data: IWaitingSayData) => void) => void;
|
|
143
|
+
[EServerEvent.PREVIOUS_HAND]: (value: IMatchPreviousHand, callback: () => void) => void;
|
|
144
|
+
[EServerEvent.UPDATE_CHAT]: (room: IPublicChatRoom, message?: IChatMessage) => void;
|
|
145
|
+
[EServerEvent.UPDATE_MATCH]: (match: IPublicMatch) => void;
|
|
146
|
+
[EServerEvent.PLAYER_USED_CARD]: (match: IPublicMatch, card: IPlayedCard) => void;
|
|
147
|
+
[EServerEvent.PLAYER_SAID_COMMAND]: (match: IPublicMatch, command: ISaidCommand) => void;
|
|
148
|
+
[EServerEvent.WAITING_PLAY]: (match: IPublicMatch, callback: (data: IWaitingPlayData) => void) => void;
|
|
149
|
+
}
|
|
150
|
+
export interface ClientToServerEvents {
|
|
151
|
+
[EClientEvent.PING]: (msg: string) => void;
|
|
152
|
+
[EClientEvent.CHAT]: (matchId: string, msg: string, callback: () => void) => void;
|
|
153
|
+
[EClientEvent.LEAVE_MATCH]: (matchId: string) => void;
|
|
154
|
+
[EClientEvent.CREATE_MATCH]: (callback: IEventCallback<{
|
|
155
|
+
match?: IPublicMatch;
|
|
156
|
+
}>) => void;
|
|
157
|
+
[EClientEvent.START_MATCH]: (callback: IEventCallback<{
|
|
158
|
+
matchSessionId?: string;
|
|
159
|
+
}>) => void;
|
|
160
|
+
[EClientEvent.FETCH_MATCH]: (session: string | null, matchId: string, callback: IEventCallback) => void;
|
|
161
|
+
[EClientEvent.LIST_MATCHES]: (filters: {
|
|
162
|
+
state?: Array<EMatchTableState>;
|
|
163
|
+
}, callback: IEventCallback<{
|
|
164
|
+
matches: Array<IPublicMatchInfo>;
|
|
165
|
+
}>) => void;
|
|
166
|
+
[EClientEvent.SET_PLAYER_READY]: (matchSessionId: string, ready: boolean, callback: IEventCallback<{
|
|
167
|
+
match?: IPublicMatch;
|
|
168
|
+
}>) => void;
|
|
169
|
+
[EClientEvent.SET_SESSION]: (id: string | null, session: string | null, callback?: IEventCallback<{
|
|
170
|
+
session?: string;
|
|
171
|
+
activeMatches: Array<IPublicMatchInfo>;
|
|
172
|
+
}>) => void;
|
|
173
|
+
[EClientEvent.JOIN_MATCH]: (matchSessionId: string, teamIdx: 0 | 1 | undefined, callback: IEventCallback<{
|
|
174
|
+
match?: IPublicMatch;
|
|
175
|
+
}>) => void;
|
|
176
|
+
}
|
|
177
|
+
export declare enum ETrucoshiMatchState {
|
|
178
|
+
UNREADY = 0,
|
|
179
|
+
STARTED = 1,
|
|
180
|
+
FINISHED = 2
|
|
181
|
+
}
|
|
182
|
+
export type IWaitingPlayData = {
|
|
183
|
+
cardIdx: number;
|
|
184
|
+
card: ICard;
|
|
185
|
+
};
|
|
186
|
+
export type IWaitingPlayCallback = (data: IWaitingPlayData) => void | null;
|
|
187
|
+
export type IWaitingSayData = {
|
|
188
|
+
command: ECommand;
|
|
189
|
+
};
|
|
190
|
+
export type IWaitingSayCallback = (data: IWaitingSayData) => void | null;
|
|
191
|
+
export declare class TMap<K, V> extends Map<K, V> {
|
|
192
|
+
find(finder: (value: V) => boolean): V | void;
|
|
193
|
+
findAll(finder: (value: V) => boolean): V[];
|
|
194
|
+
getOrThrow(key?: K): NonNullable<V>;
|
|
195
|
+
}
|