aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


commit db333f44966968463910ce202ca76222b716403c
parent 885149a47c5b750c954aae1ba6c2a8dbf5dffd2a
Author: anon <anon@example.com>
Date:   Fri,  6 Nov 2026 22:56:03 +0000

Compact character credentials and confirm the password

Diffstat:
MTODO.md | 3++-
Mclient/browser/index.html | 24++++++++++++++++++------
Mclient/tests/browser_controls.mjs | 22++++++++++++++++++++--
Mdocs/character-creation.md | 4+++-
Mtests/e2e/mobile-creation.test.mjs | 11+++++++++++
Mtests/e2e/native-creation.test.mjs | 2++
Mtools/client/create_starter.mjs | 1+
7 files changed, 57 insertions(+), 10 deletions(-)

diff --git a/TODO.md b/TODO.md @@ -36,7 +36,8 @@ research separately. More screenshots and test cases do not count as new gamepla ## P0: first experience - [x] **Use the original native character creation flow.** Login credentials are - collected in a modal at native naming, with native controls blocked until OK + collected in a compact modal with password confirmation at native naming, + with native controls blocked until OK advances the sequence. Phone and desktop browser regressions pass: password login after creation/restart, cancellation and refresh without duplicate creation, 4:3 proportions through the outro, and adaptive world rendering. diff --git a/client/browser/index.html b/client/browser/index.html @@ -55,7 +55,13 @@ #account-choices button { display: block; width: 100%; margin: 8px 0; } #account-choices button[hidden] { display: none; } #account-form input, #creation-credentials input { box-sizing: border-box; display: block; width: 100%; margin-top: 6px; padding: 8px; } - #creation-credentials input { font-size: 16px; } + #creation-credentials { width: min(300px, calc(100vw - 48px)); padding: 12px; } + #creation-credentials h1 { font-size: 18px; } + #creation-credentials label { margin: 8px 0; } + #creation-credentials input { font-size: 16px; margin-top: 3px; padding: 6px; } + #creation-credentials button { min-height: 36px; padding: 6px 14px; } + #creation-actions { display: flex; justify-content: flex-end; margin-top: 10px; } + #creation-error { margin: 8px 0 0; } #account-form label[hidden] { display: none; } #account-error, #creation-error { color: #ffb0a0; } #account-error.success { color: #b9d8b0; } @@ -128,15 +134,16 @@ </dialog> <dialog id="creation-credentials" aria-labelledby="creation-title"> <h1 id="creation-title">Name your character</h1> - <p>Use this name and password to log in to this character.</p> <form id="creation-form"> <fieldset id="creation-fields"> <label>Player name <input id="creation-player-name" name="username" autocomplete="username" autocapitalize="none" spellcheck="false" maxlength="12" required></label> <label>Password <input id="creation-password" name="password" type="password" autocomplete="new-password" maxlength="1024"></label> - <button id="creation-submit" type="submit">OK</button> + <label>Confirm password <input id="creation-password-confirm" type="password" autocomplete="new-password" maxlength="1024"></label> + <div id="creation-actions"> + <button id="creation-submit" type="submit">OK</button> + </div> </fieldset> <p id="creation-error" role="status"></p> - <button id="creation-cancel" type="button">Cancel creation</button> </form> </dialog> <script> @@ -462,11 +469,15 @@ show(); } } }; - document.querySelector('#creation-cancel').onclick = () => location.reload(); - creationDialog.addEventListener('cancel', event => { event.preventDefault(); location.reload(); }); + creationDialog.addEventListener('cancel', event => event.preventDefault()); document.querySelector('#creation-form').onsubmit = async event => { event.preventDefault(); if (creationFields.disabled || creationSubmitted) return; + if (document.querySelector('#creation-password').value !== document.querySelector('#creation-password-confirm').value) { + creationError.textContent = 'Passwords do not match.'; + document.querySelector('#creation-password-confirm').focus(); + return; + } creationFields.disabled = true; creationError.textContent = ''; const values = new URLSearchParams({name: document.querySelector('#creation-player-name').value, @@ -476,6 +487,7 @@ show(); if (response.ok) { creationSubmitted = true; document.querySelector('#creation-password').value = ''; + document.querySelector('#creation-password-confirm').value = ''; Module.finishCreation(response.headers.get('X-AO-Creation-Name')); return; } diff --git a/client/tests/browser_controls.mjs b/client/tests/browser_controls.mjs @@ -149,6 +149,7 @@ test('naming credentials block game keys until native Finish advances', async () game.creationState({active: true, name: {value: ''}}); game.element('#creation-player-name').value = 'phonehero'; game.element('#creation-password').value = 'phone password'; + game.element('#creation-password-confirm').value = 'phone password'; const nativeKeys = []; game.window.addEventListener('keydown', event => nativeKeys.push(event.key)); @@ -167,6 +168,7 @@ test('naming credentials block game keys until native Finish advances', async () assert.equal(game.requests[0].body.toString(), 'name=phonehero&password=phone+password'); assert.deepEqual(game.creationNames, ['Phonehero']); assert.equal(game.element('#creation-password').value, ''); + assert.equal(game.element('#creation-password-confirm').value, ''); assert.equal(game.element('#creation-credentials').open, true); assert.equal(game.element('#creation-fields').disabled, true); @@ -190,7 +192,23 @@ test('rejected naming credentials leave the modal editable without advancing', a assert.deepEqual(game.creationNames, []); }); -test('cancelling the naming modal reloads instead of exposing native controls', () => { +test('mismatched passwords keep naming editable without submitting credentials', async () => { + const game = page(); + game.creationState({active: true, name: {value: ''}}); + game.element('#creation-password').value = 'secret'; + game.element('#creation-password-confirm').value = 'different'; + + await game.element('#creation-form').onsubmit({preventDefault() {}}); + + assert.equal(game.requests.length, 0); + assert.deepEqual(game.creationNames, []); + assert.equal(game.element('#creation-credentials').open, true); + assert.equal(!!game.element('#creation-fields').disabled, false); + assert.equal(game.element('#creation-error').textContent, 'Passwords do not match.'); + assert.equal(game.document.activeElement, game.element('#creation-password-confirm')); +}); + +test('Escape keeps the naming modal open without abandoning creation', () => { const game = page(); game.creationState({active: true, name: {value: ''}}); @@ -198,7 +216,7 @@ test('cancelling the naming modal reloads instead of exposing native controls', assert.equal(cancel.defaultPrevented, true); assert.equal(game.element('#creation-credentials').open, true); - assert.deepEqual(game.reloads, [true]); + assert.deepEqual(game.reloads, []); }); test('Firefox Android leaves fullscreen for the naming keyboard', async () => { diff --git a/docs/character-creation.md b/docs/character-creation.md @@ -6,7 +6,9 @@ Options' "Create character from scratch" starts an unnamed creation attempt and launches the original translated `ddr.dll` creator with character ID zero. Its breed, appearance, profession and naming scenes use the original models, controls and camera paths. At the native naming step, an HTML modal collects -the character's login name and password. The modal makes the game controls inert, +the character's login name and password, with a second password field to confirm +the entry. Its only button is OK; mismatched passwords stay in the dialog without +a server request. The modal makes the game controls inert, including Randomize, and captures keyboard events before they reach the game. `POST /browser-create` validates the name and attaches a salted password hash to that same creation attempt in memory. diff --git a/tests/e2e/mobile-creation.test.mjs b/tests/e2e/mobile-creation.test.mjs @@ -89,6 +89,17 @@ test('mobile naming modal blocks native controls, survives refresh and preserves await page.keyboard.insertText('Phonehero'); await page.locator('#creation-password').tap(); await page.keyboard.insertText('phone password'); + await page.locator('#creation-password-confirm').tap(); + await page.keyboard.insertText('typo'); + await page.locator('#creation-submit').tap(); + assert.equal(await page.locator('#creation-error').textContent(), 'Passwords do not match.'); + assert.equal((await fixture.state(context)).id, original.id); + await page.locator('#creation-password-confirm').fill('phone password'); + await page.keyboard.press('Escape'); + assert.equal(await page.locator('#creation-credentials').isVisible(), true); + assert.deepEqual(await page.locator('#creation-credentials button').allTextContents(), ['OK']); + const dialog = await page.locator('#creation-credentials').boundingBox(); + assert(dialog.width <= 326 && dialog.height < 350); await game.snapshot(); const blockedSequence = game.sequence; const finish = await game.point(945, 730); diff --git a/tests/e2e/native-creation.test.mjs b/tests/e2e/native-creation.test.mjs @@ -48,6 +48,7 @@ test('native creation credentials preserve cancellation and the complete starter for (const [name, status] of [['ab', 400], ['Existing', 409]]) { await game.page.locator('#creation-player-name').fill(name); await game.page.locator('#creation-password').fill('native password'); + await game.page.locator('#creation-password-confirm').fill('native password'); const [response] = await Promise.all([ game.page.waitForResponse(response => response.url().endsWith('/browser-create') && response.request().method() === 'POST'), game.page.locator('#creation-submit').click(), @@ -64,6 +65,7 @@ test('native creation credentials preserve cancellation and the complete starter await game.page.locator('#creation-player-name').fill('Nativehero'); await game.page.locator('#creation-password').fill('native password'); + await game.page.locator('#creation-password-confirm').fill('native password'); await game.page.locator('#creation-submit').click(); await game.ready(); assert.equal(game.local().playfield, 4604); diff --git a/tools/client/create_starter.mjs b/tools/client/create_starter.mjs @@ -29,6 +29,7 @@ export async function finishStarter(game, name, password) { await game.page.locator('#creation-credentials').waitFor({state: 'visible'}); await game.page.locator('#creation-player-name').fill(name); await game.page.locator('#creation-password').fill(password); + await game.page.locator('#creation-password-confirm').fill(password); await game.page.locator('#creation-submit').click(); await game.ready(); assert.equal(game.local().playfield, 4604);