|
@@ -0,0 +1,154 @@
|
|
|
+package vip.metadev.module.battle.protobuf;
|
|
|
+
|
|
|
+option java_outer_classname = "WsProtocol";
|
|
|
+option java_multiple_files = false;
|
|
|
+
|
|
|
+// WebSocket 消息信封
|
|
|
+message WsEnvelope {
|
|
|
+ required string type = 1; // 消息类型
|
|
|
+ required string message_id = 2; // 消息ID(用于请求响应匹配)
|
|
|
+ required string session_id = 3; // 会话ID
|
|
|
+ optional string player_id = 4; // 玩家ID
|
|
|
+ optional string scene_id = 5; // 场景ID
|
|
|
+ required bytes payload = 6; // 消息负载(二进制数据)
|
|
|
+ optional string client_version = 7; // 客户端版本
|
|
|
+ optional string device_info = 8; // 设备信息
|
|
|
+}
|
|
|
+
|
|
|
+// WebSocket 错误消息
|
|
|
+message WsError {
|
|
|
+ required string error_code = 1; // 错误代码
|
|
|
+ required string error_message = 2; // 错误消息
|
|
|
+}
|
|
|
+
|
|
|
+// WebSocket 心跳消息
|
|
|
+message WsHeartbeat {
|
|
|
+ required string heartbeat_id = 1; // 心跳ID
|
|
|
+ required int64 client_timestamp = 2; // 客户端时间戳
|
|
|
+ optional int64 server_timestamp = 3; // 服务器时间戳
|
|
|
+}
|
|
|
+
|
|
|
+// WebSocket 连接确认消息
|
|
|
+message WsConnectionAck {
|
|
|
+ required string status = 1; // 连接状态:success/error
|
|
|
+ required string message = 2; // 连接消息
|
|
|
+ required int64 server_timestamp = 3; // 服务器时间戳
|
|
|
+}
|
|
|
+
|
|
|
+// WebSocket 认证消息
|
|
|
+message WsAuthentication {
|
|
|
+ required string token = 1; // 认证令牌
|
|
|
+ required string player_id = 2; // 玩家ID
|
|
|
+ required int64 auth_timestamp = 3; // 认证时间戳
|
|
|
+}
|
|
|
+
|
|
|
+// WebSocket 认证响应
|
|
|
+message WsAuthenticationResponse {
|
|
|
+ required string result = 1; // 认证结果:success/error
|
|
|
+ required string message = 2; // 认证消息
|
|
|
+ optional PlayerInfo player_info = 3; // 玩家信息
|
|
|
+ required int64 auth_timestamp = 4; // 认证时间戳
|
|
|
+}
|
|
|
+
|
|
|
+// 玩家信息
|
|
|
+message PlayerInfo {
|
|
|
+ required string player_id = 1; // 玩家ID
|
|
|
+ required string nickname = 2; // 玩家昵称
|
|
|
+ required int32 level = 3; // 玩家等级
|
|
|
+ required int64 experience = 4; // 玩家经验
|
|
|
+ required int32 vip_level = 5; // VIP等级
|
|
|
+ required int64 gold = 6; // 金币数量
|
|
|
+ required int64 diamond = 7; // 钻石数量
|
|
|
+ optional string avatar_url = 8; // 头像URL
|
|
|
+ required bool online = 9; // 在线状态
|
|
|
+ required int64 last_login_time = 10; // 最后登录时间
|
|
|
+}
|
|
|
+
|
|
|
+// WebSocket 游戏状态更新
|
|
|
+message WsGameStateUpdate {
|
|
|
+ required string game_id = 1; // 游戏ID
|
|
|
+ required string game_state = 2; // 游戏状态:waiting/playing/paused/ended
|
|
|
+ required string game_mode = 3; // 游戏模式
|
|
|
+ required int32 current_round = 4; // 当前回合
|
|
|
+ required int32 total_rounds = 5; // 总回合数
|
|
|
+ required int32 game_time = 6; // 游戏时间(秒)
|
|
|
+}
|
|
|
+
|
|
|
+// WebSocket 战斗动作消息
|
|
|
+message WsBattleAction {
|
|
|
+ required string action_type = 1; // 动作类型:attack/defend/skill/item
|
|
|
+ required string action_id = 2; // 动作ID
|
|
|
+ optional string target_id = 3; // 目标ID
|
|
|
+ required int64 action_timestamp = 4; // 动作时间戳
|
|
|
+}
|
|
|
+
|
|
|
+// WebSocket 战斗结果消息
|
|
|
+message WsBattleResult {
|
|
|
+ required string battle_id = 1; // 战斗ID
|
|
|
+ required string result = 2; // 战斗结果:victory/defeat/draw
|
|
|
+ optional string winner_id = 3; // 胜利方ID
|
|
|
+ repeated BattleReward rewards = 4; // 战斗奖励
|
|
|
+ optional BattleStats battle_stats = 5; // 战斗统计
|
|
|
+ required int64 battle_timestamp = 6; // 战斗时间戳
|
|
|
+}
|
|
|
+
|
|
|
+// 战斗奖励
|
|
|
+message BattleReward {
|
|
|
+ required string reward_type = 1; // 奖励类型:gold/experience/item
|
|
|
+ required string reward_id = 2; // 奖励ID
|
|
|
+ required int64 reward_amount = 3; // 奖励数量
|
|
|
+ optional string reward_description = 4; // 奖励描述
|
|
|
+}
|
|
|
+
|
|
|
+// 战斗统计
|
|
|
+message BattleStats {
|
|
|
+ required int64 total_damage = 1; // 总伤害
|
|
|
+ required int64 damage_taken = 2; // 承受伤害
|
|
|
+ required int32 skills_used = 3; // 技能使用次数
|
|
|
+ required int32 items_used = 4; // 物品使用次数
|
|
|
+ required int32 battle_duration = 5; // 战斗时长(秒)
|
|
|
+}
|
|
|
+
|
|
|
+// WebSocket 物品使用消息
|
|
|
+message WsItemUse {
|
|
|
+ required string item_id = 1; // 物品ID
|
|
|
+ required string item_type = 2; // 物品类型
|
|
|
+ required int32 use_amount = 3; // 使用数量
|
|
|
+ optional string target_id = 4; // 目标ID
|
|
|
+ required int64 use_timestamp = 5; // 使用时间戳
|
|
|
+}
|
|
|
+
|
|
|
+// WebSocket 技能使用消息
|
|
|
+message WsSkillUse {
|
|
|
+ required string skill_id = 1; // 技能ID
|
|
|
+ required string skill_name = 2; // 技能名称
|
|
|
+ required int32 skill_level = 3; // 技能等级
|
|
|
+ optional string target_id = 4; // 目标ID
|
|
|
+ required int64 use_timestamp = 5; // 使用时间戳
|
|
|
+}
|
|
|
+
|
|
|
+// WebSocket 系统通知消息
|
|
|
+message WsSystemNotification {
|
|
|
+ required string notification_type = 1; // 通知类型:info/warning/error/success
|
|
|
+ required string title = 2; // 通知标题
|
|
|
+ required string content = 3; // 通知内容
|
|
|
+ required string priority = 4; // 通知级别:low/medium/high/critical
|
|
|
+ required int64 notification_timestamp = 5; // 通知时间戳
|
|
|
+}
|
|
|
+
|
|
|
+// WebSocket 玩家状态更新
|
|
|
+message WsPlayerStateUpdate {
|
|
|
+ required string player_id = 1; // 玩家ID
|
|
|
+ required string state_type = 2; // 状态类型:online/offline/away/busy
|
|
|
+ optional string state_description = 3; // 状态描述
|
|
|
+ required int64 state_timestamp = 4; // 状态时间戳
|
|
|
+}
|
|
|
+
|
|
|
+// WebSocket 场景切换消息
|
|
|
+message WsSceneChange {
|
|
|
+ required string scene_id = 1; // 场景ID
|
|
|
+ required string scene_name = 2; // 场景名称
|
|
|
+ required string scene_type = 3; // 场景类型
|
|
|
+ optional string change_reason = 4; // 切换原因
|
|
|
+ required int64 change_timestamp = 5; // 切换时间戳
|
|
|
+}
|