trucoshi 7.2.0 → 7.3.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.
package/dist/lib/classes/Deck.js
CHANGED
|
@@ -37,8 +37,7 @@ export function Deck() {
|
|
|
37
37
|
export const getAllCards = () => Object.keys(CARDS);
|
|
38
38
|
export function dealCards(table, deck) {
|
|
39
39
|
const cheat_lots_of_flowers = process.env.APP_CHEAT_LOTS_OF_FLOWERS_FOR_TESTING === "1";
|
|
40
|
-
const cheat_cards = process.env.APP_CHEAT_CARDS
|
|
41
|
-
JSON.parse(process.env.APP_CHEAT_CARDS);
|
|
40
|
+
const cheat_cards = process.env.APP_CHEAT_CARDS || "";
|
|
42
41
|
const playerHands = [];
|
|
43
42
|
const players = table.getPlayersForehandFirst();
|
|
44
43
|
for (let i = 0; i < 3; i++) {
|
|
@@ -47,11 +46,17 @@ export function dealCards(table, deck) {
|
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
48
|
if (cheat_cards) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
try {
|
|
50
|
+
const new_cards = JSON.parse(cheat_cards);
|
|
51
|
+
deck.shuffle(players[0].idx);
|
|
52
|
+
for (const [key, player] of players.entries()) {
|
|
53
|
+
playerHands[player.idx] = new_cards[key]
|
|
54
|
+
? new_cards[key].map((c) => deck.pick(c) || deck.takeCard())
|
|
55
|
+
: deck.takeThree();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch (_a) {
|
|
59
|
+
//noop
|
|
55
60
|
}
|
|
56
61
|
}
|
|
57
62
|
if (cheat_lots_of_flowers) {
|
|
@@ -51,7 +51,12 @@ function Rng() {
|
|
|
51
51
|
* @param {number} nonce - the nonce
|
|
52
52
|
* @returns {string} combined string
|
|
53
53
|
*/
|
|
54
|
-
combine: (clientSeed, serverSeed, bitcoinHash, nonce) =>
|
|
54
|
+
combine: (clientSeed, serverSeed, bitcoinHash, nonce) => {
|
|
55
|
+
if (bitcoinHash) {
|
|
56
|
+
return clientSeed + serverSeed + bitcoinHash + nonce;
|
|
57
|
+
}
|
|
58
|
+
return clientSeed + serverSeed + nonce;
|
|
59
|
+
},
|
|
55
60
|
/**
|
|
56
61
|
* Generates a sha512 hash from a string
|
|
57
62
|
*
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IPlayer } from "../../types";
|
|
2
2
|
export interface ITable<TPlayer extends {
|
|
3
3
|
key: string;
|
|
4
4
|
} = IPlayer> {
|
|
5
5
|
forehandIdx: number;
|
|
6
|
-
cards: Array<Array<IPlayedCard>>;
|
|
7
6
|
players: Array<TPlayer>;
|
|
8
7
|
nextHand(): TPlayer;
|
|
9
8
|
getPlayerByPosition(idx?: number, forehandFirst?: boolean): TPlayer;
|
package/dist/lib/constants.js
CHANGED
package/dist/lib/utils.js
CHANGED
|
@@ -13,7 +13,7 @@ export function getCardValue(card) {
|
|
|
13
13
|
return CARDS[card] !== undefined ? CARDS[card] : -2;
|
|
14
14
|
}
|
|
15
15
|
export function checkHandWinner(rounds, forehandTeamIdx) {
|
|
16
|
-
var _a, _b, _c;
|
|
16
|
+
var _a, _b, _c, _d;
|
|
17
17
|
const roundsWon = {
|
|
18
18
|
0: 0,
|
|
19
19
|
1: 0,
|
|
@@ -27,17 +27,21 @@ export function checkHandWinner(rounds, forehandTeamIdx) {
|
|
|
27
27
|
roundsWon.ties = roundsWon.ties + 1;
|
|
28
28
|
continue;
|
|
29
29
|
}
|
|
30
|
-
if (
|
|
30
|
+
if (round.unbeatable) {
|
|
31
|
+
roundsWon[(_a = round.winner) === null || _a === void 0 ? void 0 : _a.teamIdx] += 1;
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (((_b = round.winner) === null || _b === void 0 ? void 0 : _b.teamIdx) === 0) {
|
|
31
35
|
roundsWon[0] += 1;
|
|
32
36
|
}
|
|
33
|
-
if (((
|
|
37
|
+
if (((_c = round.winner) === null || _c === void 0 ? void 0 : _c.teamIdx) === 1) {
|
|
34
38
|
roundsWon[1] += 1;
|
|
35
39
|
}
|
|
36
40
|
}
|
|
37
41
|
if (roundsWon[0] > 2 && roundsWon[1] > 2) {
|
|
38
42
|
return forehandTeamIdx;
|
|
39
43
|
}
|
|
40
|
-
if (rounds.length > 2 && roundsWon.ties > 0 && ((
|
|
44
|
+
if (rounds.length > 2 && roundsWon.ties > 0 && ((_d = rounds[0]) === null || _d === void 0 ? void 0 : _d.winner)) {
|
|
41
45
|
return rounds[0].winner.teamIdx;
|
|
42
46
|
}
|
|
43
47
|
if (roundsWon[0] >= 2 && roundsWon[1] < 2) {
|
package/dist/types.d.ts
CHANGED