diff --git a/DESIGN.md b/DESIGN.md index edfe77a9..7b824daa 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -331,7 +331,7 @@ your choice until you hand it back. On the map, a **Plan** chip beside the site' name switches it to the next plan with one click. Pointing at the name says what the site does: how much it **gathers** a second, how full its **store** is, and how much it **trains** a second (idle when no data reaches -its trainers). **Take it all** is a switch with no words, at the top of +its trainers). Double-click or double-tap a machine to **claim** it, as C does; again takes the claim off. **Take it all** is a switch with no words, at the top of a site's card and beside the site's name on the map: hover it to see what it does. While it is on, it claims every machine there, and claims are taken two at a time, cheapest first, never while someone sits at the machine. Claims start only while fewer than two takeovers run, counting ones you started yourself; a diff --git a/index.html b/index.html index 6ca0e155..f9ee6217 100644 --- a/index.html +++ b/index.html @@ -94,7 +94,7 @@

Spread

diff --git a/src/input.ts b/src/input.ts index e52a27e5..58194419 100644 --- a/src/input.ts +++ b/src/input.ts @@ -11,6 +11,7 @@ // the double line chip beside a site's name pay to double its lines out // the plan chip beside a site's name switch to its next plan: none, Gather, Store, Train // a scheme (green diamond) click to see its card; the Claim tool claims it +// double-click or double-tap a machine claim it, as C does (again to take the claim off) import { buildRoomAt, canInstall, cancelJob, claim, installProg, order, roomMachines, unclaim, visible, runRuse, setPlan, setTakeAll, upgradeSiteLine, takeOver, PLAN_LIST, type Plan, type State , say } from './sim'; import { tipAt } from './tip'; import { startLink } from './links'; @@ -30,6 +31,8 @@ export function attachInput(cv: HTMLCanvasElement, getS: () => State, V: View, c const stopHold = () => { clearTimeout(hold); hold = 0; }; const world = (e: PointerEvent) => toWorld(V, e.clientX, e.clientY); + let lastTap: { id: string; t: number } | null = null; // a second click on the same machine soon after is a claim + const DOUBLE_MS = 350; /** Click a machine to pick it. Click a site to see its card; click it again to zoom in. Shift adds sites. * Click a region's name to pick every site you know there. */ @@ -55,7 +58,12 @@ export function attachInput(cv: HTMLCanvasElement, getS: () => State, V: View, c const again = !!site && !add && V.sites.size === 1 && V.sites.has(site); V.selection.clear(); V.front = null; if (!add || !site) V.sites.clear(); - if (m) V.selection.add(m.id); + if (m) { + V.selection.add(m.id); + const now = performance.now(), twice = !add && lastTap?.id === m.id && now - lastTap.t < DOUBLE_MS; + lastTap = twice ? null : { id: m.id, t: now }; + if (twice && !m.owned) { if (m.claimed) unclaim(m); else claim(S, [m.id]); } // the same as C on the selection + } else if (again) zoomToSite(S, V, site!); else if (site) { if (add && V.sites.has(site)) V.sites.delete(site); else V.sites.add(site); } else if (region) V.sites = new Set(regionSites(S, region));