feedback5: merge O2 — 自选 kits for 艾雅法拉, 刻俄柏 and 霍尔海雅; OPERATOR_KIT_FILES rebuilt as one list; golden: only diy moved

This commit is contained in:
sganggs committed 2026-10-06 00:04:06 +08:00
commit 67d0993fa0
8 files changed
+2009 -119

No files matched your search

+330
View File
@@ -0,0 +1,330 @@
// test/content/op_amgoat.test.js — the 自选 operator kit of 艾雅法拉 (char_180_amgoat, 6★ 中坚术师; kit
// server/sim/content/kits/ops/op-amgoat.js), fielded the production way (a DIY slot + its `diy` pick, simdata getDiy) in
// every form: tiers 5 / 6, normal (E2 Lv1, skill rank 4, no module) and elite (E2 Lv60, rank 7) with no module, CCR-X
// “错过的声音” or CCR-Y “宠物大赛第一名” at stage 1 (tier 5) / 3 (tier 6). Every number is read back from data/backups.json
// (the form of that slot status); the fidelity checklist of kits/README.md item by item.
// Run: node --test test/content/op_amgoat.test.js
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { makeBattle, enemyRec, checkInvariants } from '../helpers/battleHarness.js';
import { KITTED_CHARS, OPERATOR_KITS, KITS } from '../../server/sim/content/kits/index.js';
import { diyPool, validateDiyPicks } from '../../shared/diy.js';
const load = (f) => JSON.parse(readFileSync(new URL(`../../data/${f}.json`, import.meta.url), 'utf8'));
const CHESS = load('chess');
const BACKUPS = load('backups');
const ID = 'char_180_amgoat';
const FORMS = BACKUPS.units[ID].forms;
const SLOT = { 5: 'chess_char_5_diy1_a', 6: 'chess_char_6_diy1_a' };
const CCRX = 'uniequip_002_amgoat', CCRY = 'uniequip_003_amgoat';
const S1 = 'skchr_amgoat_1', S2 = 'skchr_amgoat_2', S3 = 'skchr_amgoat_3';
const formOf = (tier, elite) => FORMS[elite ? (tier === 5 ? '2/60/7/1' : '2/60/7/3') : '2/1/4/0'];
const skillOf = (tier, elite, id) => formOf(tier, elite).skills.find((s) => s.skillId === id);
const modOf = (tier, mod) => (mod ? formOf(tier, true).modules.find((m) => m.uniEquipId === mod) : null);
const approx = (a, b, msg, eps = 1e-6) => assert.ok(Math.abs(a - b) <= eps * Math.max(1, Math.abs(b)), `${msg}: ${a} vs ${b}`);
const dummy = (key, o = {}) => enemyRec({ key, hp: 1e9, speed: 0, mass: 0, res: 50, ...o });
const ENEMIES = {
enemy_dummy: dummy('enemy_dummy'), enemy_fly: dummy('enemy_fly', { motion: 'FLY' }),
enemy_elite: dummy('enemy_elite', { rank: 'ELITE' }), enemy_boss: dummy('enemy_boss', { rank: 'BOSS' }),
};
/** Every 自选 form: [tier, elite, module]. */
const FORMS_ALL = [[5, false, null], [6, false, null], ...[5, 6].flatMap((t) => [null, CCRX, CCRY].map((m) => [t, true, m]))];
const label = ([tier, elite, mod]) => `T${tier} ${elite ? 'elite' : 'normal'} ${mod ?? 'none'}`;
/** A battle with 艾雅法拉 as uid 1 at (row, col) facing RIGHT, plus `others`. */
function field({ tier = 5, elite = false, mod = null, skill = 2, row = 10, col = 5, others = [], seed = 5, setup = null } = {}) {
const h = makeBattle({
defs: { enemies: ENEMIES }, timeLimit: 900, autoFinish: false, seed,
flags: { dpPerSec: 0, dpMax: 999 }, hooks: ['damaged', 'skillStart', 'skillEnd', 'statusApplied', 'spGain', 'deploy'], captureNoisy: true,
units: [{ uid: 1, diy: { slot: SLOT[tier], charId: ID, skillIndex: skill, uniEquipId: mod }, elite, row, col }, ...others],
setup,
});
h.step();
return { h, u: h.unit(1) };
}
const hitsBy = (h, u) => h.hooksOf('damaged').filter((c) => c.source === u);
function done(h) {
checkInvariants(h.b);
assert.equal(h.b.errors.length, 0, JSON.stringify(h.b.errors[0]));
}
/** Arts damage of `amount` on RES `res` with `ignore` flat RES ignored. */
const arts = (amount, res, ignore = 0) => Math.max(amount * (1 - Math.max(0, res - ignore) / 100), amount * 0.05);
test('艾雅法拉 in every 自选 form: her operator kit (all three skills authored), the form\'s stats + module attributes, 3-1 range, ranged arts that hits air, block 1, 1.6 s, 空 bonds, no 特质', () => {
assert.equal(OPERATOR_KITS[ID], KITS[ID]);
for (const f of FORMS_ALL) {
const [tier, elite, mod] = f;
for (const skill of [0, 1, 2]) {
const { h, u } = field({ tier, elite, mod, skill });
const form = formOf(tier, elite), m = elite ? modOf(tier, mod) : null;
assert.deepEqual([u.def.charId, u.def.diyFor, u.skill.id, !!u.kit.generic, u.kit.skillSource], [ID, SLOT[tier], form.skills[skill].skillId, false, 'skills'], label(f));
assert.deepEqual([u.base.maxHp, u.base.atk, u.base.def, u.base.res], [form.stats.maxHp + (m?.attr.maxHp ?? 0), form.stats.atk + (m?.attr.atk ?? 0), form.stats.def + (m?.attr.def ?? 0), 20], `${label(f)}: stats`);
assert.deepEqual([u.s.blockCnt, u.profile.attack, u.profile.dmgType, u.profile.canHitFly, u.profile.groundOnly, u.base.bat], [1, 'ranged', 'arts', true, false, 1.6], `${label(f)}: 中坚术师`);
assert.deepEqual(u.liveRangeGrid, form.rangeGrid, `${label(f)}: 3-1`);
assert.deepEqual([u.def.bonds, u.def.raw.garrisonIds, u.def.raw.tokens], [['emptyShip'], [], []], `${label(f)}: bonds / 特质 / no summon`);
assert.ok(!u.s.flags.liftoff && !u.s.flags.camou && !u.s.flags.stealth && !u.s.flags.untargetable, `${label(f)}: ground enemies target her`);
done(h);
}
}
// the numbers of the forms (zh_CN): E2 Lv1 1359 / 535 / 109, E2 Lv60 1614 / 608 / 118; CCR-X +130 / +40 → +180 / +65,
// CCR-Y +180 / +25 → +230 / +50 HP / ATK
assert.deepEqual([FORMS['2/1/4/0'].stats.maxHp, FORMS['2/1/4/0'].stats.atk, FORMS['2/60/7/1'].stats.maxHp, FORMS['2/60/7/1'].stats.atk], [1359, 535, 1614, 608]);
assert.deepEqual([modOf(5, CCRX).attr, modOf(6, CCRX).attr, modOf(5, CCRY).attr, modOf(6, CCRY).attr], [{ maxHp: 130, atk: 40 }, { maxHp: 180, atk: 65 }, { maxHp: 180, atk: 25 }, { maxHp: 230, atk: 50 }]);
});
test('a 自选 pick: 艾雅法拉 is offered at tiers 5 and 6 (she has a kit) and a roster with her passes validateDiyPicks', () => {
const data = { chess: CHESS, backups: BACKUPS };
assert.ok(KITTED_CHARS.includes(ID));
for (const t of [5, 6]) assert.ok(diyPool(t, { data, kitted: KITTED_CHARS }).includes(ID), `tier ${t}`);
assert.deepEqual(validateDiyPicks({ [SLOT[6]]: { charId: ID, skillIndex: 2, uniEquipId: CCRY } }, { data, kitted: KITTED_CHARS }),
{ ok: true, picks: { [SLOT[6]]: { charId: ID, skillIndex: 2, uniEquipId: CCRY } } });
});
test('S1 二重咏唱 (MANUAL, data DEFAULT, 25 s): ASPD +38 / +45 on the first cast of a deployment; ASPD and ATK +38 % / +45 % from the second; the count restarts after a redeploy', () => {
for (const [tier, elite] of [[5, false], [6, true]]) {
const sk = skillOf(tier, elite, S1);
const { h, u } = field({ tier, elite, skill: 0 });
const a = sk.bb['amgoat_s_1[a].attack_speed'], b = sk.bb['amgoat_s_1[b].attack_speed'], atk = sk.bb['amgoat_s_1[b].atk'];
assert.deepEqual([u.skill.rule, sk.duration, sk.spCost, sk.initSp, a, b, atk], ['DEFAULT', 25, elite ? 39 : 42, elite ? 20 : 15, elite ? 45 : 38, elite ? 45 : 38, elite ? 0.45 : 0.38], `T${tier}`);
h.run(0.6);
const aspd0 = u.s.aspd, atk0 = u.s.atk;
u.skill.gainSp(999);
h.run(2);
assert.equal(u.skill.activations, 0, `T${tier}: no enemy, no cast`);
h.spawn('enemy_dummy', { pos: [10, 6] });
assert.ok(h.runUntil(() => u.skill.active, 3), `T${tier}: cast with an enemy in her range`);
approx(u.skill.timeLeft, 25, `T${tier}: 25 s`, 0.01);
assert.deepEqual(u.findBuff('skill:amgoat:duet')?.mods, { aspd: a }, `T${tier}: the first cast`);
approx(u.s.aspd, aspd0 + a, `T${tier}: ASPD`);
approx(u.s.atk, atk0, `T${tier}: no ATK on the first cast`);
assert.ok(h.runUntil(() => !u.skill.active, 26));
assert.equal(u.findBuff('skill:amgoat:duet'), null, `T${tier}: gone after it`);
u.skill.gainSp(999);
assert.ok(h.runUntil(() => u.skill.active, 5), `T${tier}: the second cast`);
assert.deepEqual(u.findBuff('skill:amgoat:duet')?.mods, { aspd: b, atkPct: atk }, `T${tier}: the second cast`);
approx(u.s.atk, u.base.atk * (1 + 0.14 + atk), `T${tier}: ATK with 炎息`);
h.b.retreat(u);
h.b.redeploy(u);
u.skill.gainSp(999);
assert.ok(h.runUntil(() => u.skill.active, 5), `T${tier}: a cast after the redeploy`);
assert.deepEqual(u.findBuff('skill:amgoat:duet')?.mods, { aspd: a }, `T${tier}: the count restarted (PRTS 备注)`);
done(h);
}
});
test('S2 点燃 (AUTO, 2 charges, data DEFAULT): main target RES ×0.85 / ×0.8 first, ½ explosion on every enemy within 1.5 (flyers too), then ½ again on the main target; the others\' RES cut after their hit, 6 s', () => {
for (const [tier, elite, mod] of [[5, false, null], [6, true, null], [6, true, CCRX]]) {
const sk = skillOf(tier, elite, S2);
const { h, u } = field({ tier, elite, mod, skill: 1 });
assert.deepEqual([u.skill.rule, u.skill.kind, u.skill.maxCharges, sk.spCost, sk.bb.atk_scale, sk.bb.atk_scale_2, sk.bb.magic_resistance, sk.bb.duration],
['DEFAULT', 'charges', 2, elite ? 6 : 7, elite ? 1.55 : 1.375, elite ? 1.55 : 1.375, elite ? -0.2 : -0.15, 6], `T${tier}`);
const ign = mod === CCRX ? 10 : 0;
h.run(0.6);
// 乱火 filled 1–2 charges at the deployment: spent before the scene is set
u.skill.charges = 0;
u.skill.sp = 0;
// the main target alone in her range (its tip 0,3); three around it outside the range, one beyond the explosion
const main = h.spawn('enemy_dummy', { pos: [10, 8] });
const n1 = h.spawn('enemy_dummy', { pos: [10, 9] }), n2 = h.spawn('enemy_dummy', { pos: [11, 9] }), fly = h.spawn('enemy_fly', { pos: [9, 9] });
const far = h.spawn('enemy_dummy', { pos: [10, 10] });
u.skill.gainSp(999);
assert.equal(u.skill.charges, 2);
const n0 = hitsBy(h, u).length;
assert.ok(h.runUntil(() => hitsBy(h, u).slice(n0).filter((c) => c.target === main).length >= 2, 4), `T${tier}: the ignited attack lands`);
h.step();
const hits = hitsBy(h, u).slice(n0);
const atk = u.s.atk;
const cut = 50 * (1 + sk.bb.magic_resistance);
const onMain = hits.filter((c) => c.target === main);
assert.equal(onMain.length, 2, `T${tier}: two ½ hits on the main target`);
for (const c of onMain) approx(c.amount, arts(atk * sk.bb.atk_scale, cut, ign), `T${tier}: ½ on the main target after its RES cut`);
for (const e of [n1, n2, fly]) {
const hs = hits.filter((c) => c.target === e);
assert.equal(hs.length, 1, `T${tier}: one explosion hit on ${e.tileR},${e.tileC}`);
approx(hs[0].amount, arts(atk * sk.bb.atk_scale, 50, ign), `T${tier}: ½ before its own RES cut`);
assert.deepEqual([hs[0].type, hs[0].dmg.isSplash, hs[0].dmg.isSkill], ['arts', true, true]);
}
assert.ok(!hits.some((c) => c.target === far), `T${tier}: 2 tiles away — outside the 1.5 explosion`);
for (const e of [main, n1, n2, fly]) approx(e.s.res, cut, `T${tier}: RES ×${1 + sk.bb.magic_resistance}`);
approx(far.s.res, 50, `T${tier}: untouched`);
assert.equal(u.skill.charges, 1, `T${tier}: one charge spent`);
// the next attack spends the second charge; the cut stays one (同名效果取最高) and lasts 6 s
assert.ok(h.runUntil(() => u.skill.charges === 0, 4));
h.run(0.5);
approx(main.s.res, cut, `T${tier}: one RES cut, not two`);
h.b.retreat(u); // no further ignition: the cut runs out
h.run(6.2);
approx(main.s.res, 50, `T${tier}: back after 6 s`);
done(h);
}
});
test('S3 火山 (MANUAL, data SKILL_RANGE on x-3): 15 s, ATK +70 % / +85 %, interval 1.6 − 1.1 = 0.5 s, range x-3 while on, lava on 4 / 5 random different enemies of it per attack (all when fewer); back after', () => {
for (const [tier, elite] of [[5, false], [6, true]]) {
const sk = skillOf(tier, elite, S3);
const { h, u } = field({ tier, elite, skill: 2, seed: 9 });
const n = sk.bb['attack@max_target'];
assert.deepEqual([u.skill.rule, sk.trigger.rawRule, sk.rangeId, sk.duration, sk.bb.atk, sk.bb.base_attack_time, n, sk.spCost, sk.initSp],
['SKILL_RANGE', 'DEFAULT', 'x-3', 15, elite ? 0.85 : 0.7, -1.1, elite ? 5 : 4, 80, elite ? 40 : 33], `T${tier}`);
assert.deepEqual(u.skill.triggerGrid, sk.rangeGrid, `T${tier}: the trigger grid is x-3`);
h.run(0.6);
const atk0 = u.s.atk;
approx(u.s.interval, 1.6, `T${tier}: own interval`);
u.skill.gainSp(999);
h.run(1);
assert.equal(u.skill.activations, 0, `T${tier}: nobody on x-3`);
// seven enemies: x-3 holds (8,5) / (12,5) / (10,2), none of them in her own 3-1
const spots = [[10, 6], [9, 7], [11, 7], [10, 8], [8, 5], [12, 5], [10, 2]];
const foes = spots.map((p) => h.spawn('enemy_dummy', { pos: p }));
assert.ok(h.runUntil(() => u.skill.active, 2), `T${tier}: cast`);
approx(u.skill.timeLeft, 15, `T${tier}: 15 s`, 0.05);
assert.deepEqual(u.liveRangeGrid, sk.rangeGrid, `T${tier}: x-3 while on`);
approx(u.s.interval, 0.5, `T${tier}: 0.5 s`);
approx(u.s.atk, atk0 + u.base.atk * sk.bb.atk, `T${tier}: ATK +${sk.bb.atk * 100} %`);
const n0 = hitsBy(h, u).length;
h.run(6);
assert.ok(u.skill.active);
u.skill.end('test');
h.run(0.5); // the last lava lands
const hits = hitsBy(h, u).slice(n0).filter((c) => c.dmg.isAttack && c.dmg.isSkill);
const byAttack = new Map();
for (const c of hits) byAttack.set(c.dmg.attackId, [...(byAttack.get(c.dmg.attackId) ?? []), c.target]);
assert.ok(byAttack.size >= 11, `T${tier}: ${byAttack.size} attacks in 6 s (one per 0.5 s)`);
const counts = new Map(foes.map((e) => [e, 0]));
for (const [, ts] of byAttack) {
assert.equal(ts.length, n, `T${tier}: ${n} lava per attack`);
assert.equal(new Set(ts).size, n, `T${tier}: different enemies`);
for (const t of ts) counts.set(t, counts.get(t) + 1);
}
for (const [e, k] of counts) assert.ok(k > 0, `T${tier}: ${e.tileR},${e.tileC} drew lava (random draw)`);
for (const c of hits.slice(0, 4)) approx(c.amount, arts(atk0 + u.base.atk * sk.bb.atk, 50), `T${tier}: 100 % of her S3 ATK, arts`);
assert.deepEqual(u.liveRangeGrid, formOf(tier, elite).rangeGrid, `T${tier}: back to 3-1`);
approx(u.s.interval, 1.6, `T${tier}: interval back`);
done(h);
}
// two enemies of x-3 only: both every attack
const { h, u } = field({ tier: 6, elite: true, skill: 2, seed: 4 });
const two = [h.spawn('enemy_dummy', { pos: [10, 6] }), h.spawn('enemy_dummy', { pos: [10, 8] })];
u.skill.gainSp(999);
assert.ok(h.runUntil(() => u.skill.active, 2));
const n0 = hitsBy(h, u).length;
h.run(3);
const byAttack = new Map();
for (const c of hitsBy(h, u).slice(n0).filter((x) => x.dmg.isSkill)) byAttack.set(c.dmg.attackId, [...(byAttack.get(c.dmg.attackId) ?? []), c.target]);
[...byAttack.keys()].slice(0, -1).forEach((k) => assert.deepEqual(new Set(byAttack.get(k)), new Set(two), 'fewer enemies than lava: each of them'));
assert.ok(byAttack.size >= 5);
done(h);
});
test('T1 炎息: every 【术师】 operator of the field ATK +14 % while she is deployed (惊蛰 yes, 德克萨斯 no); CCR-X stage 3 "携带时" +22 %, kept while she is knocked out', () => {
const others = [{ uid: 2, chessId: 'chess_char_1_03_a', row: 12, col: 3 }, { uid: 3, chessId: 'chess_char_1_08_a', row: 12, col: 8 }];
for (const f of FORMS_ALL) {
const [tier, elite, mod] = f;
const { h, u } = field({ tier, elite, mod, skill: 0, others });
h.run(0.6);
const leizi = h.unit(2), texas = h.unit(3);
const carried = elite && tier === 6 && mod === CCRX;
const v = carried ? 0.22 : 0.14;
const t0 = u.def.raw.talents.find((t) => t.index === 0);
assert.equal(t0.bb.atk, v, `${label(f)}: the data`);
assert.match(t0.desc, carried ? /^携带时/ : /^在场时/, `${label(f)}: the text`);
assert.deepEqual(leizi.findBuff('talent:amgoat:casters')?.mods, { atkPct: v }, `${label(f)}: 惊蛰 (术师)`);
assert.deepEqual(u.findBuff('talent:amgoat:casters')?.mods, { atkPct: v }, `${label(f)}: herself`);
assert.equal(texas.findBuff('talent:amgoat:casters'), null, `${label(f)}: 德克萨斯 (先锋) gets nothing`);
h.b.kill(u, null);
h.run(1.2);
assert.equal(!!leizi.findBuff('talent:amgoat:casters'), carried, `${label(f)}: after she is knocked out`);
done(h);
}
});
test('T2 乱火: 7–15 SP at every deployment (a floored draw); CCR-Y stage 3 also ASPD +6–15, both the maxima (15 / 15) with an elite or leader in range at the deployment; stage 1 and no module: no ASPD, no maximum rule', () => {
const seen = new Set(), seenAs = new Set();
for (let seed = 1; seed <= 40; seed++) {
const gifts = [];
const setup = (b) => b.on('deploy', (c) => { if (c.unit.uid === 1) gifts.push([c.unit.skill.sp, c.unit.findBuff('talent:amgoat:wildfire')?.mods?.aspd ?? 0]); }, { priority: -100 });
const y3 = seed % 2 === 0;
const { h } = field({ tier: 6, elite: true, mod: y3 ? CCRY : null, skill: 2, seed, setup });
const sk = skillOf(6, true, S3);
const [sp, as] = gifts[0];
const k = sp - sk.initSp;
assert.ok(Number.isInteger(k) && k >= 7 && k <= 15, `seed ${seed}: +${k} SP`);
seen.add(k);
if (y3) { assert.ok(Number.isInteger(as) && as >= 6 && as <= 15, `seed ${seed}: ASPD +${as}`); seenAs.add(as); } else assert.equal(as, 0);
done(h);
}
assert.ok(seen.size >= 6 && seenAs.size >= 4, `a spread of draws: SP ${[...seen].sort((a, b) => a - b)}, ASPD ${[...seenAs].sort((a, b) => a - b)}`);
// an elite / leader in range at a deployment: the maxima with CCR-Y stage 3; a draw otherwise
for (const [tier, mod, rank] of [[6, CCRY, 'enemy_elite'], [6, CCRY, 'enemy_boss'], [5, CCRY, 'enemy_elite'], [6, null, 'enemy_elite'], [6, CCRY, 'enemy_dummy']]) {
const lab = `T${tier} ${mod ?? 'none'} ${rank}`;
const top = tier === 6 && mod === CCRY && rank !== 'enemy_dummy';
let maxed = 0;
for (let seed = 1; seed <= 6; seed++) {
const gifts = [];
const setup = (b) => b.on('deploy', (c) => { if (c.unit.uid === 1) gifts.push([c.unit.skill.sp, c.unit.findBuff('talent:amgoat:wildfire')?.mods?.aspd ?? 0]); }, { priority: -100 });
const { h, u } = field({ tier, elite: true, mod, skill: 2, seed, setup });
const sk = skillOf(tier, true, S3);
h.spawn(rank, { pos: [10, 6] });
h.b.retreat(u);
h.b.redeploy(u);
const [sp, as] = gifts[1];
if (top) assert.deepEqual([sp - sk.initSp, as], [15, 15], `${lab} seed ${seed}: the maxima`);
else {
assert.ok(sp - sk.initSp >= 7 && sp - sk.initSp <= 15, lab);
if (sp - sk.initSp === 15) maxed++;
if (mod !== CCRY || tier === 5) assert.equal(as, 0, `${lab}: no ASPD`);
}
done(h);
}
if (!top) assert.ok(maxed < 6, `${lab}: not always the maximum`);
}
// the talent's text and blackboard (stage 3 CCR-Y)
const t1 = formOf(6, true).modules.find((m) => m.uniEquipId === CCRY).talentChanges.find((t) => t.talentIndex === 1);
assert.deepEqual(t1.bb, { sp_min: 7, sp_max: 16, attack_speed_min: 6, attack_speed_max: 16, factor: 1 });
assert.match(t1.desc, /随机获得7~15点技力并随机提升6~15的攻击速度/);
});
test('modules: CCR-X "无视目标10点法术抗性" at stages 1 and 3 (her normal attack on RES 50 deals × 0.6); CCR-Y "普通攻击命中精英或领袖敌人时获得1点技力" — not on a normal enemy, not from S2\'s explosion', () => {
for (const f of FORMS_ALL) {
const [tier, elite, mod] = f;
const { h, u } = field({ tier, elite, mod, skill: 2 });
const x = elite && mod === CCRX, y = elite && mod === CCRY;
assert.equal(u.s.resIgnoreFlat, x ? 10 : 0, `${label(f)}: RES ignore`);
if (x) assert.equal(u.def.raw.trait.moduleDesc, '无视目标10点法术抗性');
if (y) assert.deepEqual(u.def.raw.trait.bb, { sp: 1 });
const foe = h.spawn('enemy_dummy', { pos: [10, 6] });
h.run(0.6);
const n0 = hitsBy(h, u).length;
h.run(4);
const hits = hitsBy(h, u).slice(n0).filter((c) => c.target === foe && c.dmg.isAttack);
assert.ok(hits.length >= 2, label(f));
approx(hits[0].amount, arts(u.s.atk, 50, x ? 10 : 0), `${label(f)}: arts on RES 50`);
const talentSp = () => h.hooksOf('spGain').filter((c) => c.unit === u && c.reason === 'trait').length;
assert.equal(talentSp(), 0, `${label(f)}: no SP from a normal enemy`);
h.b.kill(foe, null);
const el = h.spawn('enemy_elite', { pos: [10, 6] });
const k0 = talentSp(), a0 = hitsBy(h, u).filter((c) => c.target === el && c.dmg.isAttack).length;
h.run(4);
const hitsE = hitsBy(h, u).filter((c) => c.target === el && c.dmg.isAttack).length - a0;
assert.ok(hitsE >= 2, label(f));
const gained = talentSp() - k0;
assert.equal(gained, y ? hitsE : 0, `${label(f)}: +1 SP per hit on an elite`);
if (y) for (const c of h.hooksOf('spGain').filter((s) => s.unit === u && s.reason === 'trait')) assert.equal(c.amount, 1);
done(h);
}
// S2's explosion and second ½ are no further 命中 (CCR-Y stage 3): one SP per ignited attack on an elite
const { h, u } = field({ tier: 6, elite: true, mod: CCRY, skill: 1 });
h.run(0.6);
u.skill.charges = 0;
u.skill.sp = 0;
const el = h.spawn('enemy_elite', { pos: [10, 8] });
h.spawn('enemy_elite', { pos: [10, 9] });
u.skill.gainSp(999);
const k0 = h.hooksOf('spGain').filter((c) => c.unit === u && c.reason === 'trait').length;
assert.ok(h.runUntil(() => hitsBy(h, u).filter((c) => c.target === el && c.dmg.isSkill).length >= 2, 4));
h.step();
assert.equal(h.hooksOf('spGain').filter((c) => c.unit === u && c.reason === 'trait').length - k0, 1, 'one SP for the ignited attack');
done(h);
});
+294
View File
@@ -0,0 +1,294 @@
// test/content/op_cerber.test.js — the 自选 operator kit of 刻俄柏 (char_2013_cerber, 6★ 中坚术师; kit
// server/sim/content/kits/ops/op-cerber.js), fielded the production way (a DIY slot + its `diy` pick, simdata getDiy) in
// every form: tiers 5 / 6, normal (E2 Lv1, skill rank 4, no module) and elite (E2 Lv60, rank 7) with no module, CCR-X
// “很干的面包” or CCR-Y “我打的刀” at stage 1 (tier 5) / 3 (tier 6). Every number is read back from data/backups.json (the
// form of that slot status); the fidelity checklist of kits/README.md item by item.
// Run: node --test test/content/op_cerber.test.js
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { makeBattle, enemyRec, checkInvariants } from '../helpers/battleHarness.js';
import { KITTED_CHARS, OPERATOR_KITS, KITS } from '../../server/sim/content/kits/index.js';
import { diyPool, validateDiyPicks } from '../../shared/diy.js';
const load = (f) => JSON.parse(readFileSync(new URL(`../../data/${f}.json`, import.meta.url), 'utf8'));
const CHESS = load('chess');
const BACKUPS = load('backups');
const ID = 'char_2013_cerber';
const FORMS = BACKUPS.units[ID].forms;
const SLOT = { 5: 'chess_char_5_diy1_a', 6: 'chess_char_6_diy1_a' };
const CCRX = 'uniequip_002_cerber', CCRY = 'uniequip_003_cerber';
const S1 = 'skchr_cerber_1', S2 = 'skchr_cerber_2', S3 = 'skchr_cerber_3';
const formOf = (tier, elite) => FORMS[elite ? (tier === 5 ? '2/60/7/1' : '2/60/7/3') : '2/1/4/0'];
const skillOf = (tier, elite, id) => formOf(tier, elite).skills.find((s) => s.skillId === id);
const modOf = (tier, mod) => (mod ? formOf(tier, true).modules.find((m) => m.uniEquipId === mod) : null);
const approx = (a, b, msg, eps = 1e-6) => assert.ok(Math.abs(a - b) <= eps * Math.max(1, Math.abs(b)), `${msg}: ${a} vs ${b}`);
const dummy = (key, o = {}) => enemyRec({ key, hp: 1e9, speed: 0, mass: 0, ...o });
const ENEMIES = {
enemy_dummy: dummy('enemy_dummy'), enemy_fly: dummy('enemy_fly', { motion: 'FLY' }),
enemy_d100: dummy('enemy_d100', { def: 100 }), enemy_d200: dummy('enemy_d200', { def: 200 }), enemy_d300: dummy('enemy_d300', { def: 300 }),
enemy_d400: dummy('enemy_d400', { def: 400 }), enemy_r50: dummy('enemy_r50', { res: 50 }),
enemy_elite: dummy('enemy_elite', { rank: 'ELITE' }), enemy_boss: dummy('enemy_boss', { rank: 'BOSS' }),
};
/** Every 自选 form: [tier, elite, module]. */
const FORMS_ALL = [[5, false, null], [6, false, null], ...[5, 6].flatMap((t) => [null, CCRX, CCRY].map((m) => [t, true, m]))];
const label = ([tier, elite, mod]) => `T${tier} ${elite ? 'elite' : 'normal'} ${mod ?? 'none'}`;
const SHELL = 'cerber:shell';
const shellOf = (c) => !!c.dmg?.tags?.includes(SHELL);
/** A battle with 刻俄柏 as uid 1 at (row, col) facing RIGHT, plus `others`. */
function field({ tier = 5, elite = false, mod = null, skill = 2, row = 10, col = 5, others = [], seed = 5, setup = null } = {}) {
const h = makeBattle({
defs: { enemies: ENEMIES }, timeLimit: 900, autoFinish: false, seed,
flags: { dpPerSec: 0, dpMax: 999 }, hooks: ['damaged', 'skillStart', 'skillEnd', 'statusApplied', 'spGain'], captureNoisy: true,
units: [{ uid: 1, diy: { slot: SLOT[tier], charId: ID, skillIndex: skill, uniEquipId: mod }, elite, row, col }, ...others],
setup,
});
h.step();
return { h, u: h.unit(1) };
}
const hitsBy = (h, u) => h.hooksOf('damaged').filter((c) => c.source === u);
const atkHits = (h, u) => hitsBy(h, u).filter((c) => c.dmg?.isAttack);
function done(h) {
checkInvariants(h.b);
assert.equal(h.b.errors.length, 0, JSON.stringify(h.b.errors[0]));
}
const arts = (amount, res, ignore = 0) => Math.max(amount * (1 - Math.max(0, res - ignore) / 100), amount * 0.05);
test('刻俄柏 in every 自选 form: her operator kit (all three skills authored), the form\'s stats + module attributes, 3-1 range, ranged arts that hits air, block 1, 1.6 s, 空 bonds, no 特质', () => {
assert.equal(OPERATOR_KITS[ID], KITS[ID]);
for (const f of FORMS_ALL) {
const [tier, elite, mod] = f;
for (const skill of [0, 1, 2]) {
const { h, u } = field({ tier, elite, mod, skill });
const form = formOf(tier, elite), m = elite ? modOf(tier, mod) : null;
assert.deepEqual([u.def.charId, u.def.diyFor, u.skill.id, !!u.kit.generic, u.kit.skillSource], [ID, SLOT[tier], form.skills[skill].skillId, false, 'skills'], label(f));
assert.deepEqual([u.base.maxHp, u.base.atk, u.base.def, u.base.res], [form.stats.maxHp + (m?.attr.maxHp ?? 0), form.stats.atk + (m?.attr.atk ?? 0), form.stats.def + (m?.attr.def ?? 0), 20], `${label(f)}: stats`);
assert.deepEqual([u.s.blockCnt, u.profile.attack, u.profile.dmgType, u.profile.canHitFly, u.profile.groundOnly, u.base.bat], [1, 'ranged', 'arts', true, false, 1.6], `${label(f)}: 中坚术师`);
assert.deepEqual(u.liveRangeGrid, form.rangeGrid, `${label(f)}: 3-1`);
assert.deepEqual([u.def.bonds, u.def.raw.garrisonIds, u.def.raw.tokens], [['emptyShip'], [], []], `${label(f)}: bonds / 特质 / no summon`);
assert.ok(!u.s.flags.liftoff && !u.s.flags.camou && !u.s.flags.stealth && !u.s.flags.untargetable, `${label(f)}: ground enemies target her`);
done(h);
}
}
// E2 Lv1 1220 / 553 / 114, E2 Lv60 1449 / 629 / 123; CCR-X +130 / +40 → +180 / +65, CCR-Y +80 / +40 / +17 → +120 / +56 / +23
assert.deepEqual([FORMS['2/1/4/0'].stats.maxHp, FORMS['2/1/4/0'].stats.atk, FORMS['2/60/7/1'].stats.maxHp, FORMS['2/60/7/1'].stats.atk], [1220, 553, 1449, 629]);
assert.deepEqual([modOf(5, CCRX).attr, modOf(6, CCRX).attr, modOf(5, CCRY).attr, modOf(6, CCRY).attr], [{ maxHp: 130, atk: 40 }, { maxHp: 180, atk: 65 }, { maxHp: 80, atk: 40, def: 17 }, { maxHp: 120, atk: 56, def: 23 }]);
});
test('a 自选 pick: 刻俄柏 is offered at tiers 5 and 6 and a roster with her passes validateDiyPicks', () => {
const data = { chess: CHESS, backups: BACKUPS };
assert.ok(KITTED_CHARS.includes(ID));
for (const t of [5, 6]) assert.ok(diyPool(t, { data, kitted: KITTED_CHARS }).includes(ID), `tier ${t}`);
assert.deepEqual(validateDiyPicks({ [SLOT[5]]: { charId: ID, skillIndex: 0, uniEquipId: CCRX } }, { data, kitted: KITTED_CHARS }),
{ ok: true, picks: { [SLOT[5]]: { charId: ID, skillIndex: 0, uniEquipId: CCRX } } });
});
test('S1 “很冰的斧” (AUTO, 1 / 2 charges, data DEFAULT): the next attack at 165 % / 180 % ATK arts on an unblocked enemy rather than a blocked one, binding it 2 / 2.5 s', () => {
for (const [tier, elite] of [[5, false], [6, true]]) {
const sk = skillOf(tier, elite, S1);
// 角峰 blocks the dummy spawned on its tile; the other dummy is free (both in her range; the blocked one is nearer its goal)
const { h, u } = field({ tier, elite, skill: 0, others: [{ uid: 2, chessId: 'chess_char_1_02_a', row: 10, col: 7 }] });
assert.deepEqual([u.skill.rule, u.skill.kind, u.skill.maxCharges, sk.spCost, sk.bb.atk_scale, sk.bb.duration], ['DEFAULT', elite ? 'charges' : 'instant', elite ? 2 : 1, 7, elite ? 1.8 : 1.65, elite ? 2.5 : 2], `T${tier}`);
u.skill.charges = 0;
u.skill.sp = 0;
const blocked = h.spawn('enemy_dummy', { pos: [10, 7] });
const free = h.spawn('enemy_dummy', { pos: [11, 7] });
h.run(0.2);
assert.equal(blocked.blockedBy, h.unit(2), `T${tier}: 角峰 blocks it`);
const n0 = atkHits(h, u).length;
h.run(1.7);
const plain = atkHits(h, u).slice(n0);
assert.ok(plain.length >= 1 && plain.every((c) => c.target === blocked && !c.dmg.isSkill), `T${tier}: her plain attacks go to the blocked one`);
u.skill.gainSp(999);
const n1 = atkHits(h, u).length;
assert.ok(h.runUntil(() => atkHits(h, u).slice(n1).some((c) => c.dmg.isSkill), 3), `T${tier}: cast`);
const sh = atkHits(h, u).slice(n1).find((c) => c.dmg.isSkill);
assert.equal(sh.target, free, `T${tier}: "优先攻击没有被阻挡的目标"`);
approx(sh.amount, u.s.atk * sk.bb.atk_scale, `T${tier}: ${sk.bb.atk_scale * 100} % ATK`);
assert.equal(sh.type, 'arts');
const bind = h.hooksOf('statusApplied').find((c) => c.source === u && c.status === 'bind');
assert.ok(bind && bind.target === free, `T${tier}: bound`);
approx(bind.duration, sk.bb.duration, `T${tier}: 束缚 ${sk.bb.duration} s`);
done(h);
}
});
test('S2 “很热的刀” (MANUAL, data DEFAULT): 33 / 36 s, attack interval × 0.6 / × 0.4 (PRTS "(*0.4)"), the highest-DEF enemy first; all back after', () => {
for (const [tier, elite] of [[5, false], [6, true]]) {
const sk = skillOf(tier, elite, S2);
const { h, u } = field({ tier, elite, skill: 1 });
assert.deepEqual([u.skill.rule, sk.duration, sk.bb.base_attack_time, sk.spCost, sk.initSp], ['DEFAULT', elite ? 36 : 33, elite ? 0.4 : 0.6, elite ? 44 : 47, elite ? 16 : 13], `T${tier}`);
h.run(0.6);
const iv0 = u.s.interval;
const d1 = h.spawn('enemy_d100', { pos: [10, 6] }), d3 = h.spawn('enemy_d300', { pos: [11, 7] }), d2 = h.spawn('enemy_d200', { pos: [9, 6] });
void d1; void d2;
u.skill.gainSp(999);
assert.ok(h.runUntil(() => u.skill.active, 3), `T${tier}: cast`);
approx(u.skill.timeLeft, sk.duration, `T${tier}: ${sk.duration} s`, 0.05);
approx(u.s.interval, iv0 * sk.bb.base_attack_time, `T${tier}: interval × ${sk.bb.base_attack_time}`);
const n0 = atkHits(h, u).length;
h.run(5);
const hits = atkHits(h, u).slice(n0);
assert.ok(hits.length >= Math.floor(5 / u.s.interval) - 1, `T${tier}: ${hits.length} attacks`);
assert.ok(hits.every((c) => c.target === d3), `T${tier}: the DEF 300 enemy`);
assert.ok(h.runUntil(() => !u.skill.active, sk.duration));
approx(u.s.interval, iv0, `T${tier}: interval back`);
done(h);
}
});
test('S3 “很重的枪” (MANUAL, data ACTIVE_RANGE on 3-3): 56 / 57 s, range 3-3 while on, ATK +130 % / +160 %, physical, the lowest-DEF enemy first, each hit silences 2.5 / 3 s; arts and 3-1 again after', () => {
for (const [tier, elite] of [[5, false], [6, true]]) {
const sk = skillOf(tier, elite, S3);
const { h, u } = field({ tier, elite, skill: 2, seed: 7 });
assert.deepEqual([u.skill.rule, sk.trigger.rawRule, sk.rangeId, sk.duration, sk.bb.atk, sk.bb['attack@silence'], sk.initSp], ['ACTIVE_RANGE', 'DEFAULT', '3-3', elite ? 57 : 56, elite ? 1.6 : 1.3, elite ? 3 : 2.5, elite ? 47 : 41], `T${tier}`);
assert.deepEqual(u.skill.triggerGrid, sk.rangeGrid, `T${tier}: the trigger grid is 3-3`);
h.run(0.6);
const atk0 = u.s.atk;
u.skill.gainSp(999);
// (9,8) / (11,8) are on 3-3, not on her 3-1: the cast comes with an enemy there
const hi = h.spawn('enemy_d300', { pos: [9, 8] });
const lo = h.spawn('enemy_d100', { pos: [11, 8] });
assert.ok(h.runUntil(() => u.skill.active, 2), `T${tier}: cast with enemies on 3-3 only`);
assert.deepEqual(u.liveRangeGrid, sk.rangeGrid, `T${tier}: 3-3 while on`);
approx(u.s.atk, atk0 + u.base.atk * sk.bb.atk, `T${tier}: ATK`);
const n0 = atkHits(h, u).length;
h.run(5);
const hits = atkHits(h, u).slice(n0);
assert.ok(hits.length >= 2 && hits.every((c) => c.target === lo && c.type === 'phys'), `T${tier}: physical, on the lowest DEF`);
approx(hits[0].amount, Math.max(u.s.atk - 100, u.s.atk * 0.05), `T${tier}: physical on DEF 100`);
const sil = h.hooksOf('statusApplied').filter((c) => c.source === u && c.status === 'silence');
assert.ok(sil.length >= hits.length && sil.every((c) => c.target === lo), `T${tier}: silenced on every hit`);
approx(sil[0].duration, sk.bb['attack@silence'], `T${tier}: ${sk.bb['attack@silence']} s`);
// 剥壳 stays arts: DEF 100 × 40 %
const shells = hitsBy(h, u).slice(n0).filter(shellOf);
assert.ok(shells.length >= hits.length - 1 && shells.every((c) => c.type === 'arts'), `T${tier}: 剥壳 arts`);
u.skill.end('test');
h.run(0.1);
assert.deepEqual(u.liveRangeGrid, formOf(tier, elite).rangeGrid, `T${tier}: back to 3-1`);
void hi;
done(h);
}
});
test('T1 剥壳: each hit of her attacks adds DEF × 40 % arts (none on DEF 0); CCR-X stage 3: 50 % +5 % per hit on the same target up to 75 %, back to 50 % on another; stage 1 keeps 40 %', () => {
for (const f of FORMS_ALL) {
const [tier, elite, mod] = f;
const { h, u } = field({ tier, elite, mod, skill: 1 });
const x3 = elite && tier === 6 && mod === CCRX;
const t0 = u.def.raw.talents.find((t) => t.index === 0);
assert.equal(t0.bb.atk_scale, x3 ? 0.5 : 0.4, `${label(f)}: the data`);
u.skill.charges = 0;
const a = h.spawn('enemy_d400', { pos: [10, 6] });
const n0 = hitsBy(h, u).length;
h.run(1.6 * 8 + 0.4);
const shells = hitsBy(h, u).slice(n0).filter((c) => shellOf(c) && c.target === a);
const plain = hitsBy(h, u).slice(n0).filter((c) => c.dmg.isAttack && c.target === a);
assert.ok(plain.length >= 7 && shells.length === plain.length, `${label(f)}: one 剥壳 per hit (${shells.length} / ${plain.length})`);
const want = x3 ? [0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.75] : Array(7).fill(0.4);
shells.slice(0, 7).forEach((c, i) => {
approx(c.amount, 400 * want[i], `${label(f)}: hit ${i + 1}`);
assert.deepEqual([c.type, !!c.dmg.isAttack], ['arts', false], `${label(f)}: a talent arts instance`);
});
// another target: back to the base ratio; a DEF-0 target takes no 剥壳
h.b.kill(a, null);
const b = h.spawn('enemy_d200', { pos: [10, 6] });
const n1 = hitsBy(h, u).length;
h.run(1.7);
const sb = hitsBy(h, u).slice(n1).filter((c) => shellOf(c) && c.target === b);
assert.ok(sb.length >= 1);
approx(sb[0].amount, 200 * (x3 ? 0.5 : 0.4), `${label(f)}: a new target — the base ratio`);
h.b.kill(b, null);
const z = h.spawn('enemy_dummy', { pos: [10, 6] });
const n2 = hitsBy(h, u).length;
h.run(1.7);
assert.ok(hitsBy(h, u).slice(n2).some((c) => c.target === z && c.dmg.isAttack), label(f));
assert.ok(!hitsBy(h, u).slice(n2).some((c) => c.target === z && shellOf(c)), `${label(f)}: no 剥壳 on DEF 0`);
done(h);
}
});
test('T2 独行长路: ATK +8 % / ASPD +8 while nobody else is on her x-5 (a device too), off with a neighbour; an enemy-like ally does not switch it off but, seen while it is off, keeps it off until it leaves; CCR-Y stage 3: +15 % / +15 decided once per deployment', () => {
const lone = (u) => u.findBuff('talent:cerber:lone');
for (const f of FORMS_ALL) {
const [tier, elite, mod] = f;
const y3 = elite && tier === 6 && mod === CCRY;
const { h, u } = field({ tier, elite, mod, skill: 1 });
h.step();
const v = y3 ? { atkPct: 0.15, aspd: 15 } : { atkPct: 0.08, aspd: 8 };
assert.deepEqual(lone(u)?.mods, v, `${label(f)}: alone`);
const dev = h.b.spawnDevice('trap_1105_accrate', 10, 6, { name: 'test crate' });
assert.ok(dev && dev.side === 'ally', label(f));
h.step();
assert.equal(!!lone(u), y3, `${label(f)}: a crate in front of her ${y3 ? '(the deployment decided)' : ''}`);
h.b.kill(dev, null);
h.step();
assert.deepEqual(lone(u)?.mods, v, `${label(f)}: alone again`);
if (!y3) {
// an enemy-like ally (炎佑's kind: an ally built from an enemy record): stays on while on …
const like = h.b.spawnDevice('trap_1105_accrate', 9, 5, { name: 'enemy-like' });
like.defId = 'enemy_9012_acloon';
h.step();
assert.ok(lone(u), `${label(f)}: an enemy-like ally does not switch it off`);
// … but seen while off (an ordinary neighbour came first) it keeps it off until it leaves the field
const mate = h.b.spawnDevice('trap_1105_accrate', 11, 5, { name: 'mate' });
h.step();
assert.equal(lone(u), null, `${label(f)}: off with an ordinary neighbour`);
h.b.kill(mate, null);
h.step();
assert.equal(lone(u), null, `${label(f)}: the enemy-like ally seen while off keeps it off`);
h.b.relocate(like, 12, 9);
h.step();
assert.equal(lone(u), null, `${label(f)}: even away from her`);
h.b.kill(like, null);
h.step();
assert.ok(lone(u), `${label(f)}: on once it left the field`);
}
done(h);
}
// CCR-Y stage 3 with a neighbour at the deployment: none for that deployment, then a lone redeploy gets it
const { h, u } = field({ tier: 6, elite: true, mod: CCRY, skill: 1, others: [{ uid: 2, chessId: 'chess_char_1_08_a', row: 11, col: 5 }] });
h.run(0.5);
assert.equal(lone(u), null, 'a neighbour at the battle-start deployment');
h.b.retreat(h.unit(2));
h.run(0.5);
assert.equal(lone(u), null, 'still none: decided at the deployment');
h.b.retreat(u);
h.b.redeploy(u);
h.step();
assert.deepEqual(lone(u)?.mods, { atkPct: 0.15, aspd: 15 }, 'a lone redeploy');
done(h);
const t1 = formOf(6, true).modules.find((m) => m.uniEquipId === CCRY).talentChanges.find((t) => t.talentIndex === 1);
assert.match(t1.desc, /^部署时若周围四格内没有其他友方单位/);
});
test('modules: CCR-X "无视目标10点法术抗性" at stages 1 and 3 (× 0.6 on RES 50); CCR-Y "普通攻击命中精英或领袖敌人时获得1点技力" — not on a normal enemy, not from 剥壳', () => {
for (const f of FORMS_ALL) {
const [tier, elite, mod] = f;
const { h, u } = field({ tier, elite, mod, skill: 2 });
const x = elite && mod === CCRX, y = elite && mod === CCRY;
assert.equal(u.s.resIgnoreFlat, x ? 10 : 0, `${label(f)}: RES ignore`);
if (y) assert.deepEqual(u.def.raw.trait.bb, { sp: 1 });
const foe = h.spawn('enemy_r50', { pos: [10, 6] });
const n0 = hitsBy(h, u).length;
h.run(3.5);
const hits = hitsBy(h, u).slice(n0).filter((c) => c.target === foe && c.dmg.isAttack);
assert.ok(hits.length >= 2, label(f));
approx(hits[0].amount, arts(u.s.atk, 50, x ? 10 : 0), `${label(f)}: arts on RES 50`);
const traitSp = () => h.hooksOf('spGain').filter((c) => c.unit === u && c.reason === 'trait').length;
assert.equal(traitSp(), 0, `${label(f)}: no SP from a normal enemy`);
h.b.kill(foe, null);
for (const key of ['enemy_elite', 'enemy_boss']) {
const el = h.spawn(key, { pos: [10, 6] });
const k0 = traitSp(), a0 = atkHits(h, u).filter((c) => c.target === el).length;
h.run(3.5);
const hitsE = atkHits(h, u).filter((c) => c.target === el).length - a0;
assert.ok(hitsE >= 2, label(f));
assert.equal(traitSp() - k0, y ? hitsE : 0, `${label(f)}: +1 SP per hit on an ${key}`);
h.b.kill(el, null);
}
done(h);
}
});
+362
View File
@@ -0,0 +1,362 @@
// test/content/op_heyak.test.js — the 自选 operator kit of 霍尔海雅 (char_4027_heyak, 6★ 中坚术师; kit
// server/sim/content/kits/ops/op-heyak.js), fielded the production way (a DIY slot + its `diy` pick, simdata getDiy) in
// every form: tiers 5 / 6, normal (E2 Lv1, skill rank 4, no module) and elite (E2 Lv60, rank 7) with no module, CCR-X
// “图书馆”, CCR-Y “羽蛇的时间博物馆” or ISW-A “霍尔海雅特限证章” at stage 1 (tier 5) / 3 (tier 6). Every number is read back from
// data/backups.json (the form of that slot status); the fidelity checklist of kits/README.md item by item.
// Run: node --test test/content/op_heyak.test.js
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { makeBattle, enemyRec, checkInvariants } from '../helpers/battleHarness.js';
import { KITTED_CHARS, OPERATOR_KITS, KITS } from '../../server/sim/content/kits/index.js';
import { diyPool, validateDiyPicks } from '../../shared/diy.js';
const load = (f) => JSON.parse(readFileSync(new URL(`../../data/${f}.json`, import.meta.url), 'utf8'));
const CHESS = load('chess');
const BACKUPS = load('backups');
const ID = 'char_4027_heyak';
const FORMS = BACKUPS.units[ID].forms;
const SLOT = { 5: 'chess_char_5_diy1_a', 6: 'chess_char_6_diy1_a' };
const CCRX = 'uniequip_002_heyak', CCRY = 'uniequip_003_heyak', ISWA = 'uniequip_004_heyak';
const S1 = 'skchr_heyak_1', S2 = 'skchr_heyak_2', S3 = 'skchr_heyak_3';
const formOf = (tier, elite) => FORMS[elite ? (tier === 5 ? '2/60/7/1' : '2/60/7/3') : '2/1/4/0'];
const skillOf = (tier, elite, id) => formOf(tier, elite).skills.find((s) => s.skillId === id);
const modOf = (tier, mod) => (mod ? formOf(tier, true).modules.find((m) => m.uniEquipId === mod) : null);
const approx = (a, b, msg, eps = 1e-6) => assert.ok(Math.abs(a - b) <= eps * Math.max(1, Math.abs(b)), `${msg}: ${a} vs ${b}`);
const dummy = (key, o = {}) => enemyRec({ key, hp: 1e9, speed: 0, mass: 0, ...o });
const ENEMIES = {
enemy_dummy: dummy('enemy_dummy'), enemy_fly: dummy('enemy_fly', { motion: 'FLY' }), enemy_heavy: dummy('enemy_heavy', { mass: 2 }),
enemy_r50: dummy('enemy_r50', { res: 50 }), enemy_elite: dummy('enemy_elite', { rank: 'ELITE' }), enemy_boss: dummy('enemy_boss', { rank: 'BOSS' }),
};
/** Every 自选 form: [tier, elite, module]. */
const FORMS_ALL = [[5, false, null], [6, false, null], ...[5, 6].flatMap((t) => [null, CCRX, CCRY, ISWA].map((m) => [t, true, m]))];
const label = ([tier, elite, mod]) => `T${tier} ${elite ? 'elite' : 'normal'} ${mod ?? 'none'}`;
/** A battle with 霍尔海雅 as uid 1 at (row, col) facing RIGHT, plus `others`. */
function field({ tier = 5, elite = false, mod = null, skill = 2, row = 10, col = 5, others = [], seed = 5, setup = null } = {}) {
const h = makeBattle({
defs: { enemies: ENEMIES }, timeLimit: 900, autoFinish: false, seed,
flags: { dpPerSec: 0, dpMax: 999 }, hooks: ['damaged', 'skillStart', 'skillEnd', 'statusApplied', 'spGain'], captureNoisy: true,
units: [{ uid: 1, diy: { slot: SLOT[tier], charId: ID, skillIndex: skill, uniEquipId: mod }, elite, row, col }, ...others],
setup,
});
h.step();
return { h, u: h.unit(1) };
}
const hitsBy = (h, u) => h.hooksOf('damaged').filter((c) => c.source === u);
const statusBy = (h, u, key) => h.hooksOf('statusApplied').filter((c) => c.source === u && c.status === key);
function done(h) {
checkInvariants(h.b);
assert.equal(h.b.errors.length, 0, JSON.stringify(h.b.errors[0]));
}
const arts = (amount, res, ignore = 0) => Math.max(amount * (1 - Math.max(0, res - ignore) / 100), amount * 0.05);
/** 传承终焉's numbers in a form: [atk_scale, silence]. */
const t0Of = (tier, elite, mod) => {
const t = (mod ? modOf(tier, mod).talentChanges.find((c) => c.talentIndex === 0) : null) ?? formOf(tier, elite).talents.find((c) => c.index === 0);
return [t.bb.atk_scale, t.bb.silence];
};
test('霍尔海雅 in every 自选 form: her operator kit (all three skills authored), the form\'s stats + module attributes, 3-1 range, ranged arts that hits air, block 1, 1.6 s, 空 bonds, no 特质', () => {
assert.equal(OPERATOR_KITS[ID], KITS[ID]);
for (const f of FORMS_ALL) {
const [tier, elite, mod] = f;
for (const skill of [0, 1, 2]) {
const { h, u } = field({ tier, elite, mod, skill });
const form = formOf(tier, elite), m = elite ? modOf(tier, mod) : null;
assert.deepEqual([u.def.charId, u.def.diyFor, u.skill.id, !!u.kit.generic, u.kit.skillSource], [ID, SLOT[tier], form.skills[skill].skillId, false, 'skills'], label(f));
assert.deepEqual([u.base.maxHp, u.base.atk, u.base.def, u.base.res], [form.stats.maxHp + (m?.attr.maxHp ?? 0), form.stats.atk + (m?.attr.atk ?? 0), form.stats.def + (m?.attr.def ?? 0), 20], `${label(f)}: stats`);
assert.deepEqual([u.s.blockCnt, u.profile.attack, u.profile.dmgType, u.profile.canHitFly, u.profile.groundOnly, u.base.bat], [1, 'ranged', 'arts', true, false, 1.6], `${label(f)}: 中坚术师`);
assert.deepEqual(u.liveRangeGrid, form.rangeGrid, `${label(f)}: 3-1`);
assert.deepEqual([u.def.bonds, u.def.raw.garrisonIds, u.def.raw.tokens], [['emptyShip'], [], []], `${label(f)}: bonds / 特质 / no summon`);
assert.ok(!u.s.flags.liftoff && !u.s.flags.camou && !u.s.flags.stealth && !u.s.flags.untargetable, `${label(f)}: ground enemies target her`);
done(h);
}
}
// E2 Lv1 1380 / 525 / 116, E2 Lv60 1639 / 597 / 125; CCR-X +120 / +40 → +175 / +65, CCR-Y +105 / +32 / +15 → +140 / +45 /
// +25, ISW-A +100 / +55 → +130 / +80
assert.deepEqual([FORMS['2/1/4/0'].stats.maxHp, FORMS['2/1/4/0'].stats.atk, FORMS['2/60/7/1'].stats.maxHp, FORMS['2/60/7/1'].stats.atk], [1380, 525, 1639, 597]);
assert.deepEqual([modOf(5, CCRX).attr, modOf(6, CCRX).attr, modOf(5, CCRY).attr, modOf(6, CCRY).attr, modOf(5, ISWA).attr, modOf(6, ISWA).attr],
[{ maxHp: 120, atk: 40 }, { maxHp: 175, atk: 65 }, { maxHp: 105, atk: 32, def: 15 }, { maxHp: 140, atk: 45, def: 25 }, { maxHp: 100, atk: 55 }, { maxHp: 130, atk: 80 }]);
});
test('a 自选 pick: 霍尔海雅 is offered at tiers 5 and 6 and a roster with her (ISW-A included) passes validateDiyPicks', () => {
const data = { chess: CHESS, backups: BACKUPS };
assert.ok(KITTED_CHARS.includes(ID));
for (const t of [5, 6]) assert.ok(diyPool(t, { data, kitted: KITTED_CHARS }).includes(ID), `tier ${t}`);
assert.deepEqual(validateDiyPicks({ [SLOT[6]]: { charId: ID, skillIndex: 2, uniEquipId: ISWA } }, { data, kitted: KITTED_CHARS }),
{ ok: true, picks: { [SLOT[6]]: { charId: ID, skillIndex: 2, uniEquipId: ISWA } } });
});
test('S1 但为求索 (AUTO, 1 / 2 charges, data DEFAULT): the next attack hits two enemies at 200 % / 240 % ATK arts; with one enemy only it lifts it 2.5 / 3 s — before 传承终焉, so that hit is × 1.2 and silences', () => {
for (const [tier, elite] of [[5, false], [6, true]]) {
const sk = skillOf(tier, elite, S1);
const [ts, sil] = t0Of(tier, elite, null);
assert.deepEqual([sk.skillType, sk.spCost, sk.maxChargeTime, sk.bb.atk_scale, sk.bb.levitate, ts, sil], ['AUTO', 8, elite ? 2 : 1, elite ? 2.4 : 2, elite ? 3 : 2.5, 1.2, 3], `T${tier}`);
// two enemies: two shots, no lift
{
const { h, u } = field({ tier, elite, skill: 0 });
assert.deepEqual([u.skill.rule, u.skill.kind, u.skill.maxCharges], ['DEFAULT', elite ? 'charges' : 'instant', elite ? 2 : 1], `T${tier}`);
u.skill.charges = 0;
u.skill.sp = 0;
const a = h.spawn('enemy_dummy', { pos: [10, 6] }), b = h.spawn('enemy_dummy', { pos: [11, 7] });
u.skill.gainSp(999);
const n0 = hitsBy(h, u).length;
assert.ok(h.runUntil(() => hitsBy(h, u).slice(n0).filter((c) => c.dmg.isSkill).length >= 2, 3), `T${tier}: cast`);
const sh = hitsBy(h, u).slice(n0).filter((c) => c.dmg.isSkill);
assert.deepEqual(new Set(sh.slice(0, 2).map((c) => c.target)), new Set([a, b]), `T${tier}: one more target`);
for (const c of sh.slice(0, 2)) approx(c.amount, u.s.atk * sk.bb.atk_scale, `T${tier}: ${sk.bb.atk_scale * 100} % ATK`);
assert.equal(statusBy(h, u, 'levitate').length, 0, `T${tier}: two shots — no lift`);
done(h);
}
// one enemy: lifted, and that hit already counts as one on an air unit
{
const { h, u } = field({ tier, elite, skill: 0 });
u.skill.charges = 0;
u.skill.sp = 0;
const a = h.spawn('enemy_dummy', { pos: [10, 6] });
u.skill.gainSp(999);
const n0 = hitsBy(h, u).length;
assert.ok(h.runUntil(() => hitsBy(h, u).slice(n0).some((c) => c.dmg.isSkill), 3), `T${tier}: cast`);
const sh = hitsBy(h, u).slice(n0).find((c) => c.dmg.isSkill);
assert.equal(sh.target, a);
approx(sh.amount, u.s.atk * sk.bb.atk_scale * ts, `T${tier}: × ${ts} (lifted first)`);
const lev = statusBy(h, u, 'levitate');
assert.equal(lev.length, 1, `T${tier}: lifted`);
approx(lev[0].duration, sk.bb.levitate, `T${tier}: 浮空 ${sk.bb.levitate} s`);
const sl = statusBy(h, u, 'silence');
assert.ok(sl.length >= 1 && sl[0].target === a, `T${tier}: silenced`);
approx(sl[0].duration, sil, `T${tier}: ${sil} s`);
done(h);
}
}
});
test('S2 群星逶迤 (MANUAL, data DEFAULT): 16 s, each attack 9 shots of 27 % / 35 % ATK at random enemies of her range, each rolling 10 % / 12 % to lift 1 s; a lifted or flying target takes × 1.2', () => {
for (const [tier, elite] of [[5, false], [6, true]]) {
const sk = skillOf(tier, elite, S2);
const sc = sk.bb['attack@atk_scale'], p = sk.bb['attack@prob'];
assert.deepEqual([sk.duration, sc, p, sk.bb['attack@levitate'], sk.spCost, sk.initSp], [16, elite ? 0.35 : 0.27, elite ? 0.12 : 0.1, 1, elite ? 32 : 36, elite ? 22 : 21], `T${tier}`);
assert.match(sk.desc, /9连发/);
const flying = [];
const setup = (b) => b.on('damaged', (c) => { if (c.source?.uid === 1) flying.push(c.target.isFlying); }, { priority: -100 });
const { h, u } = field({ tier, elite, skill: 1, seed: 21, setup });
assert.equal(u.skill.rule, 'DEFAULT');
let rolls = 0;
const chance = h.b.rng.chance;
h.b.rng.chance = (q) => { if (q === p) rolls++; return chance(q); };
const foes = [[10, 6], [9, 6], [11, 6], [10, 7], [9, 7], [11, 7]].map((pos) => h.spawn('enemy_dummy', { pos }));
const fly = h.spawn('enemy_fly', { pos: [10, 8] });
u.skill.gainSp(999);
assert.ok(h.runUntil(() => u.skill.active, 3), `T${tier}: cast`);
approx(u.skill.timeLeft, 16, `T${tier}: 16 s`, 0.05);
const n0 = hitsBy(h, u).length, f0 = flying.length;
assert.ok(h.runUntil(() => !u.skill.active, 17));
h.run(0.6);
const shots = hitsBy(h, u).slice(n0).filter((c) => c.dmg.isSkill);
const fl = flying.slice(f0, f0 + hitsBy(h, u).slice(n0).length);
const byAttack = new Map();
for (const c of shots) byAttack.set(c.dmg.attackId, [...(byAttack.get(c.dmg.attackId) ?? []), c.target]);
assert.ok(byAttack.size >= 9, `T${tier}: ${byAttack.size} attacks`);
for (const [, ts] of byAttack) assert.equal(ts.length, 9, `T${tier}: 9 shots per attack`);
for (const e of [...foes, fly]) assert.ok(shots.some((c) => c.target === e), `T${tier}: ${e.tileR},${e.tileC} drew shots (random)`);
assert.equal(rolls, shots.length, `T${tier}: one ${p * 100} % roll per shot`);
const lifts = statusBy(h, u, 'levitate');
assert.ok(lifts.length > 0.5 * p * shots.length && lifts.length <= 1.3 * p * shots.length, `T${tier}: ${lifts.length} lifts of ${shots.length} shots`);
assert.ok(lifts.every((c) => c.target !== fly && Math.abs(c.duration - 1) < 1e-9), `T${tier}: 1 s, never on a data flyer`);
const all = hitsBy(h, u).slice(n0);
all.forEach((c, i) => {
if (!c.dmg.isSkill) return;
approx(c.amount, u.s.atk * sc * (fl[i] ? 1.2 : 1), `T${tier}: shot ${i} (${fl[i] ? 'air' : 'ground'})`);
});
assert.ok(fl.filter(Boolean).length > shots.filter((c) => c.target === fly).length, `T${tier}: lifted ground enemies took × 1.2 too`);
done(h);
}
});
test('S3 博览者的狂语 (MANUAL, data ACTIVE_RANGE on 3-10): 45 s, interval 1.6 + 1.4 = 3.0 s, range 3-10 while on; each attack three whirlwinds (her row and the rows beside), 1 tile/s, each lifting the first enemy it touches then dealing 2.33→3.5 / 2.53→3.8 × ATK over 1.77 s (× 1.2: lifted)', () => {
for (const [tier, elite] of [[5, false], [6, true]]) {
const sk = skillOf(tier, elite, S3);
const lo = sk.bb['attack@min_atk_scale'], hi = sk.bb['attack@max_atk_scale'], lev = sk.bb['attack@levitate'];
assert.deepEqual([sk.rangeId, sk.duration, sk.bb.base_attack_time, lo, hi, lev, sk.spCost, sk.initSp], ['3-10', 45, 1.4, elite ? 2.53 : 2.33, elite ? 3.8 : 3.5, elite ? 2 : 1.8, elite ? 64 : 67, elite ? 42 : 41], `T${tier}`);
const { h, u } = field({ tier, elite, skill: 2 });
assert.deepEqual([u.skill.rule, u.skill.triggerGrid], ['ACTIVE_RANGE', sk.rangeGrid], `T${tier}: the trigger`);
h.run(0.6);
u.skill.gainSp(999);
// (10,9) is on 3-10 only: the cast comes with it; lanes: row 9 → (9,6) 1 tile ahead, row 10 → (10,8) before (10,9), row 11 → (11,9)
const far = h.spawn('enemy_dummy', { pos: [10, 9] });
assert.ok(h.runUntil(() => u.skill.active, 2), `T${tier}: cast with an enemy on 3-10 only`);
const near = h.spawn('enemy_dummy', { pos: [9, 6] }), mid = h.spawn('enemy_dummy', { pos: [10, 8] }), low = h.spawn('enemy_dummy', { pos: [11, 9] });
assert.deepEqual(u.liveRangeGrid, sk.rangeGrid, `T${tier}: 3-10 while on`);
approx(u.s.interval, 3, `T${tier}: 3.0 s`);
const n0 = hitsBy(h, u).length;
h.run(6.5);
const hits = hitsBy(h, u).slice(n0);
const first = (e) => hits.find((c) => c.target === e);
const scale = (age) => lo + (hi - lo) * Math.min(1, age / 1.77);
approx(first(near).amount, u.s.atk * scale(0.5) * 1.2, `T${tier}: 0.5 tile flown`, 1e-3);
approx(first(mid).amount, u.s.atk * hi * 1.2, `T${tier}: 2.5 tiles — the maximum`);
approx(first(low).amount, u.s.atk * hi * 1.2, `T${tier}: 3.5 tiles`);
assert.ok(!hits.some((c) => c.target === far), `T${tier}: (10,9) behind (10,8) in its lane is never reached`);
for (const c of hits) assert.deepEqual([c.type, c.dmg.isAttack, c.dmg.isSkill], ['arts', true, true]);
const lifts = statusBy(h, u, 'levitate');
assert.ok(lifts.length >= 3 && lifts.every((c) => Math.abs(c.duration - lev) < 1e-9), `T${tier}: 浮空 ${lev} s`);
assert.ok(statusBy(h, u, 'silence').length >= 3, `T${tier}: 传承终焉 silences the lifted`);
u.skill.end('test');
h.run(0.1);
assert.deepEqual(u.liveRangeGrid, formOf(tier, elite).rangeGrid, `T${tier}: back to 3-1`);
approx(u.s.interval, 1.6, `T${tier}: interval back`);
done(h);
}
});
test('S3 whirlwinds: they fly 5 tiles at most, a heavy (mass > 3) target is lifted half as long, and those out when she leaves fly on without 传承终焉 or her module\'s RES ignore', () => {
// 5 tiles: from her centre (col 4) a box reaches col 9.5 — (11,9) is struck 4.5 tiles out, (10,10) never
{
const { h, u } = field({ tier: 6, elite: true, skill: 2, col: 4 });
u.skill.gainSp(999);
const trig = h.spawn('enemy_dummy', { pos: [9, 8] });
const edge = h.spawn('enemy_dummy', { pos: [11, 9] }), beyond = h.spawn('enemy_dummy', { pos: [10, 10] });
assert.ok(h.runUntil(() => u.skill.active, 2));
h.run(7);
assert.ok(hitsBy(h, u).some((c) => c.target === trig && c.dmg.isSkill), 'the lane-9 whirlwind');
assert.ok(hitsBy(h, u).some((c) => c.target === edge && c.dmg.isSkill), 'struck 4.5 tiles out');
assert.ok(!hitsBy(h, u).some((c) => c.target === beyond), '6 tiles out: the whirlwind is gone');
done(h);
}
// her module leaves with her (CCR-X stage 3 on RES 50): a whirlwind out when she retreats hits × 1 without the RES ignore
{
const { h, u } = field({ tier: 6, elite: true, mod: CCRX, skill: 2 });
u.skill.gainSp(999);
const e = h.spawn('enemy_r50', { pos: [10, 9] });
assert.ok(h.runUntil(() => u.skill.active, 2));
assert.ok(h.runUntil(() => u.mem.heyakWinds.length > 0, 5), 'whirlwinds out');
h.run(0.5);
const atk = u.s.atk;
h.b.retreat(u);
const s0 = statusBy(h, u, 'silence').length;
assert.ok(h.runUntil(() => hitsBy(h, u).some((c) => c.target === e), 6), 'the whirlwind flies on');
const c = hitsBy(h, u).find((x) => x.target === e);
approx(c.amount, arts(atk * 3.8, 50, 0), 'no 传承终焉 (× 1.2) and no RES ignore');
assert.equal(statusBy(h, u, 'silence').length, s0, 'no silence');
assert.equal(statusBy(h, u, 'levitate').filter((x) => x.target === e).length, 1, 'still lifted');
done(h);
}
// a mass-4 target: 浮空 halved (2 s → 1 s at rank 7); 曾有羽翼's 失重 lowers it to 3 while above 80 % HP
{
const { h, u } = field({ tier: 6, elite: true, skill: 2 });
u.skill.gainSp(999);
const heavy = h.spawn('enemy_heavy', { pos: [10, 9] });
heavy.base.massLevel = 4;
heavy.markDirty();
heavy.hp = heavy.s.maxHp * 0.7; // below 80 %: no 失重
assert.ok(h.runUntil(() => u.skill.active, 2));
assert.ok(h.runUntil(() => statusBy(h, u, 'levitate').length > 0, 8));
approx(statusBy(h, u, 'levitate')[0].duration, 1, 'mass 4: half of 2 s');
done(h);
}
});
test('T1 传承终焉: hits on air units × 1.2 and silence 3 s (CCR-X stage 3: × 1.35 / 5 s, ISW-A stage 3: × 1.45 / 5 s; stage 1 modules keep 1.2 / 3); ground targets: neither', () => {
for (const f of FORMS_ALL) {
const [tier, elite, mod] = f;
const [ts, sil] = t0Of(tier, elite, elite ? mod : null);
const want = elite && tier === 6 && mod === CCRX ? [1.35, 5] : elite && tier === 6 && mod === ISWA ? [1.45, 5] : [1.2, 3];
assert.deepEqual([ts, sil], want, `${label(f)}: the data`);
const { h, u } = field({ tier, elite, mod, skill: 2 });
const fly = h.spawn('enemy_fly', { pos: [10, 6] });
const n0 = hitsBy(h, u).length;
h.run(1.7);
const c = hitsBy(h, u).slice(n0).find((x) => x.target === fly && x.dmg.isAttack);
assert.ok(c, label(f));
approx(c.amount, u.s.atk * ts, `${label(f)}: × ${ts} on a flyer`);
const sl = statusBy(h, u, 'silence').find((x) => x.target === fly);
assert.ok(sl, `${label(f)}: silenced`);
approx(sl.duration, sil, `${label(f)}: ${sil} s`);
h.b.kill(fly, null);
const g = h.spawn('enemy_dummy', { pos: [10, 6] });
const n1 = hitsBy(h, u).length, s1 = statusBy(h, u, 'silence').length;
h.run(1.7);
const cg = hitsBy(h, u).slice(n1).find((x) => x.target === g && x.dmg.isAttack);
approx(cg.amount, u.s.atk, `${label(f)}: × 1 on the ground`);
assert.equal(statusBy(h, u, 'silence').length, s1, `${label(f)}: no silence on the ground`);
done(h);
}
});
test('T2 曾有羽翼: 失重 (weight −1) on every enemy of her range above 80 % HP, gone below it or out of range, never on top of another 失重; CCR-Y stage 3: above 50 %, and 20 % 【法术脆弱】 below 50 %', () => {
for (const f of FORMS_ALL) {
const [tier, elite, mod] = f;
const y3 = elite && tier === 6 && mod === CCRY;
const thr = y3 ? 0.5 : 0.8;
const { h, u } = field({ tier, elite, mod, skill: 1 });
const inR = h.spawn('enemy_heavy', { pos: [10, 6] }), out = h.spawn('enemy_heavy', { pos: [10, 10] });
h.step(2);
assert.ok(inR.findBuff('heyak:weightless'), `${label(f)}: full HP in range`);
assert.equal(inR.weight, 1, `${label(f)}: mass 2 → 1`);
assert.equal(out.findBuff('heyak:weightless'), null, `${label(f)}: out of range`);
inR.hp = inR.s.maxHp * (thr + 0.01);
h.step();
assert.ok(inR.findBuff('heyak:weightless'), `${label(f)}: above ${thr * 100} %`);
inR.hp = inR.s.maxHp * (thr - 0.01);
h.step();
assert.equal(inR.findBuff('heyak:weightless'), null, `${label(f)}: below ${thr * 100} %`);
assert.equal(inR.weight, 2, `${label(f)}: mass back`);
inR.hp = inR.s.maxHp * 0.3;
h.run(0.5);
const fr = h.hooksOf('statusApplied').filter((c) => c.source === u && c.status === 'artsFragile' && c.target === inR);
assert.equal(fr.length > 0, y3, `${label(f)}: 【法术脆弱】 below 50 %`);
if (y3) { assert.equal(fr[0].value, 0.2); approx(inR.s.artsTakenMul, 1.2, `${label(f)}: arts taken × 1.2`); }
// another source's 失重 (安洁莉娜's key): not doubled
inR.hp = inR.s.maxHp;
h.b.addBuff(inR, { key: 'aglina:weightless', status: 'weightless', duration: 1, mods: { massFlat: -1 } });
h.step();
assert.equal(inR.findBuff('heyak:weightless'), null, `${label(f)}: 同名效果不可叠加`);
assert.equal(inR.weight, 1);
h.run(1.1);
assert.ok(inR.findBuff('heyak:weightless'), `${label(f)}: hers again once the other ended`);
h.b.retreat(u);
h.step();
assert.equal(inR.findBuff('heyak:weightless'), null, `${label(f)}: gone when she leaves`);
done(h);
}
const hp = formOf(6, true).modules.find((m) => m.uniEquipId === CCRY).talentChanges;
assert.deepEqual([hp.find((t) => t.talentIndex === 1).bb, hp.find((t) => t.talentIndex === -1).bb], [{ hp_ratio: 0.5 }, { damage_scale: 1.2, hp_ratio: 0.5 }]);
});
test('modules: CCR-X "无视目标10点法术抗性" (stages 1 and 3); CCR-Y "普通攻击命中精英或领袖敌人时获得1点技力"; ISW-A (集成战略 only): no RES ignore, no SP, no goal-tile 浮空, no radius-1.1 skill splash — its stats and 传承终焉 numbers only', () => {
for (const f of FORMS_ALL) {
const [tier, elite, mod] = f;
const { h, u } = field({ tier, elite, mod, skill: 2 });
const x = elite && mod === CCRX, y = elite && mod === CCRY, w = elite && mod === ISWA;
assert.equal(u.s.resIgnoreFlat, x ? 10 : 0, `${label(f)}: RES ignore`);
if (w) assert.match(u.def.raw.trait.moduleDesc, /^在集成战略中/, `${label(f)}: the ISW trait text`);
const foe = h.spawn('enemy_r50', { pos: [10, 6] });
const n0 = hitsBy(h, u).length;
h.run(3.5);
const hits = hitsBy(h, u).slice(n0).filter((c) => c.target === foe && c.dmg.isAttack);
assert.ok(hits.length >= 2, label(f));
approx(hits[0].amount, arts(u.s.atk, 50, x ? 10 : 0), `${label(f)}: arts on RES 50`);
const traitSp = () => h.hooksOf('spGain').filter((c) => c.unit === u && c.reason === 'trait').length;
assert.equal(traitSp(), 0, `${label(f)}: no SP from a normal enemy`);
h.b.kill(foe, null);
const el = h.spawn('enemy_elite', { pos: [10, 6] });
const k0 = traitSp(), a0 = hitsBy(h, u).filter((c) => c.target === el && c.dmg.isAttack).length;
h.run(3.5);
const hitsE = hitsBy(h, u).filter((c) => c.target === el && c.dmg.isAttack).length - a0;
assert.equal(traitSp() - k0, y ? hitsE : 0, `${label(f)}: +1 SP per hit on an elite`);
done(h);
}
// ISW-A stage 3: a whirlwind strikes its target only (the 1.1 splash is 集成战略-only)
const { h, u } = field({ tier: 6, elite: true, mod: ISWA, skill: 2 });
u.skill.gainSp(999);
const t = h.spawn('enemy_dummy', { pos: [10, 9] });
const side = h.spawn('enemy_dummy', { pos: [10, 9] });
side.x = 9.6; side.y = 9.7; // 0.67 from it, behind it in lane 10 (whose whirlwind is spent on it), outside lane 9
assert.ok(h.runUntil(() => u.skill.active, 2));
h.run(8);
assert.ok(hitsBy(h, u).some((c) => c.target === t), 'the target');
assert.ok(!hitsBy(h, u).some((c) => c.target === side), 'nothing beside it');
assert.ok(!statusBy(h, u, 'levitate').some((c) => c.target === side), 'no splash 浮空');
done(h);
});