@kradle/challenges 0.0.1 → 0.1.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.
@@ -0,0 +1,76 @@
1
+ name: Create Release PR
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ release_type:
7
+ description: 'Release type'
8
+ required: true
9
+ type: choice
10
+ options:
11
+ - patch
12
+ - minor
13
+ - major
14
+
15
+ jobs:
16
+ create-release-pr:
17
+ runs-on: ubuntu-latest
18
+ permissions:
19
+ contents: write
20
+ pull-requests: write
21
+ steps:
22
+ - name: Checkout
23
+ uses: actions/checkout@v4
24
+ with:
25
+ fetch-depth: 0
26
+
27
+ - name: Setup Node.js
28
+ uses: actions/setup-node@v4
29
+ with:
30
+ node-version: '22'
31
+ cache: 'npm'
32
+
33
+ - name: Install dependencies
34
+ run: npm ci
35
+
36
+ - name: Configure Git
37
+ run: |
38
+ git config user.name "github-actions[bot]"
39
+ git config user.email "github-actions[bot]@users.noreply.github.com"
40
+
41
+ - name: Bump version
42
+ id: bump
43
+ run: |
44
+ CURRENT_VERSION=$(node -p "require('./package.json').version")
45
+ NEW_VERSION=$(npx semver $CURRENT_VERSION -i ${{ inputs.release_type }})
46
+ npm version $NEW_VERSION --no-git-tag-version
47
+ echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
48
+ echo "Bumped version from $CURRENT_VERSION to $NEW_VERSION"
49
+
50
+ - name: Build
51
+ run: npm run build
52
+
53
+ - name: Create release branch and PR
54
+ env:
55
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56
+ run: |
57
+ BRANCH_NAME="release/v${{ steps.bump.outputs.new_version }}"
58
+ git checkout -b "$BRANCH_NAME"
59
+ git add -A
60
+ git commit -m "chore: release v${{ steps.bump.outputs.new_version }}"
61
+ git push origin "$BRANCH_NAME"
62
+ gh pr create \
63
+ --title "Release v${{ steps.bump.outputs.new_version }}" \
64
+ --base main \
65
+ --head "$BRANCH_NAME" \
66
+ --body "## Release v${{ steps.bump.outputs.new_version }}
67
+
68
+ This PR was automatically created by the release workflow.
69
+
70
+ ### Changes
71
+ - Bumped version to v${{ steps.bump.outputs.new_version }} (${{ inputs.release_type }} release)
72
+
73
+ ### Checklist
74
+ - [ ] Review the version bump
75
+ - [ ] Ensure all tests pass
76
+ - [ ] Merge when ready to publish"
@@ -0,0 +1,30 @@
1
+ name: PR Checks
2
+
3
+ on:
4
+ pull_request:
5
+ branches: [main]
6
+
7
+ jobs:
8
+ validate:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - name: Checkout
12
+ uses: actions/checkout@v4
13
+
14
+ - name: Setup Node.js
15
+ uses: actions/setup-node@v4
16
+ with:
17
+ node-version: '22'
18
+ cache: 'npm'
19
+
20
+ - name: Install dependencies
21
+ run: npm ci
22
+
23
+ - name: Lint
24
+ run: npm run lint
25
+
26
+ - name: Build
27
+ run: npm run build
28
+
29
+ - name: Check if packing works
30
+ run: npm pack
@@ -0,0 +1,70 @@
1
+ name: Publish to npm
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ paths:
7
+ - 'package.json'
8
+
9
+ permissions:
10
+ contents: write # Required for creating tags
11
+
12
+ jobs:
13
+ publish:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - name: Checkout
17
+ uses: actions/checkout@v4
18
+ with:
19
+ fetch-depth: 2
20
+
21
+ - name: Check if version changed
22
+ id: version_check
23
+ run: |
24
+ CURRENT_VERSION=$(node -p "require('./package.json').version")
25
+ git checkout HEAD~1 -- package.json 2>/dev/null || true
26
+ PREVIOUS_VERSION=$(node -p "require('./package.json').version") 2>/dev/null || echo "0.0.0"
27
+ git checkout HEAD -- package.json
28
+
29
+ echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
30
+ echo "previous_version=$PREVIOUS_VERSION" >> $GITHUB_OUTPUT
31
+
32
+ if [ "$CURRENT_VERSION" != "$PREVIOUS_VERSION" ]; then
33
+ echo "changed=true" >> $GITHUB_OUTPUT
34
+ echo "Version changed from $PREVIOUS_VERSION to $CURRENT_VERSION"
35
+ else
36
+ echo "changed=false" >> $GITHUB_OUTPUT
37
+ echo "Version unchanged ($CURRENT_VERSION)"
38
+ fi
39
+
40
+ - name: Setup Node.js
41
+ if: steps.version_check.outputs.changed == 'true'
42
+ uses: actions/setup-node@v4
43
+ with:
44
+ node-version: '22'
45
+ cache: 'npm'
46
+ registry-url: 'https://registry.npmjs.org'
47
+
48
+ # Make sure NPM is up to date (it's not by default...)
49
+ - name: Update npm
50
+ if: steps.version_check.outputs.changed == 'true'
51
+ run: npm install -g npm@latest
52
+
53
+ - name: Install dependencies
54
+ if: steps.version_check.outputs.changed == 'true'
55
+ run: npm ci
56
+
57
+ - name: Publish to npm
58
+ if: steps.version_check.outputs.changed == 'true'
59
+ run: npm publish --access public --provenance=false
60
+ env:
61
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
62
+
63
+ - name: Create git tag
64
+ if: steps.version_check.outputs.changed == 'true'
65
+ run: |
66
+ VERSION="v${{ steps.version_check.outputs.current_version }}"
67
+ git config user.name "github-actions[bot]"
68
+ git config user.email "github-actions[bot]@users.noreply.github.com"
69
+ git tag -a "$VERSION" -m "Release $VERSION"
70
+ git push origin "$VERSION"
@@ -0,0 +1,14 @@
1
+ name: Tech Debt Analyzer
2
+ on:
3
+ workflow_dispatch:
4
+ jobs:
5
+ analyzer:
6
+ name: Analyzer
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v6
10
+ with:
11
+ fetch-depth: 0
12
+ - uses: volary-ai/analyzer-agent@v0.1.2
13
+ with:
14
+ completions-api-key: ${{ secrets.OPENROUTER_API_KEY }}
package/dist/actions.d.ts CHANGED
@@ -3,7 +3,6 @@ import type { ATTRIBUTES, BLOCKS, ENTITY_TYPES, ITEMS } from "sandstone/argument
3
3
  import type { LiteralStringUnion } from "./utils";
