trucoshi 0.3.4 → 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 (42) 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 -34
  8. package/dist/lib/classes/Envido.js +168 -167
  9. package/dist/lib/classes/Flor.js +1 -1
  10. package/dist/lib/classes/GameLoop.d.ts +26 -26
  11. package/dist/lib/classes/GameLoop.js +106 -105
  12. package/dist/lib/classes/Hand.d.ts +43 -43
  13. package/dist/lib/classes/Hand.js +295 -295
  14. package/dist/lib/classes/Lobby.d.ts +27 -27
  15. package/dist/lib/classes/Lobby.js +113 -113
  16. package/dist/lib/classes/Match.d.ts +21 -21
  17. package/dist/lib/classes/Match.js +88 -88
  18. package/dist/lib/classes/Play.d.ts +22 -22
  19. package/dist/lib/classes/Play.js +44 -44
  20. package/dist/lib/classes/Player.d.ts +35 -35
  21. package/dist/lib/classes/Player.js +126 -126
  22. package/dist/lib/classes/Round.d.ts +17 -17
  23. package/dist/lib/classes/Round.js +33 -33
  24. package/dist/lib/classes/Table.d.ts +12 -12
  25. package/dist/lib/classes/Table.js +38 -38
  26. package/dist/lib/classes/Team.d.ts +20 -20
  27. package/dist/lib/classes/Team.js +59 -59
  28. package/dist/lib/classes/Truco.d.ts +30 -30
  29. package/dist/lib/classes/Truco.js +97 -97
  30. package/dist/lib/classes/index.d.ts +11 -11
  31. package/dist/lib/classes/index.js +27 -27
  32. package/dist/lib/constants.d.ts +43 -43
  33. package/dist/lib/constants.js +46 -46
  34. package/dist/lib/index.d.ts +2 -2
  35. package/dist/lib/index.js +18 -18
  36. package/dist/lib/types.d.ts +44 -44
  37. package/dist/lib/types.js +21 -21
  38. package/dist/lib/utils.d.ts +5 -5
  39. package/dist/lib/utils.js +58 -58
  40. package/dist/types.d.ts +193 -184
  41. package/dist/types.js +123 -121
  42. package/package.json +1 -1
