feedback1 integrate: the prep dispatcher takes every equipped item before the first one runs (follow-up to the PR #2 fix)

Step 5 read each holder's items when the walk reached that holder, so an item equipped meanwhile onto a holder not yet
walked ran in the same dispatch and an item moved to a later holder ran twice (latent: no shipped item does either).
Every [holder, item] pair is now taken before the first item runs, as the header and META already said.
This commit is contained in:
sganggs committed 2026-10-03 17:47:19 +08:00
1 parent d6b1d1bd26
commit f671c15d3f
2 files changed
+72 -12

No files matched your search

+16 -12
View File
@@ -23,10 +23,12 @@
// ctx.triggerGarrisons(uid, eventType) re-runs another piece's garrisons (铃兰, "触发…的获得时效果", 特质相同).
// Items: onEquip / onArt / onDestroy go to the item's own handler only; every other hook runs for items equipped on
// owned chess (ev.source.holder). That step walks a snapshot — the owned chess and each holder's items as they stand
// when it begins — and runs an item only if, when its turn comes, it is still equipped on that holder and the holder
// is still owned: handlers move and destroy pieces mid-walk (突变细胞 transforms its holder and returns the equipment
// to the hand; normal 博士投影 destroys itself, which splices holder.items), and a live walk skipped the next item or
// ran it with a holder that was gone. Pieces gained or equipped during the walk wait for the next dispatch.
// when it begins (every [holder, item] pair, taken before the first item runs) — and runs an item only if, when its
// turn comes, it is still equipped on that holder and the holder is still owned: handlers move and destroy pieces
// mid-walk (突变细胞 transforms its holder and returns the equipment to the hand; normal 博士投影 destroys itself, which
// splices holder.items), and a live walk skipped the next item or ran it with a holder that was gone. Pieces gained or
// equipped during the walk wait for the next dispatch; an item moved during it runs at most once (on the holder it
// stood on, if its turn came before the move).
// Dispatch order per player: global → band → bonds → garrisons (board reading order,
// then hand) → equipped items → effects (insertion order); onPrice runs the priced chess's own 特质 first (购买价格为N
// sets the price the discounts and caps of bonds / strategies then act on — user playtest #5). Every call is
@@ -212,15 +214,17 @@ export class EffectDispatcher {
}
// 4. garrisons (onPrice: already run as step 0)
if (hook !== 'onPrice') this._garrisons(ps, hook, ev);
// 5. equipped items (not for the item-specific hooks): a snapshot of the owned chess and of each holder's items,
// each run only while still equipped on its still-owned holder — handlers move / destroy pieces (header)
// 5. equipped items (not for the item-specific hooks): every [holder, item] pair of the owned chess, taken before
// the first item runs; each runs only while still equipped on its still-owned holder — handlers move / destroy
// pieces (header). Taking the pairs per holder as the walk reached it ran an item equipped meanwhile onto a later
// holder, and twice an item moved from a holder already walked to a later one.
if (hook !== 'onEquip' && hook !== 'onArt' && hook !== 'onDestroy') {
for (const holder of ownedChess(ps)) {
for (const it of (holder.items || []).slice()) {
const key = `item:${itemKey(it.id)}`;
const h = reg.get(key);
if (h && stillEquipped(ps, holder, it)) this._call(ps, key, h, hook, { kind: 'item', key, piece: it, holder, item: this.m.gd.item(it.id) }, ev);
}
const pairs = [];
for (const holder of ownedChess(ps)) for (const it of holder.items || []) pairs.push([holder, it]);
for (const [holder, it] of pairs) {
const key = `item:${itemKey(it.id)}`;
const h = reg.get(key);
if (h && stillEquipped(ps, holder, it)) this._call(ps, key, h, hook, { kind: 'item', key, piece: it, holder, item: this.m.gd.item(it.id) }, ev);
}
}
// 6. persistent effects