From 0ad36c217888888f6b5bf2671796c00a6fe72e82 Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Wed, 4 Nov 2026 09:31:25 +0000 Subject: [PATCH 1/2] Release skill: CI tests and benchmarks a release, so don't run them locally --- .claude/skills/release/SKILL.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.claude/skills/release/SKILL.md b/.claude/skills/release/SKILL.md index 509d3fb..cc27bb7 100644 --- a/.claude/skills/release/SKILL.md +++ b/.claude/skills/release/SKILL.md @@ -65,17 +65,16 @@ gh api repos/fjaeckel/seriesoftubes/releases/latest --jq '.tag_name+" "+.publish ## Steps -1. Make sure `main` is green: `npm test` and `node scripts/i18n-check.js` - ("0 missing, 0 unused, 0 broken"). +1. Don't run the test suite, the game or benchmarks before a release: CI and the + auto-release workflow test it, and the Performance workflow benchmarks it. Just + check that the latest CI run on `main` is green (`gh run list --repo fjaeckel/seriesoftubes --limit 4`). 2. In `CHANGELOG.md`, move the bullets from `## [Unreleased]` into a new section right below it: `## [x.y.z] — YYYY-MM-DD` (em dash, today's date). Keep an empty `## [Unreleased]` heading above it. The build fails if the section has no bullets. 3. Bump the version in **both** files: - `package.json` → `"version"` - `package-lock.json` → top-level `"version"` and `packages[""].version` -4. `npm test` once more. - Then compare performance with the previous release and mention anything notable to Frederic: - `npm run perf -- --base-ref v`. +4. (Nothing to run here: the workflow tests the release before it tags it.) 5. Commit on `main` as Frederic, with no attribution trailers: ```bash git -c user.name="Frederic Jung" -c user.email="frederic@jc-ix.net" commit \ From ac5ce7fa057be998cd44ee7c8fd4a53ab957a1af Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Wed, 4 Nov 2026 11:54:31 +0000 Subject: [PATCH 2/2] Zoom in twice as far; ships at anchor keep clear of their port ZMAX goes from 16 to 32. A club ship near its home city is drawn at least 46 px (times the icon scale) out from the city's marker, along the line from the city, and a tap on a city's own marker picks the city before any ship. --- CHANGELOG.md | 3 +++ src/game/96-map/88-cable-ships.js | 9 +++++-- src/game/96-map/90-input.js | 6 +++-- tests/ship-clearance.test.js | 42 +++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 tests/ship-clearance.test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bf3623..a534b24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ All notable changes to this project are documented here. The project follows ## [Unreleased] +- The map zooms in twice as far, for crowded regions like New England or around Washington. +- Cable ships at anchor sit a little further out from their port, and a tap on a city picks the city even with a ship close by. + ## [2.8.0] — 2026-11-04 - Every capital of the world is now on the map, with Africa's 33 capitals completing the set. They run from Porto-Novo, Bamako and Niamey to Khartoum, Juba, Mogadishu, Brazzaville, Tripoli, Rabat and Pretoria. Each country brings its real telcos, Nigeria gets its wholesale backbone up to Abuja, and the island capitals of the Comoros, São Tomé and Equatorial Guinea sit on their real cables. diff --git a/src/game/96-map/88-cable-ships.js b/src/game/96-map/88-cable-ships.js index f5a81dc..e9af80b 100644 --- a/src/game/96-map/88-cable-ships.js +++ b/src/game/96-map/88-cable-ships.js @@ -1,7 +1,7 @@ /* Cable ships on the map (85-incidents/50-cable-ships.js): club ships at anchor off their ports, sailing out to a cut, splicing on site and sailing home; lay ships along a cable you are building. Where they are comes from S.fleet and the clock, so nothing here is saved; their routes are worked out once per voyage and kept in SHIP_PATH. */ -const SHIP_PATH=new Map(),SHIP_HITS=[]; +const SHIP_PATH=new Map(),SHIP_HITS=[],SHIP_CLEAR=46; // Off the port: the first point of a cable leaving it, so a ship rides at anchor at sea and not in town. function shipHomePt(s){const k='h:'+s.id;let p=SHIP_PATH.get(k);if(p)return p;const C=CITY[s.home];p=[C.x,C.y]; for(const cp of CABLE_PAIRS){if(cp.a===s.home){p=cp.pts[1].slice();break;}if(cp.b===s.home){p=cp.pts[cp.pts.length-2].slice();break;}} @@ -37,7 +37,12 @@ function drawShips(ks,now){SHIP_HITS.length=0;if(!S||pzOn()||!S.fleet)return; for(const l of S.links)if(layOwn(l)&&l.ready>S.day&&T>=layStart(l)){const g=linkGeom(l),q=layDone(l,T),two=!!l.ship2; const put=(t,k,dir)=>{const [x,y]=polyAt(g.pts,g.cum,clamp(t,0,1)),[x2]=polyAt(g.pts,g.cum,clamp(t+dir*0.01,0,1));list.push({p:{x,y,m:'lay',dx:x2-x||dir},lay:l,k,col:'#16A866'});}; if(two){put(q/2,0,1);put(1-q/2,1,-1);}else put(q,0,1);} - for(const it of list)for(const k of ks){const [sx,sy]=toS(it.p.x,it.p.y,k);if(sx<-30||sx>CW+30||sy<-30||sy>CH+30)continue; + // A ship near its port keeps SHIP_CLEAR px from the city's marker on screen (out along the line from the city), so a tap + // on the city does not land on the ship: at anchor the ship rides only a few km out, which is no distance zoomed out. + const clr=SHIP_CLEAR*iconScale(); + for(const it of list)for(const k of ks){let [sx,sy]=toS(it.p.x,it.p.y,k); + if(it.s){const C=CITY[it.s.home],[cx,cy]=toS(C.x,C.y,k),dx=sx-cx,dy=sy-cy,d=Math.hypot(dx,dy);if(d0.5?dx/d:0.8,uy=d>0.5?dy/d:0.6;sx=cx+ux*clr;sy=cy+uy*clr;}} + if(sx<-30||sx>CW+30||sy<-30||sy>CH+30)continue; const oy=it.p.m==='work'?-18*sc:0;shipSprite(sx,sy+oy,it.p.dx<0?-1:1,sc,it.col,now,it.p.m);SHIP_HITS.push({x:sx,y:sy+oy,r:14*sc,it});}} function shipHit(cx,cy){const r=cv.getBoundingClientRect(),x=cx-r.left,y=cy-r.top;let best=null,bd=Infinity; for(const h of SHIP_HITS){const d=Math.hypot(h.x-x,h.y-y);if(d<=h.r+6&&d{const h=hitCity(x,y);return !!h&&Math.hypot(h.sx-x,h.sy+4-y)<=16*iconScale();}; function pickCity(x,y){const h=hitCity(x,y);if(!h)return null;if(Math.hypot(h.sx-x,h.sy+4-y)<=16*iconScale())return h;return hitLink(x,y)?null:h;} function hitLink(x,y){if(!S)return null;let best=null,bd=12;const KS=visibleKs(),PI=pairIdx();for(const grp of linkGroups()){const l=grp[0];const g=linkGeom(l,PI.get(edgeKey(l)));for(const k of KS){let prev=null;for(const p of g.pts){const q=toS(p[0],p[1],k);if(prev){const d=segDist(x,y,prev,q);if(d{e.preventDefault();zoomAt(e.clientX,e.clientY,Math.exp(-e.deltaY*0.0015));},{passive:false}); addEventListener('keydown',e=>{if(e.key==='Enter'&&e.target.id==='metIn'){ACT.metricSet({id:e.target.dataset.id});return;}if(e.target.closest&&e.target.closest('input,textarea,select,[contenteditable]'))return;if(e.ctrlKey||e.metaKey||e.altKey)return;if(e.code==='Space'&&e.target.closest&&e.target.closest('button,a'))return;if(e.code==='Space'&&(!S||rule('clock'))&&!pzOn()&&!UI.clockLocked){e.preventDefault();UI.speed=UI.speed?0:1;renderHUD();}if(e.key==='0')ACT.speed({v:0.5});if(e.key==='1')ACT.speed({v:1});if(e.key==='2')ACT.speed({v:2});if(e.key==='3')ACT.speed({v:4});if(e.key==='4')ACT.speed({v:8});if(e.key==='Escape'&&!$('bankBox').hidden){$('bankBox').hidden=true;return;}if(e.key==='Escape'&&!$('dash').hidden){$('dash').hidden=true;return;}if(e.key==='Escape'){if(!$('modal').hidden){if(S&&UI.started&&!S.lost)closeModal();}else{UI.sel=null;renderPanel();}}}); diff --git a/tests/ship-clearance.test.js b/tests/ship-clearance.test.js new file mode 100644 index 0000000..b2565b0 --- /dev/null +++ b/tests/ship-clearance.test.js @@ -0,0 +1,42 @@ +// Cable ships at anchor keep clear of their port's marker, so a tap on the city picks the city; and the map zooms in +// further than before, for dense regions like Boston or Washington. +const test = require('node:test'); +const assert = require('node:assert/strict'); +const { load } = require('./harness'); + +const J = (ev, code) => JSON.parse(ev(`JSON.stringify(${code})`)); +// Marseille has two club ships in port. Zoomed out, a few km of sea is no distance on screen. +const view = (ev, z) => ev(`ACT.start({});S.fleet=S.fleet||{};UI.sel=null;const C=CITY.mrs;cam.x=C.x;cam.y=C.y;cam.z=${z};draw(0)`); +const city = ev => J(ev, "(()=>{const C=CITY.mrs,[x,y]=toS(C.x,C.y,0);return {x,y}})()"); +const ships = ev => J(ev, "SHIP_HITS.filter(h=>h.it.s&&h.it.s.home==='mrs').map(h=>({x:h.x,y:h.y,r:h.r}))"); + +test('ships at anchor keep clear of their port on screen, at any zoom', () => { + for (const z of [1.2, 3, 8]) { + const { ev, errors } = load(); + view(ev, z); + const c = city(ev), s = ships(ev); + assert.ok(s.length >= 1, `a Marseille ship is drawn at zoom ${z}`); + const min = ev('SHIP_CLEAR*iconScale()'); + for (const h of s) assert.ok(Math.hypot(h.x - c.x, h.y - c.y) >= min - 0.01, `at zoom ${z} the ship is ${min} px or more from the city`); + assert.deepEqual(errors, []); + } +}); + +test("a tap on the city's marker picks the city, even with a ship close by", () => { + const { ev, errors } = load(); + view(ev, 1.2); + const c = city(ev); + // Put a ship's hit circle right over the city, as the old anchorage could. + ev(`SHIP_HITS.unshift({x:${c.x},y:${c.y + 6},r:20,it:SHIP_HITS.find(h=>h.it.s).it})`); + ev(`(()=>{const r=cv.getBoundingClientRect();UI.drag={mode:'pan',moved:false,sx:${c.x}+r.left,sy:${c.y}+r.top};endPtr({pointerId:1,clientX:${c.x}+r.left,clientY:${c.y}+r.top})})()`); + assert.deepEqual(J(ev, 'UI.sel'), { type: 'city', id: 'mrs' }); + assert.deepEqual(errors, []); +}); + +test('the map zooms in twice as far as before', () => { + const { ev, errors } = load(); + ev("ACT.start({});cam.z=1;for(let i=0;i<60;i++)zoomAt(100,100,1.2)"); + assert.equal(ev('cam.z'), 32); + ev('draw(0)'); + assert.deepEqual(errors, []); +});