This commit is contained in:
meixiongfeng 2023-07-04 16:06:39 +08:00
commit b26c0b5f20
2 changed files with 18 additions and 70 deletions

View File

@ -7,7 +7,6 @@ import (
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/configure" "go_dreamfactory/sys/configure"
"go_dreamfactory/utils"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/x/bsonx" "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)) confList, err := this.module.configure.getDispatchTaskConfByType(int32(i + 1))
var tIds []int32 var tIds []int32
var weights []int32
for _, v := range confList { for _, v := range confList {
weights = append(weights, v.Weight)
if v.Completecount == 0 { if v.Completecount == 0 {
tIds = append(tIds, v.Id) tIds = append(tIds, v.Id)
} else if v.Completecount > 0 { } 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 { idex := comm.GetRandW(weights)
return 0 // idex := utils.RandomNumbers(0, len(tIds), 1)
} // if len(idex) == 0 {
return tIds[idex[0]] // return 0
// }
return tIds[idex]
} }
// 随机任务 // 随机任务

View File

@ -129,7 +129,10 @@ func (this *Practice) AddItems(session comm.IUserSession, items map[string]int32
"knapsack": room.Knapsack, "knapsack": room.Knapsack,
}) })
} else { } else {
room := &pb.DBPracticeRoom{} room := &pb.DBPracticeRoom{
Full: make(map[int32]int32),
Knapsack: make(map[string]*pb.DBPracticeRes),
}
conn, err := db.Cross() conn, err := db.Cross()
if err != nil { if err != nil {
this.Errorln(err) this.Errorln(err)
@ -166,15 +169,10 @@ func (this *Practice) AddItems(session comm.IUserSession, items map[string]int32
id = append(id, k) id = append(id, k)
this.atlas.CheckActivatePandaAtlasCollect(session.GetUserId(), 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 { if err = model.Add(session.GetUserId(), room); err != nil {
this.Errorln(err) this.Errorln(err)
return return
} }
//this.atlas.CheckActivatePandaAtlasCollect(session.GetUserId(), "100001")
} else { } else {
id = make([]string, 0) id = make([]string, 0)
for k, _ := range items { for k, _ := range items {
@ -187,11 +185,11 @@ func (this *Practice) AddItems(session comm.IUserSession, items map[string]int32
id = append(id, k) id = append(id, k)
this.atlas.CheckActivatePandaAtlasCollect(session.GetUserId(), 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}) session.SendMsg(string(this.GetType()), "jxitem", &pb.PracticeJXItemPush{Id: id})
return return
@ -203,17 +201,6 @@ func (this *Practice) TaskComplete(session comm.IUserSession, taskid int32) {
log.Field{Key: "session", Value: session.GetUserId()}, log.Field{Key: "session", Value: session.GetUserId()},
log.Field{Key: "taskid", Value: taskid}, 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) { 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}, log.Field{Key: "key", Value: args.Param2},
) )
var ( var (
// configure []*cfg.GamePandamasJsData
room *pb.DBPracticeRoom 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 { if room, err = this.modelPandata.queryUserMartialhall(args.Param1); err != nil {
this.Errorln(err) this.Errorln(err)
return return
@ -406,39 +384,6 @@ func (this *Practice) RPC_ModulePracticeUnLockPillar(ctx context.Context, args *
break break
} }
go this.ModuleBuried.TriggerBuried(args.Param1, comm.GetBuriedParam(comm.Rtype152, 1)) 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 return
} }