feedback2 WF: 钩索师 and 推击手 (歌蕾蒂娅, 崖心, 见行者) may stand on a 高台 — chess.json placement 'all' from the branch trait 可以放置于远程位; server, client highlights; bots keep them on the ground as blockers
This commit is contained in:
1 parent
2a03467897
commit
9d15538865
9 files changed
+272
-15
No files matched your search
@@ -1,7 +1,7 @@
|
||||
// Board placement legality (stage legend), deploy cap, move semantics, placeable summons (DESIGN §3, research 03 C2).
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { buildDeployMap, canPlace, legalTiles, tileKey } from '../../server/match/board.js';
|
||||
import { buildDeployMap, canPlace, legalTiles, tileKey, positionClass, basePositionClass } from '../../server/match/board.js';
|
||||
import { applyCard } from '../../server/match/choices.js';
|
||||
import { ERR } from '../../shared/constants.js';
|
||||
import { DATA, makeMatch, give, giveItem, checkInvariants, chessOfTier } from './harness.js';
|
||||
@@ -55,6 +55,18 @@ 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', () => {
|
||||
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: 'RANGED' }), 'ranged');
|
||||
assert.equal(positionClass({ position: 'ALL' }), 'all');
|
||||
assert.equal(positionClass(null), 'all');
|
||||
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_1_02_a), 10, 4), '角峰 (重装) not');
|
||||
});
|
||||
|
||||
test('g.move: legality per chess position, BAD_TILE outside, deploy cap 8, swaps allowed at cap', () => {
|
||||
const { h, m, ps } = prepMatch();
|
||||
const meleeId = chessOfTier(1, MELEE).find((id) => m.pool.has(id));
|
||||
|
||||
@@ -11,13 +11,21 @@
|
||||
// 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].
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { buildDeployMap, canPlace as boardCanPlace, legalTiles, positionClass, tileKey, ownerRangeKeys } from '../../server/match/board.js';
|
||||
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 { ERR } from '../../shared/constants.js';
|
||||
import { DATA, makeMatch, give, giveItem, checkInvariants, chessOfTier } from './harness.js';
|
||||
import { botPrep, planLayout } from '../../server/match/bot.js';
|
||||
import { botPrep, planLayout, fieldModel } from '../../server/match/bot.js';
|
||||
import { placementContext, canPlace as clientCanPlace, boardTargets, deployMap as clientDeployMap } from '../../public/js/ui/gameLogic.js';
|
||||
import { makeBattle } from '../helpers/battleHarness.js';
|
||||
|
||||
const STAGE = 'act2autochess_m04';
|
||||
const WATER = ['10,6', '11,6', '12,6'];
|
||||
@@ -297,3 +305,178 @@ test('#9 bots place 狼群 / 流形 only inside their owner\'s range', () => {
|
||||
}
|
||||
assert.ok(placed > 0, 'the bots placed some summons');
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
// GitHub #32 item 4 (after 0.1.1): 钩索师 / 推击手 on a 高台
|
||||
|
||||
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 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) });
|
||||
|
||||
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');
|
||||
}
|
||||
for (const t of Object.values(DATA.tokens)) assert.equal(t.placement, undefined, t.tokenId);
|
||||
});
|
||||
|
||||
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', () => {
|
||||
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);
|
||||
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);
|
||||
}
|
||||
assert.deepEqual(move(m, p.uid, board(9, 3)), { ok: true }, `${id}: the ground stays legal`);
|
||||
assert.deepEqual(toHand(m, ps, p), { ok: true });
|
||||
}
|
||||
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)));
|
||||
for (const k of HIGH) {
|
||||
const [r, c] = rc(k);
|
||||
assert.equal(move(m, tank.uid, board(r, c)).error, ERR.BAD_TILE, `重装 → ${k}`);
|
||||
}
|
||||
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');
|
||||
checkInvariants(m);
|
||||
m.dispose();
|
||||
});
|
||||
|
||||
test('#32-4 the client mirrors it: the drag highlights of 歌蕾蒂娅 / 崖心 / 见行者 include the 高台 (= the server\'s legal tiles); the 重装 keeps "近战单位只能部署在地面"', () => {
|
||||
const { m, ps } = prep(HIGH_STAGE);
|
||||
const pieces = ANY_TILE.map((id) => give(m, ps, id));
|
||||
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]) {
|
||||
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);
|
||||
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, '近战单位只能部署在地面');
|
||||
}
|
||||
}
|
||||
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', () => {
|
||||
const { m, ps } = prep(HIGH_STAGE);
|
||||
const glad = give(m, ps, GLADIIA);
|
||||
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)', () => {
|
||||
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);
|
||||
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']);
|
||||
m.dispose();
|
||||
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 } }],
|
||||
enemies: [{ key: 'enemy_1422_lrsldr', route: 0, time: 1, mods: { hpMul: 50 } }],
|
||||
});
|
||||
const u = h.unit(GLADIIA);
|
||||
let hits = 0;
|
||||
let blocked = false;
|
||||
h.b.on('damaged', (x) => { if (x.source === u) hits++; });
|
||||
for (let i = 0; i < 30 * 30; i++) { h.step(1); if (u.blocking.length) blocked = true; }
|
||||
assert.ok(u.deployed, `deployed on ${r},${c}`);
|
||||
assert.equal(u.ground, !high, `${r},${c}: ground unit`);
|
||||
assert.ok(hits > 0, `attacks from ${r},${c}`);
|
||||
assert.equal(blocked, !high, high ? 'blocks nothing on the 高台' : 'blocks on the ground');
|
||||
assert.equal(h.b.errors.length, 0);
|
||||
}
|
||||
});
|
||||
|
||||
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();
|
||||
}
|
||||
});
|
||||
@@ -208,6 +208,18 @@ 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
|
||||
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`);
|
||||
}
|
||||
assert.deepEqual(canPlace(ctx, m.uid, { area: 'board', row: 10, col: 4 }), { ok: false, code: 'BAD_TILE', reason: '近战单位只能部署在地面' });
|
||||
});
|
||||
test('not editable ⇒ nothing is legal', () => {
|
||||
const m = piece(MELEE);
|
||||
assert.equal(canPlace(ctxFor(privWith({ hand: [m] }), false), m.uid, { area: 'board', row: 9, col: 3 }).code, 'WRONG_PHASE');
|
||||
|
||||
Reference in new issue
Block a user