Remove duplicate code
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
import { assert, assertEquals } from "@std/assert";
|
||||
import { CRAFTING_RESULT_SLOT, PLAYER_MENU_CRAFTING } from "$/common/protocol.ts";
|
||||
import { ItemStack } from "$/common/inventory.ts";
|
||||
import { test_game } from "./helpers.ts";
|
||||
import { container_items, test_game } from "./helpers.ts";
|
||||
|
||||
// a stone floor at y 99 so drops have something to land on, high above the generated terrain
|
||||
function build_floor(game: Awaited<ReturnType<typeof test_game>>["game"]) {
|
||||
@@ -15,11 +15,9 @@ function build_floor(game: Awaited<ReturnType<typeof test_game>>["game"]) {
|
||||
}
|
||||
}
|
||||
|
||||
const inventory_count = (
|
||||
messages: { type: string; container?: string; items?: ({ id: string; count: number } | null)[] }[],
|
||||
id: string,
|
||||
) => (messages.filter((m) => m.type === "container" && m.container === "inventory").at(-1)?.items ?? [])
|
||||
.reduce((sum, item) => sum + (item?.id === id ? item.count : 0), 0);
|
||||
const inventory_count = (messages: unknown[], id: string) =>
|
||||
((container_items(messages, "inventory") ?? []) as ({ id: string; count: number } | null)[])
|
||||
.reduce((sum, item) => sum + (item?.id === id ? item.count : 0), 0);
|
||||
|
||||
Deno.test("breaking a block drops its item, which lands and gets picked up by walking to it", async () => {
|
||||
const { game, take, send, join } = await test_game("mods");
|
||||
|
||||
Reference in New Issue
Block a user