New claims get camp names from their seed, renameable from the Claims tab; add t30 (t3)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+29
-3
@@ -56,6 +56,21 @@ async function loadCareer() {
|
||||
GAME.careerId = career.id;
|
||||
} catch (e) { career = null; toast('Career could not be loaded. Using this world’s own money and bag.'); }
|
||||
}
|
||||
// Seeded camp names stay the same unless an existing world already uses one.
|
||||
function claimName(seed, taken = []) {
|
||||
const first = ['Copper', 'Iron', 'Red', 'Black', 'Grey', 'Silver', 'Deep', 'Cinder', 'Ash', 'Granite', 'Basalt', 'Slate', 'Rust', 'Ember', 'Flint', 'Cold', 'Hollow', 'Lone', 'Twin', 'Broken'];
|
||||
const last = ['Hollow', 'Ridge', 'Flats', 'Gulch', 'Mesa', 'Seam', 'Reach', 'Bluff', 'Basin', 'Crag', 'Shelf', 'Draw', 'Cut', 'Rise', 'Pit', 'Vein', 'Wash', 'Fork', 'Run', 'Bench'];
|
||||
const count = first.length * last.length, start = Math.floor(mulberry32(seed)() * count);
|
||||
for (let offset = 0; offset < count; offset++) {
|
||||
const i = (start + offset) % count, a = first[Math.floor(i / last.length)], b = last[i % last.length];
|
||||
const name = a + ' ' + b;
|
||||
if (a !== b && !taken.includes(name)) return name;
|
||||
}
|
||||
// every camp name is taken: fall back to numbered names
|
||||
let n = 1;
|
||||
while (taken.includes('Mining Camp ' + n)) n++;
|
||||
return 'Mining Camp ' + n;
|
||||
}
|
||||
async function openNewClaim() {
|
||||
if (claimBusy || !career || debt > 0 || money < 5000) return false;
|
||||
claimBusy = true; const paused = GAME.paused; GAME.paused = true;
|
||||
@@ -66,13 +81,14 @@ async function openNewClaim() {
|
||||
const carried = careerState(), n = career.claimNo + 1, w = W, h = H;
|
||||
carried.money -= 5000;
|
||||
let seed; do { seed = Math.floor(Math.random() * 900000) + 100000; } while (seed === worldSeed);
|
||||
await setupNewWorld(seed, w, h, `Claim ${n}`, carried);
|
||||
const name = claimName(seed, (await listWorlds()).map(w => w.name));
|
||||
await setupNewWorld(seed, w, h, name, carried);
|
||||
debt = CLAIM_DEBT * 2 ** (n - 1);
|
||||
career = { ...career, claims: [...career.claims, GAME.worldId], claimNo: n };
|
||||
GAME.claimNo = n;
|
||||
if (!await saveWorld('auto', true)) throw new Error('Save failed');
|
||||
showLoading(false); closeAllModals(); enterGame();
|
||||
showCard({ kind: 'New claim', title: `Claim ${n}`, body: [`You owe ${fmtMoney(debt)} on this claim. Your money, bag, upgrades and what you’ve learned came along. Buildings stayed on the old claim.`], hold: 1.8 });
|
||||
showCard({ kind: 'New claim', title: name, body: [`Claim ${n}. You owe ${fmtMoney(debt)} on this claim. Your money, bag, upgrades and what you’ve learned came along. Buildings stayed on the old claim.`], hold: 1.8 });
|
||||
return true;
|
||||
} catch (e) {
|
||||
if (previous) {
|
||||
@@ -101,9 +117,19 @@ async function renderClaimsTab(body) {
|
||||
try {
|
||||
const list = (await listWorlds()).filter(w => career && w.career === GAME.careerId && career.claims.includes(w.id));
|
||||
if (nbTab !== 'Claims') return;
|
||||
body.innerHTML = list.map(w => `<div class="world-row"><div class="world-info"><strong>${esc(w.name)}${w.id === GAME.worldId ? ' · here' : ''}</strong><div class="note">${esc(w.w)}×${esc(w.h)} grains · ${(w.id === GAME.worldId ? debt : w.debt) <= 0 ? 'paid off ✓' : fmtMoney(w.id === GAME.worldId ? debt : w.debt || 0) + ' owed'} · Last played: ${w.savedAt ? esc(new Date(w.savedAt).toLocaleString()) : 'Just opened'}</div></div>${w.id === GAME.worldId ? '' : `<button class="btn" data-travel="${esc(w.id)}">Travel</button>`}</div>`).join('') +
|
||||
body.innerHTML = list.map(w => `<div class="world-row"><div class="world-info"><strong>${esc(w.name)}${w.id === GAME.worldId ? ' · here' : ''}</strong> <small class="note">Claim ${esc(w.claimNo)}</small><div class="note">${esc(w.w)}×${esc(w.h)} grains · ${(w.id === GAME.worldId ? debt : w.debt) <= 0 ? 'paid off ✓' : fmtMoney(w.id === GAME.worldId ? debt : w.debt || 0) + ' owed'} · Last played: ${w.savedAt ? esc(new Date(w.savedAt).toLocaleString()) : 'Just opened'}</div></div><button class="btn" data-rename="${esc(w.id)}">Rename</button>${w.id === GAME.worldId ? '' : `<button class="btn" data-travel="${esc(w.id)}">Travel</button>`}</div>`).join('') +
|
||||
(debt <= 0 ? `<button class="btn primary" id="claim-open" ${money < 5000 || !career ? 'disabled' : ''}>Open a new claim: $5,000 down, then ${fmtMoney(CLAIM_DEBT * 2 ** (career ? career.claimNo : 1))} owed</button>${money < 5000 ? '<p class=note>You need $5,000 for the down payment.</p>' : ''}` : '<p class=note>A new claim opens once this one is paid off.</p>') +
|
||||
'<p class=note>Machines on other claims wait until you come back.</p>';
|
||||
body.querySelectorAll('[data-rename]').forEach(b => b.onclick = () => {
|
||||
const w = list.find(w => w.id === b.dataset.rename);
|
||||
dialog('Rename claim', `<input class="text" type="text" id="claim-name" aria-label="Claim name" maxlength="40" value="${esc(w.name)}">`, [
|
||||
{ label: 'Cancel', cls: 'ghost' }, { label: 'Save', cls: 'primary', fn: async () => {
|
||||
const name = cleanWorldName($('claim-name').value, w.name);
|
||||
try { await renameWorld(w.id, name); closeModal('m-dialog'); renderClaimsTab(body); }
|
||||
catch (e) { toast('Could not rename this claim. Try again.'); }
|
||||
} },
|
||||
]);
|
||||
});
|
||||
const button = $('claim-open');
|
||||
if (button) button.onclick = () => dialog('Open a new claim?', `<p class="note">Pay $5,000 down and owe ${fmtMoney(CLAIM_DEBT * 2 ** career.claimNo)} on fresh land. Your buildings stay here.</p>`, [
|
||||
{ label: 'Cancel', cls: 'ghost' }, { label: 'Open claim', cls: 'primary', fn: () => { closeModal('m-dialog'); openNewClaim(); } },
|
||||
|
||||
Reference in New Issue
Block a user