4
4
  export type TargetNames = LiteralStringUnion<"all" | "self"> | SelectorClass<any, any>;
5
5
  export declare function mapTarget(target: string | SelectorClass): SelectorClass<any, any> | string;
6
- export type Action = () => unknown;
7
6
  export declare const Actions: {
8
7
  /**
9
8
  * Send a chat message to everyone.
@@ -11,20 +10,20 @@ export declare const Actions: {
11
10
  */
12
11
  announce: ({ message }: {
13
12
  message: JSONTextComponent;
14
- }) => () => void;
13
+ }) => void;
15
14
  /**
16
15
  * Clear the inventory of a target.
17
16
  * @param {TargetNames} target - The target to clear the inventory of.
18
17
  */
19
18
  clear: ({ target }: {
20
19
  target: TargetNames;
21
- }) => () => void;
20
+ }) => void;
22
21
  /**
23
22
  * Custom action allowing to run any Sandstone command.
24
23
  *
25
24
  * @param {() => void} callback - The function to execute.
26
25
  */
27
- custom: (callback: () => void) => () => void;
26
+ custom: (callback: () => void) => void;
28
27
  /**
29
28
  * Fill a region with a block.
30
29
  * @param {BLOCKS} block - The block to fill the region with.
@@ -46,7 +45,7 @@ export declare const Actions: {
46
45
  z2: number;
47
46
  absolute: boolean;
48
47
  mode: "fill" | "line" | "pyramid";
49
- }) => () => void;
48
+ }) => void;
50
49
  /**
51
50
  * Give an item to a target.
52
51
  * @param {ITEMS} item - The item to give.
@@ -57,7 +56,7 @@ export declare const Actions: {
57
56
  item: ITEMS;
58
57
  target: TargetNames;
59
58
  count?: number;
60
- }) => () => void;
59
+ }) => void;
61
60
  /**
62
61
  * Give loot to a target with a weighted chance for selecting one of the items.
63
62
  * @param {{ name: ITEMS, count: number, weight: number }[]} items - The items to give.
@@ -70,7 +69,7 @@ export declare const Actions: {
70
69
  weight: number;
71
70
  }];
72
71
  target: TargetNames;
73
- }) => () => void;
72
+ }) => void;
74
73
  /**
75
74
  * Set a gamerule.
76
75
  * @param {GAMERULES} rule - The name of the gamerule.
@@ -79,14 +78,14 @@ export declare const Actions: {
79
78
  gamerule: ({ rule, value }: {
80
79
  rule: GAMERULES;
81
80
  value: boolean | number;
82
- }) => () => void;
81
+ }) => void;
83
82
  /**
84
83
  * Kill entities matching a selector.
85
84
  * @param {SelectorArgument} selector - The entities to kill.
86
85
  */
