diff --git a/docs/SIM.md b/docs/SIM.md index a0040d45..ccefa0a9 100644 --- a/docs/SIM.md +++ b/docs/SIM.md @@ -83,6 +83,12 @@ the players' fields deploy side by side: the i-th operators of all players come the summons the same way, and the summons rank after the operators of all players **[ASSUMED]** (PRTS describes one field — units deploy one after another with a fixed delay from the battle start — and "两处阵地将前后拼接为一处阵地"). Register hooks before the first step (e.g. `opts.setup(battle)` or right after `new Battle`). +外勤医疗's prepared slot is a preparation view record, not a combat `Unit`. The `battleStart` handler creates either +预备干员-医疗 or Touch after counting deployed elites. [ASSUMED] Its effective targeting order precedes ordinary +initial deployments (`preBattleAggroSeq`); its actual `deploySeq` still identifies the later runtime spawn. Prepared +slots on a shared field follow player order [ASSUMED]. A later `spawnMapChar` without this option keeps its ordinary +summon order (§29.15). + **Tick order:** scheduled callbacks → spawns → DP → buffs (+HP regen) → enemies (attack, move, block) → enemy tile index → allies (skill tick, attack) → projectiles → auto-redeploys → boss pool sync → `tick` hook → release hooks/timers of units removed this tick (§1.4) → `time += TICK` → end checks. @@ -533,7 +539,8 @@ Getters: `s` (aggregated stats), `maxHp`, `atk`, `hpRatio`, `sp`, `spMax`, `canA flag `float` (近地悬浮, PRTS 术语释义 "算作空中单位") or `levitate` (浮空 "变为空中单位") — never an enemy under 缚地 (flag `groundbind`, "目标变为地面单位") unless a 浮空 lifts it again; movement and pathing read `motion` (a hovering enemy keeps walking the ground path). `deploySeq` counts deployments (and identifies one: `seq === u.deploySeq`); -`aggroSeq` is the aggro order (= deploySeq, except the summons of the initial deployment, §1). +`aggroSeq` is the aggro order (= deploySeq, except the summons of the initial deployment and prepared 外勤医疗 map +characters, §1). 克莱门莎 S2's kit stores its cabin in `unit.mem.clemntCabin`. Before boarding each tick, it removes passengers that died, became hidden / uncarryable or cannot path to the next cabin position, removes their carry buff and @@ -891,7 +898,7 @@ instance) and skip `'counter'` / `'reflect'` damage. When the guard trips, the l | `applyStatus(tgt, key, {duration, source, value, force, point, stackAs})`, `removeStatus(tgt, key)`, `resistOf(unit)` | §3 | | `applyStrongest(tgt, key, {duration, value, mods, source})` | §3 — "同名效果取最高" for a non-catalogue effect | | `addBuff(unit, buff)`, `removeBuff(unit, key)` | §3 | -| `spawnToken(ownerUnit | playerId, tokenId, row, col, { def, stats, hp, duration, untargetable, dir, kit, force, anySource })` | field tiles; def from data/tokens.json `variants[ownerChessId]` for the owner unit's selected skill / module (`tokenDef`); `dir` defaults to the owner unit's (else the player's: RIGHT, mirrored side LEFT; a legacy `facing` ±1 is still read); returns the token or null (tile busy; or the owner runs a **non-default** skill that does not produce the token — `producesToken` — unless `anySource`: kit install hooks written for the default skill run under every skill). `spawnDevice(key, row, col, { …, dir })` likewise | +| `spawnToken(ownerUnit | playerId, tokenId, row, col, { def, stats, hp, duration, untargetable, dir, kit, force, anySource, preBattleAggroSeq })` | field tiles; def from data/tokens.json `variants[ownerChessId]` for the owner unit's selected skill / module (`tokenDef`); `dir` defaults to the owner unit's (else the player's: RIGHT, mirrored side LEFT; a legacy `facing` ±1 is still read); `preBattleAggroSeq` is a negative priority reserved for a prepared stage map character, before ordinary initial units; returns the token or null (tile busy; or the owner runs a **non-default** skill that does not produce the token — `producesToken` — unless `anySource`: kit install hooks written for the default skill run under every skill). `spawnDevice(key, row, col, { …, dir })` likewise | | `tokenDef(tokenId, ownerUnit | chessId)`, `producesToken(ownerUnit, tokenId)` | the token def a summon of that owner gets — `getToken(id, owner.defId, owner.def.loadout)`, exact even when two players of one field give the same chess different loadouts (prefer it over an id-only `battle.data.getToken(id, unit.defId)` for summon stats / blackboards); whether the owner's loadout makes the token (DATA.md §14 `sources` has 'skill' or 'talent'; true when the data does not tell: no own variant, player-owned summons) | | `spawnEnemy(enemyKey, { routeIndex, route, pos, mods, tag, sourcePlayerId, ownerPlayerId, bounty, countInTotal, inTotal, def })` | returns the enemy, or null past `MAX_ALIVE_ENEMIES`; `def` = inline record (enemies.json shape or normalised) for keys missing from data. A runtime spawn is never `inTotal` (§1.3 — the HUD capsule's own set) unless content passes `inTotal: true` explicitly | | `spawnDevice(key, row, col, { hp, obstacle, blockCnt, name, def, res, atk, bat, aspd })`, `setObstacle(r, c, on)` | obstacles re-path enemies; spawnDevice returns null outside the rect, on a living unit or on a knocked-out operator's tile | diff --git a/docs/design/engine.md b/docs/design/engine.md index ffe067f7..66e0686a 100644 --- a/docs/design/engine.md +++ b/docs/design/engine.md @@ -117,6 +117,12 @@ Engine helpers (content must use these, never touch internals): `battle.dealDama ### 5.5 Combat rules (engine) +- **Prepared 外勤医疗 slot**: 预备干员-医疗 is visible on the field during preparation. At `battleStart`, the elite count + chooses either that medic or its Touch replacement for the same slot. [ASSUMED] This replacement does not move the + slot behind the ordinary starting operators in effective deployment priority: both variants receive an earlier + `aggroSeq`, while their actual `deploySeq` still records the later runtime creation and guards deployment-scoped + effects. On a shared field, prepared slots follow player order [ASSUMED]. An ad-hoc map-character spawn during + combat retains ordinary summon priority. See §29.15 and SIM.md §1.2. - **Initial deployment** at t=0, free: operators by column — the left column first, top to bottom within a column (right-side boss player: from its own left, the highest field column) — then the summons (PRTS 卫戍协议/帮助 "按从上到下>从左到右的顺序部署。优先部署干员,随后为召唤物", read as a scan: down each column, the columns left to right — the order PRTS gives the 阿戈尔 devour, "更靠左和靠上"; row-major until 0.1.3, §23.23; `aggroSeq` ranks every start-of-battle summon after all operators) — a skill's placed summon (赫默 医疗探机, 巫恋 诅咒娃娃) included, once and free ("所有手动部署的召唤物,无视所属干员的持有状态…作战开始时立即部署一次"; afterwards it re-appears on its tile each time the owner's skill gives one, §20.1); on a shared field (联防, boss) the players' i-th operators deploy together [ASSUMED]. Deploy effects fire (`deploy` with `initial: true`). Then operators carried into 联防 knocked out (`carryState.down`) are forced out (`FORCED_EXIT`, HP 0, §19.3). Then `battleStart`, after which the forced-out operators' timers are re-read (redeploy-time effects that start with the battle, e.g. 机变 征召, cover them too). - **DP**: per player, start 10, +1/s, cap 99; used only for auto-redeploy (dead op: after `respawnTime`, if the tile it lies on is free and DP ≥ cost ⇒ redeploy there with full HP, SP = initSp). A knocked-out operator (and, since 0.1.2, one forced out by its own effects, §22.15) stays **down** on the tile it fell on — its own home when it fell on another board piece's home (that piece on the field or not) and its home is free, and 乌尔比安 knocked out while his S3 has moved him always on his deployment tile when it is free (the owner's deviation of 2026-10-07, `Unit.downAtHome`, §25.17.3) — until it redeploys there, and no ally deploys or moves onto that tile meanwhile (PRTS 卫戍协议/帮助 §作战阶段 单位部署; `Battle.downOn` / `restTile` / `_layBody`, §21.24; b.snap `down`, §18.3: counting / waiting for DP / its tile taken, a safeguard) — also one that entered 联防 knocked out (`FORCED_EXIT`, its full redeploy timer — confirmed by the user — with the battle-start redeploy effects, §19.3); summons, devices and enemies leave at once. - **Blocking** (contact radius, PRTS 游戏数据基础 §阻挡半径 / 作战机制 "中点判定…案例:阻挡"; `constants.js BLOCK_RADIUS`, `Battle._checkBlock`, §19.2): an operator with free capacity blocks an unblocked, blockable enemy whose position lies within its block radius of its centre — ground 0.7071 (squared 0.49999037), 0.8944 × the blocker's 阻挡半径倍率 for blockFly units vs flyers (起飞; mod `blockRadiusScale` = 倍率 − 1 — PRTS 游戏数据基础 "飞行阻挡半径 = 0.8944 × 阻挡半径倍率", 凯尔希·思衡托 +0.23), devices 0.4472 (阻隔工事 / 障碍物); air units (FLY, 近地悬浮, 浮空) only by blockFly units. A ground enemy is never blocked by a unit standing on a tile ground units cannot pass (围墙 / 围栏: PRTS 地形机制 "部署在其中的单位,若当前阻挡类型为'地面阻挡'则无法阻挡敌人" — an enemy pushed or pulled against the fence walks on; air blocking there stays [ASSUMED], §21.23) nor by an airborne (起飞) unit, which blocks flyers only (§21.22). An enemy holding 不可阻挡 (PRTS 异常效果 BLOCK_FREE 「无法阻挡/被阻挡,自动解除阻挡」) — `unblockable` (恐惧, 诱导, enemy abilities), 浮空, and 沉睡 (SLEEPING = 无法行动+无敌+不可阻挡) — is never blocked and is released at once: a sleeping enemy frees its blocker's slot, stays where it is and, once awake, is blocked again only by a blocker with room (§24.9). The nearest such operator wins (ties: scan order [ASSUMED]). It is re-checked every tick, moving or not, so another operator in contact with room takes the enemy over when its blocker dies, is withdrawn or is stunned, and an operator whose capacity frees up grabs an overlapping enemy; one that finds no room walks on. A stunned or frozen enemy is checked too — 晕眩 / 冻结 hold no 不可阻挡 (PRTS 异常效果: the STUN / FROZEN state machines stop its moves and attacks) —, so an operator redeployed beside a held enemy blocks it where it stands and lifts its 隐匿; one held short of contact is blocked once it walks in after the status (GitHub #232; until 0.2.0 the check waited for the status to end). A head-on enemy stops at contact (≈ 0.71 tile), outside the blocker's tile. Enemy uses `blockCnt` capacity (default 1). Blocked enemies stop moving and attack their blocker if melee (or anyone in range if ranged, blocker first). **Every blocker** — melee units (重装要塞 / 领主 / 哨戒铁卫 included), summons and a ranged operator on a melee tile alike — whose attack hits enemies may always target the enemies it blocks, in range or not, whatever its facing, and targets them first — a 速射手's air priority (优先攻击空中单位) excepted, which comes before the enemy it blocks (the owner's decision of 2026-10-08, GitHub #220) — ("可以选择且优先选择阻挡单位", PRTS 选择器; the user's rule after playtest #6, "阻挡了就一定要能打到": officially the collision pushes a blocked enemy to its blocker's front; `Battle.blockedTargets`, `targeting.js sortEnemyTargets`; §20.3 — it replaces the playtest #5 QA's melee-only restriction of §19.2). A healer (dmgType `heal`, or a skill attack turned into a heal) selects injured allies only and keeps healing while it blocks (PRTS 卫戍协议/帮助 "对于医疗干员(咒愈师分支除外),攻击目标为需要治疗的单位"; §21.17); 咒愈师 follow the blocker rule. The huge leaders are 自缚 + unblockable (§7). diff --git a/docs/history/0.2.4.md b/docs/history/0.2.4.md index 9f5c8917..02262ca7 100644 --- a/docs/history/0.2.4.md +++ b/docs/history/0.2.4.md @@ -274,3 +274,25 @@ enemy: picking emitted a unit click with no definition, instead of the tile clic engine-canvas regression retains the card/100 HP assertions and also covers another field refresh, live HP loss and closing the card when the crate is destroyed. Device metadata supplied by the new entry still wins; changing fields does not carry old devices across. Gameplay and allied targeting rules are unchanged. + +### 29.15 Prepared 外勤医疗 target order (follow-up to #451) + +PR #451 made 预备干员-医疗 visible in preparation but deliberately left its initial aggro order unchanged. In the +user-provided [卫戍协议 recording](https://b23.tv/RQLI8WS), the right-side 联防 board at 19:13 has Touch and 哈洛德 +inside the same flying 守墓石像's attack range when it locks its target, yet the attack selects 哈洛德. The 17:01 +preparation frame shows 哈洛德 with no equipment, and his position makes him the right player's first ordinary +deployment under the current column scan. The 19:36 clip supplies another targeting comparison. These observations +support an effective priority earlier than ordinary operators for the prepared 外勤医疗 slot; they do not expose the +official game's unit identity or exact deployment counters. + +The battle sim creates the selected map-character variant at `battleStart`, after deploying the board. [ASSUMED] +The prepared slot retains an earlier effective targeting order whether it stays 预备干员-医疗 or is replaced by Touch. +Only `aggroSeq` gets a negative, pre-initial value; `deploySeq` remains the actual spawn's identity for deployment +hooks and scheduled effects. [ASSUMED] If several players have prepared slots, their relative order follows the +existing player order. A map character spawned ad hoc after battle start keeps normal summon order. The real flying +守墓石像 tests check both variants at target-lock time, a right-side 联防 Touch, and the higher-taunt exception. + +`npm run golden:update` recomputed all 287 scenarios. Only `coop2-NORMAL-14-standins` changed: its human seat uses +`band_amedic`, and combat differences first appear in round 11. The match remains a round-14 victory with team LP 31; +that seat's final kills move 272 → 273 and leaks 44 → 43. Its boss damage moves 193,091 → 189,876, while the partner's +moves 586,909 → 590,124. All other golden scenarios retain their prior result. diff --git a/server/sim/battle/deploy.js b/server/sim/battle/deploy.js index d859660b..7407aae2 100644 --- a/server/sim/battle/deploy.js +++ b/server/sim/battle/deploy.js @@ -13,7 +13,7 @@ export class BattleDeploy { * operator that left the field comes back on its body tile, restTile). `keepSp` = { sp, charges } * restored right after the skill reset, before the `deploy` hook fires. */ - _deploy(u, { initial = false, carry = null, tile = null, keepSp = null } = {}) { + _deploy(u, { initial = false, carry = null, tile = null, keepSp = null, preBattleAggroSeq = null } = {}) { if ((u.alive && u.deployed) || u._removing) return false; const R0 = tile ? tile[0] : u.homeR, C0 = tile ? tile[1] : u.homeC; if (!this.grid.inRect(R0, C0)) { @@ -37,7 +37,9 @@ export class BattleDeploy { u.x = C0; u.y = R0; u.tileR = R0; u.tileC = C0; u.blocking = []; u.deploySeq = ++this._deploySeq; - u.aggroSeq = u.deploySeq; + // A prepared map character is instantiated after the board deployment but keeps an earlier target order. + // Its deploySeq remains the identity of this actual deployment for scheduled effects and redeploy checks. + u.aggroSeq = preBattleAggroSeq ?? u.deploySeq; u.deployedAt = this.time; u.atkCd = 0; u.lastAttackAt = -Infinity; diff --git a/server/sim/battle/summons.js b/server/sim/battle/summons.js index e5547f51..490ac257 100644 --- a/server/sim/battle/summons.js +++ b/server/sim/battle/summons.js @@ -60,7 +60,7 @@ export class BattleSummons { if (opts.stats) for (const [k, v] of Object.entries(opts.stats)) if (Number.isFinite(v)) u.base[k] = v; this._setupUnit(u, opts.kit ?? null); if (opts.untargetable) this.addBuff(u, { key: 'trait:untargetable', flags: { untargetable: true }, persist: true, allowDead: true }); - if (!this._deploy(u, { initial: false })) { + if (!this._deploy(u, { initial: false, preBattleAggroSeq: opts.preBattleAggroSeq })) { // tile still busy (a unit stands there even with `force`): drop the half-built token and its hooks u.removed = true; this.offOwner(u); diff --git a/server/sim/content/bands/battle.js b/server/sim/content/bands/battle.js index a1c46ca4..278eeaaf 100644 --- a/server/sim/content/bands/battle.js +++ b/server/sim/content/bands/battle.js @@ -238,12 +238,17 @@ function installMapChars(battle) { const holders = battle.players.filter((ps) => matchBands(battle, ps.playerId).includes(AMEDIC_BAND)); if (!holders.length) return; battle.on('battleStart', () => { + const chars = []; for (const ps of holders) { const elites = deployedOps(battle, ps.playerId).filter(isElite).length; - for (const id of amedicCharsFor(elites, variants)) { - const u = spawnMapChar(battle, ps.playerId, id); - if (u) fxOn(battle, 'summon', u, keyOf(AMEDIC_BAND), AMEDIC_BAND); - } + for (const id of amedicCharsFor(elites, variants)) chars.push({ playerId: ps.playerId, id }); + } + for (const [i, { playerId, id }] of chars.entries()) { + // The reserve medic occupies this stage slot in preparation; Touch replaces it at battle start. [ASSUMED] + // Replacement preserves the slot's priority before ordinary deployments. Shared-field ordering between + // prepared characters follows player order, as for other initial placements (lifecycle.js). + const u = spawnMapChar(battle, playerId, id, { preBattleAggroSeq: i - chars.length }); + if (u) fxOn(battle, 'summon', u, keyOf(AMEDIC_BAND), AMEDIC_BAND); } }); } diff --git a/server/sim/content/tokens.js b/server/sim/content/tokens.js index 442bea2a..bab6d48c 100644 --- a/server/sim/content/tokens.js +++ b/server/sim/content/tokens.js @@ -1566,9 +1566,11 @@ function touchKit(bb, raw, def) { /** * Spawn a band map character (char_605_cmedic 预备干员-医疗 / char_613_acmedc Touch) at its stage position on the - * player's half (data/stages.json `mapChars`; `_multi_only` positions only with a partner). Returns the unit or null. + * player's half (data/stages.json `mapChars`; `_multi_only` positions only with a partner). A prepared character may + * supply `preBattleAggroSeq` so its targeting order precedes the ordinary battle-start deployment. Returns the unit + * or null. */ -export function spawnMapChar(battle, playerId, tokenId, { alias = null } = {}) { +export function spawnMapChar(battle, playerId, tokenId, { alias = null, preBattleAggroSeq = null } = {}) { const list = battle.stage?.raw?.mapChars ?? battle.stage?.mapChars ?? []; const ps = battle.getPlayer(playerId); const multi = battle.players.length > 1; @@ -1585,7 +1587,7 @@ export function spawnMapChar(battle, playerId, tokenId, { alias = null } = {}) { for (const m of cands) { if (!tileFree(battle, m.pos[0], m.pos[1])) continue; // stage positions are field tiles: their direction is taken as it is (default RIGHT) - const u = battle.spawnToken(playerId, tokenId, m.pos[0], m.pos[1], { dir: normDir(m.dir) }); + const u = battle.spawnToken(playerId, tokenId, m.pos[0], m.pos[1], { dir: normDir(m.dir), preBattleAggroSeq }); if (u) return u; } return null; diff --git a/server/sim/targeting.js b/server/sim/targeting.js index eeef5d30..e54f8ebd 100644 --- a/server/sim/targeting.js +++ b/server/sim/targeting.js @@ -224,7 +224,8 @@ export function sortEnemyTargets(battle, attacker, cands, priority) { /** * Enemy target selection among allies (PRTS 作战机制 索敌, 敌方: "阻挡→特殊优先级→仇恨值(更容易被攻击→…→最后部署的目标→ * 不容易被攻击)→最早出现"): its blocker first → highest taunt level → latest deployed (`aggroSeq`: the deploy order — - * Battle.start deploys the operators first and ranks the start-of-battle summons after them). Special priorities + * Battle.start deploys the operators first and ranks the start-of-battle summons after them; a prepared 外勤医疗 map + * character keeps an earlier aggro order). Special priorities * (优先攻击…) are the enemies' own content: `e.profile.canTarget` filters, key sorts broken by `aggroCmp`. */ export function sortAllyTargets(enemy, cands) { diff --git a/server/sim/units.js b/server/sim/units.js index 39895c52..56693466 100644 --- a/server/sim/units.js +++ b/server/sim/units.js @@ -77,7 +77,7 @@ export class Unit { this.deathAt = -Infinity; this.respawnAt = Infinity; this.deploySeq = 0; // deployment counter; also the identity of one deployment (content: `seq === u.deploySeq`) - this.aggroSeq = 0; // 仇恨 order (the later the more attacked): = deploySeq, except summons of the initial deployment + this.aggroSeq = 0; // 仇恨 order: usually deploySeq; initial summons and prepared map characters are exceptions this.spawnSeq = 0; this.elem = { burn: 0, neural: 0, necrosis: 0, apoptosis: 0, erosion: 0 }; this.burstPending = null; // { [element]: true } while that element's burst resolves (damage.js burstLocked) diff --git a/test/content/bands.test.js b/test/content/bands.test.js index 638857db..0b4d6b5e 100644 --- a/test/content/bands.test.js +++ b/test/content/bands.test.js @@ -711,6 +711,91 @@ test('Touch 外勤医疗: every player of a match with the band gets 预备干 cover('band_amedic'); }); +test('外勤医疗: 预备干员-医疗 and Touch keep preplaced targeting order against a flying 守墓石像', () => { + const defs = { + harold: chessRec({ id: 'harold', profession: 'TANK', skill: null, stats: { atk: 0, maxHp: 1e7, blockCnt: 0 } }), + elite1: chessRec({ id: 'elite1', golden: true, profession: 'TANK', skill: null, stats: { atk: 0, maxHp: 1e7, blockCnt: 0 } }), + elite2: chessRec({ id: 'elite2', golden: true, profession: 'TANK', skill: null, stats: { atk: 0, maxHp: 1e7, blockCnt: 0 } }), + }; + for (const [eliteCount, mapCharId] of [[1, 'char_605_cmedic'], [2, 'char_613_acmedc']]) { + const h = makeBattle({ + stageId: 'act2autochess_m01', bandId: 'band_amedic', autoFinish: false, timeLimit: 100, + defs: { chess: defs }, units: [ + { chessId: 'harold', row: 11, col: 3 }, + { chessId: 'elite1', row: 12, col: 8 }, + ...(eliteCount === 2 ? [{ chessId: 'elite2', row: 9, col: 8 }] : []), + ], + }); + h.step(); + const medic = h.unit(mapCharId), harold = h.unit('harold'); + const ops = h.allies().filter((u) => u.kind === 'op'); + assert.ok(medic?.alive && harold?.alive, mapCharId); + assert.ok(ops.every((u) => medic.deploySeq > u.deploySeq), 'battleStart creates the map character after initial deployment'); + assert.ok(ops.every((u) => medic.aggroSeq < u.aggroSeq), 'its targeting order precedes every initial operator'); + assert.equal(medic.s.taunt, harold.s.taunt, 'the two targets have equal taunt'); + + const gargoyle = h.spawn('enemy_1172_dugago', { pos: [10, 3], routeIndex: 0, mods: { speedMul: 0 } }); + assert.ok(gargoyle); + h.b.kill(gargoyle, null); // first knock-out changes 守墓石像 into its flying form + assert.ok(gargoyle.alive); + const attacks = []; + h.b.on('enemyAttackStart', ({ enemy, targets }) => { + if (enemy === gargoyle && gargoyle.motion === 'FLY') attacks.push({ target: targets[0], x: enemy.x, y: enemy.y }); + }); + assert.ok(h.runUntil(() => attacks.length > 0, 20), 'flying gargoyle starts an attack'); + const { target, x, y } = attacks[0]; + const reach = gargoyle.base.rangeRadius + 0.25; + for (const u of [harold, medic]) assert.ok((u.x - x) ** 2 + (u.y - y) ** 2 <= reach ** 2, `${u.defId} is in range at target lock`); + assert.equal(gargoyle.blockedBy, null); + assert.equal(target, harold, `${mapCharId}: the later ordinary operator is selected`); + h.b.addBuff(medic, { key: 'test:taunt', mods: { taunt: 1 }, persist: true }); + assert.ok(h.runUntil(() => attacks.length > 1, 20), 'gargoyle starts another attack'); + assert.equal(attacks[1].target, medic, 'higher taunt still takes precedence over deployment order'); + checkInvariants(h.b); + } +}); + +test('外勤医疗: 联防右侧 Touch retains its prepared targeting order', () => { + const defs = { + harold: chessRec({ id: 'harold', profession: 'TANK', skill: null, stats: { atk: 0, maxHp: 1e7, blockCnt: 0 } }), + elite1: chessRec({ id: 'elite1', golden: true, profession: 'TANK', skill: null, stats: { atk: 0, maxHp: 1e7, blockCnt: 0 } }), + elite2: chessRec({ id: 'elite2', golden: true, profession: 'TANK', skill: null, stats: { atk: 0, maxHp: 1e7, blockCnt: 0 } }), + }; + const players = [ + { playerId: 'L', seat: 0, side: 'L', colOffset: 0, bandId: 'band_amedic', bonds: {}, playerEffects: [], units: [] }, + { playerId: 'R', seat: 1, side: 'R', colOffset: 8, bandId: 'band_amedic', bonds: {}, playerEffects: [], units: [ + { uid: 1, kind: 'chess', chessId: 'harold', row: 11, col: 3 }, + { uid: 2, kind: 'chess', chessId: 'elite1', row: 12, col: 8 }, + { uid: 3, kind: 'chess', chessId: 'elite2', row: 9, col: 8 }, + ] }, + ]; + const h = makeBattle({ kind: 'unite', stageId: 'act2autochess_m01', players, defs: { chess: defs }, autoFinish: false }); + h.step(); + const leftMedic = h.allies().find((u) => u.ownerId === 'L' && u.defId === 'char_605_cmedic'); + const rightTouch = h.allies().find((u) => u.ownerId === 'R' && u.defId === 'char_613_acmedc'); + const harold = h.allies().find((u) => u.ownerId === 'R' && u.defId === 'harold'); + assert.ok(leftMedic && rightTouch && harold); + assert.deepEqual([leftMedic.tileR, leftMedic.tileC], [10, 2]); + assert.deepEqual([rightTouch.tileR, rightTouch.tileC], [10, 10]); + assert.ok(leftMedic.aggroSeq < rightTouch.aggroSeq && rightTouch.aggroSeq < harold.aggroSeq); + assert.ok(rightTouch.deploySeq > harold.deploySeq); + + const gargoyle = h.spawn('enemy_1172_dugago', { pos: [10, 11], routeIndex: 0, mods: { speedMul: 0 } }); + assert.ok(gargoyle); + h.b.kill(gargoyle, null); + const attacks = []; + h.b.on('enemyAttackStart', ({ enemy, targets }) => { + if (enemy === gargoyle && enemy.motion === 'FLY') attacks.push({ target: targets[0], x: enemy.x, y: enemy.y }); + }); + assert.ok(h.runUntil(() => attacks.length > 0, 20)); + const { target, x, y } = attacks[0]; + const reach = gargoyle.base.rangeRadius + 0.25; + for (const u of [harold, rightTouch]) assert.ok((u.x - x) ** 2 + (u.y - y) ** 2 <= reach ** 2); + assert.equal(gargoyle.blockedBy, null); + assert.equal(target, harold); + checkInvariants(h.b); +}); + test('coverage: every band is exercised by a test above', () => { cover('band_dusk'); // 夕: 画卷 grant (fixed-round test) + 墨色真颜 (battle test) const missing = Object.keys(DATA.bands).filter((id) => !COVER.has(id)).sort(); diff --git a/test/content/tokens_devices.test.js b/test/content/tokens_devices.test.js index 77dbd84c..0ce45889 100644 --- a/test/content/tokens_devices.test.js +++ b/test/content/tokens_devices.test.js @@ -511,6 +511,7 @@ test('band map characters: spawnMapChar puts 预备干员-医疗 at its stage sl assert.ok(med); assert.deepEqual([med.tileR, med.tileC], [10, 2]); const gu = h.unit('test_guard'); + assert.ok(med.aggroSeq > gu.aggroSeq, 'an ad-hoc map character keeps ordinary summon priority'); gu.hp = 5000; h.run(4); assert.ok(gu.hp > 5000, 'healed'); @@ -518,6 +519,7 @@ test('band map characters: spawnMapChar puts 预备干员-医疗 at its stage sl h.step(); const touch = spawnMapChar(h.b, 'p1', TOKEN_IDS.touch); assert.ok(touch); + assert.ok(touch.aggroSeq > gu.aggroSeq, 'an ad-hoc Touch also keeps ordinary summon priority'); touch.skill.activate('test', { free: true }); gu.hp = 3000; h.run(4); diff --git a/test/golden/matches.json b/test/golden/matches.json index d03ea8ed..1bc7f22b 100644 --- a/test/golden/matches.json +++ b/test/golden/matches.json @@ -1575,17 +1575,17 @@ { "round": 11, "h_0": [1,28,12,0,0,5,8,"b5da5048",139,"arcaneShip 0/8, deputShip 0/6, emptyShip 1/6, kazimierzShip 0/4, preciShip 1/42, raidShip 1/31, skillfulShip 0/2, soloShip 1/6, steadShip 1/20, swiftShip 1/34, yanShip 0/1",25,25,0,98], - "ai_0": [1,23,12,0,0,5,8,"083c8c02",149,"arcaneShip 1/19, deputShip 0/8, kazimierzShip 0/8, lateranoShip 1/5, preciShip 2/24, raidShip 1/64, sargonShip 0/2, suntShip 1/8, swiftShip 1/29",25,25,0,99] + "ai_0": [1,23,12,0,0,5,8,"083c8c02",161,"arcaneShip 1/19, deputShip 0/8, kazimierzShip 0/8, lateranoShip 1/11, preciShip 2/30, raidShip 1/64, sargonShip 0/2, suntShip 1/8, swiftShip 1/29",25,25,0,99] }, { "round": 12, "h_0": [1,28,12,0,0,5,8,"093d3c03",157,"arcaneShip 0/8, deputShip 0/6, egirShip 1/3, emptyShip 0/6, kazimierzShip 0/4, preciShip 1/49, raidShip 1/36, skillfulShip 0/2, soloShip 1/6, steadShip 1/24, suntShip 1/0, swiftShip 1/39, yanShip 0/1",23,31,8,109], - "ai_0": [1,23,12,0,0,6,8,"7258fcd5",191,"arcaneShip 1/21, deputShip 0/8, kazimierzShip 0/8, lateranoShip 1/11, preciShip 2/37, raidShip 1/80, sargonShip 0/2, suntShip 1/8, swiftShip 1/34",31,31,0,112] + "ai_0": [1,23,12,0,0,6,8,"7258fcd5",206,"arcaneShip 1/24, deputShip 0/8, kazimierzShip 0/8, lateranoShip 1/17, preciShip 2/43, raidShip 1/80, sargonShip 0/2, suntShip 1/8, swiftShip 1/34",31,31,0,112] }, { "round": 13, - "h_0": [1,18,12,0,0,6,8,"ba279997",190,"arcaneShip 0/8, deputShip 0/6, egirShip 1/11, emptyShip 0/6, kazimierzShip 0/4, preciShip 1/54, raidShip 1/44, skillfulShip 0/2, soloShip 1/6, steadShip 1/31, suntShip 1/0, swiftShip 1/44, yanShip 0/1",21,57,36,120], - "ai_0": [1,13,12,0,0,6,8,"284baa2f",234,"arcaneShip 0/21, deputShip 0/8, kazimierzShip 0/8, lateranoShip 1/17, preciShip 2/48, raidShip 1/112, sargonShip 0/2, siracusaShip 0/6, soloShip 1/0, steadShip 1/4, suntShip 1/8, swiftShip 1/45",31,57,26,122] + "h_0": [1,18,12,0,0,6,8,"ba279997",190,"arcaneShip 0/8, deputShip 0/6, egirShip 1/11, emptyShip 0/6, kazimierzShip 0/4, preciShip 1/54, raidShip 1/44, skillfulShip 0/2, soloShip 1/6, steadShip 1/31, suntShip 1/0, swiftShip 1/44, yanShip 0/1",22,57,35,120], + "ai_0": [1,13,12,0,0,6,8,"284baa2f",246,"arcaneShip 0/24, deputShip 0/8, kazimierzShip 0/8, lateranoShip 1/23, preciShip 2/54, raidShip 1/112, sargonShip 0/2, siracusaShip 0/6, soloShip 1/0, steadShip 1/4, suntShip 1/8, swiftShip 1/45",31,57,26,122] } ], "players": { @@ -1599,7 +1599,7 @@ "title": {"id":"comment_3","name":"坚若磐石","picId":"comment_icon_3","text":"目标生命值损失最少"}, "trophies": 4, "reward": 400, - "stats": {"activatedLayers":172,"bossDamage":193091,"dmgDealt":2564165,"gold":131,"itemsEquipped":16,"kills":272,"leaks":44,"lpLost":10,"merges":4,"perfectRounds":11,"refreshes":13}, + "stats": {"activatedLayers":172,"bossDamage":189876,"dmgDealt":2565610,"gold":131,"itemsEquipped":16,"kills":273,"leaks":43,"lpLost":10,"merges":4,"perfectRounds":11,"refreshes":13}, "lineup": ["4_14_a@12,3[4_07_e_b+4_03_e_a]","3_10_b@11,3","6_04_a@11,4","3_09_a@11,8[3_08_e_a]","1_17_b@10,3[1_01_e_a+6_05_e_a]","5_05_a@10,4[3_04_e_a+4_02_e_a]","3_05_b@10,8[5_02_e_b+3_03_e_a]","2_17_a@9,4"], "bonds": ["arcaneShip 1/8","deputShip 0/6","egirShip 1/11","emptyShip 0/6","kazimierzShip 0/8","preciShip 1/59","raidShip 0/44","skillfulShip 0/2","soloShip 1/6","steadShip 1/35","suntShip 1/0","swiftShip 1/53","yanShip 0/1"] }, @@ -1613,9 +1613,9 @@ "title": {"id":"comment_1","name":"卫戍之星","picId":"comment_icon_1","text":"对敌方领袖造成伤害最高(仅胜利时)"}, "trophies": 4, "reward": 400, - "stats": {"activatedLayers":267,"bossDamage":586909,"dmgDealt":3838927,"gold":134,"itemsEquipped":19,"kills":276,"leaks":26,"lpLost":10,"merges":4,"perfectRounds":12,"refreshes":18}, + "stats": {"activatedLayers":282,"bossDamage":590124,"dmgDealt":3843408,"gold":134,"itemsEquipped":19,"kills":276,"leaks":26,"lpLost":10,"merges":4,"perfectRounds":12,"refreshes":18}, "lineup": ["4_10_a@12,3","4_01_a@12,8[6_02_e_a+2_01_e_a]","6_12_a@11,3[3_05_e_a+3_11_e_a]","4_14_a@11,8","1_01_b@10,3[1_05_e_b+3_01_e_b]","5_07_a@10,7[3_07_e_a+3_05_e_b]","1_18_b@10,8[4_11_e_a+4_05_e_a]","2_01_b@9,8[3_02_e_a+3_06_e_a]"], - "bonds": ["arcaneShip 1/27","deputShip 0/8","kazimierzShip 0/8","lateranoShip 1/17","preciShip 2/53","raidShip 1/112","sargonShip 0/2","siracusaShip 0/6","steadShip 0/4","suntShip 1/8","swiftShip 1/50"] + "bonds": ["arcaneShip 1/30","deputShip 0/8","kazimierzShip 0/8","lateranoShip 1/23","preciShip 2/59","raidShip 1/112","sargonShip 0/2","siracusaShip 0/6","steadShip 0/4","suntShip 1/8","swiftShip 1/50"] } }, "standIns": {