New worlds get generated camp names like new claims (t3)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-24 19:00:22 -04:00
co-authored by Claude Opus 5.5
parent 66543bbd4b
commit 945e5205b8
5 changed files with 34 additions and 11 deletions
+17 -6
View File
@@ -1,7 +1,7 @@
"""Play-test in a real browser: mouse, keyboard and a mocked gamepad drive the game; save and continue.
Screenshots go to shots/play/ (or the folder given as the first argument). Pixel look unless the
second argument is 'smooth'."""
import json, sys, pathlib
import json, sys, pathlib, re
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent.parent / 'tools'))
from use_venv import ensure_playwright; ensure_playwright()
from playwright.sync_api import sync_playwright
@@ -75,12 +75,23 @@ with sync_playwright() as p:
if pg.is_visible('#nw-seed'): pg.click('#btn-new')
pg.click('#btn-new')
pg.wait_for_function("document.activeElement === $('nw-name')")
names[seed] = 'Copper Valley' if seed == 222 else pg.input_value('#nw-name')
check(f'new world {seed} offers the next default name', pg.input_value('#nw-name') == f'World {2 if seed == 222 else 3}')
auto_name = pg.input_value('#nw-name')
check(f'new world {seed} offers a two-word camp name', bool(re.fullmatch(r'[A-Z][a-z]+ [A-Z][a-z]+', auto_name)))
check(f'new world {seed} default matches its seed', auto_name == pg.evaluate("async () => claimName(parseInt($('nw-seed').value, 10), (await listWorlds()).map(w => w.name))"))
check('default name is selected for replacement', pg.evaluate("$('nw-name').selectionStart === 0 && $('nw-name').selectionEnd === $('nw-name').value.length"))
pg.fill('#nw-seed', '42')
first_name = pg.input_value('#nw-name')
pg.fill('#nw-seed', str(seed))
expected = pg.evaluate("async seed => claimName(seed, (await listWorlds()).map(w => w.name))", seed)
check(f'changing seed to {seed} updates the camp name', pg.input_value('#nw-name') == expected and expected != first_name)
names[seed] = 'Copper Valley' if seed == 222 else expected
if seed == 222:
pg.fill('#nw-name', names[seed])
pg.screenshot(path=str(out / 'new-world.png'))
pg.fill('#nw-seed', str(seed)); pg.press('#nw-name' if seed == 222 else '#nw-seed', 'Enter')
pg.fill('#nw-seed', '42')
check('changing the seed keeps a typed world name', pg.input_value('#nw-name') == names[seed])
pg.fill('#nw-seed', str(seed))
pg.screenshot(path=str(out / 'new-world.png'))
pg.press('#nw-name' if seed == 222 else '#nw-seed', 'Enter')
pg.wait_for_function('GAME.running', timeout=20000)
check(f'new world {seed} paints a moving generation bar', pg.evaluate("__loads.some(([t, s, w]) => t === 'Generating world' && parseFloat(w) > 0 && parseFloat(w) < 90) && !GAME.loading"))
check(f'new world {seed} shows the Welcome card', pg.evaluate("[...$('cards').children].some(c => c.textContent.includes('Welcome'))"))
@@ -133,7 +144,7 @@ with sync_playwright() as p:
check('Continue chooses the most recently saved world', pg.evaluate('worldSeed') == 333)
pg.evaluate('quitToTitle()')
if not pg.is_visible('#nw-seed'): pg.click('#btn-new')
blank_default = pg.evaluate("listWorlds().then(w => `World ${w.length + 1}`)")
blank_default = pg.evaluate("listWorlds().then(w => claimName(777, w.map(w => w.name)))")
pg.fill('#nw-name', ' ')
pg.fill('#nw-seed', '777'); pg.click('#btn-generate')
pg.wait_for_function('GAME.running === true', timeout=20000)