Improve MineGeo UI and application flows
Some checks failed
Deploy MineGeo to Dokploy / deploy (push) Failing after 2m37s

This commit is contained in:
2026-10-18 11:44:04 +05:00
parent ad73132f15
commit a7085e4e80
50 changed files with 4790 additions and 703 deletions

View File

@@ -119,6 +119,7 @@ try {
)
).rows[0].id;
const manifest = {
bounds: { minX: 0, minZ: 0, maxX: 64, maxZ: 64 },
viewpoints: Array.from({ length: 5 }, (_, i) => ({
id: `p${i}`,
x: i,
@@ -163,8 +164,174 @@ try {
[id],
)
).rows[0].difficulty_settings,
{ id: preset, name: "Playable preset 45", seconds: 45, zoom: false },
{
id: preset,
name: "Playable preset 45",
seconds: 45,
zoom: false,
pan: true,
compass: true,
coordinates: true,
mapZoom: true,
scoring: "normal",
},
);
await assert.rejects(
db.query(
"update public.difficulty_presets set scoring='unsupported' where id=$1",
[preset],
),
(error) => error.code === "23514",
);
await db.query(
"update public.difficulty_presets set pan=false,compass=false,coordinates=false,map_zoom=false,scoring='strict' where id=$1",
[preset],
);
const settings = (
await db.query("select public.resolve_difficulty_preset($1) settings", [
preset,
])
).rows[0].settings;
assert.deepEqual(settings, {
id: preset,
name: "Playable preset 45",
seconds: 45,
zoom: false,
pan: false,
compass: false,
coordinates: false,
mapZoom: false,
scoring: "strict",
});
// Existing sessions retain the original curve even after the library changes.
assert.equal(
(
await db.query(
"select difficulty_settings->>'scoring' scoring from public.game_sessions where id=$1",
[solo],
)
).rows[0].scoring,
"normal",
);
for (const scoring of ["strict", "normal", "gentle"]) {
await db.query(
"update public.difficulty_presets set scoring=$1 where id=$2",
[scoring, preset],
);
const sid = (
await db.query("select public.create_game($1,$2,$3,$4) id", [
map,
preset,
owner,
"score-" + scoring,
])
).rows[0].id;
assert.equal(
(
await db.query(
"select count(*)::int total from public.game_rounds where session_id=$1",
[sid],
)
).rows[0].total,
5,
);
await db.query("select public.activate_round($1,0,$2)", [
sid,
"score-" + scoring,
]);
const point = (
await db.query(
"select viewpoint from public.game_rounds where session_id=$1 and round_number=0",
[sid],
)
).rows[0].viewpoint;
const expected = (
await db.query("select public.score_difficulty_guess($1,$2,$3) points", [
Math.hypot(32 - point.x, 32 - point.z),
Math.hypot(64, 64),
scoring,
])
).rows[0].points;
const actual = (
await db.query("select public.submit_guess($1,0,$2,32,32) result", [
sid,
"score-" + scoring,
])
).rows[0].result;
assert.equal(actual.score, expected);
const room = (
await db.query(
"select public.create_map_room($1,$2,'Scoring host',2,$3,$4) id",
[map, preset, "a".repeat(64), owner],
)
).rows[0].id;
await db.query(
"select public.multiplayer_action($1,$2,'join','{\"name\":\"Guest\"}')",
[room, "c".repeat(64)],
);
await db.query("select public.multiplayer_action($1,$2,'start')", [
room,
"a".repeat(64),
]);
await db.query(
"select public.multiplayer_action($1,$2,'ready','{\"round\":0}')",
[room, "a".repeat(64)],
);
await db.query(
"select public.multiplayer_action($1,$2,'ready','{\"round\":0}')",
[room, "c".repeat(64)],
);
const mp = (
await db.query(
"select viewpoint from public.multiplayer_rounds where room_id=$1 and round_number=0",
[room],
)
).rows[0].viewpoint;
await db.query(
'select public.multiplayer_action($1,$2,\'guess\',\'{"round":0,"x":32,"z":32}\')',
[room, "a".repeat(64)],
);
const scored = (
await db.query(
"select result from public.multiplayer_guesses where room_id=$1 and round_number=0",
[room],
)
).rows[0].result;
const expectedMulti = (
await db.query("select public.score_difficulty_guess($1,$2,$3) points", [
Math.hypot(32 - mp.x, 32 - mp.z),
Math.hypot(64, 64),
scoring,
])
).rows[0].points;
assert.equal(scored.score, expectedMulti);
}
const decay = (
await db.query(
"select public.score_difficulty_guess(20,100,'strict') strict,public.score_difficulty_guess(20,100,'normal') normal,public.score_difficulty_guess(20,100,'gentle') gentle",
)
).rows[0];
assert.ok(decay.strict < decay.normal && decay.normal < decay.gentle);
assert.equal(
(
await db.query(
"select public.score_difficulty_guess(0,100,'strict') points",
)
).rows[0].points,
5000,
);
await assert.rejects(
db.query("select public.score_difficulty_guess(1,100,'unknown')"),
/Invalid scoring rules/,
);
assert.equal(
(
await db.query(
"select has_function_privilege('anon','public.score_difficulty_guess(double precision,double precision,text)','EXECUTE') allowed",
)
).rows[0].allowed,
false,
);
assert.equal(
(
await db.query(