From a875f850bad17ec836fc2e3a7683faa79d1ac6a6 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Mon, 29 Aug 2022 19:09:35 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=A8=A1=E5=9D=97=E6=B3=A8=E5=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/smithy/api_deskskilllv.go | 4 ++-- modules/smithy/api_stoveskilllv.go | 4 ++-- modules/smithy/comp_configure.go | 1 + services/worker/main.go | 2 ++ 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/smithy/api_deskskilllv.go b/modules/smithy/api_deskskilllv.go index 9bb808296..53fb8e5f3 100644 --- a/modules/smithy/api_deskskilllv.go +++ b/modules/smithy/api_deskskilllv.go @@ -11,7 +11,7 @@ import ( ) //参数校验 -func (this *apiComp) DeskSkillLvCkeck(session comm.IUserSession, req *pb.SmithyDeskSkillLvReq) (code pb.ErrorCode) { +func (this *apiComp) DeskSkillLvCheck(session comm.IUserSession, req *pb.SmithyDeskSkillLvReq) (code pb.ErrorCode) { if req.DeskType == 0 { code = pb.ErrorCode_ReqParameterError } @@ -23,7 +23,7 @@ func (this *apiComp) DeskSkillLv(session comm.IUserSession, req *pb.SmithyDeskSk bFindSkill bool curSkillCfg *cfg.GameSmithyData ) - code = this.DeskSkillLvCkeck(session, req) + code = this.DeskSkillLvCheck(session, req) if code != pb.ErrorCode_Success { return // 参数校验失败直接返回 } diff --git a/modules/smithy/api_stoveskilllv.go b/modules/smithy/api_stoveskilllv.go index 18af0dd8a..9fc36f2a7 100644 --- a/modules/smithy/api_stoveskilllv.go +++ b/modules/smithy/api_stoveskilllv.go @@ -10,14 +10,14 @@ import ( ) //参数校验 -func (this *apiComp) StoveSkillLvCkeck(session comm.IUserSession, req *pb.SmithyStoveSkillLvReq) (code pb.ErrorCode) { +func (this *apiComp) StoveSkillLvCheck(session comm.IUserSession, req *pb.SmithyStoveSkillLvReq) (code pb.ErrorCode) { return } func (this *apiComp) StoveSkillLv(session comm.IUserSession, req *pb.SmithyStoveSkillLvReq) (code pb.ErrorCode, dat proto.Message) { - code = this.StoveSkillLvCkeck(session, req) + code = this.StoveSkillLvCheck(session, req) if code != pb.ErrorCode_Success { return // 参数校验失败直接返回 } diff --git a/modules/smithy/comp_configure.go b/modules/smithy/comp_configure.go index 2dbe26248..481fd6c06 100644 --- a/modules/smithy/comp_configure.go +++ b/modules/smithy/comp_configure.go @@ -52,6 +52,7 @@ func (this *configureComp) GetSmithyConfigData(smithyType int32, level int32) (d return this._smithyMap[int64(smithyType<<16)+int64(level)] } func (this *configureComp) GetSmithyTypeConfigData() (mapType map[int32]struct{}) { + mapType = make(map[int32]struct{}, 0) if v, err := this.GetConfigure(game_smithy); err == nil { if configure, ok := v.(*cfg.GameSmithy); ok { for _, v1 := range configure.GetDataList() { diff --git a/services/worker/main.go b/services/worker/main.go index dbb6289d5..36d4c6593 100644 --- a/services/worker/main.go +++ b/services/worker/main.go @@ -18,6 +18,7 @@ import ( "go_dreamfactory/modules/pagoda" "go_dreamfactory/modules/rtask" "go_dreamfactory/modules/shop" + "go_dreamfactory/modules/smithy" "go_dreamfactory/modules/task" "go_dreamfactory/modules/user" "go_dreamfactory/modules/viking" @@ -67,6 +68,7 @@ func main() { martialhall.NewModule(), rtask.NewModule(), viking.NewModule(), + smithy.NewModule(), ) } From 8490699f6dd4239a0c60ed81eb00580973d0c3d3 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Tue, 30 Aug 2022 11:34:15 +0800 Subject: [PATCH 2/2] =?UTF-8?q?drop=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9=20?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=A4=9A=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/comp_configure.go | 50 ++++++++++++++++++++++++++++++++ modules/gourmet/model_gourmet.go | 37 +---------------------- modules/smithy/model_smithy.go | 35 +--------------------- modules/viking/api_challenge.go | 2 +- modules/viking/model_viking.go | 35 ---------------------- modules/viking/module.go | 14 --------- 6 files changed, 53 insertions(+), 120 deletions(-) diff --git a/modules/comp_configure.go b/modules/comp_configure.go index 43d8231c7..e6cee789b 100644 --- a/modules/comp_configure.go +++ b/modules/comp_configure.go @@ -2,9 +2,11 @@ package modules import ( "fmt" + "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/lego/core/cbase" "go_dreamfactory/lego/sys/log" + "go_dreamfactory/pb" "go_dreamfactory/sys/configure" cfg "go_dreamfactory/sys/configure/structs" "sync" @@ -156,7 +158,55 @@ func (this *MCompConfigure) GetPlayerFigureConf() (list []*cfg.GameFacemodData) } return } + func (this *MCompConfigure) GetDropData(dropId int32) (data []*cfg.GameDropData) { data = this._dropMap[dropId] return } + +// todo 调用drop 表 获取掉落信息 +func (this *MCompConfigure) GetMultipleDropReward(count, dropId int32, Items []*pb.UserAssets) { + res := make([]*cfg.Gameatn, 0) + for i := 0; i < int(count); i++ { + data := this.GetDropData(dropId) + szW := make([]int32, 0) + for _, value := range data { + szW = append(szW, value.P) + } + if len(szW) > 0 { + index := comm.GetRandW(szW) + res = append(res, data[index].Prize...) + } + } + for _, v := range res { + bFind := false + for _, v1 := range Items { + if v.A == v1.A && v.T == v1.T { + v1.N += v.N + bFind = true + } + } + if !bFind { + Items = append(Items, &pb.UserAssets{ + A: v.A, + T: v.T, + N: v.N, + }) + } + } + + return +} +func (this *MCompConfigure) GetDropReward(dropId int32, Items []*cfg.Gameatn) { + Items = make([]*cfg.Gameatn, 0) + + data := this.GetDropData(dropId) + szW := make([]int32, 0) + for _, value := range data { + szW = append(szW, value.P) + } + index := comm.GetRandW(szW) + Items = append(Items, data[index].Prize...) + + return +} diff --git a/modules/gourmet/model_gourmet.go b/modules/gourmet/model_gourmet.go index 3f9ea3c77..78f327b27 100644 --- a/modules/gourmet/model_gourmet.go +++ b/modules/gourmet/model_gourmet.go @@ -6,7 +6,6 @@ import ( "go_dreamfactory/lego/sys/redis" "go_dreamfactory/modules" "go_dreamfactory/pb" - cfg "go_dreamfactory/sys/configure/structs" "go_dreamfactory/utils" "time" @@ -65,40 +64,6 @@ func (this *modelGourmet) modifyGourmetDataByObjId(uid string, data map[string]i return this.Change(uid, data) } -// todo 调用drop 表 获取掉落信息 -func (this *modelGourmet) GetDropReward(count, dropId int32, Items []*pb.UserAssets) { - res := make([]*cfg.Gameatn, 0) - for i := 0; i < int(count); i++ { - data := this.module.configure.GetDropData(dropId) - szW := make([]int32, 0) - for _, value := range data { - szW = append(szW, value.P) - } - if len(szW) > 0 { - index := comm.GetRandW(szW) - res = append(res, data[index].Prize...) - } - } - for _, v := range res { - bFind := false - for _, v1 := range Items { - if v.A == v1.A && v.T == v1.T { - v1.N += v.N - bFind = true - } - } - if !bFind { - Items = append(Items, &pb.UserAssets{ - A: v.A, - T: v.T, - N: v.N, - }) - } - } - - return -} - // 计算订单信息 func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet) { var ( @@ -140,7 +105,7 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet) gourmet.OrderCostTime = 0 // 清空当天的订单时长 } order.FoodCount-- - this.GetDropReward(_gourmetcfg.Using, _gourmetcfg.Propsgroup, gourmet.Items) // 获取掉落奖励 + this.module.configure.GetMultipleDropReward(_gourmetcfg.Using, _gourmetcfg.Propsgroup, gourmet.Items) // 获取掉落奖励 if curTime > costTime { gourmet.OrderCostTime += int32(curTime - costTime) diff --git a/modules/smithy/model_smithy.go b/modules/smithy/model_smithy.go index 4a0f3439a..2b7bfe580 100644 --- a/modules/smithy/model_smithy.go +++ b/modules/smithy/model_smithy.go @@ -6,7 +6,6 @@ import ( "go_dreamfactory/lego/sys/redis" "go_dreamfactory/modules" "go_dreamfactory/pb" - cfg "go_dreamfactory/sys/configure/structs" "go_dreamfactory/utils" "time" @@ -61,38 +60,6 @@ func (this *modelSmithy) modifySmithyDataByObjId(uid string, data map[string]int return this.Change(uid, data) } -// todo 调用drop 表 获取掉落信息 -func (this *modelSmithy) GetDropReward(count, dropId int32, Items []*pb.UserAssets) { - res := make([]*cfg.Gameatn, 0) - for i := 0; i < int(count); i++ { - data := this.module.configure.GetDropData(dropId) - szW := make([]int32, 0) - for _, value := range data { - szW = append(szW, value.P) - } - index := comm.GetRandW(szW) - res = append(res, data[index].Prize...) - } - for _, v := range res { - bFind := false - for _, v1 := range Items { - if v.A == v1.A && v.T == v1.T { - v1.N += v.N - bFind = true - } - } - if !bFind { - Items = append(Items, &pb.UserAssets{ - A: v.A, - T: v.T, - N: v.N, - }) - } - } - - return -} - // 计算订单信息 func (this *modelSmithy) CalculationSmithy(uid string, Smithy *pb.DBSmithy) { var ( @@ -134,7 +101,7 @@ func (this *modelSmithy) CalculationSmithy(uid string, Smithy *pb.DBSmithy) { Smithy.OrderCostTime = 0 // 清空当天的订单时长 } order.Count-- - this.GetDropReward(1, _Smithycfg.Drop, Smithy.Items) // 获取掉落奖励 + this.module.configure.GetMultipleDropReward(1, _Smithycfg.Drop, Smithy.Items) // 获取掉落奖励 if curTime > costTime { Smithy.OrderCostTime += int32(curTime - costTime) diff --git a/modules/viking/api_challenge.go b/modules/viking/api_challenge.go index a60b4f370..5f6cd82df 100644 --- a/modules/viking/api_challenge.go +++ b/modules/viking/api_challenge.go @@ -70,7 +70,7 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.VikingChalleng viking.ChallengeTime[req.BossType<<16+req.Difficulty] = 0 code = this.module.ModifyVikingData(session.GetUserId(), mapData) // 发放通关随机奖励 - this.module.GetDropReward(cfg.Drop, reward) // 获取掉落奖励 + this.module.configure.GetDropReward(cfg.Drop, reward) // 获取掉落奖励 if code = this.module.DispenseRes(session, reward, true); code != pb.ErrorCode_Success { return } diff --git a/modules/viking/model_viking.go b/modules/viking/model_viking.go index 4a01b4889..b59578a4d 100644 --- a/modules/viking/model_viking.go +++ b/modules/viking/model_viking.go @@ -6,7 +6,6 @@ import ( "go_dreamfactory/lego/sys/redis" "go_dreamfactory/modules" "go_dreamfactory/pb" - cfg "go_dreamfactory/sys/configure/structs" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/x/bsonx" @@ -40,37 +39,3 @@ func (this *modelViking) getVikingList(uid string) (result *pb.DBViking, err err func (this *modelViking) modifyVikingDataByObjId(uid string, data map[string]interface{}) error { return this.Change(uid, data) } - -// todo 调用drop 表 获取掉落信息 -func (this *modelViking) GetDropReward(count, dropId int32, Items []*pb.UserAssets) { - res := make([]*cfg.Gameatn, 0) - for i := 0; i < int(count); i++ { - data := this.module.configure.GetDropData(dropId) - szW := make([]int32, 0) - for _, value := range data { - szW = append(szW, value.P) - } - if len(szW) > 0 { - index := comm.GetRandW(szW) - res = append(res, data[index].Prize...) - } - } - for _, v := range res { - bFind := false - for _, v1 := range Items { - if v.A == v1.A && v.T == v1.T { - v1.N += v.N - bFind = true - } - } - if !bFind { - Items = append(Items, &pb.UserAssets{ - A: v.A, - T: v.T, - N: v.N, - }) - } - } - - return -} diff --git a/modules/viking/module.go b/modules/viking/module.go index e64143ddc..c401a0fdd 100644 --- a/modules/viking/module.go +++ b/modules/viking/module.go @@ -10,7 +10,6 @@ import ( "go_dreamfactory/lego/core" "go_dreamfactory/modules" "go_dreamfactory/pb" - cfg "go_dreamfactory/sys/configure/structs" ) type Viking struct { @@ -51,16 +50,3 @@ func (this *Viking) ModifyVikingData(uid string, data map[string]interface{}) (c } return } -func (this *Viking) GetDropReward(dropId int32, Items []*cfg.Gameatn) { - Items = make([]*cfg.Gameatn, 0) - - data := this.configure.GetDropData(dropId) - szW := make([]int32, 0) - for _, value := range data { - szW = append(szW, value.P) - } - index := comm.GetRandW(szW) - Items = append(Items, data[index].Prize...) - - return -}