Require distinct panorama locations for rounds and captures
Some checks failed
Deploy MineGeo to Dokploy / deploy (push) Failing after 6m30s
Some checks failed
Deploy MineGeo to Dokploy / deploy (push) Failing after 6m30s
This commit is contained in:
@@ -1,7 +1,53 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { boundsSchema, datasetSchema, scoreGuess } from "../shared/protocol";
|
||||
import {
|
||||
boundsSchema,
|
||||
datasetSchema,
|
||||
parseUploadManifest,
|
||||
scoreGuess,
|
||||
} from "../shared/protocol";
|
||||
const bounds = { minX: -512, minZ: -256, maxX: 512, maxZ: 256 };
|
||||
test("new maps need five distinct positions, while older captures can retain duplicates", () => {
|
||||
const manifest = {
|
||||
format: "minegeo-dataset/v1",
|
||||
minecraftVersion: "1.21.11",
|
||||
dimension: "minecraft:overworld",
|
||||
source: "plugin",
|
||||
name: "Distinct location fixture",
|
||||
serverName: "Fixture",
|
||||
north: "-z",
|
||||
bounds,
|
||||
viewpoints: Array.from({ length: 5 }, (_, i) => ({
|
||||
id: `p${i}`,
|
||||
x: i - 4,
|
||||
y: 65,
|
||||
z: i - 4,
|
||||
})),
|
||||
assets: [{ path: "terrain.json.gz", sha256: "a".repeat(64), bytes: 100 }],
|
||||
};
|
||||
assert.equal(parseUploadManifest(manifest).viewpoints.length, 5);
|
||||
const repeated = {
|
||||
...manifest,
|
||||
viewpoints: [
|
||||
...manifest.viewpoints,
|
||||
{ id: "repeat", x: -3.9, y: 65.5, z: -3.9 },
|
||||
],
|
||||
};
|
||||
// Keep older exports usable when they already contain five distinct locations.
|
||||
assert.equal(datasetSchema.safeParse(repeated).success, true);
|
||||
assert.equal(parseUploadManifest(repeated).viewpoints.length, 6);
|
||||
assert.throws(
|
||||
() =>
|
||||
parseUploadManifest({
|
||||
...manifest,
|
||||
viewpoints: [
|
||||
...manifest.viewpoints.slice(0, 4),
|
||||
repeated.viewpoints[5],
|
||||
],
|
||||
}),
|
||||
/five panoramas from different block positions/,
|
||||
);
|
||||
});
|
||||
test("horizontal scoring ignores elevation and handles negative coordinates", () => {
|
||||
assert.equal(
|
||||
scoreGuess({ x: -13, z: -25 }, { x: -13, z: -25 }, bounds).score,
|
||||
|
||||
Reference in New Issue
Block a user