trucoshi 0.3.3 → 0.3.5

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 (43) 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/Envido.d.ts +34 -0
  8. package/dist/lib/classes/Envido.js +168 -0
  9. package/dist/lib/classes/Flor.d.ts +0 -0
  10. package/dist/lib/classes/Flor.js +1 -0
  11. package/dist/lib/classes/GameLoop.d.ts +26 -23
  12. package/dist/lib/classes/GameLoop.js +106 -78
  13. package/dist/lib/classes/Hand.d.ts +43 -39
  14. package/dist/lib/classes/Hand.js +295 -197
  15. package/dist/lib/classes/Lobby.d.ts +27 -27
  16. package/dist/lib/classes/Lobby.js +113 -113
  17. package/dist/lib/classes/Match.d.ts +21 -20
  18. package/dist/lib/classes/Match.js +88 -87
  19. package/dist/lib/classes/Play.d.ts +22 -21
  20. package/dist/lib/classes/Play.js +44 -29
  21. package/dist/lib/classes/Player.d.ts +35 -30
  22. package/dist/lib/classes/Player.js +126 -74
  23. package/dist/lib/classes/Round.d.ts +17 -17
  24. package/dist/lib/classes/Round.js +33 -33
  25. package/dist/lib/classes/Table.d.ts +12 -12
  26. package/dist/lib/classes/Table.js +38 -30
  27. package/dist/lib/classes/Team.d.ts +20 -20
  28. package/dist/lib/classes/Team.js +59 -59
  29. package/dist/lib/classes/Truco.d.ts +30 -21
  30. package/dist/lib/classes/Truco.js +97 -131
  31. package/dist/lib/classes/index.d.ts +11 -11
  32. package/dist/lib/classes/index.js +27 -27
  33. package/dist/lib/constants.d.ts +43 -45
  34. package/dist/lib/constants.js +46 -84
  35. package/dist/lib/index.d.ts +2 -2
  36. package/dist/lib/index.js +18 -18
  37. package/dist/lib/types.d.ts +44 -36
  38. package/dist/lib/types.js +21 -18
  39. package/dist/lib/utils.d.ts +5 -5
  40. package/dist/lib/utils.js +58 -58
  41. package/dist/types.d.ts +193 -182
  42. package/dist/types.js +123 -106
  43. package/package.json +1 -1
