diff --git a/modules/practice/api_gymrefresh.go b/modules/practice/api_gymrefresh.go index ff07ac877..9d7291640 100644 --- a/modules/practice/api_gymrefresh.go +++ b/modules/practice/api_gymrefresh.go @@ -20,6 +20,7 @@ func (this *apiComp) GymRefresh(session comm.IUserSession, req *pb.PracticeGymRe err error room *pb.DBPracticeRoom confs []*cfg.GamePandamasMrylData + temp []*cfg.GamePandamasMrylData refreshAtns []*cfg.Gameatn atn *cfg.Gameatn ) @@ -46,11 +47,11 @@ func (this *apiComp) GymRefresh(session comm.IUserSession, req *pb.PracticeGymRe code = pb.ErrorCode_ConfigNoFound return } + temp = make([]*cfg.GamePandamasMrylData, 0) //过滤掉当前的buff - for i, v := range confs { - if v.Id == room.Gymaction { - confs = append(confs[0:i], confs[i+1:]...) - break + for _, v := range confs { + if v.Id != room.Gymaction { + temp = append(temp, v) } } if len(confs) == 0 { @@ -58,7 +59,7 @@ func (this *apiComp) GymRefresh(session comm.IUserSession, req *pb.PracticeGymRe return } r := rand.New(rand.NewSource(configure.Now().Unix())) - room.Gymaction = confs[r.Perm(len(confs))[0]].Id + room.Gymaction = temp[r.Perm(len(temp))[0]].Id room.Gymrefresh++ room.Lastrefresh = configure.Now().Unix() this.module.modelPandata.Change(session.GetUserId(), map[string]interface{}{