feedback5: merge feedback4 — PR #129, the lobby ERR import

This commit is contained in:
sganggs committed 2026-10-05 16:48:02 +08:00
commit 8ab6d021da
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();