From 14a8a7d93de9d418b0da2b81f2fda242bbfcb738 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Mon, 6 Mar 2023 15:07:40 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hero/configure_comp.go | 23 +++++++++++------------ utils/strings.go | 8 ++++++++ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/modules/hero/configure_comp.go b/modules/hero/configure_comp.go index 666d19c98..4823f38fb 100644 --- a/modules/hero/configure_comp.go +++ b/modules/hero/configure_comp.go @@ -41,9 +41,8 @@ type configureComp struct { hlock sync.RWMutex drawCardCfg map[string]map[int32][]*cfg.GameDrawCardData // 第一个key 卡池id 第二个key 星级 awakenMap map[int64]*cfg.GameHeroAwakenData - - starMap map[int64]*cfg.GameHeroStarupData - module *Hero + starMap map[int64]*cfg.GameHeroStarupData + module *Hero } //组件初始化接口 @@ -78,9 +77,8 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp defer this.hlock.Unlock() if _configure, ok := v.(*cfg.GameHeroAwaken); ok { for _, v := range _configure.GetDataList() { - this.awakenMap[int64(utils.ToInt32(v.Hid)<<8)+int64(v.Phase)] = v + this.awakenMap[utils.ToInt64(v.Hid)+int64(v.Phase<<31)] = v } - return } } else { @@ -96,7 +94,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp this.hlock.Lock() defer this.hlock.Unlock() for _, v := range _configure.GetDataList() { - this.starMap[int64(utils.ToInt32(v.Id)<<8)+int64(v.Star)] = v + this.starMap[utils.ToInt64(v.Id)+int64(v.Star<<31)] = v } return @@ -111,22 +109,23 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp // 获取英雄升星相关配置数据 func (this *configureComp) GetHeroStarupConfig(hid string, star int32) *cfg.GameHeroStarupData { - return this.starMap[int64(utils.ToInt32(hid)<<8)+int64(star)] + return this.starMap[utils.ToInt64(hid)+int64(star<<31)] } // 获取当前英雄最高星级 func (this *configureComp) GetHeroMaxStar(hid string, curStar int32) int32 { var star int32 for star = curStar; star < 100; star++ { - if _, ok := this.starMap[int64(utils.ToInt32(hid)<<8)+int64(star+1)]; !ok { + if _, ok := this.starMap[utils.ToInt64(hid)+int64((star+1)<<31)]; !ok { return star } } return star } +// 获取觉醒配置 func (this *configureComp) GetHeroAwakenConfig(hid string, phase int32) *cfg.GameHeroAwakenData { - return this.awakenMap[int64(utils.ToInt32(hid)<<8)+int64(phase)] + return this.awakenMap[utils.ToInt64(hid)+int64(phase<<31)] } // 抽卡配置表 @@ -238,7 +237,7 @@ func (this *configureComp) GetHeroLvgrow(heroId string) *cfg.GameHeroLevelgrowDa return configure.Get(heroId) } } - + this.module.Errorf("cfg.GetHeroLvgrow :id = %s", heroId) return nil } @@ -251,7 +250,7 @@ func (this *configureComp) GetHeroSkillUpConfig(skillid int32) (data *cfg.GameHe return } } - + this.module.Errorf("cfg.GetHeroSkillUpConfig :id = %d", skillid) return } @@ -267,7 +266,7 @@ func (this *configureComp) GetHeroSkillMaxLvConfig(skillId uint32) int32 { } } } - + this.module.Errorf("cfg.GetHeroSkillMaxLvConfig :id = %d", skillId) return 0 } diff --git a/utils/strings.go b/utils/strings.go index 631a913ff..7cbfbd620 100644 --- a/utils/strings.go +++ b/utils/strings.go @@ -88,3 +88,11 @@ func ToInt32(s string) int32 { return int32(j) } } + +func ToInt64(s string) int64 { + if j, err := strconv.ParseInt(s, 10, 32); err != nil { + return 0 + } else { + return int64(j) + } +} From 83a5083a93589ce52ef58f96ed7a91ae3d0c1ed3 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Mon, 6 Mar 2023 16:41:10 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E5=BA=9F=E9=99=A4?= =?UTF-8?q?=E7=9A=84=E7=89=B9=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/const.go | 20 ++++++++++---------- comm/imodule.go | 2 +- modules/hero/module.go | 8 ++++---- modules/smithy/api_createorder.go | 8 +++----- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/comm/const.go b/comm/const.go index 5ba8099de..104c67bd6 100644 --- a/comm/const.go +++ b/comm/const.go @@ -721,16 +721,16 @@ const ( ) const ( - PrivilegeType1 = iota + 1 //每日获得 - PrivilegeType2 //金币商店每日免费刷新次数 - PrivilegeType3 //维京远征每日可购买挑战次数 - PrivilegeType4 //狩猎每日可购买挑战次数 - PrivilegeType5 //竞技场每日可购买挑战次数 - PrivilegeType6 //梦境每日可购买挑战次数 - PrivilegeType7 //巨怪商队背包容量 - PrivilegeType8 //美食馆每日最大制作时间 - PrivilegeType9 //武馆每日最大练功时间 - PrivilegeType10 //铁匠铺每日最大锻造时间 + PrivilegeType1 = iota + 1 //每日获得 + PrivilegeType2 //金币商店每日免费刷新次数 + PrivilegeType3 //维京远征每日可购买挑战次数 + PrivilegeType4 //狩猎每日可购买挑战次数 + PrivilegeType5 //竞技场每日可购买挑战次数 + PrivilegeType6 //梦境每日可购买挑战次数 + PrivilegeType7 //巨怪商队背包容量 + PrivilegeType8 //美食馆每日最大制作时间 + PrivilegeType9 //武馆每日最大练功时间 + ) const ( MainStarType1 = 1 //成功通关 diff --git a/comm/imodule.go b/comm/imodule.go index 75d4eaf49..7216de839 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -67,7 +67,7 @@ type ( //清理玩家英雄数据 CleanData(uid string) // 获取指定星级等级的英雄 - GetSpecifiedHero(session IUserSession, heroConfId string, star, lv, amount int32) (code pb.ErrorCode) + GetSpecifiedHero(session IUserSession, heroConfId string, star, lv int32) (code pb.ErrorCode) // 英雄加经验 AddHeroExp(session IUserSession, heroObjID string, exp int32) (curAddExp int32, code pb.ErrorCode) // 英雄练功 diff --git a/modules/hero/module.go b/modules/hero/module.go index 315e94f67..e1ee8d508 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -204,8 +204,8 @@ func (this *Hero) CleanData(uid string) { } // 创建一些特殊的英雄 -func (this *Hero) GetSpecifiedHero(session comm.IUserSession, heroConfId string, star, lv, amount int32) (code pb.ErrorCode) { - if session.GetUserId() == "" || heroConfId == "" || star == 0 || lv == 0 || amount == 0 { +func (this *Hero) GetSpecifiedHero(session comm.IUserSession, heroConfId string, star, lv int32) (code pb.ErrorCode) { + if session.GetUserId() == "" || heroConfId == "" || star == 0 || lv == 0 { return pb.ErrorCode_ReqParameterError } // 等级校验 @@ -235,11 +235,11 @@ func (this *Hero) GetSpecifiedHero(session comm.IUserSession, heroConfId string, } hero.Lv = lv hero.Star = star - hero.SameCount = amount + hero.SameCount = 1 _heroMap := map[string]interface{}{ "lv": hero.Lv, "star": hero.Star, - "sameCount": amount, + "sameCount": 1, } // 保存数据 err = this.modelHero.ChangeList(session.GetUserId(), hero.Id, _heroMap) diff --git a/modules/smithy/api_createorder.go b/modules/smithy/api_createorder.go index c315ba6b8..a4d9ae5f9 100644 --- a/modules/smithy/api_createorder.go +++ b/modules/smithy/api_createorder.go @@ -20,9 +20,8 @@ func (this *apiComp) CreateOrderCheck(session comm.IUserSession, req *pb.SmithyC func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.SmithyCreateOrderReq) (code pb.ErrorCode, data proto.Message) { var ( - res []*cfg.Gameatn - costTime int32 - privilegeAddItme int32 // 特权额外增加的时间 + res []*cfg.Gameatn + costTime int32 ) code = this.CreateOrderCheck(session, req) @@ -83,8 +82,7 @@ func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.SmithyCreate return } _smithy.OrderCostTime += costTime - privilegeAddItme = this.module.ModulePrivilege.GetCountByPrivilegeId(session.GetUserId(), comm.PrivilegeType10) - if cfgCom.SmithyMaxtime+privilegeAddItme < _smithy.OrderCostTime { // 大于总时长是不允许的 + if cfgCom.SmithyMaxtime < _smithy.OrderCostTime { // 大于总时长是不允许的 code = pb.ErrorCode_GourmetMoreOrderTime return } From 05344dfa8124913e2050d69a0f03b839efdd6628 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Mon, 6 Mar 2023 18:05:28 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/rtask/module.go | 24 ++++++++++++------------ modules/rtask/updateHandle.go | 14 ++++++-------- modules/rtask/verifyHandle.go | 8 -------- modules/task/module.go | 6 ------ 4 files changed, 18 insertions(+), 34 deletions(-) diff --git a/modules/rtask/module.go b/modules/rtask/module.go index a552443ba..b41975a74 100644 --- a/modules/rtask/module.go +++ b/modules/rtask/module.go @@ -234,14 +234,14 @@ func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.T return } - this.Debug("任务事件触发", - log.Field{Key: "uid", Value: uid}, - log.Field{Key: "taskType", Value: rtaskType}, - log.Field{Key: "params", Value: params}, - ) + // this.Debug("任务事件触发", + // log.Field{Key: "uid", Value: uid}, + // log.Field{Key: "taskType", Value: rtaskType}, + // log.Field{Key: "params", Value: params}, + // ) var ( - err error - condiId int32 + // err error + // condiId int32 condis []*rtaskCondi ) @@ -264,11 +264,11 @@ func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.T return } - if condiId, err = v.find(codiConf, params...); condiId == 0 { - if err != nil { - this.Warnln(errors.WithMessage(err, uid).Error()) - } - } else { + if condiId, _ := v.find(codiConf, params...); condiId != 0 { + // if err != nil { + // this.Warnln(errors.WithMessage(err, uid).Error()) + // } + // } else { v.condId = codiConf.Id condis = append(condis, v) } diff --git a/modules/rtask/updateHandle.go b/modules/rtask/updateHandle.go index 9bf58867d..13bebf1d3 100644 --- a/modules/rtask/updateHandle.go +++ b/modules/rtask/updateHandle.go @@ -2,8 +2,6 @@ package rtask import ( - "go_dreamfactory/lego/sys/log" - "go_dreamfactory/pb" "go_dreamfactory/sys/configure" cfg "go_dreamfactory/sys/configure/structs" @@ -109,12 +107,12 @@ func (this *ModelRtaskRecord) addUpdate(uid string, cfg *cfg.GameRdtaskCondiData } err = this.Change(uid, update) } - log.Debug("累计次数更新", - log.Field{Key: "uid", Value: uid}, - log.Field{Key: "condiId", Value: cfg.Id}, - log.Field{Key: "params", Value: vals}, - log.Field{Key: "updated", Value: record.Vals[cfg.Id]}, - ) + // log.Debug("累计次数更新", + // log.Field{Key: "uid", Value: uid}, + // log.Field{Key: "condiId", Value: cfg.Id}, + // log.Field{Key: "params", Value: vals}, + // log.Field{Key: "updated", Value: record.Vals[cfg.Id]}, + // ) return } diff --git a/modules/rtask/verifyHandle.go b/modules/rtask/verifyHandle.go index dadfc30e6..4c0e2160a 100644 --- a/modules/rtask/verifyHandle.go +++ b/modules/rtask/verifyHandle.go @@ -154,7 +154,6 @@ func (this *ModelRtask) verifyRtype3(uid string, cfg *cfg.GameRdtaskCondiData) ( // 指定英雄等级 func (this *ModelRtask) verifyRtype4(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) { - defer printCondiLog(uid, cfg) m, err := this.service.GetModule(comm.ModuleHero) if err != nil { return @@ -182,7 +181,6 @@ func (this *ModelRtask) verifyRtype4(uid string, cfg *cfg.GameRdtaskCondiData) ( // 指定英雄的指定装备数量 func (this *ModelRtask) verifyRtype5(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) { - defer printCondiLog(uid, cfg) m, err := this.service.GetModule(comm.ModuleHero) if err != nil { return @@ -220,7 +218,6 @@ func (this *ModelRtask) verifyRtype5(uid string, cfg *cfg.GameRdtaskCondiData) ( // 指定英雄星级 func (this *ModelRtask) verifyRtype6(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) { - defer printCondiLog(uid, cfg) m, err := this.service.GetModule(comm.ModuleHero) if err != nil { return @@ -247,7 +244,6 @@ func (this *ModelRtask) verifyRtype6(uid string, cfg *cfg.GameRdtaskCondiData) ( // 日常登录一次 func (this *ModelRtask) verfiyRtype7(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) { - defer printCondiLog(uid, cfg) userModule, err := this.service.GetModule(comm.ModuleUser) if err != nil { return @@ -263,7 +259,6 @@ func (this *ModelRtask) verfiyRtype7(uid string, cfg *cfg.GameRdtaskCondiData) ( // 累计登陆xx天 func (this *ModelRtask) verfiyRtype8(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) { - defer printCondiLog(uid, cfg) userModule, err := this.service.GetModule(comm.ModuleUser) if err != nil { return @@ -281,7 +276,6 @@ func (this *ModelRtask) verfiyRtype8(uid string, cfg *cfg.GameRdtaskCondiData) ( // 连续登陆xx天 func (this *ModelRtask) verfiyRtype9(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) { - defer printCondiLog(uid, cfg) userModule, err := this.service.GetModule(comm.ModuleUser) if err != nil { return @@ -299,7 +293,6 @@ func (this *ModelRtask) verfiyRtype9(uid string, cfg *cfg.GameRdtaskCondiData) ( // 拥有xx个好友 func (this *ModelRtask) verfiyRtype10(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) { - defer printCondiLog(uid, cfg) m, err := this.service.GetModule(comm.ModuleFriend) if err != nil { return @@ -314,7 +307,6 @@ func (this *ModelRtask) verfiyRtype10(uid string, cfg *cfg.GameRdtaskCondiData) // 用户等级达到xx级 func (this *ModelRtask) verifyRtype20(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool, err error) { - defer printCondiLog(uid, cfg) userModule, err := this.service.GetModule(comm.ModuleUser) if err != nil { return diff --git a/modules/task/module.go b/modules/task/module.go index 5b99c4045..64a7ad0ea 100644 --- a/modules/task/module.go +++ b/modules/task/module.go @@ -11,8 +11,6 @@ import ( "go_dreamfactory/lego/sys/log" "go_dreamfactory/modules" "go_dreamfactory/pb" - "go_dreamfactory/sys/configure" - "time" ) var _ comm.ITask = (*ModuleTask)(nil) @@ -59,10 +57,6 @@ func (this *ModuleTask) Start() (err error) { // 初始化日常、周常、成就 func (this *ModuleTask) InitTaskAll(uid string) { - t := configure.Now() - defer func() { - log.Debugf("初始化任务 耗时:%v", time.Since(t)) - }() this.modelTask.initTask(uid, comm.TASK_DAILY) this.modelTask.initTask(uid, comm.TASK_WEEKLY) this.modelTask.initTask(uid, comm.TASK_ACHIEVE)