87
86
  kill: ({ selector }: {
88
87
  selector: TargetNames;
89
- }) => () => void;
88
+ }) => void;
90
89
  /**
91
90
  * Set an attribute for a target.
92
91
  * @param {ATTRIBUTES} attribute_ - The attribute to set.
@@ -97,14 +96,14 @@ export declare const Actions: {
97
96
  attribute_: ATTRIBUTES;
98
97
  value: number;
99
98
  target: TargetNames;
100
- }) => () => void;
99
+ }) => void;
101
100
  /**
102
101
  * Set the time of day.
103
102
  * @param {'day' | 'night'} time_ - The time to set.
104
103
  */
105
104
  setTime: ({ time }: {
106
105
  time: "day" | "night";
107
- }) => () => void;
106
+ }) => void;
108
107
  /**
109
108
  * Summon multiple entities at a specific location.
110
109
  */
@@ -115,7 +114,14 @@ export declare const Actions: {
115
114
  y: number;
116
115
  z: number;
117
116
  absolute: boolean;
118
- }) => () => void;
117
+ }) => void;
118
+ /**
119
+ * Set the end state of the challenge.
120
+ * @param {string} end_state - The end state to set.
121
+ */
122
+ setEndState: ({ endState }: {
123
+ endState: string;
124
+ }) => void;
119
125
  /**
120
126
  * Set a block at a specific location.
121
127
  */
@@ -125,7 +131,7 @@ export declare const Actions: {
125
131
  y: number;
126
132
  z: number;
127
133
  absolute: boolean;
128
- }) => () => void;
134
+ }) => void;
129
135
  /**
130
136
  * Teleport entities to a specific location.
131
137
  * @param {TargetNames} target - The entities to teleport.
@@ -140,7 +146,7 @@ export declare const Actions: {
140
146
  y: number;
141
147
  z: number;
142
148
  absolute: boolean;
143
- }) => () => import("sandstone/commands/implementations").TeleportFacing;
149
+ }) => void;
144
150
  /**
145
151
  * Send a chat message to a target.
146
152
  * @param {string[]} message - The message to send.
@@ -149,21 +155,21 @@ export declare const Actions: {
149
155
  tellraw: ({ message, target }: {
150
156
  message: string[];
151
157
  target: TargetNames;
152
- }) => () => void;
158
+ }) => void;
153
159
  /**
154
160
  * Increment a score variable by 1.
155
161
  * @param variable - The score variable to increment.
156
162
  */
157
163
  increment: ({ variable }: {
158
164
  variable: Score;
159
- }) => () => void;
165
+ }) => void;
160
166
  /**
161
167
  * Decrement a score variable by 1.
162
168
  * @param variable - The score variable to decrement.
163
169
  */
