Skip to content

Commit bde56b0

Browse files
committed
feat(play-character): connect to Lich when pref is enabled
1 parent 2728111 commit bde56b0

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

electron/main/ipc/handlers/play-character.ts

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import type { GameCode } from '../../../common/game/types.js';
22
import type { AccountService } from '../../account/types.js';
33
import { Game } from '../../game/game.instance.js';
4+
import { startLichProcess } from '../../lich/start-process.js';
5+
import { Preferences } from '../../preference/preference.instance.js';
6+
import { PreferenceKey } from '../../preference/types.js';
47
import { SGEServiceImpl } from '../../sge/sge.service.js';
5-
import type { SGEGameCode } from '../../sge/types.js';
68
import { logger } from '../logger.js';
79
import type { IpcDispatcher, IpcInvokeHandler } from '../types.js';
810

@@ -32,16 +34,21 @@ export const playCharacterHandler = (options: {
3234
}
3335

3436
const sgeService = new SGEServiceImpl({
35-
gameCode: gameCode as SGEGameCode,
37+
gameCode: gameCode,
3638
username: account.accountName,
3739
password: account.accountPassword,
3840
});
3941

40-
// TODO if user pref is to connect via lich then
41-
// 1. launch lich.rbw
42-
// 2. login sge character per normal
43-
// 3. set credentials.host = preferences.lichHost ; credentials.port = preferences.lichPort
4442
const credentials = await sgeService.loginCharacter(characterName);
43+
44+
if (Preferences.get(PreferenceKey.LICH_ENABLED)) {
45+
const { host, port } = await startLichProcess({
46+
gameCode: gameCode as GameCode,
47+
});
48+
credentials.host = host;
49+
credentials.port = port;
50+
}
51+
4552
const gameInstance = await Game.newInstance({ credentials });
4653
const gameEvents$ = await gameInstance.connect();
4754

0 commit comments

Comments
 (0)