package/README.md CHANGED
@@ -1,60 +1,60 @@
1
- # Trucoshi
2
-
3
- ### English
4
-
5
- Work in progress
6
-
7
- Pretends to be an Argentinian Truco game socket server that allows you to put Satoshis on the table ;)
8
-
9
- Try current demo at [Trucoshi](https://trucoshi.com)
10
-
11
- ### Spanish
12
-
13
- En construccion
14
-
15
- Pretende ser un server basado en sockets del juego de Truco Argentino que te permita poner unos Satoshis en la mesa ;)
16
-
17
- Proba la demo actual en [Trucoshi](https://trucoshi.com)
18
-
19
- # Test
20
-
21
- Right now there's only a local CLI way of playing as there is no socket server implementation and its just the game logic.
22
-
23
- ### Installation
24
-
25
- `yarn`
26
-
27
- ### Build
28
-
29
- `yarn build`
30
-
31
- ### Play
32
-
33
- `yarn test:play`
34
-
35
- ### Autoplay
36
-
37
- `yarn test:autoplay`
38
-
39
- # Todo
40
-
41
- [x] Logica de turnos, rondas y battalla de cartas
42
- [x] Irse al mazo
43
- [x] Cantar truco
44
- [] Cantar envido
45
- [] Cantar flor
46
- [x] Socket server
47
- [-] Unit tests
48
- [] Bitcoin Lightning integration
49
-
50
- # Donations
51
-
52
- Donate Bitcoin at [jfrader.com](https://jfrader.com)
53
-
54
- # License
55
-
56
- This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
57
-
58
- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
59
-
60
- You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
1
+ # Trucoshi
2
+
3
+ ### English
4
+
5
+ Work in progress
6
+
7
+ Pretends to be an Argentinian Truco game socket server that allows you to put Satoshis on the table ;)
8
+
9
+ Try current demo at [Trucoshi](https://trucoshi.com)
10
+
11
+ ### Spanish
12
+
13
+ En construccion
14
+
15
+ Pretende ser un server basado en sockets del juego de Truco Argentino que te permita poner unos Satoshis en la mesa ;)
16
+
17
+ Proba la demo actual en [Trucoshi](https://trucoshi.com)
18
+
19
+ # Test
20
+
21
+ Right now there's only a local CLI way of playing as there is no socket server implementation and its just the game logic.
22
+
23
+ ### Installation
24
+
25
+ `yarn`
26
+
27
+ ### Build
28
+
29
+ `yarn build`
30
+
31
+ ### Play
32
+
33
+ `yarn test:play`
34
+
35
+ ### Autoplay
36
+
37
+ `yarn test:autoplay`
38
+
39
+ # Todo
40
+
41
+ [x] Logica de turnos, rondas y battalla de cartas
42
+ [x] Irse al mazo
43
+ [x] Cantar truco
44
+ [] Cantar envido
45
+ [] Cantar flor
46
+ [x] Socket server
47
+ [-] Unit tests
48
+ [] Bitcoin Lightning integration
49
+
50
+ # Donations
51
+
52
+ Donate Bitcoin at [jfrader.com](https://jfrader.com)
53
+
54
+ # License
55
+
56
+ This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
57
+
58
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
59
+
60
+ You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from "./lib";
2
- export * from "./types";
1
+ export * from "./lib";
2
+ export * from "./types";
package/dist/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("./lib"), exports);
18
- __exportStar(require("./types"), 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("./lib"), exports);
18
+ __exportStar(require("./types"), exports);
@@ -1,17 +1,17 @@
1
- import { CARDS } from "../constants";
2
- import { IPlayer, IPublicPlayer } from "./Player";
3
- export interface IDeck {
4
- cards: Array<ICard>;
5
- usedCards: Array<ICard>;
6
- takeCard(): ICard;
7
- takeThree(): [ICard, ICard, ICard];
8
- shuffle(): IDeck;
9
- }
10
- export type ICard = keyof typeof CARDS;
11
- export interface IPlayedCard {
12
- get key(): string;
13
- player: IPlayer & IPublicPlayer;
14
- card: ICard;
15
- }
16
- export declare function Deck(): IDeck;
17
- export declare function PlayedCard(player: IPlayer, card: ICard): IPlayedCard;
1
+ import { CARDS } from "../constants";
2
+ import { IPlayer, IPublicPlayer } from "./Player";
3
+ export interface IDeck {
4
+ cards: Array<ICard>;
5
+ usedCards: Array<ICard>;
6
+ takeCard(): ICard;
7
+ takeThree(): [ICard, ICard, ICard];
8
+ shuffle(): IDeck;
9
+ }
10
+ export type ICard = keyof typeof CARDS;
11
+ export interface IPlayedCard {
12
+ get key(): string;
13
+ player: IPlayer | IPublicPlayer;
14
+ card: ICard;
15
+ }
16
+ export declare function Deck(): IDeck;
17
+ export declare function PlayedCard(player: IPlayer | IPublicPlayer, card: ICard): IPlayedCard;
@@ -1,41 +1,41 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PlayedCard = exports.Deck = void 0;
4
- const constants_1 = require("../constants");
5
- const utils_1 = require("../utils");
6
- function Deck() {
7
- const deck = {
8
- cards: Object.keys(constants_1.CARDS),
9
- usedCards: [],
10
- takeCard() {
11
- const card = deck.cards.shift();
12
- deck.usedCards.push(card);
13
- return card;
14
- },
15
- takeThree() {
16
- return [deck.takeCard(), deck.takeCard(), deck.takeCard()];
17
- },
18
- shuffle() {
19
- deck.cards = deck.cards.concat(deck.usedCards);
20
- deck.usedCards = [];
21
- deck.cards = (0, utils_1.shuffleArray)(deck.cards);
22
- if (deck.cards.length !== 40) {
23
- throw new Error("This is not good");
24
- }
25
- return deck;
26
- },
27
- };
28
- return deck;
29
- }
30
- exports.Deck = Deck;
31
- function PlayedCard(player, card) {
32
- const pc = {
33
- player,
34
- card,
35
- get key() {
36
- return card + player.key;
37
- },
38
- };
39
- return pc;
40
- }
41
- exports.PlayedCard = PlayedCard;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PlayedCard = exports.Deck = void 0;
4
+ const constants_1 = require("../constants");
5
+ const utils_1 = require("../utils");
6
+ function Deck() {
7
+ const deck = {
8
+ cards: Object.keys(constants_1.CARDS),
9
+ usedCards: [],
10
+ takeCard() {
11
+ const card = deck.cards.shift();
12
+ deck.usedCards.push(card);
13
+ return card;
14
+ },
15
+ takeThree() {
16
+ return [deck.takeCard(), deck.takeCard(), deck.takeCard()];
17
+ },
18
+ shuffle() {
19
+ deck.cards = deck.cards.concat(deck.usedCards);
20
+ deck.usedCards = [];
21
+ deck.cards = (0, utils_1.shuffleArray)(deck.cards);
22
+ if (deck.cards.length !== 40) {
23
+ throw new Error("This is not good");
24
+ }
25
+ return deck;
26
+ },
27
+ };
28
+ return deck;
29
+ }
30
+ exports.Deck = Deck;
31
+ function PlayedCard(player, card) {
32
+ const pc = {
33
+ player,
34
+ card,
35
+ get key() {
36
+ return card + player.key;
37
+ },
38
+ };
39
+ return pc;
40
+ }
41
+ exports.PlayedCard = PlayedCard;
@@ -1,34 +1,34 @@
1
- import { ECommand, EEnvidoCommand } from "../../types";
2
- import { IEnvidoCalculator } from "../types";
3
- import { IPlayer } from "./Player";
4
- import { ITable } from "./Table";
5
- import { ITeam } from "./Team";
6
- export interface IEnvido {
7
- started: boolean;
8
- accepted: boolean;
9
- answered: boolean;
10
- finished: boolean;
11
- possibleAnswerCommands: Array<ECommand>;
12
- stake: number;
13
- declineStake: number;
14
- teamIdx: 0 | 1 | null;
15
- answer: boolean | null;
16
- pointAnswersCount: number;
17
- winningPointsAnswer: number;
18
- turn: number;
19
- winningPlayer: IPlayer | null;
20
- winner: ITeam | null;
21
- teams: [ITeam, ITeam];
22
- players: Array<IPlayer>;
23
- currentPlayer: IPlayer | null;
24
- generator: Generator<IEnvido, void, unknown>;
25
- sayPoints(player: IPlayer, points: number): IEnvido;
26
- sayEnvido(command: EEnvidoCommand, player: IPlayer): IEnvido;
27
- sayAnswer(player: IPlayer, answer: boolean | null): IEnvido;
28
- setTurn(turn: number): number;
29
- setTeam(idx: 0 | 1): 0 | 1;
30
- setCurrentPlayer(player: IPlayer | null): IPlayer | null;
31
- getNextPlayer(): IteratorResult<IEnvido, IEnvido | void>;
32
- }
33
- export declare const EnvidoCalculator: IEnvidoCalculator;
34
- export declare function Envido(teams: [ITeam, ITeam], matchPoint: number, table: ITable): IEnvido;
1
+ import { ECommand, EEnvidoCommand } from "../../types";
2
+ import { IEnvidoCalculator } from "../types";
3
+ import { IPlayer } from "./Player";
4
+ import { ITable } from "./Table";
5
+ import { ITeam } from "./Team";
6
+ export interface IEnvido {
7
+ started: boolean;
8
+ accepted: boolean;
9
+ answered: boolean;
10
+ finished: boolean;
11
+ possibleAnswerCommands: Array<ECommand>;
12
+ stake: number;
13
+ declineStake: number;
14
+ teamIdx: 0 | 1 | null;
15
+ answer: boolean | null;
16
+ pointAnswersCount: number;
17
+ winningPointsAnswer: number;
18
+ turn: number;
19
+ winningPlayer: IPlayer | null;
20
+ winner: ITeam | null;
21
+ teams: [ITeam, ITeam];
22
+ players: Array<IPlayer>;
23
+ currentPlayer: IPlayer | null;
24
+ generator: Generator<IEnvido, void, unknown>;
25
+ sayPoints(player: IPlayer, points: number): IEnvido;
26
+ sayEnvido(command: EEnvidoCommand, player: IPlayer): IEnvido;
27
+ sayAnswer(player: IPlayer, answer: boolean | null): IEnvido;
28
+ setTurn(turn: number): number;
29
+ setTeam(idx: 0 | 1): 0 | 1;
30
+ setCurrentPlayer(player: IPlayer | null): IPlayer | null;
31
+ getNextPlayer(): IteratorResult<IEnvido, IEnvido | void>;
32
+ }
33
+ export declare const EnvidoCalculator: IEnvidoCalculator;
34
+ export declare function Envido(teams: [ITeam, ITeam], matchPoint: number, table: ITable): IEnvido;