xy 1 týždeň pred
rodič
commit
695205b042

+ 4 - 2
src/server/game/ludo/ludo.go

@@ -90,14 +90,16 @@ func InitGame() {
 	go handleEvents()
 }
 
-func startGame(room_info *msg.RoomInfo) {
+func startGame(room_info *msg.RoomInfo) *RoomInfoWrapper {
 	room_info.RoomStatus = msg.RoomStatus_START //状态设置为开始游戏状态
 	//给每个玩家分配阵营初始化角色
 	initRoles(room_info)
 	//设置第一个操作的阵营
 	setFirstColor(room_info)
 	// player_count := getPlayerCount(room_info)
-	runBattle(&RoomInfoWrapper{room_info})
+	room := &RoomInfoWrapper{room_info}
+	runBattle(room)
+	return room
 }
 
 func getAgentByUserId(userId string) gate.Agent {

+ 3 - 4
src/server/game/ludo/match.go

@@ -39,8 +39,7 @@ func matchRoom(matchInfo *msg.MatchLudo, userId string, user_agent gate.Agent) {
 		if err_info == nil {
 			if isFullPlayer {
 				fmt.Printf("匹配成功开始游戏!")
-				startGame(roomList[0])
-				NotifyRoomPlayerMatch(roomList[0])
+				NotifyRoomPlayerMatch(startGame(roomList[0]))
 			}
 		} else {
 			sendMatchErrorMsg(user_agent, 101, "not find player")
@@ -49,13 +48,13 @@ func matchRoom(matchInfo *msg.MatchLudo, userId string, user_agent gate.Agent) {
 }
 
 // 通知房间玩家匹配成功
-func NotifyRoomPlayerMatch(room_info *msg.RoomInfo) {
+func NotifyRoomPlayerMatch(room_info *RoomInfoWrapper) {
 	for i := range room_info.Colors {
 		user_id := room_info.Colors[i].MId
 		user_agent := getAgentByUserId(user_id)
 		if user_agent != nil {
 			user_agent.WriteMsg(&msg.ResMatchLudo{
-				Room:    room_info,
+				Room:    room_info.RoomInfo,
 				Success: true,
 				ErrMsg:  nil,
 			})