xy 1 周之前
父節點
當前提交
6165c07e30
共有 1 個文件被更改,包括 19 次插入16 次删除
  1. 19 16
      src/server/game/ludo/room.go

+ 19 - 16
src/server/game/ludo/room.go

@@ -128,24 +128,15 @@ func JoinRoom(room *msg.RoomInfo, matchInfo *msg.MatchLudo, userId string) (bool
 	if err_info != nil {
 		return false, errors.New("not find user at JoinRoom time ")
 	}
-	user_agent := getAgentByUserId(userId)
-	if user_agent == nil {
-		return false, errors.New("not find user ")
-	}
-
-	room.Colors = append(room.Colors, &msg.ColorData{
-		MId:        userId,
-		MColor:     matchInfo.SelectColor, //所属阵营
-		IsKick:     false,                 //是否被踢
-		IsFinish:   false,                 //是否完成了比赛
-		TimeOutNum: 0,                     //超时次数
-		MName:      userInfo.Name,         //玩家名字
-		MHead:      userInfo.MHead,        //头像
-		RankNum:    0,                     //本局游戏的名次
-		MCoin:      userInfo.MCoin,        //玩家拥有的金币
-	})
 
 	if !isRobot {
+
+		user_agent := getAgentByUserId(userId)
+
+		if user_agent == nil {
+			return false, errors.New("not find user ")
+		}
+
 		ud := &msg.UserInfo{
 			UserId: userInfo.UserId,
 			Name:   userInfo.Name,
@@ -159,6 +150,18 @@ func JoinRoom(room *msg.RoomInfo, matchInfo *msg.MatchLudo, userId string) (bool
 		user_agent.SetUserData(ud)
 	}
 
+	room.Colors = append(room.Colors, &msg.ColorData{
+		MId:        userId,
+		MColor:     matchInfo.SelectColor, //所属阵营
+		IsKick:     false,                 //是否被踢
+		IsFinish:   false,                 //是否完成了比赛
+		TimeOutNum: 0,                     //超时次数
+		MName:      userInfo.Name,         //玩家名字
+		MHead:      userInfo.MHead,        //头像
+		RankNum:    0,                     //本局游戏的名次
+		MCoin:      userInfo.MCoin,        //玩家拥有的金币
+	})
+
 	isFullPlayer := false
 
 	if room.RoomType == msg.RoomType_SHUANG_REN { //说明是两人的房间