trucoshi 0.2.2 → 0.2.3
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.
|
@@ -16,7 +16,7 @@ export interface IPrivateLobby {
|
|
|
16
16
|
full: boolean;
|
|
17
17
|
ready: boolean;
|
|
18
18
|
started: boolean;
|
|
19
|
-
addPlayer(id: string, session: string, teamIdx?: 0 | 1, isOwner?: boolean): IPlayer;
|
|
19
|
+
addPlayer(key: string, id: string, session: string, teamIdx?: 0 | 1, isOwner?: boolean): IPlayer;
|
|
20
20
|
removePlayer(id: string): ILobby;
|
|
21
21
|
calculateReady(): boolean;
|
|
22
22
|
calculateFull(): boolean;
|
|
@@ -34,7 +34,7 @@ function Lobby(teamSize) {
|
|
|
34
34
|
lobby.full = lobby.players.length >= lobby.maxPlayers;
|
|
35
35
|
return lobby.full;
|
|
36
36
|
},
|
|
37
|
-
addPlayer(id, session, teamIdx, isOwner) {
|
|
37
|
+
addPlayer(key, id, session, teamIdx, isOwner) {
|
|
38
38
|
const exists = lobby.players.find((player) => player.session === session);
|
|
39
39
|
if (exists) {
|
|
40
40
|
if (exists.teamIdx === teamIdx) {
|
|
@@ -53,7 +53,7 @@ function Lobby(teamSize) {
|
|
|
53
53
|
lobby.players.filter((player) => player.teamIdx === teamIdx).length > maxSize) {
|
|
54
54
|
throw new Error(types_1.GAME_ERROR.TEAM_IS_FULL);
|
|
55
55
|
}
|
|
56
|
-
const player = (0, Player_1.Player)(id, teamIdx !== undefined ? teamIdx : Number(!lobby.lastTeamIdx), isOwner);
|
|
56
|
+
const player = (0, Player_1.Player)(key, id, teamIdx !== undefined ? teamIdx : Number(!lobby.lastTeamIdx), isOwner);
|
|
57
57
|
player.setSession(session);
|
|
58
58
|
lobby.lastTeamIdx = Number(!lobby.lastTeamIdx);
|
|
59
59
|
for (let i = 0; i < lobby._players.length; i++) {
|
|
@@ -24,4 +24,4 @@ export interface IPlayer {
|
|
|
24
24
|
useCard(idx: number, card: ICard): ICard | null;
|
|
25
25
|
}
|
|
26
26
|
export type IPublicPlayer = Pick<IPlayer, "id" | "key" | "disabled" | "ready" | "hand" | "usedHand" | "prevHand" | "teamIdx" | "session" | "isTurn" | "isOwner">;
|
|
27
|
-
export declare function Player(id: string, teamIdx: number, isOwner?: boolean): IPlayer;
|
|
27
|
+
export declare function Player(key: string, id: string, teamIdx: number, isOwner?: boolean): IPlayer;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Player = void 0;
|
|
4
|
-
|
|
5
|
-
function Player(id, teamIdx, isOwner = false) {
|
|
4
|
+
function Player(key, id, teamIdx, isOwner = false) {
|
|
6
5
|
const player = {
|
|
7
|
-
key
|
|
6
|
+
key,
|
|
8
7
|
id,
|
|
9
8
|
session: undefined,
|
|
10
9
|
teamIdx,
|