trucoshi 0.1.8 → 0.2.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,112 +1,69 @@
1
1
  "use strict";
2
- var __generator = (this && this.__generator) || function (thisArg, body) {
3
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
4
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
5
- function verb(n) { return function (v) { return step([n, v]); }; }
6
- function step(op) {
7
- if (f) throw new TypeError("Generator is already executing.");
8
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
9
- 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;
10
- if (y = 0, t) op = [op[0] & 2, t.value];
11
- switch (op[0]) {
12
- case 0: case 1: t = op; break;
13
- case 4: _.label++; return { value: op[1], done: false };
14
- case 5: _.label++; y = op[1]; op = [0]; continue;
15
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
16
- default:
17
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
18
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
19
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
20
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
21
- if (t[2]) _.ops.pop();
22
- _.trys.pop(); continue;
23
- }
24
- op = body.call(thisArg, _);
25
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
26
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
27
- }
28
- };
29
2
  Object.defineProperty(exports, "__esModule", { value: true });
30
3
  exports.Match = void 0;
31
- var Deck_1 = require("./Deck");
32
- var Hand_1 = require("./Hand");
33
- function Match(table, teams, matchPoint) {
34
- if (teams === void 0) { teams = []; }
35
- if (matchPoint === void 0) { matchPoint = 9; }
36
- var deck = (0, Deck_1.Deck)().shuffle();
37
- var size = teams[0].players.length;
4
+ const Deck_1 = require("./Deck");
5
+ const Hand_1 = require("./Hand");
6
+ function Match(table, teams = [], matchPoint = 9) {
7
+ const deck = (0, Deck_1.Deck)().shuffle();
8
+ const size = teams[0].players.length;
38
9
  if (size !== teams[1].players.length) {
39
10
  throw new Error("Team size mismatch");
40
11
  }
41
- function handsGeneratorSequence() {
42
- var hand, value, teams_1, winner;
43
- return __generator(this, function (_a) {
44
- switch (_a.label) {
45
- case 0:
46
- if (!!match.winner) return [3 /*break*/, 4];
47
- deck.shuffle();
48
- hand = match.setCurrentHand((0, Hand_1.Hand)(match, deck, match.hands.length + 1));
49
- match.pushHand(hand);
50
- _a.label = 1;
51
- case 1:
52
- if (!!hand.finished()) return [3 /*break*/, 3];
53
- value = hand.getNextPlayer().value;
54
- if (value && value.finished()) {
55
- return [3 /*break*/, 1];
56
- }
57
- match.setCurrentHand(value);
58
- return [4 /*yield*/, match];
59
- case 2:
60
- _a.sent();
61
- return [3 /*break*/, 1];
62
- case 3:
63
- match.setCurrentHand(null);
64
- teams_1 = match.addPoints(hand.points);
65
- winner = teams_1.find(function (team) { return team.points.winner; });
66
- if (winner) {
67
- match.setWinner(winner);
68
- match.setCurrentHand(null);
69
- return [3 /*break*/, 4];
70
- }
71
- match.table.nextTurn();
72
- return [3 /*break*/, 0];
73
- case 4: return [4 /*yield*/, match];
74
- case 5:
75
- _a.sent();
76
- return [2 /*return*/];
12
+ function* handsGeneratorSequence() {
13
+ while (!match.winner) {
14
+ deck.shuffle();
15
+ const hand = match.setCurrentHand((0, Hand_1.Hand)(match, deck, match.hands.length + 1));
16
+ match.pushHand(hand);
17
+ while (!hand.finished()) {
18
+ const { value } = hand.getNextPlayer();
19
+ if (value && value.finished()) {
20
+ continue;
21
+ }
22
+ match.setCurrentHand(value);
23
+ yield match;
24
+ }
25
+ match.setCurrentHand(null);
26
+ const teams = match.addPoints(hand.points);
27
+ const winner = teams.find((team) => team.points.winner);
28
+ if (winner) {
29
+ match.setWinner(winner);
30
+ match.setCurrentHand(null);
31
+ break;
77
32
  }
78
- });
33
+ match.table.nextTurn();
34
+ }
35
+ yield match;
79
36
  }
80
- var handsGenerator = handsGeneratorSequence();
81
- var match = {
37
+ const handsGenerator = handsGeneratorSequence();
38
+ const match = {
82
39
  winner: null,
83
40
  teams: teams,
84
41
  hands: [],
85
- table: table,
42
+ table,
86
43
  currentHand: null,
87
- play: function () {
44
+ play() {
88
45
  match.getNextTurn();
89
46
  if (!match.currentHand) {
90
47
  return null;
91
48
  }
92
49
  return match.currentHand.play();
93
50
  },
94
- addPoints: function (points) {
51
+ addPoints(points) {
95
52
  match.teams[0].addPoints(matchPoint, points[0]);
96
53
  match.teams[1].addPoints(matchPoint, points[1]);
97
54
  return match.teams;
98
55
  },
99
- pushHand: function (hand) {
56
+ pushHand(hand) {
100
57
  match.hands.push(hand);
101
58
  },
102
- setCurrentHand: function (hand) {
59
+ setCurrentHand(hand) {
103
60
  match.currentHand = hand;
104
61
  return match.currentHand;
105
62
  },
106
- setWinner: function (winner) {
63
+ setWinner(winner) {
107
64
  match.winner = winner;
108
65
  },
109
- getNextTurn: function () {
66
+ getNextTurn() {
110
67
  return handsGenerator.next();
111
68
  },
112
69
  };
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PlayInstance = void 0;
4
- var types_1 = require("../../types");
4
+ const types_1 = require("../../types");
5
5
  function PlayInstance(hand, teams) {
6
6
  var _a, _b, _c;
7
- var instance = {
7
+ const instance = {
8
8
  state: hand.state,
9
- teams: teams,
9
+ teams,
10
10
  truco: hand.truco,
11
11
  envido: hand.envido,
12
12
  handIdx: hand.idx,
@@ -14,10 +14,10 @@ function PlayInstance(hand, teams) {
14
14
  player: hand.currentPlayer,
15
15
  commands: [],
16
16
  rounds: hand.rounds,
17
- use: function (idx, card) {
17
+ use(idx, card) {
18
18
  return hand.use(idx, card);
19
19
  },
20
- say: function (command) {
20
+ say(command) {
21
21
  var _a;
22
22
  if (!hand._currentPlayer || !((_a = instance.commands) === null || _a === void 0 ? void 0 : _a.includes(command))) {
23
23
  return null;
@@ -1,73 +1,63 @@
1
1
  "use strict";
2
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
- if (ar || !(i in from)) {
5
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
- ar[i] = from[i];
7
- }
8
- }
9
- return to.concat(ar || Array.prototype.slice.call(from));
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.Player = void 0;
13
- function Player(id, teamIdx, isOwner) {
14
- if (isOwner === void 0) { isOwner = false; }
15
- var player = {
16
- id: id,
4
+ function Player(id, teamIdx, isOwner = false) {
5
+ const player = {
6
+ id,
17
7
  session: undefined,
18
- teamIdx: teamIdx,
8
+ teamIdx,
19
9
  hand: [],
20
10
  commands: [],
21
11
  usedHand: [],
22
12
  prevHand: [],
23
- isOwner: isOwner,
13
+ isOwner,
24
14
  isTurn: false,
25
15
  disabled: false,
26
16
  ready: false,
27
- setOwner: function (owner) {
17
+ setOwner(owner) {
28
18
  player.isOwner = owner;
29
19
  },
30
- setTurn: function (turn) {
20
+ setTurn(turn) {
31
21
  player.isTurn = turn;
32
22
  },
33
- getPublicPlayer: function () {
34
- var id = player.id, disabled = player.disabled, ready = player.ready, usedHand = player.usedHand, prevHand = player.prevHand, teamIdx = player.teamIdx, isTurn = player.isTurn, isOwner = player.isOwner;
23
+ getPublicPlayer() {
24
+ const { id, disabled, ready, usedHand, prevHand, teamIdx, isTurn, isOwner } = player;
35
25
  return {
36
- id: id,
37
- disabled: disabled,
38
- ready: ready,
39
- usedHand: usedHand,
40
- prevHand: prevHand,
41
- teamIdx: teamIdx,
42
- isTurn: isTurn,
43
- isOwner: isOwner,
44
- hand: player.hand.map(function () { return "xx"; }),
26
+ id,
27
+ disabled,
28
+ ready,
29
+ usedHand,
30
+ prevHand,
31
+ teamIdx,
32
+ isTurn,
33
+ isOwner,
34
+ hand: player.hand.map(() => "xx"),
45
35
  session: undefined,
46
36
  };
47
37
  },
48
- setSession: function (session) {
38
+ setSession(session) {
49
39
  player.session = session;
50
40
  },
51
- enable: function () {
41
+ enable() {
52
42
  player.disabled = false;
53
43
  },
54
- disable: function () {
44
+ disable() {
55
45
  player.disabled = true;
56
46
  },
57
- setReady: function (ready) {
47
+ setReady(ready) {
58
48
  player.ready = ready;
59
49
  },
60
- setHand: function (hand) {
61
- player.prevHand = __spreadArray([], player.usedHand, true);
50
+ setHand(hand) {
51
+ player.prevHand = [...player.usedHand];
62
52
  player.hand = hand;
63
53
  player.usedHand = [];
64
54
  return hand;
65
55
  },
66
- useCard: function (idx, card) {
56
+ useCard(idx, card) {
67
57
  if (player.hand[idx] && player.hand[idx] === card) {
68
- var card_1 = player.hand.splice(idx, 1)[0];
69
- player.usedHand.push(card_1);
70
- return card_1;
58
+ const card = player.hand.splice(idx, 1)[0];
59
+ player.usedHand.push(card);
60
+ return card;
71
61
  }
72
62
  return null;
73
63
  },
@@ -1,23 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Round = void 0;
4
- var utils_1 = require("../utils");
5
- var Deck_1 = require("./Deck");
4
+ const utils_1 = require("../utils");
5
+ const Deck_1 = require("./Deck");
6
6
  function Round(turn) {
7
- var round = {
8
- turn: turn,
7
+ const round = {
8
+ turn,
9
9
  highest: -1,
10
10
  winner: null,
11
11
  cards: [],
12
12
  tie: false,
13
- nextTurn: function () {
13
+ nextTurn() {
14
14
  round.turn++;
15
15
  },
16
- use: function (_a) {
17
- var _b;
18
- var card = _a.card, player = _a.player;
19
- var value = (0, utils_1.getCardValue)(card);
20
- if (value === round.highest && player.teamIdx !== ((_b = round.winner) === null || _b === void 0 ? void 0 : _b.teamIdx)) {
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)) {
21
20
  round.tie = true;
22
21
  }
23
22
  if (value > round.highest) {
@@ -2,11 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Table = void 0;
4
4
  function Table(players, teams) {
5
- var table = {
6
- players: players,
5
+ const table = {
6
+ players,
7
7
  cards: [],
8
8
  forehandIdx: 0,
9
- nextTurn: function () {
9
+ nextTurn() {
10
10
  if (table.forehandIdx < table.players.length - 1) {
11
11
  table.forehandIdx++;
12
12
  }
@@ -15,10 +15,10 @@ function Table(players, teams) {
15
15
  }
16
16
  return table.player();
17
17
  },
18
- getPlayerPosition: function (id) {
19
- return table.players.findIndex(function (p) { return p.id === id; });
18
+ getPlayerPosition(id) {
19
+ return table.players.findIndex((p) => p.id === id);
20
20
  },
21
- player: function (idx) {
21
+ player(idx) {
22
22
  if (idx !== undefined) {
23
23
  return table.players[idx];
24
24
  }
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Team = void 0;
4
4
  function Team(players) {
5
- var team = {
5
+ const team = {
6
6
  _players: new Map(),
7
7
  get players() {
8
8
  return Array.from(team._players.values());
@@ -12,25 +12,23 @@ function Team(players) {
12
12
  malas: 0,
13
13
  winner: false,
14
14
  },
15
- getPublicTeam: function (playerSession) {
15
+ getPublicTeam(playerSession) {
16
16
  return {
17
17
  points: team.points,
18
- players: team.players.map(function (player) {
19
- return player.session === playerSession ? player : player.getPublicPlayer();
20
- }),
18
+ players: team.players.map((player) => player.session === playerSession ? player : player.getPublicPlayer()),
21
19
  };
22
20
  },
23
- isTeamDisabled: function () {
24
- return team.players.reduce(function (prev, curr) { return prev && curr.disabled; }, true);
21
+ isTeamDisabled() {
22
+ return team.players.reduce((prev, curr) => prev && curr.disabled, true);
25
23
  },
26
- disable: function (player) {
24
+ disable(player) {
27
25
  var _a;
28
26
  (_a = team._players.get(player.session)) === null || _a === void 0 ? void 0 : _a.disable();
29
27
  return team.isTeamDisabled();
30
28
  },
31
- addPoints: function (matchPoint, points) {
32
- var malas = team.points.malas + points;
33
- var diff = malas - matchPoint;
29
+ addPoints(matchPoint, points) {
30
+ const malas = team.points.malas + points;
31
+ const diff = malas - matchPoint;
34
32
  if (diff > 0) {
35
33
  team.points.malas = matchPoint;
36
34
  team.points.buenas += diff;
@@ -44,7 +42,7 @@ function Team(players) {
44
42
  return team.points;
45
43
  },
46
44
  };
47
- players.forEach(function (player) { return team._players.set(player.session, player); });
45
+ players.forEach((player) => team._players.set(player.session, player));
48
46
  return team;
49
47
  }
50
48
  exports.Team = Team;
@@ -1,67 +1,27 @@
1
1
  "use strict";
2
- var __generator = (this && this.__generator) || function (thisArg, body) {
3
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
4
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
5
- function verb(n) { return function (v) { return step([n, v]); }; }
6
- function step(op) {
7
- if (f) throw new TypeError("Generator is already executing.");
8
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
9
- 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;
10
- if (y = 0, t) op = [op[0] & 2, t.value];
11
- switch (op[0]) {
12
- case 0: case 1: t = op; break;
13
- case 4: _.label++; return { value: op[1], done: false };
14
- case 5: _.label++; y = op[1]; op = [0]; continue;
15
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
16
- default:
17
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
18
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
19
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
20
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
21
- if (t[2]) _.ops.pop();
22
- _.trys.pop(); continue;
23
- }
24
- op = body.call(thisArg, _);
25
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
26
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
27
- }
28
- };
29
2
  Object.defineProperty(exports, "__esModule", { value: true });
30
3
  exports.Truco = void 0;
31
4
  function Truco() {
32
- function trucoAnswerGeneratorSequence() {
33
- var i, player;
34
- return __generator(this, function (_a) {
35
- switch (_a.label) {
36
- case 0:
37
- i = 0;
38
- _a.label = 1;
39
- case 1:
40
- if (!(i < truco.players.length && truco.answer === null)) return [3 /*break*/, 3];
41
- player = truco.players[truco.turn];
42
- truco.setCurrentPlayer(player);
43
- if (player.disabled) {
44
- truco.setCurrentPlayer(null);
45
- }
46
- if (truco.turn >= truco.players.length - 1) {
47
- truco.setTurn(0);
48
- }
49
- else {
50
- truco.setTurn(truco.turn + 1);
51
- }
52
- i++;
53
- return [4 /*yield*/, truco];
54
- case 2:
55
- _a.sent();
56
- return [3 /*break*/, 1];
57
- case 3: return [4 /*yield*/, truco];
58
- case 4:
59
- _a.sent();
60
- return [2 /*return*/];
5
+ function* trucoAnswerGeneratorSequence() {
6
+ let i = 0;
7
+ while (i < truco.players.length && truco.answer === null) {
8
+ const player = truco.players[truco.turn];
9
+ truco.setCurrentPlayer(player);
10
+ if (player.disabled) {
11
+ truco.setCurrentPlayer(null);
12
+ }
13
+ if (truco.turn >= truco.players.length - 1) {
14
+ truco.setTurn(0);
15
+ }
16
+ else {
17
+ truco.setTurn(truco.turn + 1);
61
18
  }
62
- });
19
+ i++;
20
+ yield truco;
21
+ }
22
+ yield truco;
63
23
  }
64
- var truco = {
24
+ const truco = {
65
25
  turn: 0,
66
26
  state: 1,
67
27
  teamIdx: null,
@@ -69,17 +29,17 @@ function Truco() {
69
29
  currentPlayer: null,
70
30
  generator: trucoAnswerGeneratorSequence(),
71
31
  players: [],
72
- sayTruco: function (teamIdx, players) {
32
+ sayTruco(teamIdx, players) {
73
33
  truco.teamIdx = teamIdx;
74
34
  truco.answer = null;
75
35
  truco.players = players;
76
36
  truco.generator = trucoAnswerGeneratorSequence();
77
37
  return truco;
78
38
  },
79
- setPlayers: function (players) {
39
+ setPlayers(players) {
80
40
  truco.players = players;
81
41
  },
82
- setAnswer: function (answer) {
42
+ setAnswer(answer) {
83
43
  if (answer) {
84
44
  truco.state++;
85
45
  }
@@ -89,19 +49,19 @@ function Truco() {
89
49
  truco.answer = answer;
90
50
  return truco;
91
51
  },
92
- setTeam: function (idx) {
52
+ setTeam(idx) {
93
53
  truco.teamIdx = idx;
94
54
  return truco.teamIdx;
95
55
  },
96
- setTurn: function (turn) {
56
+ setTurn(turn) {
97
57
  truco.turn = turn;
98
58
  return truco.turn;
99
59
  },
100
- setCurrentPlayer: function (player) {
60
+ setCurrentPlayer(player) {
101
61
  truco.currentPlayer = player;
102
62
  return truco.currentPlayer;
103
63
  },
104
- getNextPlayer: function () {
64
+ getNextPlayer() {
105
65
  return truco.generator.next();
106
66
  },
107
67
  };
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
- var _a;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.EnvidoCalculator = exports.TEAM_SIZE_VALUES = exports.CARDS = void 0;
5
- var types_1 = require("../types");
6
- var utils_1 = require("./utils");
4
+ const types_1 = require("../types");
5
+ const utils_1 = require("./utils");
7
6
  exports.CARDS = {
8
7
  "1e": 14,
9
8
  "1b": 13,
@@ -47,23 +46,23 @@ exports.CARDS = {
47
46
  "4c": 0,
48
47
  };
49
48
  exports.TEAM_SIZE_VALUES = [1, 2, 3];
50
- exports.EnvidoCalculator = (_a = {},
51
- _a[types_1.EEnvidoCommand.ENVIDO] = function () { return ({
49
+ exports.EnvidoCalculator = {
50
+ [types_1.EEnvidoCommand.ENVIDO]: () => ({
52
51
  accept: 2,
53
52
  decline: 1,
54
53
  next: [types_1.EEnvidoCommand.ENVIDO_ENVIDO, types_1.EEnvidoCommand.REAL_ENVIDO, types_1.EEnvidoCommand.FALTA_ENVIDO],
55
- }); },
56
- _a[types_1.EEnvidoCommand.ENVIDO_ENVIDO] = function () { return ({
54
+ }),
55
+ [types_1.EEnvidoCommand.ENVIDO_ENVIDO]: () => ({
57
56
  accept: 4,
58
57
  decline: 2,
59
58
  next: [types_1.EEnvidoCommand.REAL_ENVIDO, types_1.EEnvidoCommand.FALTA_ENVIDO],
60
- }); },
61
- _a[types_1.EEnvidoCommand.REAL_ENVIDO] = function () { return ({
59
+ }),
60
+ [types_1.EEnvidoCommand.REAL_ENVIDO]: () => ({
62
61
  accept: 3,
63
62
  decline: 1,
64
63
  next: [types_1.EEnvidoCommand.FALTA_ENVIDO],
65
- }); },
66
- _a[types_1.EEnvidoCommand.FALTA_ENVIDO] = function (args) {
64
+ }),
65
+ [types_1.EEnvidoCommand.FALTA_ENVIDO]: (args) => {
67
66
  if (!args || !args.teams || !args.matchPoint) {
68
67
  return {
69
68
  accept: 1,
@@ -71,15 +70,15 @@ exports.EnvidoCalculator = (_a = {},
71
70
  next: [],
72
71
  };
73
72
  }
74
- var teams = args.teams, matchPoint = args.matchPoint;
75
- var totals = teams.map(function (team) { return team.points.malas + team.points.buenas; });
76
- var higher = (0, utils_1.getMaxNumberIndex)(totals);
77
- var points = teams[higher].points;
78
- var accept = points.buenas > 0 ? matchPoint - points.buenas : matchPoint - points.malas;
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;
79
78
  return {
80
- accept: accept,
79
+ accept,
81
80
  decline: 2,
82
81
  next: [],
83
82
  };
84
83
  },
85
- _a);
84
+ };
package/dist/lib/utils.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.checkHandWinner = exports.shuffleArray = exports.getCardValue = exports.getMaxNumberIndex = void 0;
4
- var constants_1 = require("./constants");
4
+ const constants_1 = require("./constants");
5
5
  function getMaxNumberIndex(array) {
6
- return array.reduce(function (accumulator, current, index) {
6
+ return array.reduce((accumulator, current, index) => {
7
7
  return current > array[accumulator] ? index : accumulator;
8
8
  }, 0);
9
9
  }
@@ -13,25 +13,24 @@ function getCardValue(card) {
13
13
  }
14
14
  exports.getCardValue = getCardValue;
15
15
  function shuffleArray(array) {
16
- var _a;
17
- var currentIndex = array.length, randomIndex;
16
+ let currentIndex = array.length, randomIndex;
18
17
  while (currentIndex != 0) {
19
18
  randomIndex = Math.floor(Math.random() * currentIndex);
20
19
  currentIndex--;
21
- _a = [array[randomIndex], array[currentIndex]], array[currentIndex] = _a[0], array[randomIndex] = _a[1];
20
+ [array[currentIndex], array[randomIndex]] = [array[randomIndex], array[currentIndex]];
22
21
  }
23
22
  return array;
24
23
  }
25
24
  exports.shuffleArray = shuffleArray;
26
25
  function checkHandWinner(rounds, forehandTeamIdx) {
27
26
  var _a, _b;
28
- var roundsWon = {
27
+ const roundsWon = {
29
28
  0: 0,
30
29
  1: 0,
31
30
  ties: 0,
32
31
  };
33
- for (var i = 0; i < rounds.length; i++) {
34
- var round = rounds[i];
32
+ for (let i = 0; i < rounds.length; i++) {
33
+ const round = rounds[i];
35
34
  if (round.tie) {
36
35
  roundsWon[0] += 1;
37
36
  roundsWon[1] += 1;