trucoshi 0.0.16 → 0.0.18
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/lib/classes/Deck.d.ts +2 -1
- package/dist/lib/classes/Deck.js +12 -1
- package/dist/lib/classes/Hand.js +2 -2
- package/dist/lib/classes/Round.js +2 -1
- package/dist/lib/classes/Team.js +2 -2
- package/dist/lib/constants.d.ts +2 -1
- package/dist/lib/constants.js +3 -11
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.js +58 -17
- package/dist/lib/types.d.ts +8 -3
- package/dist/server/classes/MatchTable.d.ts +9 -5
- package/dist/server/classes/MatchTable.js +41 -16
- package/dist/server/classes/User.d.ts +2 -2
- package/dist/server/classes/User.js +2 -2
- package/dist/server/index.js +135 -111
- package/package.json +29 -28
package/dist/lib/classes/Deck.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Deck = void 0;
|
|
3
|
+
exports.PlayedCard = exports.Deck = void 0;
|
|
4
4
|
var constants_1 = require("../constants");
|
|
5
5
|
var utils_1 = require("../utils");
|
|
6
6
|
function Deck() {
|
|
@@ -25,3 +25,14 @@ function Deck() {
|
|
|
25
25
|
return deck;
|
|
26
26
|
}
|
|
27
27
|
exports.Deck = Deck;
|
|
28
|
+
function PlayedCard(player, card) {
|
|
29
|
+
var pc = {
|
|
30
|
+
player: player,
|
|
31
|
+
card: card,
|
|
32
|
+
get key() {
|
|
33
|
+
return card + player.session;
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
return pc;
|
|
37
|
+
}
|
|
38
|
+
exports.PlayedCard = PlayedCard;
|
package/dist/lib/classes/Hand.js
CHANGED
|
@@ -30,6 +30,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
30
30
|
exports.Hand = void 0;
|
|
31
31
|
var types_1 = require("../types");
|
|
32
32
|
var utils_1 = require("../utils");
|
|
33
|
+
var Deck_1 = require("./Deck");
|
|
33
34
|
var Play_1 = require("./Play");
|
|
34
35
|
var Round_1 = require("./Round");
|
|
35
36
|
var Truco_1 = require("./Truco");
|
|
@@ -72,7 +73,6 @@ function Hand(match, deck, idx) {
|
|
|
72
73
|
if (!(hand.state === types_1.EHandState.WAITING_FOR_TRUCO_ANSWER)) return [3 /*break*/, 6];
|
|
73
74
|
value = hand.truco.getNextPlayer().value;
|
|
74
75
|
if (!(value && value.currentPlayer)) return [3 /*break*/, 5];
|
|
75
|
-
console.log({ value: value.currentPlayer });
|
|
76
76
|
hand.setCurrentPlayer(value.currentPlayer);
|
|
77
77
|
return [4 /*yield*/, hand];
|
|
78
78
|
case 4:
|
|
@@ -181,7 +181,7 @@ function Hand(match, deck, idx) {
|
|
|
181
181
|
var card = player.useCard(idx);
|
|
182
182
|
if (card) {
|
|
183
183
|
hand.nextTurn();
|
|
184
|
-
return round.use(
|
|
184
|
+
return round.use((0, Deck_1.PlayedCard)(player, card));
|
|
185
185
|
}
|
|
186
186
|
return null;
|
|
187
187
|
},
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Round = void 0;
|
|
4
4
|
var utils_1 = require("../utils");
|
|
5
|
+
var Deck_1 = require("./Deck");
|
|
5
6
|
function Round(turn) {
|
|
6
7
|
var round = {
|
|
7
8
|
turn: turn,
|
|
@@ -24,7 +25,7 @@ function Round(turn) {
|
|
|
24
25
|
round.highest = value;
|
|
25
26
|
round.winner = player;
|
|
26
27
|
}
|
|
27
|
-
round.cards.push(
|
|
28
|
+
round.cards.push((0, Deck_1.PlayedCard)(player, card));
|
|
28
29
|
return card;
|
|
29
30
|
},
|
|
30
31
|
};
|
package/dist/lib/classes/Team.js
CHANGED
|
@@ -17,7 +17,7 @@ function Team(players) {
|
|
|
17
17
|
},
|
|
18
18
|
disable: function (player) {
|
|
19
19
|
var _a;
|
|
20
|
-
(_a = team._players.get(player.
|
|
20
|
+
(_a = team._players.get(player.session)) === null || _a === void 0 ? void 0 : _a.disable();
|
|
21
21
|
return team.isTeamDisabled();
|
|
22
22
|
},
|
|
23
23
|
addPoints: function (matchPoint, points) {
|
|
@@ -36,7 +36,7 @@ function Team(players) {
|
|
|
36
36
|
return team.points;
|
|
37
37
|
},
|
|
38
38
|
};
|
|
39
|
-
players.forEach(function (player) { return team._players.set(player.
|
|
39
|
+
players.forEach(function (player) { return team._players.set(player.session, player); });
|
|
40
40
|
return team;
|
|
41
41
|
}
|
|
42
42
|
exports.Team = Team;
|
package/dist/lib/constants.d.ts
CHANGED
|
@@ -41,9 +41,10 @@ export declare const CARDS: {
|
|
|
41
41
|
"4b": number;
|
|
42
42
|
"4c": number;
|
|
43
43
|
};
|
|
44
|
-
export declare const COLORS: string[];
|
|
45
44
|
export declare const TEAM_SIZE_VALUES: number[];
|
|
46
45
|
export declare enum GAME_ERROR {
|
|
46
|
+
MATCH_ALREADY_STARTED = "MATCH_ALREADY_STARTED",
|
|
47
|
+
LOBBY_IS_FULL = "LOBBY_IS_FULL",
|
|
47
48
|
UNEXPECTED_TEAM_SIZE = "UNEXPECTED_TEAM_SIZE",
|
|
48
49
|
TEAM_NOT_READY = "TEAM_NOT_READY",
|
|
49
50
|
TEAM_IS_FULL = "TEAM_IS_FULL"
|
package/dist/lib/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.EnvidoCalculator = exports.GAME_ERROR = exports.TEAM_SIZE_VALUES = exports.
|
|
4
|
+
exports.EnvidoCalculator = exports.GAME_ERROR = exports.TEAM_SIZE_VALUES = exports.CARDS = void 0;
|
|
5
5
|
var types_1 = require("./types");
|
|
6
6
|
var utils_1 = require("./utils");
|
|
7
7
|
exports.CARDS = {
|
|
@@ -46,19 +46,11 @@ exports.CARDS = {
|
|
|
46
46
|
"4b": 0,
|
|
47
47
|
"4c": 0,
|
|
48
48
|
};
|
|
49
|
-
exports.COLORS = [
|
|
50
|
-
"#9b111",
|
|
51
|
-
"#17c6c6",
|
|
52
|
-
"#8c1d1d",
|
|
53
|
-
"#9f9b9b",
|
|
54
|
-
"#a5a5a5",
|
|
55
|
-
"#f5a623",
|
|
56
|
-
"#f44336",
|
|
57
|
-
"#c2185b",
|
|
58
|
-
];
|
|
59
49
|
exports.TEAM_SIZE_VALUES = [1, 2, 3];
|
|
60
50
|
var GAME_ERROR;
|
|
61
51
|
(function (GAME_ERROR) {
|
|
52
|
+
GAME_ERROR["MATCH_ALREADY_STARTED"] = "MATCH_ALREADY_STARTED";
|
|
53
|
+
GAME_ERROR["LOBBY_IS_FULL"] = "LOBBY_IS_FULL";
|
|
62
54
|
GAME_ERROR["UNEXPECTED_TEAM_SIZE"] = "UNEXPECTED_TEAM_SIZE";
|
|
63
55
|
GAME_ERROR["TEAM_NOT_READY"] = "TEAM_NOT_READY";
|
|
64
56
|
GAME_ERROR["TEAM_IS_FULL"] = "TEAM_IS_FULL";
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export interface IGameLoop {
|
|
|
8
8
|
_onWinner: IWinnerCallback;
|
|
9
9
|
teams: Array<ITeam>;
|
|
10
10
|
hands: Array<IHand>;
|
|
11
|
+
winner: ITeam | null;
|
|
11
12
|
onTurn: (callback: ITurnCallback) => IGameLoop;
|
|
12
13
|
onWinner: (callback: IWinnerCallback) => IGameLoop;
|
|
13
14
|
onTruco: (callback: ITrucoCallback) => IGameLoop;
|
package/dist/lib/index.js
CHANGED
|
@@ -49,6 +49,7 @@ var GameLoop = function (match) {
|
|
|
49
49
|
_onTurn: function () { return Promise.resolve(); },
|
|
50
50
|
_onWinner: function () { return Promise.resolve(); },
|
|
51
51
|
teams: [],
|
|
52
|
+
winner: null,
|
|
52
53
|
hands: [],
|
|
53
54
|
onTruco: function (callback) {
|
|
54
55
|
gameloop._onTruco = callback;
|
|
@@ -89,7 +90,9 @@ var GameLoop = function (match) {
|
|
|
89
90
|
_a.sent();
|
|
90
91
|
return [3 /*break*/, 1];
|
|
91
92
|
case 5: return [3 /*break*/, 1];
|
|
92
|
-
case 6:
|
|
93
|
+
case 6:
|
|
94
|
+
gameloop.winner = match.winner;
|
|
95
|
+
return [4 /*yield*/, gameloop._onWinner(match.winner, match.teams)];
|
|
93
96
|
case 7:
|
|
94
97
|
_a.sent();
|
|
95
98
|
return [2 /*return*/];
|
|
@@ -103,66 +106,104 @@ var GameLoop = function (match) {
|
|
|
103
106
|
function Lobby(teamSize) {
|
|
104
107
|
var lobby = {
|
|
105
108
|
lastTeamIdx: 1,
|
|
106
|
-
_players:
|
|
109
|
+
_players: [],
|
|
107
110
|
get players() {
|
|
108
|
-
return
|
|
111
|
+
return lobby._players.filter(function (player) { return Boolean(player && player.id); });
|
|
109
112
|
},
|
|
110
113
|
teams: [],
|
|
111
114
|
table: null,
|
|
112
115
|
maxPlayers: teamSize ? teamSize * 2 : 6,
|
|
113
116
|
full: false,
|
|
114
117
|
ready: false,
|
|
118
|
+
started: false,
|
|
115
119
|
gameLoop: undefined,
|
|
116
120
|
calculateReady: function () {
|
|
117
|
-
|
|
121
|
+
var allPlayersReady = lobby.players.reduce(function (prev, curr) { return Boolean(prev && curr && curr.ready); }, true);
|
|
122
|
+
var teamsSameSize = lobby.players.filter(function (player) { return player.teamIdx === 0; }).length ===
|
|
123
|
+
lobby.players.filter(function (player) { return player.teamIdx === 1; }).length;
|
|
124
|
+
var allTeamsComplete = lobby.players.length % 2 === 0;
|
|
125
|
+
lobby.ready = allPlayersReady && allTeamsComplete && teamsSameSize;
|
|
118
126
|
return lobby.ready;
|
|
119
127
|
},
|
|
120
128
|
calculateFull: function () {
|
|
121
|
-
lobby.full = lobby.
|
|
129
|
+
lobby.full = lobby.players.length >= lobby.maxPlayers;
|
|
122
130
|
return lobby.full;
|
|
123
131
|
},
|
|
124
132
|
addPlayer: function (id, session, teamIdx) {
|
|
133
|
+
var exists = lobby.players.find(function (player) { return player.session === session; });
|
|
134
|
+
if (exists) {
|
|
135
|
+
if (exists.teamIdx === teamIdx) {
|
|
136
|
+
return exists;
|
|
137
|
+
}
|
|
138
|
+
console.log({ session: session, ex: exists.session });
|
|
139
|
+
lobby.removePlayer(exists.session);
|
|
140
|
+
}
|
|
141
|
+
if (lobby.started) {
|
|
142
|
+
throw new Error(constants_1.GAME_ERROR.MATCH_ALREADY_STARTED);
|
|
143
|
+
}
|
|
144
|
+
if (lobby.full) {
|
|
145
|
+
throw new Error(constants_1.GAME_ERROR.LOBBY_IS_FULL);
|
|
146
|
+
}
|
|
125
147
|
var maxSize = teamSize ? teamSize : 3;
|
|
126
|
-
if (lobby.full ||
|
|
148
|
+
if (lobby.full ||
|
|
149
|
+
lobby.players.filter(function (player) { return player.teamIdx === teamIdx; }).length > maxSize) {
|
|
127
150
|
throw new Error(constants_1.GAME_ERROR.TEAM_IS_FULL);
|
|
128
151
|
}
|
|
129
152
|
var player = (0, Player_1.Player)(id, teamIdx !== undefined ? teamIdx : Number(!lobby.lastTeamIdx));
|
|
130
153
|
player.setSession(session);
|
|
131
154
|
lobby.lastTeamIdx = Number(!lobby.lastTeamIdx);
|
|
132
|
-
lobby._players.
|
|
155
|
+
for (var i = 0; i < lobby._players.length; i++) {
|
|
156
|
+
if (!lobby._players[i].id) {
|
|
157
|
+
if (player.teamIdx === 0 && i % 2 === 0) {
|
|
158
|
+
lobby._players[i] = player;
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
if (player.teamIdx === 1 && i % 2 !== 0) {
|
|
162
|
+
lobby._players[i] = player;
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
133
167
|
lobby.calculateFull();
|
|
134
168
|
lobby.calculateReady();
|
|
135
169
|
return player;
|
|
136
170
|
},
|
|
137
|
-
removePlayer: function (
|
|
138
|
-
lobby._players.
|
|
139
|
-
|
|
140
|
-
|
|
171
|
+
removePlayer: function (session) {
|
|
172
|
+
var idx = lobby._players.findIndex(function (player) { return player && player.session === session; });
|
|
173
|
+
if (idx !== -1) {
|
|
174
|
+
lobby._players[idx] = {};
|
|
175
|
+
lobby.calculateFull();
|
|
176
|
+
lobby.calculateReady();
|
|
177
|
+
}
|
|
141
178
|
return lobby;
|
|
142
179
|
},
|
|
143
180
|
startMatch: function (matchPoint) {
|
|
144
181
|
if (matchPoint === void 0) { matchPoint = 9; }
|
|
145
182
|
lobby.calculateReady();
|
|
146
|
-
var
|
|
147
|
-
if (!constants_1.TEAM_SIZE_VALUES.includes(
|
|
183
|
+
var actualTeamSize = lobby.players.length / 2;
|
|
184
|
+
if (!constants_1.TEAM_SIZE_VALUES.includes(actualTeamSize)) {
|
|
148
185
|
throw new Error(constants_1.GAME_ERROR.UNEXPECTED_TEAM_SIZE);
|
|
149
186
|
}
|
|
150
187
|
if (!lobby.ready) {
|
|
151
188
|
throw new Error(constants_1.GAME_ERROR.TEAM_NOT_READY);
|
|
152
189
|
}
|
|
153
190
|
lobby.teams = [
|
|
154
|
-
(0, Team_1.Team)(lobby.players.filter(function (
|
|
155
|
-
(0, Team_1.Team)(lobby.players.filter(function (
|
|
191
|
+
(0, Team_1.Team)(lobby.players.filter(function (player) { return player.teamIdx === 0; })),
|
|
192
|
+
(0, Team_1.Team)(lobby.players.filter(function (player) { return player.teamIdx === 1; })),
|
|
156
193
|
];
|
|
157
|
-
if (lobby.teams[0].players.length !==
|
|
158
|
-
lobby.teams[1].players.length !==
|
|
194
|
+
if (lobby.teams[0].players.length !== actualTeamSize ||
|
|
195
|
+
lobby.teams[1].players.length !== actualTeamSize) {
|
|
159
196
|
throw new Error(constants_1.GAME_ERROR.UNEXPECTED_TEAM_SIZE);
|
|
160
197
|
}
|
|
161
198
|
lobby.table = (0, Table_1.Table)(lobby.players, lobby.teams);
|
|
162
199
|
lobby.gameLoop = GameLoop((0, Match_1.Match)(lobby.table, lobby.teams, matchPoint));
|
|
200
|
+
lobby.started = true;
|
|
163
201
|
return lobby.gameLoop;
|
|
164
202
|
},
|
|
165
203
|
};
|
|
204
|
+
for (var i = 0; i < lobby.maxPlayers; i++) {
|
|
205
|
+
lobby._players.push({});
|
|
206
|
+
}
|
|
166
207
|
return lobby;
|
|
167
208
|
}
|
|
168
209
|
exports.Lobby = Lobby;
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export interface IDeck {
|
|
|
9
9
|
shuffle(): IDeck;
|
|
10
10
|
}
|
|
11
11
|
export interface IPlayedCard {
|
|
12
|
+
get key(): string;
|
|
12
13
|
player: IPlayer & IPublicPlayer;
|
|
13
14
|
card: ICard;
|
|
14
15
|
}
|
|
@@ -150,20 +151,24 @@ export interface IHand {
|
|
|
150
151
|
export interface IPrivateLobby {
|
|
151
152
|
gameLoop?: IGameLoop;
|
|
152
153
|
lastTeamIdx: 0 | 1;
|
|
153
|
-
_players:
|
|
154
|
+
_players: Array<IPlayer | {
|
|
155
|
+
id?: undefined;
|
|
156
|
+
session?: undefined;
|
|
157
|
+
}>;
|
|
154
158
|
get players(): Array<IPlayer>;
|
|
155
159
|
teams: Array<ITeam>;
|
|
156
160
|
maxPlayers: number;
|
|
157
161
|
table: ITable | null;
|
|
158
|
-
ready: boolean;
|
|
159
162
|
full: boolean;
|
|
163
|
+
ready: boolean;
|
|
164
|
+
started: boolean;
|
|
160
165
|
addPlayer(id: string, session: string, teamIdx?: 0 | 1): IPlayer;
|
|
161
166
|
removePlayer(id: string): ILobby;
|
|
162
167
|
calculateReady(): boolean;
|
|
163
168
|
calculateFull(): boolean;
|
|
164
169
|
startMatch(matchPoint?: 9 | 12 | 15): IGameLoop;
|
|
165
170
|
}
|
|
166
|
-
export interface ILobby extends Pick<IPrivateLobby, "addPlayer" | "removePlayer" | "startMatch" | "ready" | "full" | "teams" | "players" | "gameLoop" | "table"> {
|
|
171
|
+
export interface ILobby extends Pick<IPrivateLobby, "addPlayer" | "removePlayer" | "startMatch" | "ready" | "full" | "started" | "teams" | "players" | "gameLoop" | "table" | "calculateReady"> {
|
|
167
172
|
}
|
|
168
173
|
export interface ITable {
|
|
169
174
|
forehandIdx: number;
|
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
import { IPublicPlayer } from "../../lib/classes/Player";
|
|
2
2
|
import { IPublicTeam } from "../../lib/classes/Team";
|
|
3
|
-
import { ILobby, IPlayedCard } from "../../lib/types";
|
|
3
|
+
import { ILobby, IPlayedCard, ITeam } from "../../lib/types";
|
|
4
4
|
export interface IPublicMatch {
|
|
5
|
+
winner: ITeam | null;
|
|
6
|
+
matchSessionId: string;
|
|
5
7
|
teams: Array<IPublicTeam>;
|
|
6
8
|
players: Array<IPublicPlayer>;
|
|
9
|
+
me: IPublicPlayer;
|
|
7
10
|
rounds: IPlayedCard[][];
|
|
11
|
+
prevRounds: IPlayedCard[][] | null;
|
|
8
12
|
state: EMatchTableState;
|
|
9
13
|
}
|
|
10
14
|
export interface IMatchTable {
|
|
11
15
|
matchSessionId: string;
|
|
12
16
|
currentPlayer: IPublicPlayer | null;
|
|
13
17
|
lobby: ILobby;
|
|
14
|
-
state: EMatchTableState;
|
|
15
|
-
setState(state: EMatchTableState): void;
|
|
18
|
+
state(): EMatchTableState;
|
|
16
19
|
setCurrentPlayer(player: IPublicPlayer): void;
|
|
17
20
|
isSessionPlaying(session: string): IPublicPlayer | null;
|
|
18
21
|
getPublicMatch(session?: string): IPublicMatch;
|
|
19
22
|
}
|
|
20
23
|
export declare enum EMatchTableState {
|
|
21
24
|
UNREADY = 0,
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
READY = 1,
|
|
26
|
+
STARTED = 2,
|
|
27
|
+
FINISHED = 3
|
|
24
28
|
}
|
|
25
29
|
export declare function MatchTable(matchSessionId: string, teamSize?: 1 | 2 | 3): IMatchTable;
|
|
@@ -16,41 +16,66 @@ var lib_1 = require("../../lib");
|
|
|
16
16
|
var EMatchTableState;
|
|
17
17
|
(function (EMatchTableState) {
|
|
18
18
|
EMatchTableState[EMatchTableState["UNREADY"] = 0] = "UNREADY";
|
|
19
|
-
EMatchTableState[EMatchTableState["
|
|
20
|
-
EMatchTableState[EMatchTableState["
|
|
19
|
+
EMatchTableState[EMatchTableState["READY"] = 1] = "READY";
|
|
20
|
+
EMatchTableState[EMatchTableState["STARTED"] = 2] = "STARTED";
|
|
21
|
+
EMatchTableState[EMatchTableState["FINISHED"] = 3] = "FINISHED";
|
|
21
22
|
})(EMatchTableState = exports.EMatchTableState || (exports.EMatchTableState = {}));
|
|
22
23
|
function MatchTable(matchSessionId, teamSize) {
|
|
23
24
|
var matchTable = {
|
|
24
25
|
matchSessionId: matchSessionId,
|
|
25
26
|
currentPlayer: null,
|
|
26
27
|
lobby: (0, lib_1.Lobby)(teamSize),
|
|
27
|
-
state:
|
|
28
|
-
|
|
29
|
-
matchTable.
|
|
28
|
+
state: function () {
|
|
29
|
+
var _a;
|
|
30
|
+
matchTable.lobby.calculateReady();
|
|
31
|
+
if ((_a = matchTable.lobby.gameLoop) === null || _a === void 0 ? void 0 : _a.winner) {
|
|
32
|
+
return EMatchTableState.FINISHED;
|
|
33
|
+
}
|
|
34
|
+
if (matchTable.lobby.started) {
|
|
35
|
+
return EMatchTableState.STARTED;
|
|
36
|
+
}
|
|
37
|
+
if (matchTable.lobby.ready) {
|
|
38
|
+
return EMatchTableState.READY;
|
|
39
|
+
}
|
|
40
|
+
return EMatchTableState.UNREADY;
|
|
30
41
|
},
|
|
31
42
|
setCurrentPlayer: function (player) {
|
|
32
43
|
matchTable.currentPlayer = player;
|
|
33
44
|
},
|
|
34
45
|
isSessionPlaying: function (session) {
|
|
35
46
|
var lobby = matchTable.lobby;
|
|
36
|
-
var search = lobby.players.find(function (player) { return player.session === session; });
|
|
47
|
+
var search = lobby.players.find(function (player) { return player && player.session === session; });
|
|
37
48
|
return search || null;
|
|
38
49
|
},
|
|
39
50
|
getPublicMatch: function (userSession) {
|
|
40
|
-
var _a, _b, _c;
|
|
51
|
+
var _a, _b, _c, _d, _e, _f;
|
|
41
52
|
var lobby = matchTable.lobby;
|
|
42
|
-
var
|
|
43
|
-
var
|
|
53
|
+
var winner = ((_a = lobby.gameLoop) === null || _a === void 0 ? void 0 : _a.winner) || null;
|
|
54
|
+
var lastHandIdx = (((_b = lobby.gameLoop) === null || _b === void 0 ? void 0 : _b.hands.length) || 1) - 1;
|
|
55
|
+
var rounds = (_d = (_c = lobby.gameLoop) === null || _c === void 0 ? void 0 : _c.hands[lastHandIdx]) === null || _d === void 0 ? void 0 : _d.rounds.map(function (round) { return round.cards; });
|
|
56
|
+
var prevHandIdx = lastHandIdx - 1;
|
|
57
|
+
var prevRounds = prevHandIdx !== -1
|
|
58
|
+
? (_f = (_e = lobby.gameLoop) === null || _e === void 0 ? void 0 : _e.hands[prevHandIdx]) === null || _f === void 0 ? void 0 : _f.rounds.map(function (round) { return round.cards; })
|
|
59
|
+
: null;
|
|
60
|
+
var players = lobby.players.filter(function (player) { return Boolean(player); });
|
|
61
|
+
var currentPlayerIdx = players.findIndex(function (player) { return player && player.session === userSession; });
|
|
62
|
+
var me = players[currentPlayerIdx];
|
|
63
|
+
var cut = players.slice(currentPlayerIdx, players.length);
|
|
64
|
+
var end = players.slice(0, currentPlayerIdx);
|
|
65
|
+
var publicPlayers = cut.concat(end).map(function (player) {
|
|
66
|
+
return (player === null || player === void 0 ? void 0 : player.session) === userSession
|
|
67
|
+
? player
|
|
68
|
+
: __assign(__assign({}, player), { session: undefined, hand: player === null || player === void 0 ? void 0 : player.hand.map(function () { return "xx"; }) });
|
|
69
|
+
});
|
|
44
70
|
return {
|
|
45
|
-
|
|
46
|
-
|
|
71
|
+
me: me,
|
|
72
|
+
winner: winner,
|
|
73
|
+
matchSessionId: matchTable.matchSessionId,
|
|
74
|
+
state: matchTable.state(),
|
|
47
75
|
teams: [],
|
|
48
|
-
players:
|
|
49
|
-
return player.session === userSession
|
|
50
|
-
? player
|
|
51
|
-
: __assign(__assign({}, player), { hand: player.hand.map(function () { return "xx"; }) });
|
|
52
|
-
}),
|
|
76
|
+
players: publicPlayers,
|
|
53
77
|
rounds: rounds || [[]],
|
|
78
|
+
prevRounds: prevRounds || null,
|
|
54
79
|
};
|
|
55
80
|
},
|
|
56
81
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.User = void 0;
|
|
4
|
-
function User(id
|
|
4
|
+
function User(id) {
|
|
5
5
|
var user = {
|
|
6
6
|
id: id,
|
|
7
|
-
|
|
7
|
+
matchSocketIds: new Map()
|
|
8
8
|
};
|
|
9
9
|
return user;
|
|
10
10
|
}
|
package/dist/server/index.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -42,11 +53,12 @@ var socket_io_1 = require("socket.io");
|
|
|
42
53
|
var MatchTable_1 = require("./classes/MatchTable");
|
|
43
54
|
var User_1 = require("./classes/User");
|
|
44
55
|
var types_1 = require("./types");
|
|
45
|
-
var PORT = 4001;
|
|
56
|
+
var PORT = process.env.NODE_PORT || 4001;
|
|
57
|
+
var ORIGIN = process.env.NODE_ORIGIN || "http://localhost:3000";
|
|
46
58
|
var httpServer = (0, http_1.createServer)();
|
|
47
59
|
var io = new socket_io_1.Server(httpServer, {
|
|
48
60
|
cors: {
|
|
49
|
-
origin:
|
|
61
|
+
origin: ORIGIN,
|
|
50
62
|
methods: ["GET", "POST"],
|
|
51
63
|
},
|
|
52
64
|
});
|
|
@@ -69,9 +81,10 @@ var getTable = function (matchSessionId) {
|
|
|
69
81
|
};
|
|
70
82
|
io.on("connection", function (_socket) {
|
|
71
83
|
var socket = _socket;
|
|
84
|
+
console.log("New socket", socket.id);
|
|
72
85
|
var getTableSockets = function (table, callback) {
|
|
73
86
|
return new Promise(function (resolve) { return __awaiter(void 0, void 0, void 0, function () {
|
|
74
|
-
var sockets, _i, sockets_1,
|
|
87
|
+
var sockets, _i, sockets_1, playerSocket;
|
|
75
88
|
return __generator(this, function (_a) {
|
|
76
89
|
switch (_a.label) {
|
|
77
90
|
case 0: return [4 /*yield*/, io.sockets.adapter.fetchSockets({
|
|
@@ -83,8 +96,8 @@ io.on("connection", function (_socket) {
|
|
|
83
96
|
_a.label = 2;
|
|
84
97
|
case 2:
|
|
85
98
|
if (!(_i < sockets_1.length)) return [3 /*break*/, 5];
|
|
86
|
-
|
|
87
|
-
return [4 /*yield*/, callback(
|
|
99
|
+
playerSocket = sockets_1[_i];
|
|
100
|
+
return [4 /*yield*/, callback(playerSocket)];
|
|
88
101
|
case 3:
|
|
89
102
|
_a.sent();
|
|
90
103
|
_a.label = 4;
|
|
@@ -98,14 +111,32 @@ io.on("connection", function (_socket) {
|
|
|
98
111
|
});
|
|
99
112
|
}); });
|
|
100
113
|
};
|
|
101
|
-
var emitMatchUpdate = function (table) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
114
|
+
var emitMatchUpdate = function (table) { return __awaiter(void 0, void 0, void 0, function () {
|
|
115
|
+
return __generator(this, function (_a) {
|
|
116
|
+
switch (_a.label) {
|
|
117
|
+
case 0: return [4 /*yield*/, getTableSockets(table, function (playerSocket) { return __awaiter(void 0, void 0, void 0, function () {
|
|
118
|
+
var tmp, save;
|
|
119
|
+
return __generator(this, function (_a) {
|
|
120
|
+
tmp = table.getPublicMatch(playerSocket.session);
|
|
121
|
+
save = function () { return playerSocket.emit(types_1.EServerEvent.UPDATE_MATCH, tmp); };
|
|
122
|
+
// if (tmp.prevRounds && tmp.rounds[0].length === 0) {
|
|
123
|
+
// playerSocket.emit(EServerEvent.UPDATE_MATCH, {
|
|
124
|
+
// ...tmp,
|
|
125
|
+
// rounds: tmp.prevRounds,
|
|
126
|
+
// })
|
|
127
|
+
// setTimeout(save, 4500)
|
|
128
|
+
// return
|
|
129
|
+
// }
|
|
130
|
+
save();
|
|
131
|
+
return [2 /*return*/];
|
|
132
|
+
});
|
|
133
|
+
}); })];
|
|
134
|
+
case 1:
|
|
135
|
+
_a.sent();
|
|
136
|
+
return [2 /*return*/];
|
|
106
137
|
}
|
|
107
138
|
});
|
|
108
|
-
};
|
|
139
|
+
}); };
|
|
109
140
|
socket.on(types_1.EClientEvent.PING, function (msg) {
|
|
110
141
|
socket.emit(types_1.EServerEvent.PONG, msg);
|
|
111
142
|
});
|
|
@@ -124,7 +155,9 @@ io.on("connection", function (_socket) {
|
|
|
124
155
|
});
|
|
125
156
|
}
|
|
126
157
|
var table = (0, MatchTable_1.MatchTable)(socket.session);
|
|
127
|
-
table.lobby.addPlayer(user.id, socket.session);
|
|
158
|
+
table.lobby.addPlayer(user.id, socket.session, 0);
|
|
159
|
+
socket.join(socket.session);
|
|
160
|
+
addSocketToUser(socket.session, socket.id, table);
|
|
128
161
|
tables.set(socket.session, table);
|
|
129
162
|
return callback({ success: true, match: table.getPublicMatch(user.id) });
|
|
130
163
|
}
|
|
@@ -135,59 +168,52 @@ io.on("connection", function (_socket) {
|
|
|
135
168
|
}
|
|
136
169
|
callback({ success: false, error: new Error("Can't create match without an ID") });
|
|
137
170
|
});
|
|
138
|
-
var sendWaitingForPlay = function (table,
|
|
171
|
+
var sendWaitingForPlay = function (table, play) { return __awaiter(void 0, void 0, void 0, function () {
|
|
139
172
|
return __generator(this, function (_a) {
|
|
140
173
|
switch (_a.label) {
|
|
141
|
-
case 0: return [4 /*yield*/, getTableSockets(table, function (playerSocket) {
|
|
142
|
-
return
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
var cardIdx = _a.cardIdx, command = _a.command;
|
|
155
|
-
if (cardIdx !== undefined) {
|
|
156
|
-
var playedCard = play.use(cardIdx);
|
|
157
|
-
if (playedCard) {
|
|
158
|
-
return resolve();
|
|
159
|
-
}
|
|
160
|
-
return console.error("ERROR", new Error("Couldnt play card"));
|
|
174
|
+
case 0: return [4 /*yield*/, getTableSockets(table, function (playerSocket) {
|
|
175
|
+
return new Promise(function (resolve) {
|
|
176
|
+
var _a;
|
|
177
|
+
if (playerSocket.session && playerSocket.session === ((_a = play.player) === null || _a === void 0 ? void 0 : _a.session)) {
|
|
178
|
+
playerSocket.emit(types_1.EServerEvent.WAITING_PLAY, table.getPublicMatch(playerSocket.session), function (data) {
|
|
179
|
+
if (!data) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
var cardIdx = data.cardIdx, command = data.command;
|
|
183
|
+
if (cardIdx !== undefined) {
|
|
184
|
+
var playedCard = play.use(cardIdx);
|
|
185
|
+
if (playedCard) {
|
|
186
|
+
return resolve();
|
|
161
187
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
return
|
|
188
|
+
return console.error("ERROR", new Error("Couldnt play card"));
|
|
189
|
+
}
|
|
190
|
+
if (command) {
|
|
191
|
+
var saidCommand = play.say(command);
|
|
192
|
+
if (saidCommand) {
|
|
193
|
+
return resolve();
|
|
168
194
|
}
|
|
169
|
-
return console.error("ERROR", new Error("
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
195
|
+
return console.error("ERROR", new Error("Couldnt say command"));
|
|
196
|
+
}
|
|
197
|
+
return console.error("ERROR", new Error("Play callback didn't have data"));
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
resolve();
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
})];
|
|
205
|
+
case 1:
|
|
178
206
|
_a.sent();
|
|
179
207
|
return [2 /*return*/];
|
|
180
208
|
}
|
|
181
209
|
});
|
|
182
210
|
}); };
|
|
183
|
-
var startMatch = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
184
|
-
var
|
|
211
|
+
var startMatch = function (tableId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
212
|
+
var table_1;
|
|
185
213
|
return __generator(this, function (_a) {
|
|
186
214
|
try {
|
|
187
|
-
|
|
188
|
-
table_1 = getTable(tableId_1);
|
|
215
|
+
table_1 = getTable(tableId);
|
|
189
216
|
if (table_1 && !table_1.lobby.gameLoop) {
|
|
190
|
-
table_1.setState(MatchTable_1.EMatchTableState.STARTED);
|
|
191
217
|
table_1.lobby
|
|
192
218
|
.startMatch()
|
|
193
219
|
.onTurn(function (play) {
|
|
@@ -198,28 +224,30 @@ io.on("connection", function (_socket) {
|
|
|
198
224
|
switch (_b.label) {
|
|
199
225
|
case 0:
|
|
200
226
|
table_1.setCurrentPlayer(play.player);
|
|
201
|
-
turns.set(
|
|
227
|
+
turns.set(table_1.matchSessionId, { play: play, resolve: resolve });
|
|
202
228
|
_b.label = 1;
|
|
203
229
|
case 1:
|
|
204
|
-
_b.trys.push([1,
|
|
230
|
+
_b.trys.push([1, 4, , 5]);
|
|
205
231
|
session = (_a = play.player) === null || _a === void 0 ? void 0 : _a.session;
|
|
206
|
-
if (!session) {
|
|
232
|
+
if (!session || !play) {
|
|
207
233
|
throw new Error("Unexpected Error");
|
|
208
234
|
}
|
|
209
235
|
user = users.get(session);
|
|
210
236
|
if (!user) {
|
|
211
237
|
throw new Error("Unexpected Error");
|
|
212
238
|
}
|
|
213
|
-
return [4 /*yield*/,
|
|
239
|
+
return [4 /*yield*/, emitMatchUpdate(table_1)];
|
|
214
240
|
case 2:
|
|
215
241
|
_b.sent();
|
|
216
|
-
|
|
217
|
-
return [3 /*break*/, 4];
|
|
242
|
+
return [4 /*yield*/, sendWaitingForPlay(table_1, play)];
|
|
218
243
|
case 3:
|
|
244
|
+
_b.sent();
|
|
245
|
+
return [2 /*return*/, resolve()];
|
|
246
|
+
case 4:
|
|
219
247
|
e_1 = _b.sent();
|
|
220
248
|
console.error("ERROR", e_1);
|
|
221
|
-
return [3 /*break*/,
|
|
222
|
-
case
|
|
249
|
+
return [3 /*break*/, 5];
|
|
250
|
+
case 5: return [2 /*return*/];
|
|
223
251
|
}
|
|
224
252
|
});
|
|
225
253
|
}); });
|
|
@@ -246,20 +274,36 @@ io.on("connection", function (_socket) {
|
|
|
246
274
|
*/
|
|
247
275
|
socket.on(types_1.EClientEvent.START_MATCH, function () {
|
|
248
276
|
if (socket.session && users.has(socket.session)) {
|
|
249
|
-
startMatch();
|
|
277
|
+
startMatch(socket.session);
|
|
250
278
|
}
|
|
251
279
|
});
|
|
280
|
+
var addSocketToUser = function (session, socketId, table) {
|
|
281
|
+
var user = getUser(session);
|
|
282
|
+
console.log("User got new match socket", { socketId: socketId, session: session, matchId: table.matchSessionId });
|
|
283
|
+
var currentMatchSockets = user.matchSocketIds.has(table.matchSessionId)
|
|
284
|
+
? user.matchSocketIds.get(table.matchSessionId)
|
|
285
|
+
: new Set();
|
|
286
|
+
users.set(session, __assign(__assign({}, user), { matchSocketIds: user.matchSocketIds.set(table.matchSessionId, currentMatchSockets.add(socketId)) }));
|
|
287
|
+
};
|
|
252
288
|
/**
|
|
253
289
|
* Join Match
|
|
254
290
|
*/
|
|
255
|
-
socket.on(types_1.EClientEvent.JOIN_MATCH, function (matchSessionId, callback) {
|
|
291
|
+
socket.on(types_1.EClientEvent.JOIN_MATCH, function (matchSessionId, teamIdx, callback) {
|
|
256
292
|
if (!socket.session) {
|
|
257
293
|
return callback({ success: false });
|
|
258
294
|
}
|
|
259
295
|
var user = getUser(socket.session);
|
|
260
296
|
var table = tables.get(matchSessionId);
|
|
261
|
-
if (table
|
|
262
|
-
|
|
297
|
+
if (table) {
|
|
298
|
+
try {
|
|
299
|
+
table.lobby.addPlayer(user.id || "satoshi", socket.session, teamIdx);
|
|
300
|
+
}
|
|
301
|
+
catch (e) {
|
|
302
|
+
console.error(e);
|
|
303
|
+
return callback({ success: false });
|
|
304
|
+
}
|
|
305
|
+
socket.join(matchSessionId);
|
|
306
|
+
addSocketToUser(socket.session, socket.id, table);
|
|
263
307
|
emitMatchUpdate(table);
|
|
264
308
|
return callback({ success: true, match: table.getPublicMatch(socket.session) });
|
|
265
309
|
}
|
|
@@ -278,58 +322,41 @@ io.on("connection", function (_socket) {
|
|
|
278
322
|
/**
|
|
279
323
|
* Set Session
|
|
280
324
|
*/
|
|
281
|
-
socket.on(types_1.EClientEvent.SET_SESSION, function (session, id, callback) {
|
|
325
|
+
socket.on(types_1.EClientEvent.SET_SESSION, function (session, id, currentMatchId, callback) {
|
|
326
|
+
var _a;
|
|
282
327
|
if (id === void 0) { id = "satoshi"; }
|
|
328
|
+
if (currentMatchId === void 0) { currentMatchId = null; }
|
|
329
|
+
if (callback === void 0) { callback = function () { }; }
|
|
283
330
|
var user = users.get(session);
|
|
284
331
|
if (user) {
|
|
285
|
-
var updatedUser = {
|
|
286
|
-
id: id,
|
|
287
|
-
socketId: socket.id,
|
|
288
|
-
};
|
|
332
|
+
var updatedUser = __assign(__assign({}, user), { id: id });
|
|
289
333
|
users.set(session, updatedUser);
|
|
290
334
|
socket.session = session;
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
_d.trys.push([1, 3, , 4]);
|
|
303
|
-
_a = turns.get(id) || {}, play = _a.play, resolve = _a.resolve;
|
|
304
|
-
session_1 = (_c = play === null || play === void 0 ? void 0 : play.player) === null || _c === void 0 ? void 0 : _c.session;
|
|
305
|
-
if (!play || !session_1) {
|
|
306
|
-
throw new Error("Unexpected Error");
|
|
307
|
-
}
|
|
308
|
-
user_1 = users.get(session_1);
|
|
309
|
-
if (!user_1) {
|
|
310
|
-
throw new Error("Unexpected Error");
|
|
311
|
-
}
|
|
312
|
-
return [4 /*yield*/, sendWaitingForPlay(table, session_1, play)];
|
|
313
|
-
case 2:
|
|
314
|
-
_d.sent();
|
|
315
|
-
resolve === null || resolve === void 0 ? void 0 : resolve();
|
|
316
|
-
return [3 /*break*/, 4];
|
|
317
|
-
case 3:
|
|
318
|
-
e_2 = _d.sent();
|
|
319
|
-
console.error("ERROR", e_2);
|
|
320
|
-
return [3 /*break*/, 4];
|
|
321
|
-
case 4:
|
|
322
|
-
socket.emit(types_1.EServerEvent.UPDATE_MATCH, table.getPublicMatch(session));
|
|
323
|
-
_d.label = 5;
|
|
324
|
-
case 5: return [2 /*return*/];
|
|
335
|
+
var currentTable = currentMatchId ? tables.get(currentMatchId) : null;
|
|
336
|
+
if (currentTable && currentTable.isSessionPlaying(session)) {
|
|
337
|
+
addSocketToUser(session, socket.id, currentTable);
|
|
338
|
+
socket.join(currentTable.matchSessionId);
|
|
339
|
+
if (session === ((_a = currentTable.currentPlayer) === null || _a === void 0 ? void 0 : _a.session)) {
|
|
340
|
+
try {
|
|
341
|
+
var _b = turns.get(currentTable.matchSessionId) || {}, play = _b.play, resolve = _b.resolve;
|
|
342
|
+
if (!play) {
|
|
343
|
+
throw new Error("Unexpected Error");
|
|
344
|
+
}
|
|
345
|
+
sendWaitingForPlay(currentTable, play).then(resolve);
|
|
325
346
|
}
|
|
326
|
-
|
|
327
|
-
|
|
347
|
+
catch (e) {
|
|
348
|
+
console.error("ERROR", e);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
else {
|
|
352
|
+
socket.emit(types_1.EServerEvent.UPDATE_MATCH, currentTable.getPublicMatch(session));
|
|
353
|
+
}
|
|
354
|
+
}
|
|
328
355
|
return callback({ success: true, session: session });
|
|
329
356
|
}
|
|
330
357
|
var newSession = (0, crypto_1.randomUUID)();
|
|
331
358
|
socket.session = newSession;
|
|
332
|
-
users.set(newSession, (0, User_1.User)(id
|
|
359
|
+
users.set(newSession, (0, User_1.User)(id));
|
|
333
360
|
callback({ success: true, session: newSession });
|
|
334
361
|
});
|
|
335
362
|
/**
|
|
@@ -338,12 +365,9 @@ io.on("connection", function (_socket) {
|
|
|
338
365
|
socket.on(types_1.EClientEvent.SET_PLAYER_READY, function (matchSessionId, ready) {
|
|
339
366
|
try {
|
|
340
367
|
var table = getTable(matchSessionId);
|
|
341
|
-
var player = table.lobby.players.find(function (player) { return player.session === socket.session; });
|
|
368
|
+
var player = table.lobby.players.find(function (player) { return player && player.session === socket.session; });
|
|
342
369
|
if (player) {
|
|
343
370
|
player.setReady(ready);
|
|
344
|
-
if (ready) {
|
|
345
|
-
socket.join(matchSessionId);
|
|
346
|
-
}
|
|
347
371
|
emitMatchUpdate(table);
|
|
348
372
|
}
|
|
349
373
|
}
|
package/package.json
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "trucoshi",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"main": "build/lib/trucoshi.js",
|
|
5
|
-
"license": "GPL-3.0",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"test:
|
|
11
|
-
"test:
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "trucoshi",
|
|
3
|
+
"version": "0.0.18",
|
|
4
|
+
"main": "build/lib/trucoshi.js",
|
|
5
|
+
"license": "GPL-3.0",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"start": "node ./dist/server/index.js",
|
|
8
|
+
"prepublishOnly": "yarn build",
|
|
9
|
+
"dev": "nodemon",
|
|
10
|
+
"test:autoplay": "yarn run ts-node src/test/autoplay",
|
|
11
|
+
"test:play": "yarn run ts-node src/test/play",
|
|
12
|
+
"test:legacy": "yarn run ts-node src/test/legacy",
|
|
13
|
+
"build": "yarn run rimraf ./dist && yarn run tsc --project ."
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@types/node": "^18.11.18",
|
|
17
|
+
"nodemon": "^2.0.20"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"rimraf": "^4.1.1",
|
|
24
|
+
"socket.io": "^4.5.4",
|
|
25
|
+
"ts-node": "^10.9.1",
|
|
26
|
+
"tsc": "^2.0.4",
|
|
27
|
+
"typescript": "^4.9.4"
|
|
28
|
+
}
|
|
29
|
+
}
|