@@ -1,131 +1,97 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Truco = void 0;
4
- const types_1 = require("../../types");
5
- const EMPTY_TRUCO = {
6
- turn: 0,
7
- teamIdx: null,
8
- answer: null,
9
- waitingAnswer: false,
10
- currentPlayer: null,
11
- players: [],
12
- };
13
- function Truco(teams) {
14
- function* trucoAnswerGeneratorSequence() {
15
- let i = 0;
16
- while (i < truco.players.length && truco.answer === null) {
17
- const player = truco.players[truco.turn];
18
- truco.setCurrentPlayer(player);
19
- if (player.disabled || !player.ready) {
20
- truco.setCurrentPlayer(null);
21
- }
22
- if (truco.turn >= truco.players.length - 1) {
23
- truco.setTurn(0);
24
- }
25
- else {
26
- truco.setTurn(truco.turn + 1);
27
- }
28
- i++;
29
- yield truco;
30
- }
31
- yield truco;
32
- }
33
- const truco = Object.assign(Object.assign({}, EMPTY_TRUCO), { state: 1, teams, generator: trucoAnswerGeneratorSequence(), reset() {
34
- teams.forEach((team) => team.players.forEach((player) => {
35
- player._commands.delete(types_1.ESayCommand.TRUCO);
36
- player._commands.delete(types_1.ESayCommand.QUIERO);
37
- player._commands.delete(types_1.ESayCommand.NO_QUIERO);
38
- }));
39
- Object.assign(truco, EMPTY_TRUCO);
40
- },
41
- sayTruco(player, callback) {
42
- if (truco.state === 4) {
43
- return truco;
44
- }
45
- const playerTeamIdx = player.teamIdx;
46
- const teamIdx = truco.teamIdx;
47
- if (teamIdx === null || teamIdx !== playerTeamIdx) {
48
- truco.waitingAnswer = true;
49
- truco.state++;
50
- const opponentIdx = Number(!playerTeamIdx);
51
- truco.teamIdx = playerTeamIdx;
52
- truco.answer = null;
53
- truco.players = teams[opponentIdx].players;
54
- truco.generator = trucoAnswerGeneratorSequence();
55
- teams[playerTeamIdx].players.forEach((player) => {
56
- player._commands.delete(types_1.ESayCommand.TRUCO);
57
- player._commands.delete(types_1.ESayCommand.QUIERO);
58
- player._commands.delete(types_1.ESayCommand.NO_QUIERO);
59
- });
60
- teams[opponentIdx].players.forEach((player) => {
61
- if (truco.state < 4) {
62
- player._commands.add(types_1.ESayCommand.TRUCO);
63
- }
64
- else {
65
- player._commands.delete(types_1.ESayCommand.TRUCO);
66
- }
67
- player._commands.add(types_1.ESayCommand.QUIERO);
68
- player._commands.add(types_1.ESayCommand.NO_QUIERO);
69
- });
70
- callback();
71
- return truco;
72
- }
73
- return truco;
74
- },
75
- sayAnswer(player, answer, callback) {
76
- const opponentIdx = Number(!player.teamIdx);
77
- if (player.teamIdx === truco.teamIdx) {
78
- return truco;
79
- }
80
- if (answer) {
81
- teams[player.teamIdx].players.forEach((player) => {
82
- player._commands.add(types_1.ESayCommand.TRUCO);
83
- player._commands.delete(types_1.ESayCommand.NO_QUIERO);
84
- player._commands.delete(types_1.ESayCommand.QUIERO);
85
- if (truco.state > 3) {
86
- player._commands.delete(types_1.ESayCommand.TRUCO);
87
- }
88
- });
89
- teams[opponentIdx].players.forEach((player) => {
90
- player._commands.delete(types_1.ESayCommand.TRUCO);
91
- });
92
- }
93
- if (answer === false) {
94
- truco.state--;
95
- const playerTeam = teams[player.teamIdx];
96
- playerTeam.players.forEach((player) => playerTeam.disable(player));
97
- teams[player.teamIdx].players.forEach((player) => {
98
- player._commands.delete(types_1.ESayCommand.QUIERO);
99
- player._commands.delete(types_1.ESayCommand.TRUCO);
100
- player._commands.delete(types_1.ESayCommand.NO_QUIERO);
101
- });
102
- }
103
- if (answer !== null) {
104
- truco.waitingAnswer = false;
105
- truco.teamIdx = Number(!player.teamIdx);
106
- truco.answer = answer;
107
- callback();
108
- }
109
- return truco;
110
- },
111
- setTeam(idx) {
112
- truco.teamIdx = idx;
113
- return truco.teamIdx;
114
- },
115
- setTurn(turn) {
116
- truco.turn = turn;
117
- return truco.turn;
118
- },
119
- setCurrentPlayer(player) {
120
- truco.currentPlayer = player;
121
- return truco.currentPlayer;
122
- },
123
- getNextPlayer() {
124
- return truco.generator.next();
125
- } });
126
- teams.forEach((team) => team.players.forEach((player) => {
127
- player._commands.add(types_1.ESayCommand.TRUCO);
128
- }));
129
- return truco;
130
- }
131
- exports.Truco = Truco;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Truco = void 0;
4
+ const types_1 = require("../../types");
5
+ const EMPTY_TRUCO = {
6
+ turn: 0,
7
+ teamIdx: null,
8
+ answer: null,
9
+ waitingAnswer: false,
10
+ currentPlayer: null,
11
+ players: [],
12
+ };
13
+ const TRUCO_STATE_MAP = {
14
+ 1: types_1.ETrucoCommand.TRUCO,
15
+ 2: types_1.ETrucoCommand.RE_TRUCO,
16
+ 3: types_1.ETrucoCommand.VALE_CUATRO,
17
+ 4: null,
18
+ };
19
+ function Truco(teams) {
20
+ function* trucoAnswerGeneratorSequence() {
21
+ let i = 0;
22
+ while (i < truco.players.length && truco.answer === null) {
23
+ const player = truco.players[truco.turn];
24
+ truco.setCurrentPlayer(player);
25
+ if (player.disabled || !player.ready) {
26
+ truco.setCurrentPlayer(null);
27
+ }
28
+ if (truco.turn >= truco.players.length - 1) {
29
+ truco.setTurn(0);
30
+ }
31
+ else {
32
+ truco.setTurn(truco.turn + 1);
33
+ }
34
+ i++;
35
+ yield truco;
36
+ }
37
+ yield truco;
38
+ }
39
+ const truco = Object.assign(Object.assign({}, EMPTY_TRUCO), { state: 1, teams, currentCommands: [], generator: trucoAnswerGeneratorSequence(), getNextTrucoCommand() {
40
+ return TRUCO_STATE_MAP[truco.state];
41
+ },
42
+ reset() {
43
+ Object.assign(truco, EMPTY_TRUCO);
44
+ },
45
+ sayTruco(player) {
46
+ if (truco.state === 4) {
47
+ return truco;
48
+ }
49
+ truco.turn = 0;
50
+ const playerTeamIdx = player.teamIdx;
51
+ const teamIdx = truco.teamIdx;
52
+ if (teamIdx === null || teamIdx !== playerTeamIdx) {
53
+ truco.waitingAnswer = true;
54
+ truco.state++;
55
+ const opponentIdx = Number(!playerTeamIdx);
56
+ truco.teamIdx = playerTeamIdx;
57
+ truco.answer = null;
58
+ truco.players = teams[opponentIdx].players;
59
+ truco.generator = trucoAnswerGeneratorSequence();
60
+ return truco;
61
+ }
62
+ return truco;
63
+ },
64
+ sayAnswer(player, answer) {
65
+ if (player.teamIdx === truco.teamIdx) {
66
+ return truco;
67
+ }
68
+ if (answer !== null) {
69
+ truco.currentCommands = [];
70
+ if (answer === false) {
71
+ truco.state--;
72
+ const playerTeam = teams[player.teamIdx];
73
+ playerTeam.players.forEach((player) => playerTeam.disable(player));
74
+ }
75
+ truco.waitingAnswer = false;
76
+ truco.answer = answer;
77
+ }
78
+ return truco;
79
+ },
80
+ setTeam(idx) {
81
+ truco.teamIdx = idx;
82
+ return truco.teamIdx;
83
+ },
84
+ setTurn(turn) {
85
+ truco.turn = turn;
86
+ return truco.turn;
87
+ },
88
+ setCurrentPlayer(player) {
89
+ truco.currentPlayer = player;
90
+ return truco.currentPlayer;
91
+ },
92
+ getNextPlayer() {
93
+ return truco.generator.next();
94
+ } });
95
+ return truco;
96
+ }
97
+ exports.Truco = Truco;
@@ -1,11 +1,11 @@
1
- export * from "./Deck";
2
- export * from "./GameLoop";
3
- export * from "./Hand";
4
- export * from "./Lobby";
5
- export * from "./Match";
6
- export * from "./Play";
7
- export * from "./Player";
8
- export * from "./Round";
9
- export * from "./Table";
10
- export * from "./Team";
11
- export * from "./Truco";
1
+ export * from "./Deck";
2
+ export * from "./GameLoop";
3
+ export * from "./Hand";
4
+ export * from "./Lobby";
5
+ export * from "./Match";
6
+ export * from "./Play";
7
+ export * from "./Player";
8
+ export * from "./Round";
9
+ export * from "./Table";
10
+ export * from "./Team";
11
+ export * from "./Truco";
@@ -1,27 +1,27 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./Deck"), exports);
18
- __exportStar(require("./GameLoop"), exports);
19
- __exportStar(require("./Hand"), exports);
20
- __exportStar(require("./Lobby"), exports);
21
- __exportStar(require("./Match"), exports);
22
- __exportStar(require("./Play"), exports);
23
- __exportStar(require("./Player"), exports);
24
- __exportStar(require("./Round"), exports);
25
- __exportStar(require("./Table"), exports);
26
- __exportStar(require("./Team"), exports);
27
- __exportStar(require("./Truco"), exports);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Deck"), exports);
18
+ __exportStar(require("./GameLoop"), exports);
19
+ __exportStar(require("./Hand"), exports);
20
+ __exportStar(require("./Lobby"), exports);
21
+ __exportStar(require("./Match"), exports);
22
+ __exportStar(require("./Play"), exports);
23
+ __exportStar(require("./Player"), exports);
24
+ __exportStar(require("./Round"), exports);
25
+ __exportStar(require("./Table"), exports);
26
+ __exportStar(require("./Team"), exports);
27
+ __exportStar(require("./Truco"), exports);
@@ -1,45 +1,43 @@
1
- import { IEnvidoCalculator } from "../types";
2
- export declare const CARDS: {
3
- "1e": number;
4
- "1b": number;
5
- "7e": number;
6
- "7o": number;
7
- "3e": number;
8
- "3o": number;
9
- "3b": number;
10
- "3c": number;
11
- "2e": number;
12
- "2o": number;
13
- "2b": number;
14
- "2c": number;
15
- "1o": number;
16
- "1c": number;
17
- re: number;
18
- ro: number;
19
- rb: number;
20
- rc: number;
21
- ce: number;
22
- co: number;
23
- cb: number;
24
- cc: number;
25
- pe: number;
26
- po: number;
27
- pb: number;
28
- pc: number;
29
- "7b": number;
30
- "7c": number;
31
- "6e": number;
32
- "6o": number;
33
- "6b": number;
34
- "6c": number;
35
- "5e": number;
36
- "5o": number;
37
- "5b": number;
38
- "5c": number;
39
- "4e": number;
40
- "4o": number;
41
- "4b": number;
42
- "4c": number;
43
- };
44
- export declare const TEAM_SIZE_VALUES: number[];
45
- export declare const EnvidoCalculator: IEnvidoCalculator;
1
+ export declare const CARDS: {
2
+ "1e": number;
3
+ "1b": number;
4
+ "7e": number;
5
+ "7o": number;
6
+ "3e": number;
7
+ "3o": number;
8
+ "3b": number;
9
+ "3c": number;
10
+ "2e": number;
11
+ "2o": number;
12
+ "2b": number;
13
+ "2c": number;
14
+ "1o": number;
15
+ "1c": number;
16
+ re: number;
17
+ ro: number;
18
+ rb: number;
19
+ rc: number;
20
+ ce: number;
21
+ co: number;
22
+ cb: number;
23
+ cc: number;
24
+ pe: number;
25
+ po: number;
26
+ pb: number;
27
+ pc: number;
28
+ "7b": number;
29
+ "7c": number;
30
+ "6e": number;
31
+ "6o": number;
32
+ "6b": number;
33
+ "6c": number;
34
+ "5e": number;
35
+ "5o": number;
36
+ "5b": number;
37
+ "5c": number;
38
+ "4e": number;
39
+ "4o": number;
40
+ "4b": number;
41
+ "4c": number;
42
+ };
43
+ export declare const TEAM_SIZE_VALUES: number[];
@@ -1,84 +1,46 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EnvidoCalculator = exports.TEAM_SIZE_VALUES = exports.CARDS = void 0;
4
- const types_1 = require("../types");
5
- const utils_1 = require("./utils");
6
- exports.CARDS = {
7
- "1e": 14,
8
- "1b": 13,
9
- "7e": 12,
10
- "7o": 11,
11
- "3e": 10,
12
- "3o": 10,
13
- "3b": 10,
14
- "3c": 10,
15
- "2e": 9,
16
- "2o": 9,
17
- "2b": 8,
18
- "2c": 8,
19
- "1o": 7,
20
- "1c": 7,
21
- re: 6,
22
- ro: 6,
23
- rb: 6,
24
- rc: 6,
25
- ce: 5,
26
- co: 5,
27
- cb: 5,
28
- cc: 5,
29
- pe: 4,
30
- po: 4,
31
- pb: 4,
32
- pc: 4,
33
- "7b": 3,
34
- "7c": 3,
35
- "6e": 2,
36
- "6o": 2,
37
- "6b": 2,
38
- "6c": 2,
39
- "5e": 1,
40
- "5o": 1,
41
- "5b": 1,
42
- "5c": 1,
43
- "4e": 0,
44
- "4o": 0,
45
- "4b": 0,
46
- "4c": 0,
47
- };
48
- exports.TEAM_SIZE_VALUES = [1, 2, 3];
49
- exports.EnvidoCalculator = {
50
- [types_1.EEnvidoCommand.ENVIDO]: () => ({
51
- accept: 2,
52
- decline: 1,
53
- next: [types_1.EEnvidoCommand.ENVIDO_ENVIDO, types_1.EEnvidoCommand.REAL_ENVIDO, types_1.EEnvidoCommand.FALTA_ENVIDO],
54
- }),
55
- [types_1.EEnvidoCommand.ENVIDO_ENVIDO]: () => ({
56
- accept: 4,
57
- decline: 2,
58
- next: [types_1.EEnvidoCommand.REAL_ENVIDO, types_1.EEnvidoCommand.FALTA_ENVIDO],
59
- }),
60
- [types_1.EEnvidoCommand.REAL_ENVIDO]: () => ({
61
- accept: 3,
62
- decline: 1,
63
- next: [types_1.EEnvidoCommand.FALTA_ENVIDO],
64
- }),
65
- [types_1.EEnvidoCommand.FALTA_ENVIDO]: (args) => {
66
- if (!args || !args.teams || !args.matchPoint) {
67
- return {
68
- accept: 1,
69
- decline: 1,
70
- next: [],
71
- };
72
- }
73
- const { teams, matchPoint } = args;
74
- const totals = teams.map((team) => team.points.malas + team.points.buenas);
75
- const higher = (0, utils_1.getMaxNumberIndex)(totals);
76
- const points = teams[higher].points;
77
- const accept = points.buenas > 0 ? matchPoint - points.buenas : matchPoint - points.malas;
78
- return {
79
- accept,
80
- decline: 2,
81
- next: [],
82
- };
83
- },
84
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TEAM_SIZE_VALUES = exports.CARDS = void 0;
4
+ exports.CARDS = {
5
+ "1e": 14,
6
+ "1b": 13,
7
+ "7e": 12,
8
+ "7o": 11,
9
+ "3e": 10,
10
+ "3o": 10,
11
+ "3b": 10,
12
+ "3c": 10,
13
+ "2e": 9,
14
+ "2o": 9,
15
+ "2b": 8,
16
+ "2c": 8,
17
+ "1o": 7,
18
+ "1c": 7,
19
+ re: 6,
20
+ ro: 6,
21
+ rb: 6,
22
+ rc: 6,
23
+ ce: 5,
24
+ co: 5,
25
+ cb: 5,
26
+ cc: 5,
27
+ pe: 4,
28
+ po: 4,
29
+ pb: 4,
30
+ pc: 4,
31
+ "7b": 3,
32
+ "7c": 3,
33
+ "6e": 2,
34
+ "6o": 2,
35
+ "6b": 2,
36
+ "6c": 2,
37
+ "5e": 1,
38
+ "5o": 1,
39
+ "5b": 1,
40
+ "5c": 1,
41
+ "4e": 0,
42
+ "4o": 0,
43
+ "4b": 0,
44
+ "4c": 0,
45
+ };
46
+ exports.TEAM_SIZE_VALUES = [1, 2, 3];
@@ -1,2 +1,2 @@
1
- export * from "./classes";
2
- export * from "./constants";
1
+ export * from "./classes";
2
+ export * from "./constants";
package/dist/lib/index.js CHANGED
@@ -1,18 +1,18 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./classes"), exports);
18
- __exportStar(require("./constants"), exports);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./classes"), exports);
18
+ __exportStar(require("./constants"), exports);
@@ -1,36 +1,44 @@
1
- import { ECommand, EEnvidoCommand } from "../types";
2
- import { IPlayer } from "./classes/Player";
3
- import { ITeam } from "./classes/Team";
4
- export declare enum EHandState {
5
- WAITING_PLAY = "WAITING_PLAY",
6
- WAITING_FOR_TRUCO_ANSWER = "WAITING_FOR_TRUCO_ANSWER",
7
- WAITING_ENVIDO_ANSWER = "WAITING_ENVIDO_ANSWER",
8
- FINISHED = "FINISHED"
9
- }
10
- export declare enum GAME_ERROR {
11
- MATCH_ALREADY_STARTED = "MATCH_ALREADY_STARTED",
12
- LOBBY_IS_FULL = "LOBBY_IS_FULL",
13
- UNEXPECTED_TEAM_SIZE = "UNEXPECTED_TEAM_SIZE",
14
- TEAM_NOT_READY = "TEAM_NOT_READY",
15
- TEAM_IS_FULL = "TEAM_IS_FULL"
16
- }
17
- export interface EnvidoState {
18
- accept: number;
19
- decline: number;
20
- teamIdx: 0 | 1 | null;
21
- }
22
- export type IHandCommands = {
23
- [key in ECommand]: (player: IPlayer) => void;
24
- };
25
- export type IEnvidoCalculatorResult = {
26
- accept: number;
27
- decline: number;
28
- next: Array<ECommand>;
29
- };
30
- export type IEnvidoCalculatorArgs = {
31
- teams: [ITeam, ITeam];
32
- matchPoint: number;
33
- };
34
- export type IEnvidoCalculator = {
35
- [key in EEnvidoCommand]: (args?: IEnvidoCalculatorArgs) => IEnvidoCalculatorResult;
36
- };
1
+ import { ECommand, EEnvidoCommand } from "../types";
2
+ import { IPlayer } from "./classes/Player";
3
+ import { ITeam } from "./classes/Team";
4
+ export declare enum EHandState {
5
+ WAITING_PLAY = "WAITING_PLAY",
6
+ WAITING_FOR_TRUCO_ANSWER = "WAITING_FOR_TRUCO_ANSWER",
7
+ WAITING_ENVIDO_ANSWER = "WAITING_ENVIDO_ANSWER",
8
+ FINISHED = "FINISHED"
9
+ }
10
+ export declare enum GAME_ERROR {
11
+ MATCH_ALREADY_STARTED = "MATCH_ALREADY_STARTED",
12
+ LOBBY_IS_FULL = "LOBBY_IS_FULL",
13
+ UNEXPECTED_TEAM_SIZE = "UNEXPECTED_TEAM_SIZE",
14
+ TEAM_NOT_READY = "TEAM_NOT_READY",
15
+ TEAM_IS_FULL = "TEAM_IS_FULL",
16
+ INVALID_ENVIDO_POINTS = "INVALID_ENVIDO_POINTS",
17
+ ENVIDO_NOT_ACCEPTED = "ENVIDO_NOT_ACCEPTED",
18
+ INVALID_COMAND = "INVALID_COMAND"
19
+ }
20
+ export interface EnvidoState {
21
+ accept: number;
22
+ decline: number;
23
+ teamIdx: 0 | 1 | null;
24
+ }
25
+ export type IHandCommands = {
26
+ [key in ECommand]: (player: IPlayer) => void;
27
+ };
28
+ export type IEnvidoCalculatorResult = {
29
+ accept: number;
30
+ decline: number;
31
+ replace?: number;
32
+ next: Array<ECommand>;
33
+ };
34
+ export type IFaltaEnvidoCalculatorArgs = {
35
+ teams: [ITeam, ITeam];
36
+ matchPoint: number;
37
+ };
38
+ export type IEnvidoCalculatorArgs = {
39
+ stake: number;
40
+ declineStake: number;
41
+ } & (IFaltaEnvidoCalculatorArgs | never);
42
+ export type IEnvidoCalculator = {
43
+ [key in EEnvidoCommand]: (args?: IEnvidoCalculatorArgs) => IEnvidoCalculatorResult;
44
+ };