trucoshi 0.2.11 → 0.2.13
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 +3 -2
- package/dist/index.js +19 -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 +13 -6
|
@@ -1,126 +1,131 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Truco = void 0;
|
|
4
|
-
const types_1 = require("../../types");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
truco
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
truco.
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
player._commands.delete(types_1.ESayCommand.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
|
|
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,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);
|
package/dist/lib/constants.d.ts
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
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
|
+
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;
|
package/dist/lib/constants.js
CHANGED
|
@@ -1,84 +1,84 @@
|
|
|
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.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
|
+
};
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -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);
|