Watching a teammate shows their hand, 临时整备区, equipment, strategy and effects (#129)

The prep scout of another player's board carries their 整备区 hand and 临时整备区 as units on the bench rows (like the own prep bench), the equipped items of their operators, their strategy in the drawer and their effects column (the official mode shows a teammate's hand too). The scout signature includes the hand / temp slots, so a moved card refreshes the watcher. Closes #128. Contributed by @2321Robin.
This commit is contained in:
Luo Xingyu authored and GitHub committed 2026-10-05 16:47:33 +08:00
1 parent bd892a4dd6
commit bce182703b
15 files changed
+521 -20

No files matched your search

+22 -1
View File
@@ -294,6 +294,10 @@ export function renderInfo(u) {
// tap hands them to the detail card (a teammate's unit shows its owner's skill / module)
skillIndex: Number.isInteger(u.skillIndex) ? u.skillIndex : undefined,
moduleId: typeof u.moduleId === 'string' ? u.moduleId : undefined,
// the ally's equipped item ids (UnitInfo.items, DESIGN §16 / §21.11): the detail card needs them for a teammate's
// unit (resolveDetail `unitItems` → the read-only 装备 section and the 变形同构体 pairing chips); the owner's own
// unit takes its items from the piece instead, so only other players' boards ever read this field
items: Array.isArray(u.items) ? u.items.filter((x) => typeof x === 'string') : undefined,
};
}
@@ -1445,12 +1449,29 @@ export async function createFieldView(host, options = {}) {
return info;
}
// a hand item on a scouted prep board (UnitInfo kind 'item'): the plate's icon and colour resolve client-side,
// exactly like the own prep bench (pieceInfo)
function scoutItemInfo(info) {
const rec = data.item(info.defId);
const tier = rec?.tier || info.tier || 1;
return { ...info,
icon: assets.itemIcon ? assets.itemIcon(rec ? { trapId: rec.trapId, iconId: rec.iconId } : info.defId) : null,
color: (info.golden || rec?.isGolden) ? 0xffc600 : TIER_COLORS[tier] || TIER_COLORS[1] };
}
function battleView(id) {
let v = views.get(id);
if (v) return v;
const info = infos.get(id);
if (!info || gone.has(id)) return null;
v = info.kind === 'device' ? new DeviceView(ctx, info) : new UnitView(ctx, info, { prep: !!battleMeta?.prep && info.side === 'ally' });
v = info.kind === 'device' ? new DeviceView(ctx, info)
: info.kind === 'item' ? new ItemView(ctx, scoutItemInfo(info))
: new UnitView(ctx, info, { prep: !!battleMeta?.prep && info.side === 'ally' });
// a teammate's operator shows its equipped items like the own prep bench does (item pips; user playtest #2:
// at the unit, not only in the detail card) — prep surfaces only, the battle HUD stays as it is
if (v.setItems && battleMeta?.prep && Array.isArray(info.items) && info.items.length) {
v.setItems(info.items.map((it) => { const r = data.item(it); return assets.itemIcon ? assets.itemIcon(r ? { trapId: r.trapId, iconId: r.iconId } : it) : null; }));
}
v.setWorld(info.x, info.y, 0);
v._seen = false;
v._born = performance.now();