feat: integrate login flow, lobby UI and bitmap font resources

This commit is contained in:
2026-09-06 13:46:57 +08:00
parent e1bcfd91ec
commit 842c68ef55
141 changed files with 11279 additions and 1717 deletions
@@ -0,0 +1,25 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { PlatformStore } from '../../YouleNexus/assets/framework/platform/stores/platform-store.ts';
import { parseLoginResponse } from '../../YouleNexus/assets/framework/protocol/contracts/login-contract.ts';
const response = () => JSON.parse(readFileSync(new URL('../fixtures/contracts/player-login-success.json', import.meta.url), 'utf8')).data;
test('login publishes server assets and task status, including subsequent login changes', () => {
const store = new PlatformStore();
const data = response();
store.applyLoginSuccess(parseLoginResponse(data));
const self = () => store.getState().players.entities[data.playerid] as any;
assert.equal(self().roomcard, 3);
assert.equal(self().taskstate, 1);
assert.equal(self().score, 0);
assert.equal(self().sign, null);
store.applyLoginSuccess(parseLoginResponse({...data, roomcard:8, taskstate:0}));
assert.equal(self().roomcard, 8);
assert.equal(self().taskstate, 0);
});
test('invalid supplied asset fields reject the complete login without publishing partial state', () => {
const store = new PlatformStore(), before = store.getState();
assert.throws(() => store.applyLoginSuccess(parseLoginResponse({...response(), roomcard:'3'})), /roomcard/);
assert.equal(store.getState(), before);
});
@@ -0,0 +1,21 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { createRemoteConfig } from '../../YouleNexus/assets/framework/config/remote-config.ts';
import { resolveLobbyPolicy, shouldShowNotice, selectLobbyModel } from '../../YouleNexus/assets/framework/presentation/lobby-model.ts';
const identity = {agentid:'a',gameid:'g',channelid:'c',marketid:'m',version:1};
test('announcement interval preserves strict expiry and never shows on reconnect',()=>{
assert.equal(shouldShowNotice(0, null, 1000, false),true);
assert.equal(shouldShowNotice(-1, null, 1000, false),false);
assert.equal(shouldShowNotice(1, 1000, 3601000, false),false);
assert.equal(shouldShowNotice(1, 1000, 3601001, false),true);
assert.equal(shouldShowNotice(0, null, 1000, true),false);
});
test('notice configuration follows the same channel source and replaces legacy line breaks',()=>{
const p=resolveLobbyPolicy(createRemoteConfig({noticemsg:'global',agentlist:[{agentid:'a',menunotice:{advert0:{type:0,msg:'one#two',url:''}}}]},identity));
assert.equal(p.notices[0].text,'one\ntwo');
assert.equal(p.noticeHours,0);
assert.throws(()=>resolveLobbyPolicy(createRemoteConfig({gameNoticeShow:'bad'},identity)),/gameNoticeShow/);
});
test('lobby rejects incomplete self assets instead of displaying invented zeroes',()=>{
assert.throws(()=>selectLobbyModel({app:{phase:'logged-in'},room:{kind:'outside'},players:{selfPlayerId:7,entities:{7:{playerid:7,nickname:'A',avatar:'',sex:0,bean:0}}}}),/roomcard/);
});