|
@@ -6,6 +6,14 @@ import (
|
|
|
"github.com/name5566/leaf/gate"
|
|
|
)
|
|
|
|
|
|
+func RecvMatchLudo(args []interface{}) {
|
|
|
+ m := args[0].(*msg.MatchLudo)
|
|
|
+ a := args[1].(gate.Agent)
|
|
|
+ ud := a.UserData()
|
|
|
+ user_id := ud.(*msg.UserInfo).UserId
|
|
|
+ go matchRoom(m, user_id, a)
|
|
|
+}
|
|
|
+
|
|
|
//根据玩家要匹配的对局,给玩家寻找和的房间
|
|
|
|
|
|
func matchRoom(matchInfo *msg.MatchLudo, userId string, user_agent gate.Agent) {
|
|
@@ -23,6 +31,7 @@ func matchRoom(matchInfo *msg.MatchLudo, userId string, user_agent gate.Agent) {
|
|
|
if err_info != nil {
|
|
|
if isFullPlayer {
|
|
|
startGame(roomList[0])
|
|
|
+ NotifyRoomPlayerMatch(roomList[0])
|
|
|
}
|
|
|
} else {
|
|
|
sendMatchErrorMsg(user_agent, 101, "not find player")
|
|
@@ -30,6 +39,21 @@ func matchRoom(matchInfo *msg.MatchLudo, userId string, user_agent gate.Agent) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// 通知房间玩家匹配成功
|
|
|
+func NotifyRoomPlayerMatch(room_info *msg.RoomInfo) {
|
|
|
+ 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,
|
|
|
+ Success: true,
|
|
|
+ ErrMsg: nil,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
func sendMatchErrorMsg(user_agent gate.Agent, error_code int32, msg_str string) {
|
|
|
if user_agent != nil {
|
|
|
user_agent.WriteMsg(&msg.ResMatchLudo{
|