From ebf65a0c2aeb1f5cd014c99bcf2c9ef1441b7ac8 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Fri, 11 Nov 2022 17:35:52 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=95=B4=E7=90=86=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/pagoda/api_ranklist.go | 2 +- modules/pagoda/comp_configure.go | 9 +++---- modules/pagoda/model_rank.go | 46 ++++++++++++++++++++------------ modules/pagoda/module.go | 13 +++++---- modules/timer/module.go | 4 +-- modules/timer/pagodarank.go | 8 ++---- modules/timer/season.go | 26 ++++++++++++++++++ 7 files changed, 71 insertions(+), 37 deletions(-) diff --git a/modules/pagoda/api_ranklist.go b/modules/pagoda/api_ranklist.go index 3f6eb0b3b..4832ce907 100644 --- a/modules/pagoda/api_ranklist.go +++ b/modules/pagoda/api_ranklist.go @@ -35,7 +35,7 @@ func (this *apiComp) RankList(session comm.IUserSession, req *pb.PagodaRankListR pipe *pipe.RedisPipe = conn.Redis.RedisPipe(context.TODO()) ) if req.FloorId == 0 { - rd = pipe.ZRange("pagodaSeasonRank"+strconv.Itoa(int(req.FloorId)), 0, 50) + rd = pipe.ZRange("pagodaSeasonRank", 0, 50) } else { rd = pipe.ZRange("pagodaList"+strconv.Itoa(int(req.FloorId)), 0, 50) } diff --git a/modules/pagoda/comp_configure.go b/modules/pagoda/comp_configure.go index 91a426b12..287d43410 100644 --- a/modules/pagoda/comp_configure.go +++ b/modules/pagoda/comp_configure.go @@ -169,18 +169,15 @@ func (this *configureComp) GetPassCheckByID(id int32) *cfg.GamePassCheckData { } // 获取 -func (this *configureComp) GetPagodaSeasonReward() [][]int32 { - rank := make([][]int32, 0) +func (this *configureComp) GetPagodaSeasonReward() []*cfg.GamePagodaSeasonRewardData { + if v, err := this.GetConfigure(game_pagodaseasonreward); err == nil { var ( configure *cfg.GamePagodaSeasonReward ok bool ) if configure, ok = v.(*cfg.GamePagodaSeasonReward); ok { - for _, v := range configure.GetDataList() { - rank = append(rank, v.Ranking) - } - return rank + return configure.GetDataList() } } return nil diff --git a/modules/pagoda/model_rank.go b/modules/pagoda/model_rank.go index 676a46d80..b91d952a3 100644 --- a/modules/pagoda/model_rank.go +++ b/modules/pagoda/model_rank.go @@ -248,14 +248,19 @@ func (this *ModelRank) seasonSettlement() { if list == nil { return } + + rankReward := this.modulePagoda.configure.GetPagodaSeasonReward() + if rankReward == nil { + return + } if !db.IsCross() { if conn, err := db.Cross(); err == nil { var ( - pipe *pipe.RedisPipe = conn.Redis.RedisPipe(context.TODO()) - //Items []*pb.UserAssets + pipe *pipe.RedisPipe = conn.Redis.RedisPipe(context.TODO()) + Items []*pb.UserAssets ) - rd := pipe.ZRange("pagodaSeasonRank0", 0, 50) + rd := pipe.ZRange("pagodaSeasonRank", 0, 50) if _, err = pipe.Exec(); err != nil { this.modulePagoda.Errorln(err) @@ -263,20 +268,27 @@ func (this *ModelRank) seasonSettlement() { } uids := rd.Val() - if len(uids) > 0 { - //Items = make([]*pb.UserAssets, 0) //TO 排名配置 - // for i, v := range v.RankReward { - // Items[i] = &pb.UserAssets{ - // A: v.A, - // T: v.T, - // N: v.N, - // } - // } - //发邮件 - // this.modulePagoda.mail.SendNewMail(&pb.DBMailData{ - // CreateTime: uint64(configure.Now().Unix()), - // Items: Items, - // }, uids...) + for index, uid := range uids { + Items = make([]*pb.UserAssets, 0) //TO 排名配置 + for _, v := range rankReward { + if len(v.Ranking) != 2 { + continue + } + if index >= int(v.Ranking[0]) && index <= int(v.Ranking[1]) { + for _, v1 := range v.Reward { + Items = append(Items, &pb.UserAssets{ + A: v1.A, + T: v1.T, + N: v1.N, + }) + } + this.modulePagoda.mail.SendNewMail(&pb.DBMailData{ + CreateTime: uint64(configure.Now().Unix()), + Items: Items, + }, uid) + break + } + } } } } diff --git a/modules/pagoda/module.go b/modules/pagoda/module.go index 5a24f6001..122aa5d5c 100644 --- a/modules/pagoda/module.go +++ b/modules/pagoda/module.go @@ -24,7 +24,7 @@ type Pagoda struct { configure *configureComp battle comm.IBattle service base.IRPCXService - //mail comm.Imail + mail comm.Imail } func NewModule() core.IModule { @@ -73,11 +73,14 @@ func (this *Pagoda) Start() (err error) { if module, err = this.service.GetModule(comm.ModuleBattle); err != nil { return } - // if module, err = this.service.GetModule(comm.ModuleMail); err != nil { - // return - // } - //this.mail = module.(comm.Imail) + this.battle = module.(comm.IBattle) + + if module, err = this.service.GetModule(comm.ModuleMail); err != nil { + return + } + this.mail = module.(comm.Imail) + this.service.RegisterFunctionName(string(comm.Rpc_ModuleSeasonPagodaReward), this.Rpc_ModuleSeasonPagodaReward) return } diff --git a/modules/timer/module.go b/modules/timer/module.go index 56446e8b3..87cb43042 100644 --- a/modules/timer/module.go +++ b/modules/timer/module.go @@ -23,7 +23,7 @@ type Timer struct { cbase.ModuleBase options *Options service base.IRPCXService //rpc服务对象 通过这个对象可以发布服务和调用其他服务的接口 - rank *PagodaRank + //rank *PagodaRank rank2 *VikingRank rank3 *HuntingRank chat *ChatComp //俩天系统定时任务 @@ -59,7 +59,7 @@ func (this *Timer) Start() (err error) { func (this *Timer) OnInstallComp() { this.ModuleBase.OnInstallComp() - this.rank = this.RegisterComp(new(PagodaRank)).(*PagodaRank) + //this.rank = this.RegisterComp(new(PagodaRank)).(*PagodaRank) this.rank2 = this.RegisterComp(new(VikingRank)).(*VikingRank) this.rank3 = this.RegisterComp(new(HuntingRank)).(*HuntingRank) this.chat = this.RegisterComp(new(ChatComp)).(*ChatComp) diff --git a/modules/timer/pagodarank.go b/modules/timer/pagodarank.go index 5c5d56eb8..0728f0992 100644 --- a/modules/timer/pagodarank.go +++ b/modules/timer/pagodarank.go @@ -8,7 +8,6 @@ import ( "go_dreamfactory/lego/core" "go_dreamfactory/lego/core/cbase" - "go_dreamfactory/lego/sys/cron" "go_dreamfactory/lego/sys/log" "go.mongodb.org/mongo-driver/bson" @@ -34,11 +33,8 @@ func (this *PagodaRank) Init(service core.IService, module core.IModule, comp co func (this *PagodaRank) Start() (err error) { err = this.MCompModel.Start() - - cron.AddFunc("*/60 * * * * ?", this.TimerPagoda) //每60s执行一次 - - cron.AddFunc("*/60 * * * * ?", this.TimerSeason) //每60s执行一次 - + //cron.AddFunc("*/60 * * * * ?", this.TimerPagoda) //每60s执行一次 + //cron.AddFunc("*/60 * * * * ?", this.TimerSeason) //每60s执行一次 return } diff --git a/modules/timer/season.go b/modules/timer/season.go index 955be891f..21613d2a3 100644 --- a/modules/timer/season.go +++ b/modules/timer/season.go @@ -9,6 +9,7 @@ import ( "go_dreamfactory/sys/configure" cfg "go_dreamfactory/sys/configure/structs" "go_dreamfactory/sys/db" + "time" "go_dreamfactory/lego/base" "go_dreamfactory/lego/core" @@ -53,11 +54,36 @@ func (this *SeasonPagoda) Init(service core.IService, module core.IModule, comp func (this *SeasonPagoda) Start() (err error) { err = this.MCompModel.Start() err = this.MCompConfigure.Start() + configure.RegisterConfigure(game_seasonloop, cfg.NewGameSeasonLoop, nil) configure.RegisterConfigure(game_seasonreward, cfg.NewGamePagodaSeasonReward, nil) cron.AddFunc("0 0 23 L * ?", this.TimerSeasonOver) //每月最后一天23点执行一次 cron.AddFunc("0 0 5 /* * ?", this.TimerSeasonStar) //每月第一天5点执行一次 + conn, err := db.Cross() + if err == nil { + model := db.NewDBModel(comm.TableServerData, 0, conn) + + _len, err1 := model.DB.CountDocuments(comm.TableServerData, bson.M{}) + if err1 == nil && _len == 0 { + fmt.Printf("%v,%v", _len, err1) + server := &pb.DBServerData{ + Id: primitive.NewObjectID().Hex(), + ServerState: 1, + DisposableLoop: 1, + FixedLoop: 0, + SeasonType: 201, + OpenTime: time.Now().Unix(), + } + conf := this.GetSeasonLoop(comm.SeasonType) + if len(conf.DisposableLoop) > 0 { + server.SeasonType = conf.DisposableLoop[0] + } + + model.DB.InsertOne(comm.TableServerData, server) + } + } + return } func (this *SeasonPagoda) CreatTestData(index int) { From a4458a65dfb6d6e195c5ccd320f8a13f912dce5a Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Fri, 11 Nov 2022 17:56:21 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=88=98=E6=96=97=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/worldtask/api_finish.go | 37 ++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/modules/worldtask/api_finish.go b/modules/worldtask/api_finish.go index 7d4ca7947..787c64f31 100644 --- a/modules/worldtask/api_finish.go +++ b/modules/worldtask/api_finish.go @@ -72,23 +72,30 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe } } - if curTaskConf.Completetask != 0 { - if code = this.module.ModuleRtask.CheckCondi(uid, curTaskConf.Completetask); code != pb.ErrorCode_Success { - code = pb.ErrorCode_WorldtaskNoComplete - this.module.Debugf("任务条件:%v 未完成", curTaskConf.Completetask) + var nextTaskId int32 + + finishCall := func() { + nextTaskId = curTaskConf.IdAfter + // 完成任务 + if err := this.module.modelWorldtask.finishTask(req.GroupId, req.TaskId, userTask); err != nil { + code = pb.ErrorCode_WorldtaskFinish return } + // 发奖 + if code = this.module.DispenseRes(session, curTaskConf.Reword, true); code != pb.ErrorCode_Success { + this.module.Errorf("资源发放失败 err:%v", err) + } } - // 完成任务 - if err := this.module.modelWorldtask.finishTask(req.GroupId, req.TaskId, userTask); err != nil { - code = pb.ErrorCode_WorldtaskFinish - return - } - - // 发奖 - if code = this.module.DispenseRes(session, curTaskConf.Reword, true); code != pb.ErrorCode_Success { - this.module.Errorf("资源发放失败 err:%v", err) + if curTaskConf.Completetask != 0 { + if c := this.module.ModuleRtask.CheckCondi(uid, curTaskConf.Completetask); c == pb.ErrorCode_Success { + // code = pb.ErrorCode_WorldtaskNoComplete + // this.module.Debugf("任务条件:%v 未完成", curTaskConf.Completetask) + // return + finishCall() + } + } else { + finishCall() } rsp := &pb.WorldtaskFinishResp{ @@ -102,10 +109,10 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe // 任务完成推送 if err := session.SendMsg(string(this.module.GetType()), WorldtaskNexttaskPush, &pb.WorldtaskNexttaskPush{ - NextTaskId: curTaskConf.IdAfter, + NextTaskId: nextTaskId, }); err != nil { code = pb.ErrorCode_SystemError } - + return } From c41b83a2be58b90181fffd2a154809f508da609e Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Fri, 11 Nov 2022 18:10:47 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/json/game_worldtask.json | 26 +++++++++++++------------- modules/worldtask/api_finish.go | 3 --- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/bin/json/game_worldtask.json b/bin/json/game_worldtask.json index ec1120ee4..a42972b36 100644 --- a/bin/json/game_worldtask.json +++ b/bin/json/game_worldtask.json @@ -45,7 +45,7 @@ "task_name": "新剧情10101", "task_display": "新剧情文本10101", "npc": [ - "dreamwork_restaurant_01", + "scenes_ boundary_02", "邦尼兔组件名", "601" ], @@ -113,7 +113,7 @@ 2, 10004 ], - "completetask": 173, + "completetask": 0, "auto_accept": 1, "overtips": 1, "reword": [ @@ -315,7 +315,7 @@ "task_name": "新剧情10110", "task_display": "新剧情文本10110", "npc": [ - "scenes_smithy_01", + "SmithyScene", "戈伯铁匠铺组件名", "610" ], @@ -735,7 +735,7 @@ "task_name": "新剧情10124", "task_display": "新剧情文本10124", "npc": [ - "scenes_martialarts_01", + "WuGuanScene", "阿宝组件名", "624" ], @@ -765,7 +765,7 @@ "task_name": "新剧情10125", "task_display": "新剧情文本10125", "npc": [ - "scenes_martialarts_01", + "WuGuanScene", "阿宝组件名", "625" ], @@ -795,7 +795,7 @@ "task_name": "新剧情10126", "task_display": "新剧情文本10126", "npc": [ - "scenes_martialarts_01", + "WuGuanScene", "阿宝组件名", "626" ], @@ -825,7 +825,7 @@ "task_name": "新剧情10127", "task_display": "新剧情文本10127", "npc": [ - "scenes_martialarts_01", + "WuGuanScene", "阿宝组件名", "627" ], @@ -855,7 +855,7 @@ "task_name": "新剧情10128", "task_display": "新剧情文本10128", "npc": [ - "scenes_martialarts_01", + "WuGuanScene", "阿宝组件名", "628" ], @@ -885,7 +885,7 @@ "task_name": "新剧情10129", "task_display": "新剧情文本10129", "npc": [ - "scenes_martialarts_01", + "WuGuanScene", "阿宝组件名", "629" ], @@ -915,7 +915,7 @@ "task_name": "新剧情10130", "task_display": "新剧情文本10130", "npc": [ - "scenes_martialarts_01", + "WuGuanScene", "阿宝组件名", "630" ], @@ -1125,7 +1125,7 @@ "task_name": "新剧情10137", "task_display": "新剧情文本10137", "npc": [ - "scenes_martialarts_01", + "WuGuanScene", "阿宝组件名", "637" ], @@ -1155,7 +1155,7 @@ "task_name": "新剧情10138", "task_display": "新剧情文本10138", "npc": [ - "scenes_martialarts_01", + "WuGuanScene", "阿宝组件名", "638" ], @@ -1949,7 +1949,7 @@ "task_name": "新剧情10165", "task_display": "新剧情文本10165", "npc": [ - "scenes_ boundary_03", + "scenes_ boundary_02", "布兰奇组件名" ], "getafter_event": [ diff --git a/modules/worldtask/api_finish.go b/modules/worldtask/api_finish.go index 787c64f31..255e09314 100644 --- a/modules/worldtask/api_finish.go +++ b/modules/worldtask/api_finish.go @@ -89,9 +89,6 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe if curTaskConf.Completetask != 0 { if c := this.module.ModuleRtask.CheckCondi(uid, curTaskConf.Completetask); c == pb.ErrorCode_Success { - // code = pb.ErrorCode_WorldtaskNoComplete - // this.module.Debugf("任务条件:%v 未完成", curTaskConf.Completetask) - // return finishCall() } } else { From c118b8e762c1dbb79101d9b29cfeed0ca8dd8717 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Fri, 11 Nov 2022 21:01:24 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=8A=A0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/worldtask/api_finish.go | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/worldtask/api_finish.go b/modules/worldtask/api_finish.go index 255e09314..27ce56b2a 100644 --- a/modules/worldtask/api_finish.go +++ b/modules/worldtask/api_finish.go @@ -79,6 +79,7 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe // 完成任务 if err := this.module.modelWorldtask.finishTask(req.GroupId, req.TaskId, userTask); err != nil { code = pb.ErrorCode_WorldtaskFinish + this.module.Errorf("finishTask err:%v", err) return } // 发奖