feedback5: merge O13 — 自选 kits for 假日威龙陈, 莱伊 (with her 沙地兽) and 阿斯卡纶; golden: only diy moved

This commit is contained in:
sganggs committed 2026-10-06 01:48:44 +08:00
commit 9602fd5425
8 files changed
+2282 -102

No files matched your search

+311
View File
@@ -0,0 +1,311 @@
// test/content/op_ascln.test.js — the 自选 operator kit of 阿斯卡纶 (char_4132_ascln, 6★ 伏击客; kit
// server/sim/content/kits/ops/op-ascln.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, AMB-X
// “无形,无情” or AMB-Y “阿斯卡纶的眼睛” at stage 1 (tier 5) / 3 (tier 6). Numbers from data/backups.json; the fidelity
// checklist of kits/README.md.
// Run: node --test test/content/op_ascln.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';
import { dreadKey, DREAD_TAG } from '../../server/sim/content/kits/ops/op-ascln.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 ASC = 'char_4132_ascln';
const FORMS = BACKUPS.units[ASC].forms;
const SLOT = { 5: 'chess_char_5_diy1_a', 6: 'chess_char_6_diy1_a' };
const AX = 'uniequip_002_ascln', AY = 'uniequip_003_ascln';
const S1 = 'skchr_ascln_1', S2 = 'skchr_ascln_2', S3 = 'skchr_ascln_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_weak: dummy('enemy_weak', { hp: 10 }),
enemy_hitter: dummy('enemy_hitter', { atk: 200, range: 1.5, bat: 0.5 }),
enemy_walkslow: enemyRec({ key: 'enemy_walkslow', hp: 1e9, speed: 1, mass: 0 }),
};
const FORMS_ALL = [[5, false, null], [6, false, null], ...[5, 6].flatMap((t) => [null, AX, AY].map((m) => [t, true, m]))];
const label = ([tier, elite, mod]) => `T${tier} ${elite ? 'elite' : 'normal'} ${mod ?? 'none'}`;
/** 阿斯卡纶 as uid 1 at (row, col) facing RIGHT, plus `others`. */
function field({ tier = 5, elite = false, mod = null, skill = 0, row = 10, col = 5, others = [], seed = 5 } = {}) {
const h = makeBattle({
defs: { enemies: ENEMIES }, timeLimit: 900, autoFinish: false, seed,
flags: { dpPerSec: 0, dpMax: 999 }, hooks: ['damaged', 'skillStart', 'skillEnd', 'statusApplied', 'death', 'attack', 'heal', 'dodge'], captureNoisy: true,
units: [{ uid: 1, diy: { slot: SLOT[tier], charId: ASC, skillIndex: skill, uniEquipId: mod }, elite, row, col }, ...others],
});
h.step();
return { h, u: h.unit(1) };
}
const atkHits = (h, u) => h.hooksOf('damaged').filter((c) => c.source === u && c.dmg?.isAttack);
function done(h) {
checkInvariants(h.b);
assert.equal(h.b.errors.length, 0, JSON.stringify(h.b.errors[0]));
}
/** Keep her from casting (no SP). */
function noSkill(h, u) {
u.skill.charges = 0; u.skill.sp = 0;
h.b.addBuff(u, { key: 'test:noSp', flags: { noSp: true } });
}
test('阿斯卡纶 in every 自选 form: her kit (all three skills authored), the form\'s stats + module attributes, y-1, 伏击客 (melee, every enemy in range, ground only, 50 % / AMB-Y 65 % dodge, taunt level −1 — not −2), blocks 0, the data triggers; offered as a pick', () => {
assert.equal(OPERATOR_KITS[ASC], KITS[ASC]);
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], [ASC, 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), 30], `${label(f)}: stats`);
assert.deepEqual([u.s.blockCnt, u.profile.attack, u.profile.canHitFly, u.profile.dmgType, u.profile.allInRange, u.profile.sub, u.base.bat],
[0, 'melee', false, 'phys', true, 'stalker', 3.5], `${label(f)}: 伏击客`);
const p = mod === AY ? 0.65 : 0.5;
assert.deepEqual([u.s.dodgePhys, u.s.dodgeArts, u.s.taunt], [p, p, -1], `${label(f)}: dodge, taunt −1`);
assert.deepEqual(u.liveRangeGrid, form.rangeGrid, `${label(f)}: y-1`);
assert.equal(u.skill.rule, form.skills[skill].trigger.rule, `${label(f)}: the data's trigger`);
assert.ok(!u.s.flags.liftoff && !u.s.flags.camou && !u.s.flags.stealth && !u.s.flags.untargetable, `${label(f)}: ground enemies can target her`);
done(h);
}
}
assert.deepEqual(formOf(6, true).skills.map((s) => s.trigger.rule), ['DEFAULT', 'DEFAULT', 'ACTIVE_RANGE']);
assert.deepEqual([modOf(5, AX).attr, modOf(6, AX).attr, modOf(5, AY).attr, modOf(6, AY).attr],
[{ maxHp: 180, atk: 15 }, { maxHp: 270, atk: 53 }, { atk: 55, def: 25 }, { atk: 80, def: 60 }]);
const data = { chess: CHESS, backups: BACKUPS };
assert.ok(KITTED_CHARS.includes(ASC) && [5, 6].every((t) => diyPool(t, { data, kitted: KITTED_CHARS }).includes(ASC)));
assert.equal(validateDiyPicks({ [SLOT[6]]: { charId: ASC, skillIndex: 2, uniEquipId: AX } }, { data, kitted: KITTED_CHARS }).ok, true);
});
test('trait 伏击客: one attack strikes every ground enemy of her y-1 at once (physical), never a flyer; her dodge lets 50 % (AMB-Y 65 %) of the enemy hits through as dodges', () => {
for (const [tier, elite, mod] of [[5, false, null], [6, true, AY]]) {
const { h, u } = field({ tier, elite, mod, skill: 1 });
noSkill(h, u);
const a = h.spawn('enemy_dummy', { pos: [10, 6] }), b = h.spawn('enemy_dummy', { pos: [11, 4] }), c = h.spawn('enemy_dummy', { pos: [10, 7] });
const fly = h.spawn('enemy_fly', { pos: [9, 5] });
assert.ok(h.runUntil(() => atkHits(h, u).length >= 3, 6));
const id = atkHits(h, u)[0].dmg.attackId;
const hit = atkHits(h, u).filter((x) => x.dmg.attackId === id);
assert.deepEqual(new Set(hit.map((x) => x.target)), new Set([a, b, c]), `T${tier}: every ground enemy of y-1 ([0,2] included)`);
for (const x of hit) assert.equal(x.type, 'phys');
assert.ok(!atkHits(h, u).some((x) => x.target === fly), 'never the flyer');
// her dodge
const hitter = h.spawn('enemy_hitter', { pos: [10, 6] });
h.b.addBuff(u, { key: 'test:inv', mods: { defFlat: 1e6 } });
h.run(200);
const dodged = h.hooksOf('dodge').filter((x) => x.target === u && x.source === hitter).length;
const landed = h.hooksOf('damaged').filter((x) => x.target === u && x.source === hitter).length;
const r = dodged / (dodged + landed);
assert.ok(dodged + landed > 200 && Math.abs(r - (mod === AY ? 0.65 : 0.5)) < 0.06, `T${tier}: dodge rate ${r}`);
done(h);
}
});
test('T1 死亡拘审: every hit of her attacks adds a layer (≤ 3, the duration reset): move ×(1 − 0.18 × layers), layers × 10 % of her current ATK as arts every second (法术持续伤害: not dodgeable) for 25 s; AMB-X stage 3: 11 %, 30 s; all of it ends the moment she leaves', () => {
for (const [tier, elite, mod] of [[5, false, null], [5, true, AX], [6, true, AX], [6, true, AY]]) {
const x3 = tier === 6 && mod === AX;
const tb = (elite ? formOf(tier, true) : formOf(tier, elite)).talents.find((t) => t.index === 0).bb;
const [ratio, dur] = x3 ? [0.11, 30] : [0.1, 25];
if (!x3) assert.deepEqual(tb, { move_speed: -0.18, atk_ratio: 0.1, max_stack_cnt: 3, debuff_duration: 25, interval: 1 });
else assert.deepEqual(modOf(6, AX).talentChanges.find((t) => t.talentIndex === 0).bb, { move_speed: -0.18, atk_ratio: 0.11, max_stack_cnt: 3, debuff_duration: 30, interval: 1 });
const { h, u } = field({ tier, elite, mod, skill: 1 });
noSkill(h, u);
const e = h.spawn('enemy_dummy', { pos: [10, 6] });
h.b.addBuff(e, { key: 'test:dodge', mods: { dodgePhys: 1, dodgeArts: 1 } });
const key = dreadKey(u);
// a dodged attack lands nothing and adds nothing
h.run(4);
assert.equal(e.findBuff(key), null, `${label([tier, elite, mod])}: dodged hits add no layer`);
h.b.removeBuff(e, 'test:dodge');
const n0 = atkHits(h, u).length;
assert.ok(h.runUntil(() => atkHits(h, u).length > n0, 5));
let b = e.findBuff(key);
assert.deepEqual([b.data.n, b.duration], [1, dur], 'one layer');
approx(b.mods.moveMul, 0.82, 'move ×0.82');
// its ticks: 10 % × layers of her current ATK, arts, not dodgeable
const ticks = () => h.hooksOf('damaged').filter((c) => c.source === u && c.dmg.tags?.includes(DREAD_TAG));
h.run(1.05);
const t1 = ticks();
assert.ok(t1.length >= 1, 'a tick');
approx(t1[0].amount, u.s.atk * ratio * 1, `${label([tier, elite, mod])}: ${ratio * 100} % ATK × 1`);
assert.deepEqual([t1[0].type, t1[0].dmg.canDodge, t1[0].dmg.isAttack], ['arts', false, false]);
assert.ok(h.runUntil(() => e.findBuff(key)?.data.n === 3, 15), 'three layers');
b = e.findBuff(key);
approx(b.mods.moveMul, 1 - 0.18 * 3, 'move ×0.46');
h.run(5);
assert.equal(e.findBuff(key).data.n, 3, '≤ 3 layers');
const last = ticks().slice(-1)[0];
approx(last.amount, u.s.atk * ratio * 3, 'three layers tick ×3');
approx(e.findBuff(key).timeLeft, dur, 'reset on each hit', 0.15);
// no more hits: it runs out after its duration
h.b.addBuff(u, { key: 'test:disarm', flags: { disarm: true } });
const tLast = atkHits(h, u).filter((c) => c.target === e).slice(-1)[0].t;
h.run(tLast + dur - 0.3 - h.b.time);
assert.ok(e.findBuff(key), 'still there');
h.run(0.6);
assert.equal(e.findBuff(key), null, `gone ${dur} s after the last hit`);
// she leaves: every layer of hers ends at once
h.b.removeBuff(u, 'test:disarm');
h.runUntil(() => e.findBuff(key), 5);
h.b.retreat(u);
assert.equal(e.findBuff(key), null, 'ends the moment she leaves');
done(h);
}
});
test('T2 噬光残影: ASPD +8; +6 more with 高台 (HIGHLAND) among the four tiles next to her — the ranged wall on her left, the forbidden rim below', () => {
for (const [row, col, high] of [[10, 5, false], [10, 3, true], [12, 6, true], [11, 5, false]]) {
const { h, u } = field({ tier: 6, elite: true, skill: 1, row, col });
approx(u.s.aspd, 100 + 8 + (high ? 6 : 0), `(${row},${col}): ASPD`);
approx(u.s.interval, 3.5 * 100 / u.s.aspd, 'interval');
done(h);
}
assert.deepEqual(FORMS['2/1/4/0'].talents.find((t) => t.index === 1).bb, { attack_speed: 8, attack_speed_add: 6, cnt: 1 });
});
test('S1 追袭 (AUTO, 2 / 3 charges, data DEFAULT): the next attack strikes every enemy of her range twice at 130 % / 170 % ATK — two 死亡拘审 layers', () => {
for (const [tier, elite] of [[5, false], [6, true]]) {
const sk = skillOf(tier, elite, S1);
assert.deepEqual([sk.spCost, sk.initSp, sk.maxChargeTime, sk.bb.atk_scale, sk.skillType], elite ? [8, 4, 3, 1.7, 'AUTO'] : [10, 2, 2, 1.3, 'AUTO'], `T${tier}`);
const { h, u } = field({ tier, elite, skill: 0 });
assert.deepEqual([u.skill.kind, u.skill.rule, u.skill.maxCharges], ['charges', 'DEFAULT', elite ? 3 : 2]);
const a = h.spawn('enemy_dummy', { pos: [10, 6] }), b = h.spawn('enemy_dummy', { pos: [11, 5] });
u.skill.gainSp(999);
assert.ok(h.runUntil(() => u.skill.activations === 1, 3), `T${tier}: cast on her next attack`);
h.step();
const hits = atkHits(h, u).filter((c) => c.dmg.isSkill);
assert.equal(hits.length, 4, `T${tier}: 2 enemies × 2 strikes`);
for (const c of hits) approx(c.amount, u.s.atk * sk.bb.atk_scale, `T${tier}: ×${sk.bb.atk_scale}`);
assert.deepEqual([a.findBuff(dreadKey(u)).data.n, b.findBuff(dreadKey(u)).data.n], [2, 2], `T${tier}: two layers each`);
assert.equal(u.skill.charges, u.skill.maxCharges - 1, 'one charge spent');
done(h);
}
});
test('S2 恩赐 (MANUAL, 35 s, data DEFAULT): ATK +50 % / +90 %; every enemy of her range — air units too (PRTS 修正) — moves ×0.7 / ×0.6; a ground enemy of her range knocked out gives one 死亡拘审 layer to the ground enemies within 1.3 of it (not flyers, not beyond)', () => {
for (const [tier, elite] of [[5, false], [6, true]]) {
const sk = skillOf(tier, elite, S2);
assert.deepEqual([sk.duration, sk.spCost, sk.initSp, sk.bb.atk, sk.bb.move_speed, sk.bb.range_radius], [35, elite ? 24 : 27, elite ? 10 : 5, elite ? 0.9 : 0.5, elite ? -0.4 : -0.3, 1.3], `T${tier}`);
const { h, u } = field({ tier, elite, skill: 1 });
assert.deepEqual([u.skill.kind, u.skill.rule], ['duration', 'DEFAULT']);
const weak = h.spawn('enemy_weak', { pos: [10, 6] });
h.b.addBuff(weak, { key: 'test:dodge', mods: { dodgePhys: 1 } });
const near = h.spawn('enemy_dummy', { pos: [11, 6] }); // 1 tile from it, in her range too
const fly = h.spawn('enemy_fly', { pos: [10, 7] }); // in her range (air), 1 tile from it
const out = h.spawn('enemy_dummy', { pos: [9, 8] }); // outside her range, √5 from it
h.b.addBuff(near, { key: 'test:dodge', mods: { dodgePhys: 1 } });
u.skill.gainSp(999);
assert.ok(h.runUntil(() => u.skill.active, 5), `T${tier}: cast`);
approx(u.skill.timeLeft, 35, '35 s', 0.01);
approx(u.s.atk, u.base.atk * (1 + sk.bb.atk), `T${tier}: ATK`);
h.run(0.3);
for (const e of [weak, near, fly]) approx(e.findBuff('ascln:s2slow')?.mods.moveMul ?? 1, 1 + sk.bb.move_speed, `T${tier}: ${e.defId} slowed`);
assert.equal(out.findBuff('ascln:s2slow'), null, 'not outside her range');
// the knock-out: one layer on the ground enemy next to it; the flyer and the far one get none
h.b.removeBuff(weak, 'test:dodge');
assert.ok(h.runUntil(() => !weak.alive, 10), 'knocked out');
assert.equal(near.findBuff(dreadKey(u))?.data.n, 1, `T${tier}: a layer on the ground enemy within 1.3`);
assert.equal(fly.findBuff(dreadKey(u)), null, 'never a flyer');
assert.equal(out.findBuff(dreadKey(u)), null, 'not beyond 1.3');
u.skill.extend(-999);
h.step(2);
h.run(0.5);
assert.equal(near.findBuff('ascln:s2slow'), null, `T${tier}: the slow ends with the skill`);
done(h);
}
});
test('S3 降临 (MANUAL, 45 s, data ACTIVE_RANGE on y-10): an enemy only on y-10 casts it; range y-10; ATK +20 %, interval 3.5 − 1.2 / 1.5 s, taunt level −1 → +1; ground enemies of her range miss 15 % / 30 % of their attacks (one roll per attack), and a miss on her or a dodge of hers heals 4 % / 5 % of her max HP', () => {
for (const [tier, elite] of [[5, false], [6, true]]) {
const sk = skillOf(tier, elite, S3);
assert.deepEqual([sk.duration, sk.spCost, sk.initSp, sk.bb.atk, sk.bb.base_attack_time, sk.bb.taunt_level, sk.bb['attack@hp_ratio'], sk.bb['attack@damage_hitrate_physical'], sk.rangeId],
[45, elite ? 49 : 53, elite ? 30 : 25, 0.2, elite ? -1.5 : -1.2, 2, elite ? 0.05 : 0.04, elite ? -0.3 : -0.15, 'y-10'], `T${tier}`);
const { h, u } = field({ tier, elite, skill: 2 });
assert.deepEqual([u.skill.kind, u.skill.rule], ['duration', 'ACTIVE_RANGE']);
u.skill.gainSp(999);
const far = h.spawn('enemy_dummy', { pos: [12, 5] }); // [2,0]: in y-10, not in y-1
assert.ok(h.runUntil(() => u.skill.active, 1), `T${tier}: cast for [2,0]`);
assert.deepEqual(u.liveRangeGrid, sk.rangeGrid, `T${tier}: y-10 while it runs`);
approx(u.s.atk, u.base.atk * 1.2, 'ATK +20 %');
approx(u.s.interval, (3.5 + sk.bb.base_attack_time) * 100 / u.s.aspd, 'interval');
assert.equal(u.s.taunt, 1, 'taunt level +1');
h.b.kill(far, null);
// a ground hitter in her range: count its attacks before and after the 命中率 roll
const hitter = h.spawn('enemy_hitter', { pos: [10, 6] });
h.b.addBuff(hitter, { key: 'test:dodge', mods: { dodgePhys: 1 } }); // she never kills it
const seen = new Set(), passed = new Set();
h.b.on('hit', (c) => { if (c.source === hitter && c.dmg.isAttack) seen.add(c.dmg.attackId); }, { priority: 295 });
h.b.on('hit', (c) => { if (c.source === hitter && c.dmg.isAttack && !c.dmg.cancel) passed.add(c.dmg.attackId); }, { priority: 280 });
h.b.on('fatal', (c) => { if (c.unit === u) c.prevented = true; });
h.b.addBuff(u, { key: 'test:tough', mods: { defFlat: 1e6 } });
const heals0 = h.hooksOf('heal').filter((c) => c.target === u).length;
u.skill.extend(400);
h.run(300);
const r = 1 - passed.size / seen.size;
assert.ok(seen.size > 400 && Math.abs(r - Math.abs(sk.bb['attack@damage_hitrate_physical'])) < 0.05, `T${tier}: miss rate ${r} (${seen.size} attacks)`);
const dodges = h.hooksOf('dodge').filter((c) => c.target === u && c.source === hitter).length;
const heals = h.hooksOf('heal').filter((c) => c.target === u).length - heals0;
assert.equal(heals, (seen.size - passed.size) + dodges, `T${tier}: a heal per miss on her and per dodge`);
approx(h.hooksOf('heal').filter((c) => c.target === u).slice(-1)[0].amount, u.s.maxHp * sk.bb['attack@hp_ratio'], `T${tier}: ${sk.bb['attack@hp_ratio'] * 100} % max HP`, 1e-3);
u.skill.extend(-999);
h.step(2);
assert.deepEqual([u.s.taunt, u.liveRangeGrid], [-1, formOf(tier, elite).rangeGrid], `T${tier}: back`);
done(h);
}
});
test('AMB-X “无形,无情”: every enemy of her range (air too) moves ×0.8 (stages 1 and 3) — two 阿斯卡纶 with it: ×0.64 (PRTS: they stack); none without it', () => {
for (const f of FORMS_ALL) {
const [tier, elite, mod] = f;
const { h, u } = field({ tier, elite, mod, skill: 1 });
noSkill(h, u);
const e = h.spawn('enemy_dummy', { pos: [10, 6] }), fly = h.spawn('enemy_fly', { pos: [9, 5] });
h.b.addBuff(e, { key: 'test:dodge', mods: { dodgePhys: 1 } });
h.run(0.6);
const x = elite && mod === AX;
if (x) assert.deepEqual(formOf(tier, true).modules.find((m) => m.uniEquipId === AX).talentChanges.find((t) => t.talentIndex === -1).bb, { move_speed: -0.2 });
for (const t of [e, fly]) approx(t.findBuff(`ascln:ambx#${u.id}`)?.mods.moveMul ?? 1, x ? 0.8 : 1, `${label(f)}: ${t.defId}`);
done(h);
}
const h = makeBattle({
defs: { enemies: ENEMIES }, timeLimit: 60, autoFinish: false, seed: 3, flags: { dpPerSec: 0 },
units: [{ uid: 1, diy: { slot: 5, charId: ASC, skillIndex: 1, uniEquipId: AX }, elite: true, row: 10, col: 5 },
{ uid: 2, diy: { slot: 6, charId: ASC, skillIndex: 1, uniEquipId: AX }, elite: true, row: 11, col: 5 }],
});
h.step();
const e = h.spawn('enemy_walkslow', { pos: [10, 6] });
h.b.addBuff(e, { key: 'test:dodge', mods: { dodgePhys: 1 } });
h.run(0.5);
approx(e.s.moveSpeed, e.base.moveSpeed * 0.8 * 0.8, 'two AMB-X slows multiply');
done(h);
});
test('AMB-Y “阿斯卡纶的眼睛”: 65 % dodge (stages 1 and 3); stage 3 adds "拥有该效果的敌人被击倒时阿斯卡纶回复10%生命" — a heal of 10 % of her max HP whoever knocks out an enemy carrying her 死亡拘审', () => {
for (const [tier, elite, mod] of [[5, true, AY], [6, true, AY], [6, true, AX], [6, false, null]]) {
const y3 = tier === 6 && mod === AY;
const { h, u } = field({ tier, elite, mod, skill: 1 });
noSkill(h, u);
if (y3) assert.equal(modOf(6, AY).talentChanges.find((t) => t.talentIndex === 0).bb.hp_ratio, 0.1);
const e = h.spawn('enemy_dummy', { pos: [10, 6] });
assert.ok(h.runUntil(() => e.findBuff(dreadKey(u)), 6), 'marked');
u.hp = 100;
const h0 = h.hooksOf('heal').filter((c) => c.target === u).length;
h.b.kill(e, null); // knocked out by anybody
const heals = h.hooksOf('heal').filter((c) => c.target === u).slice(h0);
if (y3) {
assert.equal(heals.length, 1, 'one heal');
approx(heals[0].amount, u.s.maxHp * 0.1, '10 % of her max HP');
} else assert.equal(heals.length, 0, `${tier} ${mod}: no heal`);
// an unmarked enemy: nothing
const plain = h.spawn('enemy_dummy', { pos: [12, 8] });
h.b.kill(plain, null);
assert.equal(h.hooksOf('heal').filter((c) => c.target === u).length - h0, y3 ? 1 : 0);
done(h);
}
});
+380
View File
@@ -0,0 +1,380 @@
// test/content/op_chen2.test.js — the 自选 operator kit of 假日威龙陈 (char_1013_chen2, 6★ 散射手; kit
// server/sim/content/kits/ops/op-chen2.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, RPR-X
// 沙滩战斗套装 or RPR-Y 假期的最后一天 at stage 1 (tier 5) / 3 (tier 6). Numbers from data/backups.json; the fidelity checklist
// of kits/README.md item by item.
// Run: node --test test/content/op_chen2.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';
import { spareChance, waterOn, holidayLines, slimeOf, slimeKey } from '../../server/sim/content/kits/ops/op-chen2.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 CHEN = 'char_1013_chen2';
const FORMS = BACKUPS.units[CHEN].forms;
const SLOT = { 5: 'chess_char_5_diy1_a', 6: 'chess_char_6_diy1_a' };
const RX = 'uniequip_002_chen2', RY = 'uniequip_003_chen2';
const S1 = 'skchr_chen2_1', S2 = 'skchr_chen2_2', S3 = 'skchr_chen2_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_armor: dummy('enemy_armor', { def: 500 }),
enemy_walk: enemyRec({ key: 'enemy_walk', hp: 1e9, speed: 0.5, mass: 0 }),
};
const FORMS_ALL = [[5, false, null], [6, false, null], ...[5, 6].flatMap((t) => [null, RX, RY].map((m) => [t, true, m]))];
const label = ([tier, elite, mod]) => `T${tier} ${elite ? 'elite' : 'normal'} ${mod ?? 'none'}`;
/** 假日威龙陈 as uid 1 at (row, col) facing RIGHT, plus `others`. */
function field({ tier = 5, elite = false, mod = null, skill = 0, row = 10, col = 4, others = [], seed = 5, flags = {} } = {}) {
const h = makeBattle({
defs: { enemies: ENEMIES }, timeLimit: 900, autoFinish: false, seed,
flags: { dpPerSec: 0, dpMax: 999, ...flags }, hooks: ['damaged', 'skillStart', 'skillEnd', 'ammoUsed', 'attack', 'statusApplied'], captureNoisy: true,
units: [{ uid: 1, diy: { slot: SLOT[tier], charId: CHEN, skillIndex: skill, uniEquipId: mod }, elite, row, col }, ...others],
});
h.step();
return { h, u: h.unit(1) };
}
const atkHits = (h, u) => h.hooksOf('damaged').filter((c) => c.source === u && c.dmg?.isAttack);
function done(h) {
checkInvariants(h.b);
assert.equal(h.b.errors.length, 0, JSON.stringify(h.b.errors[0]));
}
/** Give the skill its SP and run until it starts. */
function cast(h, u, max = 5) {
u.skill.gainSp(999);
assert.ok(h.runUntil(() => u.skill.active, max), 'cast');
}
test('假日威龙陈 in every 自选 form: her kit (all three skills authored), the form\'s stats + module attributes (RPR-Y: cost −8), 2-5, 散射手 (every enemy in range, air too, ×1.5 / RPR-X ×1.6 on her front row), blocks 1, ground-targetable, the data triggers; offered as a pick', () => {
assert.equal(OPERATOR_KITS[CHEN], KITS[CHEN]);
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], [CHEN, SLOT[tier], form.skills[skill].skillId, false, 'skills'], label(f));
assert.deepEqual([u.base.maxHp, u.base.atk, u.base.def, u.base.cost],
[form.stats.maxHp + (m?.attr.maxHp ?? 0), form.stats.atk + (m?.attr.atk ?? 0), form.stats.def + (m?.attr.def ?? 0), form.stats.cost + (m?.attr.cost ?? 0)], `${label(f)}: stats`);
assert.deepEqual([u.s.blockCnt, u.profile.attack, u.profile.canHitFly, u.profile.dmgType, u.profile.allInRange, u.profile.sub, u.base.bat],
[1, 'ranged', true, 'phys', true, 'reaperrange', 2.3], `${label(f)}: 散射手`);
assert.equal(u.profile.frontScale, mod === RX ? 1.6 : 1.5, `${label(f)}: front-row scale`);
assert.deepEqual(u.profile.frontGrid, [[1, 1], [0, 0], [0, 1], [-1, 1]], `${label(f)}: the trait's front grid`);
assert.deepEqual(u.liveRangeGrid, form.rangeGrid, `${label(f)}: 2-5`);
assert.equal(u.skill.rule, form.skills[skill].trigger.rule, `${label(f)}: the data's trigger`);
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);
}
}
assert.deepEqual(formOf(6, true).skills.map((s) => s.trigger.rule), ['DEFAULT', 'DEFAULT', 'ACTIVE_RANGE']);
assert.deepEqual([FORMS['2/1/4/0'].stats.atk, FORMS['2/60/7/1'].stats.atk, FORMS['2/1/4/0'].stats.cost], [649, 731, 32]);
assert.deepEqual([modOf(5, RX).attr, modOf(6, RX).attr, modOf(5, RY).attr, modOf(6, RY).attr],
[{ atk: 30, def: 37 }, { atk: 60, def: 45 }, { cost: -8, maxHp: 135, atk: 55 }, { cost: -8, maxHp: 180, atk: 100 }]);
const data = { chess: CHESS, backups: BACKUPS };
assert.ok(KITTED_CHARS.includes(CHEN) && [5, 6].every((t) => diyPool(t, { data, kitted: KITTED_CHARS }).includes(CHEN)));
assert.equal(validateDiyPicks({ [SLOT[6]]: { charId: CHEN, skillIndex: 2, uniEquipId: RY } }, { data, kitted: KITTED_CHARS }).ok, true);
});
test('trait 散射手: one attack strikes every enemy of her 2-5 (a flyer too) — ×1.5 (RPR-X ×1.6) on the trait front row (her column ahead), ×1 elsewhere; one attackId', () => {
for (const [tier, elite, mod] of [[5, false, null], [6, true, RX], [6, true, RY]]) {
const { h, u } = field({ tier, elite, mod, skill: 1 });
u.skill.charges = 0; u.skill.sp = 0;
h.b.addBuff(u, { key: 'test:noSp', flags: { noSp: true } });
const front = h.spawn('enemy_dummy', { pos: [10, 5] }), up1 = h.spawn('enemy_dummy', { pos: [9, 5] });
const far = h.spawn('enemy_dummy', { pos: [10, 6] }), fly = h.spawn('enemy_fly', { pos: [11, 6] });
const out = h.spawn('enemy_dummy', { pos: [10, 7] });
assert.ok(h.runUntil(() => atkHits(h, u).length >= 4, 5), 'an attack');
const first = atkHits(h, u);
const id = first[0].dmg.attackId;
const hit = first.filter((c) => c.dmg.attackId === id);
assert.deepEqual(new Set(hit.map((c) => c.target)), new Set([front, up1, far, fly]), `T${tier}: every enemy of 2-5`);
const sc = mod === RX ? 1.6 : 1.5;
for (const c of hit) approx(c.amount, u.s.atk * ([front, up1].includes(c.target) ? sc : 1), `T${tier} ${mod}: ${c.target.tileR},${c.target.tileC}`);
assert.ok(!hit.some((c) => c.target === out), `T${tier}: [0,3] is outside 2-5`);
done(h);
}
});
test('S1 高压冲击 (AUTO, attack SP 6 / 5, data DEFAULT): after that many attacks ATK +55 % / +70 %, 4 bullets, every enemy of her range takes the trait multiplier; ends after 4 attacks', () => {
for (const [tier, elite] of [[5, false], [6, true]]) {
const sk = skillOf(tier, elite, S1);
assert.deepEqual([sk.spType, sk.spCost, sk.initSp, sk.bb.atk, sk.bb['attack@trigger_time'], sk.skillType], ['INCREASE_WHEN_ATTACK', elite ? 5 : 6, 0, elite ? 0.7 : 0.55, 4, 'AUTO'], `T${tier}`);
const { h, u } = field({ tier, elite, skill: 0 });
assert.deepEqual([u.skill.kind, u.skill.rule, u.skill.spType], ['ammo', 'DEFAULT', 'attack']);
const SP = h.b.rng.chance; // no spare shots for an exact count: her own 节约风气 is tested below
h.b.rng.chance = () => false;
h.spawn('enemy_dummy', { pos: [10, 5] });
h.spawn('enemy_dummy', { pos: [10, 6] });
assert.ok(h.runUntil(() => u.skill.active, 60), `T${tier}: cast`);
const plain = h.hooksOf('attack').filter((c) => c.attacker === u && !c.isSkill);
assert.equal(plain.length, sk.spCost, `T${tier}: after ${sk.spCost} attacks`);
approx(u.s.atk, u.base.atk * (1 + sk.bb.atk), `T${tier}: ATK +${sk.bb.atk * 100} %`);
h.runUntil(() => !u.skill.active, 30);
h.b.rng.chance = SP;
h.run(1); // the last arrows land
const skillAttacks = h.hooksOf('attack').filter((c) => c.attacker === u && c.isSkill);
assert.equal(skillAttacks.length, 4, `T${tier}: 4 bullets, the cast's own attack the first`);
const skillHits = atkHits(h, u).filter((c) => c.dmg.isSkill);
assert.equal(skillHits.length, 8, `T${tier}: 4 attacks × 2 enemies`);
// (the last attack's arrows land after the skill ended: the engine reads the ATK at the impact)
const ids = [...new Set(skillHits.map((c) => c.dmg.attackId))];
for (const c of skillHits.filter((x) => ids.indexOf(x.dmg.attackId) < 3)) approx(c.amount, u.base.atk * (1 + sk.bb.atk) * 1.5, `T${tier}: ×1.5 on both (the trait's front row and the tile beyond)`);
assert.equal(h.hooksOf('ammoUsed').filter((c) => c.unit === u).length, 4, `T${tier}: 4 bullets`);
approx(u.s.atk, u.base.atk, `T${tier}: ATK back`);
done(h);
}
});
test('S2 “堇青之夜” (MANUAL, data DEFAULT, 蓄力 2): 27 / 24 SP from 5 / 10; cast with one charge 8 bullets, ATK +50 % / +65 %; with both stored (蓄力) 20 bullets; every cast empties the SP', () => {
for (const [tier, elite] of [[5, false], [6, true]]) {
const sk = skillOf(tier, elite, S2);
assert.deepEqual([sk.spCost, sk.initSp, sk.maxChargeTime, sk.bb.atk, sk.bb['attack@trigger_time'], sk.bb['attack@another_trigger_time']],
[elite ? 24 : 27, elite ? 10 : 5, 2, elite ? 0.65 : 0.5, 8, 20], `T${tier}`);
const { h, u } = field({ tier, elite, skill: 1 });
const atStart = [];
h.b.on('skillStart', (c) => { if (c.unit === u) atStart.push([c.skill.ammoLeft, c.skill.ammoMax, c.skill.charges, c.skill.sp, u.mem.chen2Charged]); }, { priority: -1000 });
assert.deepEqual([u.skill.kind, u.skill.rule, u.skill.maxCharges], ['ammo', 'DEFAULT', 2]);
approx(u.skill.sp, sk.initSp, `T${tier}: initial SP`, 0.02);
// one charge and some SP towards the second: 8 bullets, everything spent
u.skill.gainSp(sk.spCost - u.skill.sp + 5);
assert.equal(u.skill.charges, 1);
approx(u.skill.sp, 5, 'SP towards the second charge');
h.spawn('enemy_dummy', { pos: [10, 5] });
assert.ok(h.runUntil(() => u.skill.active, 5), `T${tier}: cast`);
assert.deepEqual(atStart[0], [8, 8, 0, 0, false], `T${tier}: 8 bullets, SP emptied`);
approx(u.s.atk, u.base.atk * (1 + sk.bb.atk), `T${tier}: ATK`);
u.skill.end('test');
// 蓄力: both charges stored
u.skill.gainSp(999, 'init');
assert.equal(u.skill.charges, 2);
assert.ok(h.runUntil(() => u.skill.active, 10), `T${tier}: charged cast`);
assert.deepEqual(atStart[1], [20, 20, 0, 0, true], `T${tier}: 20 bullets`);
done(h);
}
});
test('slime (S2 / S3): each attack slimes the tiles of her attack range (2-5; S3 2-6) for 5 s; a ground enemy there — struck or not, stealthed too — moves ×0.8 / ×0.7 / ×0.6 and loses 100 / 150 / 200 DEF after its multipliers (not stacking); a flyer or an enemy outside never; it lapses 5 s after her last attack; two 假日威龙陈 each slow', () => {
for (const [tier, elite, skill] of [[5, false, 1], [6, true, 1], [5, false, 2], [6, true, 2]]) {
const sk = skillOf(tier, elite, [S1, S2, S3][skill]);
const [ms, def, life] = [sk.bb['attack@move_speed'], sk.bb['attack@def'], sk.bb['attack@projectile_life_time']];
const { h, u } = field({ tier, elite, skill });
const e = h.spawn('enemy_armor', { pos: [10, 5] });
const fly = h.spawn('enemy_fly', { pos: [10, 6] });
const out = h.spawn('enemy_armor', { pos: [10, 8] });
cast(h, u);
assert.ok(h.runUntil(() => h.hooksOf('attack').some((c) => c.attacker === u && c.isSkill), 5), 'an attack');
h.run(0.25);
const tiles = slimeOf(h.b, u);
assert.deepEqual([...tiles.keys()].sort((a, b) => a - b), [...u.rangeKeys].sort((a, b) => a - b), `T${tier} S${skill + 1}: her range (${skill === 2 ? '2-6' : '2-5'})`);
const key = slimeKey(u);
const b = e.findBuff(key);
assert.ok(b, `T${tier} S${skill + 1}: the ground enemy is slimed`);
approx(b.mods.moveMul, 1 + ms, `×${1 + ms}`);
approx(e.s.def, 500 + def, `DEF ${def}`);
assert.equal(fly.findBuff(key), null, 'never a flyer');
assert.equal(out.findBuff(key), null, 'not outside her range');
// a stealthed ground enemy that walks in (never struck: she cannot see it) — 无视无法选择
const sneak = h.spawn('enemy_armor', { pos: [9, 6] });
h.b.addBuff(sneak, { key: 'test:stealth', flags: { stealth: true } });
h.run(0.25);
assert.ok(sneak.findBuff(key), 'a stealthed enemy in the slime is slimed');
// the DEF cut is a final addition: after a ×0.7 DEF status
h.b.applyStatus(e, 'defDown', { duration: 30, value: 0.3, source: u });
h.run(0.25);
approx(e.s.def, 500 * 0.7 + def, 'DEF ×0.7 then the cut');
assert.equal(e.buffs.filter((x) => x.key === key).length, 1, '不叠加');
// stop her: the slime lapses life s after her last attack
u.skill.end('test');
h.b.addBuff(u, { key: 'test:disarm', flags: { disarm: true } });
const tLast = h.hooksOf('attack').filter((c) => c.attacker === u).slice(-1)[0].t;
h.run(tLast + life - 0.3 - h.b.time);
assert.ok(e.findBuff(key), 'still slimed');
h.run(0.7);
assert.equal(e.findBuff(key), null, `gone ${life} s after her last attack`);
done(h);
}
// two of them: one slow each (independentCharacterSource)
const h = makeBattle({
defs: { enemies: ENEMIES }, timeLimit: 60, autoFinish: false, seed: 3, flags: { dpPerSec: 0 },
units: [{ uid: 1, diy: { slot: 5, charId: CHEN, skillIndex: 1 }, row: 10, col: 4 }, { uid: 2, diy: { slot: 6, charId: CHEN, skillIndex: 1 }, row: 11, col: 4 }],
});
h.step();
const e = h.spawn('enemy_armor', { pos: [10, 5] });
for (const id of [1, 2]) h.unit(id).skill.gainSp(999);
h.run(3);
assert.ok(e.findBuff(slimeKey(h.unit(1))) && e.findBuff(slimeKey(h.unit(2))), 'both slimes');
approx(e.s.def, 500 - 200, 'DEF −100 twice');
done(h);
});
test('S3 “假日风暴” (MANUAL, data ACTIVE_RANGE on 2-6): an enemy only on 2-6 casts it; range 2-6 (and back); ATK +55 % / +70 %, every attack strikes twice with the trait multiplier on every enemy; 32 bullets, 2 per attack (16 attacks), one left still attacks', () => {
for (const [tier, elite] of [[5, false], [6, true]]) {
const sk = skillOf(tier, elite, S3);
assert.deepEqual([sk.spCost, sk.initSp, sk.bb.atk, sk.bb['attack@trigger_time'], sk.rangeId], [elite ? 60 : 65, elite ? 25 : 20, elite ? 0.7 : 0.55, 32, '2-6'], `T${tier}`);
const { h, u } = field({ tier, elite, skill: 2 });
assert.deepEqual([u.skill.kind, u.skill.rule], ['ammo', 'ACTIVE_RANGE']);
const SP = h.b.rng.chance;
h.b.rng.chance = () => false;
const n0 = h.hooksOf('ammoUsed').filter((c) => c.unit === u).length;
const a0 = h.hooksOf('attack').filter((c) => c.attacker === u && c.isSkill).length;
u.skill.gainSp(999);
const corner = h.spawn('enemy_dummy', { pos: [12, 6] });
assert.ok(h.runUntil(() => u.skill.active, 1), `T${tier}: cast for [2,2] (outside 2-5)`);
assert.deepEqual(u.liveRangeGrid, sk.rangeGrid, `T${tier}: 2-6 while it runs`);
const front = h.spawn('enemy_dummy', { pos: [10, 5] });
h.runUntil(() => !u.skill.active, 60);
h.b.rng.chance = SP;
const attacks = h.hooksOf('attack').filter((c) => c.attacker === u && c.isSkill).length - a0;
assert.equal(attacks, 16, `T${tier}: 32 bullets / 2`);
assert.equal(h.hooksOf('ammoUsed').filter((c) => c.unit === u).length - n0, 32, `T${tier}: one ammoUsed per bullet`);
const hits = atkHits(h, u).filter((c) => c.dmg.isSkill && c.target === front);
assert.ok(hits.length >= 28, `T${tier}: two hits per attack (${hits.length})`);
const byId = new Map();
for (const c of hits) byId.set(c.dmg.attackId, (byId.get(c.dmg.attackId) ?? 0) + 1);
assert.ok([...byId.values()].every((n) => n === 2), `T${tier}: two damage instances per attack`);
const atk = u.base.atk * (1 + sk.bb.atk);
for (const c of hits) approx(c.amount, atk * 1.5, `T${tier}: front ×1.5`);
const onCorner = atkHits(h, u).filter((c) => c.dmg.isSkill && c.target === corner);
assert.ok(onCorner.length >= 30, `T${tier}: [2,2] struck too`);
for (const c of onCorner) approx(c.amount, atk * 1.5, `T${tier}: [2,2] also ×1.5`);
assert.deepEqual(u.liveRangeGrid, formOf(tier, elite).rangeGrid, `T${tier}: back to 2-5`);
// 即使剩余弹药数小于2发仍可"消耗2发弹药"进行攻击
h.b.on('skillStart', (c) => { if (c.unit === u) c.skill.ammoLeft = 3; }, { priority: -1000 });
h.b.rng.chance = () => false;
const a1 = h.hooksOf('attack').filter((c) => c.attacker === u && c.isSkill).length;
u.skill.gainSp(999, 'init');
assert.ok(h.runUntil(() => u.skill.active, 5));
h.runUntil(() => !u.skill.active, 30);
h.b.rng.chance = SP;
assert.equal(h.hooksOf('attack').filter((c) => c.attacker === u && c.isSkill).length - a1, 2, `T${tier}: 3 bullets ⇒ 2 attacks (2 + the last one)`);
done(h);
}
});
test('T1 节约风气: her ammo-skill attacks spare their bullets 20 % of the time (RPR-X stage 3: 25 %) — one roll per attack, S3 spares both bullets, every ammoUsed still fires', () => {
for (const [tier, elite, mod, p] of [[5, false, null, 0.2], [5, true, RX, 0.2], [6, true, RX, 0.25], [6, true, RY, 0.2]]) {
for (const skill of [1, 2]) {
const { h, u } = field({ tier, elite, mod, skill, seed: 17 });
h.spawn('enemy_dummy', { pos: [10, 5] });
cast(h, u);
assert.equal(spareChance(h.b, u), p, `T${tier} ${mod}: her chance`);
u.skill.ammoLeft = 100000;
const u0 = h.hooksOf('ammoUsed').filter((c) => c.unit === u).length;
const before = new Map();
h.b.on('attack', (c) => { if (c.attacker === u) before.set(u.stats.attacks, u.skill.ammoLeft); }, { priority: 1000 });
const spent = [];
h.b.on('attack', (c) => { if (c.attacker === u) h.b.after(0, () => spent.push(before.get(u.stats.attacks) - u.skill.ammoLeft)); }, { priority: 1000 });
h.run(900);
h.b.addBuff(u, { key: 'test:disarm', flags: { disarm: true } });
h.step(3);
const per = skill === 2 ? 2 : 1;
assert.ok(spent.length > 300, `${spent.length} attacks`);
assert.ok(spent.every((n) => n === 0 || n === per), `T${tier} S${skill + 1}: 0 or ${per} per attack`);
const r = spent.filter((n) => n === 0).length / spent.length;
assert.ok(Math.abs(r - p) < 0.05, `T${tier} ${mod} S${skill + 1}: spare rate ${r} ≈ ${p}`);
const used = h.hooksOf('ammoUsed').filter((c) => c.unit === u).length - u0;
assert.equal(used, spent.length * per, `T${tier} S${skill + 1}: every bullet's ammoUsed fires, spared or not`);
done(h);
}
}
});
test('T1 节约风气 on others while she is on the field: another 【狙击】 operator\'s 弹药类技能 20 % (PRTS 修正 over the text\'s 10 %; RPR-X stage 3 too), another 远程 operator\'s 0 % / 12 % (RPR-X stage 3), never a 技能 without "攻击装有X发" nor a summon; none once she leaves; the highest of two 假日威龙陈', () => {
const t0 = FORMS['2/1/4/0'].talents.find((t) => t.index === 0);
assert.deepEqual(t0.bb, { 'spareshot_chen.prob': 0.2, prob: 0.1 }, 'the base row: 20 % / the text\'s 10 %');
assert.deepEqual(modOf(6, RX).talentChanges[0].bb, { 'e_spareshot_chen.prob': 0.25, 'chen2_t_002[spareshot][other].prob': 0.12, 'chen2_t_002[spareshot][sniper].prob': 0.2 });
for (const [tier, elite, mod, sniper, other] of [[5, false, null, 0.2, 0], [5, true, RX, 0.2, 0], [6, true, RX, 0.2, 0.12], [6, true, RY, 0.2, 0]]) {
const others = [
{ uid: 2, chessId: 'chess_char_1_01_a', row: 11, col: 3 }, // 隐现 (狙击): S2 "攻击装有14发弹药"
{ uid: 3, chessId: 'chess_char_5_03_a', row: 12, col: 3 }, // 烛煌 (术师, 远程): S3 "攻击装有18发弹药"
{ uid: 4, chessId: 'chess_char_5_08_a', skillIndex: 1, row: 9, col: 7 }, // 号角 (重装): S2 "技能拥有10枚弹药" — no 攻击装有
];
const { h, u } = field({ tier, elite, mod, skill: 0, others });
const inside = h.unit(2), blaze = h.unit(3), horn = h.unit(4);
assert.equal(spareChance(h.b, inside), sniper, `${tier} ${mod}: 狙击`);
assert.equal(spareChance(h.b, blaze), other, `${tier} ${mod}: 远程`);
assert.equal(spareChance(h.b, horn), 0, `${tier} ${mod}: 地面`);
// the roll only applies to a running 弹药类技能 (whose text says 攻击装有X发…)
for (const x of [inside, blaze]) assert.match(x.skill.def.description, /攻击装有\d+发/);
assert.doesNotMatch(horn.skill.def.description, /攻击装有\d+发/);
// 隐现's S2 over many attacks
h.spawn('enemy_dummy', { pos: [11, 5] });
inside.skill.gainSp(999);
assert.ok(h.runUntil(() => inside.skill.active, 10), '隐现 casts');
inside.skill.ammoLeft = 100000;
let spared = 0, n = 0;
h.b.on('attack', (c) => {
if (c.attacker !== inside) return;
const left = inside.skill.ammoLeft;
h.b.after(0, () => { n++; if (inside.skill.ammoLeft === left) spared++; });
}, { priority: 1000 });
h.run(500);
h.b.addBuff(inside, { key: 'test:disarm', flags: { disarm: true } });
h.step(3);
assert.ok(n > 200, `${n} attacks`);
assert.ok(Math.abs(spared / n - sniper) < 0.06, `T${tier} ${mod}: 隐现 ${spared}/${n} ≈ ${sniper}`);
// she leaves: nobody's chance
h.b.retreat(u);
assert.deepEqual([spareChance(h.b, inside), spareChance(h.b, blaze)], [0, 0], 'only while she is on the field');
done(h);
}
// two 假日威龙陈 (a shared field): each takes the highest — the RPR-X stage-3 one gives the other 20 % (≥ her own 20 %)
const h = makeBattle({
defs: { enemies: ENEMIES }, timeLimit: 60, autoFinish: false, seed: 3, flags: { dpPerSec: 0 },
units: [{ uid: 1, diy: { slot: 6, charId: CHEN, skillIndex: 0, uniEquipId: RX }, elite: true, row: 10, col: 4 },
{ uid: 2, diy: { slot: 5, charId: CHEN, skillIndex: 0, uniEquipId: null }, elite: false, row: 11, col: 4 },
{ uid: 3, chessId: 'chess_char_5_03_a', row: 12, col: 3 }],
});
h.step();
assert.deepEqual([spareChance(h.b, h.unit(1)), spareChance(h.b, h.unit(2)), spareChance(h.b, h.unit(3))], [0.25, 0.2, 0.12]);
done(h);
});
test('T2 假日余韵: ASPD +8 (no level of the mode has the water TAG); RPR-Y stage 3: ATK +15 % ASPD +12, and while her skill runs the field counts as water: ATK +28 % ASPD +20 — for every 假日威龙陈 of the field — until it ends', () => {
// the two rows of the data: base [map] = the step (8 + 4 = 12), module [map] = the totals (20 / 28 %), as their texts say
const base = FORMS['2/1/4/0'].talents.find((t) => t.index === 1);
assert.match(base.desc, /改为攻击速度\+12/);
assert.deepEqual(holidayLines(base), { common: { atkPct: 0, aspd: 8 }, water: { atkPct: 0, aspd: 12 } });
const row = modOf(6, RY).talentChanges[0];
assert.match(row.desc, /改为攻击力\+28%,攻击速度\+20,技能开启时,场地视为水地形/);
assert.deepEqual(holidayLines({ ...row, fromModule: true }), { common: { atkPct: 0.15, aspd: 12 }, water: { atkPct: 0.28, aspd: 20 } });
assert.deepEqual(modOf(5, RY).talentChanges, [], 'RPR-Y stage 1 changes no talent');
for (const f of FORMS_ALL) {
const [tier, elite, mod] = f;
const y3 = elite && mod === RY && tier === 6;
const { h, u } = field({ tier, elite, mod, skill: 2, others: [{ uid: 2, diy: { slot: 5, charId: CHEN, skillIndex: 0 }, row: 12, col: 4 }] });
const mate = h.unit(2);
approx(u.s.aspd, 100 + (elite ? (modOf(tier, mod)?.attr.aspd ?? 0) : 0) + (y3 ? 12 : 8), `${label(f)}: ASPD`);
approx(u.s.atk, u.base.atk * (y3 ? 1.15 : 1), `${label(f)}: ATK`);
assert.equal(waterOn(h.b), false);
h.spawn('enemy_dummy', { pos: [10, 5] });
cast(h, u);
h.step();
assert.equal(waterOn(h.b), y3, `${label(f)}: water while her skill runs`);
approx(u.s.aspd, 100 + (y3 ? 20 : 8), `${label(f)}: ASPD during the skill`);
approx(u.s.atk, u.base.atk * (1 + skillOf(tier, elite, S3).bb.atk + (y3 ? 0.28 : 0)), `${label(f)}: ATK during the skill`);
approx(mate.s.aspd, 100 + (y3 ? 12 : 8), `${label(f)}: the other 假日威龙陈 (no module) gets the water line too`);
u.skill.end('test');
h.step();
assert.equal(waterOn(h.b), false, `${label(f)}: the TAG ends with the skill`);
approx(u.s.aspd, 100 + (y3 ? 12 : 8), `${label(f)}: back`);
approx(mate.s.aspd, 108, `${label(f)}: the other back to +8`);
if (y3) {
cast(h, u);
h.step();
assert.equal(waterOn(h.b), true);
h.b.retreat(u);
h.step();
assert.equal(waterOn(h.b), false, 'cleared when she leaves');
}
done(h);
}
});
+371
View File
@@ -0,0 +1,371 @@
// test/content/op_ray.test.js — the 自选 operator kit of 莱伊 (char_4117_ray, 6★ 猎手; kit
// server/sim/content/kits/ops/op-ray.js) and of her summon 沙地兽 (token_10034_ray_sndbst), fielded the production way (a DIY
// slot + its `diy` pick, simdata getDiy; the 沙地兽 as the placed hand piece of her player) in every form: tiers 5 / 6,
// normal (E2 Lv1, skill rank 4, no module) and elite (E2 Lv60, rank 7) with no module, HUN-X 《跳舞的月光》 or HUN-Y 证明什么?
// at stage 1 (tier 5) / 3 (tier 6). Numbers from data/backups.json; the fidelity checklist of kits/README.md.
// Run: node --test test/content/op_ray.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';
import { SANDBEAST, SPECIAL_TAG } from '../../server/sim/content/kits/ops/op-ray.js';
import { PUSH_TILES } from '../../server/sim/constants.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 RAY = 'char_4117_ray';
const FORMS = BACKUPS.units[RAY].forms;
const TOKREC = BACKUPS.tokens[SANDBEAST];
const SLOT = { 5: 'chess_char_5_diy1_a', 6: 'chess_char_6_diy1_a' };
const HX = 'uniequip_002_ray', HY = 'uniequip_003_ray';
const S1 = 'skchr_ray_1', S2 = 'skchr_ray_2', S3 = 'skchr_ray_3';
const statusOf = (tier, elite) => (elite ? (tier === 5 ? '2/60/7/1' : '2/60/7/3') : '2/1/4/0');
const formOf = (tier, elite) => FORMS[statusOf(tier, elite)];
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);
/** The 沙地兽's variant of a form, with the pick's module (getDiyToken). */
const tokOf = (tier, elite, mod) => {
const v = TOKREC.variants[`${RAY}@${statusOf(tier, elite)}`];
return mod && v.byModule?.[mod] ? { ...v, ...v.byModule[mod] } : v;
};
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_weak: dummy('enemy_weak', { hp: 10 }),
enemy_atk: dummy('enemy_atk', { atk: 500, range: 2 }),
};
const FORMS_ALL = [[5, false, null], [6, false, null], ...[5, 6].flatMap((t) => [null, HX, HY].map((m) => [t, true, m]))];
const label = ([tier, elite, mod]) => `T${tier} ${elite ? 'elite' : 'normal'} ${mod ?? 'none'}`;
/** 莱伊 as uid 1 at (row, col) facing RIGHT; `beast` = the 沙地兽 piece's tile (uid 2) or null. */
function field({ tier = 5, elite = false, mod = null, skill = 0, row = 10, col = 3, beast = null, beastFirst = false, others = [], seed = 5, flags = {} } = {}) {
const op = { uid: 1, diy: { slot: SLOT[tier], charId: RAY, skillIndex: skill, uniEquipId: mod }, elite, row, col };
const piece = beast ? [{ uid: 2, kind: 'token', tokenId: SANDBEAST, ownerUid: 1, row: beast[0], col: beast[1] }] : [];
const h = makeBattle({
defs: { enemies: ENEMIES }, timeLimit: 900, autoFinish: false, seed,
flags: { dpPerSec: 0, dpMax: 999, ...flags }, hooks: ['damaged', 'skillStart', 'skillEnd', 'statusApplied', 'death', 'deploy', 'attack', 'kill'], captureNoisy: true,
units: beastFirst ? [...piece, op, ...others] : [op, ...piece, ...others],
});
h.step();
return { h, u: h.unit(1), t: h.b.allyUnits.find((a) => a.kind === 'token' && a.defId === SANDBEAST) ?? null };
}
const atkHits = (h, u) => h.hooksOf('damaged').filter((c) => c.source === u && c.dmg?.isAttack);
function done(h) {
checkInvariants(h.b);
assert.equal(h.b.errors.length, 0, JSON.stringify(h.b.errors[0]));
}
/** Record (time, ammo) every time her magazine changes. */
function ammoLog(h, u) {
const log = [];
let last = u.trait.ammo;
h.b.on('tick', () => { if (u.trait.ammo !== last) { log.push([h.b.time, u.trait.ammo]); last = u.trait.ammo; } });
return log;
}
test('莱伊 in every 自选 form: her kit (all three skills authored), the form\'s stats + module attributes, 4-9, 猎手 (ranged physical, hits air, 8 bullets, ×1.2 / HUN-Y ×1.33), blocks 1, ground-targetable, the triggers (S2 at full SP); offered as a pick', () => {
assert.equal(OPERATOR_KITS[RAY], KITS[RAY]);
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], [RAY, SLOT[tier], form.skills[skill].skillId, false, 'skills'], label(f));
assert.deepEqual([u.base.maxHp, u.base.atk, u.base.def, u.base.aspd],
[form.stats.maxHp + (m?.attr.maxHp ?? 0), form.stats.atk + (m?.attr.atk ?? 0), form.stats.def + (m?.attr.def ?? 0), 100 + (m?.attr.aspd ?? 0)], `${label(f)}: stats`);
assert.deepEqual([u.s.blockCnt, u.profile.attack, u.profile.canHitFly, u.profile.dmgType, u.profile.sub, u.base.bat, u.profile.ammoMax, u.profile.ammoScale, u.trait.ammo],
[1, 'ranged', true, 'phys', 'hunter', 1.6, 8, mod === HY ? 1.33 : 1.2, 8], `${label(f)}: 猎手`);
assert.deepEqual(u.liveRangeGrid, form.rangeGrid, `${label(f)}: 4-9`);
assert.equal(u.skill.rule, skill === 1 ? 'SP_FULL' : form.skills[skill].trigger.rule, `${label(f)}: trigger`);
assert.ok(!u.s.flags.liftoff && !u.s.flags.camou && !u.s.flags.stealth, `${label(f)}: ground enemies target her`);
done(h);
}
}
assert.deepEqual(formOf(6, true).skills.map((s) => s.trigger.rule), ['DEFAULT', 'DEFAULT', 'ACTIVE_RANGE']);
assert.deepEqual([modOf(5, HX).attr, modOf(6, HX).attr, modOf(5, HY).attr, modOf(6, HY).attr],
[{ maxHp: 150, atk: 50, def: 15 }, { maxHp: 200, atk: 70, def: 25 }, { maxHp: 100, atk: 60, aspd: 5 }, { maxHp: 200, atk: 75, aspd: 7 }]);
const data = { chess: CHESS, backups: BACKUPS };
assert.ok(KITTED_CHARS.includes(RAY) && [5, 6].every((t) => diyPool(t, { data, kitted: KITTED_CHARS }).includes(RAY)));
assert.equal(validateDiyPicks({ [SLOT[5]]: { charId: RAY, skillIndex: 1, uniEquipId: HX } }, { data, kitted: KITTED_CHARS }).ok, true);
});
test('trait 猎手: 8 bullets, one per attack at ×1.2 (HUN-Y ×1.33); empty ⇒ a reload of her BASE attack time (1.6 s, ASPD +100 changes nothing) loads one bullet; HUN-X loads one more onto an empty magazine; with nobody to shoot she reloads to full and stops', () => {
for (const [tier, elite, mod] of [[5, false, null], [5, true, HX], [6, true, HX], [6, true, HY]]) {
const { h, u } = field({ tier, elite, mod, skill: 1 });
u.skill.sp = 0;
h.b.addBuff(u, { key: 'test:noSp', flags: { noSp: true } });
h.b.addBuff(u, { key: 'test:fast', mods: { aspd: 100 } });
const log = ammoLog(h, u);
const e = h.spawn('enemy_dummy', { pos: [10, 5] });
assert.ok(h.runUntil(() => u.trait.ammo === 0, 20), `${mod}: the magazine runs out`);
assert.equal(h.hooksOf('attack').filter((c) => c.attacker === u).length, 8, `${mod}: 8 shots`);
h.run(0.3); // the last arrow lands (the reload has begun meanwhile)
const hits = atkHits(h, u);
assert.equal(hits.length, 8);
const sc = mod === HY ? 1.33 : 1.2;
// (入神 adds +8 % / +9 % per attack on the same target; the first shot has one layer)
const t1 = (mod === HY && tier === 6) ? 0.09 : 0.08;
approx(hits[0].amount, u.base.atk * (1 + t1) * sc, `${mod}: ×${sc}`);
const iv = u.s.interval;
approx(iv, 1.6 * 100 / (u.base.aspd + 100), 'ASPD +100 shortens her attacks');
// empty with a target: each reload (after the attack cooldown) loads, and she shoots at once — HUN-X: two bullets
const hx = elite && mod === HX;
assert.ok(h.runUntil(() => h.hooksOf('attack').filter((c) => c.attacker === u).length >= 12, 30), 'more shots');
const ts = h.hooksOf('attack').filter((c) => c.attacker === u).map((c) => c.t);
for (let i = 1; i < 8; i++) approx(ts[i] - ts[i - 1], iv, `${mod}: the magazine at ${iv.toFixed(2)} s`, 0.05);
approx(ts[8] - ts[7], iv + 1.6, `${mod}: cooldown + a 1.6 s reload (never shortened)`, 0.05);
if (hx) {
approx(ts[9] - ts[8], iv, 'HUN-X: the second bullet of that reload', 0.05);
approx(ts[10] - ts[9], iv + 1.6, 'then a reload again', 0.05);
} else {
approx(ts[9] - ts[8], iv + 1.6, `${mod}: one bullet per reload`, 0.05);
}
// nobody to shoot: one bullet per 1.6 s up to 8, then nothing
h.b.kill(e, null);
const n0 = log.length;
h.run(20);
const reloads = log.slice(n0);
assert.equal(reloads[reloads.length - 1][1], 8, `${mod}: full`);
for (let i = 1; i < reloads.length; i++) approx(reloads[i][0] - reloads[i - 1][0], 1.6, `${mod}: one bullet per 1.6 s`, 0.03);
const tFull = reloads[reloads.length - 1][0];
assert.ok(h.b.time - tFull > 5 && u.trait.ammo === 8, 'stops at 8');
done(h);
}
});
test('莱伊 shoots air units (猎手 "可对空"): a flyer in her range is her target; physical arrows', () => {
for (const [tier, elite, mod] of [[5, false, null], [6, true, HY]]) {
const { h, u } = field({ tier, elite, mod, skill: 1 });
u.skill.sp = 0;
h.b.addBuff(u, { key: 'test:noSp', flags: { noSp: true } });
const fly = h.spawn('enemy_fly', { pos: [10, 6] });
h.run(3);
const hits = atkHits(h, u).filter((c) => c.target === fly);
assert.ok(hits.length >= 1 && hits.every((c) => c.type === 'phys'), `T${tier}: the flyer is shot`);
done(h);
}
});
test('T2 入神: +8 % ATK per attack on the same target, ≤ 3 layers (HUN-Y stage 3: +9 %, ≤ 4), lost on a new target (one layer again)', () => {
for (const [tier, elite, mod] of [[5, false, null], [5, true, HY], [6, true, HY], [6, true, HX]]) {
const y3 = tier === 6 && mod === HY;
const [per, max] = y3 ? [0.09, 4] : [0.08, 3];
const t1 = (mod ? formOf(tier, true) : formOf(tier, elite)).talents.find((t) => t.index === 1).bb;
if (!y3) assert.deepEqual(t1, { atk: 0.08, max_stack_cnt: 3 });
const { h, u } = field({ tier, elite, mod, skill: 1 });
u.skill.sp = 0;
h.b.addBuff(u, { key: 'test:noSp', flags: { noSp: true } });
const atks = [];
h.b.on('damaged', (c) => { if (c.source === u && c.dmg.isAttack) atks.push([c.target, u.s.atk]); }, { priority: -100 });
const a = h.spawn('enemy_dummy', { pos: [10, 5] });
h.runUntil(() => atks.length >= 6, 20);
for (let i = 0; i < 6; i++) approx(atks[i][1], u.base.atk * (1 + per * Math.min(max, i + 1)), `${label([tier, elite, mod])}: attack ${i + 1}`);
h.b.kill(a, null);
const b = h.spawn('enemy_dummy', { pos: [10, 6] });
const n = atks.length;
h.runUntil(() => atks.length >= n + 1, 20);
assert.equal(atks[n][0], b);
approx(atks[n][1], u.base.atk * (1 + per), 'a new target: one layer');
done(h);
}
});
test('S1 脱身矢 (MANUAL, 2 charges, data DEFAULT): a special bullet at once (no bullet of the magazine) for 290 % / 360 % × the trait scale, pushed 中力 along her facing; off her facing radial at 力度 −1; a kill loads one more bullet at the next reload; with an empty magazine it still fires', () => {
for (const [tier, elite] of [[5, false], [6, true]]) {
const sk = skillOf(tier, elite, S1);
assert.deepEqual([sk.spCost, sk.initSp, sk.maxChargeTime, sk.bb.atk_scale, sk.bb.force, sk.bb.cnt], elite ? [12, 10, 2, 3.6, 1, 1] : [14, 10, 2, 2.9, 1, 1], `T${tier}`);
// straight ahead: pushed along +x
{
const { h, u } = field({ tier, elite, skill: 0, row: 11 });
assert.deepEqual([u.skill.kind, u.skill.rule, u.skill.maxCharges], ['charges', 'DEFAULT', 2]);
const atkAt = [];
h.b.on('damaged', (c) => { if (c.source === u) atkAt.push([c, u.s.atk]); }, { priority: -100 });
const e = h.spawn('enemy_dummy', { pos: [11, 5] });
u.skill.gainSp(999);
assert.ok(h.runUntil(() => u.skill.activations === 1, 3), `T${tier}: cast`);
const ammo0 = u.trait.ammo;
h.run(0.6);
const special = atkAt.filter(([c]) => c.dmg.tags?.includes(SPECIAL_TAG));
assert.equal(special.length, 1, `T${tier}: one special bullet`);
const [c, atk] = special[0];
approx(c.amount, atk * sk.bb.atk_scale * 1.2, `T${tier}: ${sk.bb.atk_scale * 100} % × 1.2`);
assert.deepEqual([c.type, c.dmg.isSkill, c.dmg.isAttack], ['phys', true, true]);
assert.equal(ammo0, 7, `T${tier}: the cast's normal attack took one bullet, the special one none`);
approx(e.x, 5 + PUSH_TILES[1], `T${tier}: pushed ${PUSH_TILES[1]} tiles along her facing`, 0.03);
approx(e.y, 11, 'no sideways push');
done(h);
}
// beside her (90° off): radial, 力度 −1 (中力 − 1 = level 0 on a weight-0 enemy — the wall stops it at 8.5)
{
const { h, u } = field({ tier, elite, skill: 0, row: 11 });
const e = h.spawn('enemy_dummy', { pos: [10, 3] });
u.skill.gainSp(999);
assert.ok(h.runUntil(() => u.skill.activations === 1, 3));
h.run(0.6);
approx(e.x, 3, 'no forward push');
assert.ok(10 - e.y > 1, `T${tier}: radial at level 0 (${(10 - e.y).toFixed(2)} tiles, the engine's −2 would be ${PUSH_TILES[-1] ?? 0.44})`);
done(h);
}
// a kill: +1 bullet at the next reload; an empty magazine: the cast still comes
{
const { h, u } = field({ tier, elite, skill: 0 });
u.trait.ammo = 0;
const log = ammoLog(h, u);
h.spawn('enemy_weak', { pos: [10, 5] });
u.skill.gainSp(999);
assert.ok(h.runUntil(() => u.skill.activations === 1, 1), `T${tier}: cast with an empty magazine`);
h.run(0.6);
assert.equal(h.hooksOf('kill').filter((k) => k.killer === u).length, 1, 'the special bullet killed it');
assert.equal(u.trait.ammo, 0, 'no bullet spent, none loaded yet');
assert.ok(h.runUntil(() => u.trait.ammo > 0, 5));
assert.equal(log[log.length - 1][1], 2, `T${tier}: 1 + 1 bullets`);
done(h);
}
}
});
test('S2 广域警觉 (AUTO, attack SP 16): on at full SP — no enemy needed beyond the attacks that fill it — for good: range 4-10, ATK +60 % / +90 %', () => {
for (const [tier, elite] of [[5, false], [6, true]]) {
const sk = skillOf(tier, elite, S2);
assert.deepEqual([sk.skillType, sk.spType, sk.spCost, sk.bb.atk, sk.bb.respawn_time, sk.rangeId], ['AUTO', 'INCREASE_WHEN_ATTACK', 16, elite ? 0.9 : 0.6, elite ? -0.3 : -0.2, '4-10'], `T${tier}`);
const { h, u } = field({ tier, elite, skill: 1 });
assert.deepEqual([u.skill.kind, u.skill.rule], ['toggle', 'SP_FULL']);
const e = h.spawn('enemy_dummy', { pos: [10, 5] });
assert.ok(h.runUntil(() => u.skill.active, 120), `T${tier}: on`);
assert.equal(h.hooksOf('attack').filter((c) => c.attacker === u).length, 16, `T${tier}: after 16 attacks (reloads give no SP)`);
assert.deepEqual(u.liveRangeGrid, sk.rangeGrid, `T${tier}: 4-10`);
approx(u.s.atk, u.base.atk * (1 + sk.bb.atk + u.mem.rayStacks * 0.08), `T${tier}: ATK (with 入神's layers)`);
h.b.kill(e, null);
h.run(200);
assert.ok(u.skill.active, `T${tier}: 持续时间无限`);
// an enemy two tiles above her: only 4-10 reaches it
const top = h.spawn('enemy_dummy', { pos: [12, 3] });
h.run(3);
assert.ok(atkHits(h, u).some((c) => c.target === top), `T${tier}: [2,0] of 4-10`);
done(h);
}
});
test('S3 “得见光芒” (MANUAL, 16 s, data ACTIVE_RANGE on 3-8): an enemy only on 3-8 casts it; no attack until the magazine is full, reloading every 0.4 s (1.6 − 1.2); range 3-8; attacks 230 % / 270 % × 1.2 and 束缚 2 s; a kill during it ⇒ +10 SP at its end, through 阻回', () => {
for (const [tier, elite] of [[5, false], [6, true]]) {
const sk = skillOf(tier, elite, S3);
assert.deepEqual([sk.duration, sk.spCost, sk.initSp, sk.bb.reload_interval, sk.bb['attack@atk_scale'], sk.bb['attack@unmove_duration'], sk.bb.sp, sk.rangeId],
[16, elite ? 33 : 37, elite ? 20 : 15, -1.2, elite ? 2.7 : 2.3, 2, 10, '3-8'], `T${tier}`);
const { h, u } = field({ tier, elite, skill: 2 });
assert.deepEqual([u.skill.kind, u.skill.rule], ['duration', 'ACTIVE_RANGE']);
u.trait.ammo = 2;
const log = ammoLog(h, u);
u.skill.gainSp(999);
const side = h.spawn('enemy_dummy', { pos: [11, 6] }); // [1,3]: in 3-8, not in 4-9
assert.ok(h.runUntil(() => u.skill.active, 1), `T${tier}: cast for [1,3]`);
assert.deepEqual(u.liveRangeGrid, sk.rangeGrid, `T${tier}: 3-8 while it runs`);
const tCast = h.b.time;
const attacksAfter = () => h.hooksOf('attack').filter((c) => c.attacker === u && c.t > tCast - 1e-9);
assert.ok(h.runUntil(() => attacksAfter().length > 0, 5), 'attacks once full');
// 2 → 8 one bullet every 0.4 s, the first attack on the reload that fills it (the log sees 3 … 7, then 7 after that shot)
const fills = log.filter((x) => x[0] > tCast - 1e-9);
assert.deepEqual(fills.map((x) => x[1]), [3, 4, 5, 6, 7], `T${tier}: one at a time`);
for (let i = 1; i < fills.length; i++) approx(fills[i][0] - fills[i - 1][0], 0.4, `T${tier}: a reload every 0.4 s`, 0.05);
approx(attacksAfter()[0].t - fills[fills.length - 1][0], 0.4, `T${tier}: the 8th bullet, then the shot`, 0.05);
assert.equal(u.trait.ammo, 7, `T${tier}: full when it shot`);
const atkAt = [];
h.b.on('damaged', (c) => { if (c.source === u && c.dmg.isAttack) atkAt.push([c, u.s.atk]); }, { priority: -100 });
h.run(4);
assert.ok(atkAt.length >= 2, `T${tier}: attacks once full`);
for (const [c, atk] of atkAt) approx(c.amount, atk * sk.bb['attack@atk_scale'] * 1.2, `T${tier}: ${sk.bb['attack@atk_scale'] * 100} % × 1.2`);
const binds = h.hooksOf('statusApplied').filter((c) => c.source === u && c.status === 'bind' && c.target === side);
assert.ok(binds.length >= 2 && binds.every((c) => Math.abs(c.duration - 2) < 1e-6), `T${tier}: 束缚 2 s on each hit`);
// a kill during it: +10 SP at its end, through 阻回
const weak = h.spawn('enemy_weak', { pos: [10, 4] });
h.runUntil(() => !weak.alive, 10);
h.b.addBuff(u, { key: 'test:noSp', flags: { noSp: true } });
h.runUntil(() => !u.skill.active, 20);
approx(u.skill.sp, sk.bb.sp, `T${tier}: +${sk.bb.sp} SP at the end`, 0.01);
assert.deepEqual(u.liveRangeGrid, formOf(tier, elite).rangeGrid, `T${tier}: back to 4-9`);
done(h);
}
});
test('沙地兽 (her placed piece): untargetable, 无敌, 禁疗, no attack; while it scouts (25 s) the enemies of its 3×3 are in her range and her skill trigger range, she shoots them first, ×1.15 (HUN-X stage 3: ×1.2) physical; then it leaves, and comes back on its tile after 30 s (HUN-X stage 3: 20 s) paying 3 DP', () => {
for (const [tier, elite, mod, ds, resp] of [[5, false, null, 0.15, 30], [5, true, HX, 0.15, 30], [6, true, HX, 0.2, 20], [6, true, HY, 0.15, 30]]) {
for (const beastFirst of [false, true]) {
const { h, u, t } = field({ tier, elite, mod, skill: 2, beast: [10, 6], beastFirst });
assert.ok(t && t.alive && t.deployed, `${mod}: deployed with the board`);
assert.equal(t.ownerUnit, u);
assert.deepEqual([t.base.respawnTime, t.base.cost, t.s.blockCnt], [tokOf(tier, elite, mod).stats.respawnTime, 3, 0], `${mod}: its stats`);
assert.equal(t.base.respawnTime, resp);
assert.ok(t.s.flags.untargetable && t.s.flags.invulnerable && t.s.flags.noHeal && t.profile.noAttack, `${mod}: untargetable, 无敌, 禁疗, no attack`);
assert.equal(t.kit.skill, null, 'no skill of its own');
// its area: in her range (and the trigger range of her skill)
const away = h.spawn('enemy_dummy', { pos: [11, 7] }); // [1,4] of hers: outside 4-9 (and 3-8), inside its 3×3
assert.ok(u.rangeKeySet.has(11 * 21 + 7), 'in her range');
u.skill.gainSp(999);
assert.ok(h.runUntil(() => u.skill.active, 1), `${mod}: S3 cast for an enemy of the area only`);
u.skill.end('test');
u.skill.sp = 0;
h.b.addBuff(u, { key: 'test:noSp', flags: { noSp: true } });
h.run(1); // S3's arrows land
// priority: an enemy in her own range nearer the goal loses to the one of the area
const near = h.spawn('enemy_dummy', { pos: [10, 4] });
const atkAt = [];
h.b.on('damaged', (c) => { if (c.source === u && c.dmg.isAttack) atkAt.push([c, u.s.atk]); }, { priority: -100 });
h.run(3);
assert.ok(atkAt.length >= 1 && atkAt.every(([c]) => c.target === away), `${mod}: she shoots the area's enemy first`);
for (const [c, atk] of atkAt) approx(c.amount, atk * 1.2 * (mod === HY ? 1.33 / 1.2 : 1) * (1 + ds), `${mod}: ×${1 + ds} in the area`);
h.b.kill(away, null);
const n = atkAt.length;
h.run(3);
for (const [c, atk] of atkAt.slice(n)) { assert.equal(c.target, near); approx(c.amount, atk * (mod === HY ? 1.33 : 1.2), 'no bonus outside'); }
// it leaves after its 25 s, her range is her own again
const life = tokOf(tier, elite, mod).talents[0].bb.duration;
assert.equal(life, 25);
assert.ok(h.runUntil(() => !t.alive, 30), 'leaves');
approx(h.b.time, life + h.b.dt, `${mod}: after ${life} s`, 0.02);
assert.ok(!u.rangeKeySet.has(11 * 21 + 7), 'her range back');
// back after its redeploy time, paying 3 DP
h.b.players[0].dp = 10;
const left = h.b.time;
assert.ok(h.runUntil(() => t.alive, resp + 2), `${mod}: back`);
approx(h.b.time - left, resp, `${mod}: after ${resp} s`, 0.3);
assert.deepEqual([t.tileR, t.tileC, h.b.players[0].dp], [10, 6, 7], `${mod}: on its tile, 3 DP paid`);
done(h);
}
}
});
test('沙地兽 with S2: 广域警觉 cuts its redeploy time by 20 % / 30 % while on; its passive gives back the bullets that hit in its area when it leaves; withdrawn when 莱伊 leaves, back once she is', () => {
for (const [tier, elite, mod, resp] of [[5, false, null, 30], [6, true, null, 30], [6, true, HX, 20]]) {
const sk = skillOf(tier, elite, S2);
const { h, u, t } = field({ tier, elite, mod, skill: 1, beast: [10, 6] });
const e = h.spawn('enemy_dummy', { pos: [11, 7] }); // in its area only
// the bullets that hit in its area: counted, given back when it leaves
h.runUntil(() => u.trait.ammo <= 3, 20);
const spent = 8 - u.trait.ammo;
h.b.addBuff(u, { key: 'test:disarm', flags: { disarm: true } });
h.run(1);
const before = u.trait.ammo;
assert.ok(h.runUntil(() => !t.alive, 30), 'leaves');
assert.equal(u.trait.ammo, Math.min(8, before + spent), `T${tier}: ${spent} bullets back`);
h.b.removeBuff(u, 'test:disarm');
h.b.kill(e, null);
// S2 on ⇒ redeploy ×(1 + respawn_time)
u.skill.gainSp(999, 'init');
h.step();
assert.ok(u.skill.active, 'S2 on');
const left = h.b.time;
assert.ok(h.runUntil(() => t.alive, resp + 2), 'back');
approx(h.b.time - left, resp * (1 + sk.bb.respawn_time), `T${tier} ${mod}: ${resp} × ${1 + sk.bb.respawn_time} s`, 0.3);
// 莱伊 leaves: the 沙地兽 goes too; it waits for her
h.b.retreat(u);
h.step();
assert.ok(!t.alive, 'withdrawn with her');
h.run(resp + 5);
assert.ok(!t.alive, 'not back while she is away');
h.b.redeploy(u);
assert.ok(h.runUntil(() => t.alive, 2), 'back with her');
done(h);
}
});