feat(admin): take reserve, cull wildlife, wildlife cap, fresh bud costs (schema 67)
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m34s
Foundation / postgres-tools (push) Successful in 26s
Foundation / server-image (push) Successful in 4m30s
Foundation / image (push) Successful in 5m46s
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m34s
Foundation / postgres-tools (push) Successful in 26s
Foundation / server-image (push) Successful in 4m30s
Foundation / image (push) Successful in 5m46s
ADR-0182 section 16, from playtesting region 16 at its 256-life cap. - Bud costs: the region host's cache of each genome's bud cost was keyed by genome only, so after a tuning adoption the client kept the old cost (or "cannot bud"). It now clears when the rules' encoding changes. - Wildlife cap: reproduction.wildlife_cap (optional, 0..organism cap, 0 = the organism cap) refuses buds of parents without an account at that many lives, keeping the slots above it for players. Bits 17-31 of the energy-cycle word, so older rules keep their bytes. DEV file: 200. - Schema 67: admin command kinds take_reserve (8: up to the amounts from a life's reserve to the spent pool) and remove_wildlife (9: every life without an account, as remove_cell). - Region view: caps; the portal shows lives against the cap. - Portal: Take reserve in the inspector, Remove all wildlife, and marking cells on the map (shift+click, shift+drag) for bulk removal; the guided editor lists optional keys the base revision lacks. - Client: a refused bud says the region may be full. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -406,7 +406,7 @@ function channelTiles(values, subs = []) {
|
||||
const kindLabels = {
|
||||
remove_cell: 'remove cell', grant_reserve: 'grant reserve', add_bubbles: 'add bubbles',
|
||||
add_pool: 'add to spent pool', release_pool: 'release spent pool', spawn_wildlife: 'spawn wildlife',
|
||||
adopt_tuning: 'adopt tuning',
|
||||
adopt_tuning: 'adopt tuning', take_reserve: 'take reserve', remove_wildlife: 'remove all wildlife',
|
||||
};
|
||||
|
||||
// Admin commands (ADR-0182): queued now, applied by the region at its next ticks.
|
||||
@@ -781,6 +781,9 @@ async function regionPage(region, params) {
|
||||
const send = commandSender(region, () => commands.load());
|
||||
let view = null, selected = null, timer = null, frame = 0, beats = 0;
|
||||
let zoom = 1, panX = 0, panY = 0, drag = null;
|
||||
// Cells marked for a bulk removal (shift+click toggles, shift+drag adds a box of them).
|
||||
const marked = new Set();
|
||||
let box = null;
|
||||
// Tick pace: the last ticks seen and when the tick last moved.
|
||||
const pace = { samples: [], movedAt: performance.now(), lastTick: null, fetchedAt: 0 };
|
||||
const layers = { players: true, online: true, wildlife: true, pools: true, patches: true, energy: true, carbon: true, nitrogen: true, phosphorus: true, other: true };
|
||||
@@ -825,15 +828,20 @@ async function regionPage(region, params) {
|
||||
chip('pools', 'pool', 'Pools'), chip('patches', 'patch', 'Patches'),
|
||||
...channels.map((c) => chip(c.key, c.key, `${c.label} bubbles`)));
|
||||
const zoomBy = (factor) => { setZoom(zoom * factor, 0, 0); };
|
||||
const markCount = h('span');
|
||||
const markNote = h('span', { class: 'muted small' });
|
||||
const markBar = h('div', { class: 'mark-bar glass', hidden: true }, markCount,
|
||||
h('button', { class: 'danger', onclick: () => removeMarked() }, 'Remove'),
|
||||
h('button', { class: 'ghost', onclick: () => { marked.clear(); drawMarks(); paint(); } }, 'Clear'), markNote);
|
||||
const mapCard = h('div', { class: 'map-card' },
|
||||
h('div', { class: 'map-toolbar' }, chipRow,
|
||||
h('div', { class: 'map-zoom' },
|
||||
h('button', { title: 'Zoom in', onclick: () => zoomBy(1.6) }, '+'),
|
||||
h('button', { title: 'Zoom out', onclick: () => zoomBy(1 / 1.6) }, '−'),
|
||||
h('button', { title: 'Fit the region', onclick: () => { zoom = 1; panX = 0; panY = 0; paint(); } }, '⤢'))),
|
||||
h('div', { class: 'map-stage' }, canvas, banner,
|
||||
h('div', { class: 'map-stage' }, canvas, banner, markBar,
|
||||
h('div', { class: 'map-foot' },
|
||||
h('div', { class: 'map-hint glass' }, 'Click to inspect · scroll to zoom · drag to pan'),
|
||||
h('div', { class: 'map-hint glass' }, 'Click to inspect · shift+click or shift+drag to mark cells · scroll to zoom · drag to pan'),
|
||||
h('div', { class: 'scale glass' }, scaleLabel, scaleRule)),
|
||||
tip));
|
||||
|
||||
@@ -908,7 +916,7 @@ async function regionPage(region, params) {
|
||||
h('div', { class: 'list-item' },
|
||||
h('span', { class: 'mono faint' }, `#${c.id}`),
|
||||
h('div', { class: 'grow' }, kindLabels[c.kind] || c.kind, c.count ? ` ×${c.count}` : '',
|
||||
c.kind === 'remove_cell' || c.kind === 'grant_reserve' ? h('span', { class: 'mono muted' }, ` ${c.target}`) : '',
|
||||
['remove_cell', 'grant_reserve', 'take_reserve'].includes(c.kind) ? h('span', { class: 'mono muted' }, ` ${c.target}`) : '',
|
||||
c.kind === 'adopt_tuning' ? ` revision ${c.target}` : '',
|
||||
h('div', { class: 'sub', title: c.author || '' }, (c.author || '').split(' (')[0])),
|
||||
c.applied_tick ? h('span', { class: 'badge alive' }, `tick ${fmtInt(c.applied_tick)}`) : h('span', { class: 'badge warn' }, 'pending'))))
|
||||
@@ -917,7 +925,17 @@ async function regionPage(region, params) {
|
||||
},
|
||||
};
|
||||
const schedules = schedulesBlock(region);
|
||||
const cullReason = reasonInput(), cullNote = h('div', { class: 'note' });
|
||||
const cull = () => {
|
||||
const wild = view ? view.cells.filter((c) => c.flags & 1).length : 0;
|
||||
if (!confirm(`Remove all ${fmtInt(wild)} wildlife cells? Their bodies and reserves go to the spent pool.`)) return;
|
||||
send({ kind: 'remove_wildlife' }, 'remove all wildlife', cullNote, cullReason);
|
||||
};
|
||||
tabBodies.actions.append(
|
||||
block('Remove wildlife', null,
|
||||
h('p', { class: 'hint' }, 'Every wildlife cell at once, in one command; bodies and reserves go to the spent pool. To remove some, shift+click or shift+drag them on the map.'),
|
||||
h('div', { class: 'form-row' }, cullReason, h('button', { class: 'danger', onclick: cull }, 'Remove all wildlife')),
|
||||
cullNote),
|
||||
block('Spawn wildlife', null,
|
||||
h('p', { class: 'hint' }, 'Founder wildlife at random spots, funded like any birth.'),
|
||||
h('div', { class: 'form-row' }, h('div', { class: 'field' }, h('label', {}, 'Cells'), spawnCount), spawnReason,
|
||||
@@ -1097,6 +1115,15 @@ async function regionPage(region, params) {
|
||||
ctx.beginPath(); ctx.arc(x, y, size / 2, 0, Math.PI * 2); ctx.fill();
|
||||
ctx.globalAlpha = 1;
|
||||
if ((highlight && c.account === highlight) || (selected && selected.cell && selected.cell.life === c.life)) ring(x, y, size / 2);
|
||||
if (marked.has(c.life)) {
|
||||
ctx.strokeStyle = css('bad'); ctx.lineWidth = 2 * g.dpr;
|
||||
ctx.beginPath(); ctx.arc(x, y, size / 2 + 2 * g.dpr, 0, Math.PI * 2); ctx.stroke();
|
||||
}
|
||||
}
|
||||
if (box) {
|
||||
ctx.strokeStyle = css('bad'); ctx.lineWidth = g.dpr; ctx.setLineDash([5 * g.dpr, 4 * g.dpr]);
|
||||
ctx.strokeRect(box.x0 * g.dpr, box.y0 * g.dpr, (box.x1 - box.x0) * g.dpr, (box.y1 - box.y0) * g.dpr);
|
||||
ctx.setLineDash([]);
|
||||
}
|
||||
// Scale bar: a round length about 90 px long.
|
||||
const len = niceLength((90 * g.dpr) / g.s);
|
||||
@@ -1146,6 +1173,34 @@ async function regionPage(region, params) {
|
||||
h('div', { class: 'tip-row' }, h('span', {}, 'Radius'), h('span', {}, fmtLength(d.r)))];
|
||||
}
|
||||
|
||||
// ----- Marked cells -----
|
||||
function drawMarks() {
|
||||
markBar.hidden = marked.size === 0;
|
||||
if (!view) return;
|
||||
const wild = view.cells.filter((c) => marked.has(c.life) && c.flags & 1).length;
|
||||
markCount.textContent = `${fmtInt(marked.size)} marked`;
|
||||
markNote.textContent = wild === marked.size ? 'wildlife' : `${fmtInt(marked.size - wild)} player${marked.size - wild === 1 ? '' : 's'}`;
|
||||
}
|
||||
// One remove_cell command each, queued in turn; the region applies them over its next ticks.
|
||||
async function removeMarked() {
|
||||
const lives = [...marked];
|
||||
if (!lives.length || !confirm(`Remove ${fmtInt(lives.length)} marked cells? Their bodies and reserves go to the spent pool.`)) return;
|
||||
let queued = 0, failed = '';
|
||||
for (const life of lives) {
|
||||
markNote.textContent = `queuing ${queued + 1} of ${lives.length}…`;
|
||||
try {
|
||||
await api(`/api/regions/${region}/commands?${new URLSearchParams({ kind: 'remove_cell', target: life, reason: 'bulk removal from the map' })}`, true, 'POST');
|
||||
marked.delete(life);
|
||||
++queued;
|
||||
} catch (e) { failed = e.code || e.message; break; }
|
||||
}
|
||||
commands.load();
|
||||
drawMarks();
|
||||
paint();
|
||||
markNote.textContent = failed ? `queued ${queued}; stopped: ${failed}` : `queued ${queued}`;
|
||||
markBar.hidden = false;
|
||||
}
|
||||
|
||||
// ----- Inspector -----
|
||||
function select(found) {
|
||||
selected = found;
|
||||
@@ -1190,6 +1245,12 @@ async function regionPage(region, params) {
|
||||
try { values = grant.read(); } catch (e) { note.className = 'note error'; note.textContent = e.message; return; }
|
||||
send({ kind: 'grant_reserve', target: c.life, ...values }, `grant reserve to ${c.life}`, note, reason).then((ok) => { if (ok) grant.clear(); });
|
||||
};
|
||||
const takeAmount = amountInputs(), takeReason = reasonInput(), takeNote = h('div', { class: 'note' });
|
||||
const take = () => {
|
||||
let values;
|
||||
try { values = takeAmount.read(); } catch (e) { takeNote.className = 'note error'; takeNote.textContent = e.message; return; }
|
||||
send({ kind: 'take_reserve', target: c.life, ...values }, `take reserve from ${c.life}`, takeNote, takeReason).then((ok) => { if (ok) takeAmount.clear(); });
|
||||
};
|
||||
const remove = () => {
|
||||
if (!confirm(`Remove ${c.flags & 1 ? 'wildlife' : 'player'} cell ${c.life}? Its body and reserve go to the spent pool.`)) return;
|
||||
send({ kind: 'remove_cell', target: c.life }, `remove cell ${c.life}`, note, reason);
|
||||
@@ -1198,6 +1259,8 @@ async function regionPage(region, params) {
|
||||
h('div', { class: 'inspect-head' }, swatch(cellLayer(c) === 'players' ? 'player' : cellLayer(c)), h('h2', { class: 'grow' }, cellName(c)), locate, close),
|
||||
inspectFacts,
|
||||
block('Grant reserve', null, grant.node, h('div', { class: 'form-row' }, reason, h('button', { onclick: give }, 'Grant')), note),
|
||||
block('Take reserve', null, h('p', { class: 'hint' }, 'Moves up to these amounts from the cell\'s reserve to the spent pool (never more than it holds).'),
|
||||
takeAmount.node, h('div', { class: 'form-row' }, takeReason, h('button', { onclick: take }, 'Take')), takeNote),
|
||||
block('Remove', null, h('p', { class: 'hint' }, 'Kills the cell now; its body and reserve go to the spent pool.'),
|
||||
h('button', { class: 'danger', onclick: remove }, 'Remove cell')));
|
||||
} else {
|
||||
@@ -1324,6 +1387,11 @@ async function regionPage(region, params) {
|
||||
// ----- Pointer -----
|
||||
canvas.addEventListener('mousemove', (e) => {
|
||||
const rect = canvas.getBoundingClientRect();
|
||||
if (box) {
|
||||
box.x1 = e.clientX - rect.left; box.y1 = e.clientY - rect.top;
|
||||
tip.hidden = true;
|
||||
paint(); return;
|
||||
}
|
||||
if (drag) {
|
||||
if (Math.abs(e.clientX - drag.x) > 3 || Math.abs(e.clientY - drag.y) > 3) { drag.moved = true; canvas.classList.add('dragging'); }
|
||||
panX = drag.panX + (e.clientX - drag.x); panY = drag.panY + (e.clientY - drag.y);
|
||||
@@ -1338,9 +1406,39 @@ async function regionPage(region, params) {
|
||||
tip.style.left = `${Math.min(x, rect.width - tip.offsetWidth - 8)}px`;
|
||||
tip.style.top = `${Math.min(y, rect.height - tip.offsetHeight - 8)}px`;
|
||||
});
|
||||
canvas.addEventListener('mouseleave', () => { tip.hidden = true; drag = null; canvas.classList.remove('dragging'); });
|
||||
canvas.addEventListener('mousedown', (e) => { drag = { x: e.clientX, y: e.clientY, panX, panY, moved: false }; });
|
||||
canvas.addEventListener('mouseleave', () => { tip.hidden = true; drag = null; box = null; canvas.classList.remove('dragging'); paint(); });
|
||||
canvas.addEventListener('mousedown', (e) => {
|
||||
if (e.shiftKey) {
|
||||
const rect = canvas.getBoundingClientRect();
|
||||
const x = e.clientX - rect.left, y = e.clientY - rect.top;
|
||||
box = { x0: x, y0: y, x1: x, y1: y };
|
||||
return;
|
||||
}
|
||||
drag = { x: e.clientX, y: e.clientY, panX, panY, moved: false };
|
||||
});
|
||||
canvas.addEventListener('mouseup', (e) => {
|
||||
if (box) {
|
||||
const b = box;
|
||||
box = null;
|
||||
if (Math.abs(b.x1 - b.x0) < 4 && Math.abs(b.y1 - b.y0) < 4) {
|
||||
const found = hit(b.x0, b.y0);
|
||||
if (found && found.cell) {
|
||||
if (marked.has(found.cell.life)) marked.delete(found.cell.life); else marked.add(found.cell.life);
|
||||
}
|
||||
} else if (view) {
|
||||
// Every shown cell whose centre is inside the box.
|
||||
const g = geometry();
|
||||
const xs = [b.x0, b.x1].map((v) => g.fromX(v * g.dpr)), ys = [b.y0, b.y1].map((v) => g.fromY(v * g.dpr));
|
||||
const [x0, x1] = [Math.min(...xs), Math.max(...xs)], [y0, y1] = [Math.min(...ys), Math.max(...ys)];
|
||||
for (const c of view.cells) {
|
||||
const cx = c.x + c.extent / 2, cy = c.y + c.extent / 2;
|
||||
if (layers[cellLayer(c)] && cx >= x0 && cx <= x1 && cy >= y0 && cy <= y1) marked.add(c.life);
|
||||
}
|
||||
}
|
||||
drawMarks();
|
||||
paint();
|
||||
return;
|
||||
}
|
||||
const moved = drag && drag.moved;
|
||||
drag = null;
|
||||
canvas.classList.remove('dragging');
|
||||
@@ -1397,7 +1495,16 @@ async function regionPage(region, params) {
|
||||
const deposits = Number(raw.deposits_total);
|
||||
const r = rate();
|
||||
k.tick.set(fmtInt(tick), pace.stalled ? `not advancing for ${fmtDuration((now - pace.movedAt) / 1000)}` : `${r.toFixed(1)} ticks/s`, pace.stalled ? 'warn' : '');
|
||||
k.cells.set(fmtInt(players + wild), `${fmtInt(players)} players · ${fmtInt(wild)} wildlife`, players + wild ? '' : 'warn');
|
||||
if (raw.caps) {
|
||||
// Births stop at the organism cap; wildlife buds stop at the wildlife cap.
|
||||
const cap = Number(raw.caps[0]), wildCap = Number(raw.caps[1]) || cap, lives = players + wild;
|
||||
const full = lives >= cap ? 'bad' : lives >= wildCap ? 'warn' : '';
|
||||
k.cells.set(`${fmtInt(lives)} / ${fmtInt(cap)}`,
|
||||
`${fmtInt(players)} players · ${fmtInt(wild)} wildlife${wildCap < cap ? ` · wildlife stop at ${fmtInt(wildCap)}` : ''}`,
|
||||
lives ? full : 'warn', lives / cap, full);
|
||||
} else {
|
||||
k.cells.set(fmtInt(players + wild), `${fmtInt(players)} players · ${fmtInt(wild)} wildlife`, players + wild ? '' : 'warn');
|
||||
}
|
||||
k.deposits.set(`${fmtInt(deposits)} / ${fmtInt(depositLimit)}`, `${fmtInt(kinds[2])} bubbles · ${fmtInt(kinds[1])} pools`,
|
||||
deposits >= depositLimit ? 'bad' : '', deposits / depositLimit, deposits >= depositLimit ? 'bad' : deposits >= depositLimit * 0.9 ? 'warn' : '');
|
||||
k.energy.set(fmtEnergy(energy), `${fmtEnergy(freeOf(0))} free to eat`, energy ? '' : 'bad');
|
||||
@@ -1416,6 +1523,11 @@ async function regionPage(region, params) {
|
||||
banner.hidden = !pace.stalled;
|
||||
banner.textContent = pace.stalled ? `Tick ${fmtInt(tick)} has not advanced for ${fmtDuration((now - pace.movedAt) / 1000)}` : '';
|
||||
|
||||
if (marked.size) {
|
||||
const alive = new Set(view.cells.map((c) => c.life));
|
||||
for (const life of marked) if (!alive.has(life)) marked.delete(life);
|
||||
drawMarks();
|
||||
}
|
||||
if (selected) {
|
||||
if (selected.cell) {
|
||||
const again = view.cells.find((c) => c.life === selected.cell.life);
|
||||
@@ -1505,6 +1617,11 @@ const tuningUnits = [
|
||||
[/_pj$/, 'pJ'], [/_fg$/, 'fg'], [/_ticks$/, 'ticks'], [/_ms$/, 'ms'], [/_um$/, 'µm'], [/_seconds$/, 's'], [/_mk$/, 'mK'],
|
||||
];
|
||||
const tuningSwitches = new Set(['feeding.split_evenly', 'spent.drip_absorb']);
|
||||
const tuningOptional = [
|
||||
['spent.heat_recycle_per_mille', '0', 'share of the heat returned to the spent pool each tick'],
|
||||
['spent.drip_absorb', '0', 'a drip at the deposit limit joins an existing bubble'],
|
||||
['reproduction.wildlife_cap', '0', 'wildlife buds refused at this many lives (0: the organism cap); the rest are for players'],
|
||||
];
|
||||
const isSwitch = (key) => tuningSwitches.has(key) || key.endsWith('.enabled');
|
||||
function tuningLabel(key, section) {
|
||||
let name = key.slice(section.length + 1);
|
||||
@@ -1584,6 +1701,13 @@ async function tuningPage() {
|
||||
|
||||
// ----- Guided editor -----
|
||||
const groups = parseTuning(base.text);
|
||||
// Optional keys a revision may lack, shown at the value that keeps the historical law.
|
||||
for (const [key, value, note] of tuningOptional) {
|
||||
const name = key.split('.')[0];
|
||||
let group = groups.find((g) => g.name === name);
|
||||
if (!group) { group = { name, about: '', settings: [] }; groups.push(group); }
|
||||
if (!group.settings.some((s) => s.key === key)) group.settings.push({ key, value, note, lead: '' });
|
||||
}
|
||||
const baseValues = new Map(groups.flatMap((g) => g.settings.map((s) => [s.key, s.value])));
|
||||
const edits = new Map(); // key -> normalized new value (only where it differs)
|
||||
const problems = new Map(); // key -> message (bad input or the server's refusal)
|
||||
|
||||
Reference in New Issue
Block a user