Label mixed-size parallel waves per size instead of N × total (#56)

800G + 400G on one route was drawn as "2 × 1.2T", which reads like two
1.2T waves. Mixed groups now list each size, largest first, e.g.
"2×800G + 400G"; equal sizes keep "4×800G".
This commit is contained in:
Frederic Jung 2026-10-26 09:23:57 +01:00
parent 3cd30aa473
commit 92b24fd2ad
No known key found for this signature in database
3 changed files with 21 additions and 1 deletions

View file

@ -10,6 +10,7 @@ All notable changes to this project are documented here. The project follows
- Your own IX can now live in either building of a two-site metro, or in both with a second switch, so a dark building no longer takes your exchange down (#36). The LAG buttons that did nothing on your own IX are gone.
- Upgrading the only router in a POP that has nothing plugged in yet no longer opens a maintenance window or a NOC warning (#105).
- Declining a loan offer clears the bank badge right away, even while the game is paused (#104).
- Parallel waves of different sizes now show each size on the map, like 800G + 400G, instead of a misleading 2 × 1.2T (#56).
- Picking a subsea route from a city without a cable landing, like Oslo, now names the nearest landing station instead of saying its cables reach "nowhere" (#50).
## [1.29.0] — 2026-10-26

View file

@ -4022,7 +4022,8 @@ const lineIdx=(l,pl)=>{const ks=[];for(const x of pl||pairLinks(l.a,l.b)){const
// pairLinks() for every pair at once (same links, same order), for code that asks about all of them.
function pairIdx(){const m=new Map();for(const l of S.links){const k=edgeKey(l),a=m.get(k);if(a)a.push(l);else m.set(k,[l]);}return m;}
function linkGroups(){const m=new Map();for(const l of S.links){const key=gKey(l);const g=m.get(key);if(g)g.push(l);else m.set(key,[l]);}return [...m.values()];}
function groupLabel(grp,up){const t=grp[0].tier,same=grp.every(x=>x.tier===t),tot=grp.reduce((a,x)=>a+LT[x.tier].g,0);return (same?`${grp.length}×${LT[t].n}`:`${grp.length} × ${fmtCap(tot)}`)+(up.length<grp.length?` · ${up.length}/${grp.length} ${tr('up')}`:'');}
// Mixed sizes are spelled out per size ("2×800G + 400G"): "2 × 1.2T" read like two 1.2T waves (#56).
function groupLabel(grp,up){const n=[];for(const x of grp)n[x.tier]=(n[x.tier]||0)+1;let s='';for(let t=n.length-1;t>=0;t--)if(n[t])s+=(s?' + ':'')+(n[t]>1||n[t]===grp.length?n[t]+'×':'')+LT[t].n;return s+(up.length<grp.length?` · ${up.length}/${grp.length} ${tr('up')}`:'');}
function linkGeom(l,pl){const i=lineIdx(l,pl);const key=l.id+'|'+i+'|'+(l.cable||'');const h=GEO.get(key);if(h)return h;
let pts=null;if(l.cable){const cp=cablePair(l.cable,l.a,l.b);if(cp){pts=cp.pts.map(p=>p.slice());const same=pairLinks(l.a,l.b).filter(x=>x.cable===l.cable).indexOf(l);if(same>0)for(let j=1;j<pts.length-1;j++){pts[j][1]+=same*5;}}}
// Your own subsea cable (#64) follows the shortest commercial cable on the same route, drawn alongside it; with

View file

@ -1108,3 +1108,21 @@ test('#36 your own IX moves between buildings, or runs a switch in both', () =>
assert.equal(ev("ixCap('beg')"), 0, 'both dark');
assert.deepEqual(errors, []);
});
test('#56 parallel waves of different sizes are labelled per size, not as N times the total', () => {
const { ev, errors } = load();
ev("ACT.start({});S.cash=1e9;S.lvl=4;for(const g of GOALS)S.done[g.id]=0;ACT.launchBB({city:'fra'});ACT.buildPop({city:'nyc'});ACT.buildPop({city:'lon'})");
ev("for(let i=0;i<3;i++){UI.via='grace';UI.route='same';openLinkModal('nyc','lon');ACT.buildLink({tier:1});closeModal();}compute()");
const lbl = () => ev("(()=>{const g=linkGroups()[0];return groupLabel(g,g)})()");
assert.equal(ev("linkGroups().length"), 1);
assert.equal(lbl(), '3×100G', 'equal sizes keep the short form');
ev("S.links[2].tier=2;S.links[0].tier=3;S.links[1].tier=3");
assert.equal(lbl(), '2×800G + 400G');
ev("S.links[1].tier=2");
assert.equal(lbl(), '800G + 2×400G');
ev("S.links.pop()");
assert.equal(lbl(), '800G + 400G', 'not "2 × 1.2T"');
assert.match(ev("(()=>{const g=linkGroups()[0];return groupLabel(g,[g[0]])})()"), /^800G \+ 400G · 1\/2 /);
ev("cam.z=2;draw(0)");
assert.deepEqual(errors, []);
});