164
170
  decrement: ({ variable }: {
165
171
  variable: Score;
166
- }) => () => void;
172
+ }) => void;
167
173
  /**
168
174
  * Set a score variable to a specific value.
169
175
  * @param variable - The score variable to set.
@@ -172,7 +178,7 @@ export declare const Actions: {
172
178
  set: ({ variable, value }: {
173
179
  variable: Score;
174
180
  value: number | Score;
175
- }) => () => void;
181
+ }) => void;
176
182
  /**
177
183
  * log a message with the watcher
178
184
  * @param {string} message - The message to send.
@@ -183,7 +189,7 @@ export declare const Actions: {
183
189
  message: string;
184
190
  variable: Score;
185
191
  store: boolean;
186
- }) => () => void;
192
+ }) => void;
187
193
  /**
188
194
  * Summon an item at a specific location.
189
195
  * @param {ITEMS} item - The item to summon.
@@ -198,6 +204,6 @@ export declare const Actions: {
198
204
  y: number;
199
205
  z: number;
200
206
  absolute: boolean;
201
- }) => () => void;
207
+ }) => void;
202
208
  };
203
209
  //# sourceMappingURL=actions.d.ts.map
@@ -1 +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,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAEvF,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,GAAG,aAAa,CAAC,GAAG,EAAE,GAA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zE;;;OAGG;8BACuB;QAAE,QAAQ,EAAE,KAAK,CAAA;KAAE;IAI7C;;;OAGG;8BACuB;QAAE,QAAQ,EAAE,KAAK,CAAA;KAAE;IAI7C;;;;OAIG;+BACwB;QAAE,QAAQ,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,KAAK,CAAA;KAAE;IAIrE;;;;;OAKG;iDAE0C;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE;IAIjG;;;;;;;OAOG;8CACuC;QAAE,IAAI,EAAE,KAAK,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE;CAI9C,CAAC"}
package/dist/actions.js CHANGED
@@ -31,16 +31,14 @@ exports.Actions = {
31
31
  * @param {JSONTextComponent} message - The message to send.
32
32
  */
33
33
  announce: ({ message }) => {
34
- return () => {
35
- (0, sandstone_1.tellraw)("@a", ["\n", { text: constants_1.DISPLAY_TAG, color: "aqua" }, " | ", message, "\n"]);
36
- };
34
+ (0, sandstone_1.tellraw)("@a", ["\n", { text: constants_1.DISPLAY_TAG, color: "aqua" }, " | ", message, "\n"]);
37
35
  },
38
36
  /**
39
37
  * Clear the inventory of a target.
40
38
  * @param {TargetNames} target - The target to clear the inventory of.
41
39
  */
42
40
  clear: ({ target }) => {
43
- return () => (0, sandstone_1.clear)(mapTarget(target));
41
+ (0, sandstone_1.clear)(mapTarget(target));
44
42
  },
45
43
  /**
46
44
  * Custom action allowing to run any Sandstone command.
@@ -48,7 +46,7 @@ exports.Actions = {
48
46
  * @param {() => void} callback - The function to execute.
49
47
  */
50
48
  custom: (callback) => {
51
- return () => callback();
49
+ callback();
52
50
  },
53
51
  /**
54
52
  * Fill a region with a block.
@@ -62,52 +60,50 @@ exports.Actions = {
62
60
  * @param {boolean} absolute - Whether the coordinates are absolute or relative.
63
61
  */
64
62
  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;
63
+ // fill the region with the block
64
+ if (mode === "fill") {
65
+ const coordinates1 = absolute ? (0, sandstone_1.abs)(x1, y1, z1) : (0, sandstone_1.rel)(x1, y1, z1);
66
+ const coordinates2 = absolute ? (0, sandstone_1.abs)(x2, y2, z2) : (0, sandstone_1.rel)(x2, y2, z2);
67
+ (0, sandstone_1.fill)(coordinates1, coordinates2, block);
68
+ return;
69
+ }
70
+ // draw a line from the first coordinate to the second coordinate
71
+ if (mode === "line") {
72
+ const dx = x2 - x1;
73
+ const dy = y2 - y1;
74
+ const dz = z2 - z1;
75
+ const length = Math.max(Math.abs(dx), Math.abs(dy), Math.abs(dz));
76
+ const stepX = dx / length || 0;
77
+ const stepY = dy / length || 0;
78
+ const stepZ = dz / length || 0;
79
+ for (let i = 0; i <= length; i++) {
80
+ const x = Math.round(x1 + stepX * i);
81
+ const y = Math.round(y1 + stepY * i);
82
+ const z = Math.round(z1 + stepZ * i);
83
+ (0, sandstone_1.setblock)(absolute ? (0, sandstone_1.abs)(x, y, z) : (0, sandstone_1.rel)(x, y, z), block);
89
84
  }
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
- }
85
+ return;
86
+ }
87
+ if (mode === "pyramid") {
88
+ const height = Math.abs(y2);
89
+ const direction = Math.sign(y2); // +1 for up, -1 for down
90
+ for (let i = 0; i < height; i++) {
91
+ const y = y1 + i * direction;
92
+ const layerRadius = (height - 1 - i) * 2;
93
+ const minX = x1 - layerRadius;
94
+ const maxX = x1 + layerRadius;
95
+ const minZ = z1 - layerRadius;
96
+ const maxZ = z1 + layerRadius;
97
+ for (let x = minX; x <= maxX; x++) {
98
+ for (let z = minZ; z <= maxZ; z++) {
99
+ (0, sandstone_1.setblock)(absolute ? (0, sandstone_1.abs)(x, y, z) : (0, sandstone_1.rel)(x, y, z), block);
104
100
  }
105
101
  }
106
- return;
107
102
  }
108
- // if mode is not fill or line, throw an error
109
- throw new Error(`Invalid fill mode: ${mode}`);
110
- };
103
+ return;
104
+ }
105
+ // if mode is not fill or line, throw an error
106
+ throw new Error(`Invalid fill mode: ${mode}`);
111
107
  },
