Files
sganggs 6464e4b46a Playtest #6 fixes: summons placed by hand, boss pool stall, bounties, 联防 leak counter, distinct offers, 机变 card text, phone buy tap, skill triggers, blocking, push force, 孤立, enemies, element bar
- #1 #2 skill / device summons (赫默's drone, 巫恋's doll, 凯瑟琳's devices) are hand cards placed by the player;
  placed summons deploy once at battle start, then a skill summon re-appears at its tile on each cast (the user's call)
- #3 叙拉古 隐匿 ends on time (32 + 0.4 × layers s); 忍冬 S3 迷彩 lasts until her next cast (official), kept apart from 隐匿
- #4 multi-round bounty cards last two battles (the user's call; MULTI_ROUND_BOUNTY_BATTLES), blue / red card text
- #5 the shared boss pool's float dust (≈3.6e-12 HP) stalled Final Assault leaders at 0 %; < 1 HP now clears the pool,
  and the team LP reaching 0 first is a defeat (PRTS)
- #6 #10 机变 cards show their official effect text; an invisible 详情 button no longer swallows the confirming tap on phones
- #7 live ×N counter of a leaker's enemies still on the 联防 field (LP loss stays capped at 10)
- #8 #15 #16 skill triggers per 技能策略: skill-range triggers, injured-ally heals (古米, 塞雷娅), tank take-damage
  triggers with a 3 s cooldown; 新约能天使 S2 shields the highest-aggro operator in range
- #9 official per-enemy model scales (威龙)
- #11 element bar under the unit's HP bar (white = 元素值 left, element-coloured refill after a burst), floor rounding
- #12 枯朽战车 kit per PRTS; every ranged enemy reaches its target's 0.25 collider
- #13 恐惧 wander (萨科塔之翼 at half HP, operator fears make enemies flee) with re-planning after pushes
- #14 push / pull distance by 力度 − 重量 (PRTS table); #17 every blocker attacks what it blocks; ASPD floor 20
- #18 炎佑 is 孤立: no heals or ally buffs
- #19 every free pick-one chess offer (promotion reward, 信标, 寻呼模块) shows different operators
- DESIGN §20 and the normative lines, SIM / META / DATA / PLAYING updated; 2747 unit tests and all 27 browser suites
  green; dev recordings regenerated
2026-10-01 19:08:23 +08:00

121 lines
5.6 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// The worked examples of docs/SIM.md, executed (keeps the documentation honest).
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { makeBattle, enemyRec, chessRec, checkInvariants } from '../helpers/battleHarness.js';
import { releaseSkillSummon } from '../../server/sim/content/tokens.js';
const approx = (a, b, msg = '', eps = 1e-6) => assert.ok(Math.abs(a - b) <= eps * Math.max(1, Math.abs(b)), `${msg} ${a} ≈ ${b}`);
const dummy = (o = {}) => enemyRec({ key: 'enemy_dummy', hp: 1e7, speed: 0, ...o });
test('SIM.md §10: 隐现 S2 fires 14 shots then ends', () => {
const h = makeBattle({
defs: { enemies: { enemy_dummy: dummy() } },
units: [{ chessId: 'chess_char_1_01_a', row: 10, col: 4 }],
enemies: [{ key: 'enemy_dummy', pos: [10, 6] }],
hooks: ['ammoUsed', 'skillEnd'],
});
const u = h.unit('chess_char_1_01_a');
assert.ok(h.runUntil(() => u.skill.activations === 1, 60));
h.runUntil(() => !u.skill.active, 60);
assert.equal(h.hooksOf('ammoUsed').length, 14);
checkInvariants(h.b);
});
test('SIM.md example 1: ammo sniper kit with talent (+2 ammo after 20 s)', () => {
const kit = (bb, chess, def) => ({
skill: { kind: 'ammo', ammo: bb['attack@trigger_time'], mods: { atkPct: bb.atk, batPct: bb.base_attack_time, taunt: -1 }, targeting: { priority: 'ranged' } },
talents: [{ install(battle, unit) {
const t = def.talents[0].bb;
battle.on('skillStart', ({ unit: u, skill }) => { if (u === unit && battle.time - unit.deployedAt >= t.duration) skill.ammoLeft += t.self_ammo; }, { owner: unit });
} }],
});
const h = makeBattle({
defs: { enemies: { enemy_dummy: dummy() } }, kits: { chess_char_1_01_a: kit },
units: [{ chessId: 'chess_char_1_01_a', row: 10, col: 4 }], hooks: ['ammoUsed'],
});
const u = h.unit('chess_char_1_01_a');
h.run(25);
h.spawn('enemy_dummy', { pos: [10, 6] });
h.runUntil(() => u.skill.activations === 1, 10);
h.runUntil(() => !u.skill.active, 60);
assert.equal(h.hooksOf('ammoUsed').length, 14 + 2);
assert.equal(u.s.taunt, 0, 'taunt −1 removed after the skill');
});
test('SIM.md example 2: 幽灵鲨 undying during the skill, self-stun afterwards', () => {
const kit = (bb) => ({
skill: {
kind: 'duration', mods: { atkPct: bb.atk },
onStart({ battle, unit }) { unit.mem.undying = battle.on('fatal', (c) => { if (c.unit === unit) c.prevented = true; }, { owner: unit }); },
onEnd({ battle, unit, reason }) { battle.off(unit.mem.undying); if (reason !== 'death') battle.applyStatus(unit, 'stun', { duration: bb.stun, source: unit }); },
},
});
const h = makeBattle({
defs: { enemies: { enemy_dummy: dummy() } }, kits: { chess_char_2_07_a: kit },
units: [{ chessId: 'chess_char_2_07_a', row: 9, col: 5 }], enemies: [{ key: 'enemy_dummy', pos: [9, 6] }],
});
const u = h.unit('chess_char_2_07_a');
h.runUntil(() => u.skill.active, 60);
h.b.dealDamage(null, u, { amount: 1e9, type: 'true' });
assert.equal(u.alive, true);
assert.ok(u.hp >= 1);
h.runUntil(() => !u.skill.active, 20);
h.step();
assert.ok(u.s.flags.stun);
h.b.dealDamage(null, u, { amount: 1e9, type: 'true' });
assert.equal(u.alive, false, 'undying ended with the skill');
});
test('SIM.md example 5: 赫默 brings her placed medical drone onto its tile; it expires after 10 s', () => {
const kit = (bb) => ({
skill: {
kind: 'instant', heal: true,
onStart({ battle, unit }) { releaseSkillSummon(battle, unit, 'token_10000_silent_healrb', { cap: bb.cnt }); },
},
});
const h = makeBattle({
defs: { chess: { t_guard: chessRec({ id: 't_guard', profession: 'WARRIOR', skill: null, stats: { atk: 0, maxHp: 1e5 } }) } },
kits: { chess_char_2_02_a: kit },
units: [{ chessId: 'chess_char_2_02_a', row: 10, col: 4, uid: 1 }, { chessId: 't_guard', row: 10, col: 5, uid: 2 }, { kind: 'token', tokenId: 'token_10000_silent_healrb', ownerUid: 1, row: 11, col: 4, uid: 3 }],
});
const u = h.unit('chess_char_2_02_a');
const drone = h.unit(3);
h.step();
assert.equal(drone.alive, true, 'the placed piece deploys once with the board (SKILL_SUMMON_START_DEPLOY)');
h.run(10.1);
assert.equal(drone.alive, false, 'its 10 s');
h.unit('t_guard').hp = 1000;
h.runUntil(() => u.skill.activations === 1, 60);
h.step();
assert.ok(drone.alive && drone.tileR === 11 && drone.tileC === 4);
assert.equal(drone.profile.dmgType, 'heal');
h.run(10.1);
assert.equal(drone.alive, false);
});
test('SIM.md example 6: 古米 备用军粮 — an AUTO heal skill cast by an injured ally of its range (no enemy), the next attack is the heal', () => {
const kit = (bb, chess, def) => ({
skill: {
kind: 'instant', heal: true,
trigger: { rule: 'SKILL_RANGE', grid: def.skill.rangeGrid, allies: true },
targeting: { rangeGrid: def.skill.rangeGrid },
attack: { dmgType: 'heal', heal: { mode: 'single' }, healScale: bb.heal_scale },
},
});
const h = makeBattle({
defs: { chess: { t_ally: chessRec({ id: 't_ally', skill: null, stats: { maxHp: 10000, atk: 0 } }) } },
kits: { chess_char_1_10_a: kit },
units: [{ chessId: 'chess_char_1_10_a', row: 9, col: 5 }, { chessId: 't_ally', row: 10, col: 5 }],
autoFinish: false, // no enemy at all
});
const g = h.unit('chess_char_1_10_a');
h.run(7);
assert.equal(g.skill.rule, 'SKILL_RANGE');
assert.equal(g.skill.activations, 0, 'ready, nobody injured');
h.unit('t_ally').hp = 2000;
h.run(2);
assert.equal(g.skill.activations, 1);
approx(h.unit('t_ally').hp, 2000 + g.s.atk * g.def.skill.bb.heal_scale, 'healed by her heal-mode attack');
checkInvariants(h.b);
});