@adiakys/feeling-lucky 0.2.0 → 0.3.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 +53 -1
- package/dist/config/types.d.ts +5 -0
- package/dist/{de-B56NsnDF.js → de-CmzpGbNK.js} +11 -1
- package/dist/developer/panel.d.ts +1 -0
- package/dist/developer/settings.d.ts +1 -0
- package/dist/{es-9iWwCe8s.js → es-k_kS6Fn2.js} +11 -1
- package/dist/feeling-lucky.iife.js +395 -243
- package/dist/feeling-lucky.js +17 -41
- package/dist/{fr-Y2BcCS3U.js → fr-GuCZB1l4.js} +11 -1
- package/dist/games/cards/table.d.ts +3 -1
- package/dist/{i18n-it2FlmVZ.js → i18n-Cid8bj2R.js} +15 -5
- package/dist/icons-DTaPp44c.js +863 -0
- package/dist/{it-CNSOLgaT.js → it-BNztlqHd.js} +11 -1
- package/dist/locales/de/cards.d.ts +7 -0
- package/dist/locales/de/developer.d.ts +3 -0
- package/dist/locales/en/cards.d.ts +7 -0
- package/dist/locales/en/developer.d.ts +3 -0
- package/dist/locales/es/cards.d.ts +7 -0
- package/dist/locales/es/developer.d.ts +3 -0
- package/dist/locales/fr/cards.d.ts +7 -0
- package/dist/locales/fr/developer.d.ts +3 -0
- package/dist/locales/it/cards.d.ts +7 -0
- package/dist/locales/it/developer.d.ts +3 -0
- package/dist/mount-CMm0qSYk.js +6257 -0
- package/dist/multiplayer/blackjack.d.ts +35 -0
- package/dist/multiplayer/client.d.ts +55 -0
- package/dist/multiplayer/holdem.d.ts +21 -0
- package/dist/multiplayer/index.d.ts +2 -0
- package/dist/multiplayer/seats.d.ts +16 -0
- package/dist/multiplayer/shared.d.ts +33 -0
- package/dist/multiplayer-CN0t0j_F.js +502 -0
- package/dist/{panel-tWJMt9kl.js → panel-BVgq3Cm5.js} +158 -145
- package/dist/resolve-Dc48n2Jo.js +28 -0
- package/dist/room/room.d.ts +7 -1
- package/dist/runtime/context.d.ts +2 -1
- package/package.json +2 -2
- package/dist/mount-CBUkAcVV.js +0 -7109
package/README.md
CHANGED
|
@@ -69,6 +69,7 @@ Every field takes a value, a function, or a function returning a Promise.
|
|
|
69
69
|
| `onWin` | `(win: Win) => void` | none |
|
|
70
70
|
| `onClaim` | `(win: Win) => Promise<void>`; shows **Claim** on the certificate | no claim button |
|
|
71
71
|
| `developer` | `true` or `{ passwordHash? }`: enables the developer menu (Ctrl+Shift+L), behind a password when the hash is given | disabled |
|
|
72
|
+
| `multiplayer` | base URL of a [multiplayer server](#multiplayer), or `{ url, headers? }` | single player |
|
|
72
73
|
|
|
73
74
|
```ts
|
|
74
75
|
interface Prize {
|
|
@@ -177,6 +178,55 @@ interface Dealer {
|
|
|
177
178
|
|
|
178
179
|
Without `dealers`, the library's own illustrated dealer takes every shift; `dealers: []` leaves the tables without one.
|
|
179
180
|
|
|
181
|
+
## Multiplayer
|
|
182
|
+
|
|
183
|
+
Optional: with `multiplayer`, Blackjack and Texas Hold'em are played at shared tables, one per game, up to five players, each against the house.
|
|
184
|
+
|
|
185
|
+
- **Seats:** players watch from the rail and pick a free seat, the same places for everyone; they can move or stand up between hands. A browser holds one seat per table, whatever its tabs; a signed-in user holds one across devices.
|
|
186
|
+
- **Outcomes:** the server deals and draws them, with the same odds as single player, a dealer's bonus included; wins still reach `onWin` and `onClaim` in each player's browser.
|
|
187
|
+
- **Fallback:** without the server the room plays single player; the developer menu switches between the two.
|
|
188
|
+
- **Size:** the client code loads only when `multiplayer` is set.
|
|
189
|
+
|
|
190
|
+
```ts
|
|
191
|
+
createFeelingLucky({ prizes, multiplayer: '/feeling-lucky' });
|
|
192
|
+
|
|
193
|
+
createFeelingLucky({
|
|
194
|
+
prizes,
|
|
195
|
+
multiplayer: { url: 'https://tables.example.com/feeling-lucky', headers: async () => ({ Authorization: `Bearer ${await token()}` }) },
|
|
196
|
+
});
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
`headers` is asked for again on every request. On the same origin the browser's cookies go along, so the server sees the signed-in user.
|
|
200
|
+
|
|
201
|
+
### Server
|
|
202
|
+
|
|
203
|
+
In your ASP.NET Core app, from NuGet:
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
dotnet add package Adiakys.FeelingLucky
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
```cs
|
|
210
|
+
builder.Services.AddFeelingLucky();
|
|
211
|
+
app.MapFeelingLucky(); // /feeling-lucky, chain .RequireAuthorization() or .RequireCors() as needed
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Or standalone, from the container:
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
docker run -p 8080:8080 -e Cors__Origins__0=https://app.example.com ghcr.io/adiakys/feeling-lucky-server
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
| Option (`FeelingLucky__*` in the container) | Default |
|
|
221
|
+
|---|---|
|
|
222
|
+
| `Seats` | 5 |
|
|
223
|
+
| `Pace`: the time between two cards | 480 ms |
|
|
224
|
+
| `BettingTime`: from the first bet to the deal | 10 s |
|
|
225
|
+
| `ActionTime`: to hit, stand, call or fold | 20 s |
|
|
226
|
+
| `TimeZone`: the dealers' shifts, IANA id | the server's |
|
|
227
|
+
|
|
228
|
+
Tables live in memory: one instance, no storage.
|
|
229
|
+
|
|
180
230
|
## Structure
|
|
181
231
|
|
|
182
232
|
```
|
|
@@ -194,6 +244,7 @@ src/
|
|
|
194
244
|
locales/ en, it, es, fr, de
|
|
195
245
|
playground/ demo with sample prizes
|
|
196
246
|
tests/ unit (engine), e2e
|
|
247
|
+
server/ multiplayer server: the NuGet package, the standalone host, tests
|
|
197
248
|
```
|
|
198
249
|
|
|
199
250
|
### Rules
|
|
@@ -207,7 +258,7 @@ tests/ unit (engine), e2e
|
|
|
207
258
|
|
|
208
259
|
```bash
|
|
209
260
|
npm install
|
|
210
|
-
npm run dev # playground
|
|
261
|
+
npm run dev # playground; multiplayer through docker compose up -d
|
|
211
262
|
npm test # unit tests
|
|
212
263
|
npm run test:e2e # one smoke test per game
|
|
213
264
|
npm run typecheck
|
|
@@ -221,6 +272,7 @@ Publish a GitHub release or pre-release on a `v<version>` tag, e.g. `v1.2.0` or
|
|
|
221
272
|
- runs the checks;
|
|
222
273
|
- publishes the package to npm: `latest` for a release, `next` for a pre-release;
|
|
223
274
|
- attaches the packed `.tgz` to the release;
|
|
275
|
+
- publishes the server to NuGet through Trusted Publishing, and its image to `ghcr.io/adiakys/feeling-lucky-server`, `latest` for a release;
|
|
224
276
|
- deploys the playground to GitHub Pages, for releases only.
|
|
225
277
|
|
|
226
278
|
## License
|
package/dist/config/types.d.ts
CHANGED
|
@@ -33,6 +33,10 @@ export interface Player {
|
|
|
33
33
|
name: string;
|
|
34
34
|
avatar?: string;
|
|
35
35
|
}
|
|
36
|
+
export interface Multiplayer {
|
|
37
|
+
url: string;
|
|
38
|
+
headers?: Resolvable<Record<string, string>>;
|
|
39
|
+
}
|
|
36
40
|
export type Messages = {
|
|
37
41
|
[key: string]: string | Messages;
|
|
38
42
|
};
|
|
@@ -48,6 +52,7 @@ export interface FeelingLuckyConfig<V extends Variant = Variant> {
|
|
|
48
52
|
developer?: Resolvable<boolean | {
|
|
49
53
|
passwordHash?: string;
|
|
50
54
|
}>;
|
|
55
|
+
multiplayer?: Resolvable<string | Multiplayer>;
|
|
51
56
|
}
|
|
52
57
|
export interface FeelingLucky<V extends Variant = Variant> {
|
|
53
58
|
open(options?: {
|
|
@@ -337,7 +337,14 @@ var t = e({
|
|
|
337
337
|
cards: {
|
|
338
338
|
you: "Du",
|
|
339
339
|
dealer: "Bank",
|
|
340
|
-
deal: "Geben"
|
|
340
|
+
deal: "Geben",
|
|
341
|
+
player: "Spieler",
|
|
342
|
+
stand: "Vom Tisch aufstehen",
|
|
343
|
+
sit: "Hier hinsetzen",
|
|
344
|
+
chooseSeat: "Wähle einen Platz",
|
|
345
|
+
dealingIn: "Neue Hand in {seconds}s",
|
|
346
|
+
playIn: "{seconds}s zum Spielen",
|
|
347
|
+
nextHand: "Du spielst ab der nächsten Hand"
|
|
341
348
|
},
|
|
342
349
|
blackjack: {
|
|
343
350
|
print: "Bank steht bei 17 · Pik-Blackjack: Jackpot",
|
|
@@ -450,6 +457,9 @@ var t = e({
|
|
|
450
457
|
noTheme: "Keins",
|
|
451
458
|
language: "Sprache",
|
|
452
459
|
autoLanguage: "Automatisch",
|
|
460
|
+
tables: "Kartentische",
|
|
461
|
+
multiplayer: "Mehrspieler",
|
|
462
|
+
singlePlayer: "Einzelspieler",
|
|
453
463
|
dealer: "Croupier",
|
|
454
464
|
dealerShifts: "Nach den Schichten des Tages",
|
|
455
465
|
dealerAbsent: "Abwesend",
|
|
@@ -337,7 +337,14 @@ var t = e({
|
|
|
337
337
|
cards: {
|
|
338
338
|
you: "Tú",
|
|
339
339
|
dealer: "Banca",
|
|
340
|
-
deal: "Repartir"
|
|
340
|
+
deal: "Repartir",
|
|
341
|
+
player: "Jugador",
|
|
342
|
+
stand: "Levantarse de la mesa",
|
|
343
|
+
sit: "Siéntate aquí",
|
|
344
|
+
chooseSeat: "Elige un asiento",
|
|
345
|
+
dealingIn: "Se reparte en {seconds}s",
|
|
346
|
+
playIn: "{seconds}s para jugar",
|
|
347
|
+
nextHand: "Juegas desde la próxima mano"
|
|
341
348
|
},
|
|
342
349
|
blackjack: {
|
|
343
350
|
print: "Banca se planta en 17 · Blackjack de picas: jackpot",
|
|
@@ -450,6 +457,9 @@ var t = e({
|
|
|
450
457
|
noTheme: "Ninguno",
|
|
451
458
|
language: "Idioma",
|
|
452
459
|
autoLanguage: "Automático",
|
|
460
|
+
tables: "Mesas de cartas",
|
|
461
|
+
multiplayer: "Multijugador",
|
|
462
|
+
singlePlayer: "Un jugador",
|
|
453
463
|
dealer: "Crupier",
|
|
454
464
|
dealerShifts: "Según los turnos del día",
|
|
455
465
|
dealerAbsent: "Ausente",
|