上传捕羊大赛调试优化
This commit is contained in:
parent
29f24d7e0a
commit
28d745e3ca
@ -42,10 +42,10 @@ func (this *apiComp) InviteHandle(session comm.IUserSession, req *pb.ParkourInvi
|
||||
code = pb.ErrorCode_ParkourMemberFull
|
||||
return
|
||||
}
|
||||
if req.State == 1 {
|
||||
if req.State == 3 {
|
||||
ok = false
|
||||
for i, v := range tean.Invite {
|
||||
if v.Uid == session.GetUserId() && !configure.Now().Before(time.Unix(v.Expired, 0)) { //邀请未过期
|
||||
if v.Uid == session.GetUserId() && configure.Now().Before(time.Unix(v.Expired, 0)) { //邀请未过期
|
||||
invite = v
|
||||
index = int32(i)
|
||||
ok = true
|
||||
@ -64,6 +64,7 @@ func (this *apiComp) InviteHandle(session comm.IUserSession, req *pb.ParkourInvi
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
}
|
||||
users = append(users, invite.Uid)
|
||||
member = &pb.DBRaceMember{Uid: invite.Uid, Name: invite.Name, Avatar: invite.Avatar, Lv: invite.Lv, Mount: info.Dfmount, Hp: mount.Hp}
|
||||
tean.Captainid = tean.Uid
|
||||
tean.State = pb.RaceTeamState_teaming
|
||||
@ -93,6 +94,6 @@ func (this *apiComp) InviteHandle(session comm.IUserSession, req *pb.ParkourInvi
|
||||
&pb.ParkourInviteNoticePush{Team: tean, State: 3}, tean.Captainid)
|
||||
}
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), "invite", &pb.ParkourInviteHandleResp{IsSucc: true})
|
||||
session.SendMsg(string(this.module.GetType()), "invitehandle", &pb.ParkourInviteHandleResp{IsSucc: true})
|
||||
return
|
||||
}
|
||||
|
@ -8,6 +8,10 @@ import (
|
||||
|
||||
//参数校验
|
||||
func (this *apiComp) JoinTeamCheck(session comm.IUserSession, req *pb.ParkourJoinTeamReq) (code pb.ErrorCode) {
|
||||
if session.GetUserId() == req.Uid {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@ -36,7 +40,7 @@ func (this *apiComp) JoinTeam(session comm.IUserSession, req *pb.ParkourJoinTeam
|
||||
}
|
||||
|
||||
if len(info.Member) > 3 {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
code = pb.ErrorCode_ParkourMemberFull
|
||||
return
|
||||
}
|
||||
if tean, err = this.module.parkourComp.queryinfo(req.Uid); err != nil {
|
||||
@ -58,7 +62,7 @@ func (this *apiComp) JoinTeam(session comm.IUserSession, req *pb.ParkourJoinTeam
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
}
|
||||
member = &pb.DBRaceMember{Uid: session.GetUserId(), Name: user.Name, Avatar: user.Avatar, Lv: user.Lv, Mount: tean.Dfmount, Hp: mount.Hp}
|
||||
member = &pb.DBRaceMember{Uid: user.Uid, Name: user.Name, Avatar: user.Avatar, Lv: user.Lv, Mount: tean.Dfmount, Hp: mount.Hp}
|
||||
tean.Captainid = tean.Uid
|
||||
tean.State = pb.RaceTeamState_teaming
|
||||
tean.Member = append(tean.Member, member)
|
||||
@ -71,7 +75,7 @@ func (this *apiComp) JoinTeam(session comm.IUserSession, req *pb.ParkourJoinTeam
|
||||
return
|
||||
}
|
||||
user := this.module.ModuleUser.GetUser(session.GetUserId())
|
||||
member = &pb.DBRaceMember{Uid: session.GetUserId(), Name: user.Name, Avatar: user.Avatar, Lv: user.Lv, Mount: info.Dfmount, Hp: mount.Hp}
|
||||
member = &pb.DBRaceMember{Uid: user.Uid, Name: user.Name, Avatar: user.Avatar, Lv: user.Lv, Mount: info.Dfmount, Hp: mount.Hp}
|
||||
tean.Member = append(tean.Member, member)
|
||||
if err = this.module.parkourComp.Change(session.GetUserId(), map[string]interface{}{
|
||||
"state": tean.State,
|
||||
|
@ -3,6 +3,7 @@ package parkour
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
)
|
||||
|
||||
//参数校验
|
||||
@ -17,6 +18,8 @@ func (this *apiComp) RaceMatchCheck(session comm.IUserSession, req *pb.ParkourRa
|
||||
func (this *apiComp) RaceMatch(session comm.IUserSession, req *pb.ParkourRaceMatchReq) (code pb.ErrorCode, data *pb.ErrorData) {
|
||||
var (
|
||||
team *pb.DBParkour
|
||||
tuser *pb.DBUser
|
||||
mount *cfg.GameBuzkashiMountData
|
||||
users []string
|
||||
err error
|
||||
)
|
||||
@ -27,10 +30,31 @@ func (this *apiComp) RaceMatch(session comm.IUserSession, req *pb.ParkourRaceMat
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
if team.Captainid != session.GetUserId() {
|
||||
if team.Captainid != "" && team.Captainid != session.GetUserId() {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
return
|
||||
}
|
||||
if team.Captainid == "" { //为组队情况
|
||||
team.Captainid = team.Uid
|
||||
team.State = pb.RaceTeamState_teaming
|
||||
if tuser = this.module.ModuleUser.GetUser(session.GetUserId()); tuser == nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
if mount, err = this.module.configure.getGameBuzkashiMount(team.Dfmount); err != nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
}
|
||||
team.Member = append(team.Member, &pb.DBRaceMember{Uid: tuser.Uid, Name: tuser.Name, Avatar: tuser.Avatar, Lv: tuser.Lv, Mount: team.Dfmount, Hp: mount.Hp})
|
||||
if err = this.module.parkourComp.Change(team.Captainid, map[string]interface{}{
|
||||
"state": team.State,
|
||||
"captainid": team.Captainid,
|
||||
"member": team.Member,
|
||||
}); err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if err = this.module.match(team); err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
|
@ -18,7 +18,9 @@ func (this *apiComp) ViewPlayer(session comm.IUserSession, req *pb.ParkourViewPl
|
||||
if code = this.ViewPlayerCheck(session, req); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
|
||||
resp = &pb.ParkourViewPlayerResp{
|
||||
Player: make([]*pb.ParkourData, 0),
|
||||
}
|
||||
for _, uid := range req.Uid {
|
||||
if u := this.module.ModuleUser.GetUser(uid); u != nil {
|
||||
{
|
||||
|
@ -148,11 +148,12 @@ func (this *Parkour) createbattle(ctx context.Context, req *pb.RPCParkourMatchSu
|
||||
v.Ready = true
|
||||
}
|
||||
}
|
||||
battle.BuleMember = req.Bule
|
||||
|
||||
for _, v := range battle.Session {
|
||||
sessions = append(sessions, v)
|
||||
}
|
||||
|
||||
battle.BuleMember = req.Bule
|
||||
if err = this.raceComp.addrace(race); err != nil {
|
||||
return
|
||||
}
|
||||
@ -406,17 +407,6 @@ func (this *Parkour) useroffline(uid, sessionid string) {
|
||||
}
|
||||
if info.State == pb.RaceTeamState_teaming {
|
||||
if info.Captainid == uid {
|
||||
info.Invite = info.Invite[:0]
|
||||
info.Member = info.Member[:0]
|
||||
if err = this.parkourComp.Change(uid, map[string]interface{}{
|
||||
"captainid": "",
|
||||
"state": 0,
|
||||
"Invite": info.Invite,
|
||||
"member": info.Member,
|
||||
}); err != nil {
|
||||
this.Error("用户离线! 处理数据", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err.Error()})
|
||||
return
|
||||
}
|
||||
users = make([]string, 0)
|
||||
for _, v := range info.Member {
|
||||
if v.Uid != uid && !v.Isai {
|
||||
@ -430,6 +420,17 @@ func (this *Parkour) useroffline(uid, sessionid string) {
|
||||
}
|
||||
}
|
||||
}
|
||||
info.Invite = info.Invite[:0]
|
||||
info.Member = info.Member[:0]
|
||||
if err = this.parkourComp.Change(uid, map[string]interface{}{
|
||||
"captainid": "",
|
||||
"state": 0,
|
||||
"Invite": info.Invite,
|
||||
"member": info.Member,
|
||||
}); err != nil {
|
||||
this.Error("用户离线! 处理数据", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err.Error()})
|
||||
return
|
||||
}
|
||||
if len(users) > 0 {
|
||||
if err = this.SendMsgToUsers(string(comm.ModulePvp), "teamdisbandnotice", &pb.ParkourTeamDisbandNoticePush{}, users...); err != nil {
|
||||
this.Errorln(err)
|
||||
|
@ -197,6 +197,7 @@ func (this *ParkourComp) cancel(ctx context.Context, req *pb.RPCParkourCancelMat
|
||||
|
||||
//定时匹配处理
|
||||
func (this *ParkourComp) timer() {
|
||||
this.module.Errorf("捕羊大赛 定时匹配,%d", this.total)
|
||||
if this.total == 0 {
|
||||
return
|
||||
}
|
||||
@ -338,7 +339,7 @@ func (this *ParkourComp) timer() {
|
||||
reduser = append(reduser, this.teams[v]...)
|
||||
}
|
||||
for _, v := range bule {
|
||||
buleuser = append(reduser, this.teams[v]...)
|
||||
buleuser = append(buleuser, this.teams[v]...)
|
||||
}
|
||||
|
||||
if len(users)+rednum+bulenum < 6 {
|
||||
@ -357,6 +358,7 @@ func (this *ParkourComp) timer() {
|
||||
} else {
|
||||
v.Name = user.Name
|
||||
v.Avatar = user.Avatar
|
||||
v.Lv = user.Lv
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -372,6 +374,7 @@ func (this *ParkourComp) timer() {
|
||||
} else {
|
||||
v.Name = user.Name
|
||||
v.Avatar = user.Avatar
|
||||
v.Lv = user.Lv
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user