Add Void difficulty and publish changelogs
Some checks failed
Deploy MineGeo to Dokploy / deploy (push) Failing after 3m40s

This commit is contained in:
2026-10-20 14:05:01 +05:00
parent 3ba398a838
commit de0e891b62
37 changed files with 995 additions and 65 deletions

View File

@@ -59,7 +59,7 @@ try {
),
(error) => error.code === "23514",
);
for (const seconds of [0, 14, 16, 601])
for (const seconds of [0, 4, 14, 16, 601])
await assert.rejects(
db.query(
"insert into public.difficulty_presets(name,seconds,zoom) values('Invalid clock',$1,true)",
@@ -83,6 +83,7 @@ try {
["easy", 180],
["normal", 90],
["hard", 30],
["void", 10],
])
assert.equal(
(
@@ -111,6 +112,10 @@ try {
"insert into auth.users values(gen_random_uuid()) returning id",
)
).rows[0].id;
await db.query(
"insert into public.profiles(id,display_name) values($1,'Difficulty host') on conflict(id) do update set display_name=excluded.display_name",
[owner],
);
const map = (
await db.query(
`insert into public.datasets(owner_id,name,source,bounds,state,panorama_count)
@@ -137,6 +142,85 @@ try {
revision,
map,
]);
const voidRules = {
id: "void",
name: "Void",
seconds: 10,
zoom: false,
pan: false,
compass: false,
coordinates: false,
mapZoom: false,
mapPan: false,
timerVisible: true,
scoring: "strict",
};
const voidSolo = (
await db.query("select public.create_game($1,'void',$2,'void-solo') id", [
map,
owner,
])
).rows[0].id;
const voidRoom = (
await db.query(
"select public.create_map_room($1,'void','Void host',2,$2,$3) id",
[map, "d".repeat(64), owner],
)
).rows[0].id;
for (const [table, id] of [
["game_sessions", voidSolo],
["multiplayer_rooms", voidRoom],
])
assert.deepEqual(
(
await db.query(
`select difficulty_settings from public.${table} where id=$1`,
[id],
)
).rows[0].difficulty_settings,
voidRules,
);
await db.query("select public.activate_round($1,0,'void-solo')", [voidSolo]);
const voidClock = (
await db.query(
"select extract(epoch from (deadline-clock_timestamp()))::float8 seconds from public.game_rounds where session_id=$1 and round_number=0",
[voidSolo],
)
).rows[0].seconds;
assert.ok(voidClock > 9 && voidClock <= 10);
await db.query(
"select public.multiplayer_action($1,$2,'join','{\"name\":\"Void guest\"}')",
[voidRoom, "e".repeat(64)],
);
await db.query("select public.multiplayer_action($1,$2,'start')", [
voidRoom,
"d".repeat(64),
]);
for (const token of ["d".repeat(64), "e".repeat(64)])
await db.query(
"select public.multiplayer_action($1,$2,'ready','{\"round\":0}')",
[voidRoom, token],
);
const voidMultiClock = (
await db.query(
"select extract(epoch from (deadline-clock_timestamp()))::float8 seconds from public.multiplayer_rounds where room_id=$1 and round_number=0",
[voidRoom],
)
).rows[0].seconds;
assert.ok(voidMultiClock > 9 && voidMultiClock <= 10);
const fiveSeconds = (
await db.query(
"insert into public.difficulty_presets(name,seconds,zoom,map_pan,timer_visible) values('Five second blind clock',5,false,false,false) returning id",
)
).rows[0].id;
const extraRules = (
await db.query("select public.resolve_difficulty_preset($1) rules", [
fiveSeconds,
])
).rows[0].rules;
assert.equal(extraRules.seconds, 5);
assert.equal(extraRules.mapPan, false);
assert.equal(extraRules.timerVisible, false);
const solo = (
await db.query("select public.create_game($1,$2,$3,$4) id", [
map,
@@ -173,6 +257,8 @@ try {
compass: true,
coordinates: true,
mapZoom: true,
mapPan: true,
timerVisible: true,
scoring: "normal",
},
);
@@ -201,6 +287,8 @@ try {
compass: false,
coordinates: false,
mapZoom: false,
mapPan: true,
timerVisible: true,
scoring: "strict",
});
// Existing sessions retain the original curve even after the library changes.

View File

@@ -68,6 +68,31 @@ try {
JSON.stringify({ ...base, ...payload }),
])
)[0].id;
const voidEvent = await create({
difficulty: "void",
roundTimeSeconds: 10,
timerMode: "perMini",
});
const voidRules = (
await q(
"select difficulty_settings,round_time_seconds,timer_mode from public.tournaments where id=$1",
[voidEvent],
)
)[0];
assert.equal(voidRules.difficulty_settings.seconds, 10);
assert.equal(voidRules.difficulty_settings.mapPan, false);
assert.equal(voidRules.difficulty_settings.scoring, "strict");
assert.equal(voidRules.round_time_seconds, 10);
assert.equal(voidRules.timer_mode, "perMini");
for (const settings of [
{ roundTimeSeconds: 90, timerMode: "perMini" },
{ roundTimeSeconds: 10, timerMode: "shared" },
])
await assert.rejects(
create({ difficulty: "void", ...settings }),
/Void requires a separate 10-second timer/,
);
await q("delete from public.tournaments where id=$1", [voidEvent]);
const act = async (id, user, action = "view", payload = {}) =>
(
await q("select public.tournament_action($1,$2,$3,$4) value", [