|
1 | 1 | import type { GameCode } from '../../../common/game/types.js';
|
2 | 2 | import type { AccountService } from '../../account/types.js';
|
3 | 3 | 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'; |
4 | 7 | import { SGEServiceImpl } from '../../sge/sge.service.js';
|
5 |
| -import type { SGEGameCode } from '../../sge/types.js'; |
6 | 8 | import { logger } from '../logger.js';
|
7 | 9 | import type { IpcDispatcher, IpcInvokeHandler } from '../types.js';
|
8 | 10 |
|
@@ -32,16 +34,21 @@ export const playCharacterHandler = (options: {
|
32 | 34 | }
|
33 | 35 |
|
34 | 36 | const sgeService = new SGEServiceImpl({
|
35 |
| - gameCode: gameCode as SGEGameCode, |
| 37 | + gameCode: gameCode, |
36 | 38 | username: account.accountName,
|
37 | 39 | password: account.accountPassword,
|
38 | 40 | });
|
39 | 41 |
|
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 |
44 | 42 | 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 | + |
45 | 52 | const gameInstance = await Game.newInstance({ credentials });
|
46 | 53 | const gameEvents$ = await gameInstance.connect();
|
47 | 54 |
|
|
0 commit comments