feat: add persistent unique tags to player nicknames

This commit is contained in:
2026-10-26 18:15:29 +09:00
parent fc45534c7d
commit 794cc4da04
8 changed files with 77 additions and 16 deletions
+8 -1
View File
@@ -1,6 +1,13 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { profileNameError } from '../src/shared/profile-name.js';
import { formatProfileName, profileNameError } from '../src/shared/profile-name.js';
test('name tags distinguish duplicate nicknames and keep all digits beyond four places', () => {
assert.equal(formatProfileName({ displayName: '손오공', nameTag: 1 }), '손오공#0001');
assert.equal(formatProfileName({ displayName: '손오공', nameTag: 2 }), '손오공#0002');
assert.equal(formatProfileName({ displayName: '손오공', nameTag: 10000 }), '손오공#10000');
assert.equal(profileNameError('손오공#0001'), 'INVALID_PROFILE_NAME');
});
test('nickname validation accepts ordinary names and rejects profanity and separated variants', () => {
for (const name of ['손오공', '무도가', '구름-1234', 'ClassMaster', '별빛 전사']) assert.equal(profileNameError(name), undefined, name);