Merge branch 'main' into own-carrier-egress
This commit is contained in:
commit
b8845413d3
10 changed files with 103 additions and 9 deletions
|
|
@ -6,6 +6,10 @@ All notable changes to this project are documented here. The project follows
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
## [2.3.0] — 2026-10-31
|
||||
|
||||
- Clicking a city without a POP works again while the intern's transit order is set to Already connected (#249). Before, the city panel failed to open and the map stuck to the mouse.
|
||||
- The intern's Accept free caches order, and the Request caches button, now add more cache boxes as demand to a network outgrows the ones you have (#248). Before, they stopped at one box per site.
|
||||
- Manila gets real exchanges: GotchaFIX Manila, the free community Bayanihan-IX and In-Vitro-IX, run by PLDTea Time. Diverge, Smarty Pants, Ditto and RISE & Shine join as Philippine networks, and PLDTea Time and Globe-Trotter Telecom now sell transit.
|
||||
- Cebu joins the map on its own island, with GotchaFIX Cebu and two domestic cables from Manila: the Pan de Sal Cable Network and the Philippines Long Distance Relationship. PLDTea Time, Globe-Trotter Telecom, Diverge and RISE & Shine reach Cebu, and typhoons can hit it too.
|
||||
- Davao joins the map on Mindanao, with GotchaFIX Davao. Bi-Frosted and SEA-US Later now land in Davao, as the real cables do, instead of Manila; a link you already run on their old Manila landings keeps working as a plain subsea link. Three domestic cables reach Davao from Cebu: the Pan de Sal Cable Network, the Philippines Long Distance Relationship and the new Diverge VisMin Express. RISE & Shine peers at GotchaFIX Davao. The Pan de Sal Cable Network also runs straight from Manila to Davao.
|
||||
|
|
@ -14,6 +18,7 @@ All notable changes to this project are documented here. The project follows
|
|||
- Manila, Cebu and Davao have more people online, in line with their real populations.
|
||||
- Cable names on the map no longer pile on top of each other when you zoom in. Where short cables crowd together, a name that would cover another is left out, and selecting a city shows the names of all its cables.
|
||||
- Traffic for a carrier now leaves through that carrier's own transit port at the same POP, instead of being shared with every other transit port there. Networks that buy transit from the carrier get the same treatment, and a new switch on each transit port, Carry here, pulls that traffic across your network from POPs that have no port of that carrier. Prefer, Backup only and RouteScript still win.
|
||||
- Inspecting a congested or busy link now moves the map to it, zoomed so the whole line fits beside the open panel.
|
||||
|
||||
## [2.2.0] — 2026-10-31
|
||||
|
||||
|
|
|
|||
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "seriesoftubes",
|
||||
"version": "2.2.0",
|
||||
"version": "2.3.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "seriesoftubes",
|
||||
"version": "2.2.0",
|
||||
"version": "2.3.0",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"jsdom": "24.1.3",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "seriesoftubes",
|
||||
"version": "2.2.0",
|
||||
"version": "2.3.0",
|
||||
"description": "A cartoon browser game about building the internet.",
|
||||
"private": true,
|
||||
"license": "MIT",
|
||||
|
|
|
|||
|
|
@ -114,7 +114,8 @@ function opsTransitOk(n,c){if(n.id==='cog'&&(scnRule('spat')||S.ev.depeer>S.day)
|
|||
const chk=()=>bz.map(b=>b.reqs.every(k=>!OPS_TREQ.includes(k)||REQS[k].ok(b))).concat(ls.map(l=>COVS.nocog.ok(l)));
|
||||
const was=chk(),all=S.transit;S.transit=all.concat({net:n.id,city:c});try{const now=chk();return was.every((v,i)=>!v||now[i]);}finally{S.transit=all;}}
|
||||
const cheapestTransit=c=>NETS.filter(n=>sellsAt(n,c)&&opsTransitOk(n,c)).sort((a,b)=>transitPerG(a,c,premOnlyAt(a,c))-transitPerG(b,c,premOnlyAt(b,c)))[0];
|
||||
const opsProv=c=>{const pv=opsP('transit','prov');return pv!=='cheap'&&sellsAt(NET[pv],c)&&opsTransitOk(NET[pv],c)?NET[pv]:cheapestTransit(c);};
|
||||
// 'cheap' and 'have' (Already connected) name no network: quote the cheapest seller (#249).
|
||||
const opsProv=c=>{const pv=opsP('transit','prov'),n=isNet(pv)?NET[pv]:null;return n&&sellsAt(n,c)&&opsTransitOk(n,c)?n:cheapestTransit(c);};
|
||||
// The orders. Each takes the shift and does its jobs through the player's own actions.
|
||||
const OPS_RUN={
|
||||
repair(X){purgeInc();for(const i of S.inc.slice())if(i.type!=='ddos'&&i.until>S.day&&i.cost>0&&!(i.slow&&i.rushed)&&X.can('repair',i.cost)&&X.pay('repair',()=>ACT.fixInc({id:i.id})))X.did('repair');},
|
||||
|
|
|
|||
|
|
@ -10,9 +10,13 @@ function utilityCacheMoves(city){if(!S||!S.pops[city])return [];const groups=new
|
|||
const from=diff>0?'a':'b',to=from==='a'?'b':'a';let left=Math.floor(Math.abs(diff)/2);
|
||||
for(const g of groups.values())if(left&&g[from].length>g[to].length){move(g,from,1);left--;}
|
||||
return moves;}
|
||||
function utilityCaches(city){const p=S&&S.pops[city];if(!p)return null;const sites=p.site2?['a','b']:['a'],add=[],have=new Set();
|
||||
for(const c of S.caches)if(c.city===city)have.add(c.net+'@'+(c.site==='b'?'b':'a'));
|
||||
for(const n of NETS)if(n.cache&&(R.demTo[n.id]||0)>=n.cache.min)for(const site of sites)if(!have.has(n.id+'@'+site))add.push({net:n.id,site});
|
||||
// One box per site first; then more boxes while this city's demand to the network outgrows them (100G each, #248).
|
||||
function utilityCaches(city){const p=S&&S.pops[city];if(!p)return null;const sites=p.site2?['a','b']:['a'],add=[],have={};
|
||||
for(const c of S.caches)if(c.city===city){const k=c.net+'@'+(c.site==='b'?'b':'a');have[k]=(have[k]||0)+1;}
|
||||
for(const n of NETS)if(n.cache&&(R.demTo[n.id]||0)>=n.cache.min){const box=sites.map(st=>have[n.id+'@'+st]||0);
|
||||
sites.forEach((site,i)=>{if(!box[i]){add.push({net:n.id,site});box[i]=1;}});
|
||||
const need=Math.ceil(((R.cityDem&&R.cityDem[city])||0)*(NSH[n.id]||0)/CACHE_CAP-1e-9);
|
||||
for(let t=box.reduce((a,b)=>a+b,0);t<need;t++){const i=box.indexOf(Math.min(...box));add.push({net:n.id,site:sites[i]});box[i]++;}}
|
||||
return {add,key:add.map(c=>c.net+'@'+c.site).join(','),mo:add.length*CACHE_MO,free:Math.max(0,portsMax(city)-portsUsed(city))};}
|
||||
function utilityKit(city){const p=S&&S.pops[city];if(!p)return null;
|
||||
const gen=!p.gen,site=!p.site2,router=(p.routers||1)<2,g=p.rgen||0;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ const ACT={
|
|||
if(UI.confirm!==id){UI.confirm=id;renderBank();return;}UI.confirm=null;if(!spend(cost)){renderBank();return;}S.loans=S.loans.filter(x=>x!==l);track('loan_repaid');
|
||||
toast(B.equity?tr('interface.you_bought_out_bank_they_flew',{bank:esc(B.name)}):tr('interface.loan_from_bank_repaid_early',{bank:esc(B.name)}),'good');after();renderBank();},
|
||||
leaseSwap:({a,b,src})=>{if(!S.pops[a]||!S.pops[b]||a===b)return;$('dash').hidden=true;UI.lmode='df';UI.dfSrc=['lease','build','cable'].includes(src)?src:isSub(a,b)?'cable':'build';UI.dfSys=lvl()>=3?'roadm':'lite';openLinkModal(a,b);},
|
||||
dashLink:({id})=>{$('dash').hidden=true;selectLink(id);},
|
||||
dashLink:({id})=>{$('dash').hidden=true;selectLink(id);focusLink(id);},
|
||||
animSet:({v})=>{if(!['auto','on','off'].includes(v))return;UI.anim=v;try{localStorage.setItem('sot-anim',v);}catch(e){}applyAnim();refreshSettings();},
|
||||
soundSet:({v})=>{UI.muted=v==='off';try{localStorage.setItem('sot-mute',UI.muted?'1':'0');}catch(e){}renderHUD();refreshSettings();},
|
||||
langSet:({v})=>{if(!Object.hasOwn(LANGS,v)||v===LANG)return;try{localStorage.setItem('sot-lang',v);}catch(e){}save(true);location.reload();},
|
||||
|
|
@ -48,5 +48,5 @@ const ACT={
|
|||
findOpen:()=>findOpen(),
|
||||
findGo:({city})=>{if(!isCity(city))return;closeModal();$('dash').hidden=true;ACT.focusCity({city});},
|
||||
focusCity:({city})=>{selectCity(city);const C=CITY[city];cam.x=C.x;cam.y=C.y;cam.z=Math.max(cam.z,1.2);if(innerWidth<760)UI.leftOpen=false;renderLeft();},
|
||||
selLink:({id})=>selectLink(id),
|
||||
selLink:({id})=>{selectLink(id);focusLink(id);},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -27,5 +27,15 @@ function bbCost(c){return 15000+CITY[c].P*20;}
|
|||
function after(){if(pzOn()){pzAfter();return;}if(S)purgeInc();compute();checkGoals();renderAll();if(S&&!$('dash').hidden)renderDash();save();}
|
||||
const isTablet=()=>innerWidth>760&&innerWidth<=1200;
|
||||
function selectLink(id){UI.sel={type:'link',id};UI.confirm=null;if(isTablet()||isPhone())UI.leftOpen=false;$('panel').classList.remove('full');renderPanel();renderLeft();}
|
||||
// Frame the whole drawn line (cables bend far from the straight one) in the part of the map the panel leaves free:
|
||||
// above a phone's bottom sheet, left of the side panel. Long links zoom out to fit; short ones zoom in like a city.
|
||||
// A puzzle keeps its own framing beside the puzzle card (pzCam).
|
||||
function focusLink(id){if(pzOn())return;const l=S.links.find(x=>x.id===id);if(!l||!CITY[l.a]||!CITY[l.b])return;const pts=linkGeom(l).pts;
|
||||
let x0=Infinity,x1=-Infinity,y0=Infinity,y1=-Infinity;for(const [x,y] of pts){if(x<x0)x0=x;if(x>x1)x1=x;if(y<y0)y0=y;if(y>y1)y1=y;}
|
||||
const P=$('panel'),r=P&&!P.hidden&&P.getBoundingClientRect();let fl=0,fr=CW,ft=70,fb=CH;
|
||||
if(r&&r.width>0){if(r.width>CW*0.6)fb=Math.min(fb,r.top);else fr=Math.min(fr,r.left);}
|
||||
// Phones leave a thin strip above the sheet: a fixed margin would eat most of it.
|
||||
const m=(a,b)=>Math.max(40,b-a-Math.min(100,(b-a)*0.3)),fw=m(fl,fr),fh=m(ft,fb),z=clamp(Math.min(fw/Math.max(1,x1-x0),fh/Math.max(1,y1-y0),Math.max(cam.z,1.2)),ZMIN,ZMAX);
|
||||
cam.z=z;cam.x=(x0+x1)/2-((fl+fr)/2-CW/2)/z;cam.y=(y0+y1)/2-((ft+fb)/2-CH/2)/z;wrapCam();}
|
||||
function selectCity(c){UI.sel={type:'city',id:c};UI.confirm=null;if(isTablet()||isPhone())UI.leftOpen=false;const P=$('panel');if(P)P.classList.remove('full');if(!S.pops[c])UI.tab='cust';renderPanel();}
|
||||
|
||||
|
|
|
|||
51
tests/focus-link.test.js
Normal file
51
tests/focus-link.test.js
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const { load } = require('./harness');
|
||||
|
||||
const start = "ACT.start({});S.cash=1e8;for(const g of GOALS)S.done[g.id]=0;ACT.launchBB({city:'fra'})";
|
||||
// Where a world point lands on screen, in whichever wrapped copy of the map is nearest the middle.
|
||||
const onScreen = (ev, x, y) => JSON.parse(ev(`JSON.stringify([-1,0,1].map(k=>toS(${x},${y},k)).sort((p,q)=>Math.abs(p[0]-CW/2)-Math.abs(q[0]-CW/2))[0])`));
|
||||
const ends = (ev, id) => JSON.parse(ev(`JSON.stringify((()=>{const l=S.links.find(x=>x.id==='${id}');return [CITY[l.a],CITY[l.b]].map(c=>[c.x,c.y]);})())`));
|
||||
const inBox = (p, b, why) => assert.ok(p[0] >= b[0] && p[0] <= b[2] && p[1] >= b[1] && p[1] <= b[3], `${why}: ${p} not in ${b}`);
|
||||
|
||||
test('Inspect on a congested link moves the map to that link', () => {
|
||||
const { ev, errors, dom } = load();
|
||||
ev(start);
|
||||
ev("S.links.push({id:'hot',a:'fra',b:'ams',kind:'wave',tier:0,km:400,mo:100,cut:0});R.load.hot=capOf(S.links.find(l=>l.id==='hot'))*0.95");
|
||||
ev("const C=CITY.syd;cam.x=C.x;cam.y=C.y;cam.z=0.8;UI.left='noc';UI.leftOpen=true;renderLeft()");
|
||||
ev("document.querySelector('#leftBody [data-act=selLink][data-args*=hot]').click()");
|
||||
assert.equal(ev('UI.sel.id'), 'hot');
|
||||
assert.ok(ev('cam.z') >= 1.2, 'a short link zooms in like a city does');
|
||||
const box = [0, 0, ev('CW'), ev('CH')];
|
||||
for (const [x, y] of ends(ev, 'hot')) inBox(onScreen(ev, x, y), box, 'both cities are on screen');
|
||||
assert.deepEqual(errors, []);
|
||||
dom.window.close();
|
||||
});
|
||||
|
||||
test('a long link zooms out to fit, and stays clear of a bottom sheet', () => {
|
||||
const { ev, errors, dom } = load();
|
||||
ev(start);
|
||||
ev("S.links.push({id:'far',a:'fra',b:'sin',kind:'wave',tier:0,km:10000,mo:100,cut:0})");
|
||||
// jsdom lays nothing out, so stand in for a phone's bottom sheet covering the lower 60% of the map.
|
||||
ev("$('panel').getBoundingClientRect=()=>({left:0,top:CH*0.4,width:CW,height:CH*0.6,right:CW,bottom:CH});cam.z=3");
|
||||
ev("ACT.selLink({id:'far'})");
|
||||
assert.ok(ev('cam.z') < 1.2, 'zoomed out for a long link');
|
||||
const box = [0, 0, ev('CW'), ev('CH*0.4')];
|
||||
for (const [x, y] of ends(ev, 'far')) inBox(onScreen(ev, x, y), box, 'both cities are above the sheet');
|
||||
// The drawn line, not just its ends, fits.
|
||||
for (const [x, y] of JSON.parse(ev("JSON.stringify(linkGeom(S.links.find(l=>l.id==='far')).pts)"))) inBox(onScreen(ev, x, y), box, 'the whole line is above the sheet');
|
||||
assert.deepEqual(errors, []);
|
||||
dom.window.close();
|
||||
});
|
||||
|
||||
test('a puzzle keeps its own framing when a link is opened', () => {
|
||||
const { ev, errors, dom } = load();
|
||||
ev("ACT.pzStart({id:'hello'})");
|
||||
ev("S.links.push({id:'pz',a:'nyc',b:'lon',kind:'wave',tier:0,km:5600,mo:100,cut:0})");
|
||||
const before = ev('JSON.stringify(cam)');
|
||||
ev("ACT.selLink({id:'pz'})");
|
||||
assert.equal(ev('UI.sel.id'), 'pz');
|
||||
assert.equal(ev('JSON.stringify(cam)'), before, 'the camera stays on the whole puzzle');
|
||||
assert.deepEqual(errors, []);
|
||||
dom.window.close();
|
||||
});
|
||||
|
|
@ -635,3 +635,12 @@ test('#244 the PNI order counts the traffic the PNI list shows at that POP, not
|
|||
assert.equal(ev("S.pni.some(p=>p.city==='ham'&&p.net==='nfx')"), true, 'ordered once the traffic is really there');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('#249 a city without a POP opens while the transit order is set to Already connected', t => {
|
||||
const { ev, dom, errors } = game(t, '');
|
||||
hire(ev); on(ev, 'transit', { x: 1.5, prov: 'have' });
|
||||
ev("selectCity('lon')");
|
||||
assert.match(dom.window.document.getElementById('panelBody').textContent, /London/);
|
||||
assert.equal(ev("opsProv('lon')&&opsProv('lon').id"), ev("cheapestTransit('lon')&&cheapestTransit('lon').id"), 'the quote uses the cheapest seller');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -118,3 +118,17 @@ test('balanced caches keep serving when either site fails', t => {
|
|||
}
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('more boxes while demand outgrows them, balanced across sites (#248)', t => {
|
||||
const { ev, errors } = setup(t);
|
||||
ev("Object.assign(S.pops.fra,{site2:true,routers:2});S.caches=[{id:'a1',city:'fra',net:'cfl',site:'a'},{id:'b1',city:'fra',net:'cfl',site:'b'}];compute();R.demTo={cfl:NET.cfl.cache.min};R.cityDem.fra=450/NSH.cfl");
|
||||
const add = JSON.parse(ev("JSON.stringify(utilityCaches('fra').add)"));
|
||||
assert.deepEqual(add.map(x => x.net + '@' + x.site), ['cfl@a', 'cfl@b', 'cfl@a'], '450G needs five 100G boxes: three more, spread over both sites');
|
||||
ev("R.cityDem.fra=150/NSH.cfl");
|
||||
assert.equal(ev("utilityCaches('fra').add.length"), 0, 'two boxes already carry 150G');
|
||||
// Requesting them adds just what is missing.
|
||||
ev("R.cityDem.fra=350/NSH.cfl");
|
||||
ev("ACT.utilityCaches({city:'fra',quote:utilityCaches('fra').key})");
|
||||
assert.equal(ev("S.caches.filter(c=>c.net==='cfl').length"), 4);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue