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.
- 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 -64
- package/dist/lib/classes/Hand.d.ts +39 -38
- package/dist/lib/classes/Hand.js +192 -188
- 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 -26
- 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 -19
- package/dist/lib/classes/Truco.js +131 -123
- 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
|
@@ -1,78 +1,79 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Player = void 0;
|
|
4
|
-
function Player(key, id, teamIdx, isOwner = false) {
|
|
5
|
-
const player = {
|
|
6
|
-
key,
|
|
7
|
-
id,
|
|
8
|
-
session: undefined,
|
|
9
|
-
teamIdx,
|
|
10
|
-
hand: [],
|
|
11
|
-
_commands: new Set(),
|
|
12
|
-
usedHand: [],
|
|
13
|
-
prevHand: [],
|
|
14
|
-
isOwner,
|
|
15
|
-
isTurn: false,
|
|
16
|
-
disabled: false,
|
|
17
|
-
connected: false,
|
|
18
|
-
ready: false,
|
|
19
|
-
get commands() {
|
|
20
|
-
return Array.from(player._commands.values());
|
|
21
|
-
},
|
|
22
|
-
setOwner(owner) {
|
|
23
|
-
player.isOwner = owner;
|
|
24
|
-
},
|
|
25
|
-
setTurn(turn) {
|
|
26
|
-
player.isTurn = turn;
|
|
27
|
-
},
|
|
28
|
-
getPublicPlayer() {
|
|
29
|
-
const { id, key, commands, connected, disabled, ready, usedHand, prevHand, teamIdx, isTurn, isOwner, } = player;
|
|
30
|
-
return {
|
|
31
|
-
id,
|
|
32
|
-
key,
|
|
33
|
-
connected,
|
|
34
|
-
commands,
|
|
35
|
-
disabled,
|
|
36
|
-
ready,
|
|
37
|
-
usedHand,
|
|
38
|
-
prevHand,
|
|
39
|
-
teamIdx,
|
|
40
|
-
isTurn,
|
|
41
|
-
isOwner,
|
|
42
|
-
hand: player.hand.map(() => "xx"),
|
|
43
|
-
session: undefined,
|
|
44
|
-
};
|
|
45
|
-
},
|
|
46
|
-
setSession(session) {
|
|
47
|
-
player.session = session;
|
|
48
|
-
},
|
|
49
|
-
enable() {
|
|
50
|
-
player.disabled = false;
|
|
51
|
-
},
|
|
52
|
-
disable() {
|
|
53
|
-
player.disabled = true;
|
|
54
|
-
},
|
|
55
|
-
setConnected(connected) {
|
|
56
|
-
player.connected = connected;
|
|
57
|
-
},
|
|
58
|
-
setReady(ready) {
|
|
59
|
-
player.ready = ready;
|
|
60
|
-
},
|
|
61
|
-
setHand(hand) {
|
|
62
|
-
player.prevHand = [...player.usedHand];
|
|
63
|
-
player.hand = hand;
|
|
64
|
-
player.usedHand = [];
|
|
65
|
-
return hand;
|
|
66
|
-
},
|
|
67
|
-
useCard(idx, card) {
|
|
68
|
-
if (player.hand[idx] && player.hand[idx] === card) {
|
|
69
|
-
const card = player.hand.splice(idx, 1)[0];
|
|
70
|
-
player.usedHand.push(card);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Player = void 0;
|
|
4
|
+
function Player(key, id, teamIdx, isOwner = false) {
|
|
5
|
+
const player = {
|
|
6
|
+
key,
|
|
7
|
+
id,
|
|
8
|
+
session: undefined,
|
|
9
|
+
teamIdx,
|
|
10
|
+
hand: [],
|
|
11
|
+
_commands: new Set(),
|
|
12
|
+
usedHand: [],
|
|
13
|
+
prevHand: [],
|
|
14
|
+
isOwner,
|
|
15
|
+
isTurn: false,
|
|
16
|
+
disabled: false,
|
|
17
|
+
connected: false,
|
|
18
|
+
ready: false,
|
|
19
|
+
get commands() {
|
|
20
|
+
return Array.from(player._commands.values());
|
|
21
|
+
},
|
|
22
|
+
setOwner(owner) {
|
|
23
|
+
player.isOwner = owner;
|
|
24
|
+
},
|
|
25
|
+
setTurn(turn) {
|
|
26
|
+
player.isTurn = turn;
|
|
27
|
+
},
|
|
28
|
+
getPublicPlayer() {
|
|
29
|
+
const { id, key, commands, connected, disabled, ready, usedHand, prevHand, teamIdx, isTurn, isOwner, } = player;
|
|
30
|
+
return {
|
|
31
|
+
id,
|
|
32
|
+
key,
|
|
33
|
+
connected,
|
|
34
|
+
commands,
|
|
35
|
+
disabled,
|
|
36
|
+
ready,
|
|
37
|
+
usedHand,
|
|
38
|
+
prevHand,
|
|
39
|
+
teamIdx,
|
|
40
|
+
isTurn,
|
|
41
|
+
isOwner,
|
|
42
|
+
hand: player.hand.map(() => "xx"),
|
|
43
|
+
session: undefined,
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
setSession(session) {
|
|
47
|
+
player.session = session;
|
|
48
|
+
},
|
|
49
|
+
enable() {
|
|
50
|
+
player.disabled = false;
|
|
51
|
+
},
|
|
52
|
+
disable() {
|
|
53
|
+
player.disabled = true;
|
|
54
|
+
},
|
|
55
|
+
setConnected(connected) {
|
|
56
|
+
player.connected = connected;
|
|
57
|
+
},
|
|
58
|
+
setReady(ready) {
|
|
59
|
+
player.ready = ready;
|
|
60
|
+
},
|
|
61
|
+
setHand(hand) {
|
|
62
|
+
player.prevHand = [...player.usedHand];
|
|
63
|
+
player.hand = hand;
|
|
64
|
+
player.usedHand = [];
|
|
65
|
+
return hand;
|
|
66
|
+
},
|
|
67
|
+
useCard(idx, card) {
|
|
68
|
+
if (player.hand[idx] && player.hand[idx] === card) {
|
|
69
|
+
const card = player.hand.splice(idx, 1)[0];
|
|
70
|
+
player.usedHand.push(card);
|
|
71
|
+
player.isTurn = false;
|
|
72
|
+
return card;
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
return player;
|
|
78
|
+
}
|
|
79
|
+
exports.Player = Player;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { ICard, IPlayedCard } from "./Deck";
|
|
2
|
-
import { IPlayer } from "./Player";
|
|
3
|
-
export interface IRound {
|
|
4
|
-
tie: boolean;
|
|
5
|
-
winner: IPlayer | null;
|
|
6
|
-
highest: number;
|
|
7
|
-
cards: Array<IPlayedCard>;
|
|
8
|
-
turn: number;
|
|
9
|
-
nextTurn(): void;
|
|
10
|
-
use(playedCard: IPlayedCard): ICard;
|
|
11
|
-
}
|
|
12
|
-
export interface IRoundPoints {
|
|
13
|
-
0: number;
|
|
14
|
-
1: number;
|
|
15
|
-
ties: number;
|
|
16
|
-
}
|
|
17
|
-
export declare function Round(): IRound;
|
|
1
|
+
import { ICard, IPlayedCard } from "./Deck";
|
|
2
|
+
import { IPlayer } from "./Player";
|
|
3
|
+
export interface IRound {
|
|
4
|
+
tie: boolean;
|
|
5
|
+
winner: IPlayer | null;
|
|
6
|
+
highest: number;
|
|
7
|
+
cards: Array<IPlayedCard>;
|
|
8
|
+
turn: number;
|
|
9
|
+
nextTurn(): void;
|
|
10
|
+
use(playedCard: IPlayedCard): ICard;
|
|
11
|
+
}
|
|
12
|
+
export interface IRoundPoints {
|
|
13
|
+
0: number;
|
|
14
|
+
1: number;
|
|
15
|
+
ties: number;
|
|
16
|
+
}
|
|
17
|
+
export declare function Round(): IRound;
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Round = void 0;
|
|
4
|
-
const utils_1 = require("../utils");
|
|
5
|
-
const Deck_1 = require("./Deck");
|
|
6
|
-
function Round() {
|
|
7
|
-
const round = {
|
|
8
|
-
turn: 0,
|
|
9
|
-
highest: -1,
|
|
10
|
-
winner: null,
|
|
11
|
-
cards: [],
|
|
12
|
-
tie: false,
|
|
13
|
-
nextTurn() {
|
|
14
|
-
round.turn++;
|
|
15
|
-
},
|
|
16
|
-
use({ card, player }) {
|
|
17
|
-
var _a;
|
|
18
|
-
const value = (0, utils_1.getCardValue)(card);
|
|
19
|
-
if (value === round.highest && player.teamIdx !== ((_a = round.winner) === null || _a === void 0 ? void 0 : _a.teamIdx)) {
|
|
20
|
-
round.tie = true;
|
|
21
|
-
}
|
|
22
|
-
if (value > round.highest) {
|
|
23
|
-
round.tie = false;
|
|
24
|
-
round.highest = value;
|
|
25
|
-
round.winner = player;
|
|
26
|
-
}
|
|
27
|
-
round.cards.push((0, Deck_1.PlayedCard)(player, card));
|
|
28
|
-
return card;
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
return round;
|
|
32
|
-
}
|
|
33
|
-
exports.Round = Round;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Round = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const Deck_1 = require("./Deck");
|
|
6
|
+
function Round() {
|
|
7
|
+
const round = {
|
|
8
|
+
turn: 0,
|
|
9
|
+
highest: -1,
|
|
10
|
+
winner: null,
|
|
11
|
+
cards: [],
|
|
12
|
+
tie: false,
|
|
13
|
+
nextTurn() {
|
|
14
|
+
round.turn++;
|
|
15
|
+
},
|
|
16
|
+
use({ card, player }) {
|
|
17
|
+
var _a;
|
|
18
|
+
const value = (0, utils_1.getCardValue)(card);
|
|
19
|
+
if (value === round.highest && player.teamIdx !== ((_a = round.winner) === null || _a === void 0 ? void 0 : _a.teamIdx)) {
|
|
20
|
+
round.tie = true;
|
|
21
|
+
}
|
|
22
|
+
if (value > round.highest) {
|
|
23
|
+
round.tie = false;
|
|
24
|
+
round.highest = value;
|
|
25
|
+
round.winner = player;
|
|
26
|
+
}
|
|
27
|
+
round.cards.push((0, Deck_1.PlayedCard)(player, card));
|
|
28
|
+
return card;
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
return round;
|
|
32
|
+
}
|
|
33
|
+
exports.Round = Round;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { IPlayedCard } from "./Deck";
|
|
2
|
-
import { IPlayer } from "./Player";
|
|
3
|
-
import { ITeam } from "./Team";
|
|
4
|
-
export interface ITable {
|
|
5
|
-
forehandIdx: number;
|
|
6
|
-
cards: Array<Array<IPlayedCard>>;
|
|
7
|
-
players: Array<IPlayer>;
|
|
8
|
-
nextTurn(): IPlayer;
|
|
9
|
-
player(idx?: number): IPlayer;
|
|
10
|
-
getPlayerPosition(id: string): number;
|
|
11
|
-
}
|
|
12
|
-
export declare function Table(players: Array<IPlayer>, teams: Array<ITeam>): ITable;
|
|
1
|
+
import { IPlayedCard } from "./Deck";
|
|
2
|
+
import { IPlayer } from "./Player";
|
|
3
|
+
import { ITeam } from "./Team";
|
|
4
|
+
export interface ITable {
|
|
5
|
+
forehandIdx: number;
|
|
6
|
+
cards: Array<Array<IPlayedCard>>;
|
|
7
|
+
players: Array<IPlayer>;
|
|
8
|
+
nextTurn(): IPlayer;
|
|
9
|
+
player(idx?: number): IPlayer;
|
|
10
|
+
getPlayerPosition(id: string): number;
|
|
11
|
+
}
|
|
12
|
+
export declare function Table(players: Array<IPlayer>, teams: Array<ITeam>): ITable;
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Table = void 0;
|
|
4
|
-
function Table(players, teams) {
|
|
5
|
-
const table = {
|
|
6
|
-
players,
|
|
7
|
-
cards: [],
|
|
8
|
-
forehandIdx: 0,
|
|
9
|
-
nextTurn() {
|
|
10
|
-
if (table.forehandIdx < table.players.length - 1) {
|
|
11
|
-
table.forehandIdx++;
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
table.forehandIdx = 0;
|
|
15
|
-
}
|
|
16
|
-
return table.player();
|
|
17
|
-
},
|
|
18
|
-
getPlayerPosition(id) {
|
|
19
|
-
return table.players.findIndex((p) => p.id === id);
|
|
20
|
-
},
|
|
21
|
-
player(idx) {
|
|
22
|
-
if (idx !== undefined) {
|
|
23
|
-
return table.players[idx];
|
|
24
|
-
}
|
|
25
|
-
return table.players[table.forehandIdx];
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
return table;
|
|
29
|
-
}
|
|
30
|
-
exports.Table = Table;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Table = void 0;
|
|
4
|
+
function Table(players, teams) {
|
|
5
|
+
const table = {
|
|
6
|
+
players,
|
|
7
|
+
cards: [],
|
|
8
|
+
forehandIdx: 0,
|
|
9
|
+
nextTurn() {
|
|
10
|
+
if (table.forehandIdx < table.players.length - 1) {
|
|
11
|
+
table.forehandIdx++;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
table.forehandIdx = 0;
|
|
15
|
+
}
|
|
16
|
+
return table.player();
|
|
17
|
+
},
|
|
18
|
+
getPlayerPosition(id) {
|
|
19
|
+
return table.players.findIndex((p) => p.id === id);
|
|
20
|
+
},
|
|
21
|
+
player(idx) {
|
|
22
|
+
if (idx !== undefined) {
|
|
23
|
+
return table.players[idx];
|
|
24
|
+
}
|
|
25
|
+
return table.players[table.forehandIdx];
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
return table;
|
|
29
|
+
}
|
|
30
|
+
exports.Table = Table;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { IPlayer, IPublicPlayer } from "./Player";
|
|
2
|
-
export interface ITeam {
|
|
3
|
-
_players: Map<string, IPlayer>;
|
|
4
|
-
players: Array<IPlayer>;
|
|
5
|
-
points: ITeamPoints;
|
|
6
|
-
getPublicTeam(playerSession?: string): IPublicTeam;
|
|
7
|
-
isTeamDisabled(): boolean;
|
|
8
|
-
disable(player: IPlayer): boolean;
|
|
9
|
-
enable(player?: IPlayer): boolean;
|
|
10
|
-
addPoints(matchPoint: number, points: number): ITeamPoints;
|
|
11
|
-
}
|
|
12
|
-
export type IPublicTeam = Pick<ITeam, "points"> & {
|
|
13
|
-
players: Array<IPublicPlayer>;
|
|
14
|
-
};
|
|
15
|
-
export interface ITeamPoints {
|
|
16
|
-
buenas: number;
|
|
17
|
-
malas: number;
|
|
18
|
-
winner: boolean;
|
|
19
|
-
}
|
|
20
|
-
export declare function Team(players: Array<IPlayer>): ITeam;
|
|
1
|
+
import { IPlayer, IPublicPlayer } from "./Player";
|
|
2
|
+
export interface ITeam {
|
|
3
|
+
_players: Map<string, IPlayer>;
|
|
4
|
+
players: Array<IPlayer>;
|
|
5
|
+
points: ITeamPoints;
|
|
6
|
+
getPublicTeam(playerSession?: string): IPublicTeam;
|
|
7
|
+
isTeamDisabled(): boolean;
|
|
8
|
+
disable(player: IPlayer): boolean;
|
|
9
|
+
enable(player?: IPlayer): boolean;
|
|
10
|
+
addPoints(matchPoint: number, points: number): ITeamPoints;
|
|
11
|
+
}
|
|
12
|
+
export type IPublicTeam = Pick<ITeam, "points"> & {
|
|
13
|
+
players: Array<IPublicPlayer>;
|
|
14
|
+
};
|
|
15
|
+
export interface ITeamPoints {
|
|
16
|
+
buenas: number;
|
|
17
|
+
malas: number;
|
|
18
|
+
winner: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare function Team(players: Array<IPlayer>): ITeam;
|
package/dist/lib/classes/Team.js
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Team = void 0;
|
|
4
|
-
function Team(players) {
|
|
5
|
-
const team = {
|
|
6
|
-
_players: new Map(),
|
|
7
|
-
get players() {
|
|
8
|
-
return Array.from(team._players.values());
|
|
9
|
-
},
|
|
10
|
-
points: {
|
|
11
|
-
buenas: 0,
|
|
12
|
-
malas: 0,
|
|
13
|
-
winner: false,
|
|
14
|
-
},
|
|
15
|
-
getPublicTeam(playerSession) {
|
|
16
|
-
return {
|
|
17
|
-
points: team.points,
|
|
18
|
-
players: team.players.map((player) => player.session === playerSession ? player : player.getPublicPlayer()),
|
|
19
|
-
};
|
|
20
|
-
},
|
|
21
|
-
isTeamDisabled() {
|
|
22
|
-
return team.players.reduce((prev, curr) => prev && curr.disabled, true);
|
|
23
|
-
},
|
|
24
|
-
enable(player) {
|
|
25
|
-
var _a;
|
|
26
|
-
if (player) {
|
|
27
|
-
(_a = team._players.get(player.session)) === null || _a === void 0 ? void 0 : _a.enable();
|
|
28
|
-
return team.isTeamDisabled();
|
|
29
|
-
}
|
|
30
|
-
for (const player of team.players) {
|
|
31
|
-
player.enable();
|
|
32
|
-
}
|
|
33
|
-
return team.isTeamDisabled();
|
|
34
|
-
},
|
|
35
|
-
disable(player) {
|
|
36
|
-
var _a;
|
|
37
|
-
(_a = team._players.get(player.session)) === null || _a === void 0 ? void 0 : _a.disable();
|
|
38
|
-
return team.isTeamDisabled();
|
|
39
|
-
},
|
|
40
|
-
addPoints(matchPoint, points) {
|
|
41
|
-
const malas = team.points.malas + points;
|
|
42
|
-
const diff = malas - matchPoint;
|
|
43
|
-
if (diff > 0) {
|
|
44
|
-
team.points.malas = matchPoint;
|
|
45
|
-
team.points.buenas += diff;
|
|
46
|
-
if (team.points.buenas >= matchPoint) {
|
|
47
|
-
team.points.winner = true;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
team.points.malas = malas;
|
|
52
|
-
}
|
|
53
|
-
return team.points;
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
players.forEach((player) => team._players.set(player.session, player));
|
|
57
|
-
return team;
|
|
58
|
-
}
|
|
59
|
-
exports.Team = Team;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Team = void 0;
|
|
4
|
+
function Team(players) {
|
|
5
|
+
const team = {
|
|
6
|
+
_players: new Map(),
|
|
7
|
+
get players() {
|
|
8
|
+
return Array.from(team._players.values());
|
|
9
|
+
},
|
|
10
|
+
points: {
|
|
11
|
+
buenas: 0,
|
|
12
|
+
malas: 0,
|
|
13
|
+
winner: false,
|
|
14
|
+
},
|
|
15
|
+
getPublicTeam(playerSession) {
|
|
16
|
+
return {
|
|
17
|
+
points: team.points,
|
|
18
|
+
players: team.players.map((player) => player.session === playerSession ? player : player.getPublicPlayer()),
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
isTeamDisabled() {
|
|
22
|
+
return team.players.reduce((prev, curr) => prev && curr.disabled, true);
|
|
23
|
+
},
|
|
24
|
+
enable(player) {
|
|
25
|
+
var _a;
|
|
26
|
+
if (player) {
|
|
27
|
+
(_a = team._players.get(player.session)) === null || _a === void 0 ? void 0 : _a.enable();
|
|
28
|
+
return team.isTeamDisabled();
|
|
29
|
+
}
|
|
30
|
+
for (const player of team.players) {
|
|
31
|
+
player.enable();
|
|
32
|
+
}
|
|
33
|
+
return team.isTeamDisabled();
|
|
34
|
+
},
|
|
35
|
+
disable(player) {
|
|
36
|
+
var _a;
|
|
37
|
+
(_a = team._players.get(player.session)) === null || _a === void 0 ? void 0 : _a.disable();
|
|
38
|
+
return team.isTeamDisabled();
|
|
39
|
+
},
|
|
40
|
+
addPoints(matchPoint, points) {
|
|
41
|
+
const malas = team.points.malas + points;
|
|
42
|
+
const diff = malas - matchPoint;
|
|
43
|
+
if (diff > 0) {
|
|
44
|
+
team.points.malas = matchPoint;
|
|
45
|
+
team.points.buenas += diff;
|
|
46
|
+
if (team.points.buenas >= matchPoint) {
|
|
47
|
+
team.points.winner = true;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
team.points.malas = malas;
|
|
52
|
+
}
|
|
53
|
+
return team.points;
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
players.forEach((player) => team._players.set(player.session, player));
|
|
57
|
+
return team;
|
|
58
|
+
}
|
|
59
|
+
exports.Team = Team;
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import { IPlayer } from "./Player";
|
|
2
|
-
import { ITeam } from "./Team";
|
|
3
|
-
export interface ITruco {
|
|
4
|
-
state: 1 | 2 | 3 | 4;
|
|
5
|
-
teamIdx: 0 | 1 | null;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import { IPlayer } from "./Player";
|
|
2
|
+
import { ITeam } from "./Team";
|
|
3
|
+
export interface ITruco {
|
|
4
|
+
state: 1 | 2 | 3 | 4;
|
|
5
|
+
teamIdx: 0 | 1 | null;
|
|
6
|
+
waitingAnswer: boolean;
|
|
7
|
+
answer: boolean | null;
|
|
8
|
+
turn: number;
|
|
9
|
+
teams: [ITeam, ITeam];
|
|
10
|
+
players: Array<IPlayer>;
|
|
11
|
+
currentPlayer: IPlayer | null;
|
|
12
|
+
generator: Generator<ITruco, void, unknown>;
|
|
13
|
+
sayTruco(player: IPlayer, callback: () => void): ITruco;
|
|
14
|
+
sayAnswer(player: IPlayer, answer: boolean | null, callback: () => void): ITruco;
|
|
15
|
+
setTurn(turn: number): number;
|
|
16
|
+
setTeam(idx: 0 | 1): 0 | 1;
|
|
17
|
+
setCurrentPlayer(player: IPlayer | null): IPlayer | null;
|
|
18
|
+
getNextPlayer(): IteratorResult<ITruco, ITruco | void>;
|
|
19
|
+
reset(): void;
|
|
20
|
+
}
|
|
21
|
+
export declare function Truco(teams: [ITeam, ITeam]): ITruco;
|