unocab 0.8.0 → 0.9.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 +24 -4
- package/{script → dist}/errors.d.ts +13 -3
- package/dist/game.d.ts +459 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +786 -0
- package/dist/types.d.ts +1106 -0
- package/{esm → dist}/utils.d.ts +4 -3
- package/package.json +17 -11
- package/esm/_dnt.shims.d.ts +0 -4
- package/esm/_dnt.shims.js +0 -62
- package/esm/_dnt.test_shims.d.ts +0 -7
- package/esm/deps/deno.land/std@0.190.0/fmt/colors.d.ts +0 -270
- package/esm/deps/deno.land/std@0.190.0/testing/_diff.d.ts +0 -26
- package/esm/deps/deno.land/std@0.190.0/testing/_format.d.ts +0 -1
- package/esm/deps/deno.land/std@0.190.0/testing/asserts.d.ts +0 -284
- package/esm/deps/deno.land/x/zod@v3.21.4/ZodError.d.ts +0 -163
- package/esm/deps/deno.land/x/zod@v3.21.4/ZodError.js +0 -148
- package/esm/deps/deno.land/x/zod@v3.21.4/errors.d.ts +0 -5
- package/esm/deps/deno.land/x/zod@v3.21.4/errors.js +0 -9
- package/esm/deps/deno.land/x/zod@v3.21.4/external.d.ts +0 -6
- package/esm/deps/deno.land/x/zod@v3.21.4/external.js +0 -6
- package/esm/deps/deno.land/x/zod@v3.21.4/helpers/enumUtil.d.ts +0 -8
- package/esm/deps/deno.land/x/zod@v3.21.4/helpers/enumUtil.js +0 -1
- package/esm/deps/deno.land/x/zod@v3.21.4/helpers/errorUtil.d.ts +0 -9
- package/esm/deps/deno.land/x/zod@v3.21.4/helpers/errorUtil.js +0 -5
- package/esm/deps/deno.land/x/zod@v3.21.4/helpers/parseUtil.d.ts +0 -78
- package/esm/deps/deno.land/x/zod@v3.21.4/helpers/parseUtil.js +0 -104
- package/esm/deps/deno.land/x/zod@v3.21.4/helpers/partialUtil.d.ts +0 -8
- package/esm/deps/deno.land/x/zod@v3.21.4/helpers/partialUtil.js +0 -1
- package/esm/deps/deno.land/x/zod@v3.21.4/helpers/typeAliases.d.ts +0 -2
- package/esm/deps/deno.land/x/zod@v3.21.4/helpers/typeAliases.js +0 -1
- package/esm/deps/deno.land/x/zod@v3.21.4/helpers/util.d.ts +0 -68
- package/esm/deps/deno.land/x/zod@v3.21.4/helpers/util.js +0 -138
- package/esm/deps/deno.land/x/zod@v3.21.4/index.d.ts +0 -4
- package/esm/deps/deno.land/x/zod@v3.21.4/index.js +0 -4
- package/esm/deps/deno.land/x/zod@v3.21.4/locales/en.d.ts +0 -3
- package/esm/deps/deno.land/x/zod@v3.21.4/locales/en.js +0 -127
- package/esm/deps/deno.land/x/zod@v3.21.4/mod.d.ts +0 -1
- package/esm/deps/deno.land/x/zod@v3.21.4/mod.js +0 -1
- package/esm/deps/deno.land/x/zod@v3.21.4/types.d.ts +0 -965
- package/esm/deps/deno.land/x/zod@v3.21.4/types.js +0 -3689
- package/esm/errors.d.ts +0 -72
- package/esm/errors.js +0 -39
- package/esm/game.d.ts +0 -868
- package/esm/game.js +0 -868
- package/esm/mod.d.ts +0 -3
- package/esm/mod.js +0 -3
- package/esm/package.json +0 -3
- package/esm/tests/basic-tests.d.ts +0 -8
- package/esm/tests/draw-tests.d.ts +0 -8
- package/esm/tests/non-specific-tests.test.d.ts +0 -1
- package/esm/tests/rule-violation-tests.d.ts +0 -8
- package/esm/tests/specific-tests.test.d.ts +0 -1
- package/esm/tests/test-utils.d.ts +0 -91
- package/esm/tests/turn-tests.d.ts +0 -8
- package/esm/types.d.ts +0 -2280
- package/esm/types.js +0 -152
- package/esm/utils.js +0 -44
- package/script/_dnt.shims.d.ts +0 -4
- package/script/_dnt.shims.js +0 -66
- package/script/_dnt.test_shims.d.ts +0 -7
- package/script/deps/deno.land/std@0.190.0/fmt/colors.d.ts +0 -270
- package/script/deps/deno.land/std@0.190.0/testing/_diff.d.ts +0 -26
- package/script/deps/deno.land/std@0.190.0/testing/_format.d.ts +0 -1
- package/script/deps/deno.land/std@0.190.0/testing/asserts.d.ts +0 -284
- package/script/deps/deno.land/x/zod@v3.21.4/ZodError.d.ts +0 -163
- package/script/deps/deno.land/x/zod@v3.21.4/ZodError.js +0 -152
- package/script/deps/deno.land/x/zod@v3.21.4/errors.d.ts +0 -5
- package/script/deps/deno.land/x/zod@v3.21.4/errors.js +0 -17
- package/script/deps/deno.land/x/zod@v3.21.4/external.d.ts +0 -6
- package/script/deps/deno.land/x/zod@v3.21.4/external.js +0 -22
- package/script/deps/deno.land/x/zod@v3.21.4/helpers/enumUtil.d.ts +0 -8
- package/script/deps/deno.land/x/zod@v3.21.4/helpers/enumUtil.js +0 -2
- package/script/deps/deno.land/x/zod@v3.21.4/helpers/errorUtil.d.ts +0 -9
- package/script/deps/deno.land/x/zod@v3.21.4/helpers/errorUtil.js +0 -8
- package/script/deps/deno.land/x/zod@v3.21.4/helpers/parseUtil.d.ts +0 -78
- package/script/deps/deno.land/x/zod@v3.21.4/helpers/parseUtil.js +0 -119
- package/script/deps/deno.land/x/zod@v3.21.4/helpers/partialUtil.d.ts +0 -8
- package/script/deps/deno.land/x/zod@v3.21.4/helpers/partialUtil.js +0 -2
- package/script/deps/deno.land/x/zod@v3.21.4/helpers/typeAliases.d.ts +0 -2
- package/script/deps/deno.land/x/zod@v3.21.4/helpers/typeAliases.js +0 -2
- package/script/deps/deno.land/x/zod@v3.21.4/helpers/util.d.ts +0 -68
- package/script/deps/deno.land/x/zod@v3.21.4/helpers/util.js +0 -142
- package/script/deps/deno.land/x/zod@v3.21.4/index.d.ts +0 -4
- package/script/deps/deno.land/x/zod@v3.21.4/index.js +0 -33
- package/script/deps/deno.land/x/zod@v3.21.4/locales/en.d.ts +0 -3
- package/script/deps/deno.land/x/zod@v3.21.4/locales/en.js +0 -129
- package/script/deps/deno.land/x/zod@v3.21.4/mod.d.ts +0 -1
- package/script/deps/deno.land/x/zod@v3.21.4/mod.js +0 -17
- package/script/deps/deno.land/x/zod@v3.21.4/types.d.ts +0 -965
- package/script/deps/deno.land/x/zod@v3.21.4/types.js +0 -3739
- package/script/errors.js +0 -43
- package/script/game.d.ts +0 -868
- package/script/game.js +0 -895
- package/script/mod.d.ts +0 -3
- package/script/mod.js +0 -19
- package/script/package.json +0 -3
- package/script/tests/basic-tests.d.ts +0 -8
- package/script/tests/draw-tests.d.ts +0 -8
- package/script/tests/non-specific-tests.test.d.ts +0 -1
- package/script/tests/rule-violation-tests.d.ts +0 -8
- package/script/tests/specific-tests.test.d.ts +0 -1
- package/script/tests/test-utils.d.ts +0 -91
- package/script/tests/turn-tests.d.ts +0 -8
- package/script/types.d.ts +0 -2280
- package/script/types.js +0 -155
- package/script/utils.d.ts +0 -19
- package/script/utils.js +0 -50
package/script/types.js
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.gameState = exports.shorthandGameState = exports.fullGameState = exports.infoEvent = exports.gameEvent = exports.chooseColorEvent = exports.passEvent = exports.drawEvent = exports.bluffCalledEvent = exports.cardPlayedEvent = exports.playerId = exports.card = exports.cardColor = exports.allCards = exports.specialCards = exports.nonColorSwitchingScs = exports.colorSwitchingScs = exports.regularCards = void 0;
|
|
4
|
-
const mod_js_1 = require("./deps/deno.land/x/zod@v3.21.4/mod.js");
|
|
5
|
-
/*
|
|
6
|
-
* This file exports both Zod types and TS types for everything
|
|
7
|
-
* Zod types start with a lowercase character, while TS types
|
|
8
|
-
* start with an uppercase character.
|
|
9
|
-
*/
|
|
10
|
-
// ─── Card Utils ──────────────────────────────────────────────────────────────
|
|
11
|
-
exports.regularCards = mod_js_1.z.enum([
|
|
12
|
-
"zero",
|
|
13
|
-
"one",
|
|
14
|
-
"two",
|
|
15
|
-
"three",
|
|
16
|
-
"four",
|
|
17
|
-
"five",
|
|
18
|
-
"six",
|
|
19
|
-
"seven",
|
|
20
|
-
"eight",
|
|
21
|
-
"nine",
|
|
22
|
-
]);
|
|
23
|
-
// color-switching special cards
|
|
24
|
-
exports.colorSwitchingScs = mod_js_1.z.enum(["plus-four", "color-chooser"]);
|
|
25
|
-
// non color-switching special cards
|
|
26
|
-
exports.nonColorSwitchingScs = mod_js_1.z.enum(["plus-two", "reverse", "skip"]);
|
|
27
|
-
exports.specialCards = mod_js_1.z.enum([
|
|
28
|
-
...exports.nonColorSwitchingScs.options,
|
|
29
|
-
...exports.colorSwitchingScs.options,
|
|
30
|
-
]);
|
|
31
|
-
// all cards = regular cards + special cards
|
|
32
|
-
exports.allCards = mod_js_1.z.enum([
|
|
33
|
-
...exports.regularCards.options,
|
|
34
|
-
...exports.specialCards.options,
|
|
35
|
-
]);
|
|
36
|
-
exports.cardColor = mod_js_1.z.enum(["red", "blue", "green", "yellow"]);
|
|
37
|
-
exports.card = mod_js_1.z.union([
|
|
38
|
-
mod_js_1.z.object({
|
|
39
|
-
type: mod_js_1.z.union([exports.regularCards, exports.nonColorSwitchingScs]),
|
|
40
|
-
color: exports.cardColor,
|
|
41
|
-
}),
|
|
42
|
-
mod_js_1.z.object({
|
|
43
|
-
type: exports.colorSwitchingScs,
|
|
44
|
-
color: mod_js_1.z.undefined(),
|
|
45
|
-
}),
|
|
46
|
-
]);
|
|
47
|
-
exports.playerId = mod_js_1.z.string();
|
|
48
|
-
// ─── Game Events ─────────────────────────────────────────────────────────────
|
|
49
|
-
exports.cardPlayedEvent = mod_js_1.z.object({
|
|
50
|
-
type: mod_js_1.z.literal("card_played"),
|
|
51
|
-
by: exports.playerId,
|
|
52
|
-
card: exports.card,
|
|
53
|
-
});
|
|
54
|
-
exports.bluffCalledEvent = mod_js_1.z.object({
|
|
55
|
-
type: mod_js_1.z.literal("bluff_called"),
|
|
56
|
-
by: exports.playerId,
|
|
57
|
-
});
|
|
58
|
-
exports.drawEvent = mod_js_1.z.object({
|
|
59
|
-
type: mod_js_1.z.literal("draw"),
|
|
60
|
-
by: exports.playerId,
|
|
61
|
-
});
|
|
62
|
-
exports.passEvent = mod_js_1.z.object({
|
|
63
|
-
type: mod_js_1.z.literal("pass"),
|
|
64
|
-
by: exports.playerId,
|
|
65
|
-
});
|
|
66
|
-
exports.chooseColorEvent = mod_js_1.z.object({
|
|
67
|
-
type: mod_js_1.z.literal("choose-color"),
|
|
68
|
-
by: exports.playerId,
|
|
69
|
-
color: exports.cardColor,
|
|
70
|
-
});
|
|
71
|
-
// the collective game event object
|
|
72
|
-
exports.gameEvent = mod_js_1.z.union([
|
|
73
|
-
exports.cardPlayedEvent,
|
|
74
|
-
exports.bluffCalledEvent,
|
|
75
|
-
exports.chooseColorEvent,
|
|
76
|
-
exports.drawEvent,
|
|
77
|
-
exports.passEvent,
|
|
78
|
-
]);
|
|
79
|
-
// the game info event is added the engine
|
|
80
|
-
exports.infoEvent = mod_js_1.z.object({
|
|
81
|
-
type: mod_js_1.z.literal("game_info"),
|
|
82
|
-
info: mod_js_1.z.union([
|
|
83
|
-
mod_js_1.z.object({
|
|
84
|
-
type: mod_js_1.z.literal("bluff_called"),
|
|
85
|
-
by: exports.playerId,
|
|
86
|
-
}),
|
|
87
|
-
mod_js_1.z.object({
|
|
88
|
-
type: mod_js_1.z.literal("bluff_call_succeeded"),
|
|
89
|
-
by: exports.playerId,
|
|
90
|
-
of: exports.playerId,
|
|
91
|
-
}),
|
|
92
|
-
mod_js_1.z.object({
|
|
93
|
-
type: mod_js_1.z.literal("bluff_call_failed"),
|
|
94
|
-
by: exports.playerId,
|
|
95
|
-
of: exports.playerId,
|
|
96
|
-
}),
|
|
97
|
-
mod_js_1.z.object({
|
|
98
|
-
type: mod_js_1.z.literal("seed_changed"),
|
|
99
|
-
newSeed: mod_js_1.z.number(),
|
|
100
|
-
}),
|
|
101
|
-
mod_js_1.z.object({
|
|
102
|
-
type: mod_js_1.z.literal("player_won"),
|
|
103
|
-
id: exports.playerId,
|
|
104
|
-
}),
|
|
105
|
-
mod_js_1.z.object({
|
|
106
|
-
type: mod_js_1.z.literal("game_ended"),
|
|
107
|
-
loser: exports.playerId,
|
|
108
|
-
}),
|
|
109
|
-
mod_js_1.z.object({
|
|
110
|
-
type: mod_js_1.z.literal("player_joined"),
|
|
111
|
-
id: exports.playerId,
|
|
112
|
-
}),
|
|
113
|
-
mod_js_1.z.object({
|
|
114
|
-
type: mod_js_1.z.literal("player_left"),
|
|
115
|
-
id: exports.playerId,
|
|
116
|
-
}),
|
|
117
|
-
mod_js_1.z.object({
|
|
118
|
-
type: mod_js_1.z.literal("pile_to_deck"),
|
|
119
|
-
}),
|
|
120
|
-
]),
|
|
121
|
-
});
|
|
122
|
-
// ─── Game Utils ──────────────────────────────────────────────────────────────
|
|
123
|
-
const commonGameState = {
|
|
124
|
-
// the index gets modulo'd with the player count to get the active player index
|
|
125
|
-
index: mod_js_1.z.number(),
|
|
126
|
-
initialSeed: mod_js_1.z.number(),
|
|
127
|
-
players: exports.playerId.array(),
|
|
128
|
-
// game options
|
|
129
|
-
stackPlusTwos: mod_js_1.z.boolean(),
|
|
130
|
-
// this is a cache, since all of the info here can be obtained from the
|
|
131
|
-
// events array; but since it's expensive to do that all the time, we
|
|
132
|
-
// can keep it here. note that re-obtaining this info in shorthand mode
|
|
133
|
-
// is not possible, since past events are not kept, so it acts as state.
|
|
134
|
-
cache: mod_js_1.z.object({
|
|
135
|
-
hands: mod_js_1.z.record(exports.playerId, exports.card.array()),
|
|
136
|
-
deck: exports.card.array(),
|
|
137
|
-
seed: mod_js_1.z.number(),
|
|
138
|
-
stackedPlusTwos: mod_js_1.z.number(),
|
|
139
|
-
turnStep: mod_js_1.z.union([mod_js_1.z.literal(1), mod_js_1.z.literal(-1)]),
|
|
140
|
-
ended: mod_js_1.z.boolean(),
|
|
141
|
-
pile: exports.card.array(),
|
|
142
|
-
last3CardPlayOrColorChanges: mod_js_1.z.union([exports.card, exports.cardColor]).array(),
|
|
143
|
-
}),
|
|
144
|
-
};
|
|
145
|
-
exports.fullGameState = mod_js_1.z.object({
|
|
146
|
-
shorthandMode: mod_js_1.z.literal(false),
|
|
147
|
-
...commonGameState,
|
|
148
|
-
events: mod_js_1.z.union([exports.gameEvent, exports.infoEvent]).array(),
|
|
149
|
-
});
|
|
150
|
-
exports.shorthandGameState = mod_js_1.z.object({
|
|
151
|
-
shorthandMode: mod_js_1.z.literal(true),
|
|
152
|
-
...commonGameState,
|
|
153
|
-
events: exports.gameEvent.array(),
|
|
154
|
-
});
|
|
155
|
-
exports.gameState = mod_js_1.z.union([exports.fullGameState, exports.shorthandGameState]);
|
package/script/utils.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export declare const ENGINE_ID = "ENGINE";
|
|
2
|
-
export declare const MAX_SHORTHAND_EVENTS = 5;
|
|
3
|
-
export declare const MIN_PLAYERS = 2;
|
|
4
|
-
export declare const MAX_PLAYERS = 10;
|
|
5
|
-
export declare const DECK: ({
|
|
6
|
-
type: "reverse" | "zero" | "one" | "two" | "three" | "four" | "five" | "six" | "seven" | "eight" | "nine" | "plus-two" | "skip";
|
|
7
|
-
color: "red" | "blue" | "green" | "yellow";
|
|
8
|
-
} | {
|
|
9
|
-
type: "plus-four" | "color-chooser";
|
|
10
|
-
color?: undefined;
|
|
11
|
-
})[];
|
|
12
|
-
export declare function cyrb128(str: string): number;
|
|
13
|
-
export declare function includes<T>(arr: T[], v: unknown): v is T;
|
|
14
|
-
export declare function exhaustive(_: never): void;
|
|
15
|
-
type Without<T, U> = {
|
|
16
|
-
[P in Exclude<keyof T, keyof U>]?: never;
|
|
17
|
-
};
|
|
18
|
-
export type XOR<T, U> = T | U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
|
|
19
|
-
export {};
|
package/script/utils.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.exhaustive = exports.includes = exports.cyrb128 = exports.DECK = exports.MAX_PLAYERS = exports.MIN_PLAYERS = exports.MAX_SHORTHAND_EVENTS = exports.ENGINE_ID = void 0;
|
|
4
|
-
const types_js_1 = require("./types.js");
|
|
5
|
-
// 36 chars by default to match uuid length
|
|
6
|
-
exports.ENGINE_ID = "ENGINE";
|
|
7
|
-
// we need at least 5 events, since 3 events are taken
|
|
8
|
-
// up for +4, choose color, and call bluff, and the 4th
|
|
9
|
-
// last event is hence needed to check for bluff. The fifth
|
|
10
|
-
// last card is kept just in case it's needed for checkEvent.
|
|
11
|
-
exports.MAX_SHORTHAND_EVENTS = 5;
|
|
12
|
-
// the minimum and maximum number of players in a game
|
|
13
|
-
exports.MIN_PLAYERS = 2;
|
|
14
|
-
exports.MAX_PLAYERS = 10;
|
|
15
|
-
const [zero, ...nonZeroRegularTypes] = types_js_1.regularCards.options;
|
|
16
|
-
const twoCardTypes = [...nonZeroRegularTypes, ...types_js_1.nonColorSwitchingScs.options];
|
|
17
|
-
exports.DECK = [
|
|
18
|
-
// one zero of each color
|
|
19
|
-
...types_js_1.cardColor.options.map((color) => ({
|
|
20
|
-
type: zero,
|
|
21
|
-
color,
|
|
22
|
-
})),
|
|
23
|
-
// two of one-nine, plus-two, reverse, and skip of each color
|
|
24
|
-
...types_js_1.cardColor.options.flatMap((color) => twoCardTypes.flatMap((type) => Array(2).fill({ type, color }))),
|
|
25
|
-
// four of each of the color switching special cards
|
|
26
|
-
...types_js_1.colorSwitchingScs.options.flatMap((type) => Array(4).fill({ type })),
|
|
27
|
-
];
|
|
28
|
-
// stackoverflow.com/questions/521295/seeding-the-random-number-generator-in-javascript
|
|
29
|
-
function cyrb128(str) {
|
|
30
|
-
let h1 = 1779033703, h2 = 3144134277, h3 = 1013904242, h4 = 2773480762;
|
|
31
|
-
for (let i = 0, k; i < str.length; i++) {
|
|
32
|
-
k = str.charCodeAt(i);
|
|
33
|
-
h1 = h2 ^ Math.imul(h1 ^ k, 597399067);
|
|
34
|
-
h2 = h3 ^ Math.imul(h2 ^ k, 2869860233);
|
|
35
|
-
h3 = h4 ^ Math.imul(h3 ^ k, 951274213);
|
|
36
|
-
h4 = h1 ^ Math.imul(h4 ^ k, 2716044179);
|
|
37
|
-
}
|
|
38
|
-
h1 = Math.imul(h3 ^ (h1 >>> 18), 597399067);
|
|
39
|
-
h2 = Math.imul(h4 ^ (h2 >>> 22), 2869860233);
|
|
40
|
-
h3 = Math.imul(h1 ^ (h3 >>> 17), 951274213);
|
|
41
|
-
h4 = Math.imul(h2 ^ (h4 >>> 19), 2716044179);
|
|
42
|
-
return (h1 ^ h2 ^ h3 ^ h4) >>> 0;
|
|
43
|
-
}
|
|
44
|
-
exports.cyrb128 = cyrb128;
|
|
45
|
-
function includes(arr, v) {
|
|
46
|
-
return arr.includes(v);
|
|
47
|
-
}
|
|
48
|
-
exports.includes = includes;
|
|
49
|
-
function exhaustive(_) { }
|
|
50
|
-
exports.exhaustive = exhaustive;
|