112
108
  /**
113
109
  * Give an item to a target.
@@ -116,7 +112,7 @@ exports.Actions = {
116
112
  * @param {number} count - The number of items to give.
117
113
  */
118
114
  give: ({ item, target, count = 1 }) => {
119
- return () => (0, sandstone_1.give)(mapTarget(target), item, count);
115
+ (0, sandstone_1.give)(mapTarget(target), item, count);
120
116
  },
121
117
  /**
122
118
  * Give loot to a target with a weighted chance for selecting one of the items.
@@ -125,7 +121,7 @@ exports.Actions = {
125
121
  */
126
122
  giveLoot: ({ items, target }) => {
127
123
  // sort incoming items and create a hash for table re-use
128
- const lootItemsSorted = items.sort((a, b) => a.name.localeCompare(b.name));
124
+ const lootItemsSorted = [...items].sort((a, b) => a.name.localeCompare(b.name));
129
125
  const lootItemsJson = JSON.stringify(lootItemsSorted);
130
126
  const lootItemsHash = node_crypto_1.default.createHash("sha256").update(lootItemsJson).digest("hex");
131
127
  const lootTableName = `loot_${lootItemsHash}`.slice(0, 16);
@@ -152,7 +148,7 @@ exports.Actions = {
152
148
  ],
153
149
  };
154
150
  // on conflict, ignore because we can re-use duplicate loot tables
155
- return () => (0, sandstone_1.LootTable)(lootTableName, lootTable, { onConflict: "ignore" }).give(mapTarget(target));
151
+ (0, sandstone_1.LootTable)(lootTableName, lootTable, { onConflict: "ignore" }).give(mapTarget(target));
156
152
  },
157
153
  /**
158
154
  * Set a gamerule.
@@ -160,14 +156,14 @@ exports.Actions = {
160
156
  * @param {boolean | number} value - The value to set the gamerule to.
161
157
  */
162
158
  gamerule: ({ rule, value }) => {
163
- return () => (0, sandstone_1.gamerule)(rule, value);
159
+ (0, sandstone_1.gamerule)(rule, value);
164
160
  },
165
161
  /**
166
162
  * Kill entities matching a selector.
167
163
  * @param {SelectorArgument} selector - The entities to kill.
168
164
  */
169
165
  kill: ({ selector }) => {
170
- return () => (0, sandstone_1.kill)(mapTarget(selector));
166
+ (0, sandstone_1.kill)(mapTarget(selector));
171
167
  },
172
168
  /**
173
169
  * Set an attribute for a target.
@@ -176,36 +172,37 @@ exports.Actions = {
176
172
  * @param {TargetNames} target - The target to set the attribute for.
177
173
  */
178
174
  setAttribute: ({ attribute_, value, target }) => {
179
- return () => {
180
- sandstone_1.execute.as(mapTarget(target)).run.attribute("@s", attribute_).baseSet(value);
181
- };
175
+ sandstone_1.execute.as(mapTarget(target)).run.attribute("@s", attribute_).baseSet(value);
182
176
  },
183
177
  /**
184
178
  * Set the time of day.
185
179
  * @param {'day' | 'night'} time_ - The time to set.
186
180
  */
