package catchbugs import ( "go_dreamfactory/comm" "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" ) //接受切磋 func (this *apiComp) SingleGameCheck(session comm.IUserSession, req *pb.CatchbugsSingleGameReq) (errdata *pb.ErrorData) { return } func (this *apiComp) SingleGame(session comm.IUserSession, req *pb.CatchbugsSingleGameReq) (errdata *pb.ErrorData) { var ( err error user *pb.DBUser info *pb.DBCatchBugs robots []*cfg.GameRobotData redplayer, blueplayer *pb.DBCatchBugsPlayer ) if errdata = this.SingleGameCheck(session, req); errdata != nil { return } if robots, err = this.module.ModuleTools.RandRobotConfig(1); err != nil { return } //发起者 red user, err = this.module.GetUserForSession(session) if err != nil { this.module.Error("未找到红方信息", log.Field{Key: "uid", Value: session.GetUserId()}) return } if info, err = this.module.model.getModel(session.GetUserId()); err != nil { this.module.Error("未找到红方信息", log.Field{Key: "uid", Value: session.GetUserId()}) return } redplayer = &pb.DBCatchBugsPlayer{ Info: comm.GetUserBaseInfo(user), Integral: info.Integral, } blueplayer = &pb.DBCatchBugsPlayer{ Info: comm.GetRobotBaseInfo(robots[0]), Integral: 0, Isai: true, Ready: true, } if _, err = this.module.createRoom(req.Rules, redplayer, blueplayer, []comm.IUserSession{session.Clone()}); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_SystemError, Message: err.Error(), } return } session.SendMsg(string(this.module.GetType()), "singlegame", &pb.CatchbugsSingleGameResp{}) return }