sync inventory when focus schools were unlocked

This commit is contained in:
Sainan 2025-09-08 06:09:02 +02:00
parent f2dcb50110
commit a1362aaf9b
2 changed files with 22 additions and 10 deletions

View File

@ -62,6 +62,7 @@ interface IWsMsgFromClient {
nonce: number; nonce: number;
}; };
logout?: boolean; logout?: boolean;
sync_inventory?: boolean;
} }
interface IWsMsgToClient { interface IWsMsgToClient {
@ -168,6 +169,7 @@ const wsOnConnect = (ws: WebSocket, req: http.IncomingMessage): void => {
} }
if (data.logout) { if (data.logout) {
const accountId = (ws as IWsCustomData).accountId; const accountId = (ws as IWsCustomData).accountId;
if (accountId) {
(ws as IWsCustomData).accountId = undefined; (ws as IWsCustomData).accountId = undefined;
await Account.updateOne( await Account.updateOne(
{ {
@ -179,6 +181,13 @@ const wsOnConnect = (ws: WebSocket, req: http.IncomingMessage): void => {
} }
); );
} }
}
if (data.sync_inventory) {
const accountId = (ws as IWsCustomData).accountId;
if (accountId) {
sendWsBroadcastToGame(accountId, { sync_inventory: true });
}
}
} catch (e) { } catch (e) {
logError(e as Error, `processing websocket message`); logError(e as Error, `processing websocket message`);
} }

View File

@ -2324,6 +2324,9 @@ function doUnlockAllFocusSchools() {
toast(loc("code_focusAllUnlocked")); toast(loc("code_focusAllUnlocked"));
} else { } else {
toast(loc("code_focusUnlocked").split("|COUNT|").join(Object.keys(missingFocusUpgrades).length)); toast(loc("code_focusUnlocked").split("|COUNT|").join(Object.keys(missingFocusUpgrades).length));
if (ws_is_open) {
window.ws.send(JSON.stringify({ sync_inventory: true }));
}
} }
}); });
}); });