Back to The Bathyal Post
SOURCE / PINNED RELEASE

Made of little things.

The Bathyal Post

Release
fa6ce530b9f3…
Author-recorded commit
b255b3c9fd49…
License
LICENSE
Author’s source reference
nostr://npub182jczunncwe0jn6frpqwq3e0qjws7yqqnc3auccqv9nte2dnd63scjm4rf/wss%3A%2F%2Fgit.napplet.soy%2F/n-55c50b9a042

Archive hash verified: 03cf62191e7476c5…. The source-to-build association is the author’s claim; it has not been independently rebuilt.

src/folio.ts
import { icon } from './icons.js';
import { STOPS, RIGS, archivedLetters, neighbours, type StopId, type Voyage } from './voyage.js';
import type { Ledger, PostOffice } from './post-office.js';

export function escapeText(text: string) {
  return text.replace(/[&<>"']/g, char => ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'})[char]!);
}
export const pad = (n: number) => String(n).padStart(2, '0');

export function stamp(id: StopId) {
  const artwork = STOPS[id].kind === 'recipient'
    ? `<span class="stamp-art ${id}"></span>`
    : `<span class="stamp-symbol">${icon(id === 'buoy' ? 'anchor' : id === 'wreck' ? 'wrench' : 'air')}</span>`;
  return `<span class="stamp" aria-hidden="true">${artwork}<span class="seal-label">Bathyal post</span></span>`;
}

export function mailPage(ledger: Ledger) {
  const { voyage, postmarks } = ledger;
  const letters = voyage.letters.map(letter => `
    <article class="letter-item">${stamp(letter.to)}<div>
      <div class="tag-line"><span>${STOPS[letter.to].name}</span><span>${letter.delivered ? '✓ Posted' : '+' + letter.reward + ' postage'}</span></div>
      <h3>${escapeText(letter.title)}</h3><p>“${escapeText(letter.body)}”</p>
      <div class="plate-condition">${escapeText(letter.condition)} · +6 premium</div>
      ${!letter.delivered && voyage.phase === 'sailing' ? `<button class="text-link" data-plot="${letter.to}">Plot a course →</button>` : ''}
    </div></article>`).join('');
  const marks = (['medusa','whale','garden','trench'] as const).map(id => {
    const count = postmarks.filter(mark => mark.startsWith(id + '-')).length;
    return `<span class="${count ? 'inked' : ''}">${STOPS[id].name} · ${count}/5</span>`;
  }).join('');
  return `<p>Carry ${voyage.quota} signed ${voyage.quota === 1 ? 'letter' : 'letters'} back to the buoy to clear this dispatch.</p>${letters}
    ${voyage.deadLetter === 'carried' ? '<div class="guide-row"><h3>An unaddressed envelope</h3><p>“Where the sea opens its mouth.”</p></div>' : ''}
    <div class="guide-row"><h3>Postmark album</h3><p>Each different letter leaves its own mark.</p>
    <div class="postmarks">${marks}${postmarks.includes('black') ? '<span class="inked">The black postmark</span>' : ''}</div>
    ${archivedLetters(postmarks).map(l=>`<details class="archived-letter"><summary>${escapeText(l.title)} · ${STOPS[l.to].name}</summary><p>“${escapeText(l.body)}”</p></details>`).join('')}</div>`;
}

export function logPage(ledger: Ledger, office: PostOffice) {
  const { voyage, record } = ledger;
  const stats = [[voyage.score,'Postage'],[voyage.totalDelivered,'Delivered'],[record,'Best return']];
  return `<div class="log-stats">${stats.map(([n,label]) => `<div><b>${n}</b><span class="micro">${label}</span></div>`).join('')}</div>
    <div class="tag-line"><span>Dispatch ${pad(voyage.bag)} · watch ${pad(voyage.turn)}</span><span>Tide № ${voyage.seed.toString(16).toUpperCase()}</span></div>
    <p class="guide-note">${RIGS[voyage.rig].name} · ${voyage.lace} muffled drives left · Vent ${voyage.ventUsed ? 'spent' : 'ready'} · Wreck ${voyage.wreckUsed ? 'salvaged' : 'unopened'}</p>
    <div class="tool-actions">${office.available ? '<button class="tool-action" data-save>Save voyage</button>' : ''}
    <button class="tool-action" data-new-confirm>New tide</button></div>
    <p class="storage" data-storage>${escapeText(office.status)}</p>
    ${[...voyage.log].reverse().map(line=>`<div class="logentry">${escapeText(line)}</div>`).join('')}`;
}

export function guidePage() {
  const topics = [
    ['Your first round', 'Choose the Bell Medusa, then Take passage. The held letter is delivered on arrival. Bring one postmark home to the Post Buoy to qualify for the second dispatch, or keep going for the rest of the bag.'],
    ['Read the water', 'One crossing advances one watch. Flood favors descent, ebb favors ascent. High and low water are slack. Drifting sheds two wake. It costs one air with the current and up to five against it in later dispatches. The passage forecast shows the cost before you sail.'],
    ['Use the screw', 'Drive can save air against the current, at the cost of wake. Spin-up and deep strain appear in the forecast. At six wake, the Listener strikes the hull. In later dispatches its hunting ground moves each watch. Medusa lace silences two drives.'],
    ['Keep a way home', 'The vent gives up to six air and the wreck repairs up to two hull once per dispatch. A delivery to the Choir Whale restores air. The garden grows hull plates. The Trench Mouth clears your wake. Check the cost of the return leg.'],
    ['Earn your postmarks', 'Each letter carries a postage premium for a special condition. You need one signed letter in the first dispatch, two in the second, and three in the third. A full bag adds air capacity to later dispatches. Refits change how you handle the deeper water.'],
    ['At the pilot’s desk', 'Tap a charted stop or the name on the passage slip to select a destination. Follow a plotted course one leg at a time. Open Mailbag to read letters and Logbook for receipts and saved progress. The sea waits for your next move.'],
  ];
  return topics.map(([title,body])=>`<section class="guide-row"><h3>${title}</h3><p>${body}</p></section>`).join('');
}

export function routesPage(voyage: Voyage, selected: StopId) {
  const adjacent = neighbours(voyage.at);
  return `<p>Moored at ${STOPS[voyage.at].name}. Choose a destination to inspect its passage.</p>${Object.values(STOPS)
    .filter(stop => stop.id !== voyage.at).sort((a,b)=>Number(adjacent.includes(b.id))-Number(adjacent.includes(a.id)))
    .map(stop=>`<button class="route-row ${stop.id === selected ? 'current' : ''}" data-plot="${stop.id}"><span>${stop.name}</span><small>${adjacent.includes(stop.id) ? 'Direct' : 'Via chart'} · ${stop.depth} m</small></button>`).join('')}`;
}