City panel opens again with the transit order on Already connected (closes #249)

This commit is contained in:
Frederic Jung 2026-10-31 16:31:33 +01:00
parent f0d0675bad
commit c3b253925d
No known key found for this signature in database
3 changed files with 12 additions and 1 deletions

View file

@ -6,6 +6,7 @@ All notable changes to this project are documented here. The project follows
## [Unreleased]
- 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.

View file

@ -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');},

View file

@ -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, []);
});