From 2d0f2d09742de2f141e6a5e4c76890fe77105e75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=94=E6=B0=91=E5=B0=8F=E9=95=87?= <262610965@qq.com> Date: Sat, 18 May 2024 16:05:34 +0800 Subject: [PATCH] :whale: --- .../com/iohao/game/widget/light/room/RoomService.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/widget/light-game-room/src/main/java/com/iohao/game/widget/light/room/RoomService.java b/widget/light-game-room/src/main/java/com/iohao/game/widget/light/room/RoomService.java index 340e76fd4..d24658b4e 100644 --- a/widget/light-game-room/src/main/java/com/iohao/game/widget/light/room/RoomService.java +++ b/widget/light-game-room/src/main/java/com/iohao/game/widget/light/room/RoomService.java @@ -169,6 +169,16 @@ default void removePlayer(Room room, Player player) { this.getUserRoomMap().remove(player.getUserId()); } + /** + * 将玩家从房间内内移除 并删除 userId 与 roomId 的关联 + * + * @param room 房间 + * @param userId userId + */ + default void removePlayer(Room room, long userId) { + room.ifPlayerExist(userId, player -> this.removePlayer(room, player)); + } + /** * 得到房间列表 *