trucoshi 0.2.10 → 0.2.12

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.
Files changed (39) hide show
  1. package/LICENSE +674 -674
  2. package/README.md +60 -60
  3. package/dist/index.d.ts +2 -2
  4. package/dist/index.js +18 -18
  5. package/dist/lib/classes/Deck.d.ts +17 -17
  6. package/dist/lib/classes/Deck.js +41 -41
  7. package/dist/lib/classes/GameLoop.d.ts +23 -22
  8. package/dist/lib/classes/GameLoop.js +76 -64
  9. package/dist/lib/classes/Hand.d.ts +39 -38
  10. package/dist/lib/classes/Hand.js +192 -188
  11. package/dist/lib/classes/Lobby.d.ts +27 -27
  12. package/dist/lib/classes/Lobby.js +113 -113
  13. package/dist/lib/classes/Match.d.ts +20 -18
  14. package/dist/lib/classes/Match.js +87 -81
  15. package/dist/lib/classes/Play.d.ts +21 -20
  16. package/dist/lib/classes/Play.js +29 -26
  17. package/dist/lib/classes/Player.d.ts +32 -32
  18. package/dist/lib/classes/Player.js +79 -78
  19. package/dist/lib/classes/Round.d.ts +17 -17
  20. package/dist/lib/classes/Round.js +33 -33
  21. package/dist/lib/classes/Table.d.ts +12 -12
  22. package/dist/lib/classes/Table.js +30 -30
  23. package/dist/lib/classes/Team.d.ts +20 -20
  24. package/dist/lib/classes/Team.js +59 -59
  25. package/dist/lib/classes/Truco.d.ts +21 -19
  26. package/dist/lib/classes/Truco.js +131 -123
  27. package/dist/lib/classes/index.d.ts +11 -11
  28. package/dist/lib/classes/index.js +27 -27
  29. package/dist/lib/constants.d.ts +45 -45
  30. package/dist/lib/constants.js +84 -84
  31. package/dist/lib/index.d.ts +2 -2
  32. package/dist/lib/index.js +18 -18
  33. package/dist/lib/types.d.ts +50 -50
  34. package/dist/lib/types.js +34 -34
  35. package/dist/lib/utils.d.ts +5 -5
  36. package/dist/lib/utils.js +58 -58
  37. package/dist/types.d.ts +173 -167
  38. package/dist/types.js +106 -98
  39. package/package.json +2 -2
