Files
ark-stronghold-protocol/test/content/lemuen-wanted-023.test.js
T

62 lines
3.3 KiB
JavaScript

import { test } from 'node:test';
import assert from 'node:assert/strict';
import { makeBattle, enemyRec, checkInvariants } from '../helpers/battleHarness.js';
const LEM = 'chess_char_6_01_a';
function field({ skillIndex = 2, second = false, unite = false } = {}) {
const units = [{ uid: 1, chessId: LEM, row: 12, col: 2, skillIndex, potential: 1 },
{ uid: 2, chessId: 'chess_char_2_01_a', row: 9, col: 7 }];
if (second) units.push({ uid: 3, chessId: LEM, row: 12, col: 4, skillIndex, potential: 1 });
const config = { defs: { enemies: { target: enemyRec({ key: 'target', rank: 'ELITE', hp: 1e9, speed: 0 }) } },
units, enemies: [{ key: 'target', pos: [9, 8] }], autoFinish: false, hooks: ['skillStart'] };
if (unite) {
config.kind = 'unite';
config.players = [{ playerId: 'p1', seat: 0, side: 'L', colOffset: 0, bonds: {}, units: [{ kind: 'chess', ...units[0] }] },
{ playerId: 'p2', seat: 1, side: 'L', colOffset: 0, bonds: {}, units: [{ kind: 'chess', ...units[1] }] }];
delete config.units;
}
const h = makeBattle(config);h.step();return { h, u: h.unit(1), e: h.enemies()[0] };
}
function done(h) { checkInvariants(h.b); assert.deepEqual(h.b.errors, []); }
for (const skillIndex of [0, 1, 2]) for (const unite of [false, true]) {
test(`通缉 opens S${skillIndex + 1} outside original range (unite=${unite})`, () => {
const { h, u, e } = field({ skillIndex, unite });
u.skill.gainSp(999);h.run(8.5);
assert.ok(e.findBuff('lemuen:wanted'));
assert.ok(h.hooksOf('skillStart').some(c => c.unit === u));
done(h);
});
}
test('a new 通缉 timer waits for selectability; an existing timer continues through sleep', () => {
for (const startBeforeSleep of [false, true]) {
const { h, u, e } = field();
if (startBeforeSleep) h.run(0.5);
h.b.applyStatus(e, 'sleep', { duration: 10 });
u.skill.gainSp(999);h.run(8.5);
assert.equal(!!e.findBuff('lemuen:wanted'), startBeforeSleep);
assert.equal(u.skill.active, false, 'sleep cannot trigger the skill');
h.run(2);
assert.equal(u.skill.active, startBeforeSleep, 'waking a marked enemy opens S3');
if (!startBeforeSleep) { h.run(8);assert.ok(e.findBuff('lemuen:wanted')); }
done(h);
}
});
test('each 蕾缪安 clears only her own timer/mark on exit and starts fresh on redeployment', () => {
const { h, u, e } = field({ second: true });const other = h.unit(3);
h.run(8.5);assert.ok(e.findBuff('lemuen:wanted'));
h.b.retreat(u, { reason: 'test' });assert.ok(e.findBuff('lemuen:wanted'), 'other source remains');
h.b.retreat(other, { reason: 'test' });assert.equal(e.findBuff('lemuen:wanted'), null);
h.b.redeploy(u, { free: true });h.run(0.5);assert.equal(e.findBuff('lemuen:wanted'), null);
h.run(8);assert.ok(e.findBuff('lemuen:wanted'));
done(h);
});
test('immediate redeployment cannot attack through a cleared wanted range', () => {
const { h, u, e } = field();h.run(8.5);assert.ok(e.findBuff('lemuen:wanted'));
h.b.retreat(u, { reason: 'test' });
assert.equal(e.findBuff('lemuen:wanted'), null);
assert.equal(h.b.enemiesInKeys(u.extraRangeKeys || [], u, u.profile).length, 0);
h.b.redeploy(u, { free: true });const before = u.stats.attacks;u.atkCd = 0;
h.step();assert.equal(u.stats.attacks, before, 'the allies phase sees the cleared range immediately');
done(h);
});