From b3a74e40e11beec3c6b7dedf57dcf8a8d639f6c9 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 8 Mar 2026 04:45:23 +0000 Subject: [PATCH] feat: add superlatives socket methods to client Co-Authored-By: Claude Opus 4.6 --- client/src/network/SocketClient.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/client/src/network/SocketClient.ts b/client/src/network/SocketClient.ts index 3f3c997..0f56860 100644 --- a/client/src/network/SocketClient.ts +++ b/client/src/network/SocketClient.ts @@ -1,5 +1,5 @@ import { io, Socket } from 'socket.io-client'; -import type { ServerEvents, ClientEvents, WorldState, StateUpdate, PlayerJoined, PlayerLeft, PlayerInput } from '@dflike/shared'; +import type { ServerEvents, ClientEvents, WorldState, StateUpdate, PlayerJoined, PlayerLeft, PlayerInput, SuperlativesData } from '@dflike/shared'; type TypedSocket = Socket; @@ -13,6 +13,7 @@ export class SocketClient { onStateUpdate: ((data: StateUpdate) => void) | null = null; onPlayerJoined: ((data: PlayerJoined) => void) | null = null; onPlayerLeft: ((data: PlayerLeft) => void) | null = null; + onSuperlativesUpdate: ((data: SuperlativesData) => void) | null = null; constructor(url: string) { this.socket = io(url); @@ -36,6 +37,10 @@ export class SocketClient { this.socket.on('player-left', (data) => { this.onPlayerLeft?.(data); }); + + this.socket.on('superlatives-update', (data) => { + this.onSuperlativesUpdate?.(data); + }); } get playerId(): string | null { return this._playerId; } @@ -49,6 +54,14 @@ export class SocketClient { this.socket.emit('spawn-npc', { x, y }); } + subscribeSuperlatives(): void { + this.socket.emit('superlatives-subscribe'); + } + + unsubscribeSuperlatives(): void { + this.socket.emit('superlatives-unsubscribe'); + } + disconnect(): void { this.socket.disconnect(); }