trucoshi 1.0.0 → 2.0.1

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.
@@ -1,66 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkMatchWinner = exports.checkHandWinner = exports.shuffleArray = exports.getCardValue = void 0;
4
- var constants_1 = require("./constants");
5
- function getCardValue(card) {
6
- return constants_1.CARDS[card] || -1;
7
- }
8
- exports.getCardValue = getCardValue;
9
- function shuffleArray(array) {
10
- var _a;
11
- var currentIndex = array.length, randomIndex;
12
- while (currentIndex != 0) {
13
- randomIndex = Math.floor(Math.random() * currentIndex);
14
- currentIndex--;
15
- _a = [
16
- array[randomIndex], array[currentIndex]
17
- ], array[currentIndex] = _a[0], array[randomIndex] = _a[1];
18
- }
19
- return array;
20
- }
21
- exports.shuffleArray = shuffleArray;
22
- function checkHandWinner(rounds, forehandTeamIdx) {
23
- var _a, _b;
24
- var roundsWon = {
25
- 0: 0,
26
- 1: 0,
27
- 2: 0 // tied rounds
28
- };
29
- for (var i = 0; i < rounds.length; i++) {
30
- var round = rounds[i];
31
- if (round.tie) {
32
- roundsWon[0] += 1;
33
- roundsWon[1] += 1;
34
- roundsWon[2] = (roundsWon[2] || 0) + 1;
35
- continue;
36
- }
37
- if (((_a = round.winner) === null || _a === void 0 ? void 0 : _a.teamIdx) === 0) {
38
- roundsWon[0] += 1;
39
- }
40
- if (((_b = round.winner) === null || _b === void 0 ? void 0 : _b.teamIdx) === 1) {
41
- roundsWon[1] += 1;
42
- }
43
- }
44
- var ties = roundsWon[2] || 0;
45
- if ((roundsWon[0] > 2 && roundsWon[1] > 2) || (rounds.length > 2 && ties > 0)) {
46
- return forehandTeamIdx;
47
- }
48
- if (roundsWon[0] >= 2 && roundsWon[1] < 2) {
49
- return 0;
50
- }
51
- if (roundsWon[1] >= 2 && roundsWon[0] < 2) {
52
- return 1;
53
- }
54
- return null;
55
- }
56
- exports.checkHandWinner = checkHandWinner;
57
- function checkMatchWinner(teams, matchPoint) {
58
- if (teams[0].points >= matchPoint) {
59
- return teams[0];
60
- }
61
- if (teams[1].points >= matchPoint) {
62
- return teams[1];
63
- }
64
- return null;
65
- }
66
- exports.checkMatchWinner = checkMatchWinner;
@@ -1 +0,0 @@
1
- export {};
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var http_1 = require("http");
4
- var socket_io_1 = require("socket.io");
5
- var PORT = 4001;
6
- var httpServer = (0, http_1.createServer)();
7
- var io = new socket_io_1.Server(httpServer, {
8
- cors: {
9
- origin: "http://localhost:3000",
10
- methods: ["GET", "POST"]
11
- }
12
- });
13
- io.on("connection", function (socket) {
14
- socket.on('ping', function (msg) {
15
- io.emit('pong', msg);
16
- });
17
- });
18
- httpServer.listen(PORT);
19
- console.log('Listening on port', PORT);
File without changes
@@ -1 +0,0 @@
1
- "use strict";
@@ -1 +0,0 @@
1
- export {};
@@ -1,73 +0,0 @@
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
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- var constants_1 = require("../lib/constants");
40
- var trucoshi_1 = require("../lib/trucoshi");
41
- (function () { return __awaiter(void 0, void 0, void 0, function () {
42
- var player1, player2, player3, player4, player5, player6, team1, team2, match, play, name, randomIdx, card;
43
- var _a;
44
- return __generator(this, function (_b) {
45
- player1 = (0, trucoshi_1.Player)('lukini', 0);
46
- player2 = (0, trucoshi_1.Player)('guada', 0);
47
- player3 = (0, trucoshi_1.Player)('denoph', 1);
48
- player4 = (0, trucoshi_1.Player)('juli', 1);
49
- player5 = (0, trucoshi_1.Player)('fran', 1);
50
- player6 = (0, trucoshi_1.Player)('day', 0);
51
- team1 = (0, trucoshi_1.Team)(constants_1.COLORS[0], [player1, player2, player6]);
52
- team2 = (0, trucoshi_1.Team)(constants_1.COLORS[1], [player3, player4, player5]);
53
- match = (0, trucoshi_1.Match)([team1, team2], 9);
54
- while (!match.winner) {
55
- play = match.play();
56
- if (!play || !play.player) {
57
- break;
58
- }
59
- name = play.player.id.toUpperCase();
60
- console.log("=== Mano ".concat(play.handIdx, " === Ronda ").concat(play.roundIdx, " === Turno de ").concat(name, " ==="));
61
- match.teams.map(function (team, id) { return console.log("=== Team ".concat(id, " = ").concat(team.points, " Puntos ===")); });
62
- console.log(play.rounds && play.rounds.length ? (play.rounds.map(function (round) { return round.cards.length ? round.cards.map(function (c) { return [c.player.id, c.card]; }) : ''; })) : '');
63
- randomIdx = Math.round(Math.random() * (play.player.hand.length - 1));
64
- card = play.use(randomIdx);
65
- console.log("\n".concat(JSON.stringify(play.player.hand), "\nUsing ").concat(card));
66
- console.log(play.rounds && play.rounds.length ? (play.rounds.map(function (round) { return round.cards.length ? round.cards.map(function (c) { return [c.player.id, c.card]; }) : ''; })) : '');
67
- }
68
- console.log('\n');
69
- match.teams.map(function (t, i) { return console.log("Equipo ".concat(i, ": ").concat(t.players.map(function (p) { return " ".concat(p.id); }), " === ").concat(t.points, " puntos")); });
70
- console.log("\nEquipo Ganador:".concat((_a = match.winner) === null || _a === void 0 ? void 0 : _a.players.map(function (p) { return " ".concat(p.id); })));
71
- return [2 /*return*/];
72
- });
73
- }); })();
@@ -1 +0,0 @@
1
- export {};
@@ -1,146 +0,0 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- var __generator = (this && this.__generator) || function (thisArg, body) {
35
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
36
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
37
- function verb(n) { return function (v) { return step([n, v]); }; }
38
- function step(op) {
39
- if (f) throw new TypeError("Generator is already executing.");
40
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
41
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
42
- if (y = 0, t) op = [op[0] & 2, t.value];
43
- switch (op[0]) {
44
- case 0: case 1: t = op; break;
45
- case 4: _.label++; return { value: op[1], done: false };
46
- case 5: _.label++; y = op[1]; op = [0]; continue;
47
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
48
- default:
49
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
50
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
51
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
52
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
53
- if (t[2]) _.ops.pop();
54
- _.trys.pop(); continue;
55
- }
56
- op = body.call(thisArg, _);
57
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
58
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
59
- }
60
- };
61
- Object.defineProperty(exports, "__esModule", { value: true });
62
- var readline = __importStar(require("readline"));
63
- var constants_1 = require("../lib/constants");
64
- var trucoshi_1 = require("../lib/trucoshi");
65
- (function () { return __awaiter(void 0, void 0, void 0, function () {
66
- var player1, player2, player3, player4, team1, team2, match, _loop_1;
67
- var _a;
68
- return __generator(this, function (_b) {
69
- switch (_b.label) {
70
- case 0:
71
- player1 = (0, trucoshi_1.Player)('lukini', 0);
72
- player2 = (0, trucoshi_1.Player)('guada', 0);
73
- player3 = (0, trucoshi_1.Player)('denoph', 1);
74
- player4 = (0, trucoshi_1.Player)('juli', 1);
75
- team1 = (0, trucoshi_1.Team)(constants_1.COLORS[0], [player1, player2]);
76
- team2 = (0, trucoshi_1.Team)(constants_1.COLORS[1], [player3, player4]);
77
- match = (0, trucoshi_1.Match)([team1, team2], 9);
78
- _loop_1 = function () {
79
- var value, prom_1;
80
- return __generator(this, function (_c) {
81
- switch (_c.label) {
82
- case 0:
83
- if ((_a = match.currentHand) === null || _a === void 0 ? void 0 : _a.finished) {
84
- console.log(match.currentHand && match.currentHand.rounds.length ? (match.currentHand.rounds.map(function (round) { return round.cards.length ? round.cards.map(function (c) { return [c.player.id, c.card]; }) : ''; })) : '');
85
- }
86
- value = match.getNextTurn().value;
87
- if (!(value && value.currentHand && value.currentHand.currentPlayer)) return [3 /*break*/, 2];
88
- prom_1 = function () { return new Promise(function (resolve) {
89
- var _a, _b, _c, _d;
90
- // process.stdout.write('\u001B[2J\u001B[0;0f');
91
- var rl = readline.createInterface(process.stdin, process.stdout);
92
- var currentHand = value.currentHand;
93
- var name = (_b = (_a = value.currentHand) === null || _a === void 0 ? void 0 : _a.currentPlayer) === null || _b === void 0 ? void 0 : _b.id.toUpperCase();
94
- console.log("=== Mano ".concat(currentHand.idx + 1, " === Ronda ").concat(currentHand.rounds.length, " === Turno de ").concat(name, " ===\n"));
95
- match.teams.map(function (team, id) { return console.log("=== Team ".concat(id, " = ").concat(team.points, " Puntos ===\n")); });
96
- console.log(currentHand && currentHand.rounds.length ? (currentHand.rounds.map(function (round) { return round.cards.length ? round.cards.map(function (c) { return [c.player.id, c.card]; }) : ''; })) : '');
97
- rl.setPrompt("\n".concat(name, " elije una carta [1, 2, 3]: ").concat(JSON.stringify((_d = (_c = value.currentHand) === null || _c === void 0 ? void 0 : _c.currentPlayer) === null || _d === void 0 ? void 0 : _d.hand), "\n"));
98
- rl.prompt();
99
- rl.on('line', function (idx) {
100
- var _a, _b, _c, _d, _e;
101
- var index = Number(idx) - 1;
102
- var playedCard = null;
103
- if (index >= 0 && index < 3) {
104
- playedCard = (_b = (_a = value.currentHand) === null || _a === void 0 ? void 0 : _a.currentPlayer) === null || _b === void 0 ? void 0 : _b.useCard(index);
105
- }
106
- if (!playedCard) {
107
- rl.close();
108
- return (function () { return __awaiter(void 0, void 0, void 0, function () {
109
- return __generator(this, function (_a) {
110
- switch (_a.label) {
111
- case 0: return [4 /*yield*/, prom_1()];
112
- case 1:
113
- _a.sent();
114
- resolve();
115
- return [2 /*return*/];
116
- }
117
- });
118
- }); })();
119
- }
120
- (_d = (_c = value.currentHand) === null || _c === void 0 ? void 0 : _c.currentRound) === null || _d === void 0 ? void 0 : _d.play({ player: (_e = value.currentHand) === null || _e === void 0 ? void 0 : _e.currentPlayer, card: playedCard });
121
- console.log(currentHand && currentHand.rounds.length ? (currentHand.rounds.map(function (round) { return round.cards.length ? round.cards.map(function (c) { return [c.player.id, c.card]; }) : ''; })) : '');
122
- rl.close();
123
- resolve();
124
- });
125
- }); };
126
- return [4 /*yield*/, prom_1()];
127
- case 1:
128
- _c.sent();
129
- _c.label = 2;
130
- case 2: return [2 /*return*/];
131
- }
132
- });
133
- };
134
- _b.label = 1;
135
- case 1:
136
- if (!!match.winner) return [3 /*break*/, 3];
137
- return [5 /*yield**/, _loop_1()];
138
- case 2:
139
- _b.sent();
140
- return [3 /*break*/, 1];
141
- case 3:
142
- console.log(match.teams.map(function (t) { return [t.points, t.players[0].id]; }));
143
- return [2 /*return*/];
144
- }
145
- });
146
- }); })();
@@ -1 +0,0 @@
1
- export {};
@@ -1,148 +0,0 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- var __generator = (this && this.__generator) || function (thisArg, body) {
35
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
36
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
37
- function verb(n) { return function (v) { return step([n, v]); }; }
38
- function step(op) {
39
- if (f) throw new TypeError("Generator is already executing.");
40
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
41
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
42
- if (y = 0, t) op = [op[0] & 2, t.value];
43
- switch (op[0]) {
44
- case 0: case 1: t = op; break;
45
- case 4: _.label++; return { value: op[1], done: false };
46
- case 5: _.label++; y = op[1]; op = [0]; continue;
47
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
48
- default:
49
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
50
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
51
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
52
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
53
- if (t[2]) _.ops.pop();
54
- _.trys.pop(); continue;
55
- }
56
- op = body.call(thisArg, _);
57
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
58
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
59
- }
60
- };
61
- Object.defineProperty(exports, "__esModule", { value: true });
62
- var readline = __importStar(require("readline"));
63
- var constants_1 = require("../lib/constants");
64
- var trucoshi_1 = require("../lib/trucoshi");
65
- (function () { return __awaiter(void 0, void 0, void 0, function () {
66
- var player1, player2, player3, player4, team1, team2, match, _loop_1, state_1;
67
- var _a;
68
- return __generator(this, function (_b) {
69
- switch (_b.label) {
70
- case 0:
71
- player1 = (0, trucoshi_1.Player)('lukini', 0);
72
- player2 = (0, trucoshi_1.Player)('guada', 0);
73
- player3 = (0, trucoshi_1.Player)('denoph', 1);
74
- player4 = (0, trucoshi_1.Player)('juli', 1);
75
- team1 = (0, trucoshi_1.Team)(constants_1.COLORS[0], [player1, player2]);
76
- team2 = (0, trucoshi_1.Team)(constants_1.COLORS[1], [player3, player4]);
77
- match = (0, trucoshi_1.Match)([team1, team2], 9);
78
- _loop_1 = function () {
79
- var play, name, prom;
80
- return __generator(this, function (_c) {
81
- switch (_c.label) {
82
- case 0:
83
- play = match.play();
84
- if (!play || !play.player) {
85
- return [2 /*return*/, "break"];
86
- }
87
- name = play.player.id.toUpperCase();
88
- process.stdout.write('\u001B[2J\u001B[0;0f');
89
- process.stdout.write('\u001B[0;0f');
90
- console.log("=== Mano ".concat(play.handIdx, " === Ronda ").concat(play.roundIdx, " === Turno de ").concat(name, " ==="));
91
- process.stdout.write('\u001B[2;0f');
92
- match.teams.map(function (team, id) { return console.log("=== Team ".concat(id, " = ").concat(team.points, " Puntos ===")); });
93
- process.stdout.write('\u001B[5;0f');
94
- console.log(play.rounds && play.rounds.length ? (play.rounds.map(function (round) { return round.cards.length ? round.cards.map(function (c) { return [c.player.id, c.card]; }) : ''; })) : '');
95
- prom = function () { return new Promise(function (resolve) {
96
- var _a, _b;
97
- var rl = readline.createInterface(process.stdin, process.stdout);
98
- rl.setPrompt("\n".concat((_a = play.player) === null || _a === void 0 ? void 0 : _a.id, " elije una carta [1, 2, 3]: ").concat(JSON.stringify((_b = play.player) === null || _b === void 0 ? void 0 : _b.hand), "\n"));
99
- rl.prompt();
100
- rl.on('line', function (idx) {
101
- var _a;
102
- var playedCard = play.use(Number(idx) - 1);
103
- if (!playedCard) {
104
- rl.close();
105
- return (function () { return __awaiter(void 0, void 0, void 0, function () {
106
- return __generator(this, function (_a) {
107
- switch (_a.label) {
108
- case 0: return [4 /*yield*/, prom()];
109
- case 1:
110
- _a.sent();
111
- resolve();
112
- return [2 /*return*/];
113
- }
114
- });
115
- }); })();
116
- }
117
- process.stdout.write('\u001B[7;0f');
118
- console.log("\n".concat(JSON.stringify((_a = play.player) === null || _a === void 0 ? void 0 : _a.hand), "\nUsing ").concat(playedCard));
119
- process.stdout.write('\u001B[10;0f');
120
- console.log(play.rounds && play.rounds.length ? (play.rounds.map(function (round) { return round.cards.length ? round.cards.map(function (c) { return [c.player.id, c.card]; }) : ''; })) : '');
121
- rl.close();
122
- resolve();
123
- });
124
- }); };
125
- return [4 /*yield*/, prom()];
126
- case 1:
127
- _c.sent();
128
- return [2 /*return*/];
129
- }
130
- });
131
- };
132
- _b.label = 1;
133
- case 1:
134
- if (!!match.winner) return [3 /*break*/, 3];
135
- return [5 /*yield**/, _loop_1()];
136
- case 2:
137
- state_1 = _b.sent();
138
- if (state_1 === "break")
139
- return [3 /*break*/, 3];
140
- return [3 /*break*/, 1];
141
- case 3:
142
- process.stdout.write('\u001B[2J\u001B[2;0f');
143
- match.teams.map(function (t, i) { return console.log("Equipo ".concat(i, ": ").concat(t.players.map(function (p) { return " ".concat(p.id); }), " === ").concat(t.points, " puntos")); });
144
- console.log("\nEquipo Ganador:".concat((_a = match.winner) === null || _a === void 0 ? void 0 : _a.players.map(function (p) { return " ".concat(p.id); })));
145
- return [2 /*return*/];
146
- }
147
- });
148
- }); })();
package/nodemon.json DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "watch": ["src"],
3
- "ext": ".ts,.js",
4
- "ignore": [],
5
- "exec": "yarn run ts-node ./src/server/index.ts"
6
- }
@@ -1,14 +0,0 @@
1
- export const CARDS = {
2
- '1e': 14, '1b': 13, '7e': 12, '7o': 11,
3
- '3e': 10, '3o': 10, '3b': 10, '3c': 10,
4
- '2e': 9, '2o': 9, '2b': 8, '2c': 8,
5
- '1o': 7, '1c': 7, 're': 6, 'ro': 6,
6
- 'rb': 6, 'rc': 6, 'ce': 5, 'co': 5,
7
- 'cb': 5, 'cc': 5, 'pe': 4, 'po': 4,
8
- 'pb': 4, 'pc': 4, '7b': 3, '7c': 3,
9
- '6e': 2, '6o': 2, '6b': 2, '6c': 2,
10
- '5e': 1, '5o': 1, '5b': 1, '5c': 1,
11
- '4e': 0, '4o': 0, '4b': 0, '4c': 0
12
- }
13
-
14
- export const COLORS = ["#9b111", "#17c6c6", "#8c1d1d", "#9f9b9b", "#a5a5a5", "#f5a623", "#f44336", "#c2185b"];