feedback1 WD: forms reach late views, stable enemy shapes, review fixes

- Every form change goes through content setForm(): the unit keeps it (e.form)
  and UnitInfo publishes it, so a view built mid-battle from fieldMeta (a
  watched teammate's field, 联防 observers, a reconnect) starts in the
  current form instead of the first-form model.
- Enemy profile (dmgType) and Unit moving / form are initialised at spawn:
  one object shape for the sim's hot loop (the boss-field bench is back at
  the base speed).
- 转译基底·α: an HP loss cannot knock out its original form (no death clip).
- 假想敌:再生: 1 s 重生 and walking 傀儡 cited from PRTS; shields within 1.8
  as the 再生状态 begins.
- Renderer: a 重生's closing clip (and the ember's stand-up clip) is timed
  from the fx dur to end with it, so the next form attacks on its own clips.
- Docs: ASSETS FORMS list, SIM form fx, PLAYING 隐匿 wording.
This commit is contained in:
sganggs committed 2026-10-03 03:02:46 +08:00
1 parent 06be81f67e
commit 5c23eeb804
12 files changed
+318 -88

No files matched your search

+96 -1
View File
@@ -11,6 +11,10 @@
// every 逐火 enemy of a round leaked.
// The real-round tests build the battle like Match._normalOpts: an official wave (waves.js buildNormalWave, a 悬赏 card
// through withBounties), the real stage 战场#01, real chess, full content, buildBattleSpec → createBattleFromSpec.
// Review follow-ups: a view built mid-battle (fieldMeta — a watched teammate's field, 联防 observers, a reconnect; the
// client runner's silent catch-up drops the fx) learns the current form from UnitInfo `form`; an HP loss (流失) cannot
// knock 转译基底·α out before its change; 假想敌:再生's shields come with its 再生状态, within 1.8 (PRTS 天赋); enemy
// profiles keep one object shape from spawn (the sim's hot loop).
import { test, describe } from 'node:test';
import assert from 'node:assert/strict';
@@ -23,7 +27,7 @@ import { getDefaultSource } from '../../server/sim/simdata.js';
import { GEO } from '../../shared/constants.js';
import { makeBattle, chessRec, checkInvariants } from '../helpers/battleHarness.js';
import { canTargetEnemy } from '../../server/sim/targeting.js';
import { HUSK_REBIRTH, TRANSLATOR_CHANGE } from '../../server/sim/content/enemies.js';
import { HUSK_REBIRTH, TRANSLATOR_CHANGE, abOf } from '../../server/sim/content/enemies.js';
const QUIET = { warn() {}, error() {}, info() {} };
const DATA = getData({ log: QUIET });
@@ -128,6 +132,7 @@ describe('#8 深池逐火: a knock-out is a walking 隐匿 ember that a blocker
walked = Math.max(walked, Math.hypot(u.x - m.x, u.y - m.y));
}
check(u.stats.attacks === m.attacks, 'an ember never attacks');
if (n % 30 === 0) check(b.fieldMeta().units.find((x) => x.id === u.id)?.form === 'husk', 'a view built now (fieldMeta) shows the ember');
}
}
const r = b.result();
@@ -209,6 +214,23 @@ describe('#8 深池逐火: a knock-out is a walking 隐匿 ember that a blocker
assert.equal(e.hp, n - 4);
assert.ok(e.alive);
});
test('假想敌:再生 (PRTS 天赋 "被击倒后重生,持续1s,随后变为再生状态 … 进入此形态时,使半径1.8范围内的其他敌方单位…获得5层…护盾"): no shields during the 1 s 重生, then 5-hit shields within 1.8 only', () => {
const h = arena({ units: [{ chessId: 't_gun', row: 10, col: 4 }], kits: QUIET_GUNS });
h.step();
const still = { mods: { speedMul: 0 } };
const e = put(h, 'enemy_9010_acpupp', { pos: [10, 8], ...still });
const near = put(h, 'enemy_1007_slime', { pos: [10, 6.3], ...still }); // 1.7 away
const far = put(h, 'enemy_1007_slime', { pos: [11.9, 8], ...still }); // 1.9 away
h.b.kill(e, h.unit('t_gun'));
assert.ok(e.alive && e.form === 'husk');
h.run(HUSK_REBIRTH - 0.1);
assert.equal(abOf(h.b, near).hitShield ?? 0, 0, 'no shield while it is still in its 重生');
h.run(0.2);
assert.equal(abOf(h.b, near).hitShield, tb('enemy_9010_acpupp', 'Aura.max_damage_block_cnt'), 'the 再生状态 begins: 5 hits of shield within 1.8');
assert.equal(abOf(h.b, far).hitShield ?? 0, 0, 'nothing 1.9 away');
assert.ok(e.s.flags.unblockable && !e.s.flags.noMove, '不可阻挡, free to move after the 1 s');
});
});
// ---------------------------------------------------------------------------------------------------------------
@@ -268,10 +290,12 @@ describe('#5 转译基底·α: damage is cancelled until its form change; only t
],
});
let tr = null, phaseAt = null, kind = null, diedAt = null, formAt = null, maxBefore = null, firstFormLoss = null, earlyAttack = false;
let lateForm; // UnitInfo.form of the translator in fieldMeta() 1 s after its change began
let n = 0;
while (!b.finished && n++ < 30 * 300) {
b.step();
tr = tr ?? b.enemies.find((e) => e.defId === TR) ?? null;
if (tr && tr.alive && phaseAt != null && lateForm === undefined && b.time >= phaseAt + 1) lateForm = b.fieldMeta().units.find((u) => u.id === tr.id)?.form ?? null;
for (const ev of b.drainEvents()) {
if (!tr) continue;
if (ev[0] === 'fx' && ev[1] === 'phase' && ev[4].id === tr.id) { phaseAt = b.time; kind = ev[4].kind; }
@@ -289,6 +313,7 @@ describe('#5 转译基底·α: damage is cancelled until its form change; only t
assert.ok(phaseAt != null && diedAt > phaseAt + TRANSLATOR_CHANGE - 0.05, 'it changed form before it died — never killed in its first form');
assert.equal(firstFormLoss, null, 'its first form loses no HP');
assert.equal(kind, 'translator_fuchou', '4 physical hits first ⇒ 寻仇者');
assert.equal(lateForm, 'translator_fuchou', 'a view built mid-battle (fieldMeta) draws the changing form, not the A model');
approx(formAt - phaseAt, TRANSLATOR_CHANGE, 0.02, 'the change lasts 2 s');
assert.ok(!earlyAttack, 'no attack before its change');
const r = b.result();
@@ -356,6 +381,24 @@ describe('#5 转译基底·α: damage is cancelled until its form change; only t
checkInvariants(h2.b);
});
test('an HP loss (流失 — no damage instance to cancel, e.g. 隐德来希\'s 心烛 hand-over) cannot knock out its original form; once changed it can', () => {
const h = arena({ units: [{ chessId: 't_gun', row: 10, col: 4 }], kits: QUIET_GUNS });
h.step();
const e = put(h, TR, { mods: { speedMul: 0 } });
const g = h.unit('t_gun');
h.b.loseHp(e, 1e9, { source: g });
assert.ok(e.alive && e.hp >= 1, 'still standing in its first form');
assert.equal(h.b.killed, 0);
assert.equal(h.eventsOf('die').filter((ev) => ev[1] === e.id).length, 0, 'no die event: its first form has no death clip');
for (let i = 0; i < 4; i++) h.b.dealDamage(g, e, { amount: 1, type: 'phys' });
h.b.loseHp(e, 1e9, { source: g });
assert.ok(e.alive, 'not during its change either');
h.run(TRANSLATOR_CHANGE + 0.1);
h.b.loseHp(e, 1e9, { source: g });
assert.ok(!e.alive && e.removeReason === 'killed', 'the changed form dies');
assert.equal(h.b.killed, 1);
});
test('the 4th arts hit ⇒ 特战术师: its stats, ranged arts attacks on 2 targets at once', () => {
const h = arena({ units: [{ chessId: 't_mage', row: 11, col: 6 }, { chessId: 't_gun', row: 10, col: 7 }], kits: QUIET_GUNS, hooks: ['damaged'], captureNoisy: true });
h.step();
@@ -397,3 +440,55 @@ describe('#5 转译基底·α: damage is cancelled until its form change; only t
assert.equal(e.mem.ab.list.length, 1);
});
});
// ---------------------------------------------------------------------------------------------------------------
// review follow-ups: the form reaches a view built mid-battle; stable enemy shapes
describe('a view built mid-battle learns the form (UnitInfo `form` in fieldMeta)', () => {
const formOf = (h, e) => h.b.fieldMeta().units.find((u) => u.id === e.id)?.form;
test('spawned: no form; 转译基底·α changing / changed, a 逐火 ember and its revival, a leader\'s 重生 and second form, 守墓石像 — each fieldMeta carries the current one', () => {
const h = arena({ units: [{ chessId: 't_gun', row: 10, col: 4 }, { chessId: 't_mage', row: 11, col: 4 }], kits: QUIET_GUNS });
h.step();
const still = { mods: { speedMul: 0 } };
const tr = put(h, TR, { pos: [9, 8], ...still });
const ember = put(h, 'enemy_1288_duskls', { pos: [10, 8], ...still });
const mace = put(h, 'enemy_1525_blkswb', { pos: [11, 8], ...still });
const stone = put(h, 'enemy_1172_dugago', { pos: [12, 8], ...still });
const spawned = h.eventsOf('spawn').find((ev) => ev[1].id === tr.id)[1];
assert.equal(spawned.form, undefined, 'a fresh enemy has no form');
assert.equal(formOf(h, tr), undefined);
const m = h.unit('t_mage');
for (let i = 0; i < 4; i++) h.b.dealDamage(m, tr, { amount: 1, type: 'arts' });
h.b.kill(ember, m);
h.b.kill(mace, m);
h.b.kill(stone, m);
// the client runner's silent catch-up: the fx are drained and dropped
h.b.step();
h.b.drainEvents();
assert.equal(formOf(h, tr), 'translator_shushi', 'changing');
assert.equal(formOf(h, ember), 'husk');
assert.equal(formOf(h, mace), 'reborn');
assert.equal(formOf(h, stone), 'stone');
h.b.kill(ember, null); // still in its 1 s 重生: nothing changes
while (h.b.time < 12.5) { h.b.step(); h.b.drainEvents(); }
assert.equal(formOf(h, tr), 'translator_shushi', 'changed');
assert.equal(formOf(h, ember), 'revived', 'the warrior again');
assert.equal(formOf(h, mace), 'form2', 'after its 重生');
assert.equal(formOf(h, stone), 'fly');
});
});
test('every enemy starts with the same profile fields and `moving` / `form` (one object shape for the hot loop)', () => {
const h = arena({ units: [{ chessId: 't_gun', row: 10, col: 4 }], kits: QUIET_GUNS });
h.step();
const keys = [TR, ...EMBERS, 'enemy_1007_slime', 'enemy_1172_dugago', 'enemy_1525_blkswb', 'enemy_9010_acpupp'];
const shapes = new Set();
for (const key of keys) {
const e = put(h, key);
assert.equal(e.moving, false, `${key} moving`);
assert.equal(e.form, null, `${key} form`);
assert.ok('dmgType' in e.profile && e.profile.dmgType === null, `${key} profile.dmgType`);
shapes.add(Object.keys(e).join());
}
assert.equal(shapes.size, 1, 'one key order for every enemy');
});