@kradle/challenges 0.0.1

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.
Files changed (49) hide show
  1. package/README.md +1 -0
  2. package/biome.json +39 -0
  3. package/dist/actions.d.ts +203 -0
  4. package/dist/actions.d.ts.map +1 -0
  5. package/dist/actions.js +287 -0
  6. package/dist/actions.js.map +1 -0
  7. package/dist/api_utils.d.ts +5 -0
  8. package/dist/api_utils.d.ts.map +1 -0
  9. package/dist/api_utils.js +13 -0
  10. package/dist/api_utils.js.map +1 -0
  11. package/dist/challenge.d.ts +56 -0
  12. package/dist/challenge.d.ts.map +1 -0
  13. package/dist/challenge.js +462 -0
  14. package/dist/challenge.js.map +1 -0
  15. package/dist/commands.d.ts +38 -0
  16. package/dist/commands.d.ts.map +1 -0
  17. package/dist/commands.js +135 -0
  18. package/dist/commands.js.map +1 -0
  19. package/dist/constants.d.ts +70 -0
  20. package/dist/constants.d.ts.map +1 -0
  21. package/dist/constants.js +112 -0
  22. package/dist/constants.js.map +1 -0
  23. package/dist/index.d.ts +5 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +23 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/testmode.d.ts +3 -0
  28. package/dist/testmode.d.ts.map +1 -0
  29. package/dist/testmode.js +19 -0
  30. package/dist/testmode.js.map +1 -0
  31. package/dist/types.d.ts +103 -0
  32. package/dist/types.d.ts.map +1 -0
  33. package/dist/types.js +10 -0
  34. package/dist/types.js.map +1 -0
  35. package/dist/utils.d.ts +17 -0
  36. package/dist/utils.d.ts.map +1 -0
  37. package/dist/utils.js +22 -0
  38. package/dist/utils.js.map +1 -0
  39. package/package.json +27 -0
  40. package/src/actions.ts +388 -0
  41. package/src/api_utils.ts +10 -0
  42. package/src/challenge.ts +553 -0
  43. package/src/commands.ts +141 -0
  44. package/src/constants.ts +121 -0
  45. package/src/index.ts +4 -0
  46. package/src/testmode.ts +18 -0
  47. package/src/types.ts +136 -0
  48. package/src/utils.ts +22 -0
  49. package/tsconfig.json +38 -0
