trucoshi 12.1.0 → 12.2.0
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/README.md +4 -2
- package/dist/events.d.ts +9 -0
- package/dist/events.js +2 -0
- package/dist/lib/classes/Deck.d.ts +1 -1
- package/dist/lib/classes/Deck.js +46 -3
- package/dist/tutorials/basic-truco-v1.json +806 -0
- package/dist/tutorials/index.d.ts +11 -0
- package/dist/tutorials/index.js +238 -0
- package/dist/types.d.ts +58 -0
- package/package.json +2 -1
- package/prisma/client/edge.js +3 -3
- package/prisma/client/index-browser.js +2 -2
- package/prisma/client/index.d.ts +1 -1
- package/prisma/client/index.js +3 -3
- package/prisma/client/package.json +1 -1
- package/prisma/client/wasm.js +3 -3
package/README.md
CHANGED
|
@@ -30,9 +30,11 @@ Proba la demo actual en [Trucoshi](https://trucoshi.com)
|
|
|
30
30
|
|
|
31
31
|
Run the three-repo local stack from this repo with:
|
|
32
32
|
|
|
33
|
-
`yarn dev:all
|
|
33
|
+
`yarn dev:all`
|
|
34
34
|
|
|
35
|
-
Do not prefix
|
|
35
|
+
If your user cannot run Docker directly, use `yarn dev:all:sudo-docker`. Do not prefix either command with `sudo`; that mode only elevates Docker commands, so Yarn, Vite, generated Prisma files, and local links remain owned by your user.
|
|
36
|
+
|
|
37
|
+
The launcher keeps the local stack in development mode: Lightning Accounts, Trucoshi, and the Vite client. Its interactive control panel can show one service's logs at a time, display stack status, restart a service, and optionally build and host a client snapshot at `http://10.10.1.106:2993`. The snapshot is off by default, so it never slows Vite's hot-reload loop. Set `DEV_ALL_PUBLIC_HOST`, `DEV_ALL_CLIENT_HOST_PORT`, or `DEV_ALL_LOG_DIR` if you need different defaults.
|
|
36
38
|
|
|
37
39
|
# Test
|
|
38
40
|
|
package/dist/events.d.ts
CHANGED
|
@@ -56,6 +56,7 @@ export declare enum EClientEvent {
|
|
|
56
56
|
LOGOUT = "LOGOUT",
|
|
57
57
|
LEAVE_MATCH = "LEAVE_MATCH",
|
|
58
58
|
CREATE_MATCH = "CREATE_MATCH",
|
|
59
|
+
CREATE_TUTORIAL_MATCH = "CREATE_TUTORIAL_MATCH",
|
|
59
60
|
FETCH_ACCOUNT_DETAILS = "FETCH_ACCOUNT_DETAILS",
|
|
60
61
|
FETCH_MATCH_DETAILS = "FETCH_MATCH_DETAILS",
|
|
61
62
|
SET_MATCH_OPTIONS = "SET_MATCH_OPTIONS",
|
|
@@ -67,6 +68,7 @@ export declare enum EClientEvent {
|
|
|
67
68
|
PAUSE_MATCH = "PAUSE_MATCH",
|
|
68
69
|
PLAY_AGAIN = "PLAY_AGAIN",
|
|
69
70
|
JOIN_QUEUE = "JOIN_QUEUE",
|
|
71
|
+
FETCH_QUEUE_STATUS = "FETCH_QUEUE_STATUS",
|
|
70
72
|
LEAVE_QUEUE = "LEAVE_QUEUE",
|
|
71
73
|
CONFIRM_QUEUE_MATCH = "CONFIRM_QUEUE_MATCH",
|
|
72
74
|
DECLINE_QUEUE_MATCH = "DECLINE_QUEUE_MATCH",
|
|
@@ -103,6 +105,10 @@ export interface ClientToServerEvents {
|
|
|
103
105
|
match?: IPublicMatch;
|
|
104
106
|
activeMatches?: IPublicMatchInfo[];
|
|
105
107
|
}>) => void;
|
|
108
|
+
[EClientEvent.CREATE_TUTORIAL_MATCH]: (tutorialId: string | null | undefined, callback: IEventCallback<{
|
|
109
|
+
match?: IPublicMatch;
|
|
110
|
+
activeMatches?: IPublicMatchInfo[];
|
|
111
|
+
}>) => void;
|
|
106
112
|
[EClientEvent.SET_MATCH_OPTIONS]: (matchSessionId: string, options: Partial<ILobbyOptions>, callback: IEventCallback<{
|
|
107
113
|
match?: IPublicMatch;
|
|
108
114
|
activeMatches?: IPublicMatchInfo[];
|
|
@@ -132,6 +138,9 @@ export interface ClientToServerEvents {
|
|
|
132
138
|
[EClientEvent.JOIN_QUEUE]: (options: IJoinQueueOptions, callback: IEventCallback<{
|
|
133
139
|
status?: IQueueStatus;
|
|
134
140
|
}>) => void;
|
|
141
|
+
[EClientEvent.FETCH_QUEUE_STATUS]: (callback: IEventCallback<{
|
|
142
|
+
status?: IQueueStatus;
|
|
143
|
+
}>) => void;
|
|
135
144
|
[EClientEvent.LEAVE_QUEUE]: (callback?: IEventCallback<{}>) => void;
|
|
136
145
|
[EClientEvent.CONFIRM_QUEUE_MATCH]: (proposalId: string, callback?: IEventCallback<{
|
|
137
146
|
update?: IQueueReadyUpdate;
|
package/dist/events.js
CHANGED
|
@@ -28,6 +28,7 @@ export var EClientEvent;
|
|
|
28
28
|
EClientEvent["LOGOUT"] = "LOGOUT";
|
|
29
29
|
EClientEvent["LEAVE_MATCH"] = "LEAVE_MATCH";
|
|
30
30
|
EClientEvent["CREATE_MATCH"] = "CREATE_MATCH";
|
|
31
|
+
EClientEvent["CREATE_TUTORIAL_MATCH"] = "CREATE_TUTORIAL_MATCH";
|
|
31
32
|
EClientEvent["FETCH_ACCOUNT_DETAILS"] = "FETCH_ACCOUNT_DETAILS";
|
|
32
33
|
EClientEvent["FETCH_MATCH_DETAILS"] = "FETCH_MATCH_DETAILS";
|
|
33
34
|
EClientEvent["SET_MATCH_OPTIONS"] = "SET_MATCH_OPTIONS";
|
|
@@ -39,6 +40,7 @@ export var EClientEvent;
|
|
|
39
40
|
EClientEvent["PAUSE_MATCH"] = "PAUSE_MATCH";
|
|
40
41
|
EClientEvent["PLAY_AGAIN"] = "PLAY_AGAIN";
|
|
41
42
|
EClientEvent["JOIN_QUEUE"] = "JOIN_QUEUE";
|
|
43
|
+
EClientEvent["FETCH_QUEUE_STATUS"] = "FETCH_QUEUE_STATUS";
|
|
42
44
|
EClientEvent["LEAVE_QUEUE"] = "LEAVE_QUEUE";
|
|
43
45
|
EClientEvent["CONFIRM_QUEUE_MATCH"] = "CONFIRM_QUEUE_MATCH";
|
|
44
46
|
EClientEvent["DECLINE_QUEUE_MATCH"] = "DECLINE_QUEUE_MATCH";
|
|
@@ -6,6 +6,6 @@ export declare function dealCards<TPlayer extends {
|
|
|
6
6
|
key: string;
|
|
7
7
|
idx: number;
|
|
8
8
|
setHand(h: Array<ICard>): void;
|
|
9
|
-
} = IPlayer>(table: ITable<TPlayer>, deck: IDeck): void;
|
|
9
|
+
} = IPlayer>(table: ITable<TPlayer>, deck: IDeck, fixedHandsByPlayerIdx?: Record<string, ICard[]>): void;
|
|
10
10
|
export declare function shuffleArray<T = unknown>(array: Array<T>, getRandom?: (max: number) => number): Array<T>;
|
|
11
11
|
export declare function PlayedCard(player: IPlayer | IPublicPlayer, card: ICard, burn?: boolean): IPlayedCard;
|
package/dist/lib/classes/Deck.js
CHANGED
|
@@ -38,11 +38,54 @@ export function Deck() {
|
|
|
38
38
|
return deck;
|
|
39
39
|
}
|
|
40
40
|
export const getAllCards = () => Object.keys(CARDS);
|
|
41
|
-
|
|
41
|
+
const normalizeFixedHands = (table, fixedHandsByPlayerIdx) => {
|
|
42
|
+
if (!fixedHandsByPlayerIdx) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const fixedHands = new Map();
|
|
46
|
+
const usedCards = new Set();
|
|
47
|
+
const playersByIdx = new Set(table.players.map((player) => player.idx));
|
|
48
|
+
for (const [playerIdxText, cards] of Object.entries(fixedHandsByPlayerIdx)) {
|
|
49
|
+
const playerIdx = Number(playerIdxText);
|
|
50
|
+
if (!Number.isInteger(playerIdx) || !playersByIdx.has(playerIdx)) {
|
|
51
|
+
throw new Error(`Invalid fixed hand player index: ${playerIdxText}`);
|
|
52
|
+
}
|
|
53
|
+
if (!Array.isArray(cards) || cards.length !== 3) {
|
|
54
|
+
throw new Error(`Fixed hand for player ${playerIdx} must contain exactly 3 cards`);
|
|
55
|
+
}
|
|
56
|
+
for (const card of cards) {
|
|
57
|
+
if (!(card in CARDS)) {
|
|
58
|
+
throw new Error(`Invalid fixed hand card: ${card}`);
|
|
59
|
+
}
|
|
60
|
+
if (usedCards.has(card)) {
|
|
61
|
+
throw new Error(`Duplicate fixed hand card: ${card}`);
|
|
62
|
+
}
|
|
63
|
+
usedCards.add(card);
|
|
64
|
+
}
|
|
65
|
+
fixedHands.set(playerIdx, cards);
|
|
66
|
+
}
|
|
67
|
+
return fixedHands;
|
|
68
|
+
};
|
|
69
|
+
export function dealCards(table, deck, fixedHandsByPlayerIdx) {
|
|
42
70
|
const cheat_lots_of_flowers = process.env.APP_CHEAT_LOTS_OF_FLOWERS_FOR_TESTING === "1";
|
|
43
71
|
const cheat_cards = process.env.APP_CHEAT_CARDS || "";
|
|
44
72
|
const playerHands = [];
|
|
45
73
|
const players = table.getPlayersForehandFirst();
|
|
74
|
+
const fixedHands = normalizeFixedHands(table, fixedHandsByPlayerIdx);
|
|
75
|
+
if (fixedHands) {
|
|
76
|
+
for (const player of table.players) {
|
|
77
|
+
const fixedHand = fixedHands.get(player.idx);
|
|
78
|
+
playerHands[player.idx] = fixedHand
|
|
79
|
+
? fixedHand.map((card) => deck.pick(card) || (() => {
|
|
80
|
+
throw new Error(`Fixed hand card is not available in deck: ${card}`);
|
|
81
|
+
})())
|
|
82
|
+
: deck.takeThree();
|
|
83
|
+
}
|
|
84
|
+
for (const player of table.players) {
|
|
85
|
+
player.setHand(playerHands[player.idx]);
|
|
86
|
+
}
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
46
89
|
for (let i = 0; i < 3; i++) {
|
|
47
90
|
for (const player of players) {
|
|
48
91
|
playerHands[player.idx] = [...(playerHands[player.idx] || []), deck.takeCard()];
|
|
@@ -70,8 +113,8 @@ export function dealCards(table, deck) {
|
|
|
70
113
|
playerHands[player.idx] = deck.takeThree();
|
|
71
114
|
}
|
|
72
115
|
}
|
|
73
|
-
for (const
|
|
74
|
-
player.setHand(playerHands[
|
|
116
|
+
for (const player of table.players) {
|
|
117
|
+
player.setHand(playerHands[player.idx]);
|
|
75
118
|
}
|
|
76
119
|
}
|
|
77
120
|
const defaultGetRandom = (max) => Math.floor(Math.random() * max);
|