@skyblock-finance/actions 0.0.1 → 0.0.3
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/data/$schema.json +147 -0
- package/data/bits-crafts.json +921 -0
- package/data/bits.json +350 -0
- package/data/gems.json +90 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/data.d.ts +52 -21
- package/dist/data.js +4 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +6 -1
- package/dist/schema.d.ts +59 -51
- package/dist/schema.js +16 -14
- package/dist/types.d.ts +7 -0
- package/dist/types.js +2 -0
- package/package.json +2 -1
- package/source/data.test.ts +60 -63
- package/source/data.ts +5 -2
- package/source/index.ts +13 -1
- package/source/schema.ts +15 -18
- package/source/types.ts +13 -0
package/dist/data.d.ts
CHANGED
|
@@ -5,10 +5,8 @@ export declare const bits: {
|
|
|
5
5
|
type: "item";
|
|
6
6
|
} | {
|
|
7
7
|
amount: number;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
amount: number;
|
|
11
|
-
type: "coin";
|
|
8
|
+
id: "bit" | "coin" | "gem" | "northStar" | "second" | "usd";
|
|
9
|
+
type: "currency";
|
|
12
10
|
})[];
|
|
13
11
|
outputs: ({
|
|
14
12
|
amount: number;
|
|
@@ -16,14 +14,15 @@ export declare const bits: {
|
|
|
16
14
|
type: "item";
|
|
17
15
|
} | {
|
|
18
16
|
amount: number;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
amount: number;
|
|
22
|
-
type: "coin";
|
|
17
|
+
id: "bit" | "coin" | "gem" | "northStar" | "second" | "usd";
|
|
18
|
+
type: "currency";
|
|
23
19
|
})[];
|
|
24
20
|
place: ({
|
|
25
21
|
id: string;
|
|
26
22
|
type: "npc";
|
|
23
|
+
} | {
|
|
24
|
+
type: "website";
|
|
25
|
+
url: string;
|
|
27
26
|
} | {
|
|
28
27
|
type: "workbench";
|
|
29
28
|
grid: ({
|
|
@@ -40,25 +39,58 @@ export declare const bitsCrafts: {
|
|
|
40
39
|
type: "item";
|
|
41
40
|
} | {
|
|
42
41
|
amount: number;
|
|
43
|
-
|
|
42
|
+
id: "bit" | "coin" | "gem" | "northStar" | "second" | "usd";
|
|
43
|
+
type: "currency";
|
|
44
|
+
})[];
|
|
45
|
+
outputs: ({
|
|
46
|
+
amount: number;
|
|
47
|
+
id: string;
|
|
48
|
+
type: "item";
|
|
44
49
|
} | {
|
|
45
50
|
amount: number;
|
|
46
|
-
|
|
51
|
+
id: "bit" | "coin" | "gem" | "northStar" | "second" | "usd";
|
|
52
|
+
type: "currency";
|
|
47
53
|
})[];
|
|
48
|
-
|
|
54
|
+
place: ({
|
|
55
|
+
id: string;
|
|
56
|
+
type: "npc";
|
|
57
|
+
} | {
|
|
58
|
+
type: "website";
|
|
59
|
+
url: string;
|
|
60
|
+
} | {
|
|
61
|
+
type: "workbench";
|
|
62
|
+
grid: ({
|
|
63
|
+
amount: number;
|
|
64
|
+
id: string;
|
|
65
|
+
type: "item";
|
|
66
|
+
} | null)[];
|
|
67
|
+
})[];
|
|
68
|
+
}[];
|
|
69
|
+
export declare const gems: {
|
|
70
|
+
inputs: ({
|
|
49
71
|
amount: number;
|
|
50
72
|
id: string;
|
|
51
73
|
type: "item";
|
|
52
74
|
} | {
|
|
53
75
|
amount: number;
|
|
54
|
-
|
|
76
|
+
id: "bit" | "coin" | "gem" | "northStar" | "second" | "usd";
|
|
77
|
+
type: "currency";
|
|
78
|
+
})[];
|
|
79
|
+
outputs: ({
|
|
80
|
+
amount: number;
|
|
81
|
+
id: string;
|
|
82
|
+
type: "item";
|
|
55
83
|
} | {
|
|
56
84
|
amount: number;
|
|
57
|
-
|
|
85
|
+
id: "bit" | "coin" | "gem" | "northStar" | "second" | "usd";
|
|
86
|
+
type: "currency";
|
|
58
87
|
})[];
|
|
59
88
|
place: ({
|
|
60
89
|
id: string;
|
|
61
90
|
type: "npc";
|
|
91
|
+
} | {
|
|
92
|
+
type: "website";
|
|
93
|
+
url: string;
|
|
62
94
|
} | {
|
|
63
95
|
type: "workbench";
|
|
64
96
|
grid: ({
|
|
@@ -75,10 +107,8 @@ export declare const allActions: {
|
|
|
75
107
|
type: "item";
|
|
76
108
|
} | {
|
|
77
109
|
amount: number;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
amount: number;
|
|
81
|
-
type: "coin";
|
|
110
|
+
id: "bit" | "coin" | "gem" | "northStar" | "second" | "usd";
|
|
111
|
+
type: "currency";
|
|
82
112
|
})[];
|
|
83
113
|
outputs: ({
|
|
84
114
|
amount: number;
|
|
@@ -86,14 +116,15 @@ export declare const allActions: {
|
|
|
86
116
|
type: "item";
|
|
87
117
|
} | {
|
|
88
118
|
amount: number;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
amount: number;
|
|
92
|
-
type: "coin";
|
|
119
|
+
id: "bit" | "coin" | "gem" | "northStar" | "second" | "usd";
|
|
120
|
+
type: "currency";
|
|
93
121
|
})[];
|
|
94
122
|
place: ({
|
|
95
123
|
id: string;
|
|
96
124
|
type: "npc";
|
|
125
|
+
} | {
|
|
126
|
+
type: "website";
|
|
127
|
+
url: string;
|
|
97
128
|
} | {
|
|
98
129
|
type: "workbench";
|
|
99
130
|
grid: ({
|
package/dist/data.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.allActions = exports.bitsCrafts = exports.bits = void 0;
|
|
3
|
+
exports.allActions = exports.gems = exports.bitsCrafts = exports.bits = void 0;
|
|
4
4
|
const bits_json_1 = require("../data/bits.json");
|
|
5
5
|
const bits_crafts_json_1 = require("../data/bits-crafts.json");
|
|
6
|
+
const gems_json_1 = require("../data/gems.json");
|
|
6
7
|
exports.bits = bits_json_1.actions;
|
|
7
8
|
exports.bitsCrafts = bits_crafts_json_1.actions;
|
|
8
|
-
exports.
|
|
9
|
+
exports.gems = gems_json_1.actions;
|
|
10
|
+
exports.allActions = [...exports.bits, ...exports.bitsCrafts, ...exports.gems];
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -14,5 +14,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.actionSchema = exports.actionPlaceSchema = exports.actionIoSchema = exports.actionIoItemSchema = void 0;
|
|
17
18
|
__exportStar(require("./data"), exports);
|
|
18
|
-
|
|
19
|
+
var schema_1 = require("./schema");
|
|
20
|
+
Object.defineProperty(exports, "actionIoItemSchema", { enumerable: true, get: function () { return schema_1.actionIoItemSchema; } });
|
|
21
|
+
Object.defineProperty(exports, "actionIoSchema", { enumerable: true, get: function () { return schema_1.actionIoSchema; } });
|
|
22
|
+
Object.defineProperty(exports, "actionPlaceSchema", { enumerable: true, get: function () { return schema_1.actionPlaceSchema; } });
|
|
23
|
+
Object.defineProperty(exports, "actionSchema", { enumerable: true, get: function () { return schema_1.actionSchema; } });
|
package/dist/schema.d.ts
CHANGED
|
@@ -12,25 +12,31 @@ export declare const actionIoItemSchema: z.ZodObject<{
|
|
|
12
12
|
id: string;
|
|
13
13
|
type: "item";
|
|
14
14
|
}>;
|
|
15
|
-
export
|
|
16
|
-
export declare const actionIoSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
15
|
+
export declare const actionIoCurrencySchema: z.ZodObject<{
|
|
17
16
|
amount: z.ZodNumber;
|
|
18
|
-
|
|
17
|
+
id: z.ZodEnum<["bit", "coin", "gem", "northStar", "second", "usd"]>;
|
|
18
|
+
type: z.ZodLiteral<"currency">;
|
|
19
19
|
}, "strict", z.ZodTypeAny, {
|
|
20
20
|
amount: number;
|
|
21
|
-
|
|
21
|
+
id: "bit" | "coin" | "gem" | "northStar" | "second" | "usd";
|
|
22
|
+
type: "currency";
|
|
22
23
|
}, {
|
|
23
24
|
amount: number;
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
id: "bit" | "coin" | "gem" | "northStar" | "second" | "usd";
|
|
26
|
+
type: "currency";
|
|
27
|
+
}>;
|
|
28
|
+
export declare const actionIoSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
26
29
|
amount: z.ZodNumber;
|
|
27
|
-
|
|
30
|
+
id: z.ZodEnum<["bit", "coin", "gem", "northStar", "second", "usd"]>;
|
|
31
|
+
type: z.ZodLiteral<"currency">;
|
|
28
32
|
}, "strict", z.ZodTypeAny, {
|
|
29
33
|
amount: number;
|
|
30
|
-
|
|
34
|
+
id: "bit" | "coin" | "gem" | "northStar" | "second" | "usd";
|
|
35
|
+
type: "currency";
|
|
31
36
|
}, {
|
|
32
37
|
amount: number;
|
|
33
|
-
|
|
38
|
+
id: "bit" | "coin" | "gem" | "northStar" | "second" | "usd";
|
|
39
|
+
type: "currency";
|
|
34
40
|
}>, z.ZodObject<{
|
|
35
41
|
amount: z.ZodNumber;
|
|
36
42
|
id: z.ZodString;
|
|
@@ -44,7 +50,6 @@ export declare const actionIoSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObjec
|
|
|
44
50
|
id: string;
|
|
45
51
|
type: "item";
|
|
46
52
|
}>]>;
|
|
47
|
-
export type ActionIo = z.output<typeof actionIoSchema>;
|
|
48
53
|
export declare const actionPlaceSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
49
54
|
id: z.ZodString;
|
|
50
55
|
type: z.ZodLiteral<"npc">;
|
|
@@ -54,6 +59,15 @@ export declare const actionPlaceSchema: z.ZodDiscriminatedUnion<"type", [z.ZodOb
|
|
|
54
59
|
}, {
|
|
55
60
|
id: string;
|
|
56
61
|
type: "npc";
|
|
62
|
+
}>, z.ZodObject<{
|
|
63
|
+
type: z.ZodLiteral<"website">;
|
|
64
|
+
url: z.ZodString;
|
|
65
|
+
}, "strict", z.ZodTypeAny, {
|
|
66
|
+
type: "website";
|
|
67
|
+
url: string;
|
|
68
|
+
}, {
|
|
69
|
+
type: "website";
|
|
70
|
+
url: string;
|
|
57
71
|
}>, z.ZodObject<{
|
|
58
72
|
grid: z.ZodArray<z.ZodNullable<z.ZodObject<{
|
|
59
73
|
amount: z.ZodNumber;
|
|
@@ -87,22 +101,16 @@ export declare const actionPlaceSchema: z.ZodDiscriminatedUnion<"type", [z.ZodOb
|
|
|
87
101
|
export declare const actionSchema: z.ZodObject<{
|
|
88
102
|
inputs: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
89
103
|
amount: z.ZodNumber;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
amount: number;
|
|
93
|
-
type: "bit";
|
|
94
|
-
}, {
|
|
95
|
-
amount: number;
|
|
96
|
-
type: "bit";
|
|
97
|
-
}>, z.ZodObject<{
|
|
98
|
-
amount: z.ZodNumber;
|
|
99
|
-
type: z.ZodLiteral<"coin">;
|
|
104
|
+
id: z.ZodEnum<["bit", "coin", "gem", "northStar", "second", "usd"]>;
|
|
105
|
+
type: z.ZodLiteral<"currency">;
|
|
100
106
|
}, "strict", z.ZodTypeAny, {
|
|
101
107
|
amount: number;
|
|
102
|
-
|
|
108
|
+
id: "bit" | "coin" | "gem" | "northStar" | "second" | "usd";
|
|
109
|
+
type: "currency";
|
|
103
110
|
}, {
|
|
104
111
|
amount: number;
|
|
105
|
-
|
|
112
|
+
id: "bit" | "coin" | "gem" | "northStar" | "second" | "usd";
|
|
113
|
+
type: "currency";
|
|
106
114
|
}>, z.ZodObject<{
|
|
107
115
|
amount: z.ZodNumber;
|
|
108
116
|
id: z.ZodString;
|
|
@@ -118,22 +126,16 @@ export declare const actionSchema: z.ZodObject<{
|
|
|
118
126
|
}>]>, "many">;
|
|
119
127
|
outputs: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
120
128
|
amount: z.ZodNumber;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
amount: number;
|
|
124
|
-
type: "bit";
|
|
125
|
-
}, {
|
|
126
|
-
amount: number;
|
|
127
|
-
type: "bit";
|
|
128
|
-
}>, z.ZodObject<{
|
|
129
|
-
amount: z.ZodNumber;
|
|
130
|
-
type: z.ZodLiteral<"coin">;
|
|
129
|
+
id: z.ZodEnum<["bit", "coin", "gem", "northStar", "second", "usd"]>;
|
|
130
|
+
type: z.ZodLiteral<"currency">;
|
|
131
131
|
}, "strict", z.ZodTypeAny, {
|
|
132
132
|
amount: number;
|
|
133
|
-
|
|
133
|
+
id: "bit" | "coin" | "gem" | "northStar" | "second" | "usd";
|
|
134
|
+
type: "currency";
|
|
134
135
|
}, {
|
|
135
136
|
amount: number;
|
|
136
|
-
|
|
137
|
+
id: "bit" | "coin" | "gem" | "northStar" | "second" | "usd";
|
|
138
|
+
type: "currency";
|
|
137
139
|
}>, z.ZodObject<{
|
|
138
140
|
amount: z.ZodNumber;
|
|
139
141
|
id: z.ZodString;
|
|
@@ -156,6 +158,15 @@ export declare const actionSchema: z.ZodObject<{
|
|
|
156
158
|
}, {
|
|
157
159
|
id: string;
|
|
158
160
|
type: "npc";
|
|
161
|
+
}>, z.ZodObject<{
|
|
162
|
+
type: z.ZodLiteral<"website">;
|
|
163
|
+
url: z.ZodString;
|
|
164
|
+
}, "strict", z.ZodTypeAny, {
|
|
165
|
+
type: "website";
|
|
166
|
+
url: string;
|
|
167
|
+
}, {
|
|
168
|
+
type: "website";
|
|
169
|
+
url: string;
|
|
159
170
|
}>, z.ZodObject<{
|
|
160
171
|
grid: z.ZodArray<z.ZodNullable<z.ZodObject<{
|
|
161
172
|
amount: z.ZodNumber;
|
|
@@ -193,10 +204,8 @@ export declare const actionSchema: z.ZodObject<{
|
|
|
193
204
|
type: "item";
|
|
194
205
|
} | {
|
|
195
206
|
amount: number;
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
amount: number;
|
|
199
|
-
type: "coin";
|
|
207
|
+
id: "bit" | "coin" | "gem" | "northStar" | "second" | "usd";
|
|
208
|
+
type: "currency";
|
|
200
209
|
})[];
|
|
201
210
|
outputs: ({
|
|
202
211
|
amount: number;
|
|
@@ -204,14 +213,15 @@ export declare const actionSchema: z.ZodObject<{
|
|
|
204
213
|
type: "item";
|
|
205
214
|
} | {
|
|
206
215
|
amount: number;
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
amount: number;
|
|
210
|
-
type: "coin";
|
|
216
|
+
id: "bit" | "coin" | "gem" | "northStar" | "second" | "usd";
|
|
217
|
+
type: "currency";
|
|
211
218
|
})[];
|
|
212
219
|
place: ({
|
|
213
220
|
id: string;
|
|
214
221
|
type: "npc";
|
|
222
|
+
} | {
|
|
223
|
+
type: "website";
|
|
224
|
+
url: string;
|
|
215
225
|
} | {
|
|
216
226
|
type: "workbench";
|
|
217
227
|
grid: ({
|
|
@@ -227,10 +237,8 @@ export declare const actionSchema: z.ZodObject<{
|
|
|
227
237
|
type: "item";
|
|
228
238
|
} | {
|
|
229
239
|
amount: number;
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
amount: number;
|
|
233
|
-
type: "coin";
|
|
240
|
+
id: "bit" | "coin" | "gem" | "northStar" | "second" | "usd";
|
|
241
|
+
type: "currency";
|
|
234
242
|
})[];
|
|
235
243
|
outputs: ({
|
|
236
244
|
amount: number;
|
|
@@ -238,14 +246,15 @@ export declare const actionSchema: z.ZodObject<{
|
|
|
238
246
|
type: "item";
|
|
239
247
|
} | {
|
|
240
248
|
amount: number;
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
amount: number;
|
|
244
|
-
type: "coin";
|
|
249
|
+
id: "bit" | "coin" | "gem" | "northStar" | "second" | "usd";
|
|
250
|
+
type: "currency";
|
|
245
251
|
})[];
|
|
246
252
|
place: ({
|
|
247
253
|
id: string;
|
|
248
254
|
type: "npc";
|
|
255
|
+
} | {
|
|
256
|
+
type: "website";
|
|
257
|
+
url: string;
|
|
249
258
|
} | {
|
|
250
259
|
type: "workbench";
|
|
251
260
|
grid: ({
|
|
@@ -255,4 +264,3 @@ export declare const actionSchema: z.ZodObject<{
|
|
|
255
264
|
} | null)[];
|
|
256
265
|
})[];
|
|
257
266
|
}>;
|
|
258
|
-
export type Action = z.output<typeof actionSchema>;
|
package/dist/schema.js
CHANGED
|
@@ -1,27 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.actionSchema = exports.actionPlaceSchema = exports.actionIoSchema = exports.actionIoItemSchema = void 0;
|
|
3
|
+
exports.actionSchema = exports.actionPlaceSchema = exports.actionIoSchema = exports.actionIoCurrencySchema = exports.actionIoItemSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
exports.actionIoItemSchema = zod_1.z
|
|
6
6
|
.object({
|
|
7
|
-
amount: zod_1.z.number().
|
|
7
|
+
amount: zod_1.z.number().finite(),
|
|
8
8
|
id: zod_1.z.string(),
|
|
9
9
|
type: zod_1.z.literal('item'),
|
|
10
10
|
})
|
|
11
11
|
.strict();
|
|
12
|
+
exports.actionIoCurrencySchema = zod_1.z
|
|
13
|
+
.object({
|
|
14
|
+
amount: zod_1.z.number().finite(),
|
|
15
|
+
id: zod_1.z.enum(['bit', 'coin', 'gem', 'northStar', 'second', 'usd']),
|
|
16
|
+
type: zod_1.z.literal('currency'),
|
|
17
|
+
})
|
|
18
|
+
.strict();
|
|
12
19
|
exports.actionIoSchema = zod_1.z.discriminatedUnion('type', [
|
|
13
|
-
|
|
14
|
-
.object({
|
|
15
|
-
amount: zod_1.z.number().int().finite(),
|
|
16
|
-
type: zod_1.z.literal('bit'),
|
|
17
|
-
})
|
|
18
|
-
.strict(),
|
|
19
|
-
zod_1.z
|
|
20
|
-
.object({
|
|
21
|
-
amount: zod_1.z.number().int().finite(),
|
|
22
|
-
type: zod_1.z.literal('coin'),
|
|
23
|
-
})
|
|
24
|
-
.strict(),
|
|
20
|
+
exports.actionIoCurrencySchema,
|
|
25
21
|
exports.actionIoItemSchema,
|
|
26
22
|
]);
|
|
27
23
|
exports.actionPlaceSchema = zod_1.z.discriminatedUnion('type', [
|
|
@@ -31,6 +27,12 @@ exports.actionPlaceSchema = zod_1.z.discriminatedUnion('type', [
|
|
|
31
27
|
type: zod_1.z.literal('npc'),
|
|
32
28
|
})
|
|
33
29
|
.strict(),
|
|
30
|
+
zod_1.z
|
|
31
|
+
.object({
|
|
32
|
+
type: zod_1.z.literal('website'),
|
|
33
|
+
url: zod_1.z.string().url(),
|
|
34
|
+
})
|
|
35
|
+
.strict(),
|
|
34
36
|
zod_1.z
|
|
35
37
|
.object({
|
|
36
38
|
grid: zod_1.z.array(exports.actionIoItemSchema.nullable()).length(9),
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { actionIoCurrencySchema, actionIoItemSchema, actionIoSchema, actionSchema } from './schema';
|
|
3
|
+
export type Action = z.output<typeof actionSchema>;
|
|
4
|
+
export type ActionCurrency = z.output<typeof actionIoCurrencySchema.shape.id>;
|
|
5
|
+
export type ActionIo = z.output<typeof actionIoSchema>;
|
|
6
|
+
export type ActionIoCurrency = z.output<typeof actionIoCurrencySchema>;
|
|
7
|
+
export type ActionIoItem = z.output<typeof actionIoItemSchema>;
|
package/dist/types.js
ADDED
package/package.json
CHANGED
package/source/data.test.ts
CHANGED
|
@@ -1,85 +1,82 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { actionSchema } from './schema'
|
|
2
2
|
import { allActions } from './data'
|
|
3
3
|
import { z } from 'zod'
|
|
4
4
|
import { describe, expect, test } from 'bun:test'
|
|
5
5
|
import assert from 'node:assert'
|
|
6
|
+
import { ActionIoItem } from './types'
|
|
6
7
|
|
|
7
8
|
test('all actions follow the schema', () => {
|
|
8
9
|
expect(() => z.array(actionSchema).parse(allActions)).not.toThrow()
|
|
9
10
|
})
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
const result = new Map<string, number>()
|
|
12
|
+
/**
|
|
13
|
+
* Simplifies and "sorts" action input/output items
|
|
14
|
+
*/
|
|
15
|
+
const sumUp = (ios: ActionIoItem[]): Map<string, number> => {
|
|
16
|
+
const result = new Map<string, number>()
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return result
|
|
18
|
+
for (const io of ios) {
|
|
19
|
+
const previousValue = result.get(io.id) ?? 0
|
|
20
|
+
result.set(io.id, previousValue + io.amount)
|
|
24
21
|
}
|
|
25
22
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
23
|
+
return result
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
test('sumUp works', () => {
|
|
27
|
+
expect(
|
|
28
|
+
sumUp([
|
|
29
|
+
{
|
|
30
|
+
amount: 1,
|
|
31
|
+
id: 'FOO',
|
|
32
|
+
type: 'item',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
amount: 2,
|
|
36
|
+
id: 'BAR',
|
|
37
|
+
type: 'item',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
amount: 1,
|
|
41
|
+
id: 'BAZ',
|
|
42
|
+
type: 'item',
|
|
43
|
+
},
|
|
44
|
+
]),
|
|
45
|
+
).toEqual(
|
|
46
|
+
sumUp([
|
|
47
|
+
{
|
|
48
|
+
amount: 1,
|
|
49
|
+
id: 'BAR',
|
|
50
|
+
type: 'item',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
amount: 1,
|
|
54
|
+
id: 'FOO',
|
|
55
|
+
type: 'item',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
amount: 1,
|
|
59
|
+
id: 'BAZ',
|
|
60
|
+
type: 'item',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
amount: 1,
|
|
64
|
+
id: 'BAR',
|
|
65
|
+
type: 'item',
|
|
66
|
+
},
|
|
67
|
+
]),
|
|
68
|
+
)
|
|
69
|
+
})
|
|
70
70
|
|
|
71
|
+
describe('every action’s inputs match its crafing grid', () => {
|
|
71
72
|
for (const action of allActions) {
|
|
72
73
|
for (const grid of action.place.filter((x) => x.type === 'workbench')) {
|
|
73
74
|
test(`${JSON.stringify(action.outputs)} is valid`, () => {
|
|
74
75
|
assert(grid.type === 'workbench')
|
|
75
76
|
|
|
76
|
-
const actual = sumUp(
|
|
77
|
-
action.inputs.filter((x) => x.type === 'item') as ActionIoItem[],
|
|
78
|
-
)
|
|
77
|
+
const actual = sumUp(action.inputs.filter((x) => x.type === 'item'))
|
|
79
78
|
|
|
80
|
-
const expected = sumUp(
|
|
81
|
-
grid.grid.filter((x) => x !== null) as ActionIoItem[],
|
|
82
|
-
)
|
|
79
|
+
const expected = sumUp(grid.grid.filter((x) => x !== null))
|
|
83
80
|
|
|
84
81
|
expect(actual).toEqual(expected)
|
|
85
82
|
})
|
package/source/data.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { actions as _bits } from '../data/bits.json'
|
|
2
2
|
import { actions as _bitsCrafts } from '../data/bits-crafts.json'
|
|
3
|
-
import {
|
|
3
|
+
import { actions as _gems } from '../data/gems.json'
|
|
4
|
+
import { Action } from './types'
|
|
4
5
|
|
|
5
6
|
export const bits = _bits as Action[]
|
|
6
7
|
export const bitsCrafts = _bitsCrafts as Action[]
|
|
7
8
|
|
|
8
|
-
export const
|
|
9
|
+
export const gems = _gems as Action[]
|
|
10
|
+
|
|
11
|
+
export const allActions = [...bits, ...bitsCrafts, ...gems]
|
package/source/index.ts
CHANGED
|
@@ -1,2 +1,14 @@
|
|
|
1
1
|
export * from './data'
|
|
2
|
-
export
|
|
2
|
+
export {
|
|
3
|
+
Action,
|
|
4
|
+
ActionCurrency,
|
|
5
|
+
ActionIo,
|
|
6
|
+
ActionIoCurrency,
|
|
7
|
+
ActionIoItem,
|
|
8
|
+
} from './types'
|
|
9
|
+
export {
|
|
10
|
+
actionIoItemSchema,
|
|
11
|
+
actionIoSchema,
|
|
12
|
+
actionPlaceSchema,
|
|
13
|
+
actionSchema,
|
|
14
|
+
} from './schema'
|