feedback5 WY: 拟态物质 with 2 copies owned and none left in the pool gives nothing instead of a random same-bond operator (GitHub #207)

The item text 「若已拥有至少2名该初始干员,则再获得1名该初始干员;否则随机获得1名同盟约初始干员」: the 否则 is the
case of fewer than 2 owned. builtinMeta's use_equip_reward_char_chess returned only when grantChess(base) gave a piece,
so an elite 溯光星源 plus 2 normal copies (all 5 Ⅵ阶 copies) fell through to the same-bond roll (白面鸮 in the report's
seed). Now with 2 owned it asks for the 3rd and stops; the item is still consumed. The bots' carrier choice
(itemTarget) skips 2 copies whose pool is out.

Tests: test/content/items.test.js (the report with the normal and golden item; 2 copies with the pool drained; 2 copies
with copies left still merge), test/match/bot-smarter.test.js (no carrier on a pair whose pool is out); both fail
without the fix. Docs: META built-ins and bot items, research 04 / 06, DESIGN §25.13.1.
Golden unchanged.
This commit is contained in:
sganggs committed 2026-10-06 20:55:49 +08:00
1 parent e1ffcd1b07
commit 463352d9bc
8 files changed
+92 -11

No files matched your search

+7 -3
View File
@@ -1730,7 +1730,8 @@ function lastPerfect(m, ps) {
* The carrier of an item (null = keep it), by what the item does (itemEffect):
* 信标 (destroys its carrier for a pick of two chess of the same tier): the highest-tier bench single, else the
* weakest normal deployed operator;
* 拟态物质 (a third copy of a pair, else a member of a bond): a pair (highest tier), else a focus member;
* 拟态物质 (a third copy of a pair, else a member of a bond): a pair (highest tier), else a focus member — never one
* of 2 copies whose pool is out (the item gives nothing then);
* 博士投影 (promotes to elite; the normal one at the next round start, the golden one at once): the strongest normal
* deployed operator;
* 突变细胞 (the carrier becomes a random tier + 1 operator after the battle): cellTarget;
@@ -1759,10 +1760,13 @@ export function itemTarget(m, ps, item, ctx = context(m, ps)) {
return bench[0] || byVal(deployed.filter(normal), 1)[0] || null;
}
case 'use_equip_reward_char_chess': {
// with 2 copies owned and none left in the pool the item gives nothing (GitHub #207): such a pair is no carrier
const counts = copyCounts(m, ps);
const pair = owned.filter((p) => normal(p) && (counts.get(gd.baseIdOf(p.id)) || 0) + 1 >= mergeNeed(m, gd.baseIdOf(p.id)))
const live = (base) => { const pool = typeof ps.poolOf === 'function' ? ps.poolOf(base) : m.pool; return pool.left(base) > 0 || !pool.has(base); };
const dead = (p) => (counts.get(gd.baseIdOf(p.id)) || 0) >= 2 && !live(gd.baseIdOf(p.id));
const pair = owned.filter((p) => normal(p) && !dead(p) && (counts.get(gd.baseIdOf(p.id)) || 0) + 1 >= mergeNeed(m, gd.baseIdOf(p.id)))
.sort((a, b) => (chessRec(m, b.id, ps)?.tier || 0) - (chessRec(m, a.id, ps)?.tier || 0) || a.uid - b.uid);
return pair[0] || owned.slice().sort((a, b) => rel(b) - rel(a) || val(b) - val(a) || a.uid - b.uid)[0] || null;
return pair[0] || owned.filter((p) => !dead(p)).sort((a, b) => rel(b) - rel(a) || val(b) - val(a) || a.uid - b.uid)[0] || null;
}
// 博士投影: the normal one promotes at the next round start, the golden one (缪尔赛思's R1 item, item merges) at once;
// both refuse an elite (builtinMeta: BAD_TARGET 'already elite')
+7 -2
View File
@@ -12,7 +12,8 @@
// use_equip_gain_coin_when_next_round_start {count} 见钱眼开玩偶 +count funds next round
// equip_destory_deployment_cnt_change {count} 人事部文档 deploy cap = count
// use_equip_upgrade_char / equip_round_start_upgrade_char 博士投影 promote (golden: now, normal: next round)
// use_equip_reward_char_chess 拟态物质 3rd copy or a same-bond chess
// use_equip_reward_char_chess 拟态物质 3rd copy (none when the pool is
// out), or with < 2 a same-bond chess
// use_equip_reward_special_goods_char_chess {refresh_cnt} 寻呼模块 offer N same-bond chess (≤ shop level)
// use_equip_recruit_new_char_and_give_char_to_player_most_bond {refresh_cnt} 信标 destroy target, offer N same-tier
// chess, gift the original (an elite stays
@@ -130,11 +131,15 @@ const ITEM_HANDLERS = {
ctx.promote(holder.uid);
},
},
// 拟态物质 「若已拥有至少2名该初始干员,则再获得1名该初始干员;否则随机获得1名同盟约初始干员」: the 否则 is the owned < 2
// case only. With 2 copies owned and none left in the pool (an elite holds 3 of a Ⅵ阶's 5) the grant fails and the
// item gives nothing (research 06 §7: some effects fail at the copy cap) — it never falls back to a same-bond operator
// (GitHub #207).
use_equip_reward_char_chess: {
onEquip(ctx, ev) {
const base = ctx.gd.baseIdOf(ev.target.id);
const owned = [...ctx.board(), ...ctx.hand(), ...ctx.temp()].filter((p) => p && p.kind === 'chess' && !p.golden && ctx.gd.baseIdOf(p.id) === base).length;
if (owned >= 2) { if (ctx.grantChess(base)) return; }
if (owned >= 2) { ctx.grantChess(base); return; }
const id = rollSameBond(ctx, ctx.pieceBonds(ev.target.uid), 6);
if (id) ctx.grantChess(id);
},