diff --git a/packages/actions/data/$schema.json b/packages/actions/data/$schema.json index 7551b70..a052625 100644 --- a/packages/actions/data/$schema.json +++ b/packages/actions/data/$schema.json @@ -123,7 +123,25 @@ "const": "workbench" } }, - "required": ["type"], + "required": ["type", "grid"], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "left": { + "$ref": "#/definitions/itemAction", + "type": "object" + }, + "right": { + "$ref": "#/definitions/itemAction", + "type": "object" + }, + "type": { + "const": "anvil" + } + }, + "required": ["type", "left", "right"], "type": "object" } ], diff --git a/packages/actions/data/north-stars-crafts.json b/packages/actions/data/north-stars-crafts.json index 0e59c31..962280d 100644 --- a/packages/actions/data/north-stars-crafts.json +++ b/packages/actions/data/north-stars-crafts.json @@ -73,6 +73,130 @@ "type": "workbench" } ] + }, + { + "inputs": [ + { + "amount": 2, + "id": "ENCHANTMENT_ULTIMATE_REFRIGERATE_1", + "type": "item" + } + ], + "outputs": [ + { + "amount": 1, + "id": "ENCHANTMENT_ULTIMATE_REFRIGERATE_2", + "type": "item" + } + ], + "place": [ + { + "left": { + "amount": 1, + "id": "ENCHANTMENT_ULTIMATE_REFRIGERATE_1", + "type": "item" + }, + "right": { + "amount": 1, + "id": "ENCHANTMENT_ULTIMATE_REFRIGERATE_1", + "type": "item" + }, + "type": "anvil" + } + ] + }, + { + "inputs": [ + { + "amount": 2, + "id": "ENCHANTMENT_ULTIMATE_REFRIGERATE_2", + "type": "item" + } + ], + "outputs": [ + { + "amount": 1, + "id": "ENCHANTMENT_ULTIMATE_REFRIGERATE_3", + "type": "item" + } + ], + "place": [ + { + "left": { + "amount": 1, + "id": "ENCHANTMENT_ULTIMATE_REFRIGERATE_2", + "type": "item" + }, + "right": { + "amount": 1, + "id": "ENCHANTMENT_ULTIMATE_REFRIGERATE_2", + "type": "item" + }, + "type": "anvil" + } + ] + }, + { + "inputs": [ + { + "amount": 2, + "id": "ENCHANTMENT_ULTIMATE_REFRIGERATE_3", + "type": "item" + } + ], + "outputs": [ + { + "amount": 1, + "id": "ENCHANTMENT_ULTIMATE_REFRIGERATE_4", + "type": "item" + } + ], + "place": [ + { + "left": { + "amount": 1, + "id": "ENCHANTMENT_ULTIMATE_REFRIGERATE_3", + "type": "item" + }, + "right": { + "amount": 1, + "id": "ENCHANTMENT_ULTIMATE_REFRIGERATE_3", + "type": "item" + }, + "type": "anvil" + } + ] + }, + { + "inputs": [ + { + "amount": 2, + "id": "ENCHANTMENT_ULTIMATE_REFRIGERATE_4", + "type": "item" + } + ], + "outputs": [ + { + "amount": 1, + "id": "ENCHANTMENT_ULTIMATE_REFRIGERATE_5", + "type": "item" + } + ], + "place": [ + { + "left": { + "amount": 1, + "id": "ENCHANTMENT_ULTIMATE_REFRIGERATE_4", + "type": "item" + }, + "right": { + "amount": 1, + "id": "ENCHANTMENT_ULTIMATE_REFRIGERATE_4", + "type": "item" + }, + "type": "anvil" + } + ] } ] } diff --git a/packages/actions/package.json b/packages/actions/package.json index 9846bfa..ba655ad 100644 --- a/packages/actions/package.json +++ b/packages/actions/package.json @@ -42,5 +42,5 @@ "sideEffects": false, "type": "commonjs", "types": "dist/index.d.ts", - "version": "0.1.0" + "version": "0.1.1" } diff --git a/packages/actions/source/data.test.ts b/packages/actions/source/data.test.ts index 05addec..3e524ed 100644 --- a/packages/actions/source/data.test.ts +++ b/packages/actions/source/data.test.ts @@ -68,7 +68,7 @@ test('sumUp works', () => { ) }) -describe('every action’s inputs match its crafing grid', () => { +describe('every action’s workbench inputs match its crafing grid', () => { for (const action of allActions) { for (const grid of action.place.filter((x) => x.type === 'workbench')) { test(`${JSON.stringify(action.outputs)} is valid`, () => { @@ -83,3 +83,19 @@ describe('every action’s inputs match its crafing grid', () => { } } }) + +describe('every action’s anvil inputs match its crafing grid', () => { + for (const action of allActions) { + for (const grid of action.place.filter((x) => x.type === 'anvil')) { + test(`${JSON.stringify(action.outputs)} is valid`, () => { + assert(grid.type === 'anvil') + + const actual = sumUp(action.inputs.filter((x) => x.type === 'item')) + + const expected = sumUp([grid.left, grid.right]) + + expect(actual).toEqual(expected) + }) + } + } +}) diff --git a/packages/actions/source/schema.ts b/packages/actions/source/schema.ts index b062bcc..8c78eec 100644 --- a/packages/actions/source/schema.ts +++ b/packages/actions/source/schema.ts @@ -22,6 +22,13 @@ export const actionIoSchema = z.discriminatedUnion('type', [ ]) export const actionPlaceSchema = z.discriminatedUnion('type', [ + z + .object({ + left: actionIoItemSchema, + right: actionIoItemSchema, + type: z.literal('anvil'), + }) + .strict(), z .object({ id: z.string(),