feedback3: merge WJ — 高台 only for elite 歌蕾蒂娅 with HOK-Y, live prep watch, silenced 折射, grant toasts, emote timeout glyph
This commit is contained in:
commit
c9dd2a6392
41 files changed
+700
-216
No files matched your search
@@ -696,6 +696,34 @@ test('pools: 凯瑟琳 127 odd rounds, 佩佩 94, 洛洛 91, 焰尾 149, 歌蕾
|
||||
}
|
||||
});
|
||||
|
||||
test('歌蕾蒂娅 / 余: granting a chess toasts 「名字:获得X」', () => {
|
||||
const glady = setup(11);
|
||||
const row = plain().slice(0, 2);
|
||||
give(glady.m, glady.ps, 'chess_char_4_12_a', 'board', [10, 4]);
|
||||
give(glady.m, glady.ps, row[0], 'board', [10, 6]);
|
||||
give(glady.m, glady.ps, row[1], 'board', [10, 8]);
|
||||
const n0 = glady.h.allTo('p_0', 'm.toast').length;
|
||||
glady.roundStart();
|
||||
const lines = glady.h.allTo('p_0', 'm.toast').slice(n0).map((t) => t.text);
|
||||
const line = lines.find((t) => t.startsWith('歌蕾蒂娅:获得'));
|
||||
assert.ok(line, lines.join(' | '));
|
||||
const gained = line.slice('歌蕾蒂娅:获得'.length);
|
||||
assert.ok(handChess(glady.ps).some((id) => CH(id).name === gained), `${line} not in ${handChess(glady.ps)}`);
|
||||
const yu = setup(12);
|
||||
give(yu.m, yu.ps, 'chess_char_6_03_a', 'board', [10, 4]);
|
||||
yu.ps.bondCountBonus.egirShip = 9;
|
||||
yu.ps.recompute();
|
||||
const fillers = plain((c) => !c.bonds.includes('egirShip')).slice(0, 2);
|
||||
give(yu.m, yu.ps, fillers[0], 'board', [10, 6]);
|
||||
give(yu.m, yu.ps, fillers[1], 'board', [10, 8]);
|
||||
const n1 = yu.h.allTo('p_0', 'm.toast').length;
|
||||
yu.roundStart();
|
||||
const yuLine = yu.h.allTo('p_0', 'm.toast').slice(n1).map((t) => t.text).find((t) => t.startsWith('余:获得'));
|
||||
assert.ok(yuLine, yu.h.allTo('p_0', 'm.toast').slice(n1).map((t) => t.text).join(' | '));
|
||||
const yuName = yuLine.slice('余:获得'.length);
|
||||
assert.ok(handChess(yu.ps).some((id) => CH(id).name === yuName), yuLine);
|
||||
});
|
||||
|
||||
test('余 37: a chess of the bond with the most members (normal: 3 in the row; 精锐: always)', () => {
|
||||
for (const { gid, g, owners } of idsOf('SERVER_PREP_START', 'SERVER_MOST_BOND')) {
|
||||
for (const owner of owners) {
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
import { startServer } from '../../server/index.js';
|
||||
import { Match } from '../../server/match/Match.js';
|
||||
import { legalTiles, positionClass, tileKey } from '../../server/match/board.js';
|
||||
import { legalTiles, placeClass, tileKey } from '../../server/match/board.js';
|
||||
import { planLayout } from '../../server/match/bot.js';
|
||||
|
||||
if (!process.env.NODE_TEST_CONTEXT) {
|
||||
@@ -104,7 +104,7 @@ if (!process.env.NODE_TEST_CONTEXT) {
|
||||
const res = ps.move(piece.uid, { area: 'board', row, col }, plan.dirs.get(piece.uid) || 'RIGHT');
|
||||
if (!res || !res.error) continue;
|
||||
}
|
||||
for (const [row, col] of legalTiles(ps.deployMap(), positionClass(this.gd.chess(piece.id)))) {
|
||||
for (const [row, col] of legalTiles(ps.deployMap(), placeClass(ps, this.gd.chess(piece.id)))) {
|
||||
if (ps.board.has(tileKey(row, col))) continue;
|
||||
const res = ps.move(piece.uid, { area: 'board', row, col }, 'RIGHT');
|
||||
if (!res || !res.error) break;
|
||||
|
||||
@@ -55,16 +55,27 @@ test('glyph rules: melee only on LOW buildable ALL/MELEE; ranged also on HIGH/RA
|
||||
assert.ok(canPlace(buildDeployMap(null), 'melee', 10, 5));
|
||||
});
|
||||
|
||||
test('positionClass: the position class, widened to \'all\' by chess.json placement (钩索师 / 推击手, DESIGN §22.6); basePositionClass ignores it', () => {
|
||||
test('positionClass: melee stays ground-only; only elite 歌蕾蒂娅 + HOK-Y is widened (owner 2026-10-04)', () => {
|
||||
assert.equal(positionClass({ position: 'MELEE' }), 'melee');
|
||||
assert.equal(positionClass({ position: 'MELEE', placement: 'all' }), 'all');
|
||||
assert.equal(basePositionClass({ position: 'MELEE', placement: 'all' }), 'melee');
|
||||
assert.equal(positionClass({ position: 'MELEE', placement: 'all' }), 'melee', 'the old placement field is ignored');
|
||||
assert.equal(basePositionClass({ position: 'MELEE', isGolden: true, charId: 'char_474_glady' }), 'melee');
|
||||
assert.equal(positionClass({ position: 'RANGED' }), 'ranged');
|
||||
assert.equal(positionClass({ position: 'ALL' }), 'all');
|
||||
assert.equal(positionClass(null), 'all');
|
||||
const HOK_Y = 'uniequip_003_glady';
|
||||
const gladE = DATA.chess.chess_char_4_12_b;
|
||||
const map = buildDeployMap(DATA.stages.act2autochess_m01);
|
||||
assert.ok(canPlace(map, positionClass(DATA.chess.chess_char_4_12_a), 10, 4), '歌蕾蒂娅 on the 高台');
|
||||
assert.ok(!canPlace(map, positionClass(DATA.chess.chess_char_4_12_a, HOK_Y), 10, 4), 'normal 歌蕾蒂娅, even with the id, not');
|
||||
assert.ok(!canPlace(map, positionClass(gladE), 10, 4), 'elite with no module id (default is not passed) not');
|
||||
assert.ok(!canPlace(map, positionClass(gladE, 'uniequip_002_glady'), 10, 4), 'HOK-X not');
|
||||
assert.ok(!canPlace(map, positionClass(gladE, 'none'), 10, 4), 'no module not');
|
||||
assert.ok(canPlace(map, positionClass(gladE, HOK_Y), 10, 4), 'elite + HOK-Y on the 高台');
|
||||
assert.ok(canPlace(map, positionClass(gladE, HOK_Y), 9, 3), 'and still on the ground');
|
||||
assert.ok(!canPlace(map, positionClass(DATA.chess.chess_char_2_03_b, HOK_Y), 10, 4), '崖心 not');
|
||||
assert.ok(!canPlace(map, positionClass(DATA.chess.chess_char_3_07_b, HOK_Y), 10, 4), '见行者 not');
|
||||
assert.ok(!canPlace(map, positionClass(DATA.chess.chess_char_1_02_a), 10, 4), '角峰 (重装) not');
|
||||
assert.equal(DATA.chess.chess_char_4_12_a.placement, undefined);
|
||||
assert.equal(gladE.placement, undefined);
|
||||
});
|
||||
|
||||
test('g.move: legality per chess position, BAD_TILE outside, deploy cap 8, swaps allowed at cap', () => {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { PHASE } from '../../shared/constants.js';
|
||||
import { fieldModel, planLayout, rehearse, rangeTiles, REHEARSAL_VARIANTS, LAYOUT_PARAMS, botPickCard, botPickBand } from '../../server/match/bot.js';
|
||||
import { FIELD, canPlace, positionClass, parseKey } from '../../server/match/board.js';
|
||||
import { FIELD, canPlace, placeClass, parseKey } from '../../server/match/board.js';
|
||||
import { makeMatch, checkInvariants, give, DATA } from './harness.js';
|
||||
|
||||
const soloBot = (o = {}) => makeMatch({ mode: 'solo', difficulty: 'NORMAL', seats: [{ seat: 0, playerId: 'ai_0', name: 'AI', isBot: true, connected: true }], ...o });
|
||||
@@ -73,7 +73,7 @@ test('layout planner: legal distinct tiles; blockers on the enemy road, ranged u
|
||||
const model = fieldModel(m);
|
||||
for (const p of pieces) {
|
||||
const [r, c] = parseKey(plan.get(p.uid));
|
||||
assert.ok(canPlace(map, positionClass(m.gd.chess(p.id)), r, c), `${p.id} legal at ${r},${c}`);
|
||||
assert.ok(canPlace(map, placeClass(ps, m.gd.chess(p.id)), r, c), `${p.id} legal at ${r},${c}`);
|
||||
}
|
||||
for (const p of pieces.slice(0, 2)) assert.ok(model.ground.has(plan.get(p.uid)), 'a blocker stands on the enemy road');
|
||||
for (const p of pieces.slice(2)) {
|
||||
|
||||
@@ -11,16 +11,13 @@
|
||||
// nowhere to go); moving the owner sends it back anyway (PRTS 卫戍协议/帮助 "移动干员时,其所属召唤物全部退场并重置
|
||||
// 至手牌区") — with no room it leaves the board until the next round start.
|
||||
// The sim side (突袭 landing tile, tactical point) is test/sim/feedback1-water.test.js.
|
||||
// After 0.1.1, GitHub issue #32 item 4 "哥蕾蒂娅无法部署到高台" (DESIGN §22.6): the 钩索师 (歌蕾蒂娅, 崖心) and 推击手
|
||||
// (见行者) branch trait reads "可以放置于远程位" (character_table; PRTS 新人入门 "可部署在高台和地面"): chess.json
|
||||
// `placement` 'all' lets them stand on a 高台 too — server, client highlights, swaps, merges —; the battle keeps position
|
||||
// MELEE (on a 高台 they attack but block nothing); the bots keep planning them on the ground [ASSUMED].
|
||||
// Owner's decision 2026-10-04 reverses DESIGN §22.6: the trait 「可以放置于远程位」 is not trusted. Only elite
|
||||
// 歌蕾蒂娅 carrying HOK-Y 淡金坠饰 (uniequip_003_glady) may stand on a 高台. The battle keeps position MELEE
|
||||
// (on a 高台 she attacks but blocks nothing). A bot may plan that one loadout on a 高台; everyone else stays on the ground.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { existsSync, readFileSync } from 'node:fs';
|
||||
import { join, dirname } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { buildDeployMap, canPlace as boardCanPlace, legalTiles, positionClass, basePositionClass, tileKey, ownerRangeKeys } from '../../server/match/board.js';
|
||||
import { buildDeployMap, canPlace as boardCanPlace, legalTiles, positionClass, placeClass, tileKey, ownerRangeKeys } from '../../server/match/board.js';
|
||||
import { GLADIIA_HOK_Y } from '../../shared/highGround.js';
|
||||
import { ERR } from '../../shared/constants.js';
|
||||
import { DATA, makeMatch, give, giveItem, checkInvariants, chessOfTier } from './harness.js';
|
||||
import { botPrep, planLayout, fieldModel } from '../../server/match/bot.js';
|
||||
@@ -307,59 +304,76 @@ test('#9 bots place 狼群 / 流形 only inside their owner\'s range', () => {
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
// GitHub #32 item 4 (after 0.1.1): 钩索师 / 推击手 on a 高台
|
||||
// 高台: only elite 歌蕾蒂娅 + HOK-Y (owner's decision 2026-10-04)
|
||||
|
||||
const HIGH_STAGE = 'act2autochess_m01';
|
||||
const HIGH = ['10,4', '11,4', '12,4']; // 战场#01(下半)'s ranged-only (高台) tiles
|
||||
// 崖心 and 歌蕾蒂娅 (钩索师), 见行者 (推击手), normal and elite — 崖心 and 见行者 are hidden chess (not in the shop pool)
|
||||
const ANY_TILE = ['chess_char_2_03_a', 'chess_char_2_03_b', 'chess_char_3_07_a', 'chess_char_3_07_b', 'chess_char_4_12_a', 'chess_char_4_12_b'];
|
||||
const GLADIIA = 'chess_char_4_12_a';
|
||||
const GLAD_N = 'chess_char_4_12_a';
|
||||
const GLAD_E = 'chess_char_4_12_b'; // the golden record
|
||||
const CLIFF_E = 'chess_char_2_03_b';
|
||||
const FORCER_N = 'chess_char_3_07_a';
|
||||
const FORCER_E = 'chess_char_3_07_b';
|
||||
const HOK_X = 'uniequip_002_glady';
|
||||
const TANK = (c) => c.profession === 'TANK' && c.position === 'MELEE';
|
||||
const CHAR_TABLE = join(dirname(fileURLToPath(import.meta.url)), '../..', '.cache', 'gamedata', 'excel', 'character_table.json');
|
||||
const rc = (k) => k.split(',').map(Number);
|
||||
const toHand = (m, ps, p) => move(m, p.uid, { area: 'hand', idx: ps.hand.findIndex((x) => x == null) });
|
||||
const equip = (ps, module) => {
|
||||
assert.equal(ps.setLoadout({ [GLAD_N]: { module } }), true, module);
|
||||
};
|
||||
|
||||
test('#32-4 data: placement \'all\' on exactly the chess whose branch trait reads "可以放置于远程位" (MELEE 钩索师 / 推击手, normal and elite); no token', () => {
|
||||
const branchTrait = (c) => (c.traitBase || c.trait)?.desc || ''; // an elite's trait without its module
|
||||
assert.deepEqual(Object.values(DATA.chess).filter((c) => c.placement !== undefined).map((c) => c.chessId).sort(), ANY_TILE);
|
||||
assert.deepEqual(Object.values(DATA.chess).filter((c) => branchTrait(c).includes('可以放置于远程位')).map((c) => c.chessId).sort(), ANY_TILE);
|
||||
for (const id of ANY_TILE) {
|
||||
const c = DATA.chess[id];
|
||||
assert.equal(c.placement, 'all', id);
|
||||
assert.equal(c.position, 'MELEE', `${id}: the battle keeps position MELEE`);
|
||||
assert.ok(['hookmaster', 'pusher'].includes(c.subProfessionId), id);
|
||||
assert.equal(positionClass(c), 'all');
|
||||
assert.equal(basePositionClass(c), 'melee');
|
||||
}
|
||||
test('高台 data: no chess stores placement; HOK-Y is 淡金坠饰 on the elite 歌蕾蒂娅 only', () => {
|
||||
assert.equal(Object.values(DATA.chess).some((c) => c.placement !== undefined), false);
|
||||
for (const t of Object.values(DATA.tokens)) assert.equal(t.placement, undefined, t.tokenId);
|
||||
const e = DATA.chess[GLAD_E];
|
||||
const y = e.modules.find((m) => m.uniEquipId === GLADIIA_HOK_Y);
|
||||
assert.equal(e.charId, 'char_474_glady');
|
||||
assert.equal(e.isGolden, true);
|
||||
assert.equal(y.typeName, 'HOK-Y');
|
||||
assert.equal(y.name, '淡金坠饰');
|
||||
assert.equal(e.modules.find((m) => m.isDefault).uniEquipId, HOK_X, 'the default module is HOK-X, ground-only');
|
||||
assert.equal(DATA.chess[GLAD_N].isGolden, false);
|
||||
assert.ok(!DATA.chess[CLIFF_E].modules.some((m) => m.uniEquipId === GLADIIA_HOK_Y), '崖心 has no HOK-Y');
|
||||
assert.equal(DATA.chess[GLAD_N].position, 'MELEE');
|
||||
assert.equal(e.position, 'MELEE');
|
||||
});
|
||||
|
||||
test('#32-4 data = the official character_table: a chess is flagged iff its character\'s own trait text (no module) reads 可以放置于远程位', { skip: !existsSync(CHAR_TABLE) && 'no .cache/gamedata (run node tools/build-data.mjs once)' }, () => {
|
||||
const ct = JSON.parse(readFileSync(CHAR_TABLE, 'utf8'));
|
||||
let checked = 0;
|
||||
for (const c of Object.values(DATA.chess)) {
|
||||
const ch = c.charId ? ct[c.charId] : null;
|
||||
if (!ch) continue;
|
||||
const own = [ch.description || '', ...(ch.trait?.candidates || []).map((x) => x.overrideDescripton || '')];
|
||||
assert.equal(c.placement === 'all', own.some((t) => t.includes('可以放置于远程位')), c.chessId);
|
||||
checked++;
|
||||
}
|
||||
assert.ok(checked > 200, `${checked} chess checked`);
|
||||
});
|
||||
|
||||
test('#32-4 g.move: 歌蕾蒂娅 / 崖心 / 见行者 (normal and elite) onto every 高台 tile of 战场#01(下半) — accepted; a 重装 still refused, a ranged operator unchanged', () => {
|
||||
test('高台 table: (operator, module, tile) → allowed only for elite 歌蕾蒂娅 + HOK-Y on a 高台; ranged unchanged', () => {
|
||||
const { m, ps } = prep(HIGH_STAGE);
|
||||
assert.deepEqual([...ps.deployMap()].filter(([, cls]) => cls === 'ranged').map(([k]) => k).sort(), HIGH);
|
||||
for (const id of ANY_TILE) {
|
||||
const p = give(m, ps, id);
|
||||
// rows: chess id, module set on the 歌蕾蒂娅 loadout (null = leave the default), expect 高台
|
||||
const rows = [
|
||||
[GLAD_E, GLADIIA_HOK_Y, true],
|
||||
[GLAD_E, HOK_X, false],
|
||||
[GLAD_E, 'none', false],
|
||||
[GLAD_N, GLADIIA_HOK_Y, false],
|
||||
[GLAD_N, null, false],
|
||||
[CLIFF_E, GLADIIA_HOK_Y, false],
|
||||
[FORCER_N, null, false],
|
||||
[FORCER_E, null, false],
|
||||
];
|
||||
const owned = new Map();
|
||||
for (const [id, module, allowHigh] of rows) {
|
||||
if (module) equip(ps, module);
|
||||
else ps.setLoadout({});
|
||||
let p = owned.get(id);
|
||||
if (!p) { p = give(m, ps, id); owned.set(id, p); }
|
||||
else if (ps.find(p.uid)?.area === 'board') assert.deepEqual(toHand(m, ps, p), { ok: true });
|
||||
for (const k of HIGH) {
|
||||
const [r, c] = rc(k);
|
||||
assert.deepEqual(move(m, p.uid, board(r, c), 'DOWN'), { ok: true }, `${id} → ${k}`);
|
||||
assert.equal(ps.board.get(k), p);
|
||||
checkInvariants(m);
|
||||
const res = move(m, p.uid, board(r, c), 'DOWN');
|
||||
if (allowHigh) {
|
||||
assert.deepEqual(res, { ok: true }, `${id} ${module} → ${k}`);
|
||||
assert.equal(ps.board.get(k), p);
|
||||
checkInvariants(m);
|
||||
assert.deepEqual(toHand(m, ps, p), { ok: true });
|
||||
} else {
|
||||
assert.equal(res.error, ERR.BAD_TILE, `${id} ${module || 'default'} → ${k}`);
|
||||
}
|
||||
}
|
||||
assert.deepEqual(move(m, p.uid, board(9, 3)), { ok: true }, `${id}: the ground stays legal`);
|
||||
assert.equal(placeClass(ps, DATA.chess[id]) === 'all', allowHigh, id);
|
||||
assert.deepEqual(toHand(m, ps, p), { ok: true });
|
||||
ps.setLoadout({});
|
||||
}
|
||||
const tank = give(m, ps, chessOfTier(1, TANK).find((x) => m.pool.has(x)));
|
||||
const ranged = give(m, ps, chessOfTier(1, RANGED).find((x) => m.pool.has(x)));
|
||||
@@ -369,90 +383,83 @@ test('#32-4 g.move: 歌蕾蒂娅 / 崖心 / 见行者 (normal and elite) onto ev
|
||||
}
|
||||
assert.deepEqual(move(m, tank.uid, board(9, 3)), { ok: true }, 'the 重装 on the ground');
|
||||
assert.deepEqual(move(m, ranged.uid, board(10, 4)), { ok: true }, 'ranged on the 高台');
|
||||
assert.deepEqual(move(m, ranged.uid, board(9, 4)), { ok: true }, 'ranged on the ground');
|
||||
assert.deepEqual(move(m, ranged.uid, board(9, 4)), { ok: true }, 'ranged on the ground (there is no ground-only tile)');
|
||||
assert.equal(move(m, ranged.uid, board(9, 6)).error, ERR.BAD_TILE, 'ranged refused on a non-deployable tile');
|
||||
checkInvariants(m);
|
||||
m.dispose();
|
||||
});
|
||||
|
||||
test('#32-4 the client mirrors it: the drag highlights of 歌蕾蒂娅 / 崖心 / 见行者 include the 高台 (= the server\'s legal tiles); the 重装 keeps "近战单位只能部署在地面"', () => {
|
||||
test('高台 client: drag highlights follow the loadout; a 重装 keeps "近战单位只能部署在地面"', () => {
|
||||
const { m, ps } = prep(HIGH_STAGE);
|
||||
const pieces = ANY_TILE.map((id) => give(m, ps, id));
|
||||
equip(ps, GLADIIA_HOK_Y);
|
||||
const glad = give(m, ps, GLAD_E);
|
||||
const normal = give(m, ps, GLAD_N);
|
||||
const cliff = give(m, ps, CLIFF_E);
|
||||
const tank = give(m, ps, chessOfTier(1, TANK).find((x) => m.pool.has(x)));
|
||||
const ranged = give(m, ps, chessOfTier(1, RANGED).find((x) => m.pool.has(x)));
|
||||
const ctx = clientCtx(m, ps);
|
||||
const map = ps.deployMap();
|
||||
for (const p of [...pieces, tank, ranged]) {
|
||||
for (const p of [glad, normal, cliff, tank, ranged]) {
|
||||
const lit = boardTargets(ctx, p.uid).legal.map(([r, c]) => tileKey(r, c)).sort();
|
||||
assert.deepEqual(lit, legalTiles(map, positionClass(DATA.chess[p.id])).map(([r, c]) => tileKey(r, c)).sort(), `${p.id}: highlights = the server's tiles`);
|
||||
for (const k of HIGH) {
|
||||
const [r, c] = rc(k);
|
||||
assert.deepEqual(lit, legalTiles(map, placeClass(ps, DATA.chess[p.id])).map(([r, c]) => tileKey(r, c)).sort(), `${p.id}: highlights = the server`);
|
||||
}
|
||||
for (const k of HIGH) {
|
||||
const [r, c] = rc(k);
|
||||
assert.equal(clientCanPlace(ctx, glad.uid, board(r, c)).ok, true, k);
|
||||
for (const p of [normal, cliff, tank]) {
|
||||
const res = clientCanPlace(ctx, p.uid, board(r, c));
|
||||
assert.equal(res.ok, p !== tank, `${p.id} → ${k}`);
|
||||
assert.equal(lit.includes(k), p !== tank);
|
||||
if (p === tank) assert.equal(res.reason, '近战单位只能部署在地面');
|
||||
assert.equal(res.ok, false, p.id);
|
||||
assert.equal(res.reason, '近战单位只能部署在地面');
|
||||
}
|
||||
assert.equal(clientCanPlace(ctx, ranged.uid, board(r, c)).ok, true);
|
||||
}
|
||||
m.dispose();
|
||||
});
|
||||
|
||||
test('#32-4 swaps: a 高台 歌蕾蒂娅 trades places with a ranged operator but not with a 重装 (it may not take the 高台); the client agrees', () => {
|
||||
test('高台 swaps: elite 歌蕾蒂娅 + HOK-Y trades with a ranged operator, not with a 重装', () => {
|
||||
const { m, ps } = prep(HIGH_STAGE);
|
||||
const glad = give(m, ps, GLADIIA);
|
||||
equip(ps, GLADIIA_HOK_Y);
|
||||
const glad = give(m, ps, GLAD_E);
|
||||
const tank = give(m, ps, chessOfTier(1, TANK).find((x) => m.pool.has(x)));
|
||||
const ranged = give(m, ps, chessOfTier(1, RANGED).find((x) => m.pool.has(x)));
|
||||
assert.deepEqual(move(m, glad.uid, board(10, 4), 'DOWN'), { ok: true });
|
||||
assert.deepEqual(move(m, tank.uid, board(9, 3)), { ok: true });
|
||||
assert.deepEqual(move(m, ranged.uid, board(11, 4)), { ok: true });
|
||||
let ctx = clientCtx(m, ps);
|
||||
// 歌蕾蒂娅 onto the 重装 would send it to (10,4); the 重装 onto her would put it there itself: both refused
|
||||
assert.equal(clientCanPlace(ctx, glad.uid, board(9, 3)).ok, false);
|
||||
assert.equal(move(m, glad.uid, board(9, 3)).error, ERR.BAD_TILE);
|
||||
assert.equal(clientCanPlace(ctx, tank.uid, board(10, 4)).ok, false);
|
||||
assert.equal(move(m, tank.uid, board(10, 4)).error, ERR.BAD_TILE);
|
||||
// onto the ranged operator on the next 高台 tile: both stay legal
|
||||
assert.equal(clientCanPlace(ctx, glad.uid, board(11, 4)).ok, true);
|
||||
assert.deepEqual(move(m, glad.uid, board(11, 4)), { ok: true });
|
||||
assert.equal(ps.board.get('11,4'), glad);
|
||||
assert.equal(ps.board.get('10,4'), ranged);
|
||||
// on the ground she swaps with the 重装 like any melee operator
|
||||
assert.deepEqual(move(m, glad.uid, board(12, 5)), { ok: true });
|
||||
ctx = clientCtx(m, ps);
|
||||
assert.equal(clientCanPlace(ctx, tank.uid, board(12, 5)).ok, true);
|
||||
assert.deepEqual(move(m, tank.uid, board(12, 5)), { ok: true });
|
||||
assert.equal(ps.board.get('9,3'), glad);
|
||||
assert.equal(ps.board.get('12,5'), tank);
|
||||
checkInvariants(m);
|
||||
m.dispose();
|
||||
});
|
||||
|
||||
test('#32-4 merge: the elite of a 高台 歌蕾蒂娅 takes her 高台 tile and facing (PlayerState._mergeChess, board.js mergeTile)', () => {
|
||||
test('高台 battle input: elite 歌蕾蒂娅 + HOK-Y is fielded on (10,4) and blocks nothing there; on the ground she blocks', () => {
|
||||
const { m, ps } = prep(HIGH_STAGE);
|
||||
const a = give(m, ps, GLADIIA);
|
||||
assert.deepEqual(move(m, a.uid, board(12, 4), 'DOWN'), { ok: true });
|
||||
give(m, ps, GLADIIA);
|
||||
// the third copy gained like any other (her bond may be banned in this match, so not through the shop)
|
||||
assert.ok(ps.acquireChess(GLADIIA));
|
||||
const elite = ps.board.get('12,4');
|
||||
assert.equal(elite?.id, DATA.chess[GLADIIA].goldenId, 'the elite stands on the 高台');
|
||||
assert.equal(elite.dir, 'DOWN');
|
||||
checkInvariants(m);
|
||||
m.dispose();
|
||||
});
|
||||
|
||||
test('#32-4 battle: the board fields 歌蕾蒂娅 on (10,4); there she attacks the lane but blocks nothing, on the ground she blocks (position MELEE)', () => {
|
||||
const { m, ps } = prep(HIGH_STAGE);
|
||||
const glad = give(m, ps, GLADIIA);
|
||||
equip(ps, GLADIIA_HOK_Y);
|
||||
const glad = give(m, ps, GLAD_E);
|
||||
assert.deepEqual(move(m, glad.uid, board(10, 4), 'DOWN'), { ok: true });
|
||||
const u0 = ps.battleInput().units.find((u) => u.uid === glad.uid);
|
||||
assert.deepEqual([u0.row, u0.col, u0.dir], [10, 4, 'DOWN']);
|
||||
assert.deepEqual([u0.row, u0.col, u0.dir, u0.moduleId], [10, 4, 'DOWN', GLADIIA_HOK_Y]);
|
||||
m.dispose();
|
||||
// position stays MELEE either way: the normal record (the same body the 0.1.2 measurement used) attacks the lane
|
||||
// from the 高台 and blocks nothing there. HOK-Y's own range is not what this asserts.
|
||||
for (const [r, c, dir, high] of [[10, 4, 'DOWN', true], [9, 5, 'RIGHT', false]]) {
|
||||
const h = makeBattle({
|
||||
stageId: HIGH_STAGE, seed: 3, timeLimit: 60, autoFinish: false,
|
||||
units: [{ chessId: GLADIIA, row: r, col: c, dir, carryState: { sp: 0 } }],
|
||||
units: [{ chessId: GLAD_N, row: r, col: c, dir, carryState: { sp: 0 } }],
|
||||
enemies: [{ key: 'enemy_1422_lrsldr', route: 0, time: 1, mods: { hpMul: 50 } }],
|
||||
});
|
||||
const u = h.unit(GLADIIA);
|
||||
const u = h.unit(GLAD_N);
|
||||
let hits = 0;
|
||||
let blocked = false;
|
||||
h.b.on('damaged', (x) => { if (x.source === u) hits++; });
|
||||
@@ -465,18 +472,42 @@ test('#32-4 battle: the board fields 歌蕾蒂娅 on (10,4); there she attacks t
|
||||
}
|
||||
});
|
||||
|
||||
test('#32-4 bots still count 歌蕾蒂娅 / 崖心 / 见行者 as blockers and plan them on the ground road, never on a 高台 [ASSUMED]', () => {
|
||||
for (const seed of [11, 12]) {
|
||||
const { m, ps } = prep(HIGH_STAGE, seed);
|
||||
const pieces = ['chess_char_4_02_a', 'chess_char_4_12_a', 'chess_char_3_07_a', 'chess_char_2_03_a'].map((id) => give(m, ps, id));
|
||||
const plan = planLayout(m, ps, pieces);
|
||||
const map = ps.deployMap();
|
||||
const road = fieldModel(m, ps).ground;
|
||||
for (const p of pieces.slice(1)) {
|
||||
const k = plan.get(p.uid);
|
||||
assert.equal(map.get(k), 'melee', `seed ${seed}: ${p.id} on a ground tile (${k})`);
|
||||
assert.ok(road.has(k), `seed ${seed}: ${p.id} on an enemy road tile (${k}), where it blocks`);
|
||||
}
|
||||
m.dispose();
|
||||
test('高台 bots: elite 歌蕾蒂娅 + HOK-Y takes a 高台 that covers the road while the ground is still free', () => {
|
||||
const { m, ps } = prep(HIGH_STAGE, 11);
|
||||
equip(ps, GLADIIA_HOK_Y);
|
||||
const elite = give(m, ps, GLAD_E);
|
||||
const k = planLayout(m, ps, [elite]).get(elite.uid);
|
||||
assert.equal(ps.deployMap().get(k), 'ranged', `planned on a 高台 with the road open (${k})`);
|
||||
const [r, c] = rc(k);
|
||||
assert.deepEqual(move(m, elite.uid, board(r, c)), { ok: true });
|
||||
m.dispose();
|
||||
});
|
||||
|
||||
test('高台 bots: everyone else stays on the road; elite 歌蕾蒂娅 + HOK-Y may take a 高台 when the ground is full', () => {
|
||||
const { m, ps } = prep(HIGH_STAGE, 11);
|
||||
const pieces = ['chess_char_4_02_a', GLAD_N, FORCER_N, 'chess_char_2_03_a'].map((id) => give(m, ps, id));
|
||||
const plan = planLayout(m, ps, pieces);
|
||||
const map = ps.deployMap();
|
||||
const road = fieldModel(m, ps).ground;
|
||||
for (const p of pieces.slice(1)) {
|
||||
const k = plan.get(p.uid);
|
||||
assert.equal(map.get(k), 'melee', `${p.id} on a ground tile (${k})`);
|
||||
assert.ok(road.has(k), `${p.id} on an enemy road tile (${k})`);
|
||||
assert.equal(move(m, p.uid, board(10, 4)).error, ERR.BAD_TILE, `${p.id} deploy refused`);
|
||||
}
|
||||
const elite = give(m, ps, GLAD_E);
|
||||
equip(ps, GLADIIA_HOK_Y);
|
||||
const melee = [...map].filter(([, cls]) => cls === 'melee').map(([k]) => k);
|
||||
const highPlan = planLayout(m, ps, [elite], undefined, { occupied: new Set(melee) });
|
||||
const hk = highPlan.get(elite.uid);
|
||||
assert.equal(map.get(hk), 'ranged', `HOK-Y planned on a 高台 (${hk})`);
|
||||
const [hr, hc] = rc(hk);
|
||||
assert.deepEqual(move(m, elite.uid, board(hr, hc)), { ok: true });
|
||||
checkInvariants(m);
|
||||
assert.deepEqual(toHand(m, ps, elite), { ok: true });
|
||||
equip(ps, 'none');
|
||||
const refused = planLayout(m, ps, [elite], undefined, { occupied: new Set(melee) });
|
||||
assert.equal(refused.get(elite.uid), undefined, 'no module: a 高台 is not a fallback');
|
||||
assert.equal(move(m, elite.uid, board(10, 4)).error, ERR.BAD_TILE);
|
||||
m.dispose();
|
||||
});
|
||||
@@ -20,7 +20,7 @@ import assert from 'node:assert/strict';
|
||||
import { Match } from '../../server/match/Match.js';
|
||||
import { VirtualScheduler } from '../../server/match/scheduler.js';
|
||||
import { getData } from '../../server/data.js';
|
||||
import { FIELD, canPlace, positionClass, tileKey } from '../../server/match/board.js';
|
||||
import { FIELD, canPlace, placeClass, positionClass, tileKey } from '../../server/match/board.js';
|
||||
import { FakeBattle } from './fakeBattle.js';
|
||||
import { GEO } from '../../shared/constants.js';
|
||||
import { collectViolations } from '../../server/match/invariants.js';
|
||||
@@ -179,7 +179,8 @@ function legacyInvariants(m) {
|
||||
assert.ok(r >= FIELD.r0 && r <= FIELD.r1 && c >= FIELD.c0 && c <= FIELD.c1, `piece outside the board ${k}`);
|
||||
const rec = p.kind === 'token' ? m.gd.token(p.id) : m.gd.chess(p.id);
|
||||
assert.ok(rec, `unknown board piece ${p.id}`);
|
||||
assert.ok(canPlace(dmap, positionClass(rec), r, c), `illegal tile ${p.id} @ ${k}`);
|
||||
const cls = p.kind === 'chess' ? placeClass(ps, rec) : positionClass(rec);
|
||||
assert.ok(canPlace(dmap, cls, r, c), `illegal tile ${p.id} @ ${k}`);
|
||||
assert.notEqual(p.kind, 'item', 'items never stand on the board');
|
||||
if (p.kind === 'chess') deployed++;
|
||||
if (p.kind === 'token') assert.ok(chessUids.has(p.ownerUid), `orphan token ${p.uid}`);
|
||||
@@ -255,7 +256,7 @@ export function chessOfTier(tier, filter = () => true) {
|
||||
|
||||
/** First legal board tile for a chess (reading order). */
|
||||
export function legalTileFor(m, ps, chessId, skip = new Set()) {
|
||||
const pos = positionClass(m.gd.chess(chessId));
|
||||
const pos = placeClass(ps, m.gd.chess(chessId));
|
||||
const map = ps.deployMap();
|
||||
for (let r = FIELD.r1; r >= FIELD.r0; r--) for (let c = FIELD.c0; c <= FIELD.c1; c++) {
|
||||
if (skip.has(tileKey(r, c)) || ps.board.has(tileKey(r, c))) continue;
|
||||
|
||||
@@ -3,7 +3,7 @@ import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { ERR, PHASE } from '../../shared/constants.js';
|
||||
import { DATA, makeMatch, give, giveItem, checkInvariants, chessOfTier, legalTileFor } from './harness.js';
|
||||
import { canPlace, positionClass } from '../../server/match/board.js';
|
||||
import { canPlace, placeClass } from '../../server/match/board.js';
|
||||
|
||||
function prep(seed = 21, o = {}) {
|
||||
const h = makeMatch({ mode: 'solo', difficulty: 'NORMAL', seed, ...o }).start();
|
||||
@@ -361,7 +361,7 @@ test('a merge completed during SETTLE (突变细胞) keeps its reward offer for
|
||||
// PRTS 卫戍协议/帮助: a merge consuming a deployed copy sends the elite to that copy's tile — outside PREP too; of
|
||||
// several, the first in deploy order (col asc, then row desc — by column from the left, Battle.start)
|
||||
const map = ps.deployMap();
|
||||
const pos = positionClass(m.gd.chess(elite.id));
|
||||
const pos = placeClass(ps, m.gd.chess(elite.id));
|
||||
const legal = deployedTiles.map((k) => k.split(',').map(Number)).filter(([r, c]) => canPlace(map, pos, r, c)).sort((a, b) => a[1] - b[1] || b[0] - a[0]);
|
||||
assert.ok(legal.length, `${label}: a legal deployed tile exists`);
|
||||
assert.equal(loc.area, 'board', `${label}: the elite stands on the board`);
|
||||
|
||||
@@ -12,7 +12,7 @@ import assert from 'node:assert/strict';
|
||||
import { ERR, PHASE } from '../../shared/constants.js';
|
||||
import { checkLoadout } from '../../shared/protocol.js';
|
||||
import { DATA, makeMatch, give, giveItem, checkInvariants, chessOfTier, legalTileFor } from './harness.js';
|
||||
import { canPlace, positionClass, tileKey, mergeTile } from '../../server/match/board.js';
|
||||
import { canPlace, placeClass, tileKey, mergeTile } from '../../server/match/board.js';
|
||||
import { makeCtx } from '../../server/match/effectsMeta.js';
|
||||
import { attachAudit } from '../../server/match/audit.js';
|
||||
import { botPrep } from '../../server/match/bot.js';
|
||||
@@ -364,7 +364,7 @@ test('boss-field prep (R14, act2 m01): the elite takes a copy\'s tile that is le
|
||||
assert.deepEqual(m.handle(pid, { t: 'g.buy', slot: 0 }), { ok: true });
|
||||
const elite = ps.board.get('11,8');
|
||||
assert.ok(elite && elite.id === chess(id).goldenId && elite.dir === 'UP', `${pid} (${field}): the elite on board (11,8) of its boss half`);
|
||||
assert.ok(canPlace(ps.deployMap(), positionClass(chess(elite.id)), 11, 8));
|
||||
assert.ok(canPlace(ps.deployMap(), placeClass(ps, chess(elite.id)), 11, 8));
|
||||
}
|
||||
checkInvariants(m);
|
||||
m.dispose();
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
// GitHub #87: watching another board during prep follows its moves. A spectator uses the same prep scout.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { PHASE } from '../../shared/constants.js';
|
||||
import { makeMatch, give, legalTileFor, chessOfTier } from './harness.js';
|
||||
|
||||
const MELEE = (c) => c.position === 'MELEE' && c.profession === 'TANK';
|
||||
|
||||
test('#87 prep watch: seat B moves during prep and seat A\'s view of B changes before combat; a spectator does too', () => {
|
||||
const S = 's_spec';
|
||||
const h = makeMatch({ mode: 'coop', humans: 2, seed: 8701, fake: true, spectators: [S] }).start();
|
||||
h.toPrep(1);
|
||||
const m = h.m;
|
||||
assert.equal(m.phase, PHASE.PREP);
|
||||
const b = h.ps('p_1');
|
||||
assert.deepEqual(m.handle('p_1', { t: 'g.ready', ready: false }), { ok: true });
|
||||
for (const p of [...b.board.values(), ...b.hand.filter(Boolean), ...b.temp.filter(Boolean)]) {
|
||||
if (p.kind === 'chess') b.returnCopies(p);
|
||||
}
|
||||
b.board.clear();
|
||||
b.hand.fill(null);
|
||||
b.temp.fill(null);
|
||||
b.recompute();
|
||||
const id = chessOfTier(1, MELEE).find((x) => m.pool.has(x));
|
||||
const piece = give(m, b, id);
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.watch', fieldId: 'n:p_1' }), { ok: true });
|
||||
assert.deepEqual(m.handle(S, { t: 'g.watch', fieldId: 'n:p_1' }), { ok: true });
|
||||
assert.equal(m.watchers.get('p_0'), 'n:p_1');
|
||||
assert.equal(m.watchers.get(S), 'n:p_1');
|
||||
for (const pid of ['p_0', S]) {
|
||||
const first = h.lastTo(pid, 'm.field');
|
||||
assert.equal(first.fieldId, 'n:p_1');
|
||||
assert.equal(first.prep, true);
|
||||
assert.equal(first.units.some((u) => u.uid === piece.uid), false, `${pid}: the piece is still in the hand`);
|
||||
}
|
||||
assert.equal(h.allTo(S, 'm.private').length, 0);
|
||||
const beforeA = h.allTo('p_0', 'm.field').length;
|
||||
const beforeS = h.allTo(S, 'm.field').length;
|
||||
const [r, c] = legalTileFor(m, b, id);
|
||||
assert.deepEqual(m.handle('p_1', { t: 'g.move', uid: piece.uid, to: { area: 'board', row: r, col: c }, dir: 'LEFT' }), { ok: true });
|
||||
assert.equal(m.phase, PHASE.PREP, 'still prep — the update did not wait for combat');
|
||||
for (const [pid, before] of [['p_0', beforeA], [S, beforeS]]) {
|
||||
const fields = h.allTo(pid, 'm.field');
|
||||
assert.equal(fields.length, before + 1, `${pid}: one new board`);
|
||||
const last = fields.at(-1);
|
||||
const u = last.units.find((x) => x.uid === piece.uid);
|
||||
assert.ok(u, `${pid}: the moved piece is on the watched board`);
|
||||
assert.deepEqual([u.x, u.y, u.dir], [c, r, 'LEFT']);
|
||||
}
|
||||
const n = h.allTo('p_0', 'm.field').length;
|
||||
assert.deepEqual(m.handle('p_1', { t: 'g.freeze' }), { ok: true });
|
||||
assert.equal(h.allTo('p_0', 'm.field').length, n, 'a shop toggle is not a board change');
|
||||
assert.equal(h.allTo(S, 'm.private').length, 0);
|
||||
m.dispose();
|
||||
});
|
||||
@@ -51,6 +51,7 @@ test('unitStatsEntry: effective stats next to the base, rounded for display; the
|
||||
id: 3, uid: 44, defId: 'chess_x', hp: 813, alive: true,
|
||||
maxHp: 1250, atk: 420, def: 90, res: 12.3, interval: 1.08, blockCnt: 3, moveSpeed: 0,
|
||||
base: { maxHp: 1000, atk: 300, def: 100, res: 10, interval: 1.2, blockCnt: 2, moveSpeed: 0 },
|
||||
silenced: false,
|
||||
});
|
||||
const plain = unitStatsEntry(u);
|
||||
assert.equal(plain.atk, 300, 'no aggregated stats: the base');
|
||||
|
||||
@@ -351,6 +351,125 @@ describe('public/js/ui/emotes.js helpers', () => {
|
||||
assert.match(readFileSync(path.join(ROOT, 'public/index.html'), 'utf8'), /href="\/css\/emotes\.css"/);
|
||||
});
|
||||
|
||||
test('a hung emote manifest is missing when the clock fires (glyph), and a later retry replaces it', async () => {
|
||||
const { createDataStore } = await import('../../public/js/data.js');
|
||||
const timers = [];
|
||||
let calls = 0;
|
||||
let releaseWait;
|
||||
const store = createDataStore({
|
||||
timeoutMs: 1000,
|
||||
retryDelays: [0],
|
||||
wait: () => new Promise((r) => { releaseWait = r; }),
|
||||
setTimeout: (fn, ms) => { timers.push({ fn, ms }); return timers.length; },
|
||||
clearTimeout: () => {},
|
||||
fetch: () => {
|
||||
calls++;
|
||||
if (calls === 1) return new Promise(() => {});
|
||||
return Promise.resolve({ ok: true, status: 200, json: async () => ({ ok: true, groups: { a: { pic: { path: '/p.png' } } } }) });
|
||||
},
|
||||
});
|
||||
const states = [];
|
||||
store.subscribe(() => states.push(store.status('local')));
|
||||
const p = store.load('local');
|
||||
assert.equal(store.status('local'), 'loading');
|
||||
assert.equal(timers.length, 1);
|
||||
assert.equal(timers[0].ms, 1000);
|
||||
timers[0].fn();
|
||||
await new Promise((r) => setImmediate(r));
|
||||
assert.equal(store.status('local'), 'missing', 'glyph as soon as the attempt times out, before the retry');
|
||||
assert.equal(calls, 1, 'still on the first attempt while the retry waits');
|
||||
releaseWait();
|
||||
const value = await p;
|
||||
assert.equal(calls, 2);
|
||||
assert.equal(store.status('local'), 'ready');
|
||||
assert.equal(value.ok, true);
|
||||
assert.equal(store.get('local').groups.a.pic.path, '/p.png');
|
||||
assert.deepEqual(states, ['missing', 'ready']);
|
||||
for (const t of timers) t.fn();
|
||||
assert.equal(store.status('local'), 'ready', 'a timer that fires after success does not demote the file');
|
||||
});
|
||||
|
||||
test('a failed emote manifest (no clock) is missing before the retry, then ready; a 404 stays missing', async () => {
|
||||
const { createDataStore } = await import('../../public/js/data.js');
|
||||
let calls = 0;
|
||||
const store = createDataStore({
|
||||
timeoutMs: 1000,
|
||||
retryDelays: [0],
|
||||
wait: async () => {},
|
||||
setTimeout: () => 1,
|
||||
clearTimeout: () => {},
|
||||
fetch: async () => {
|
||||
calls++;
|
||||
if (calls === 1) throw new TypeError('Failed to fetch');
|
||||
return { ok: true, status: 200, json: async () => ({ groups: { emoticon: {} } }) };
|
||||
},
|
||||
});
|
||||
const states = [];
|
||||
store.subscribe(() => states.push(store.status('assets')));
|
||||
const value = await store.load('assets');
|
||||
assert.equal(value.groups.emoticon !== undefined, true);
|
||||
assert.deepEqual(states, ['missing', 'ready']);
|
||||
const warn = console.warn;
|
||||
console.warn = () => {};
|
||||
try {
|
||||
const timers = [];
|
||||
const gone = createDataStore({
|
||||
timeoutMs: 5,
|
||||
retryDelays: [],
|
||||
setTimeout: (fn) => { timers.push(fn); return timers.length; },
|
||||
clearTimeout: () => {},
|
||||
fetch: () => new Promise(() => {}),
|
||||
});
|
||||
const p = gone.load('local');
|
||||
assert.equal(timers.length, 1);
|
||||
timers[0]();
|
||||
assert.equal(await p, null);
|
||||
assert.equal(gone.status('local'), 'missing');
|
||||
let n = 0;
|
||||
const missing = createDataStore({
|
||||
timeoutMs: 5,
|
||||
retryDelays: [0],
|
||||
wait: async () => {},
|
||||
setTimeout: () => 1,
|
||||
clearTimeout: () => {},
|
||||
fetch: async () => { n++; return { ok: false, status: 404, json: async () => ({}) }; },
|
||||
});
|
||||
assert.equal(await missing.load('assets'), null);
|
||||
assert.equal(missing.status('assets'), 'missing');
|
||||
assert.equal(n, 1, 'a 404 is not retried');
|
||||
} finally { console.warn = warn; }
|
||||
});
|
||||
|
||||
test('the art-manifest clock is not armed for other files; the default wait is ART_MANIFEST_TIMEOUT_MS', async () => {
|
||||
const { createDataStore, ART_MANIFEST_TIMEOUT_MS } = await import('../../public/js/data.js');
|
||||
assert.equal(ART_MANIFEST_TIMEOUT_MS, 8000);
|
||||
const arms = [];
|
||||
let release;
|
||||
const store = createDataStore({
|
||||
setTimeout: (fn, ms) => { arms.push(ms); return arms.length; },
|
||||
clearTimeout: () => {},
|
||||
fetch: (url) => new Promise((resolve) => { release = () => resolve(String(url).includes('chess')
|
||||
? { ok: false, status: 404, json: async () => ({}) }
|
||||
: { ok: true, status: 200, json: async () => ({ ok: 1 }) }); }),
|
||||
});
|
||||
const local = store.load('local');
|
||||
assert.deepEqual(arms, [8000]);
|
||||
release();
|
||||
assert.equal((await local).ok, 1);
|
||||
arms.length = 0;
|
||||
const warn = console.warn;
|
||||
console.warn = () => {};
|
||||
try {
|
||||
const chess = store.load('chess');
|
||||
await new Promise((r) => setImmediate(r));
|
||||
assert.deepEqual(arms, [], 'chess is not on the emote clock');
|
||||
assert.equal(store.status('chess'), 'loading');
|
||||
release();
|
||||
await chess;
|
||||
assert.equal(store.status('chess'), 'missing');
|
||||
} finally { console.warn = warn; }
|
||||
});
|
||||
|
||||
test('emote UI never renders an emote label as text (aria-label only)', () => {
|
||||
const src = readFileSync(path.join(ROOT, 'public/js/ui/emotes.js'), 'utf8');
|
||||
assert.doesNotMatch(src, /EMOTE_TEXT|EMOTE_LABEL/, 'no text table in the UI');
|
||||
|
||||
+22
-11
@@ -39,13 +39,13 @@ let uid = 0;
|
||||
const piece = (id, extra = {}) => ({ uid: ++uid, kind: 'chess', id, golden: false, tier: chess[id]?.tier ?? 1, items: [], ...extra });
|
||||
const item = (id) => ({ uid: ++uid, kind: 'item', id, golden: false, tier: 1 });
|
||||
|
||||
function privWith({ board = [], hand = [], temp = [], deployCap = 8, ready = false } = {}) {
|
||||
function privWith({ board = [], hand = [], temp = [], deployCap = 8, ready = false, loadout = null } = {}) {
|
||||
const h = new Array(GEO.HAND_SIZE).fill(null);
|
||||
hand.forEach((p, i) => { if (p) h[p.idx ?? i] = p.piece ?? p; });
|
||||
const t = new Array(GEO.TEMP_SIZE).fill(null);
|
||||
temp.forEach((p, i) => { t[i] = p; });
|
||||
return { alive: true, ready, funds: 10, board, hand: h, temp: t, deployCap, deployCount: board.filter((p) => p.kind === 'chess').length, canReady: !t.some(Boolean),
|
||||
shop: { level: 3, maxLevel: 6, upgradePrice: 8, refreshPrice: 1, freeRefreshes: 0, frozen: false, slots: [] } };
|
||||
loadout, shop: { level: 3, maxLevel: 6, upgradePrice: 8, refreshPrice: 1, freeRefreshes: 0, frozen: false, slots: [] } };
|
||||
}
|
||||
const ctxFor = (priv, editable = true) => placementContext({ priv, stage: STAGE, editable, getChess, getItem, getToken });
|
||||
|
||||
@@ -245,17 +245,28 @@ describe('placement mirror (canPlace)', () => {
|
||||
assert.equal(canPlace(ctx, m.uid, null).ok, false);
|
||||
assert.equal(canPlace(ctx, m.uid, { area: 'temp', idx: 0 }).ok, false, 'no temp target');
|
||||
});
|
||||
test('a 钩索师 / 推击手 (chess.json placement all: "可以放置于远程位") may also use the high ground; a plain melee keeps the refusal', () => {
|
||||
const glad = piece('chess_char_4_12_a'); // 歌蕾蒂娅 (钩索师)
|
||||
const forcer = piece('chess_char_3_07_b'); // 见行者 (推击手), elite
|
||||
test('only elite 歌蕾蒂娅 carrying HOK-Y lights the 高台; 崖心, 见行者, a normal record and other modules stay on the ground', () => {
|
||||
const HOK_Y = 'uniequip_003_glady';
|
||||
const gladE = piece('chess_char_4_12_b');
|
||||
const gladN = piece('chess_char_4_12_a');
|
||||
const cliff = piece('chess_char_2_03_b');
|
||||
const forcer = piece('chess_char_3_07_b');
|
||||
const m = piece(MELEE);
|
||||
const ctx = ctxFor(privWith({ hand: [glad, forcer, m] }));
|
||||
for (const p of [glad, forcer]) {
|
||||
for (const [row, col] of [[10, 4], [11, 4], [12, 4], [9, 3]]) assert.equal(canPlace(ctx, p.uid, { area: 'board', row, col }).ok, true, `${p.id} on ${row},${col}`);
|
||||
const lit = boardTargets(ctx, p.uid).legal.map(([a, b]) => tileKey(a, b));
|
||||
assert.equal(lit.length, STAGE.deployTiles.normal.melee.length + STAGE.deployTiles.normal.rangedOnly.length, `${p.id}: every deploy tile lit`);
|
||||
const loadout = { chess_char_4_12_a: { module: HOK_Y } };
|
||||
const ctx = ctxFor(privWith({ hand: [gladE, gladN, cliff, forcer, m], loadout }));
|
||||
for (const [row, col] of [[10, 4], [11, 4], [12, 4], [9, 3]]) assert.equal(canPlace(ctx, gladE.uid, { area: 'board', row, col }).ok, true, `elite HOK-Y on ${row},${col}`);
|
||||
const lit = boardTargets(ctx, gladE.uid).legal.map(([a, b]) => tileKey(a, b));
|
||||
assert.equal(lit.length, STAGE.deployTiles.normal.melee.length + STAGE.deployTiles.normal.rangedOnly.length, 'every deploy tile lit');
|
||||
for (const p of [gladN, cliff, forcer, m]) {
|
||||
assert.deepEqual(canPlace(ctx, p.uid, { area: 'board', row: 10, col: 4 }), { ok: false, code: 'BAD_TILE', reason: '近战单位只能部署在地面' }, p.id);
|
||||
assert.equal(canPlace(ctx, p.uid, { area: 'board', row: 9, col: 3 }).ok, true, `${p.id} on the ground`);
|
||||
}
|
||||
assert.deepEqual(canPlace(ctx, m.uid, { area: 'board', row: 10, col: 4 }), { ok: false, code: 'BAD_TILE', reason: '近战单位只能部署在地面' });
|
||||
const none = ctxFor(privWith({ hand: [gladE], loadout: { chess_char_4_12_a: { module: 'none' } } }));
|
||||
assert.equal(canPlace(none, gladE.uid, { area: 'board', row: 10, col: 4 }).ok, false, 'no module');
|
||||
const xmod = ctxFor(privWith({ hand: [gladE], loadout: { chess_char_4_12_a: { module: 'uniequip_002_glady' } } }));
|
||||
assert.equal(canPlace(xmod, gladE.uid, { area: 'board', row: 10, col: 4 }).ok, false, 'HOK-X');
|
||||
const bare = ctxFor(privWith({ hand: [gladE] }));
|
||||
assert.equal(canPlace(bare, gladE.uid, { area: 'board', row: 10, col: 4 }).ok, false, 'default module is HOK-X');
|
||||
});
|
||||
test('not editable ⇒ nothing is legal', () => {
|
||||
const m = piece(MELEE);
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// 折射 while silenced: the enemy card greys the SILENCE-format line; the status icon is mapped and not drawn
|
||||
// under silence. The sim already drops the RES bonus (enemies.js) — not asserted here.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { abilityRows } from '../../public/js/ui/abilityLines.js';
|
||||
import { statusIconKey, statusIconSuppressed } from '../../public/js/render/style.js';
|
||||
|
||||
const scout = JSON.parse(readFileSync(new URL('../../data/enemies.json', import.meta.url), 'utf8')).enemy_1166_dusbr;
|
||||
|
||||
test('折射: the card line greys only while silenced; the icon key exists and is suppressed under silence', () => {
|
||||
const on = abilityRows(scout.abilities, false);
|
||||
assert.equal(on.length, 1);
|
||||
assert.match(on[0].text, /折射/);
|
||||
assert.equal(on[0].off, false);
|
||||
const off = abilityRows(scout.abilities, true);
|
||||
assert.equal(off[0].off, true, 'grey the 折射 line');
|
||||
assert.equal(off[0].text, on[0].text, 'the words stay');
|
||||
assert.equal(abilityRows([{ text: '普通攻击', format: 'NONE' }], true)[0].off, false);
|
||||
assert.equal(abilityRows(['plain'], true)[0].off, false);
|
||||
assert.equal(statusIconKey('ab:refraction'), 'refraction');
|
||||
const both = new Set(['ab:refraction', 'silence']);
|
||||
assert.equal(statusIconSuppressed('ab:refraction', both), true, 'drop the icon while silenced');
|
||||
assert.equal(statusIconSuppressed('silence', both), false, 'the silence icon itself stays');
|
||||
assert.equal(statusIconSuppressed('ab:refraction', new Set(['ab:refraction'])), false, 'the icon shows while 折射 is on');
|
||||
});
|
||||
Reference in new issue
Block a user