/** * Your five, always. * * Who is on your team and who is still standing must not depend on whether * you can see them — for most of a round you cannot see anybody. Every team * mate is in every snapshot already (the server shows you your own side), so * this is a read of what is there: a fixed order, health clamped, and the * dead marked. */ /** The player's own team, in a stable order, ready to draw as rows. */ export function roster(snap) { if (!snap || !snap.players) return []; return snap.players .filter((p) => p.mate) .map((p) => ({ id: p.id, name: p.name, agent: p.agent, hp: p.alive ? Math.max(0, Math.min(100, p.hp)) : 0, alive: p.alive === true, spike: p.spike === true, mine: p.id === snap.me.id, })) .sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0)); } /** Enough of the roster to know when the panel has to be rebuilt. */ export const rosterKey = (rows) => rows.map((r) => `${r.id}:${r.agent}:${Math.round(r.hp)}:${r.alive ? 1 : 0}:${r.spike ? 1 : 0}`).join("|");