187
181
  setTime: ({ time }) => {
188
- return () => sandstone_1.time.set(time);
182
+ sandstone_1.time.set(time);
189
183
  },
190
184
  /**
191
185
  * Summon multiple entities at a specific location.
192
186
  */
193
187
  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
- };
188
+ const coordinates = params.absolute ? (0, sandstone_1.abs)(params.x, params.y, params.z) : (0, sandstone_1.rel)(params.x, params.y, params.z);
189
+ for (let i = 0; i < params.count; i++) {
190
+ (0, sandstone_1.summon)(params.entity, coordinates);
191
+ }
192
+ },
193
+ /**
194
+ * Set the end state of the challenge.
195
+ * @param {string} end_state - The end state to set.
196
+ */
197
+ setEndState: ({ endState }) => {
198
+ sandstone_1.data.modify.storage(constants_1.KRADLE_STORAGE, constants_1.END_STATE_KEY).set.value(endState);
200
199
  },
201
200
  /**
202
201
  * Set a block at a specific location.
203
202
  */
204
203
  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
- };
204
+ const coordinates = params.absolute ? (0, sandstone_1.abs)(params.x, params.y, params.z) : (0, sandstone_1.rel)(params.x, params.y, params.z);
205
+ (0, sandstone_1.setblock)(coordinates, params.block);
209
206
  },
210
207
  // teleport
211
208
  // TODO: allow destination to be a SingleEntityArgument | Coordinates
@@ -220,7 +217,7 @@ exports.Actions = {
220
217
  */
221
218
  teleport: ({ target, x, y, z, absolute = true, }) => {
222
219
  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);
220
+ (0, sandstone_1.teleport)(mapTarget(target), coordinates);
224
221
  },
225
222
  /**
226
223
  * Send a chat message to a target.
@@ -228,7 +225,7 @@ exports.Actions = {
228
225
  * @param {TargetNames} target - The target to send the message to.
229
226
  */
230
227
  tellraw: ({ message, target }) => {
231
- return () => (0, sandstone_1.tellraw)(mapTarget(target), message);
228
+ (0, sandstone_1.tellraw)(mapTarget(target), message);
232
229
  },
233
230
  // Score operations
234
231
  /**
@@ -236,18 +233,14 @@ exports.Actions = {
236
233
  * @param variable - The score variable to increment.
237
234
  */
238
235
  increment: ({ variable }) => {
239
- return () => {
240
- variable.add(1);
241
- };
236
+ variable.add(1);
242
237
  },
243
238
  /**
244
239
  * Decrement a score variable by 1.
245
240
  * @param variable - The score variable to decrement.
246
241
  */
247
242
  decrement: ({ variable }) => {
248
- return () => {
249
- variable.remove(1);
250
- };
243
+ variable.remove(1);
251
244
  },
252
245
  /**
253
246
  * Set a score variable to a specific value.
@@ -255,9 +248,7 @@ exports.Actions = {
255
248
  * @param value - The value to set the score variable to, which can be a number or another score variable.
256
249
  */
257
250
  set: ({ variable, value }) => {
258
- return () => {
259
- variable.set(value);
260
- };
251
+ variable.set(value);
261
252
  },
262
253
  /**
263
254
  * log a message with the watcher
@@ -267,7 +258,7 @@ exports.Actions = {
267
258
  */
268
259
  // WARNING: the logs must have precisely this structure to be read by the watcher. DO NOT CHANGE THE STRUCTURE.
269
260
  log_variable: ({ message, variable, store }) => {
270
- return () => commands_1.Commands.logVariable(message, variable, store);
261
+ commands_1.Commands.logVariable(message, variable, store);
271
262
  },
272
263
  /**
273
264
  * Summon an item at a specific location.
@@ -278,10 +269,8 @@ exports.Actions = {
278
269
  * @param {boolean} absolute - Whether the coordinates are absolute or relative.
279
270
  */
280
271
  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
- };
272
+ const abs = absolute ? "" : "~";
273
+ (0, sandstone_1.raw)(`summon item ${abs}${x} ${abs}${y} ${abs}${z} {Item:{id:"${item}",Count:1b}}`);
285
274
  },
286
275
  };
287
276
  //# sourceMappingURL=actions.js.map