From 35367e18fc88bd0eabeba9ceaf723bdf8df09d81 Mon Sep 17 00:00:00 2001 From: liwei <2211068034@qq.com> Date: Tue, 4 Jul 2023 14:39:14 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=AD=A6=E9=A6=86?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/practice/module.go | 73 +++++--------------------------------- 1 file changed, 9 insertions(+), 64 deletions(-) diff --git a/modules/practice/module.go b/modules/practice/module.go index 60ce1f0d6..0900be082 100644 --- a/modules/practice/module.go +++ b/modules/practice/module.go @@ -129,7 +129,10 @@ func (this *Practice) AddItems(session comm.IUserSession, items map[string]int32 "knapsack": room.Knapsack, }) } else { - room := &pb.DBPracticeRoom{} + room := &pb.DBPracticeRoom{ + Full: make(map[int32]int32), + Knapsack: make(map[string]*pb.DBPracticeRes), + } conn, err := db.Cross() if err != nil { this.Errorln(err) @@ -166,15 +169,10 @@ func (this *Practice) AddItems(session comm.IUserSession, items map[string]int32 id = append(id, k) this.atlas.CheckActivatePandaAtlasCollect(session.GetUserId(), k) } - // if err = this.modelPandata.refreshnpc(room); err != nil { - // this.Errorln(err) - // return - // } if err = model.Add(session.GetUserId(), room); err != nil { this.Errorln(err) return } - //this.atlas.CheckActivatePandaAtlasCollect(session.GetUserId(), "100001") } else { id = make([]string, 0) for k, _ := range items { @@ -187,11 +185,11 @@ func (this *Practice) AddItems(session comm.IUserSession, items map[string]int32 id = append(id, k) this.atlas.CheckActivatePandaAtlasCollect(session.GetUserId(), k) } - + model.Change(session.GetUserId(), map[string]interface{}{ + "knapsack": room.Knapsack, + }) } - model.Change(session.GetUserId(), map[string]interface{}{ - "knapsack": room.Knapsack, - }) + } session.SendMsg(string(this.GetType()), "jxitem", &pb.PracticeJXItemPush{Id: id}) return @@ -203,17 +201,6 @@ func (this *Practice) TaskComplete(session comm.IUserSession, taskid int32) { log.Field{Key: "session", Value: session.GetUserId()}, log.Field{Key: "taskid", Value: taskid}, ) - // if !this.IsCross() { - // err := this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(), - // comm.Service_Worker, string(comm.RPC_ModulePracticeUnLockPillar), - // &pb.RPCGeneralReqA2{Param1: session.GetUserId(), Param2: fmt.Sprintf("%d", taskid)}, &pb.EmptyResp{}) - // if err != nil { - // this.Errorln(err) - // return - // } - // } else { - // this.RPC_ModulePracticeUnLockPillar(context.Background(), &pb.RPCGeneralReqA2{Param1: session.GetUserId(), Param2: fmt.Sprintf("%d", taskid)}, &pb.EmptyResp{}) - // } } func (this *Practice) OpenCmdNotice(session comm.IUserSession, keys ...string) { @@ -354,18 +341,9 @@ func (this *Practice) RPC_ModulePracticeUnLockPillar(ctx context.Context, args * log.Field{Key: "key", Value: args.Param2}, ) var ( - // configure []*cfg.GamePandamasJsData room *pb.DBPracticeRoom - // taskid int64 ) - // if taskid, err = strconv.ParseInt(args.Param2, 10, 64); err != nil { - // this.Errorln(err) - // return - // } - // if configure, err = this.configure.getGamePandamasJs(); err != nil { - // this.Errorln(err) - // return - // } + if room, err = this.modelPandata.queryUserMartialhall(args.Param1); err != nil { this.Errorln(err) return @@ -406,39 +384,6 @@ func (this *Practice) RPC_ModulePracticeUnLockPillar(ctx context.Context, args * break } go this.ModuleBuried.TriggerBuried(args.Param1, comm.GetBuriedParam(comm.Rtype152, 1)) - // for _, v := range configure { - // if v.UnlockCondition == int32(taskid) { - // switch v.Id { - // case 1: - // if room.Pillar1.Isunlock == 0 { - // room.Pillar1.Isunlock = 1 - // } - // this.modelPandata.Change(args.Param1, map[string]interface{}{ - // "pillar1": room.Pillar1, - // }) - // this.atlas.CheckActivatePandaAtlasCollect(args.Param1, "1001") - // break - // case 2: - // if room.Pillar2.Isunlock == 0 { - // room.Pillar2.Isunlock = 1 - // } - // this.modelPandata.Change(args.Param1, map[string]interface{}{ - // "pillar2": room.Pillar2, - // }) - // this.atlas.CheckActivatePandaAtlasCollect(args.Param1, "1001") - // break - // case 3: - // if room.Pillar3.Isunlock == 0 { - // room.Pillar3.Isunlock = 1 - // } - // this.modelPandata.Change(args.Param1, map[string]interface{}{ - // "pillar3": room.Pillar3, - // }) - // this.atlas.CheckActivatePandaAtlasCollect(args.Param1, "1001") - // break - // } - // } - // } return } From acd896bb2485f822fe722a6e123187f6fc44d8f0 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Tue, 4 Jul 2023 15:45:46 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=82=AC=E8=B5=8F=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=8A=A0=E6=9D=83=E9=87=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/dispatch/model_dispatch.go | 15 +++++++++------ sys/configure/structs/Game.Dispatch_TaskData.go | 2 ++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/modules/dispatch/model_dispatch.go b/modules/dispatch/model_dispatch.go index 08b664a14..bd3185ef7 100644 --- a/modules/dispatch/model_dispatch.go +++ b/modules/dispatch/model_dispatch.go @@ -7,7 +7,6 @@ import ( "go_dreamfactory/modules" "go_dreamfactory/pb" "go_dreamfactory/sys/configure" - "go_dreamfactory/utils" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/x/bsonx" @@ -63,7 +62,9 @@ func (this *modelDispatch) getTasksWeight(dispatch *pb.DBDispatch) int32 { confList, err := this.module.configure.getDispatchTaskConfByType(int32(i + 1)) var tIds []int32 + var weights []int32 for _, v := range confList { + weights = append(weights, v.Weight) if v.Completecount == 0 { tIds = append(tIds, v.Id) } else if v.Completecount > 0 { @@ -76,11 +77,13 @@ func (this *modelDispatch) getTasksWeight(dispatch *pb.DBDispatch) int32 { } } } - idex := utils.RandomNumbers(0, len(tIds), 1) - if len(idex) == 0 { - return 0 - } - return tIds[idex[0]] + + idex := comm.GetRandW(weights) + // idex := utils.RandomNumbers(0, len(tIds), 1) + // if len(idex) == 0 { + // return 0 + // } + return tIds[idex] } // 随机任务 diff --git a/sys/configure/structs/Game.Dispatch_TaskData.go b/sys/configure/structs/Game.Dispatch_TaskData.go index c82fee976..cbb7812ff 100644 --- a/sys/configure/structs/Game.Dispatch_TaskData.go +++ b/sys/configure/structs/Game.Dispatch_TaskData.go @@ -13,6 +13,7 @@ import "errors" type GameDispatch_TaskData struct { Id int32 Type int32 + Weight int32 Taskname string Icon string Taskcd int32 @@ -37,6 +38,7 @@ func (*GameDispatch_TaskData) GetTypeId() int32 { func (_v *GameDispatch_TaskData)Deserialize(_buf map[string]interface{}) (err error) { { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["id"].(float64); !_ok_ { err = errors.New("id error"); return }; _v.Id = int32(_tempNum_) } { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["type"].(float64); !_ok_ { err = errors.New("type error"); return }; _v.Type = int32(_tempNum_) } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["weight"].(float64); !_ok_ { err = errors.New("weight error"); return }; _v.Weight = int32(_tempNum_) } {var _ok_ bool; var __json_text__ map[string]interface{}; if __json_text__, _ok_ = _buf["taskname"].(map[string]interface{}) ; !_ok_ { err = errors.New("_v.Taskname error"); return }; { var _ok_ bool; if _, _ok_ = __json_text__["key"].(string); !_ok_ { err = errors.New("key error"); return } }; { var _ok_ bool; if _v.Taskname, _ok_ = __json_text__["text"].(string); !_ok_ { err = errors.New("text error"); return } } } { var _ok_ bool; if _v.Icon, _ok_ = _buf["icon"].(string); !_ok_ { err = errors.New("icon error"); return } } { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["taskcd"].(float64); !_ok_ { err = errors.New("taskcd error"); return }; _v.Taskcd = int32(_tempNum_) }