@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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AS,CAAC,IAAI,CAAC;QAC9C,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;QAEhD,OAAO,gBAAQ,CAAC,GAAG,CAAC,cAAc,EAAE;YACnC,OAAO;YACP,KAAK;YACL,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC;gBACxB,SAAS,EAAE,aAAa;gBACxB,QAAQ,EAAE,YAAY;aACtB,CAAC;YACF,KAAK,EAAE,QAAQ;YACf,OAAO,EAAE,oBAAoB,CAAC,IAAA,oBAAQ,EAAC,YAAmB,CAAC,CAAC;SAC5D,CAAC,CAAC;IACJ,CAAC;CACD,CAAC"}
@@ -0,0 +1,70 @@
1
+ import { type Score } from "sandstone";
2
+ /**
3
+ * All possible events that can be defined in a challenge.
4
+ */
5
+ export type POSSIBLE_SCENARIO_EVENTS = "start_challenge" | "init_participants" | "end_challenge" | "on_tick";
6
+ export declare const VISIBLE_OBJECTIVE: import("sandstone").ObjectiveInstance<string | undefined>;
7
+ export declare const HIDDEN_OBJECTIVE: import("sandstone").ObjectiveInstance<string | undefined>;
8
+ export declare const WATCHER = "watcher";
9
+ export declare const WEB_VIEWER = "KradleWebViewer";
10
+ export declare const KRADLE_PARTICIPANT_TAG = "kradle_participant";
11
+ export declare const WINNER_TAG = "kradle_winner";
12
+ export declare const DISPLAY_TAG = "***KRADLE***";
13
+ export declare const MAX_DURATION: number;
14
+ export declare const ALL: import("sandstone").SelectorClass<false, true>;
15
+ export declare const GAME_STATES: {
16
+ readonly CREATED: 0;
17
+ readonly ON: 2;
18
+ readonly OFF: 1;
19
+ };
20
+ export declare const BUILTIN_VARIABLES: {
21
+ death_count: {
22
+ type: "individual";
23
+ objective_type: "deathCount";
24
+ default: number;
25
+ };
26
+ has_never_died: {
27
+ type: "individual";
28
+ updater: (value: Score, { death_count }: Record<string, Score<string | undefined>>) => void;
29
+ };
30
+ alive_players: {
31
+ type: "global";
32
+ updater: (value: Score, { has_never_died }: Record<string, Score<string | undefined>>) => void;
33
+ };
34
+ main_score: {
35
+ type: "individual";
36
+ default: number;
37
+ updater: (value: Score) => void;
38
+ };
39
+ game_timer: {
40
+ type: "global";
41
+ default: number;
42
+ updater: (value: Score) => void;
43
+ };
44
+ game_state: {
45
+ type: "global";
46
+ default: 0;
47
+ };
48
+ player_count: {
49
+ type: "global";
50
+ default: number;
51
+ };
52
+ player_number: {
53
+ type: "individual";
54
+ objective_type: "dummy";
55
+ default: number;
56
+ updater: (value: Score, { player_count }: Record<string, Score<string | undefined>>) => void;
57
+ };
58
+ death_event: {
59
+ type: "individual";
60
+ objective_type: "deathCount";
61
+ updater: (value: Score) => void;
62
+ };
63
+ };
64
+ export type BUILTIN_VARIABLE_NAMES = keyof typeof BUILTIN_VARIABLES;
65
+ export declare const BUILTIN_SCORE_EVENTS: (variables: Record<BUILTIN_VARIABLE_NAMES, Score>) => {
66
+ mode: "repeatable";
67
+ score: Score<string | undefined>;
68
+ actions: (() => void)[];
69
+ }[];
70
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,KAAK,EAAY,MAAM,WAAW,CAAC;AAIxE;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,iBAAiB,GAAG,mBAAmB,GAAG,eAAe,GAAG,SAAS,CAAC;AAE7G,eAAO,MAAM,iBAAiB,2DAAuF,CAAC;AACtH,eAAO,MAAM,gBAAgB,2DAAoC,CAAC;AAElE,eAAO,MAAM,OAAO,YAAY,CAAC;AACjC,eAAO,MAAM,UAAU,oBAAoB,CAAC;AAC5C,eAAO,MAAM,sBAAsB,uBAAuB,CAAC;AAC3D,eAAO,MAAM,UAAU,kBAAkB,CAAC;AAC1C,eAAO,MAAM,WAAW,iBAAiB,CAAC;AAE1C,eAAO,MAAM,YAAY,QAAc,CAAC;AAGxC,eAAO,MAAM,GAAG,gDAAkD,CAAC;AACnE,eAAO,MAAM,WAAW;;;;CAId,CAAC;AAKX,eAAO,MAAM,iBAAiB;;;;;;;;yBAQX,KAAK;;;;yBASL,KAAK;;;;;yBAYL,KAAK;;;;;yBAOL,KAAK;;;;;;;;;;;;;;yBAiBL,KAAK;;;;;yBAYL,KAAK;;CAS8B,CAAC;AAEvD,MAAM,MAAM,sBAAsB,GAAG,MAAM,OAAO,iBAAiB,CAAC;AAEpE,eAAO,MAAM,oBAAoB,GAAI,WAAW,MAAM,CAAC,sBAAsB,EAAE,KAAK,CAAC;;;;GAWjD,CAAC"}
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BUILTIN_SCORE_EVENTS = exports.BUILTIN_VARIABLES = exports.GAME_STATES = exports.ALL = exports.MAX_DURATION = exports.DISPLAY_TAG = exports.WINNER_TAG = exports.KRADLE_PARTICIPANT_TAG = exports.WEB_VIEWER = exports.WATCHER = exports.HIDDEN_OBJECTIVE = exports.VISIBLE_OBJECTIVE = void 0;
4
+ const sandstone_1 = require("sandstone");
5
+ const types_1 = require("./types");
6
+ const utils_1 = require("./utils");
7
+ exports.VISIBLE_OBJECTIVE = sandstone_1.Objective.create("kradle.board", "dummy", [{ text: "Kradle Board", color: "gold" }]);
8
+ exports.HIDDEN_OBJECTIVE = sandstone_1.Objective.create("kradle.hidden");
9
+ exports.WATCHER = "watcher";
10
+ exports.WEB_VIEWER = "KradleWebViewer";
11
+ exports.KRADLE_PARTICIPANT_TAG = "kradle_participant";
12
+ exports.WINNER_TAG = "kradle_winner";
13
+ exports.DISPLAY_TAG = "***KRADLE***";
14
+ exports.MAX_DURATION = 5 * 60 * 20; // 5 minutes in ticks
15
+ /// The selector that targets all participants in the game.
16
+ exports.ALL = (0, sandstone_1.Selector)("@a", { tag: exports.KRADLE_PARTICIPANT_TAG });
17
+ exports.GAME_STATES = {
18
+ CREATED: 0,
19
+ ON: 2,
20
+ OFF: 1,
21
+ };
22
+ /// The variables that are builtin by default in every challenge.
23
+ /// These variables are used to track the state of the game and the players.
24
+ /// They can be used in the challenge definition to create end conditions, win conditions, and events.
25
+ exports.BUILTIN_VARIABLES = {
26
+ death_count: {
27
+ type: "individual",
28
+ objective_type: "deathCount",
29
+ default: 0,
30
+ },
31
+ has_never_died: {
32
+ type: "individual",
33
+ updater: (value, { death_count }) => {
34
+ value.set(0);
35
+ sandstone_1._.if(death_count.equalTo(0), () => {
36
+ value.set(1);
37
+ });
38
+ },
39
+ },
40
+ alive_players: {
41
+ type: "global",
42
+ updater: (value, { has_never_died }) => {
43
+ value.set(0);
44
+ sandstone_1.execute.as(exports.ALL).run((0, utils_1.getChildFunctionName)("alive_players"), () => {
45
+ sandstone_1._.if(has_never_died, () => {
46
+ value.add(1);
47
+ });
48
+ });
49
+ },
50
+ },
51
+ main_score: {
52
+ type: "individual",
53
+ default: 0,
54
+ updater: (value) => {
55
+ (0, exports.VISIBLE_OBJECTIVE)("@s").set(value);
56
+ },
57
+ },
58
+ game_timer: {
59
+ type: "global",
60
+ default: 0,
61
+ updater: (value) => {
62
+ value.add(1);
63
+ },
64
+ },
65
+ game_state: {
66
+ type: "global",
67
+ default: exports.GAME_STATES.CREATED,
68
+ },
69
+ player_count: {
70
+ type: "global",
71
+ default: 0,
72
+ },
73
+ /// This variable is used to assign a unique number to each player, starting from 1.
74
+ player_number: {
75
+ type: "individual",
76
+ objective_type: "dummy",
77
+ default: 0,
78
+ updater: (value, { player_count }) => {
79
+ sandstone_1._.if(value.equalTo(0), () => {
80
+ player_count.add(1);
81
+ value.set(player_count);
82
+ //tellraw("@a", [`${DISPLAY_TAG}`, { selector: "@s" }, "@s is player number ", value]);
83
+ });
84
+ },
85
+ },
86
+ /// This variable is used to announce in-game deaths
87
+ death_event: {
88
+ type: "individual",
89
+ objective_type: "deathCount",
90
+ updater: (value) => {
91
+ sandstone_1._.if(value.greaterThan(0), () => {
92
+ types_1.Actions.announce({
93
+ message: [(0, sandstone_1.Selector)("@s"), " has died!"],
94
+ })();
95
+ value.set(0); // Reset the death count after announcing
96
+ });
97
+ },
98
+ },
99
+ };
100
+ const BUILTIN_SCORE_EVENTS = (variables) => [
101
+ {
102
+ mode: "repeatable",
103
+ score: variables.main_score,
104
+ actions: [
105
+ () => {
106
+ (0, exports.VISIBLE_OBJECTIVE)("@s").set(variables.main_score);
107
+ },
108
+ ],
109
+ },
110
+ ];
111
+ exports.BUILTIN_SCORE_EVENTS = BUILTIN_SCORE_EVENTS;
112
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAA,yCAAwE;AACxE,mCAAuF;AACvF,mCAA+C;AAOlC,QAAA,iBAAiB,GAAG,qBAAS,CAAC,MAAM,CAAC,cAAc,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AACzG,QAAA,gBAAgB,GAAG,qBAAS,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;AAErD,QAAA,OAAO,GAAG,SAAS,CAAC;AACpB,QAAA,UAAU,GAAG,iBAAiB,CAAC;AAC/B,QAAA,sBAAsB,GAAG,oBAAoB,CAAC;AAC9C,QAAA,UAAU,GAAG,eAAe,CAAC;AAC7B,QAAA,WAAW,GAAG,cAAc,CAAC;AAE7B,QAAA,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,qBAAqB;AAE9D,2DAA2D;AAC9C,QAAA,GAAG,GAAG,IAAA,oBAAQ,EAAC,IAAI,EAAE,EAAE,GAAG,EAAE,8BAAsB,EAAE,CAAC,CAAC;AACtD,QAAA,WAAW,GAAG;IAC1B,OAAO,EAAE,CAAC;IACV,EAAE,EAAE,CAAC;IACL,GAAG,EAAE,CAAC;CACG,CAAC;AAEX,iEAAiE;AACjE,4EAA4E;AAC5E,sGAAsG;AACzF,QAAA,iBAAi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AAC,SAAS,CAAC,UAAU,CAAC,CAAC;YACnD,CAAC;SACD;KACD;CACiC,CAAC;AAXxB,QAAA,oBAAoB,wBAWI"}
@@ -0,0 +1,5 @@
1
+ export { Actions } from "./actions";
2
+ export * from "./api_utils";
3
+ export * from "./challenge";
4
+ export * from "./constants";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.Actions = void 0;
18
+ var actions_1 = require("./actions");
19
+ Object.defineProperty(exports, "Actions", { enumerable: true, get: function () { return actions_1.Actions; } });
20
+ __exportStar(require("./api_utils"), exports);
21
+ __exportStar(require("./challenge"), exports);
22
+ __exportStar(require("./constants"), exports);
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,8CAA4B;AAC5B,8CAA4B;AAC5B,8CAA4B"}
@@ -0,0 +1,3 @@
1
+ export declare const test_mode_enabled = false;
2
+ export declare const set_up_test_mode: () => void;
3
+ //# sourceMappingURL=testmode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testmode.d.ts","sourceRoot":"","sources":["../src/testmode.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,iBAAiB,QAAQ,CAAC;AAIvC,eAAO,MAAM,gBAAgB,YAS5B,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.set_up_test_mode = exports.test_mode_enabled = void 0;
4
+ const sandstone_1 = require("sandstone");
5
+ const constants_1 = require("./constants");
6
+ //set to true to enable test mode
7
+ exports.test_mode_enabled = false;
8
+ //set the minecraft name of the tester player
9
+ const tester_minecraft_name = "";
10
+ const set_up_test_mode = () => {
11
+ // 1. Tag the tester player if they're going to be participating
12
+ (0, sandstone_1.tag)(tester_minecraft_name).add(constants_1.KRADLE_PARTICIPANT_TAG);
13
+ // 2. Set the tester player's gamemode, e.g. survival
14
+ (0, sandstone_1.raw)(`gamemode survival ${tester_minecraft_name}`);
15
+ // 3. Set the gamerule sendCommandFeedback to true
16
+ (0, sandstone_1.raw)("gamerule sendCommandFeedback true");
17
+ };
18
+ exports.set_up_test_mode = set_up_test_mode;
19
+ //# sourceMappingURL=testmode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testmode.js","sourceRoot":"","sources":["../src/testmode.ts"],"names":[],"mappings":";;;AAAA,yCAAqC;AACrC,2CAAqD;AAErD,iCAAiC;AACpB,QAAA,iBAAiB,GAAG,KAAK,CAAC;AACvC,6CAA6C;AAC7C,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAE1B,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACpC,gEAAgE;IAChE,IAAA,eAAG,EAAC,qBAAqB,CAAC,CAAC,GAAG,CAAC,kCAAsB,CAAC,CAAC;IAEvD,qDAAqD;IACrD,IAAA,eAAG,EAAC,qBAAqB,qBAAqB,EAAE,CAAC,CAAC;IAElD,kDAAkD;IAClD,IAAA,eAAG,EAAC,mCAAmC,CAAC,CAAC;AAC1C,CAAC,CAAC;AATW,QAAA,gBAAgB,oBAS3B"}
@@ -0,0 +1,103 @@
1
+ import type { Score } from "sandstone";
2
+ import type { OBJECTIVE_CRITERION } from "sandstone/arguments/generated";
3
+ import type { AdvancementTriggers } from "sandstone/arguments/resources/AdvancementTriggers";
4
+ import type { Action } from "./actions";
5
+ import type { BUILTIN_VARIABLE_NAMES, POSSIBLE_SCENARIO_EVENTS } from "./constants";
6
+ export { Actions } from "./actions";
7
+ export type _SpecificObjectiveVariable<VARIABLE_NAMES extends string = string> = {
8
+ type: "individual";
9
+ objective_type: OBJECTIVE_CRITERION;
10
+ /** The default value for the variable. 0 if undefined. */
11
+ default?: number;
12
+ /** The updater function is used to dynamically compute the value of the variable. */
13
+ updater?: (value: Score, variables: Record<VARIABLE_NAMES, Score>) => void;
14
+ };
15
+ export type _DummyGlobalVariable<VARIABLE_NAMES extends string = string> = {
16
+ type: "global";
17
+ /** Whether the value should be displayed in-game. */
18
+ hidden?: boolean;
19
+ /** The default value for the variable. 0 if undefined. */
20
+ default?: number;
21
+ /** The updater function is used to dynamically compute the value of the variable. */
22
+ updater?: (value: Score, variables: Record<VARIABLE_NAMES, Score>) => void;
23
+ };
24
+ export type _DummyIndividualVariable<VARIABLE_NAMES extends string = string> = {
25
+ type: "individual";
26
+ /** The default value for the variable. 0 if undefined. */
27
+ default?: number;
28
+ /** The updater function is used to dynamically compute the value of the variable. */
29
+ updater?: (value: Score, variables: Record<VARIABLE_NAMES, Score>) => void;
30
+ };
31
+ /**
32
+ * A custom variable defined for the whole challenge.
33
+ */
34
+ export type _InputVariableType<VARIABLE_NAMES extends string = string> = _SpecificObjectiveVariable<VARIABLE_NAMES> | _DummyGlobalVariable<VARIABLE_NAMES> | _DummyIndividualVariable<VARIABLE_NAMES>;
35
+ export declare function isSpecificObjectiveVariable(variable: _InputVariableType<string>): variable is _SpecificObjectiveVariable<string>;
36
+ /**
37
+ * The base configuration necessary to define events, end conditions, and win conditions for a challenge.
38
+ */
39
+ export type _BaseConfig<ROLE_NAMES extends string, VARIABLE_NAMES extends string> = {
40
+ /**
41
+ * Name of the datapack that will be created for this challenge.
42
+ */
43
+ name: string;
44
+ /**
45
+ * The path where the datapack will be created. It is expected to be `kradle-studio/challenges`.
46
+ */
47
+ kradle_challenge_path: string;
48
+ /**
49
+ * Game duration in ticks.
50
+ *
51
+ * Can be set to `INFINITY` (the default) to run without a time limit.
52
+ *
53
+ * @default INFINITY
54
+ */
55
+ GAME_DURATION?: number;
56
+ roles: ROLE_NAMES[];
57
+ custom_variables: Record<VARIABLE_NAMES, _InputVariableType<VARIABLE_NAMES | BUILTIN_VARIABLE_NAMES>>;
58
+ };
59
+ export type _ScenarioEvents = Partial<Record<POSSIBLE_SCENARIO_EVENTS, {
60
+ actions: Action[];
61
+ }>>;
62
+ export type Roles<ROLES_NAMES extends string = string> = {
63
+ [role in ROLES_NAMES]: role;
64
+ };
65
+ export type FullVariable<VARIABLE_NAMES extends string = string> = {
66
+ type: "individual" | "global";
67
+ score: Score;
68
+ default: number | undefined;
69
+ updater: ((value: Score, variables: Record<VARIABLE_NAMES, Score>) => void) | undefined;
70
+ };
71
+ /**
72
+ * "Full" variables are the variables the challenges passes to the user in events/other variable updaters.
73
+ */
74
+ export type FullVariables<VARIABLE_NAMES extends string = string> = Record<VARIABLE_NAMES | BUILTIN_VARIABLE_NAMES, FullVariable<VARIABLE_NAMES>>;
75
+ export type Variables<VARIABLE_NAMES extends string = string> = Record<VARIABLE_NAMES | BUILTIN_VARIABLE_NAMES, Score>;
76
+ type _InputEventCommonProperties = {
77
+ /** The target score to reach to trigger the event */
78
+ target?: number | undefined;
79
+ /** The mode of the event, either fire once or fire every time the score reaches the target */
80
+ mode: "fire_once" | "repeatable";
81
+ /** Actions to execute when the event is triggered */
82
+ actions: Action[];
83
+ };
84
+ export type _InputScoreCustomEventType = {
85
+ /** The target score to reach to trigger the event */
86
+ score: Score;
87
+ } & _InputEventCommonProperties;
88
+ export type _InputAdvancementCustomEventType = {
89
+ /** A list of criteria that must be met to trigger the event */
90
+ criteria: AdvancementTriggers[];
91
+ } & _InputEventCommonProperties;
92
+ export type _InputCustomEventType = _InputScoreCustomEventType | _InputAdvancementCustomEventType;
93
+ export type CustomScoreEvent = {
94
+ /** The input event that defines the conditions for the custom event */
95
+ inputEvent: _InputScoreCustomEventType;
96
+ /** The score that counts how many times the event has been triggered */
97
+ counter: Score;
98
+ /** The type of the event */
99
+ type: "global" | "individual";
100
+ /** A name used for debugging purposes */
101
+ debugName: string;
102
+ };
103
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mDAAmD,CAAC;AAC7F,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,KAAK,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAEpF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,MAAM,MAAM,0BAA0B,CAAC,cAAc,SAAS,MAAM,GAAG,MAAM,IAAI;IAChF,IAAI,EAAE,YAAY,CAAC;IACnB,cAAc,EAAE,mBAAmB,CAAC;IACpC,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qFAAqF;IACrF,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,SAA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,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACxC,qDAAqD;IACrD,KAAK,EAAE,KAAK,CAAC;CACb,GAAG,2BAA2B,CAAC;AAEhC,MAAM,MAAM,gCAAgC,GAAG;IAC9C,+DAA+D;IAC/D,QAAQ,EAAE,mBAAmB,EAAE,CAAC;CAChC,GAAG,2BAA2B,CAAC;AAEhC,MAAM,MAAM,qBAAqB,GAAG,0BAA0B,GAAG,gCAAgC,CAAC;AAElG,MAAM,MAAM,gBAAgB,GAAG;IAC9B,uEAAuE;IACvE,UAAU,EAAE,0BAA0B,CAAC;IAEvC,wEAAwE;IACxE,OAAO,EAAE,KAAK,CAAC;IAEf,4BAA4B;IAC5B,IAAI,EAAE,QAAQ,GAAG,YAAY,CAAC;IAE9B,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;CAClB,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Actions = void 0;
4
+ exports.isSpecificObjectiveVariable = isSpecificObjectiveVariable;
5
+ var actions_1 = require("./actions");
6
+ Object.defineProperty(exports, "Actions", { enumerable: true, get: function () { return actions_1.Actions; } });
7
+ function isSpecificObjectiveVariable(variable) {
8
+ return variable.type === "individual" && !!variable.objective_type;
9
+ }
10
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AA+CA,kEAIC;AA7CD,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAyChB,SAAgB,2BAA2B,CAC1C,QAAoC;IAEpC,OAAO,QAAQ,CAAC,IAAI,KAAK,YAAY,IAAI,CAAC,CAAE,QAAgB,CAAC,cAAc,CAAC;AAC7E,CAAC"}
@@ -0,0 +1,17 @@
1
+ export type LiteralStringUnion<LiteralType> = LiteralType | (string & Record<never, never>);
2
+ /**
3
+ * Generates a unique child function name based on the given name & the current context.
4
+ *
5
+ * For example, if you're inside a MCFunction named "test",
6
+ * getChildFunctionName("myFunction") will return "test/myFunction".
7
+ *
8
+ * This is useful to get meaningful names for child functions, instead of the standard "execute_as_1/2/3...".
9
+ *
10
+ * 👉 This brings more clarity to the generated functions tree, without impacting the datapack behavior.
11
+ *
12
+ * @param name The base name for the child function.
13
+ *
14
+ * @returns A meaningful child function name that is unique within the current context.
15
+ */
16
+ export declare function getChildFunctionName(name: string): string;
17
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,kBAAkB,CAAC,WAAW,IAAI,WAAW,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AAE5F;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEzD"}
package/dist/utils.js ADDED
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getChildFunctionName = getChildFunctionName;
4
+ const init_1 = require("sandstone/init");
5
+ /**
6
+ * Generates a unique child function name based on the given name & the current context.
7
+ *
8
+ * For example, if you're inside a MCFunction named "test",
9
+ * getChildFunctionName("myFunction") will return "test/myFunction".
10
+ *
11
+ * This is useful to get meaningful names for child functions, instead of the standard "execute_as_1/2/3...".
12
+ *
13
+ * 👉 This brings more clarity to the generated functions tree, without impacting the datapack behavior.
14
+ *
15
+ * @param name The base name for the child function.
16
+ *
17
+ * @returns A meaningful child function name that is unique within the current context.
18
+ */
19
+ function getChildFunctionName(name) {
20
+ return init_1.dataPack.getUniqueChildName(name).fullName;
21
+ }
22
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;AAmBA,oDAEC;AArBD,yCAA0C;AAK1C;;;;;;;;;;;;;GAaG;AACH,SAAgB,oBAAoB,CAAC,IAAY;IAChD,OAAO,eAAQ,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;AACnD,CAAC"}
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@kradle/challenges",
3
+ "version": "0.0.1",
4
+ "description": "Kradle's challenges API",
5
+ "keywords": [],
6
+ "license": "AGPL-3.0",
7
+ "author": "Kradle",
8
+ "main": "dist/index.js",
9
+ "types": "dist/index.d.ts",
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "watch": "tsc --watch",
13
+ "lint": "biome lint --fix --unsafe",
14
+ "prepack": "npm run build"
15
+ },
16
+ "dependencies": {
17
+ "sandstone": "0.14.0-alpha.13"
18
+ },
19
+ "devDependencies": {
20
+ "@biomejs/biome": "^2.3.4",
21
+ "@types/node": "^18.14.0",
22
+ "typescript": "^5.9.3"
23
+ },
24
+ "engines": {
25
+ "node": ">=22.18.0"
26
+ }
27
+ }