@@ -1,113 +1,113 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Lobby = void 0;
4
- const constants_1 = require("../constants");
5
- const types_1 = require("../../types");
6
- const GameLoop_1 = require("./GameLoop");
7
- const Match_1 = require("./Match");
8
- const Player_1 = require("./Player");
9
- const Table_1 = require("./Table");
10
- const Team_1 = require("./Team");
11
- function Lobby(teamSize) {
12
- const lobby = {
13
- lastTeamIdx: 1,
14
- _players: [],
15
- get players() {
16
- return lobby._players.filter((player) => Boolean(player && player.id));
17
- },
18
- teams: [],
19
- table: null,
20
- maxPlayers: teamSize ? teamSize * 2 : 6,
21
- full: false,
22
- ready: false,
23
- started: false,
24
- gameLoop: undefined,
25
- calculateReady() {
26
- const allPlayersReady = lobby.players.reduce((prev, curr) => Boolean(prev && curr && curr.ready), true);
27
- const teamsSameSize = lobby.players.filter((player) => player.teamIdx === 0).length ===
28
- lobby.players.filter((player) => player.teamIdx === 1).length;
29
- const allTeamsComplete = lobby.players.length % 2 === 0;
30
- lobby.ready = allPlayersReady && allTeamsComplete && teamsSameSize;
31
- return lobby.ready;
32
- },
33
- calculateFull() {
34
- lobby.full = lobby.players.length >= lobby.maxPlayers;
35
- return lobby.full;
36
- },
37
- addPlayer(key, id, session, teamIdx, isOwner) {
38
- const exists = lobby.players.find((player) => player.session === session);
39
- if (exists) {
40
- if (exists.teamIdx === teamIdx) {
41
- return exists;
42
- }
43
- isOwner = exists.isOwner;
44
- lobby.removePlayer(exists.session);
45
- }
46
- if (lobby.started) {
47
- throw new Error(types_1.GAME_ERROR.MATCH_ALREADY_STARTED);
48
- }
49
- if (lobby.full) {
50
- throw new Error(types_1.GAME_ERROR.LOBBY_IS_FULL);
51
- }
52
- const maxSize = teamSize ? teamSize : 3;
53
- if (lobby.full ||
54
- lobby.players.filter((player) => player.teamIdx === teamIdx).length > maxSize) {
55
- throw new Error(types_1.GAME_ERROR.TEAM_IS_FULL);
56
- }
57
- const player = (0, Player_1.Player)(key, id, teamIdx !== undefined ? teamIdx : Number(!lobby.lastTeamIdx), isOwner);
58
- player.setSession(session);
59
- lobby.lastTeamIdx = Number(!lobby.lastTeamIdx);
60
- for (let i = 0; i < lobby._players.length; i++) {
61
- if (!lobby._players[i].id) {
62
- if (player.teamIdx === 0 && i % 2 === 0) {
63
- lobby._players[i] = player;
64
- break;
65
- }
66
- if (player.teamIdx === 1 && i % 2 !== 0) {
67
- lobby._players[i] = player;
68
- break;
69
- }
70
- }
71
- }
72
- lobby.calculateFull();
73
- lobby.calculateReady();
74
- return player;
75
- },
76
- removePlayer(session) {
77
- const idx = lobby._players.findIndex((player) => player && player.session === session);
78
- if (idx !== -1) {
79
- lobby._players[idx] = {};
80
- lobby.calculateFull();
81
- lobby.calculateReady();
82
- }
83
- return lobby;
84
- },
85
- startMatch(matchPoint = 9) {
86
- lobby.calculateReady();
87
- const actualTeamSize = lobby.players.length / 2;
88
- if (!constants_1.TEAM_SIZE_VALUES.includes(actualTeamSize)) {
89
- throw new Error(types_1.GAME_ERROR.UNEXPECTED_TEAM_SIZE);
90
- }
91
- if (!lobby.ready) {
92
- throw new Error(types_1.GAME_ERROR.TEAM_NOT_READY);
93
- }
94
- lobby.teams = [
95
- (0, Team_1.Team)(lobby.players.filter((player) => player.teamIdx === 0)),
96
- (0, Team_1.Team)(lobby.players.filter((player) => player.teamIdx === 1)),
97
- ];
98
- if (lobby.teams[0].players.length !== actualTeamSize ||
99
- lobby.teams[1].players.length !== actualTeamSize) {
100
- throw new Error(types_1.GAME_ERROR.UNEXPECTED_TEAM_SIZE);
101
- }
102
- lobby.table = (0, Table_1.Table)(lobby.players, lobby.teams);
103
- lobby.gameLoop = (0, GameLoop_1.GameLoop)((0, Match_1.Match)(lobby.table, lobby.teams, matchPoint));
104
- lobby.started = true;
105
- return lobby.gameLoop;
106
- },
107
- };
108
- for (let i = 0; i < lobby.maxPlayers; i++) {
109
- lobby._players.push({});
110
- }
111
- return lobby;
112
- }
113
- exports.Lobby = Lobby;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Lobby = void 0;
4
+ const constants_1 = require("../constants");
5
+ const types_1 = require("../../types");
6
+ const GameLoop_1 = require("./GameLoop");
7
+ const Match_1 = require("./Match");
8
+ const Player_1 = require("./Player");
9
+ const Table_1 = require("./Table");
10
+ const Team_1 = require("./Team");
11
+ function Lobby(teamSize) {
12
+ const lobby = {
13
+ lastTeamIdx: 1,
14
+ _players: [],
15
+ get players() {
16
+ return lobby._players.filter((player) => Boolean(player && player.id));
17
+ },
18
+ teams: [],
19
+ table: null,
20
+ maxPlayers: teamSize ? teamSize * 2 : 6,
21
+ full: false,
22
+ ready: false,
23
+ started: false,
24
+ gameLoop: undefined,
25
+ calculateReady() {
26
+ const allPlayersReady = lobby.players.reduce((prev, curr) => Boolean(prev && curr && curr.ready), true);
27
+ const teamsSameSize = lobby.players.filter((player) => player.teamIdx === 0).length ===
28
+ lobby.players.filter((player) => player.teamIdx === 1).length;
29
+ const allTeamsComplete = lobby.players.length % 2 === 0;
30
+ lobby.ready = allPlayersReady && allTeamsComplete && teamsSameSize;
31
+ return lobby.ready;
32
+ },
33
+ calculateFull() {
34
+ lobby.full = lobby.players.length >= lobby.maxPlayers;
35
+ return lobby.full;
36
+ },
37
+ addPlayer(key, id, session, teamIdx, isOwner) {
38
+ const exists = lobby.players.find((player) => player.session === session);
39
+ if (exists) {
40
+ if (exists.teamIdx === teamIdx) {
41
+ return exists;
42
+ }
43
+ isOwner = exists.isOwner;
44
+ lobby.removePlayer(exists.session);
45
+ }
46
+ if (lobby.started) {
47
+ throw new Error(types_1.GAME_ERROR.MATCH_ALREADY_STARTED);
48
+ }
49
+ if (lobby.full) {
50
+ throw new Error(types_1.GAME_ERROR.LOBBY_IS_FULL);
51
+ }
52
+ const maxSize = teamSize ? teamSize : 3;
53
+ if (lobby.full ||
54
+ lobby.players.filter((player) => player.teamIdx === teamIdx).length > maxSize) {
55
+ throw new Error(types_1.GAME_ERROR.TEAM_IS_FULL);
56
+ }
57
+ const player = (0, Player_1.Player)(key, id, teamIdx !== undefined ? teamIdx : Number(!lobby.lastTeamIdx), isOwner);
58
+ player.setSession(session);
59
+ lobby.lastTeamIdx = Number(!lobby.lastTeamIdx);
60
+ for (let i = 0; i < lobby._players.length; i++) {
61
+ if (!lobby._players[i].id) {
62
+ if (player.teamIdx === 0 && i % 2 === 0) {
63
+ lobby._players[i] = player;
64
+ break;
65
+ }
66
+ if (player.teamIdx === 1 && i % 2 !== 0) {
67
+ lobby._players[i] = player;
68
+ break;
69
+ }
70
+ }
71
+ }
72
+ lobby.calculateFull();
73
+ lobby.calculateReady();
74
+ return player;
75
+ },
76
+ removePlayer(session) {
77
+ const idx = lobby._players.findIndex((player) => player && player.session === session);
78
+ if (idx !== -1) {
79
+ lobby._players[idx] = {};
80
+ lobby.calculateFull();
81
+ lobby.calculateReady();
82
+ }
83
+ return lobby;
84
+ },
85
+ startMatch(matchPoint = 9) {
86
+ lobby.calculateReady();
87
+ const actualTeamSize = lobby.players.length / 2;
88
+ if (!constants_1.TEAM_SIZE_VALUES.includes(actualTeamSize)) {
89
+ throw new Error(types_1.GAME_ERROR.UNEXPECTED_TEAM_SIZE);
90
+ }
91
+ if (!lobby.ready) {
92
+ throw new Error(types_1.GAME_ERROR.TEAM_NOT_READY);
93
+ }
94
+ lobby.teams = [
95
+ (0, Team_1.Team)(lobby.players.filter((player) => player.teamIdx === 0)),
96
+ (0, Team_1.Team)(lobby.players.filter((player) => player.teamIdx === 1)),
97
+ ];
98
+ if (lobby.teams[0].players.length !== actualTeamSize ||
99
+ lobby.teams[1].players.length !== actualTeamSize) {
100
+ throw new Error(types_1.GAME_ERROR.UNEXPECTED_TEAM_SIZE);
101
+ }
102
+ lobby.table = (0, Table_1.Table)(lobby.players, lobby.teams);
103
+ lobby.gameLoop = (0, GameLoop_1.GameLoop)((0, Match_1.Match)(lobby.table, lobby.teams, matchPoint));
104
+ lobby.started = true;
105
+ return lobby.gameLoop;
106
+ },
107
+ };
108
+ for (let i = 0; i < lobby.maxPlayers; i++) {
109
+ lobby._players.push({});
110
+ }
111
+ return lobby;
112
+ }
113
+ exports.Lobby = Lobby;
@@ -1,18 +1,20 @@
1
- import { IHand, IHandPoints } from "./Hand";
2
- import { IPlayInstance } from "./Play";
3
- import { ITable } from "./Table";
4
- import { ITeam } from "./Team";
5
- export interface IMatch {
6
- teams: [ITeam, ITeam];
7
- hands: Array<IHand>;
8
- winner: ITeam | null;
9
- currentHand: IHand | null;
10
- table: ITable;
11
- play(): IPlayInstance | null;
12
- addPoints(points: IHandPoints): [ITeam, ITeam];
13
- pushHand(hand: IHand): void;
14
- setCurrentHand(hand: IHand | null): IHand | null;
15
- setWinner(winner: ITeam): void;
16
- getNextTurn(): IteratorResult<IMatch | null, IMatch | null | void>;
17
- }
18
- export declare function Match(table: ITable, teams?: Array<ITeam>, matchPoint?: number): IMatch;
1
+ import { IHand, IHandPoints } from "./Hand";
2
+ import { IPlayInstance } from "./Play";
3
+ import { ITable } from "./Table";
4
+ import { ITeam } from "./Team";
5
+ export interface IMatch {
6
+ teams: [ITeam, ITeam];
7
+ hands: Array<IHand>;
8
+ winner: ITeam | null;
9
+ prevHand: IHand | null;
10
+ currentHand: IHand | null;
11
+ table: ITable;
12
+ play(): IPlayInstance | null;
13
+ addPoints(points: IHandPoints): [ITeam, ITeam];
14
+ pushHand(hand: IHand): void;
15
+ setPrevHand(hand: IHand | null): IHand | null;
16
+ setCurrentHand(hand: IHand | null): IHand | null;
17
+ setWinner(winner: ITeam): void;
18
+ getNextTurn(): IteratorResult<IMatch | null, IMatch | null | void>;
19
+ }
20
+ export declare function Match(table: ITable, teams?: Array<ITeam>, matchPoint?: number): IMatch;
@@ -1,81 +1,87 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Match = void 0;
4
- const Deck_1 = require("./Deck");
5
- const Hand_1 = require("./Hand");
6
- const playerIsNotReady = (player) => !player.ready;
7
- function Match(table, teams = [], matchPoint = 9) {
8
- const deck = (0, Deck_1.Deck)().shuffle();
9
- const size = teams[0].players.length;
10
- if (size !== teams[1].players.length) {
11
- throw new Error("Team size mismatch");
12
- }
13
- function* handsGeneratorSequence() {
14
- while (!match.winner) {
15
- if (match.teams[0].players.every(playerIsNotReady)) {
16
- match.setWinner(match.teams[1]);
17
- break;
18
- }
19
- if (match.teams[1].players.every(playerIsNotReady)) {
20
- match.setWinner(match.teams[0]);
21
- break;
22
- }
23
- deck.shuffle();
24
- const hand = match.setCurrentHand((0, Hand_1.Hand)(match, deck, match.hands.length + 1));
25
- match.pushHand(hand);
26
- while (!hand.finished()) {
27
- const { value } = hand.getNextPlayer();
28
- if (value && value.finished()) {
29
- continue;
30
- }
31
- match.setCurrentHand(value);
32
- yield match;
33
- }
34
- match.setCurrentHand(null);
35
- const teams = match.addPoints(hand.points);
36
- const winner = teams.find((team) => team.points.winner);
37
- if (winner) {
38
- match.setWinner(winner);
39
- match.setCurrentHand(null);
40
- break;
41
- }
42
- match.table.nextTurn();
43
- }
44
- yield match;
45
- }
46
- const handsGenerator = handsGeneratorSequence();
47
- const match = {
48
- winner: null,
49
- teams: teams,
50
- hands: [],
51
- table,
52
- currentHand: null,
53
- play() {
54
- match.getNextTurn();
55
- if (!match.currentHand) {
56
- return null;
57
- }
58
- return match.currentHand.play();
59
- },
60
- addPoints(points) {
61
- match.teams[0].addPoints(matchPoint, points[0]);
62
- match.teams[1].addPoints(matchPoint, points[1]);
63
- return match.teams;
64
- },
65
- pushHand(hand) {
66
- match.hands.push(hand);
67
- },
68
- setCurrentHand(hand) {
69
- match.currentHand = hand;
70
- return match.currentHand;
71
- },
72
- setWinner(winner) {
73
- match.winner = winner;
74
- },
75
- getNextTurn() {
76
- return handsGenerator.next();
77
- },
78
- };
79
- return match;
80
- }
81
- exports.Match = Match;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Match = void 0;
4
+ const Deck_1 = require("./Deck");
5
+ const Hand_1 = require("./Hand");
6
+ const playerIsNotReady = (player) => !player.ready;
7
+ function Match(table, teams = [], matchPoint = 9) {
8
+ const deck = (0, Deck_1.Deck)().shuffle();
9
+ const size = teams[0].players.length;
10
+ if (size !== teams[1].players.length) {
11
+ throw new Error("Team size mismatch");
12
+ }
13
+ function* handsGeneratorSequence() {
14
+ while (!match.winner) {
15
+ if (match.teams[0].players.every(playerIsNotReady)) {
16
+ match.setWinner(match.teams[1]);
17
+ break;
18
+ }
19
+ if (match.teams[1].players.every(playerIsNotReady)) {
20
+ match.setWinner(match.teams[0]);
21
+ break;
22
+ }
23
+ deck.shuffle();
24
+ const hand = match.setCurrentHand((0, Hand_1.Hand)(match, deck, match.hands.length + 1));
25
+ match.setPrevHand(match.hands.at(-1) || null);
26
+ match.pushHand(hand);
27
+ while (!hand.finished()) {
28
+ const { value } = hand.getNextPlayer();
29
+ if (value && value.finished()) {
30
+ continue;
31
+ }
32
+ match.setCurrentHand(value);
33
+ yield match;
34
+ }
35
+ match.setCurrentHand(null);
36
+ const teams = match.addPoints(hand.points);
37
+ const winner = teams.find((team) => team.points.winner);
38
+ if (winner) {
39
+ match.setWinner(winner);
40
+ match.setCurrentHand(null);
41
+ break;
42
+ }
43
+ match.table.nextTurn();
44
+ }
45
+ yield match;
46
+ }
47
+ const handsGenerator = handsGeneratorSequence();
48
+ const match = {
49
+ winner: null,
50
+ teams: teams,
51
+ hands: [],
52
+ table,
53
+ prevHand: null,
54
+ currentHand: null,
55
+ play() {
56
+ match.getNextTurn();
57
+ if (!match.currentHand) {
58
+ return null;
59
+ }
60
+ return match.currentHand.play(match.prevHand);
61
+ },
62
+ addPoints(points) {
63
+ match.teams[0].addPoints(matchPoint, points[0]);
64
+ match.teams[1].addPoints(matchPoint, points[1]);
65
+ return match.teams;
66
+ },
67
+ pushHand(hand) {
68
+ match.hands.push(hand);
69
+ },
70
+ setCurrentHand(hand) {
71
+ match.currentHand = hand;
72
+ return match.currentHand;
73
+ },
74
+ setPrevHand(hand) {
75
+ match.prevHand = hand;
76
+ return match.prevHand;
77
+ },
78
+ setWinner(winner) {
79
+ match.winner = winner;
80
+ },
81
+ getNextTurn() {
82
+ return handsGenerator.next();
83
+ },
84
+ };
85
+ return match;
86
+ }
87
+ exports.Match = Match;
@@ -1,20 +1,21 @@
1
- import { ECommand, EHandState, EnvidoState } from "../../types";
2
- import { ICard } from "./Deck";
3
- import { IHand } from "./Hand";
4
- import { IPlayer } from "./Player";
5
- import { IRound } from "./Round";
6
- import { ITeam } from "./Team";
7
- import { ITruco } from "./Truco";
8
- export interface IPlayInstance {
9
- teams: [ITeam, ITeam];
10
- handIdx: number;
11
- roundIdx: number;
12
- state: EHandState;
13
- truco: ITruco;
14
- envido: EnvidoState;
15
- player: IPlayer | null;
16
- rounds: Array<IRound> | null;
17
- use(idx: number, card: ICard): ICard | null;
18
- say(command: ECommand, player: IPlayer): ECommand | null;
19
- }
20
- export declare function PlayInstance(hand: IHand, teams: [ITeam, ITeam]): IPlayInstance;
1
+ import { ECommand, EHandState, EnvidoState } from "../../types";
2
+ import { ICard } from "./Deck";
3
+ import { IHand } from "./Hand";
4
+ import { IPlayer } from "./Player";
5
+ import { IRound } from "./Round";
6
+ import { ITeam } from "./Team";
7
+ import { ITruco } from "./Truco";
8
+ export interface IPlayInstance {
9
+ teams: [ITeam, ITeam];
10
+ handIdx: number;
11
+ roundIdx: number;
12
+ state: EHandState;
13
+ truco: ITruco;
14
+ envido: EnvidoState;
15
+ player: IPlayer | null;
16
+ rounds: Array<IRound> | null;
17
+ prevHand: IHand | null;
18
+ use(idx: number, card: ICard): ICard | null;
19
+ say(command: ECommand, player: IPlayer): ECommand | null;
20
+ }
21
+ export declare function PlayInstance(hand: IHand, prevHand: IHand | null, teams: [ITeam, ITeam]): IPlayInstance;
@@ -1,26 +1,29 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PlayInstance = void 0;
4
- const types_1 = require("../../types");
5
- function PlayInstance(hand, teams) {
6
- const instance = {
7
- state: hand.state,
8
- teams,
9
- truco: hand.truco,
10
- envido: hand.envido,
11
- handIdx: hand.idx,
12
- roundIdx: hand.rounds.length,
13
- player: hand.currentPlayer,
14
- rounds: hand.rounds,
15
- use(idx, card) {
16
- return hand.use(idx, card);
17
- },
18
- say(command, player) {
19
- hand.commands[command](player);
20
- return command;
21
- },
22
- };
23
- teams.forEach((team) => team.players.forEach((player) => player._commands.add(types_1.ESayCommand.MAZO)));
24
- return instance;
25
- }
26
- exports.PlayInstance = PlayInstance;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PlayInstance = void 0;
4
+ const types_1 = require("../../types");
5
+ function PlayInstance(hand, prevHand, teams) {
6
+ const instance = {
7
+ state: hand.state,
8
+ teams,
9
+ truco: hand.truco,
10
+ envido: hand.envido,
11
+ handIdx: hand.idx,
12
+ roundIdx: hand.rounds.length,
13
+ player: hand.currentPlayer,
14
+ rounds: hand.rounds,
15
+ prevHand: prevHand && !hand.started && !hand.truco.waitingAnswer ? prevHand : null,
16
+ use(idx, card) {
17
+ return hand.use(idx, card);
18
+ },
19
+ say(command, player) {
20
+ hand.commands[command](player);
21
+ return command;
22
+ },
23
+ };
24
+ if (!hand.truco.waitingAnswer) {
25
+ teams.forEach((team) => team.players.forEach((player) => player._commands.add(types_1.ESayCommand.MAZO)));
26
+ }
27
+ return instance;
28
+ }
29
+ exports.PlayInstance = PlayInstance;
@@ -1,32 +1,32 @@
1
- import { ECommand } from "../../types";
2
- import { ICard } from "./Deck";
3
- export interface IPlayer {
4
- teamIdx: number;
5
- id: string;
6
- key: string;
7
- session?: string;
8
- hand: Array<ICard>;
9
- _commands: Set<ECommand>;
10
- get commands(): Array<ECommand>;
11
- usedHand: Array<ICard>;
12
- prevHand: Array<ICard>;
13
- isTurn: boolean;
14
- isOwner: boolean;
15
- disabled: boolean;
16
- ready: boolean;
17
- connected: boolean;
18
- setTurn(turn: boolean): void;
19
- getPublicPlayer(): IPublicPlayer;
20
- setSession(session: string): void;
21
- enable(): void;
22
- disable(): void;
23
- setConnected(connected: boolean): void;
24
- setOwner(owner: boolean): void;
25
- setReady(ready: boolean): void;
26
- setHand(hand: Array<ICard>): Array<ICard>;
27
- useCard(idx: number, card: ICard): ICard | null;
28
- }
29
- export type IPublicPlayer = Pick<IPlayer, "id" | "key" | "disabled" | "ready" | "connected" | "hand" | "usedHand" | "prevHand" | "teamIdx" | "session" | "isTurn" | "isOwner"> & {
30
- commands: Array<ECommand>;
31
- };
32
- export declare function Player(key: string, id: string, teamIdx: number, isOwner?: boolean): IPlayer;
1
+ import { ECommand } from "../../types";
2
+ import { ICard } from "./Deck";
3
+ export interface IPlayer {
4
+ teamIdx: number;
5
+ id: string;
6
+ key: string;
7
+ session?: string;
8
+ hand: Array<ICard>;
9
+ _commands: Set<ECommand>;
10
+ get commands(): Array<ECommand>;
11
+ usedHand: Array<ICard>;
12
+ prevHand: Array<ICard>;
13
+ isTurn: boolean;
14
+ isOwner: boolean;
15
+ disabled: boolean;
16
+ ready: boolean;
17
+ connected: boolean;
18
+ setTurn(turn: boolean): void;
19
+ getPublicPlayer(): IPublicPlayer;
20
+ setSession(session: string): void;
21
+ enable(): void;
22
+ disable(): void;
23
+ setConnected(connected: boolean): void;
24
+ setOwner(owner: boolean): void;
25
+ setReady(ready: boolean): void;
26
+ setHand(hand: Array<ICard>): Array<ICard>;
27
+ useCard(idx: number, card: ICard): ICard | null;
28
+ }
29
+ export type IPublicPlayer = Pick<IPlayer, "id" | "key" | "disabled" | "ready" | "connected" | "hand" | "usedHand" | "prevHand" | "teamIdx" | "session" | "isTurn" | "isOwner"> & {
30
+ commands: Array<ECommand>;
31
+ };
32
+ export declare function Player(key: string, id: string, teamIdx: number, isOwner?: boolean): IPlayer;