trucoshi 0.2.11 → 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.
- package/LICENSE +674 -674
- package/README.md +60 -60
- package/dist/index.d.ts +2 -2
- package/dist/index.js +18 -18
- package/dist/lib/classes/Deck.d.ts +17 -17
- package/dist/lib/classes/Deck.js +41 -41
- package/dist/lib/classes/GameLoop.d.ts +23 -22
- package/dist/lib/classes/GameLoop.js +76 -74
- package/dist/lib/classes/Hand.d.ts +39 -38
- package/dist/lib/classes/Hand.js +192 -187
- package/dist/lib/classes/Lobby.d.ts +27 -27
- package/dist/lib/classes/Lobby.js +113 -113
- package/dist/lib/classes/Match.d.ts +20 -18
- package/dist/lib/classes/Match.js +87 -81
- package/dist/lib/classes/Play.d.ts +21 -20
- package/dist/lib/classes/Play.js +29 -28
- package/dist/lib/classes/Player.d.ts +32 -32
- package/dist/lib/classes/Player.js +79 -78
- package/dist/lib/classes/Round.d.ts +17 -17
- package/dist/lib/classes/Round.js +33 -33
- package/dist/lib/classes/Table.d.ts +12 -12
- package/dist/lib/classes/Table.js +30 -30
- package/dist/lib/classes/Team.d.ts +20 -20
- package/dist/lib/classes/Team.js +59 -59
- package/dist/lib/classes/Truco.d.ts +21 -20
- package/dist/lib/classes/Truco.js +131 -126
- package/dist/lib/classes/index.d.ts +11 -11
- package/dist/lib/classes/index.js +27 -27
- package/dist/lib/constants.d.ts +45 -45
- package/dist/lib/constants.js +84 -84
- package/dist/lib/index.d.ts +2 -2
- package/dist/lib/index.js +18 -18
- package/dist/lib/types.d.ts +50 -50
- package/dist/lib/types.js +34 -34
- package/dist/lib/utils.d.ts +5 -5
- package/dist/lib/utils.js +58 -58
- package/dist/types.d.ts +173 -167
- package/dist/types.js +106 -98
- package/package.json +2 -2
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
|
-
[] Cantar truco
|
|
44
|
-
[] Cantar envido
|
|
45
|
-
[] Cantar flor
|
|
46
|
-
[x] Socket server
|
|
47
|
-
[] Bitcoin Lightning integration
|
|
48
|
-
[] Unit tests
|
|
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
|
+
[] Cantar truco
|
|
44
|
+
[] Cantar envido
|
|
45
|
+
[] Cantar flor
|
|
46
|
+
[x] Socket server
|
|
47
|
+
[] Bitcoin Lightning integration
|
|
48
|
+
[] Unit tests
|
|
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, card: ICard): IPlayedCard;
|
package/dist/lib/classes/Deck.js
CHANGED
|
@@ -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.
|
|
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,22 +1,23 @@
|
|
|
1
|
-
import { IHand } from "./Hand";
|
|
2
|
-
import { IMatch } from "./Match";
|
|
3
|
-
import { IPlayInstance } from "./Play";
|
|
4
|
-
import { IPlayer } from "./Player";
|
|
5
|
-
import { ITeam } from "./Team";
|
|
6
|
-
export type IWinnerCallback = (winner: ITeam, teams: [ITeam, ITeam]) => Promise<void>;
|
|
7
|
-
export type ITurnCallback = (play: IPlayInstance) => Promise<void>;
|
|
8
|
-
export type ITrucoCallback = (play: IPlayInstance) => Promise<void>;
|
|
9
|
-
export interface IGameLoop {
|
|
10
|
-
_onTruco: ITrucoCallback;
|
|
11
|
-
_onTurn: ITurnCallback;
|
|
12
|
-
_onWinner: IWinnerCallback;
|
|
13
|
-
currentPlayer: IPlayer | null;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
import { IHand } from "./Hand";
|
|
2
|
+
import { IMatch } from "./Match";
|
|
3
|
+
import { IPlayInstance } from "./Play";
|
|
4
|
+
import { IPlayer } from "./Player";
|
|
5
|
+
import { ITeam } from "./Team";
|
|
6
|
+
export type IWinnerCallback = (winner: ITeam, teams: [ITeam, ITeam]) => Promise<void>;
|
|
7
|
+
export type ITurnCallback = (play: IPlayInstance) => Promise<void>;
|
|
8
|
+
export type ITrucoCallback = (play: IPlayInstance) => Promise<void>;
|
|
9
|
+
export interface IGameLoop {
|
|
10
|
+
_onTruco: ITrucoCallback;
|
|
11
|
+
_onTurn: ITurnCallback;
|
|
12
|
+
_onWinner: IWinnerCallback;
|
|
13
|
+
currentPlayer: IPlayer | null;
|
|
14
|
+
currentHand: IHand | null;
|
|
15
|
+
previousHand: IHand | null;
|
|
16
|
+
teams: Array<ITeam>;
|
|
17
|
+
winner: ITeam | null;
|
|
18
|
+
onTurn: (callback: ITurnCallback) => IGameLoop;
|
|
19
|
+
onWinner: (callback: IWinnerCallback) => IGameLoop;
|
|
20
|
+
onTruco: (callback: ITrucoCallback) => IGameLoop;
|
|
21
|
+
begin: () => Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
export declare const GameLoop: (match: IMatch) => IGameLoop;
|
|
@@ -1,74 +1,76 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.GameLoop = void 0;
|
|
13
|
-
const types_1 = require("../../types");
|
|
14
|
-
const GameLoop = (match) => {
|
|
15
|
-
let gameloop = {
|
|
16
|
-
_onTruco: () => Promise.resolve(),
|
|
17
|
-
_onTurn: () => Promise.resolve(),
|
|
18
|
-
_onWinner: () => Promise.resolve(),
|
|
19
|
-
teams: [],
|
|
20
|
-
winner: null,
|
|
21
|
-
currentPlayer: null,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
};
|
|
74
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.GameLoop = void 0;
|
|
13
|
+
const types_1 = require("../../types");
|
|
14
|
+
const GameLoop = (match) => {
|
|
15
|
+
let gameloop = {
|
|
16
|
+
_onTruco: () => Promise.resolve(),
|
|
17
|
+
_onTurn: () => Promise.resolve(),
|
|
18
|
+
_onWinner: () => Promise.resolve(),
|
|
19
|
+
teams: [],
|
|
20
|
+
winner: null,
|
|
21
|
+
currentPlayer: null,
|
|
22
|
+
currentHand: null,
|
|
23
|
+
previousHand: null,
|
|
24
|
+
onTruco: (callback) => {
|
|
25
|
+
gameloop._onTruco = callback;
|
|
26
|
+
return gameloop;
|
|
27
|
+
},
|
|
28
|
+
onTurn: (callback) => {
|
|
29
|
+
gameloop._onTurn = callback;
|
|
30
|
+
return gameloop;
|
|
31
|
+
},
|
|
32
|
+
onWinner: (callback) => {
|
|
33
|
+
gameloop._onWinner = callback;
|
|
34
|
+
return gameloop;
|
|
35
|
+
},
|
|
36
|
+
begin() {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
gameloop.teams = match.teams;
|
|
39
|
+
while (!match.winner) {
|
|
40
|
+
const play = match.play();
|
|
41
|
+
gameloop.currentHand = match.currentHand;
|
|
42
|
+
if (!play || !play.player) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
gameloop.currentPlayer = play.player;
|
|
46
|
+
if (play.state === types_1.EHandState.WAITING_FOR_TRUCO_ANSWER) {
|
|
47
|
+
try {
|
|
48
|
+
yield gameloop._onTruco(play);
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
console.error("GAME LOOP ERROR", e);
|
|
52
|
+
}
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (play.state === types_1.EHandState.WAITING_PLAY) {
|
|
56
|
+
play.player.setTurn(true);
|
|
57
|
+
try {
|
|
58
|
+
yield gameloop._onTurn(play);
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
console.error("GAME LOOP ERROR", e);
|
|
62
|
+
}
|
|
63
|
+
gameloop.previousHand = match.prevHand;
|
|
64
|
+
play.player.setTurn(false);
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
gameloop.winner = match.winner;
|
|
69
|
+
gameloop.currentPlayer = null;
|
|
70
|
+
yield gameloop._onWinner(match.winner, match.teams);
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
return gameloop;
|
|
75
|
+
};
|
|
76
|
+
exports.GameLoop = GameLoop;
|
|
@@ -1,38 +1,39 @@
|
|
|
1
|
-
import { EHandState, EnvidoState, IHandCommands } from "../../types";
|
|
2
|
-
import { ICard, IDeck } from "./Deck";
|
|
3
|
-
import { IMatch } from "./Match";
|
|
4
|
-
import { IPlayInstance } from "./Play";
|
|
5
|
-
import { IPlayer } from "./Player";
|
|
6
|
-
import { IRound } from "./Round";
|
|
7
|
-
import { ITruco } from "./Truco";
|
|
8
|
-
export interface IHandPoints {
|
|
9
|
-
0: number;
|
|
10
|
-
1: number;
|
|
11
|
-
}
|
|
12
|
-
export interface IHand {
|
|
13
|
-
idx: number;
|
|
14
|
-
state: EHandState;
|
|
15
|
-
turn: number;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
1
|
+
import { EHandState, EnvidoState, IHandCommands } from "../../types";
|
|
2
|
+
import { ICard, IDeck } from "./Deck";
|
|
3
|
+
import { IMatch } from "./Match";
|
|
4
|
+
import { IPlayInstance } from "./Play";
|
|
5
|
+
import { IPlayer } from "./Player";
|
|
6
|
+
import { IRound } from "./Round";
|
|
7
|
+
import { ITruco } from "./Truco";
|
|
8
|
+
export interface IHandPoints {
|
|
9
|
+
0: number;
|
|
10
|
+
1: number;
|
|
11
|
+
}
|
|
12
|
+
export interface IHand {
|
|
13
|
+
idx: number;
|
|
14
|
+
state: EHandState;
|
|
15
|
+
turn: number;
|
|
16
|
+
started: boolean;
|
|
17
|
+
points: IHandPoints;
|
|
18
|
+
truco: ITruco;
|
|
19
|
+
envido: EnvidoState;
|
|
20
|
+
rounds: Array<IRound>;
|
|
21
|
+
_currentPlayer: IPlayer | null;
|
|
22
|
+
get currentPlayer(): IPlayer | null;
|
|
23
|
+
set currentPlayer(player: IPlayer | null);
|
|
24
|
+
currentRound: IRound | null;
|
|
25
|
+
commands: IHandCommands;
|
|
26
|
+
finished: () => boolean;
|
|
27
|
+
play(prevHand: IHand | null): IPlayInstance | null;
|
|
28
|
+
nextTurn(): void;
|
|
29
|
+
use(idx: number, card: ICard): ICard | null;
|
|
30
|
+
pushRound(round: IRound): IRound;
|
|
31
|
+
setTurn(turn: number): IPlayer;
|
|
32
|
+
addPoints(team: 0 | 1, points: number): void;
|
|
33
|
+
disablePlayer(player: IPlayer): void;
|
|
34
|
+
setCurrentRound(round: IRound | null): IRound | null;
|
|
35
|
+
setCurrentPlayer(player: IPlayer | null): IPlayer | null;
|
|
36
|
+
setState(state: EHandState): EHandState;
|
|
37
|
+
getNextPlayer(): IteratorResult<IHand, IHand | void>;
|
|
38
|
+
}
|
|
39
|
+
export declare function Hand(match: IMatch, deck: IDeck, idx: number): IHand;
|