This commit is contained in:
2025-10-26 20:44:58 +08:00
parent e287aadd3c
commit e73c08abf7
45 changed files with 280774 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
#pragma once
#include <string>
#include <memory>
// 前向声明
class GameServer;
/**
* @brief 游戏大厅管理类
*
* 功能:
* 1. 管理大厅聊天
* 2. 处理玩家列表
* 3. 处理对战邀请
*/
class GameLobby {
private:
GameServer* m_server;
public:
/**
* @brief 构造函数
*/
explicit GameLobby(GameServer* server);
/**
* @brief 析构函数
*/
~GameLobby();
/**
* @brief 广播聊天消息
* @param sender 发送者用户名
* @param message 消息内容
* @param excludeClientId 排除的客户端ID (不发送给自己)
*/
void broadcastMessage(const std::string& sender,
const std::string& message,
int excludeClientId = -1);
/**
* @brief 处理对战邀请
* @param inviter 邀请者用户名
* @param target 被邀请者用户名
* @return bool 是否成功发送邀请
*/
bool handleInvite(const std::string& inviter, const std::string& target);
/**
* @brief 处理邀请响应
* @param inviter 邀请者用户名
* @param target 被邀请者用户名
* @param accept 是否接受
* @return bool 是否成功处理
*/
bool handleInviteResponse(const std::string& inviter,
const std::string& target,
bool accept);
};