feat: add persistent unique tags to player nicknames
This commit is contained in:
@@ -44,7 +44,7 @@ test('first visit waits for a saved nickname and keeps the form open on rejectio
|
||||
const document = documentSurface(), original = Object.getOwnPropertyDescriptor(globalThis, 'document');
|
||||
Object.defineProperty(globalThis, 'document', { configurable: true, value: document });
|
||||
t.after(() => { if (original) Object.defineProperty(globalThis, 'document', original); else Reflect.deleteProperty(globalThis, 'document'); });
|
||||
const profile: PlayerProfile = { playerId: 'a', displayName: '', appearance: normalizeAppearance(undefined),
|
||||
const profile: PlayerProfile = { playerId: 'a', displayName: '', nameTag: 1, appearance: normalizeAppearance(undefined),
|
||||
stats: { wins: 0, losses: 0, draws: 0, current: 0, best: 0 }, unlockedColors: ['white'], unlockedEquipment: [] };
|
||||
let writes = 0, initialized = false, rejectSave = true;
|
||||
const api = { async request(_path: string, method?: string, body?: { displayName: string }) {
|
||||
@@ -70,6 +70,11 @@ test('first visit waits for a saved nickname and keeps the form open on rejectio
|
||||
assert.equal(initialized, false); assert.equal(dialog.querySelector('p').textContent, '저장 실패');
|
||||
rejectSave = false; await submit(); await loading;
|
||||
assert.equal(initialized, true); assert.equal(dialog.open, false);
|
||||
assert.equal(document.getElementById('profile-name').textContent, '손오공#0001');
|
||||
await document.getElementById('nickname-open').onclick!();
|
||||
assert.equal(dialog.querySelector('input').value, '손오공', 'the tag is not part of the editable nickname');
|
||||
dialog.querySelector('input').value = '베지터'; await submit();
|
||||
assert.equal(document.getElementById('profile-name').textContent, '베지터#0001');
|
||||
});
|
||||
|
||||
test('ranked confirmation shows accept, waits for opponent and cancels by offer id', async t => {
|
||||
@@ -77,7 +82,7 @@ test('ranked confirmation shows accept, waits for opponent and cancels by offer
|
||||
Object.defineProperty(globalThis, 'document', { configurable: true, value: document });
|
||||
t.after(() => { if (original) Object.defineProperty(globalThis, 'document', original); else Reflect.deleteProperty(globalThis, 'document'); });
|
||||
t.mock.timers.enable({ apis: ['setTimeout'] });
|
||||
const profile: PlayerProfile = { playerId: 'a', displayName: 'A', appearance: normalizeAppearance(undefined),
|
||||
const profile: PlayerProfile = { playerId: 'a', displayName: 'A', nameTag: 1, appearance: normalizeAppearance(undefined),
|
||||
stats: { wins: 0, losses: 0, draws: 0, current: 0, best: 0 }, unlockedColors: ['white'], unlockedEquipment: [] };
|
||||
let accepted = false, screen = '', cancelBody: unknown;
|
||||
const api = { async request(path: string, method?: string, body?: unknown) {
|
||||
@@ -104,7 +109,7 @@ test('a delayed accept response cannot overwrite a restored newer offer', async
|
||||
Object.defineProperty(globalThis, 'document', { configurable: true, value: document });
|
||||
t.after(() => { if (original) Object.defineProperty(globalThis, 'document', original); else Reflect.deleteProperty(globalThis, 'document'); });
|
||||
t.mock.timers.enable({ apis: ['setTimeout'] });
|
||||
const profile: PlayerProfile = { playerId: 'a', displayName: 'A', appearance: normalizeAppearance(undefined),
|
||||
const profile: PlayerProfile = { playerId: 'a', displayName: 'A', nameTag: 1, appearance: normalizeAppearance(undefined),
|
||||
stats: { wins: 0, losses: 0, draws: 0, current: 0, best: 0 }, unlockedColors: ['white'], unlockedEquipment: [] };
|
||||
let currentId = 'old', finishAccept!: (value: unknown) => void;
|
||||
const pendingAccept = new Promise(resolve => { finishAccept = resolve; });
|
||||
@@ -130,7 +135,7 @@ test('an old confirmation poll cannot restore the prompt after accepting starts
|
||||
Object.defineProperty(globalThis, 'document', { configurable: true, value: document });
|
||||
t.after(() => { if (original) Object.defineProperty(globalThis, 'document', original); else Reflect.deleteProperty(globalThis, 'document'); });
|
||||
t.mock.timers.enable({ apis: ['setTimeout'] });
|
||||
const profile: PlayerProfile = { playerId: 'a', displayName: 'A', appearance: normalizeAppearance(undefined),
|
||||
const profile: PlayerProfile = { playerId: 'a', displayName: 'A', nameTag: 1, appearance: normalizeAppearance(undefined),
|
||||
stats: { wins: 0, losses: 0, draws: 0, current: 0, best: 0 }, unlockedColors: ['white'], unlockedEquipment: [] };
|
||||
const confirming = { status: 'confirming', profile, offer: { matchId: 'offer-a', expiresAt: 10000, serverNow: 0, accepted: false } };
|
||||
const engine = createMatchEngine({ matchId: 'offer-a', mode: 'friend', selfIndex: 0, clock: { now: () => 0 } });
|
||||
@@ -166,7 +171,7 @@ for (const initiallyQueued of [false, true]) test(`ranked introduction follows s
|
||||
const engine = createMatchEngine({ matchId: 'ranked-intro', mode: 'friend', selfIndex: 0, clock: { now: () => now } });
|
||||
engine.start(matchIntroductionDuration(DEFAULT_GLOBAL_SETTINGS, true));
|
||||
const profile: PlayerProfile = {
|
||||
playerId: 'player-a', displayName: 'Alpha', appearance: normalizeAppearance(undefined),
|
||||
playerId: 'player-a', displayName: 'Alpha', nameTag: 1, appearance: normalizeAppearance(undefined),
|
||||
stats: { wins: 0, losses: 0, draws: 0, current: 0, best: 0 }, unlockedColors: ['white'], unlockedEquipment: [],
|
||||
};
|
||||
const screens: string[] = [];
|
||||
@@ -213,7 +218,7 @@ test('a profile read started before equip cannot undo the saved appearance', asy
|
||||
else Reflect.deleteProperty(globalThis, 'document');
|
||||
});
|
||||
const profile = (skinTone: 'light' | 'tan'): PlayerProfile => ({
|
||||
playerId: 'player-a', displayName: 'Alpha', appearance: normalizeAppearance({ characterId: 0, skinTone, colorId: 'white' }),
|
||||
playerId: 'player-a', displayName: 'Alpha', nameTag: 1, appearance: normalizeAppearance({ characterId: 0, skinTone, colorId: 'white' }),
|
||||
stats: { wins: 0, losses: 0, draws: 0, current: 0, best: 0 }, unlockedColors: ['white'], unlockedEquipment: [],
|
||||
});
|
||||
let finishOldRead!: (value: PlayerProfile) => void;
|
||||
@@ -267,7 +272,7 @@ for (const editedDuringLoad of [false, true]) {
|
||||
const cached = normalizeAppearance({ characterId: 0, colorId: 'white' });
|
||||
const remote = normalizeAppearance({ characterId: 1, colorId: 'white', equipment: ['shoes'] });
|
||||
const profile = (appearance: FighterAppearance): PlayerProfile => ({
|
||||
playerId: 'player-a', displayName: 'Alpha', appearance,
|
||||
playerId: 'player-a', displayName: 'Alpha', nameTag: 1, appearance,
|
||||
stats: { wins: 5, losses: 0, draws: 0, current: 5, best: 5 },
|
||||
unlockedColors: ['white'], unlockedEquipment: ['shoes', 'wristbands'],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user