- Shared card pool and item stock as in the official mode (the owner's request, from the 路标档案馆 video and public notes): solo low-tier exceptions, co-op operators x2, shared item stock with special-item exceptions, normal / advanced occupancy 1 / 2, re-check on buy, 机变 exhaustion, release on consume / destroy / elimination; 整备 never exceeds stock; invariant held <= cap. - 突袭: one taunt-first reselect right after a revive (the owner's rule); ordinary polls and redeploys keep the 0.2.3 rule; a revive on an enemy's tile stays. #475: online boss / hidden-boss Raid may land on the empty half (owner-limited scope). - 浊心斯卡蒂 S1 x 坚守 no longer bounce redirected damage, and the two shares conserve the hit (idea of PR #464 by @HappyTanuki). - Operator fixes adapted from PRs by @Xinglan233 (#459 哈洛德 S2 elemental trigger, #460 涤火杰西卡 shield on the four adjacent tiles, #461 家族徽章 first hit after stealth, #462 松果 S2 regrow per deploy); 克莱门莎 S2 splash 1.1 / 100% ATK and air auto-trigger (#467); 白面 copying 歌蕾蒂娅 / 余 skips the three-member condition (#473, the owner's video). - 香槟炸弹 is not chosen by friendly auras / heals (PR #468 / #476 by @Siornya); 琳琅诗怀雅 coin balance (PR #450 by @IceCodeNew); Touch prep display (PR #451 by @YinqiMargatroid); lobby header (PR #471 by @YuriRestia); Japanese UI terms (PR #448 by @scutkane). - AI-only boss countdown grace, render-failure cache / recovery without restarting a battle, device units kept on a same-field re-entry, DIY detail / skill previews, large-text result buttons. - golden: battle families equal 0.2.3 except diy-135 / diy-136 (克莱门莎); all 18 release matches move through the shared pool, every flip named in docs/history/0.2.4.md §29.12; two coverage scenarios added.
55 lines
3.3 KiB
JavaScript
55 lines
3.3 KiB
JavaScript
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { startServer } from '../../server/index.js';
|
|
import { TestClient } from '../helpers/wsClient.js';
|
|
import { PHASE, EMOTES } from '../../shared/constants.js';
|
|
|
|
const ok = async (c, msg) => {
|
|
const r = await c.request(msg);
|
|
assert.equal(r.t, 'ok', JSON.stringify(r));
|
|
};
|
|
|
|
// Exercise the real lobby/session routing after the match has eliminated a leaker. Only the battle outcome is
|
|
// supplied directly: these tests target room ownership, not a particular operator composition or wave duration.
|
|
for (const leaverSeat of [0, 1]) for (const phase of [PHASE.PREP, PHASE.COMBAT, PHASE.UNITE]) {
|
|
test(`an eliminated ${leaverSeat === 0 ? 'host' : 'guest'} leaving ${phase} cannot evict the survivor`, async (t) => {
|
|
const errors = [], clients = [];
|
|
const srv = await startServer({ port: 0, host: '127.0.0.1', seedFn: () => 123,
|
|
log: { info() {}, warn() {}, debug() {}, error: (...a) => errors.push(a.map(String).join(' ')) } });
|
|
t.after(async () => { await Promise.all(clients.map(c => c.terminate())); await srv.close(); assert.deepEqual(errors, []); });
|
|
for (const name of ['Host', 'Guest']) {
|
|
const c = await TestClient.connect(`ws://127.0.0.1:${srv.port}/ws`);
|
|
clients.push(c); const w = await c.hello(name); c.id = w.playerId; c.token = w.token;
|
|
}
|
|
const [host, guest] = clients;
|
|
await ok(host, { t: 'room.create', mode: 'coop', difficulty: 'NORMAL' });
|
|
const state = await host.waitFor('room.state');
|
|
await ok(guest, { t: 'room.join', code: state.code });
|
|
await ok(guest, { t: 'room.ready', ready: true });
|
|
await ok(host, { t: 'room.start' });
|
|
await host.waitFor('m.public', p => p.phase === PHASE.INFO_CHECK);
|
|
const room = srv.lobby.rooms.get(state.code), m = room.match;
|
|
// Stop phase progression without replacing the actual match/lobby/session implementation.
|
|
m.setDeadline(0); m.phase = phase; m.round = 2;
|
|
for (const ps of m.order) ps.lp = 20;
|
|
const leaver = clients[leaverSeat], survivor = clients[1 - leaverSeat];
|
|
const lost = m.players.get(leaver.id); lost.lp = 0; lost.eliminate(2);
|
|
await ok(leaver, { t: 'g.leave' });
|
|
const leftAgain = await leaver.request({ t: 'room.leave' });
|
|
assert.equal(leftAgain.code, 'NOT_IN_ROOM', 'the UI tolerates this only on the departing client');
|
|
const retained = await survivor.waitFor('room.state', r => r.code === state.code && !r.seats.some(s => s?.playerId === leaver.id && s.connected));
|
|
assert.ok(retained.seats.some(s => s?.playerId === survivor.id && s.connected));
|
|
assert.equal(room.seatOf(leaver.id).left, true);
|
|
assert.equal(retained.hostId, survivor.id);
|
|
assert.equal(srv.lobby.registry.byId(survivor.id).roomCode, state.code);
|
|
assert.equal(room.match, m); assert.equal(m.ended, false);
|
|
await ok(survivor, { t: 'g.emote', id: EMOTES[0] });
|
|
assert.equal(survivor.log.some(x => x.t === 'room.closed'), false);
|
|
await survivor.terminate();
|
|
const restored = await TestClient.connect(`ws://127.0.0.1:${srv.port}/ws`); clients.push(restored);
|
|
const w = await restored.hello('Survivor', survivor.token); assert.equal(w.playerId, survivor.id);
|
|
assert.equal((await restored.waitFor('room.state')).code, state.code);
|
|
await ok(restored, { t: 'g.autoplay', on: false });
|
|
});
|
|
}
|