package/README.md ADDED
@@ -0,0 +1 @@
1
+ Kradle's Challenges API.
package/biome.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "files": {
3
+ "includes": ["src/**/*.ts"]
4
+ },
5
+ "formatter": {
6
+ "lineWidth": 120
7
+ },
8
+ "linter": {
9
+ "rules": {
10
+ "suspicious": {
11
+ "noExplicitAny": "off",
12
+ "useIterableCallbackReturn": "off"
13
+ },
14
+ "correctness": {
15
+ "noUnusedImports": {
16
+ "level": "error",
17
+ "fix": "safe"
18
+ },
19
+ "noUnusedVariables": {
20
+ "options": {
21
+ "ignoreRestSiblings": true
22
+ }
23
+ }
24
+ }
25
+ }
26
+ },
27
+ "assist": {
28
+ "actions": {
29
+ "source": {
30
+ "organizeImports": {
31
+ "level": "on",
32
+ "options": {
33
+ "groups": [":NODE:", ":BLANK_LINE:", ":PACKAGE:", ":BLANK_LINE:", ":PATH:"]
34
+ }
35
+ }
36
+ }
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,203 @@
1
+ import { type GAMERULES, type JSONTextComponent, type Score, SelectorClass } from "sandstone";
2
+ import type { ATTRIBUTES, BLOCKS, ENTITY_TYPES, ITEMS } from "sandstone/arguments/generated";
3
+ import type { LiteralStringUnion } from "./utils";
4
+ export type TargetNames = LiteralStringUnion<"all" | "self"> | SelectorClass<any, any>;
5
+ export declare function mapTarget(target: string | SelectorClass): SelectorClass<any, any> | string;
6
+ export type Action = () => unknown;
7
+ export declare const Actions: {
8
+ /**
9
+ * Send a chat message to everyone.
10
+ * @param {JSONTextComponent} message - The message to send.
11
+ */
12
+ announce: ({ message }: {
13
+ message: JSONTextComponent;
14
+ }) => () => void;
15
+ /**
16
+ * Clear the inventory of a target.
17
+ * @param {TargetNames} target - The target to clear the inventory of.
18
+ */
19
+ clear: ({ target }: {
20
+ target: TargetNames;
21
+ }) => () => void;
22
+ /**
23
+ * Custom action allowing to run any Sandstone command.
24
+ *
25
+ * @param {() => void} callback - The function to execute.
26
+ */
27
+ custom: (callback: () => void) => () => void;
28
+ /**
29
+ * Fill a region with a block.
30
+ * @param {BLOCKS} block - The block to fill the region with.
31
+ * @param {number} x1 - The x coordinate of the region.
32
+ * @param {number} y1 - The y coordinate of the region.
33
+ * @param {number} z1 - The z coordinate of the region.
34
+ * @param {number} x2 - The x coordinate of the region.
35
+ * @param {number} y2 - The y coordinate of the region.
36
+ * @param {number} z2 - The z coordinate of the region.
37
+ * @param {boolean} absolute - Whether the coordinates are absolute or relative.
38
+ */
39
+ fill: ({ block, x1, y1, z1, x2, y2, z2, absolute, mode, }: {
40
+ block: BLOCKS;
41
+ x1: number;
42
+ y1: number;
43
+ z1: number;
44
+ x2: number;
45
+ y2: number;
46
+ z2: number;
47
+ absolute: boolean;
48
+ mode: "fill" | "line" | "pyramid";
49
+ }) => () => void;
50
+ /**
51
+ * Give an item to a target.
52
+ * @param {ITEMS} item - The item to give.
53
+ * @param {TargetNames} target - The target to give the item to.
54
+ * @param {number} count - The number of items to give.
55
+ */
56
+ give: ({ item, target, count }: {
57
+ item: ITEMS;
58
+ target: TargetNames;
59
+ count?: number;
60
+ }) => () => void;
61
+ /**
62
+ * Give loot to a target with a weighted chance for selecting one of the items.
63
+ * @param {{ name: ITEMS, count: number, weight: number }[]} items - The items to give.
64
+ * @param {TargetNames} target - The target to give the item to.
65
+ */
66
+ giveLoot: ({ items, target }: {
67
+ items: [{
68
+ name: ITEMS;
69
+ count: number;
70
+ weight: number;
71
+ }];
72
+ target: TargetNames;
73
+ }) => () => void;
74
+ /**
75
+ * Set a gamerule.
76
+ * @param {GAMERULES} rule - The name of the gamerule.
77
+ * @param {boolean | number} value - The value to set the gamerule to.
78
+ */
79
+ gamerule: ({ rule, value }: {
80
+ rule: GAMERULES;
81
+ value: boolean | number;
82
+ }) => () => void;
83
+ /**
84
+ * Kill entities matching a selector.
85
+ * @param {SelectorArgument} selector - The entities to kill.
86
+ */
87
+ kill: ({ selector }: {
88
+ selector: TargetNames;
89
+ }) => () => void;
90
+ /**
91
+ * Set an attribute for a target.
92
+ * @param {ATTRIBUTES} attribute_ - The attribute to set.
93
+ * @param {number} value - The value to set the attribute to.
94
+ * @param {TargetNames} target - The target to set the attribute for.
95
+ */
96
+ setAttribute: ({ attribute_, value, target }: {
97
+ attribute_: ATTRIBUTES;
98
+ value: number;
99
+ target: TargetNames;
100
+ }) => () => void;
101
+ /**
102
+ * Set the time of day.
103
+ * @param {'day' | 'night'} time_ - The time to set.
104
+ */
105
+ setTime: ({ time }: {
106
+ time: "day" | "night";
107
+ }) => () => void;
108
+ /**
109
+ * Summon multiple entities at a specific location.
110
+ */
111
+ summonMultiple: (params: {
112
+ entity: ENTITY_TYPES;
113
+ count: number;
114
+ x: number;
115
+ y: number;
116
+ z: number;
117
+ absolute: boolean;
118
+ }) => () => void;
119
+ /**
120
+ * Set a block at a specific location.
121
+ */
122
+ setBlock: (params: {
123
+ block: BLOCKS;
124
+ x: number;
125
+ y: number;
126
+ z: number;
127
+ absolute: boolean;
128
+ }) => () => void;
129
+ /**
130
+ * Teleport entities to a specific location.
131
+ * @param {TargetNames} target - The entities to teleport.
132
+ * @param {number} x - The x coordinate of the destination.
133
+ * @param {number} y - The y coordinate of the destination.
134
+ * @param {number} z - The z coordinate of the destination.
135
+ * @param {boolean} absolute - Whether the coordinates are absolute or relative.
136
+ */
137
+ teleport: ({ target, x, y, z, absolute, }: {
138
+ target: TargetNames;
139
+ x: number;
140
+ y: number;
141
+ z: number;
142
+ absolute: boolean;
143
+ }) => () => import("sandstone/commands/implementations").TeleportFacing;
144
+ /**
145
+ * Send a chat message to a target.
146
+ * @param {string[]} message - The message to send.
147
+ * @param {TargetNames} target - The target to send the message to.
148
+ */
149
+ tellraw: ({ message, target }: {
150
+ message: string[];
151
+ target: TargetNames;
152
+ }) => () => void;
153
+ /**
154
+ * Increment a score variable by 1.
155
+ * @param variable - The score variable to increment.
156
+ */
157
+ increment: ({ variable }: {
158
+ variable: Score;
159
+ }) => () => void;
160
+ /**
161
+ * Decrement a score variable by 1.
162
+ * @param variable - The score variable to decrement.
163
+ */
164
+ decrement: ({ variable }: {
165
+ variable: Score;
166
+ }) => () => void;
167
+ /**
168
+ * Set a score variable to a specific value.
169
+ * @param variable - The score variable to set.
170
+ * @param value - The value to set the score variable to, which can be a number or another score variable.
171
+ */
172
+ set: ({ variable, value }: {
173
+ variable: Score;
174
+ value: number | Score;
175
+ }) => () => void;
176
+ /**
177
+ * log a message with the watcher
178
+ * @param {string} message - The message to send.
179
+ * @param {Score} variable - The variable to log.
180
+ * @param {boolean} store - Whether to store the variable in the backend.
181
+ */
182
+ log_variable: ({ message, variable, store }: {
183
+ message: string;
184
+ variable: Score;
185
+ store: boolean;
186
+ }) => () => void;
187
+ /**
188
+ * Summon an item at a specific location.
189
+ * @param {ITEMS} item - The item to summon.
190
+ * @param {number} x - The x coordinate of the location.
191
+ * @param {number} y - The y coordinate of the location.
192
+ * @param {number} z - The z coordinate of the location.
193
+ * @param {boolean} absolute - Whether the coordinates are absolute or relative.
194
+ */
195
+ summonItem: ({ item, x, y, z, absolute }: {
196
+ item: ITEMS;
197
+ x: number;
198
+ y: number;
199
+ z: number;
200
+ absolute: boolean;
201
+ }) => () => void;
202
+ };
203
+ //# sourceMappingURL=actions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AACA,OAAO,EAMN,KAAK,SAAS,EAGd,KAAK,iBAAiB,EAOtB,KAAK,KAAK,EAEV,aAAa,EAOb,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAG7F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAGlD,MAAM,MAAM,WAAW,GAAG,kBAAkB,CAAC,KAAK,GAAG,MAAM,CAAC,GAAG,a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C,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE;CAMxD,CAAC"}
@@ -0,0 +1,287 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Actions = void 0;
7
+ exports.mapTarget = mapTarget;
8
+ const node_crypto_1 = __importDefault(require("node:crypto"));
9
+ const sandstone_1 = require("sandstone");
10
+ const commands_1 = require("./commands");
11
+ const constants_1 = require("./constants");
12
+ function mapTarget(target) {
13
+ switch (target) {
14
+ case "all":
15
+ return constants_1.ALL;
16
+ case "self":
17
+ return "@s";
18
+ }
19
+ if (target instanceof sandstone_1.SelectorClass) {
20
+ return target;
21
+ }
22
+ // check if the target is a valid entity type
23
+ if (target.startsWith("minecraft:")) {
24
+ return (0, sandstone_1.Selector)("@e", { type: target });
25
+ }
26
+ return (0, sandstone_1.Selector)("@a", { tag: target }); // Assuming the target is a team name
27
+ }
28
+ exports.Actions = {
29
+ /**
30
+ * Send a chat message to everyone.
31
+ * @param {JSONTextComponent} message - The message to send.
32
+ */
33
+ announce: ({ message }) => {
34
+ return () => {
35
+ (0, sandstone_1.tellraw)("@a", ["\n", { text: constants_1.DISPLAY_TAG, color: "aqua" }, " | ", message, "\n"]);
36
+ };
37
+ },
38
+ /**
39
+ * Clear the inventory of a target.
40
+ * @param {TargetNames} target - The target to clear the inventory of.
41
+ */
42
+ clear: ({ target }) => {
43
+ return () => (0, sandstone_1.clear)(mapTarget(target));
44
+ },
45
+ /**
46
+ * Custom action allowing to run any Sandstone command.
47
+ *
48
+ * @param {() => void} callback - The function to execute.
49
+ */
50
+ custom: (callback) => {
51
+ return () => callback();
52
+ },
53
+ /**
54
+ * Fill a region with a block.
55
+ * @param {BLOCKS} block - The block to fill the region with.
56
+ * @param {number} x1 - The x coordinate of the region.
57
+ * @param {number} y1 - The y coordinate of the region.
58
+ * @param {number} z1 - The z coordinate of the region.
59
+ * @param {number} x2 - The x coordinate of the region.
60
+ * @param {number} y2 - The y coordinate of the region.
61
+ * @param {number} z2 - The z coordinate of the region.
62
+ * @param {boolean} absolute - Whether the coordinates are absolute or relative.
63
+ */
64
+ fill: ({ block, x1, y1, z1, x2, y2, z2, absolute, mode, }) => {
65
+ return () => {
66
+ // fill the region with the block
67
+ if (mode === "fill") {
68
+ const coordinates1 = absolute ? (0, sandstone_1.abs)(x1, y1, z1) : (0, sandstone_1.rel)(x1, y1, z1);
69
+ const coordinates2 = absolute ? (0, sandstone_1.abs)(x2, y2, z2) : (0, sandstone_1.rel)(x2, y2, z2);
70
+ (0, sandstone_1.fill)(coordinates1, coordinates2, block);
71
+ return;
72
+ }
73
+ // draw a line from the first coordinate to the second coordinate
74
+ if (mode === "line") {
75
+ const dx = x2 - x1;
76
+ const dy = y2 - y1;
77
+ const dz = z2 - z1;
78
+ const length = Math.max(Math.abs(dx), Math.abs(dy), Math.abs(dz));
79
+ const stepX = dx / length || 0;
80
+ const stepY = dy / length || 0;
81
+ const stepZ = dz / length || 0;
82
+ for (let i = 0; i <= length; i++) {
83
+ const x = Math.round(x1 + stepX * i);
84
+ const y = Math.round(y1 + stepY * i);
85
+ const z = Math.round(z1 + stepZ * i);
86
+ (0, sandstone_1.setblock)(absolute ? (0, sandstone_1.abs)(x, y, z) : (0, sandstone_1.rel)(x, y, z), block);
87
+ }
88
+ return;
89
+ }
90
+ if (mode === "pyramid") {
91
+ const height = Math.abs(y2);
92
+ const direction = Math.sign(y2); // +1 for up, -1 for down
93
+ for (let i = 0; i < height; i++) {
94
+ const y = y1 + i * direction;
95
+ const layerRadius = (height - 1 - i) * 2;
96
+ const minX = x1 - layerRadius;
97
+ const maxX = x1 + layerRadius;
98
+ const minZ = z1 - layerRadius;
99
+ const maxZ = z1 + layerRadius;
100
+ for (let x = minX; x <= maxX; x++) {
101
+ for (let z = minZ; z <= maxZ; z++) {
102
+ (0, sandstone_1.setblock)(absolute ? (0, sandstone_1.abs)(x, y, z) : (0, sandstone_1.rel)(x, y, z), block);
103
+ }
104
+ }
105
+ }
106
+ return;
107
+ }
108
+ // if mode is not fill or line, throw an error
109
+ throw new Error(`Invalid fill mode: ${mode}`);
110
+ };
111
+ },
112
+ /**
113
+ * Give an item to a target.
114
+ * @param {ITEMS} item - The item to give.
115
+ * @param {TargetNames} target - The target to give the item to.
116
+ * @param {number} count - The number of items to give.
117
+ */
118
+ give: ({ item, target, count = 1 }) => {
119
+ return () => (0, sandstone_1.give)(mapTarget(target), item, count);
120
+ },
121
+ /**
122
+ * Give loot to a target with a weighted chance for selecting one of the items.
123
+ * @param {{ name: ITEMS, count: number, weight: number }[]} items - The items to give.
124
+ * @param {TargetNames} target - The target to give the item to.
125
+ */
126
+ giveLoot: ({ items, target }) => {
127
+ // sort incoming items and create a hash for table re-use
128
+ const lootItemsSorted = items.sort((a, b) => a.name.localeCompare(b.name));
129
+ const lootItemsJson = JSON.stringify(lootItemsSorted);
130
+ const lootItemsHash = node_crypto_1.default.createHash("sha256").update(lootItemsJson).digest("hex");
131
+ const lootTableName = `loot_${lootItemsHash}`.slice(0, 16);
132
+ // create the entries for the loot table
133
+ const entries = items.map((item) => ({
134
+ type: "minecraft:item",
135
+ name: item.name,
136
+ weight: item.weight,
137
+ functions: [
138
+ {
139
+ function: "set_count",
140
+ count: item.count,
141
+ },
142
+ ],
143
+ }));
144
+ // create the loot table with simple settings
145
+ const lootTable = {
146
+ type: "minecraft:generic",
147
+ pools: [
148
+ {
149
+ rolls: 1,
150
+ entries,
151
+ },
152
+ ],
153
+ };
154
+ // on conflict, ignore because we can re-use duplicate loot tables
155
+ return () => (0, sandstone_1.LootTable)(lootTableName, lootTable, { onConflict: "ignore" }).give(mapTarget(target));
156
+ },
157
+ /**
158
+ * Set a gamerule.
159
+ * @param {GAMERULES} rule - The name of the gamerule.
160
+ * @param {boolean | number} value - The value to set the gamerule to.
161
+ */
162
+ gamerule: ({ rule, value }) => {
163
+ return () => (0, sandstone_1.gamerule)(rule, value);
164
+ },
165
+ /**
166
+ * Kill entities matching a selector.
167
+ * @param {SelectorArgument} selector - The entities to kill.
168
+ */
169
+ kill: ({ selector }) => {
170
+ return () => (0, sandstone_1.kill)(mapTarget(selector));
171
+ },
172
+ /**
173
+ * Set an attribute for a target.
174
+ * @param {ATTRIBUTES} attribute_ - The attribute to set.
175
+ * @param {number} value - The value to set the attribute to.
176
+ * @param {TargetNames} target - The target to set the attribute for.
177
+ */
178
+ setAttribute: ({ attribute_, value, target }) => {
179
+ return () => {
180
+ sandstone_1.execute.as(mapTarget(target)).run.attribute("@s", attribute_).baseSet(value);
181
+ };
182
+ },
183
+ /**
184
+ * Set the time of day.
185
+ * @param {'day' | 'night'} time_ - The time to set.
186
+ */
187
+ setTime: ({ time }) => {
188
+ return () => sandstone_1.time.set(time);
189
+ },
190
+ /**
191
+ * Summon multiple entities at a specific location.
192
+ */
193
+ summonMultiple: (params) => {
194
+ return () => {
195
+ const coordinates = params.absolute ? (0, sandstone_1.abs)(params.x, params.y, params.z) : (0, sandstone_1.rel)(params.x, params.y, params.z);
196
+ for (let i = 0; i < params.count; i++) {
197
+ (0, sandstone_1.summon)(params.entity, coordinates);
198
+ }
199
+ };
200
+ },
201
+ /**
202
+ * Set a block at a specific location.
203
+ */
204
+ setBlock: (params) => {
205
+ return () => {
206
+ const coordinates = params.absolute ? (0, sandstone_1.abs)(params.x, params.y, params.z) : (0, sandstone_1.rel)(params.x, params.y, params.z);
207
+ (0, sandstone_1.setblock)(coordinates, params.block);
208
+ };
209
+ },
210
+ // teleport
211
+ // TODO: allow destination to be a SingleEntityArgument | Coordinates
212
+ // - removed for now to allow XYZ from UI until we implement better form field for nested objects
213
+ /**
214
+ * Teleport entities to a specific location.
215
+ * @param {TargetNames} target - The entities to teleport.
216
+ * @param {number} x - The x coordinate of the destination.
217
+ * @param {number} y - The y coordinate of the destination.
218
+ * @param {number} z - The z coordinate of the destination.
219
+ * @param {boolean} absolute - Whether the coordinates are absolute or relative.
220
+ */
221
+ teleport: ({ target, x, y, z, absolute = true, }) => {
222
+ const coordinates = absolute ? (0, sandstone_1.abs)(x, y, z) : (0, sandstone_1.rel)(x, y, z);
223
+ return () => (0, sandstone_1.teleport)(mapTarget(target), coordinates);
224
+ },
225
+ /**
226
+ * Send a chat message to a target.
227
+ * @param {string[]} message - The message to send.
228
+ * @param {TargetNames} target - The target to send the message to.
229
+ */
230
+ tellraw: ({ message, target }) => {
231
+ return () => (0, sandstone_1.tellraw)(mapTarget(target), message);
232
+ },
233
+ // Score operations
234
+ /**
235
+ * Increment a score variable by 1.
236
+ * @param variable - The score variable to increment.
237
+ */
238
+ increment: ({ variable }) => {
239
+ return () => {
240
+ variable.add(1);
241
+ };
242
+ },
243
+ /**
244
+ * Decrement a score variable by 1.
245
+ * @param variable - The score variable to decrement.
246
+ */
247
+ decrement: ({ variable }) => {
248
+ return () => {
249
+ variable.remove(1);
250
+ };
251
+ },
252
+ /**
253
+ * Set a score variable to a specific value.
254
+ * @param variable - The score variable to set.
255
+ * @param value - The value to set the score variable to, which can be a number or another score variable.
256
+ */
257
+ set: ({ variable, value }) => {
258
+ return () => {
259
+ variable.set(value);
260
+ };
261
+ },
262
+ /**
263
+ * log a message with the watcher
264
+ * @param {string} message - The message to send.
265
+ * @param {Score} variable - The variable to log.
266
+ * @param {boolean} store - Whether to store the variable in the backend.
267
+ */
268
+ // WARNING: the logs must have precisely this structure to be read by the watcher. DO NOT CHANGE THE STRUCTURE.
269
+ log_variable: ({ message, variable, store }) => {
270
+ return () => commands_1.Commands.logVariable(message, variable, store);
271
+ },
272
+ /**
273
+ * Summon an item at a specific location.
274
+ * @param {ITEMS} item - The item to summon.
275
+ * @param {number} x - The x coordinate of the location.
276
+ * @param {number} y - The y coordinate of the location.
277
+ * @param {number} z - The z coordinate of the location.
278
+ * @param {boolean} absolute - Whether the coordinates are absolute or relative.
279
+ */
280
+ summonItem: ({ item, x, y, z, absolute }) => {
281
+ return () => {
282
+ const abs = absolute ? "" : "~";
283
+ (0, sandstone_1.raw)(`summon item ${abs}${x} ${abs}${y} ${abs}${z} {Item:{id:"${item}",Count:1b}}`);
284
+ };
285
+ },
286
+ };
287
+ //# sourceMappingURL=actions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":";;;;;;AAmCA,8BAkBC;AArDD,8DAAiC;AACjC,yCAyBmB;AAEnB,yCAAsC;AACtC,2CAA+C;AAM/C,SAAgB,SAAS,CAAC,MAA8B;IACvD,QAAQ,MAAM,EAAE,CAAC;QAChB,KAAK,KAAK;YACT,OAAO,eAAG,CAAC;QACZ,KAAK,MAAM;YACV,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,MAAM,YAAY,yBAAa,EAAE,CAAC;QACrC,OAAO,MAAM,CAAC;IACf,CAAC;IAED,6CAA6C;IAC7C,IAAI,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QACrC,OAAO,IAAA,oBAAQ,EAAC,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,IAAA,oBAAQ,EAAC,IAAI,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,qCAAqC;AAC9E,CAAC;AAIY,QAAA,OAAO,GAAG;IACtB;;;OAGG;IACH,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAkC,EAAE,EAAE;QACzD,OAAO,GAAG,EAAE;YACX,IAAA,mBAAO,EAAC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,uBAAW,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;QACnF,CAAC,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,KAAK,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C;IAED;;;OAGG;IACH,SAAS,EAAE,CAAC,EAAE,QAAQ,EAAuB,EAAE,EAAE;QAChD,OAAO,GAAG,EAAE;YACX,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,GAAG,EAAE,CAAC,EAAE,QAAQ,EAAE,KAAK,EAA8C,EAAE,EAAE;QACxE,OAAO,GAAG,EAAE;YACX,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,+GAA+G;IAC/G,YAAY,EAAE,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAwD,EAAE,EAAE;QACpG,OAAO,GAAG,EAAE,CAAC,mBAAQ,CAAC,WAAW,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC7D,CAAC;IAED;;;;;;;OAOG;IACH,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAuE,EAAE,EAAE;QAChH,OAAO,GAAG,EAAE;YACX,MAAM,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;YAChC,IAAA,eAAG,EAAC,eAAe,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,eAAe,IAAI,cAAc,CAAC,CAAC;QACpF,CAAC,CAAC;IACH,CAAC;CACoD,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Execute a callback for every player in the game, at their position.
3
+ */
4
+ export declare function forEveryPlayer(callback: () => void): void;
5
+ //# sourceMappingURL=api_utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api_utils.d.ts","sourceRoot":"","sources":["../src/api_utils.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,IAAI,QAElD"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.forEveryPlayer = forEveryPlayer;
4
+ /// Utilities for the external API - not necessarily used by the API itself, but useful for users of the API.
5
+ const sandstone_1 = require("sandstone");
6
+ const constants_1 = require("./constants");
7
+ /**
8
+ * Execute a callback for every player in the game, at their position.
9
+ */
10
+ function forEveryPlayer(callback) {
11
+ return sandstone_1.execute.as((0, sandstone_1.Selector)("@a", { tag: constants_1.KRADLE_PARTICIPANT_TAG })).at("@s").run(callback);
12
+ }
13
+ //# sourceMappingURL=api_utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api_utils.js","sourceRoot":"","sources":["../src/api_utils.ts"],"names":[],"mappings":";;AAOA,wCAEC;AATD,6GAA6G;AAC7G,yCAA8C;AAC9C,2CAAqD;AAErD;;GAEG;AACH,SAAgB,cAAc,CAAC,QAAoB;IAClD,OAAO,mBAAO,CAAC,EAAE,CAAC,IAAA,oBAAQ,EAAC,IAAI,EAAE,EAAE,GAAG,EAAE,kCAAsB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC3F,CAAC"}
@@ -0,0 +1,56 @@
1
+ import type { ConditionType } from "sandstone/flow";
2
+ import { type _BaseConfig, type _InputCustomEventType, type _ScenarioEvents, type Roles, type Variables } from "./types";
3
+ export declare const DEFAULT_CHALLENGE_PATH = "kradle-studio/challenges";
4
+ export declare class ChallengeBase<const ROLES_NAMES extends string, const VARIABLE_NAMES extends string> {
5
+ private game_duration;
6
+ private roles;
7
+ private full_variables;
8
+ private variablesPreviousValues;
9
+ private _events;
10
+ private _userInputCustomEvents;
11
+ private _end_condition;
12
+ private _win_conditions;
13
+ private name;
14
+ private kradle_challenge_path;
15
+ constructor(config: _BaseConfig<ROLES_NAMES, VARIABLE_NAMES>);
16
+ private get variables();
17
+ /**
18
+ * Build a CustomScoreEvent from an _InputScoreCustomEventType.
19
+ * This will setup the tracking objective.
20
+ *
21
+ * @param event The input event to create the custom event from.
22
+ * @param suffix A suffix that will be added to the variable's debug name, ensuring its uniqueness.
23
+ */
24
+ private buildCustomScoreEvent;
25
+ private addVariable;
26
+ private getPreviousValueScore;
27
+ events(events: (variables: Variables<VARIABLE_NAMES>, roles: Roles<ROLES_NAMES>) => _ScenarioEvents): Pick<this, "custom_events" | "end_condition" | "win_conditions">;
28
+ /**
29
+ * Returns the name of the variable based on its score.
30
+ */
31
+ private getVariableName;
32
+ /**
33
+ * Returns the type of the variable (individual/global) based on its score.
34
+ */
35
+ private getVariableType;
36
+ custom_events(custom_events: (variables: Variables<VARIABLE_NAMES>, roles: Roles<ROLES_NAMES>) => _InputCustomEventType[]): Pick<this, "end_condition" | "win_conditions">;
37
+ end_condition(condition?: (variables: Variables<VARIABLE_NAMES>, roles: Roles<ROLES_NAMES>) => ConditionType): Pick<this, "win_conditions">;
38
+ win_conditions(condition: (variables: Variables<VARIABLE_NAMES>, roles: Roles<ROLES_NAMES>) => Record<ROLES_NAMES, ConditionType>): void;
39
+ /**
40
+ * Processes a custom score event by checking if the score has reached the target,
41
+ * and if so, executes the actions associated with the event.
42
+ *
43
+ * @param event - The custom event to process.
44
+ * @param mcFunctionReference - Optional reference to the parent MCFunction - used to give better naming to the children functions.
45
+ */
46
+ private processCustomScoreEvent;
47
+ /**
48
+ * Builds the datapack based on the challenge configuration.
49
+ */
50
+ private build;
51
+ }
52
+ /**
53
+ * Creates a new challenge with the provided configuration.
54
+ */
55
+ export declare function createChallenge<const ROLE_NAMES extends string, const VARIABLE_NAMES extends string>(config: _BaseConfig<ROLE_NAMES, VARIABLE_NAMES>): Pick<ChallengeBase<ROLE_NAMES, VARIABLE_NAMES>, "events">;
56
+ //# sourceMappingURL=challenge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"challenge.d.ts","sourceRoot":"","sources":["../src/challenge.ts"],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