feedback5: merge O8 — 自选 kits for 闪灵, 夜莺 (with her 幻影) and 嵯峨 (劝善's 重伤); engine: a shield may be limited to one damage type (shieldType), a profile may skip enemies it never targets (skipEnemy); golden: only diy moved
This commit is contained in:
commit
89ec6aabb6
14 files changed
+1938
-125
No files matched your search
@@ -0,0 +1,303 @@
|
||||
// test/content/op_cgbird.test.js — the 自选 operator kit of 夜莺 (char_179_cgbird, 6★ 群愈师; kit
|
||||
// server/sim/content/kits/ops/op-cgbird.js) and her summon 幻影 (token_10003_cgbird_bird), fielded the production way (a DIY
|
||||
// slot + its `diy` pick, simdata getDiy; the 幻影 as a board token piece of hers) in every form: tiers 5 / 6, normal (E2 Lv1,
|
||||
// skill rank 4, no module) and elite (E2 Lv60, rank 7) with no module, RIN-X “封闭的希望” or RIN-Y “莺歌” at stage 1
|
||||
// (tier 5) / 3 (tier 6). Every number is read back from data/backups.json; the fidelity checklist of kits/README.md.
|
||||
// Run: node --test test/content/op_cgbird.test.js
|
||||
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { makeBattle, enemyRec, chessRec, checkInvariants } from '../helpers/battleHarness.js';
|
||||
import { KITTED_CHARS, OPERATOR_KITS, KITS } from '../../server/sim/content/kits/index.js';
|
||||
import { diyPool, validateDiyPicks, diyRecord } from '../../shared/diy.js';
|
||||
import { attackRangeGrid } from '../../shared/loadoutRecord.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 CGBIRD = 'char_179_cgbird';
|
||||
const PHANTOM = 'token_10003_cgbird_bird';
|
||||
const FORMS = BACKUPS.units[CGBIRD].forms;
|
||||
const SLOT = { 5: 'chess_char_5_diy1_a', 6: 'chess_char_6_diy1_a' };
|
||||
const RINX = 'uniequip_002_cgbird', RINY = 'uniequip_003_cgbird';
|
||||
const S1 = 'skcom_heal_up[3]', S2 = 'skchr_cgbird_2', S3 = 'skchr_cgbird_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);
|
||||
const tokenVariant = (tier, elite, mod) => {
|
||||
const v = BACKUPS.tokens[PHANTOM].variants[`${CGBIRD}@${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 ENEMIES = { enemy_dummy: enemyRec({ key: 'enemy_dummy', hp: 1e9, speed: 0, mass: 0 }) };
|
||||
const ALLIES = { test_melee_a: chessRec({ id: 'test_melee_a', profession: 'WARRIOR', stats: { maxHp: 10000, def: 100, res: 10, atk: 0 }, skill: null }) };
|
||||
const FORMS_ALL = [[5, false, null], [6, false, null], ...[5, 6].flatMap((t) => [null, RINX, RINY].map((m) => [t, true, m]))];
|
||||
const label = ([tier, elite, mod]) => `T${tier} ${elite ? 'elite' : 'normal'} ${mod ?? 'none'}`;
|
||||
|
||||
/**
|
||||
* 夜莺 as uid 1 on the 高台 tile (11,2) facing RIGHT — her y-2: rows 10–12, cols 1–4; RIN-X adds (11,5); 圣域's y-4 adds
|
||||
* (11,5) and (9,1)–(9,3) —, allies (melee, no skill) at (11,3) uid 2, (10,3) uid 3, (12,3) uid 4, (10,4) uid 5 (all in
|
||||
* y-2), (11,5) uid 6 (RIN-X / y-4 only), (9,3) uid 7 (y-4 only), (11,8) uid 8 (outside); `phantom` = a board 幻影 of hers.
|
||||
*/
|
||||
function field({ tier = 5, elite = false, mod = null, skill = 0, seed = 5, phantom = null, dp = 0 } = {}) {
|
||||
const ally = (uid, row, col) => ({ uid, chessId: 'test_melee_a', row, col });
|
||||
const h = makeBattle({
|
||||
defs: { enemies: ENEMIES, chess: ALLIES }, timeLimit: 900, autoFinish: false, seed,
|
||||
flags: { dpPerSec: 0, dpMax: 999, dpInit: dp }, hooks: ['damaged', 'heal', 'attack', 'skillStart', 'skillEnd', 'death', 'deploy'], captureNoisy: true,
|
||||
units: [
|
||||
{ uid: 1, diy: { slot: SLOT[tier], charId: CGBIRD, skillIndex: skill, uniEquipId: mod }, elite, row: 11, col: 2 },
|
||||
ally(2, 11, 3), ally(3, 10, 3), ally(4, 12, 3), ally(5, 10, 4), ally(6, 11, 5), ally(7, 9, 3), ally(8, 11, 8),
|
||||
...(phantom ? [{ uid: 9, kind: 'token', tokenId: PHANTOM, ownerUid: 1, row: phantom[0], col: phantom[1] }] : []),
|
||||
],
|
||||
});
|
||||
h.step();
|
||||
const u = h.unit(1);
|
||||
return { h, u, a: (uid) => h.unit(uid), bird: phantom ? h.b.allyUnits.find((t) => t.kind === 'token' && t.uid === 9) : null };
|
||||
}
|
||||
function done(h) {
|
||||
checkInvariants(h.b);
|
||||
assert.equal(h.b.errors.length, 0, JSON.stringify(h.b.errors[0]));
|
||||
}
|
||||
const rangeOf = (tier, elite, mod) => {
|
||||
const rec = diyRecord(SLOT[tier], { charId: CGBIRD, skillIndex: 0, uniEquipId: mod }, { elite, data: { chess: CHESS, backups: BACKUPS } });
|
||||
return attackRangeGrid(rec);
|
||||
};
|
||||
|
||||
test('夜莺 in every 自选 form: her operator kit (all three skills authored), the form\'s stats + module attributes, y-2 (RIN-X: its grid), 3 heals (RIN-Y: 4), no 特质', () => {
|
||||
assert.equal(OPERATOR_KITS[CGBIRD], KITS[CGBIRD]);
|
||||
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], [CGBIRD, SLOT[tier], form.skills[skill].skillId, false, 'skills'], label(f));
|
||||
assert.deepEqual([u.base.maxHp, u.base.atk, u.base.def, u.base.res, u.base.aspd],
|
||||
[form.stats.maxHp + (m?.attr.maxHp ?? 0), form.stats.atk + (m?.attr.atk ?? 0), form.stats.def, form.stats.res + (m?.attr.res ?? 0), form.stats.aspd + (m?.attr.aspd ?? 0)], `${label(f)}: stats`);
|
||||
assert.deepEqual([u.profile.dmgType, u.profile.heal?.mode, u.profile.heal?.count, u.profile.attack], ['heal', 'multi', elite && mod === RINY ? 4 : 3, 'ranged'], `${label(f)}: 群愈师`);
|
||||
const rinx = elite && mod === RINX;
|
||||
const mg = rinx ? modOf(tier, RINX).talentChanges.find((t) => t.talentIndex === -1).rangeGrid : form.rangeGrid;
|
||||
assert.deepEqual(u.liveRangeGrid, mg, `${label(f)}: range`);
|
||||
assert.deepEqual(u.liveRangeGrid, rangeOf(tier, elite, mod), `${label(f)}: the range the card draws (attackRangeGrid)`);
|
||||
assert.equal(mg.length, rinx ? 13 : 12, `${label(f)}: y-2 (+ [0,3])`);
|
||||
assert.deepEqual([u.def.bonds, u.def.raw.garrisonIds], [['emptyShip'], []], `${label(f)}: bonds / 特质`);
|
||||
assert.ok(!u.s.flags.liftoff && !u.s.flags.camou && !u.s.flags.stealth && !u.s.flags.untargetable, `${label(f)}: enemies target her`);
|
||||
done(h);
|
||||
}
|
||||
}
|
||||
assert.deepEqual([modOf(5, RINX).attr, modOf(6, RINX).attr, modOf(5, RINY).attr, modOf(6, RINY).attr], [{ atk: 40, res: 5 }, { atk: 65, res: 5 }, { maxHp: 160, aspd: 5 }, { maxHp: 220, aspd: 7 }]);
|
||||
});
|
||||
|
||||
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(CGBIRD));
|
||||
for (const t of [5, 6]) assert.ok(diyPool(t, { data, kitted: KITTED_CHARS }).includes(CGBIRD), `tier ${t}`);
|
||||
assert.deepEqual(validateDiyPicks({ [SLOT[6]]: { charId: CGBIRD, skillIndex: 1, uniEquipId: RINY } }, { data, kitted: KITTED_CHARS }),
|
||||
{ ok: true, picks: { [SLOT[6]]: { charId: CGBIRD, skillIndex: 1, uniEquipId: RINY } } });
|
||||
});
|
||||
|
||||
test('群愈师 heals 3 allies at once; RIN-Y “莺歌” 4 (stages 1 and 3)', () => {
|
||||
for (const f of [[5, false, null], [5, true, RINY], [6, true, RINY], [6, true, RINX]]) {
|
||||
const [tier, elite, mod] = f;
|
||||
const { h, u, a } = field({ tier, elite, mod, skill: 0 });
|
||||
for (const uid of [2, 3, 4, 5]) a(uid).hp = 1000 + uid;
|
||||
const n0 = h.hooksOf('attack').length;
|
||||
assert.ok(h.runUntil(() => h.hooksOf('attack').slice(n0).some((c) => c.attacker === u), 6), label(f));
|
||||
const at = h.hooksOf('attack').slice(n0).find((c) => c.attacker === u);
|
||||
assert.equal(new Set(at.targets.map((t) => t.uid)).size, elite && mod === RINY ? 4 : 3, `${label(f)}: heals per attack`);
|
||||
done(h);
|
||||
}
|
||||
});
|
||||
|
||||
test('S1 治疗强化·γ型 (MANUAL, data DEFAULT): 30 s of ATK +55 % / +70 %, cast on an injured ally in range; 35 / 32 SP from 20', () => {
|
||||
for (const [tier, elite] of [[5, false], [6, true]]) {
|
||||
const sk = skillOf(tier, elite, S1);
|
||||
const { h, u, a } = field({ tier, elite, mod: elite ? RINX : null, skill: 0 });
|
||||
assert.deepEqual([u.skill.rule, u.skill.spCost, sk.initSp, sk.duration, sk.bb.atk], ['DEFAULT', elite ? 32 : 35, 20, 30, elite ? 0.7 : 0.55], `T${tier}`);
|
||||
u.skill.gainSp(999);
|
||||
a(8).hp = 100; // outside her range: no cast
|
||||
h.run(2);
|
||||
assert.equal(u.skill.activations, 0, `T${tier}: nobody injured in range`);
|
||||
a(2).hp = 100;
|
||||
assert.ok(h.runUntil(() => u.skill.active, 5), `T${tier}: cast`);
|
||||
approx(u.skill.timeLeft, 30, `T${tier}: 30 s`, 0.01);
|
||||
approx(u.s.atk, u.base.atk * (1 + sk.bb.atk), `T${tier}: ATK`);
|
||||
h.runUntil(() => !u.skill.active, 35);
|
||||
approx(u.s.atk, u.base.atk, `T${tier}: back`);
|
||||
done(h);
|
||||
}
|
||||
});
|
||||
|
||||
test('S2 法术护盾 (AUTO, data DEFAULT, 2 charges): the next heal gives each of its targets a 屏障 of 50 % / 60 % ATK for 3.5 / 4 s that absorbs arts damage only, and RES +10 / +15 while it holds', () => {
|
||||
for (const f of [[5, false, null], [6, true, RINY]]) {
|
||||
const [tier, elite, mod] = f;
|
||||
const sk = skillOf(tier, elite, S2);
|
||||
const { h, u, a } = field({ tier, elite, mod, skill: 1 });
|
||||
assert.deepEqual([u.skill.rule, u.skill.maxCharges, u.skill.kind, sk.spCost, sk.bb.atk_scale, sk.bb.duration, sk.bb.magic_resistance],
|
||||
['DEFAULT', 2, 'charges', 10, elite ? 0.6 : 0.5, elite ? 4 : 3.5, elite ? 15 : 10], label(f));
|
||||
u.skill.gainSp(999);
|
||||
h.run(2);
|
||||
assert.equal(u.skill.activations, 0, `${label(f)}: nobody injured, no cast`);
|
||||
const hurt = [2, 3, 4, 5].map(a);
|
||||
hurt.forEach((x, i) => { x.hp = 1000 + i; });
|
||||
assert.ok(h.runUntil(() => u.skill.activations === 1 && hurt.some((x) => x.findBuff('cgbird:barrier')), 5), `${label(f)}: cast with a heal`);
|
||||
const got = hurt.filter((x) => x.findBuff('cgbird:barrier'));
|
||||
const first = got.map((x) => x.findBuff('cgbird:barrier'));
|
||||
assert.equal(got.length, elite && mod === RINY ? 4 : 3, `${label(f)}: every target of that heal`);
|
||||
for (const x of got) {
|
||||
const b = x.findBuff('cgbird:barrier');
|
||||
approx(b.shield, u.s.atk * sk.bb.atk_scale, `${label(f)}: ${sk.bb.atk_scale * 100} % ATK`);
|
||||
approx(b.duration, sk.bb.duration, `${label(f)}: ${sk.bb.duration} s`);
|
||||
assert.equal(b.shieldType, 'arts', `${label(f)}: arts only`);
|
||||
assert.deepEqual(x.findBuff('cgbird:barrierRes')?.mods, { resFlat: sk.bb.magic_resistance }, `${label(f)}: RES bonus`);
|
||||
}
|
||||
const x = got[0], b = x.findBuff('cgbird:barrier');
|
||||
const hp0 = x.hp, sh0 = b.shield;
|
||||
h.b.dealDamage(null, x, { amount: 50, type: 'phys', canDodge: false });
|
||||
assert.ok(x.hp < hp0, `${label(f)}: physical damage passes`);
|
||||
approx(b.shield, sh0, `${label(f)}: the barrier untouched by physical damage`);
|
||||
h.b.dealDamage(null, x, { amount: 20, type: 'true' });
|
||||
approx(b.shield, sh0, `${label(f)}: … and by true damage`);
|
||||
const hp1 = x.hp;
|
||||
h.b.dealDamage(null, x, { amount: 30, type: 'arts', canDodge: false });
|
||||
approx(x.hp, hp1, `${label(f)}: arts damage absorbed`);
|
||||
assert.ok(b.shield < sh0, `${label(f)}: the barrier took it`);
|
||||
h.b.dealDamage(null, x, { amount: 1e6, type: 'arts', canDodge: false, resIgnorePct: 1 });
|
||||
assert.equal(x.findBuff('cgbird:barrier'), null, `${label(f)}: broken`);
|
||||
assert.equal(x.findBuff('cgbird:barrierRes'), null, `${label(f)}: the RES bonus goes with it`);
|
||||
h.run(sk.bb.duration + 0.1);
|
||||
got.forEach((y, i) => assert.ok(!y.buffs.includes(first[i]), `${label(f)}: the first heal's barrier expired`));
|
||||
done(h);
|
||||
}
|
||||
});
|
||||
|
||||
test('S3 圣域 (MANUAL, data ACTIVE_RANGE on y-4): cast for an injured ally inside y-4 only; 60 s, range y-4, ATK +40 % / +50 %, allies in it RES ×1.9 / ×2.05 and 15 % / 20 % arts dodge; all back after', () => {
|
||||
for (const f of [[5, false, null], [6, true, null], [6, true, RINX]]) {
|
||||
const [tier, elite, mod] = f;
|
||||
const sk = skillOf(tier, elite, S3);
|
||||
const { h, u, a } = field({ tier, elite, mod, skill: 2 });
|
||||
assert.deepEqual([u.skill.rule, sk.duration, sk.spCost, sk.rangeId, sk.bb.atk, sk.bb.magic_resistance, sk.bb.prob],
|
||||
['ACTIVE_RANGE', 60, 120, 'y-4', elite ? 0.5 : 0.4, elite ? 1.05 : 0.9, elite ? 0.2 : 0.15], label(f));
|
||||
assert.deepEqual(sk.trigger.customRangeGrid, sk.rangeGrid, `${label(f)}: the trigger grid is its running range`);
|
||||
const base = u.liveRangeGrid;
|
||||
u.skill.gainSp(999);
|
||||
a(8).hp = 100; // outside y-4
|
||||
h.run(2);
|
||||
assert.equal(u.skill.activations, 0, `${label(f)}: no injured ally in y-4`);
|
||||
a(7).hp = 100; // (9,3): y-4 only
|
||||
assert.ok(h.runUntil(() => u.skill.active, 2), `${label(f)}: cast for the ally 2 rows down`);
|
||||
assert.deepEqual(u.liveRangeGrid, sk.rangeGrid, `${label(f)}: y-4 while it runs`);
|
||||
h.run(0.3);
|
||||
approx(u.s.atk, u.base.atk * (1 + sk.bb.atk), `${label(f)}: ATK`);
|
||||
for (const uid of [2, 6, 7]) assert.deepEqual(a(uid).findBuff('skill:cgbird:sanctuary')?.mods, { resMul: 1 + sk.bb.magic_resistance, dodgeArts: sk.bb.prob }, `${label(f)}: uid ${uid} in y-4`);
|
||||
assert.deepEqual(u.findBuff('skill:cgbird:sanctuary')?.mods, { resMul: 1 + sk.bb.magic_resistance, dodgeArts: sk.bb.prob }, `${label(f)}: herself`);
|
||||
assert.equal(a(8).findBuff('skill:cgbird:sanctuary'), null, `${label(f)}: outside`);
|
||||
// RES = (10 + 15 talent) × (1 + v) on an ally (base 10)
|
||||
approx(a(7).s.res, Math.min(100, (10 + 15) * (1 + sk.bb.magic_resistance)), `${label(f)}: RES`);
|
||||
approx(a(7).s.dodgeArts, sk.bb.prob, `${label(f)}: arts dodge`);
|
||||
u.skill.end('test');
|
||||
h.run(0.3);
|
||||
assert.deepEqual(u.liveRangeGrid, base, `${label(f)}: own range back`);
|
||||
for (const uid of [2, 6, 7]) assert.equal(a(uid).findBuff('skill:cgbird:sanctuary'), null, `${label(f)}: uid ${uid} after`);
|
||||
done(h);
|
||||
}
|
||||
});
|
||||
|
||||
test('T1 白恶魔的庇护: allies in her range RES +15 (herself too, not outside); RIN-X: its range tile too, stage 3 also 受到的治疗效果 ×1.05', () => {
|
||||
for (const f of FORMS_ALL) {
|
||||
const [tier, elite, mod] = f;
|
||||
const { h, u, a } = field({ tier, elite, mod, skill: 0 });
|
||||
h.run(0.3);
|
||||
const rinx = elite && mod === RINX, x3 = rinx && tier === 6;
|
||||
const want = x3 ? { resFlat: 15, healingTakenMul: 1.05 } : { resFlat: 15 };
|
||||
for (const uid of [2, 3, 4, 5]) assert.deepEqual(a(uid).findBuff('talent:cgbird:res')?.mods, want, `${label(f)}: uid ${uid}`);
|
||||
assert.deepEqual(u.findBuff('talent:cgbird:res')?.mods, want, `${label(f)}: herself`);
|
||||
assert.deepEqual(a(6).findBuff('talent:cgbird:res')?.mods ?? null, rinx ? want : null, `${label(f)}: (11,5) — the RIN-X tile`);
|
||||
for (const uid of [7, 8]) assert.equal(a(uid).findBuff('talent:cgbird:res'), null, `${label(f)}: uid ${uid} outside`);
|
||||
approx(a(2).s.res, 10 + 15, `${label(f)}: RES`);
|
||||
if (x3) {
|
||||
a(2).hp = 1000;
|
||||
const n0 = h.hooksOf('heal').length;
|
||||
assert.ok(h.runUntil(() => h.hooksOf('heal').slice(n0).some((c) => c.target === a(2) && c.source === u), 6));
|
||||
const c = h.hooksOf('heal').slice(n0).find((x) => x.target === a(2) && x.source === u);
|
||||
approx(c.amount, u.s.atk * 1.05, `${label(f)}: healing received ×1.05`);
|
||||
}
|
||||
done(h);
|
||||
}
|
||||
});
|
||||
|
||||
test('幻影 (T2): the token of her form — HP 3000 / 4989, RES 75, blocks nothing, taunt 1, no attack; 30 % physical dodge (RIN-Y stage 3: 40 %), loses 3 % of its max HP each second', () => {
|
||||
for (const f of FORMS_ALL) {
|
||||
const [tier, elite, mod] = f;
|
||||
const { h, u, bird } = field({ tier, elite, mod, skill: 0, phantom: [12, 8] }); // outside her range: no heals on it
|
||||
const v = tokenVariant(tier, elite, mod);
|
||||
assert.ok(bird && bird.alive, `${label(f)}: deployed with the board`);
|
||||
assert.equal(bird.ownerUnit, u, `${label(f)}: hers`);
|
||||
assert.deepEqual([bird.base.maxHp, bird.base.res, bird.s.blockCnt, bird.s.taunt, bird.profile.noAttack], [v.stats.maxHp, 75, 0, 1, true], `${label(f)}: stats`);
|
||||
assert.equal(v.stats.maxHp, elite ? 4989 : 3000);
|
||||
const y3 = elite && tier === 6 && mod === RINY;
|
||||
approx(bird.s.dodgePhys, y3 ? 0.4 : 0.3, `${label(f)}: physical dodge`);
|
||||
assert.equal(bird.s.dodgeArts, 0, `${label(f)}: no arts dodge`);
|
||||
const hp0 = bird.hp;
|
||||
h.run(3.02);
|
||||
approx(hp0 - bird.hp, 3 * 0.03 * bird.s.maxHp, `${label(f)}: 3 × 3 % in 3 s`, 1e-6);
|
||||
assert.ok(h.hooksOf('damaged').some((c) => c.target === bird && c.dmg?.tags?.includes('hpLoss')), `${label(f)}: a 流失`);
|
||||
// enemies: a 30 % dodge on physical hits, none on arts
|
||||
let dodged = 0;
|
||||
for (let i = 0; i < 400; i++) if (h.b.dealDamage(null, bird, { amount: 1, type: 'phys' }) === 0) dodged++;
|
||||
assert.ok(Math.abs(dodged / 400 - (y3 ? 0.4 : 0.3)) < 0.08, `${label(f)}: ${dodged} / 400 dodged`);
|
||||
done(h);
|
||||
}
|
||||
});
|
||||
|
||||
test('幻影: each 夜莺 deployment adds 2 (RIN-Y stage 3: 3) to her stock, at most 3; a fallen 幻影 comes back on its tile 20 s later using one and paying 5 DP; it stays when she leaves', () => {
|
||||
for (const f of [[5, true, RINY], [6, true, RINY], [6, false, null]]) {
|
||||
const [tier, elite, mod] = f;
|
||||
const { h, u, bird } = field({ tier, elite, mod, skill: 0, phantom: [12, 8], dp: 50 });
|
||||
const cnt = elite && tier === 6 && mod === RINY ? 3 : 2;
|
||||
assert.equal(u.mem.phantomStock, cnt, `${label(f)}: her deployment gave ${cnt}; the board piece used none`);
|
||||
const tile = [bird.tileR, bird.tileC];
|
||||
h.b.kill(bird, null);
|
||||
assert.ok(!bird.alive && !bird.removed, `${label(f)}: fallen, kept`);
|
||||
h.run(19.5);
|
||||
assert.ok(!bird.alive, `${label(f)}: not before its 20 s`);
|
||||
const dp0 = h.b.players[0].dp;
|
||||
assert.ok(h.runUntil(() => bird.alive, 1), `${label(f)}: back after 20 s`);
|
||||
assert.deepEqual([bird.tileR, bird.tileC], tile, `${label(f)}: on its own tile`);
|
||||
assert.equal(u.mem.phantomStock, cnt - 1, `${label(f)}: one used`);
|
||||
approx(dp0 - h.b.players[0].dp, 5, `${label(f)}: its DP cost`);
|
||||
approx(bird.hp, bird.s.maxHp, `${label(f)}: full HP`, 0.05);
|
||||
approx(bird.s.dodgePhys, tokenVariant(tier, elite, mod).talents.at(-1).bb.prob, `${label(f)}: its talent again`);
|
||||
// she leaves: the deployed 幻影 stays; she comes back: +cnt (cap 3)
|
||||
h.b.retreat(u);
|
||||
h.step();
|
||||
assert.ok(bird.alive, `${label(f)}: stays when she leaves`);
|
||||
h.b.redeploy(u, { free: true });
|
||||
assert.equal(u.mem.phantomStock, Math.min(3, cnt - 1 + cnt), `${label(f)}: +${cnt}, at most 3`);
|
||||
// none held: a fallen 幻影 waits
|
||||
u.mem.phantomStock = 0;
|
||||
h.b.kill(bird, null);
|
||||
h.run(30);
|
||||
assert.ok(!bird.alive, `${label(f)}: no 幻影 held, none comes`);
|
||||
u.mem.phantomStock = 1;
|
||||
assert.ok(h.runUntil(() => bird.alive, 1), `${label(f)}: comes as soon as one is held`);
|
||||
assert.equal(u.mem.phantomStock, 0);
|
||||
done(h);
|
||||
}
|
||||
});
|
||||
|
||||
test('幻影 without DP waits for it; 夜莺 heals her 幻影 (an injured 友方单位 in range) and her S2 barrier reaches it', () => {
|
||||
const { h, u, bird } = field({ tier: 6, elite: true, mod: RINY, skill: 1, phantom: [12, 4], dp: 0 });
|
||||
// the drain makes it an injured ally of her range
|
||||
u.skill.gainSp(999);
|
||||
assert.ok(h.runUntil(() => bird.findBuff('cgbird:barrier'), 6), 'barrier on the 幻影 with the next heal');
|
||||
assert.ok(h.hooksOf('heal').some((c) => c.source === u && c.target === bird), 'healed');
|
||||
h.b.kill(bird, null);
|
||||
h.run(25);
|
||||
assert.ok(!bird.alive, 'no DP: still down');
|
||||
h.b.players[0].dp = 5;
|
||||
assert.ok(h.runUntil(() => bird.alive, 1), 'back once the DP is there');
|
||||
approx(h.b.players[0].dp, 0, 'paid 5');
|
||||
done(h);
|
||||
});
|
||||
@@ -0,0 +1,379 @@
|
||||
// test/content/op_saga.test.js — the 自选 operator kit of 嵯峨 (char_362_saga, 6★ 尖兵; kit
|
||||
// server/sim/content/kits/ops/op-saga.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, SOL-Y 身向云泥 or
|
||||
// SOL-X 何处寻驮? at stage 1 (tier 5) / 3 (tier 6). Every number is read back from data/backups.json; the fidelity
|
||||
// checklist of kits/README.md item by item (劝善's 重伤 per PRTS 术语释义 重伤 / the talent and S2 备注).
|
||||
// Run: node --test test/content/op_saga.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 { DYING, S2_CHECK, isDying } from '../../server/sim/content/kits/ops/op-saga.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 SAGA = 'char_362_saga';
|
||||
const FORMS = BACKUPS.units[SAGA].forms;
|
||||
const SLOT = { 5: 'chess_char_5_diy1_a', 6: 'chess_char_6_diy1_a' };
|
||||
const SOLY = 'uniequip_002_saga', SOLX = 'uniequip_003_saga';
|
||||
const S1 = 'skcom_charge_cost[3]', S2 = 'skchr_saga_2', S3 = 'skchr_saga_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: 100 }),
|
||||
enemy_walk: enemyRec({ key: 'enemy_walk', hp: 1e9, speed: 0.6, mass: 0 }),
|
||||
};
|
||||
// a regenerating enemy (data/enemies.json has two: 200 HP/s for enemy_1061_zomshd)
|
||||
ENEMIES.enemy_regen = { ...dummy('enemy_regen', { hp: 100 }), stats: { ...dummy('enemy_regen', { hp: 100 }).stats, hpRecoveryPerSec: 200 } };
|
||||
const FORMS_ALL = [[5, false, null], [6, false, null], ...[5, 6].flatMap((t) => [null, SOLY, SOLX].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 = 0, row = 10, col = 5, others = [], seed = 5, dp = 0 } = {}) {
|
||||
const h = makeBattle({
|
||||
defs: { enemies: ENEMIES }, timeLimit: 900, autoFinish: false, seed,
|
||||
flags: { dpPerSec: 0, dpMax: 999, dpInit: dp }, hooks: ['damaged', 'skillStart', 'skillEnd', 'kill', 'death', 'spGain', 'attack'], captureNoisy: true,
|
||||
units: [{ uid: 1, diy: { slot: SLOT[tier], charId: SAGA, skillIndex: skill, uniEquipId: mod }, elite, row, col }, ...others],
|
||||
});
|
||||
h.step();
|
||||
return { h, u: h.unit(1) };
|
||||
}
|
||||
const hitsBy = (h, u, from = 0) => h.hooksOf('damaged').slice(from).filter((c) => c.source === u && c.target?.side === 'enemy');
|
||||
function done(h) {
|
||||
checkInvariants(h.b);
|
||||
assert.equal(h.b.errors.length, 0, JSON.stringify(h.b.errors[0]));
|
||||
}
|
||||
|
||||
test('嵯峨 in every 自选 form: her operator kit (all three skills authored), the form\'s stats + module attributes, 1-1, blocks 2, melee ground-only, no 特质', () => {
|
||||
assert.equal(OPERATOR_KITS[SAGA], KITS[SAGA]);
|
||||
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], [SAGA, SLOT[tier], form.skills[skill].skillId, false, 'skills'], label(f));
|
||||
assert.deepEqual([u.base.maxHp, u.base.atk, u.base.def], [form.stats.maxHp + (m?.attr.maxHp ?? 0), form.stats.atk + (m?.attr.atk ?? 0), form.stats.def + (m?.attr.def ?? 0)], `${label(f)}: stats`);
|
||||
assert.deepEqual([u.s.blockCnt, u.profile.attack, u.profile.dmgType, u.profile.canHitFly, u.base.bat, typeof u.profile.skipEnemy], [2, 'melee', 'phys', false, 1.05, 'function'], `${label(f)}: 尖兵`);
|
||||
assert.deepEqual(u.liveRangeGrid, form.rangeGrid, `${label(f)}: 1-1`);
|
||||
assert.deepEqual([u.def.bonds, u.def.raw.garrisonIds], [['emptyShip'], []], `${label(f)}: bonds / 特质`);
|
||||
assert.ok(!u.s.flags.liftoff && !u.s.flags.camou && !u.s.flags.stealth, `${label(f)}: ground enemies target her`);
|
||||
done(h);
|
||||
}
|
||||
}
|
||||
// E2 Lv1 1609 / 434 / 297, E2 Lv60 2004 / 498 / 347; SOL-Y +75 / +45 / +15 → +125 / +55 / +20, SOL-X +50 / +28 → +70 / +44
|
||||
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], [1609, 434, 2004, 498]);
|
||||
assert.deepEqual([modOf(5, SOLY).attr, modOf(6, SOLY).attr, modOf(5, SOLX).attr, modOf(6, SOLX).attr],
|
||||
[{ maxHp: 75, atk: 45, def: 15 }, { maxHp: 125, atk: 55, def: 20 }, { atk: 50, def: 28 }, { atk: 70, def: 44 }]);
|
||||
});
|
||||
|
||||
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(SAGA));
|
||||
for (const t of [5, 6]) assert.ok(diyPool(t, { data, kitted: KITTED_CHARS }).includes(SAGA), `tier ${t}`);
|
||||
assert.deepEqual(validateDiyPicks({ [SLOT[5]]: { charId: SAGA, skillIndex: 1, uniEquipId: SOLX } }, { data, kitted: KITTED_CHARS }),
|
||||
{ ok: true, picks: { [SLOT[5]]: { charId: SAGA, skillIndex: 1, uniEquipId: SOLX } } });
|
||||
});
|
||||
|
||||
test('melee, ground-only: no attack on a flyer in her range; a ground enemy there is attacked (physical, 100 % ATK)', () => {
|
||||
const { h, u } = field({ tier: 5, skill: 0 });
|
||||
const fly = h.spawn('enemy_fly', { pos: [10, 6] });
|
||||
h.run(3);
|
||||
assert.equal(hitsBy(h, u).filter((c) => c.target === fly).length, 0, 'flyer untouched');
|
||||
const e = h.spawn('enemy_dummy', { pos: [10, 6] });
|
||||
assert.ok(h.runUntil(() => hitsBy(h, u).some((c) => c.target === e), 3));
|
||||
const c = hitsBy(h, u).find((x) => x.target === e);
|
||||
assert.deepEqual([c.type, c.dmg.isAttack], ['phys', true]);
|
||||
approx(c.amount, u.s.atk, '100 % ATK');
|
||||
done(h);
|
||||
});
|
||||
|
||||
test('S1 冲锋号令·γ型 (AUTO): +12 DP as soon as its SP is full — no enemy needed (SP_FULL); 41 / 38 SP from 12 / 14', () => {
|
||||
for (const [tier, elite] of [[5, false], [6, true]]) {
|
||||
const sk = skillOf(tier, elite, S1);
|
||||
const { h, u } = field({ tier, elite, mod: elite ? SOLX : null, skill: 0 });
|
||||
assert.deepEqual([u.skill.rule, u.skill.spCost, sk.initSp, sk.bb.cost], ['SP_FULL', elite ? 38 : 41, elite ? 14 : 12, 12], `T${tier}`);
|
||||
h.b.players[0].dp = 0;
|
||||
h.run(sk.spCost - sk.initSp - 0.5);
|
||||
assert.equal(u.skill.activations, 0, `T${tier}: not before`);
|
||||
assert.ok(h.runUntil(() => u.skill.activations === 1, 1), `T${tier}: at full SP, no enemy`);
|
||||
approx(h.b.players[0].dp, 12, `T${tier}: +12 DP`);
|
||||
done(h);
|
||||
}
|
||||
});
|
||||
|
||||
test('S2 除恶 (MANUAL, data SKILL_RANGE on x-6, 2 charges): +4 DP; the cross\'s ground enemies take 280 % / 320 % ATK physical — at most 6, flyers and other tiles untouched', () => {
|
||||
for (const [tier, elite] of [[5, false], [6, true]]) {
|
||||
const sk = skillOf(tier, elite, S2);
|
||||
const { h, u } = field({ tier, elite, mod: elite ? SOLY : null, skill: 1 });
|
||||
assert.deepEqual([u.skill.rule, u.skill.maxCharges, sk.rangeId, sk.bb.atk_scale, sk.bb.cost, sk.spCost, sk.initSp], ['SKILL_RANGE', 2, 'x-6', elite ? 3.2 : 2.8, 4, elite ? 16 : 18, elite ? 10 : 9], `T${tier}`);
|
||||
assert.match(sk.desc, /最多6名地面敌人/);
|
||||
const cross = [[12, 5], [11, 5], [10, 3], [10, 4], [10, 6], [10, 7], [9, 5]];
|
||||
const ground = cross.map((pos) => h.spawn('enemy_dummy', { pos }));
|
||||
const fly = h.spawn('enemy_fly', { pos: [8, 5] });
|
||||
const diag = h.spawn('enemy_dummy', { pos: [11, 6] });
|
||||
h.b.players[0].dp = 0;
|
||||
const n0 = hitsBy(h, u).length;
|
||||
u.skill.gainSp(999);
|
||||
assert.ok(h.runUntil(() => u.skill.activations === 1, 1), `T${tier}: cast (enemies in the cross)`);
|
||||
const hit = hitsBy(h, u, n0).filter((c) => c.dmg.tags?.includes('saga:s2'));
|
||||
assert.equal(hit.length, 6, `T${tier}: at most 6`);
|
||||
assert.ok(hit.every((c) => ground.includes(c.target)), `T${tier}: ground enemies of the cross only`);
|
||||
assert.equal(new Set(hit.map((c) => c.target)).size, 6, `T${tier}: six different`);
|
||||
for (const c of hit) {
|
||||
approx(c.amount, u.s.atk * sk.bb.atk_scale, `T${tier}: ${sk.bb.atk_scale * 100} % ATK`);
|
||||
assert.deepEqual([c.type, c.dmg.isSkill, c.dmg.isAttack], ['phys', true, false], `T${tier}: a physical skill damage`);
|
||||
}
|
||||
assert.ok(!hit.some((c) => c.target === fly || c.target === diag), `T${tier}: flyer / diagonal untouched`);
|
||||
approx(h.b.players[0].dp, 4, `T${tier}: +4 DP`);
|
||||
assert.equal(u.skill.charges, 1, `T${tier}: one charge left`);
|
||||
done(h);
|
||||
}
|
||||
});
|
||||
|
||||
test('S2 除恶: its trigger counts any enemy in the cross (a flyer too, 无视其不可选中) but hits ground ones only', () => {
|
||||
const { h, u } = field({ tier: 6, elite: true, skill: 1 });
|
||||
const fly = h.spawn('enemy_fly', { pos: [9, 5] });
|
||||
u.skill.gainSp(999);
|
||||
assert.ok(h.runUntil(() => u.skill.activations === 1, 1), 'cast for a flyer alone in the cross');
|
||||
assert.equal(hitsBy(h, u).filter((c) => c.target === fly).length, 0, 'but not hit');
|
||||
done(h);
|
||||
});
|
||||
|
||||
test('S2 除恶: a 重伤 enemy is selected (可选择重伤单位) and every hit enemy still 重伤 0.7 s later is killed by her (killer 嵯峨, +2 SP each)', () => {
|
||||
const { h, u } = field({ tier: 6, elite: true, skill: 1 });
|
||||
const sk = skillOf(6, true, S2);
|
||||
const weak = h.spawn('enemy_weak', { pos: [10, 7] }); // in the cross, outside her 1-1
|
||||
const front = h.spawn('enemy_weak', { pos: [10, 6] }); // in her 1-1
|
||||
assert.ok(h.runUntil(() => isDying(front), 3), 'her attack: 重伤');
|
||||
assert.deepEqual([front.hp, weak.hp], [1, 100]);
|
||||
// 除恶 comes by itself once a charge is ready (SKILL_RANGE: enemies in the cross)
|
||||
assert.ok(h.runUntil(() => u.skill.activations === 1, sk.spCost - sk.initSp + 1), 'cast');
|
||||
const tc = h.b.time;
|
||||
assert.ok(hitsBy(h, u).some((c) => c.target === front && c.dmg.tags?.includes('saga:s2')), '可选择重伤单位');
|
||||
assert.ok(isDying(weak) && weak.hp === 1, 'the weak one: 1 HP, 重伤');
|
||||
h.run(S2_CHECK - 0.1);
|
||||
assert.ok(weak.alive && front.alive, 'not before 0.7 s');
|
||||
assert.ok(h.runUntil(() => !weak.alive && !front.alive, 0.2), 'both killed at 0.7 s');
|
||||
const kills = h.hooksOf('kill').filter((c) => c.victim === weak || c.victim === front);
|
||||
assert.ok(kills.length === 2 && kills.every((c) => c.killer === u), 'killer: 嵯峨');
|
||||
assert.equal(u.stats.kills, 2);
|
||||
const talentSp = h.hooksOf('spGain').filter((c) => c.unit === u && c.reason === 'talent' && c.t >= tc).reduce((n, c) => n + c.amount, 0);
|
||||
approx(talentSp, 4, '2 × 2 SP');
|
||||
done(h);
|
||||
});
|
||||
|
||||
test('S3 怒目 (MANUAL, data ACTIVE_RANGE on 1-1 + 1): 20 s, ATK +70 % / +100 %, interval 1.05 + 0.5 s, range +1, every blocked enemy at once, +20 DP over the skill; all 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, row: 9, col: 5 });
|
||||
assert.deepEqual([u.skill.rule, sk.duration, sk.bb.atk, sk.bb.base_attack_time, sk.bb.ability_range_forward_extend, sk.bb.cost, sk.bb.interval, sk.bb.value, sk.bb['attack@hp_ratio']],
|
||||
['ACTIVE_RANGE', 20, elite ? 1 : 0.7, 0.5, 1, 1, 1, 20, 0.5], `T${tier}`);
|
||||
assert.deepEqual(sk.trigger.customRangeGrid, [[0, 0], [0, 1], [0, 2]], `T${tier}: her 1-1 + 1`);
|
||||
u.skill.gainSp(999);
|
||||
const far = h.spawn('enemy_dummy', { pos: [9, 7] }); // two tiles ahead: the running range only
|
||||
assert.ok(h.runUntil(() => u.skill.active, 1), `T${tier}: cast for an enemy 2 tiles ahead`);
|
||||
h.b.players[0].dp = 0;
|
||||
assert.deepEqual(u.liveRangeGrid, [[0, 0], [0, 1], [0, 2]], `T${tier}: range +1`);
|
||||
approx(u.s.atk, u.base.atk * (1 + sk.bb.atk), `T${tier}: ATK`);
|
||||
approx(u.s.interval, 1.55, `T${tier}: +0.5 s`);
|
||||
assert.ok(h.runUntil(() => hitsBy(h, u).some((c) => c.target === far), 3), `T${tier}: reaches 2 tiles ahead`);
|
||||
h.b.kill(far, null);
|
||||
// two walkers blocked: one attack hits both
|
||||
h.spawn('enemy_walk', { routeIndex: 0 });
|
||||
h.spawn('enemy_walk', { routeIndex: 0, pos: [9, 9] });
|
||||
assert.ok(h.runUntil(() => u.blocking.length === 2, 30), `T${tier}: blocking two`);
|
||||
const n0 = h.hooksOf('attack').length;
|
||||
assert.ok(h.runUntil(() => h.hooksOf('attack').slice(n0).some((c) => c.attacker === u), 3));
|
||||
const at = h.hooksOf('attack').slice(n0).find((c) => c.attacker === u);
|
||||
assert.equal(at.targets.length, 2, `T${tier}: every blocked enemy`);
|
||||
h.runUntil(() => !u.skill.active, 25);
|
||||
approx(h.b.players[0].dp, 20, `T${tier}: +20 DP in all`, 1e-6);
|
||||
assert.deepEqual(u.liveRangeGrid, formOf(tier, elite).rangeGrid, `T${tier}: 1-1 again`);
|
||||
approx(u.s.interval, 1.05, `T${tier}: interval back`);
|
||||
done(h);
|
||||
}
|
||||
});
|
||||
|
||||
test('S3 怒目: DP comes gradually (1 per second) and one more attack follows each attack on a target below half HP (checked before the hit), none above', () => {
|
||||
const { h, u } = field({ tier: 6, elite: true, skill: 2 });
|
||||
const low = h.spawn('enemy_dummy', { pos: [10, 6] });
|
||||
low.hp = low.s.maxHp * 0.4;
|
||||
u.skill.gainSp(999);
|
||||
assert.ok(h.runUntil(() => u.skill.active, 1));
|
||||
h.b.players[0].dp = 0;
|
||||
h.run(5.5);
|
||||
approx(h.b.players[0].dp, 5, '5 DP after 5.5 s', 1e-6);
|
||||
// hits on the target, grouped by attack: an extra attack lands one tick after its attack
|
||||
const groups = (hits) => {
|
||||
const out = [];
|
||||
for (const c of hits) { const g = out.at(-1); if (g && c.t - g.at(-1).t < 0.1) g.push(c); else out.push([c]); }
|
||||
return out.map((g) => g.length);
|
||||
};
|
||||
const n0 = hitsBy(h, u).length;
|
||||
h.run(6);
|
||||
const low6 = groups(hitsBy(h, u, n0).filter((c) => c.target === low && c.dmg.isAttack));
|
||||
assert.ok(low6.length >= 3, `${low6.length} attacks in 6 s (1.55 s apart)`);
|
||||
assert.ok(low6.slice(0, -1).every((n) => n === 2), `every attack followed by one more: ${low6}`);
|
||||
// above half: no extra attack
|
||||
h.b.kill(low, null);
|
||||
const high = h.spawn('enemy_dummy', { pos: [10, 6] });
|
||||
high.hp = high.s.maxHp * 0.6;
|
||||
const n1 = hitsBy(h, u).length;
|
||||
h.run(5);
|
||||
const high5 = groups(hitsBy(h, u, n1).filter((c) => c.target === high && c.dmg.isAttack));
|
||||
assert.ok(high5.length >= 2 && high5.every((n) => n === 1), `one hit per attack: ${high5}`);
|
||||
done(h);
|
||||
});
|
||||
|
||||
test('T1 劝善: her damage leaves an enemy at 1 HP and 重伤 (move ×0.2, unblockable, 禁疗, no regeneration); she never attacks it; it dies 10 s later (无来源, no SP); a 重伤 enemy takes no second 重伤', () => {
|
||||
for (const f of [[5, false, null], [6, true, SOLY]]) {
|
||||
const { h, u } = field({ tier: f[0], elite: f[1], mod: f[2], skill: 2 });
|
||||
const t0 = BACKUPS.units[SAGA].forms[f[1] ? '2/60/7/3' : '2/1/4/0'].talents[0].bb;
|
||||
assert.deepEqual(t0, { move_speed: -0.8, sp: 2, interval: 10 });
|
||||
const e = h.spawn('enemy_weak', { pos: [10, 6] });
|
||||
assert.ok(h.runUntil(() => isDying(e), 3), `${label(f)}: 重伤`);
|
||||
const at = h.b.time;
|
||||
assert.deepEqual([e.alive, e.hp], [true, 1], `${label(f)}: 1 HP left`);
|
||||
const d = e.findBuff(DYING);
|
||||
assert.equal(d.source, u);
|
||||
approx(d.mods.moveMul, 0.2, `${label(f)}: move −80 %`);
|
||||
assert.equal(d.mods.hpRegen, -1e9, `${label(f)}: regeneration zeroed`);
|
||||
assert.deepEqual(d.flags, { unblockable: true, healFree: true, noHeal: true }, `${label(f)}: 禁用近战 / 禁疗`);
|
||||
approx(e.s.moveSpeed, e.base.moveSpeed * 0.2, `${label(f)}: move`);
|
||||
assert.ok(e.s.hpRegen <= 0, `${label(f)}: no regeneration (a cancelling hpRegen)`);
|
||||
assert.equal(h.b.heal(e, e, 50, { self: true }), 0, `${label(f)}: 禁疗`);
|
||||
// she never attacks it again
|
||||
const n0 = hitsBy(h, u).length, a0 = u.stats.attacks;
|
||||
h.run(4);
|
||||
assert.equal(hitsBy(h, u, n0).length, 0, `${label(f)}: no damage of hers`);
|
||||
assert.equal(u.stats.attacks, a0, `${label(f)}: no attack`);
|
||||
// no second 重伤
|
||||
h.b.dealDamage(u, e, { amount: 1000, type: 'true' });
|
||||
assert.equal(e.findBuff(DYING), d, `${label(f)}: the same 重伤`);
|
||||
assert.equal(e.hp, 1, `${label(f)}: still not lethal`);
|
||||
// 10 s: a forced, 无来源 death
|
||||
const sp0 = u.skill.sp;
|
||||
h.run(at + 10 - h.b.time - 0.1);
|
||||
assert.ok(e.alive, `${label(f)}: alive before 10 s`);
|
||||
assert.ok(h.runUntil(() => !e.alive, 0.2), `${label(f)}: dead at 10 s`);
|
||||
const k = h.hooksOf('kill').find((c) => c.victim === e);
|
||||
assert.deepEqual([k.killer, e.removeReason], [null, 'killed'], `${label(f)}: 无来源 kill`);
|
||||
assert.equal(h.b.killed, 1, `${label(f)}: counted`);
|
||||
assert.equal(h.hooksOf('spGain').filter((c) => c.reason === 'talent').length, 0, `${label(f)}: no SP for it`);
|
||||
assert.ok(u.skill.sp >= sp0, `${label(f)}: (time SP only)`);
|
||||
done(h);
|
||||
}
|
||||
});
|
||||
|
||||
test('T1 劝善: a 重伤 enemy regenerates nothing (生命回复速度归零) — one with 200 HP/s stays at 1 HP', () => {
|
||||
const { h, u } = field({ tier: 5, skill: 2 });
|
||||
const e = h.spawn('enemy_regen', { pos: [10, 6] });
|
||||
assert.equal(e.s.hpRegen, 200, 'it regenerates');
|
||||
assert.ok(h.runUntil(() => isDying(e), 3));
|
||||
h.run(3);
|
||||
assert.deepEqual([e.alive, e.hp], [true, 1], 'no HP back while 重伤');
|
||||
assert.equal(hitsBy(h, u).filter((c) => c.target === e).length, 1, 'one hit of hers, then none');
|
||||
done(h);
|
||||
});
|
||||
|
||||
test('T1 劝善: whoever kills a 重伤 enemy gets 2 SP; 重伤 never kills while 消失 and kills at once when it comes back', () => {
|
||||
const others = [{ uid: 2, chessId: 'chess_char_1_08_a', row: 12, col: 9 }];
|
||||
const { h } = field({ tier: 5, skill: 2, others });
|
||||
const texas = h.unit(2);
|
||||
const e = h.spawn('enemy_weak', { pos: [10, 6] });
|
||||
assert.ok(h.runUntil(() => isDying(e), 3));
|
||||
const sp0 = texas.skill.sp;
|
||||
h.b.dealDamage(texas, e, { amount: 1e6, type: 'true' });
|
||||
assert.ok(!e.alive, 'another operator\'s damage kills it');
|
||||
approx(texas.skill.sp - sp0, 2, '+2 SP to 德克萨斯');
|
||||
// 消失
|
||||
const g = h.spawn('enemy_weak', { pos: [10, 6] });
|
||||
assert.ok(h.runUntil(() => isDying(g), 3));
|
||||
h.step();
|
||||
g.hidden = true;
|
||||
h.run(12);
|
||||
assert.ok(g.alive, 'no natural death while 消失');
|
||||
g.hidden = false;
|
||||
h.step();
|
||||
assert.ok(!g.alive, 'dead the moment it appears');
|
||||
assert.equal(h.hooksOf('kill').find((c) => c.victim === g).killer, null);
|
||||
done(h);
|
||||
});
|
||||
|
||||
test('T1 劝善 SOL-X stage 3: her damage on a target below half HP ×1.15 (stage 1 and the other forms: none)', () => {
|
||||
for (const f of FORMS_ALL) {
|
||||
const [tier, elite, mod] = f;
|
||||
const { h, u } = field({ tier, elite, mod, skill: 0 });
|
||||
const x3 = elite && tier === 6 && mod === SOLX;
|
||||
const e = h.spawn('enemy_dummy', { pos: [10, 6] });
|
||||
const hitAt = (ratio) => {
|
||||
e.hp = e.s.maxHp * ratio;
|
||||
const n0 = hitsBy(h, u).length;
|
||||
assert.ok(h.runUntil(() => hitsBy(h, u, n0).length > 0, 3), label(f));
|
||||
return hitsBy(h, u, n0)[0].amount;
|
||||
};
|
||||
const lo = hitAt(0.4), hi = hitAt(0.6);
|
||||
approx(lo / hi, x3 ? 1.15 : 1, `${label(f)}: below / above half`);
|
||||
if (x3) assert.match(u.def.raw.talents.find((t) => t.index === 0).desc, /对生命值低于一半的单位造成的伤害提升15%/);
|
||||
done(h);
|
||||
}
|
||||
});
|
||||
|
||||
test('T2 清明: once per deployment, the first time she drops below 40 %: 70 % physical dodge and 5 % max HP/s for 15 s; SOL-Y stage 3: 6.5 % (its blackboard) for 18 s', () => {
|
||||
for (const f of FORMS_ALL) {
|
||||
const [tier, elite, mod] = f;
|
||||
const { h, u } = field({ tier, elite, mod, skill: 0, row: 12, col: 9 });
|
||||
const y3 = elite && tier === 6 && mod === SOLY;
|
||||
const tb = u.def.raw.talents.find((t) => t.index === 1).bb;
|
||||
assert.deepEqual(tb, { hp_ratio: 0.4, hp_recovery_per_sec_by_max_hp_ratio: y3 ? 0.065 : 0.05, prob: 0.7, duration: y3 ? 18 : 15 }, label(f));
|
||||
h.b.dealDamage(null, u, { amount: u.s.maxHp * 0.55, type: 'true' });
|
||||
assert.equal(u.findBuff('talent:saga:qingming'), null, `${label(f)}: at 45 % nothing`);
|
||||
h.b.dealDamage(null, u, { amount: u.s.maxHp * 0.1, type: 'true' });
|
||||
const b = u.findBuff('talent:saga:qingming');
|
||||
assert.ok(b, `${label(f)}: below 40 %`);
|
||||
assert.deepEqual(b.mods, { dodgePhys: 0.7, hpRegenRatio: y3 ? 0.065 : 0.05 }, `${label(f)}: mods`);
|
||||
approx(b.duration, y3 ? 18 : 15, `${label(f)}: duration`);
|
||||
approx(u.s.dodgePhys, 0.7, `${label(f)}: dodge`);
|
||||
const hp0 = u.hp;
|
||||
h.run(2.01);
|
||||
approx(u.hp - hp0, 2 * (y3 ? 0.065 : 0.05) * u.s.maxHp, `${label(f)}: regeneration`, 0.02);
|
||||
h.run(b.duration);
|
||||
assert.equal(u.findBuff('talent:saga:qingming'), null, `${label(f)}: over`);
|
||||
u.hp = u.s.maxHp;
|
||||
h.b.dealDamage(null, u, { amount: u.s.maxHp * 0.7, type: 'true' });
|
||||
assert.equal(u.findBuff('talent:saga:qingming'), null, `${label(f)}: only once`);
|
||||
h.b.retreat(u);
|
||||
h.b.redeploy(u, { free: true });
|
||||
h.b.dealDamage(null, u, { amount: u.s.maxHp * 0.7, type: 'true' });
|
||||
assert.ok(u.findBuff('talent:saga:qingming'), `${label(f)}: again after a new deployment`);
|
||||
done(h);
|
||||
}
|
||||
});
|
||||
|
||||
test('SOL-X 何处寻驮? trait: ATK / DEF +8 % while she blocks an enemy (stages 1 and 3); none without it; SOL-Y\'s 首次部署时部署费用-4 changes nothing in battle', () => {
|
||||
for (const f of FORMS_ALL) {
|
||||
const [tier, elite, mod] = f;
|
||||
const { h, u } = field({ tier, elite, mod, skill: 0, row: 9, col: 5 });
|
||||
const solx = elite && mod === SOLX;
|
||||
if (solx) assert.deepEqual(u.def.raw.trait.bb, { atk: 0.08, def: 0.08 }, label(f));
|
||||
h.run(1);
|
||||
assert.equal(u.findBuff('trait:saga:block'), null, `${label(f)}: nothing blocked`);
|
||||
h.spawn('enemy_walk', { routeIndex: 0 });
|
||||
assert.ok(h.runUntil(() => u.blocking.length > 0, 30), `${label(f)}: the walker reaches her`);
|
||||
h.step();
|
||||
assert.equal(!!u.findBuff('trait:saga:block'), solx, `${label(f)}: blocking`);
|
||||
if (solx) assert.deepEqual(u.findBuff('trait:saga:block').mods, { atkPct: 0.08, defPct: 0.08 });
|
||||
if (elite && mod === SOLY) {
|
||||
assert.deepEqual(u.def.raw.talents.filter((t) => t.index === -1).map((t) => t.bb.runtime_cost).filter((v) => v != null), [-4], `${label(f)}: the data carries it`);
|
||||
assert.equal(u.base.cost, formOf(tier, true).stats.cost, `${label(f)}: no cost change`);
|
||||
}
|
||||
done(h);
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,252 @@
|
||||
// test/content/op_shining.test.js — the 自选 operator kit of 闪灵 (char_147_shining, 6★ 医师; kit
|
||||
// server/sim/content/kits/ops/op-shining.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, PHY-Y
|
||||
// 干枯剑鞘 or PHY-X “使徒” 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_shining.test.js
|
||||
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { makeBattle, enemyRec, chessRec, 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 SHINING = 'char_147_shining';
|
||||
const FORMS = BACKUPS.units[SHINING].forms;
|
||||
const SLOT = { 5: 'chess_char_5_diy1_a', 6: 'chess_char_6_diy1_a' };
|
||||
const PHYY = 'uniequip_002_shining', PHYX = 'uniequip_003_shining';
|
||||
const S1 = 'skchr_shining_1', S2 = 'skchr_shining_2', S3 = 'skchr_shining_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 ENEMIES = { enemy_dummy: enemyRec({ key: 'enemy_dummy', hp: 1e9, speed: 0, mass: 0 }) };
|
||||
/** Synthetic allies with no skill: a melee one (地面 tiles) and a ranged one (高台). */
|
||||
const ALLIES = {
|
||||
test_melee_a: chessRec({ id: 'test_melee_a', profession: 'WARRIOR', stats: { maxHp: 10000, def: 100, atk: 0 }, skill: null }),
|
||||
test_ranged_a: chessRec({ id: 'test_ranged_a', profession: 'SNIPER', stats: { maxHp: 10000, def: 100, atk: 0 }, skill: null }),
|
||||
};
|
||||
const FORMS_ALL = [[5, false, null], [6, false, null], ...[5, 6].flatMap((t) => [null, PHYY, PHYX].map((m) => [t, true, m]))];
|
||||
const label = ([tier, elite, mod]) => `T${tier} ${elite ? 'elite' : 'normal'} ${mod ?? 'none'}`;
|
||||
|
||||
/**
|
||||
* A battle with 闪灵 as uid 1 on the 高台 tile (11,2) facing RIGHT (her 3-3: rows 10–12, cols 2–5), a melee ally on the
|
||||
* 地面 tile (10,4) (uid 2) and a ranged ally on the 高台 tile (10,2) (uid 3) — both in her range —, a melee ally outside it
|
||||
* at (10,8) (uid 4).
|
||||
*/
|
||||
function field({ tier = 5, elite = false, mod = null, skill = 0, seed = 5, extra = [] } = {}) {
|
||||
const h = makeBattle({
|
||||
defs: { enemies: ENEMIES, chess: ALLIES }, timeLimit: 600, autoFinish: false, seed,
|
||||
flags: { dpPerSec: 0, dpMax: 999 }, hooks: ['damaged', 'heal', 'skillStart', 'skillEnd'], captureNoisy: true,
|
||||
units: [
|
||||
{ uid: 1, diy: { slot: SLOT[tier], charId: SHINING, skillIndex: skill, uniEquipId: mod }, elite, row: 11, col: 2 },
|
||||
{ uid: 2, chessId: 'test_melee_a', row: 10, col: 4 },
|
||||
{ uid: 3, chessId: 'test_ranged_a', row: 10, col: 2 },
|
||||
{ uid: 4, chessId: 'test_melee_a', row: 10, col: 8 },
|
||||
...extra,
|
||||
],
|
||||
});
|
||||
h.step();
|
||||
return { h, u: h.unit(1), ground: h.unit(2), high: h.unit(3), out: h.unit(4) };
|
||||
}
|
||||
function done(h) {
|
||||
checkInvariants(h.b);
|
||||
assert.equal(h.b.errors.length, 0, JSON.stringify(h.b.errors[0]));
|
||||
}
|
||||
const healsOn = (h, u, t, from = 0) => h.hooksOf('heal').slice(from).filter((c) => c.source === u && c.target === t && !c.opts?.regen);
|
||||
|
||||
test('闪灵 in every 自选 form: her operator kit (all three skills authored), the form\'s stats + module attributes, 3-3, one heal (医师), no 特质', () => {
|
||||
assert.equal(OPERATOR_KITS[SHINING], KITS[SHINING]);
|
||||
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], [SHINING, 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), form.stats.aspd + (m?.attr.aspd ?? 0)], `${label(f)}: stats`);
|
||||
// a heal attack selects injured allies only (ai.js acquireTargets): no enemy, so no anti-air question
|
||||
assert.deepEqual([u.profile.dmgType, u.profile.heal?.mode, u.profile.attack, u.base.bat], ['heal', 'single', 'ranged', 2.85], `${label(f)}: 医师`);
|
||||
assert.deepEqual(u.liveRangeGrid, form.rangeGrid, `${label(f)}: 3-3`);
|
||||
assert.deepEqual([u.def.bonds, u.def.raw.garrisonIds], [['emptyShip'], []], `${label(f)}: bonds / 特质`);
|
||||
assert.ok(!u.s.flags.liftoff && !u.s.flags.camou && !u.s.flags.stealth && !u.s.flags.untargetable, `${label(f)}: enemies target her`);
|
||||
done(h);
|
||||
}
|
||||
}
|
||||
// the numbers of the forms (zh_CN): E2 Lv1 1451 / 424 / 110, E2 Lv60 1558 / 494 / 129; PHY-Y +35 ATK +5 ASPD → +60 / +7,
|
||||
// PHY-X +45 ATK +13 DEF → +63 / +20
|
||||
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], [1451, 424, 1558, 494]);
|
||||
assert.deepEqual([modOf(5, PHYY).attr, modOf(6, PHYY).attr, modOf(5, PHYX).attr, modOf(6, PHYX).attr], [{ atk: 35, aspd: 5 }, { atk: 60, aspd: 7 }, { atk: 45, def: 13 }, { atk: 63, def: 20 }]);
|
||||
});
|
||||
|
||||
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(SHINING));
|
||||
for (const t of [5, 6]) assert.ok(diyPool(t, { data, kitted: KITTED_CHARS }).includes(SHINING), `tier ${t}`);
|
||||
assert.deepEqual(validateDiyPicks({ [SLOT[5]]: { charId: SHINING, skillIndex: 2, uniEquipId: PHYX } }, { data, kitted: KITTED_CHARS }),
|
||||
{ ok: true, picks: { [SLOT[5]]: { charId: SHINING, skillIndex: 2, uniEquipId: PHYX } } });
|
||||
});
|
||||
|
||||
test('S1 信条 (MANUAL, data DEFAULT): cast on an injured ally in range only; 20 s of ATK +58 % / +67 % and ASPD +10 / +20; 47 / 44 SP from 10 / 14', () => {
|
||||
for (const [tier, elite] of [[5, false], [6, true]]) {
|
||||
const sk = skillOf(tier, elite, S1);
|
||||
const { h, u, ground } = field({ tier, elite, mod: elite ? PHYY : null, skill: 0 });
|
||||
assert.deepEqual([u.skill.rule, u.skill.spCost, sk.initSp, sk.duration, sk.bb.atk, sk.bb.attack_speed],
|
||||
['DEFAULT', elite ? 44 : 47, elite ? 14 : 10, 20, elite ? 0.67 : 0.58, elite ? 20 : 10], `T${tier}`);
|
||||
const aspd0 = u.s.aspd;
|
||||
u.skill.gainSp(999);
|
||||
h.run(3);
|
||||
assert.equal(u.skill.activations, 0, `T${tier}: nobody injured, no cast`);
|
||||
ground.hp = 100;
|
||||
assert.ok(h.runUntil(() => u.skill.active, 5), `T${tier}: cast as she heals`);
|
||||
approx(u.skill.timeLeft, 20, `T${tier}: 20 s`, 0.01);
|
||||
approx(u.s.atk, u.base.atk * (1 + sk.bb.atk), `T${tier}: ATK`);
|
||||
approx(u.s.aspd, aspd0 + sk.bb.attack_speed, `T${tier}: ASPD`);
|
||||
h.runUntil(() => !u.skill.active, 25);
|
||||
approx(u.s.atk, u.base.atk, `T${tier}: ATK back`);
|
||||
approx(u.s.aspd, aspd0, `T${tier}: ASPD back`);
|
||||
done(h);
|
||||
}
|
||||
});
|
||||
|
||||
test('S2 自动掩护 (AUTO, data DEFAULT, 1 / 2 charges): the next heal gives its target a 屏障 of 28 % / 35 % ATK for 2 / 3 s (every damage type) and DEF +25 % / +35 % while it holds', () => {
|
||||
for (const [tier, elite] of [[5, false], [6, true]]) {
|
||||
const sk = skillOf(tier, elite, S2);
|
||||
const { h, u, ground } = field({ tier, elite, mod: elite ? PHYX : null, skill: 1 });
|
||||
assert.deepEqual([u.skill.rule, u.skill.maxCharges, u.skill.kind, sk.spCost, sk.bb.atk_scale, sk.bb.duration, sk.bb.def],
|
||||
['DEFAULT', elite ? 2 : 1, elite ? 'charges' : 'instant', 7, elite ? 0.35 : 0.28, elite ? 3 : 2, elite ? 0.35 : 0.25], `T${tier}`);
|
||||
u.skill.gainSp(999);
|
||||
h.run(2);
|
||||
assert.equal(u.skill.activations, 0, `T${tier}: nobody injured, no cast (it waits for a heal)`);
|
||||
ground.hp = 100;
|
||||
const def0 = ground.s.def;
|
||||
assert.ok(h.runUntil(() => ground.findBuff('shining:barrier'), 5), `T${tier}: the barrier comes with the heal`);
|
||||
assert.equal(healsOn(h, u, ground).length, 1, `T${tier}: one heal so far`);
|
||||
const bar = ground.findBuff('shining:barrier');
|
||||
approx(bar.shield, u.s.atk * sk.bb.atk_scale, `T${tier}: ${sk.bb.atk_scale * 100} % ATK`);
|
||||
approx(bar.duration, sk.bb.duration, `T${tier}: ${sk.bb.duration} s`);
|
||||
assert.equal(bar.shieldType, null, `T${tier}: absorbs every damage type`);
|
||||
assert.deepEqual(ground.findBuff('shining:barrierDef')?.mods, { defPct: sk.bb.def }, `T${tier}: DEF bonus`);
|
||||
approx(ground.s.def, def0 * (1 + sk.bb.def), `T${tier}: DEF`, 1e-6);
|
||||
// the barrier takes physical and arts damage alike
|
||||
const hp0 = ground.hp, sh0 = bar.shield;
|
||||
h.b.dealDamage(null, ground, { amount: 10, type: 'arts', canDodge: false });
|
||||
approx(ground.hp, hp0, `T${tier}: arts absorbed`);
|
||||
approx(bar.shield, sh0 - 10, `T${tier}: shield −10`);
|
||||
h.b.dealDamage(null, ground, { amount: 1e6, type: 'true' });
|
||||
assert.equal(ground.findBuff('shining:barrier'), null, `T${tier}: broken`);
|
||||
assert.equal(ground.findBuff('shining:barrierDef'), null, `T${tier}: the DEF bonus goes with it`);
|
||||
done(h);
|
||||
}
|
||||
});
|
||||
|
||||
test('S2 自动掩护: barriers stack with their own timers, the older absorbs first, the DEF bonus does not stack; all gone after their time', () => {
|
||||
const sk = skillOf(6, true, S2);
|
||||
const { h, u, ground } = field({ tier: 6, elite: true, mod: PHYY, skill: 1 });
|
||||
ground.hp = 100;
|
||||
u.skill.gainSp(999);
|
||||
assert.ok(h.runUntil(() => ground.buffs.filter((b) => b.key === 'shining:barrier').length === 1, 5));
|
||||
ground.hp = 100; // still the most injured
|
||||
assert.ok(h.runUntil(() => ground.buffs.filter((b) => b.key === 'shining:barrier').length === 2, 8), 'the second charge on the next heal');
|
||||
const [a, b] = ground.buffs.filter((x) => x.key === 'shining:barrier');
|
||||
assert.ok(a.seq < b.seq && a.timeLeft < b.timeLeft, 'own timers');
|
||||
assert.equal(ground.buffs.filter((x) => x.key === 'shining:barrierDef').length, 1, 'one DEF bonus');
|
||||
approx(ground.findBuff('shining:barrierDef').mods.defPct, sk.bb.def, 'not doubled');
|
||||
approx(ground.s.shield, a.shield + b.shield, 'the absorption adds up');
|
||||
const sa = a.shield, sb = b.shield;
|
||||
h.b.dealDamage(null, ground, { amount: sa / 2, type: 'true' });
|
||||
approx(a.shield, sa / 2, 'the older one first');
|
||||
approx(b.shield, sb, 'the newer one untouched');
|
||||
h.run(sk.bb.duration + 0.1);
|
||||
assert.equal(ground.findBuff('shining:barrier'), null, 'expired');
|
||||
assert.equal(ground.findBuff('shining:barrierDef'), null, 'the DEF bonus with them');
|
||||
done(h);
|
||||
});
|
||||
|
||||
test('S3 教条力场 (MANUAL, data DEFAULT): 60 s, ATK +30 % / +40 %, every ally in her range DEF +45 % / +60 % (not outside it); gone after it ends', () => {
|
||||
for (const [tier, elite] of [[5, false], [6, true]]) {
|
||||
const sk = skillOf(tier, elite, S3);
|
||||
const { h, u, ground, high, out } = field({ tier, elite, mod: elite ? PHYX : null, skill: 2 });
|
||||
assert.deepEqual([u.skill.rule, sk.duration, sk.spCost, sk.initSp, sk.bb.atk, sk.bb.def], ['DEFAULT', 60, 120, 100, elite ? 0.4 : 0.3, elite ? 0.6 : 0.45], `T${tier}`);
|
||||
u.skill.gainSp(999);
|
||||
ground.hp = 100;
|
||||
assert.ok(h.runUntil(() => u.skill.active, 5), `T${tier}: cast on the injured ally`);
|
||||
h.run(0.3);
|
||||
approx(u.s.atk, u.base.atk * (1 + sk.bb.atk), `T${tier}: ATK`);
|
||||
for (const a of [ground, high, u]) assert.deepEqual(a.findBuff('skill:shining:def')?.mods, { defPct: sk.bb.def }, `T${tier}: ${a.defId} in range`);
|
||||
assert.equal(out.findBuff('skill:shining:def'), null, `T${tier}: outside her range`);
|
||||
u.skill.end('test');
|
||||
h.run(0.3);
|
||||
for (const a of [ground, high, u]) assert.equal(a.findBuff('skill:shining:def'), null, `T${tier}: gone once it ends`);
|
||||
done(h);
|
||||
}
|
||||
});
|
||||
|
||||
test('T1 黑恶魔的庇护: allies in her range DEF +60 (herself too, not outside); PHY-Y stage 3: +100 and 地面 units +40 more (stage 1: +60 only)', () => {
|
||||
for (const f of FORMS_ALL) {
|
||||
const [tier, elite, mod] = f;
|
||||
const { h, u, ground, high, out } = field({ tier, elite, mod, skill: 0 });
|
||||
h.run(0.3);
|
||||
const y3 = elite && tier === 6 && mod === PHYY;
|
||||
const d = y3 ? 100 : 60, low = y3 ? 40 : 0;
|
||||
assert.deepEqual(ground.findBuff('talent:shining:def')?.mods, { defFlat: d + low }, `${label(f)}: 地面 ally`);
|
||||
assert.deepEqual(high.findBuff('talent:shining:def')?.mods, { defFlat: d }, `${label(f)}: 高台 ally`);
|
||||
assert.deepEqual(u.findBuff('talent:shining:def')?.mods, { defFlat: d }, `${label(f)}: herself (高台)`);
|
||||
assert.equal(out.findBuff('talent:shining:def'), null, `${label(f)}: outside her range`);
|
||||
approx(ground.s.def, 100 + d + low, `${label(f)}: DEF of the 地面 ally`);
|
||||
if (y3) assert.match(u.def.raw.talents.find((t) => t.index === 0).desc, /防御力\+100,地面单位防御力额外\+40/);
|
||||
h.b.retreat(u);
|
||||
h.run(0.3);
|
||||
assert.equal(ground.findBuff('talent:shining:def'), null, `${label(f)}: gone once she leaves`);
|
||||
done(h);
|
||||
}
|
||||
});
|
||||
|
||||
test('T2 法典: ASPD +10; PHY-X stage 3: ASPD +15, ATK +25 % with 自动掩护 picked, SP +0.6/s with 教条力场 picked (stage 1: ASPD +10 only)', () => {
|
||||
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 x3 = elite && tier === 6 && mod === PHYX;
|
||||
approx(u.s.aspd, u.base.aspd + (x3 ? 15 : 10), `${label(f)} S${skill + 1}: ASPD`);
|
||||
approx(u.s.atk, u.base.atk * (1 + (x3 && skill === 1 ? 0.25 : 0)), `${label(f)} S${skill + 1}: ATK`);
|
||||
approx(u.s.spRecovery, 1 + (x3 && skill === 2 ? 0.6 : 0), `${label(f)} S${skill + 1}: SP/s`);
|
||||
if (x3 && skill === 2) {
|
||||
const sp0 = u.skill.sp;
|
||||
h.run(5);
|
||||
approx(u.skill.sp - sp0, 5 * 1.6, `${label(f)}: 1.6 SP/s`, 0.01);
|
||||
}
|
||||
done(h);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('module traits: PHY-Y heals on 地面 units ×1.15 (not on 高台), PHY-X heals on allies below 50 % ×1.15 (stages 1 and 3); none without a module', () => {
|
||||
for (const f of FORMS_ALL) {
|
||||
const [tier, elite, mod] = f;
|
||||
const { h, u, ground, high } = field({ tier, elite, mod, skill: 0 });
|
||||
const tb = u.def.raw.trait.bb;
|
||||
const y = elite && mod === PHYY, x = elite && mod === PHYX;
|
||||
if (y) assert.deepEqual(tb, { heal_scale: 1.15 }, label(f));
|
||||
if (x) assert.deepEqual(tb, { heal_scale: 1.15, hp_ratio: 0.5 }, label(f));
|
||||
const heal = (t, hp) => {
|
||||
t.hp = hp;
|
||||
const n0 = h.hooksOf('heal').length;
|
||||
assert.ok(h.runUntil(() => healsOn(h, u, t, n0).length > 0, 6), `${label(f)}: a heal on ${t.defId}`);
|
||||
return healsOn(h, u, t, n0)[0].amount;
|
||||
};
|
||||
// 地面 vs 高台, both below 50 %
|
||||
approx(heal(ground, 100), u.s.atk * (y || x ? 1.15 : 1), `${label(f)}: 地面 ally at 1 %`);
|
||||
ground.hp = ground.s.maxHp;
|
||||
approx(heal(high, 100), u.s.atk * (x ? 1.15 : 1), `${label(f)}: 高台 ally at 1 %`);
|
||||
high.hp = high.s.maxHp;
|
||||
// above 50 %
|
||||
approx(heal(ground, 6000), u.s.atk * (y ? 1.15 : 1), `${label(f)}: 地面 ally at 60 %`);
|
||||
ground.hp = ground.s.maxHp;
|
||||
approx(heal(high, 6000), u.s.atk, `${label(f)}: 高台 ally at 60 %`);
|
||||
done(h);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user