trucoshi 7.0.0-alpha.2 → 7.0.0-rc.2
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 +9 -5
- package/dist/lib/utils.d.ts +1 -2
- package/dist/lib/utils.js +0 -17
- package/dist/types.d.ts +19 -2
- package/dist/types.js +1 -0
- package/package.json +1 -1
package/dist/lib/classes/Deck.js
CHANGED
|
@@ -44,13 +44,17 @@ export function dealCards(table, deck) {
|
|
|
44
44
|
playerHands[player.idx] = [...(playerHands[player.idx] || []), deck.takeCard()];
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
if (cheat_lots_of_flowers
|
|
47
|
+
if (cheat_lots_of_flowers) {
|
|
48
48
|
deck.shuffle(players[0].idx);
|
|
49
49
|
for (const player of players) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
if (Math.random() > 0.50) {
|
|
51
|
+
const first = deck.takeCard();
|
|
52
|
+
const second = deck.pick(deck.cards.find((c) => c.charAt(1) === first.charAt(1)));
|
|
53
|
+
const third = deck.pick(deck.cards.find((c) => c.charAt(1) === first.charAt(1)));
|
|
54
|
+
playerHands[player.idx] = [first, second, third];
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
playerHands[player.idx] = deck.takeThree();
|
|
54
58
|
}
|
|
55
59
|
}
|
|
56
60
|
for (const [key, player] of table.players.entries()) {
|
package/dist/lib/utils.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { IRound } from "../truco";
|
|
2
|
-
import { ICard
|
|
3
|
-
export declare function calculateFlorPoints(player: IPlayer): number;
|
|
2
|
+
import { ICard } from "../types";
|
|
4
3
|
export declare function getMaxNumberIndex<T = number>(array: Array<T>): number;
|
|
5
4
|
export declare function getMinNumberIndex<T = number>(array: Array<T>): number;
|
|
6
5
|
export declare function getCardValue(card: ICard): number;
|
package/dist/lib/utils.js
CHANGED
|
@@ -1,21 +1,4 @@
|
|
|
1
|
-
import { splitCardvalues } from "../truco";
|
|
2
1
|
import { CARDS } from "./constants";
|
|
3
|
-
// Calculates the Flor points for a player's hand.
|
|
4
|
-
// Returns the sum of the envidoValue of three cards of the same suit plus 20, or 0 if no Flor exists.
|
|
5
|
-
export function calculateFlorPoints(player) {
|
|
6
|
-
if (!player.hasFlor) {
|
|
7
|
-
return 0;
|
|
8
|
-
}
|
|
9
|
-
const hand = [...player.hand, ...player.usedHand].map(splitCardvalues);
|
|
10
|
-
// Verify that all cards share the same suit (should be true if player.hasFlor is set)
|
|
11
|
-
const sameSuit = hand.every((card) => card.palo === hand[0].palo);
|
|
12
|
-
if (!sameSuit) {
|
|
13
|
-
return 0;
|
|
14
|
-
}
|
|
15
|
-
// Sum the envidoValue of all cards (figures are 0)
|
|
16
|
-
const points = hand.reduce((sum, card) => sum + card.value, 20);
|
|
17
|
-
return points;
|
|
18
|
-
}
|
|
19
2
|
export function getMaxNumberIndex(array) {
|
|
20
3
|
return array.reduce((accumulator, current, index) => {
|
|
21
4
|
return current > array[accumulator] ? index : accumulator;
|
package/dist/types.d.ts
CHANGED
|
@@ -39,6 +39,16 @@ export interface ISaidCommand {
|
|
|
39
39
|
player: IPlayer | IPublicPlayer;
|
|
40
40
|
command: ECommand | number;
|
|
41
41
|
}
|
|
42
|
+
export interface IMatchFlorBattle {
|
|
43
|
+
matchSessionId: string;
|
|
44
|
+
playersWithFlor: {
|
|
45
|
+
idx: number;
|
|
46
|
+
cards?: ICard[];
|
|
47
|
+
points: number;
|
|
48
|
+
}[];
|
|
49
|
+
winnerTeamIdx: 0 | 1 | null;
|
|
50
|
+
winner: IPublicPlayer | null;
|
|
51
|
+
}
|
|
42
52
|
export interface IMatchPreviousHand {
|
|
43
53
|
envido: {
|
|
44
54
|
winner: IPublicPlayer;
|
|
@@ -48,6 +58,7 @@ export interface IMatchPreviousHand {
|
|
|
48
58
|
};
|
|
49
59
|
} | null;
|
|
50
60
|
flor: {
|
|
61
|
+
winner: IPublicPlayer | null;
|
|
51
62
|
data: Array<{
|
|
52
63
|
idx: number;
|
|
53
64
|
value: number;
|
|
@@ -64,6 +75,7 @@ export interface IPublicMatch {
|
|
|
64
75
|
busy: boolean;
|
|
65
76
|
state: EMatchState;
|
|
66
77
|
handState: EHandState | null;
|
|
78
|
+
florBattle: IMatchFlorBattle | null;
|
|
67
79
|
winner: ITeam | null;
|
|
68
80
|
matchSessionId: string;
|
|
69
81
|
ownerKey: string;
|
|
@@ -144,6 +156,7 @@ export declare enum EHandState {
|
|
|
144
156
|
WAITING_ENVIDO_ANSWER = "WAITING_ENVIDO_ANSWER",
|
|
145
157
|
WAITING_ENVIDO_POINTS_ANSWER = "WAITING_ENVIDO_POINTS_ANSWER",
|
|
146
158
|
WAITING_FLOR_ANSWER = "WAITING_FLOR_ANSWER",
|
|
159
|
+
DISPLAY_FLOR_BATTLE = "DISPLAY_FLOR_BATTLE",
|
|
147
160
|
BEFORE_FINISHED = "BEFORE_FINISHED",
|
|
148
161
|
FINISHED = "FINISHED"
|
|
149
162
|
}
|
|
@@ -270,7 +283,11 @@ export interface IPlayer {
|
|
|
270
283
|
turnExpiresAt: number | null;
|
|
271
284
|
turnExtensionExpiresAt: number | null;
|
|
272
285
|
hasFlor: boolean;
|
|
273
|
-
|
|
286
|
+
flor: {
|
|
287
|
+
value: number;
|
|
288
|
+
cards: ICard[];
|
|
289
|
+
} | null;
|
|
290
|
+
hasSaidFlor: boolean;
|
|
274
291
|
hasSaidEnvidoPoints: boolean;
|
|
275
292
|
isEnvidoTurn: boolean;
|
|
276
293
|
isOwner: boolean;
|
|
@@ -278,7 +295,7 @@ export interface IPlayer {
|
|
|
278
295
|
abandoned: boolean;
|
|
279
296
|
ready: boolean;
|
|
280
297
|
saidEnvidoPoints(): void;
|
|
281
|
-
|
|
298
|
+
saidFlor(): void;
|
|
282
299
|
resetCommands(): void;
|
|
283
300
|
calculateEnvido(): Array<{
|
|
284
301
|
value: number;
|
package/dist/types.js
CHANGED
|
@@ -52,6 +52,7 @@ export var EHandState;
|
|
|
52
52
|
EHandState["WAITING_ENVIDO_ANSWER"] = "WAITING_ENVIDO_ANSWER";
|
|
53
53
|
EHandState["WAITING_ENVIDO_POINTS_ANSWER"] = "WAITING_ENVIDO_POINTS_ANSWER";
|
|
54
54
|
EHandState["WAITING_FLOR_ANSWER"] = "WAITING_FLOR_ANSWER";
|
|
55
|
+
EHandState["DISPLAY_FLOR_BATTLE"] = "DISPLAY_FLOR_BATTLE";
|
|
55
56
|
EHandState["BEFORE_FINISHED"] = "BEFORE_FINISHED";
|
|
56
57
|
EHandState["FINISHED"] = "FINISHED";
|
|
57
58
|
})(EHandState || (EHandState = {}));
|