diff --git a/modules/gourmet/model_gourmet.go b/modules/gourmet/model_gourmet.go index 44919121d..d3e0afdc8 100644 --- a/modules/gourmet/model_gourmet.go +++ b/modules/gourmet/model_gourmet.go @@ -71,9 +71,9 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet) costTime int32 curTime int32 szTime map[int32]int32 - zTime int64 - nextDay bool - nextDayTime int32 + zeroTime int64 // 订单开始的时间对应第二天0点时间 + nextDay bool // 是否跨天了 + nextDayTime int32 // 跨天累计时间 ) mapData := make(map[string]interface{}, 0) szTime = make(map[int32]int32, 0) @@ -92,12 +92,8 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet) } szTime[k] = _time } - if !utils.IsToday(gourmet.Ctime) { - gourmet.Ctime = time.Now().Unix() - zTime = utils.GetZeroTime() - } - if gourmet.CookingFood != nil && gourmet.CookingFood.ETime > 0 { + zeroTime = utils.GetZeroTime(gourmet.CookingFood.STime) // 获取订单开始时间当天的0点 costTime = int32(time.Now().Unix() - gourmet.CookingFood.ETime) // 当前过去的时间 if costTime < 0 { // 没有完成 不做处理 return @@ -121,14 +117,21 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet) } order.CookTime = order.FoodCount * szTime[order.FoodType] if gourmet.CookingFood == nil { + if zeroTime == 0 { + zeroTime = utils.GetZeroTime(time.Now().Unix()) + } gourmet.CookingFood = &pb.Cooking{} gourmet.CookingFood.STime = time.Now().Unix() - gourmet.CookingFood.ETime = time.Now().Unix() + gourmet.CookingFood.ETime = time.Now().Unix() + int64(szTime[order.FoodType]) + } else { + gourmet.CookingFood.STime += int64(szTime[order.FoodType]) + gourmet.CookingFood.ETime += int64(szTime[order.FoodType]) } gourmet.CookingFood.FoodType = order.FoodType - gourmet.CookingFood.STime += int64(szTime[order.FoodType]) - gourmet.CookingFood.ETime += int64(szTime[order.FoodType]) - if zTime > 0 && gourmet.CookingFood.STime > zTime { + + // 判断订单是否跨天 + if gourmet.CookingFood.ETime >= zeroTime && !nextDay { + gourmet.Ctime = zeroTime // 设置 gourmet.OrderCostTime = 0 nextDay = true } @@ -163,6 +166,11 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet) gourmet.OrderCostTime += szTime[order.FoodType] * order.FoodCount } } + + if utils.GetZeroTime(gourmet.Ctime) <= time.Now().Unix() { + gourmet.OrderCostTime = 0 + } + if gourmet.CookingFood != nil && gourmet.CookingFood.ETime <= time.Now().Unix() { // 当前时间超过正在做的时间 foodtype := gourmet.CookingFood.FoodType skillLv := gourmet.Skill[foodtype] // 获取技能等级 diff --git a/modules/hero/api_awaken.go b/modules/hero/api_awaken.go index cda8199cf..ffb843303 100644 --- a/modules/hero/api_awaken.go +++ b/modules/hero/api_awaken.go @@ -37,18 +37,13 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c return } - AwakenConfig, err1 := this.module.configure.GetHeroAwakenConfig() - if err1 != nil { + awakenData = this.module.configure.GetHeroAwakenConfig(_hero.HeroID, _hero.JuexingLv) + if awakenData == nil { code = pb.ErrorCode_ConfigNoFound return } - for _, v := range AwakenConfig.GetDataMap() { - if v.Hid == _hero.HeroID && v.Phase == _hero.JuexingLv+1 { - awakenData = v - break - } - } - if awakenData == nil { + nextAwaken := this.module.configure.GetHeroAwakenConfig(_hero.HeroID, _hero.JuexingLv+1) + if nextAwaken == nil { code = pb.ErrorCode_HeroMaxAwaken // 达到最大觉醒等级 return } @@ -87,10 +82,10 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c "isOverlying": false, } // 保存数据 - err1 = this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap) - if err1 != nil { + err := this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap) + if err != nil { code = pb.ErrorCode_DBError - this.module.Errorf("update hero skill failed:%v", err1) + this.module.Errorf("update hero skill failed:%v", err) return } } else { // 加属性 @@ -107,10 +102,10 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c "isOverlying": false, } // 保存数据 - err1 = this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap) - if err1 != nil { + err = this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap) + if err != nil { code = pb.ErrorCode_DBError - this.module.Errorf("update hero skill failed:%v", err1) + this.module.Errorf("update hero skill failed:%v", err) return } } @@ -126,6 +121,14 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c cfg := this.module.configure.GetHero(_hero.HeroID) if cfg != nil { this.module.ModuleRtask.SendToRtask(session, comm.Rtype36, 1, cfg.Color, cfg.Job, cfg.Race, _hero.JuexingLv) + //xx英雄满级、共鸣、觉醒至最高状态 + nextAwaken := this.module.configure.GetHeroAwakenConfig(_hero.HeroID, _hero.JuexingLv+1) + if nextAwaken == nil { // 达到满级觉醒 + resonConfig := this.module.configure.GetHeroResonanceConfig(_hero.HeroID, _hero.Star+1) + if resonConfig == nil { // 满星 + + } + } } return } diff --git a/modules/hero/api_resonance.go b/modules/hero/api_resonance.go index b73d4ab3a..49fa17710 100644 --- a/modules/hero/api_resonance.go +++ b/modules/hero/api_resonance.go @@ -44,8 +44,8 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR } // 共鸣次数判断 - resonConfig, errr := this.module.configure.GetHeroResonanceConfig(_hero.HeroID) - if errr != nil { + resonConfig := this.module.configure.GetHeroResonanceConfig(_hero.HeroID, _hero.Star) + if resonConfig == nil { code = pb.ErrorCode_ConfigNoFound return } @@ -84,12 +84,6 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR ChangeList = append(ChangeList, _costMaphero[k]) } - resonConfig, err1 := this.module.configure.GetHeroResonanceConfig(_hero.HeroID) - if err1 != nil { - code = pb.ErrorCode_ConfigNoFound - return - } - code = this.module.ConsumeRes(session, resonConfig.Need, true) if code != pb.ErrorCode_Success { return @@ -108,9 +102,9 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR "isOverlying": false, "sameCount": 1, } - err1 = this.module.modelHero.ChangeList(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息 - if err1 != nil { - this.module.Errorf("update hero skill failed:%v", err1) + err := this.module.modelHero.ChangeList(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息 + if err != nil { + this.module.Errorf("update hero skill failed:%v", err) code = pb.ErrorCode_DBError return } @@ -129,6 +123,6 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR // 任务相关 this.module.ModuleRtask.SendToRtask(session, comm.Rtype39, 1) - this.module.ModuleRtask.SendToRtask(session, comm.Rtype39, 1, 1) + this.module.ModuleRtask.SendToRtask(session, comm.Rtype40, 1, 1) return } diff --git a/modules/hero/api_resonanceReset.go b/modules/hero/api_resonanceReset.go index 3e0138475..2ac2bc78a 100644 --- a/modules/hero/api_resonanceReset.go +++ b/modules/hero/api_resonanceReset.go @@ -39,8 +39,8 @@ func (this *apiComp) ResonanceReset(session comm.IUserSession, req *pb.HeroReson } // 共鸣次数判断 - resonConfig, errr := this.module.configure.GetHeroResonanceConfig(_hero.HeroID) - if errr != nil { + resonConfig := this.module.configure.GetHeroResonanceConfig(_hero.HeroID, _hero.Star) + if resonConfig == nil { code = pb.ErrorCode_ConfigNoFound return } diff --git a/modules/hero/api_strengthenUpStar.go b/modules/hero/api_strengthenUpStar.go index ba8d24e82..a3338e183 100644 --- a/modules/hero/api_strengthenUpStar.go +++ b/modules/hero/api_strengthenUpStar.go @@ -51,31 +51,17 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, req *pb.HeroStr } // 校验指定英雄 - tagHeroConfig, err1 := this.module.configure.GetHeroStarupConfig() - if err1 != nil { + tagHeroConfig := this.module.configure.GetHeroStarupConfig(_hero.HeroID, _hero.Star) + if tagHeroConfig == nil { code = pb.ErrorCode_ReqParameterError return } - - for _, value := range tagHeroConfig.GetDataList() { - if _hero.HeroID == value.Id && _hero.Star == value.Star { - // 校验等级 - if _hero.Lv < _hero.Star*comm.HeroStarLvRatio { - code = pb.ErrorCode_HeroStarLvErr - return - } - if value.Needhero == "" && value.Needracenum == 0 && value.Gold == 0 { // 不能再升星了 - code = pb.ErrorCode_HeroMaxStarLv - return - } - target = value - break - } - } - if target == nil { - code = pb.ErrorCode_HeroStarErr //升星条件不满足 + nextHeroConfig := this.module.configure.GetHeroStarupConfig(_hero.HeroID, _hero.Star+1) + if nextHeroConfig == nil { + code = pb.ErrorCode_HeroMaxStarLv return } + // 优先校验数量对不对 if target.Needheronum != costNeedHeroCount || target.Needracenum != costRaceHeroCount { code = pb.ErrorCode_ReqParameterError @@ -159,10 +145,10 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, req *pb.HeroStr // 触发星级任务 this.module.ModuleTask.SendToTask(session, comm.TaskTypeUpHeroStar, &pb.TaskParam{First: _hero.Star}) // 保存数据 - err1 = this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap) - if err1 != nil { + err := this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap) + if err != nil { code = pb.ErrorCode_DBError - this.module.Errorf("update hero skill failed:%v", err1) + this.module.Errorf("update hero skill failed:%v", err) } this.module.modelHero.ChangeHeroProperty(session, _hero) // 重新计算属性 diff --git a/modules/hero/configure_comp.go b/modules/hero/configure_comp.go index d4b9c162a..fff22336b 100644 --- a/modules/hero/configure_comp.go +++ b/modules/hero/configure_comp.go @@ -7,6 +7,7 @@ import ( cfg "go_dreamfactory/sys/configure/structs" "go_dreamfactory/lego/core" + "go_dreamfactory/utils" ) const ( @@ -31,6 +32,9 @@ type configureComp struct { modules.MCompConfigure drawCardCfg map[string]map[int32][]*cfg.GameDrawCardData // 第一个key 卡池id 第二个key 星级 //map["base_pool1"]map[3]*cfg.Game_drawCardData + awakenMap map[int64]*cfg.GameHeroAwakenData + resonanceMap map[int64]*cfg.GameHeroResonanceData + starMap map[int64]*cfg.GameHeroStarupData } //组件初始化接口 @@ -41,28 +45,83 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp new_hero: cfg.NewGameHero, hero_stargrow: cfg.NewGameHeroStargrow, hero_levelgrow: cfg.NewGameHeroLevelgrow, - hero_starup: cfg.NewGameHeroStarup, hero_levelup: cfg.NewGameHeroLevelup, hero_exp: cfg.NewGameHeroExp, hero_skillup: cfg.NewGameHeroSkillLevel, game_skillatk: cfg.NewGameSkillAtk, - hero_resonance: cfg.NewGameHeroResonance, hero_comatn: cfg.NewGameComAtn, - hero_awaken: cfg.NewGameHeroAwaken, hero_drawcard: cfg.NewGameDrawCard, }) this.drawCardCfg = make(map[string]map[int32][]*cfg.GameDrawCardData, 0) - configure.RegisterConfigure(hero_drawcard, cfg.NewGameDrawCard, func() { - this.SetHeroDrawConfig() + configure.RegisterConfigure(hero_drawcard, cfg.NewGameDrawCard, this.SetHeroDrawConfig) + this.awakenMap = make(map[int64]*cfg.GameHeroAwakenData, 0) + configure.RegisterConfigure(hero_awaken, cfg.NewGameHeroAwaken, func() { + if v, err := this.GetConfigure(hero_awaken); err == nil { + if _configure, ok := v.(*cfg.GameHeroAwaken); ok { + for _, v := range _configure.GetDataList() { + this.awakenMap[int64(utils.ToInt32(v.Hid)<<8)+int64(v.Phase)] = v + } + + return + } + } else { + err = fmt.Errorf("%T no is *cfg.Game_drawCard", v) + } + }) + // 共鸣 + this.resonanceMap = make(map[int64]*cfg.GameHeroResonanceData, 0) + configure.RegisterConfigure(hero_resonance, cfg.NewGameHeroResonance, func() { + if v, err := this.GetConfigure(hero_resonance); err == nil { + if _configure, ok := v.(*cfg.GameHeroResonance); ok { + for _, v := range _configure.GetDataList() { + this.resonanceMap[int64(utils.ToInt32(v.Hid)<<8)+int64(v.Star)] = v + } + + return + } + } else { + err = fmt.Errorf("%T no is *cfg.Game_drawCard", v) + } + }) + // 升星 + //: cfg., + this.starMap = make(map[int64]*cfg.GameHeroStarupData, 0) + configure.RegisterConfigure(hero_starup, cfg.NewGameHeroStarup, func() { + if v, err := this.GetConfigure(hero_starup); err == nil { + if _configure, ok := v.(*cfg.GameHeroStarup); ok { + for _, v := range _configure.GetDataList() { + this.starMap[int64(utils.ToInt32(v.Id)<<8)+int64(v.Star)] = v + } + + return + } + } else { + err = fmt.Errorf("%T no is *cfg.Game_drawCard", v) + } }) return } +// 获取英雄升星相关配置数据 +func (this *configureComp) GetHeroStarupConfig(hid string, star int32) *cfg.GameHeroStarupData { + return this.starMap[int64(utils.ToInt32(hid)<<8)+int64(star)] +} + +// 通过英雄配置ID获取共鸣配置信息 +func (this *configureComp) GetHeroResonanceConfig(hid string, star int32) *cfg.GameHeroResonanceData { + return this.resonanceMap[int64(utils.ToInt32(hid)<<8)+int64(star)] +} + +func (this *configureComp) GetHeroAwakenConfig(hid string, phase int32) *cfg.GameHeroAwakenData { + return this.awakenMap[int64(utils.ToInt32(hid)<<8)+int64(phase)] +} + // 抽卡配置表 -func (this *configureComp) SetHeroDrawConfig() (err error) { +func (this *configureComp) SetHeroDrawConfig() { var ( - v interface{} + v interface{} + err error ) if v, err = this.GetConfigure(hero_drawcard); err == nil { if _configure, ok := v.(*cfg.GameDrawCard); !ok { @@ -140,23 +199,6 @@ func (this *configureComp) GetHeroLevelgrowConfig() (configure *cfg.GameHeroLeve return } -// 获取英雄升星相关配置数据 -func (this *configureComp) GetHeroStarupConfig() (configure *cfg.GameHeroStarup, err error) { - var ( - v interface{} - ok bool - ) - if v, err = this.GetConfigure(hero_starup); err == nil { - if configure, ok = v.(*cfg.GameHeroStarup); !ok { - err = fmt.Errorf("%T no is *cfg.GameHeroStarup", v) - return - } - } else { - err = fmt.Errorf("%T no is *cfg.GameHeroStarup", v) - } - return -} - // 获取英雄升级相关配置数据 func (this *configureComp) GetHeroLevelUpConfig() (configure *cfg.GameHeroLevelup, err error) { var ( @@ -334,25 +376,6 @@ func (this *configureComp) GetHeroSkillMaxLvConfig(skillId uint32) int32 { return 0 } -// 通过英雄配置ID获取共鸣配置信息 -func (this *configureComp) GetHeroResonanceConfig(cardConfigID string) (data *cfg.GameHeroResonanceData, err error) { - var ( - v interface{} - ) - if v, err = this.GetConfigure(hero_resonance); err == nil { - if configure, ok := v.(*cfg.GameHeroResonance); !ok { - err = fmt.Errorf("%T no is *cfg.GameHeroResonance", v) - return - } else { - data = configure.Get(cardConfigID) - } - } else { - err = fmt.Errorf("%T no is *cfg.GameHeroResonance", v) - } - - return -} - func (this *configureComp) GetHeroResonanceRestConfig() (data *cfg.GameComAtnData, err error) { var ( v interface{} @@ -370,19 +393,3 @@ func (this *configureComp) GetHeroResonanceRestConfig() (data *cfg.GameComAtnDat return } -func (this *configureComp) GetHeroAwakenConfig() (configure *cfg.GameHeroAwaken, err error) { - var ( - v interface{} - ok bool - ) - if v, err = this.GetConfigure(hero_awaken); err == nil { - if configure, ok = v.(*cfg.GameHeroAwaken); !ok { - err = fmt.Errorf("%T no is *cfg.GameHeroAwaken", v) - return - } - } else { - err = fmt.Errorf("%T no is *cfg.GameHeroAwaken", v) - } - - return -} diff --git a/modules/hero/hero_test.go b/modules/hero/hero_test.go index 8ca0dc38a..033751cc2 100644 --- a/modules/hero/hero_test.go +++ b/modules/hero/hero_test.go @@ -56,11 +56,10 @@ func (this *TestService) InitSys() { } func TestMain(m *testing.M) { - hero := &pb.DBHero{} - hero.Block = false - hero.Lv = 12 - new := CloneNewHero(hero) - fmt.Printf("%v", new) + currentTime := time.Unix(1637420154, 0) + startTime := time.Date(currentTime.Year(), currentTime.Month(), currentTime.Day(), 0, 0, 0, 0, currentTime.Location()) + fmt.Print(startTime.Unix()) + service = newService( rpcx.SetConfPath("../../bin/conf/worker_1.yaml"), ) diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index e40bc2911..34749c7d8 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -253,8 +253,8 @@ func (this *ModelHero) getHeroList(uid string) []*pb.DBHero { // 设置共鸣能量点数属性 func (this *ModelHero) setEnergyProperty(hero *pb.DBHero) { - resonConfig, err := this.moduleHero.configure.GetHeroResonanceConfig(hero.HeroID) - if err != nil { + resonConfig := this.moduleHero.configure.GetHeroResonanceConfig(hero.HeroID, hero.Star) + if resonConfig == nil { return } EnergyProperty := make(map[string]int32) //副属性 diff --git a/modules/hero/module.go b/modules/hero/module.go index 4a5c07453..8faa13f9e 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -126,10 +126,39 @@ func (this *Hero) UpdateEquipment(session comm.IUserSession, hero *pb.DBHero, eq this.modelHero.setEquipProperty(hero, equip) session.SendMsg("hero", "change", &pb.HeroChangePush{List: list}) + // 随机任务统计 + if hero.SuiteId != 0 || hero.SuiteExtId != 0 { + this.SendRdTask(session) + } return } +func (this *Hero) SendRdTask(session comm.IUserSession) { + equipmap := make(map[int32]map[int32]int32, 0) // k 套装id k1 xx星 v 数量 + list := this.GetHeroList(session.GetUserId()) + for _, v := range list { + if v.SuiteId != 0 || v.SuiteExtId != 0 { + if _, ok := equipmap[v.SuiteId]; !ok { + equipmap[v.SuiteId] = make(map[int32]int32, 0) + } + equipmap[v.SuiteId][v.Suite1Star]++ + } + if v.SuiteExtId != 0 { + if _, ok := equipmap[v.SuiteExtId]; !ok { + equipmap[v.SuiteExtId] = make(map[int32]int32, 0) + } + equipmap[v.SuiteExtId][v.Suite2Star]++ + } + } + + for k, v := range equipmap { + for k1, v1 := range v { + this.ModuleRtask.SendToRtask(session, comm.Rtype46, v1, k1, k) + } + } +} + //英雄列表 func (this *Hero) GetHeroList(uid string) []*pb.DBHero { return this.modelHero.getHeroList(uid) diff --git a/modules/pagoda/api_challenge.go b/modules/pagoda/api_challenge.go index 6658567bb..408dc0d85 100644 --- a/modules/pagoda/api_challenge.go +++ b/modules/pagoda/api_challenge.go @@ -119,7 +119,10 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.PagodaChalleng pagoda.Reward = seasonPagoda.Reward session.SendMsg(string(this.module.GetType()), PagodaChallengeResp, &pb.PagodaChallengeResp{Data: pagoda}) } - this.module.ModuleRtask.SendToRtask(session, comm.Rtype58, 1) - this.module.ModuleRtask.SendToRtask(session, comm.Rtype59, pagoda.PagodaId) + + if req.PagodaType == comm.PagodaType { + this.module.ModuleRtask.SendToRtask(session, comm.Rtype58, 1) + this.module.ModuleRtask.SendToRtask(session, comm.Rtype59, pagoda.PagodaId) + } return } diff --git a/modules/smithy/api_deskskilllv.go b/modules/smithy/api_deskskilllv.go index 0cd464d70..4e185f2ba 100644 --- a/modules/smithy/api_deskskilllv.go +++ b/modules/smithy/api_deskskilllv.go @@ -56,8 +56,17 @@ func (this *apiComp) DeskSkillLv(session comm.IUserSession, req *pb.SmithyDeskSk if n.Int64() < int64(curSkillCfg.Probability) { // 可以升级 // 技能升级成功 _smithy.Skill[req.DeskType] += 1 + _smithy.DeskFloor[req.DeskType] = 0 this.module.modelSmithy.CalculationDeskSkillLv(session.GetUserId(), _smithy) + } else { + _smithy.DeskFloor[req.DeskType] += 1 + if _smithy.DeskFloor[req.DeskType] >= curSkillCfg.Floors { // 触发保底 + _smithy.Skill[req.DeskType] += 1 + _smithy.DeskFloor[req.DeskType] = 0 + this.module.modelSmithy.CalculationDeskSkillLv(session.GetUserId(), _smithy) + + } } } else { code = pb.ErrorCode_GourmetSkillMaxLv diff --git a/modules/smithy/api_getReward.go b/modules/smithy/api_getReward.go index 6747d68a0..474ce7f9a 100644 --- a/modules/smithy/api_getReward.go +++ b/modules/smithy/api_getReward.go @@ -35,11 +35,15 @@ func (this *apiComp) GetReward(session comm.IUserSession, req *pb.SmithyGetRewar if code != pb.ErrorCode_Success { return } + // 随机任务 + this.module.SendRdTask(session, _gourmet.Items) + _gourmet.Items = nil mapData := make(map[string]interface{}, 0) mapData["items"] = nil code = this.module.ModifySmithyData(session.GetUserId(), mapData) } session.SendMsg(string(this.module.GetType()), SmithyGetRewardResp, &pb.SmithyGetRewardResp{Data: _gourmet}) + return } diff --git a/modules/smithy/api_stoveskilllv.go b/modules/smithy/api_stoveskilllv.go index e4f3fcd0c..b408808f9 100644 --- a/modules/smithy/api_stoveskilllv.go +++ b/modules/smithy/api_stoveskilllv.go @@ -16,7 +16,7 @@ func (this *apiComp) StoveSkillLvCheck(session comm.IUserSession, req *pb.Smithy } func (this *apiComp) StoveSkillLv(session comm.IUserSession, req *pb.SmithyStoveSkillLvReq) (code pb.ErrorCode, dat proto.Message) { - + var bLevelUp bool code = this.StoveSkillLvCheck(session, req) if code != pb.ErrorCode_Success { return // 参数校验失败直接返回 @@ -46,11 +46,18 @@ func (this *apiComp) StoveSkillLv(session comm.IUserSession, req *pb.SmithyStove n, _ := rand.Int(rand.Reader, big.NewInt(100)) if n.Int64() < int64(curLvData.Probability) { // 可以升级 - // 技能升级成功 + bLevelUp = true + } else { // 升级失败了 记录 + _smithy.StoveFloor += 1 + if curLvData.Floors >= _smithy.StoveFloor { // 触发保底 + bLevelUp = true + } + } + if bLevelUp { + _smithy.StoveFloor = 0 // 清理保底数据 _smithy.StoveLv += 1 this.module.modelSmithy.CalculationStoveSkillLv(session.GetUserId(), _smithy, _smithy.StoveLv) } - session.SendMsg(string(this.module.GetType()), SmithyDeskSkillLvResp, &pb.SmithyDeskSkillLvResp{Data: _smithy}) return } diff --git a/modules/smithy/comp_configure.go b/modules/smithy/comp_configure.go index a526432a4..52eed0fd3 100644 --- a/modules/smithy/comp_configure.go +++ b/modules/smithy/comp_configure.go @@ -1,6 +1,7 @@ package smithy import ( + "fmt" "go_dreamfactory/lego/core" "go_dreamfactory/lego/sys/log" "go_dreamfactory/modules" @@ -12,11 +13,13 @@ import ( const ( game_smithy = "game_smithy.json" game_smithystove = "game_smithystove.json" + game_equip = "game_equip.json" //装备信息表 ) ///配置管理基础组件 type configureComp struct { modules.MCompConfigure + module *Smithy hlock sync.RWMutex _smithyMap map[int64]*cfg.GameSmithyData } @@ -25,6 +28,7 @@ type configureComp struct { func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { err = this.MCompConfigure.Init(service, module, comp, options) this._smithyMap = make(map[int64]*cfg.GameSmithyData, 0) + this.module = module.(*Smithy) configure.RegisterConfigure(game_smithy, cfg.NewGameSmithy, func() { if v, err := this.GetConfigure(game_smithy); err == nil { if configure, ok := v.(*cfg.GameSmithy); ok { @@ -40,6 +44,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp return }) err = this.LoadConfigure(game_smithystove, cfg.NewGameSmithyStove) + err = this.LoadConfigure(game_equip, cfg.NewGameEquip) return } @@ -90,3 +95,21 @@ func (this *configureComp) LoadMultiConfigure(confs map[string]interface{}) (err func (this *configureComp) GetConfigure(name string) (v interface{}, err error) { return configure.GetConfigure(name) } + +func (this *configureComp) GetEquipmentConfigureById(equipmentId string) (configure *cfg.GameEquipData, err error) { + var ( + v interface{} + ok bool + ) + if v, err = this.GetConfigure(game_equip); err != nil { + this.module.Errorf("err:%v", err) + return + } else { + if configure, ok = v.(*cfg.GameEquip).GetDataMap()[equipmentId]; !ok { + err = fmt.Errorf("EquipmentConfigure not found:%s ", equipmentId) + this.module.Errorf("err:%v", err) + return + } + } + return +} diff --git a/modules/smithy/model_smithy.go b/modules/smithy/model_smithy.go index c7508110c..fc9c0cb04 100644 --- a/modules/smithy/model_smithy.go +++ b/modules/smithy/model_smithy.go @@ -39,10 +39,12 @@ func (this *modelSmithy) getSmithyList(uid string) (result *pb.DBSmithy, err err result.Id = primitive.NewObjectID().Hex() result.Uid = uid result.Skill = make(map[int32]int32, 0) - result.StoveLv = 1 // storv 等级默认1级 + result.StoveLv = 1 // storv 等级默认1级 + result.DeskFloor = make(map[int32]int32, 0) mapType := this.module.configure.GetSmithyTypeConfigData() // 找类型 for key := range mapType { result.Skill[key] = 1 + result.DeskFloor[key] = 0 } if err = this.Add(uid, result); err != nil { @@ -59,96 +61,125 @@ func (this *modelSmithy) getSmithyList(uid string) (result *pb.DBSmithy, err err func (this *modelSmithy) modifySmithyDataByObjId(uid string, data map[string]interface{}) error { return this.Change(uid, data) } - -// 计算订单信息 -func (this *modelSmithy) CalculationSmithy(uid string, Smithy *pb.DBSmithy) { +func (this *modelSmithy) CalculationSmithy(uid string, smithy *pb.DBSmithy) { var ( - bCooking bool - costTime int32 - curTime int32 + bCooking bool + costTime int32 + curTime int32 + szTime map[int32]int32 // k 台子类型 v订单耗时 + zeroTime int64 // 订单开始的时间对应第二天0点时间 + nextDay bool // 是否跨天了 + nextDayTime int32 // 跨天累计时间 ) - mapData := make(map[string]interface{}, 0) - if Smithy.Clang != nil && Smithy.Clang.ETime > 0 { - costTime = int32(time.Now().Unix() - Smithy.Clang.ETime) // 当前过去的时间 + szTime = make(map[int32]int32, 0) + defer this.module.ModifySmithyData(uid, mapData) + + // 记录每个食材耗时 + for k, v := range smithy.Skill { + // 计算出需要的时间 + _skillCfg := this.module.configure.GetSmithyStoveConfigData(v) // 技能配置表 + szTime[k] = _skillCfg.Time + } + if smithy.Clang != nil && smithy.Clang.ETime > 0 { + zeroTime = utils.GetZeroTime(smithy.Clang.STime) // 获取订单开始时间当天的0点 + costTime = int32(time.Now().Unix() - smithy.Clang.ETime) // 当前过去的时间 if costTime < 0 { // 没有完成 不做处理 return } } - if Smithy.Clang == nil { - Smithy.Clang = &pb.Clang{} - } - for _, order := range Smithy.Orders { + + for _, order := range smithy.Orders { if order.Count == 0 { continue } - foodtype := order.DeskType - // 获取技能等级 - skillLv := Smithy.Skill[foodtype] - + desktype := order.DeskType + skillLv := smithy.Skill[desktype] // 获取技能等级 // 计算出需要的时间 - _skillCfg := this.module.configure.GetSmithyStoveConfigData(skillLv) // 技能配置表 - _Smithycfg := this.module.configure.GetSmithyConfigData(foodtype, skillLv) // 美食家配置表 - for i := 0; i < int(order.Count); i++ { - curTime += _skillCfg.Time - // 判断是不是第二天 - if Smithy.Clang.ETime == 0 { - Smithy.Clang.ETime = time.Now().Unix() - } - if !utils.IsToday(Smithy.Clang.ETime + int64(curTime)) { // 判断是不是今天 - // 跨天了 - Smithy.Clang.ETime = Smithy.Clang.ETime + int64(curTime) // 设置下单的时间 - Smithy.Clang.STime = Smithy.Clang.ETime - int64(curTime) // 设置下单的时间 - Smithy.Ctime = Smithy.Clang.ETime // 设置创建订单时间 - Smithy.OrderCostTime = 0 // 清空当天的订单时长 - } + + _smithycfg := this.module.configure.GetSmithyConfigData(desktype, skillLv) // 美食家配置表 + iCount := int(order.Count) + for i := 0; i < iCount; i++ { + curTime += szTime[order.DeskType] order.Count-- + if order.Count == 0 { + order.NeedTime = 0 + } + order.NeedTime = order.Count * szTime[order.DeskType] + if smithy.Clang == nil { + if zeroTime == 0 { + zeroTime = utils.GetZeroTime(time.Now().Unix()) + } + smithy.Clang = &pb.Clang{} + smithy.Clang.STime = time.Now().Unix() + smithy.Clang.ETime = time.Now().Unix() + int64(szTime[order.DeskType]) + } else { + smithy.Clang.STime += int64(szTime[order.DeskType]) + smithy.Clang.ETime += int64(szTime[order.DeskType]) + } + smithy.Clang.DeskType = order.DeskType - Smithy.Items = this.module.configure.GetMultipleDropReward(1, _Smithycfg.Drop, Smithy.Items) // 获取掉落奖励 - - mapData["items"] = Smithy.Items + // 判断订单是否跨天 + if smithy.Clang.ETime >= zeroTime && !nextDay { + smithy.Ctime = zeroTime // 设置 + smithy.OrderCostTime = 0 + nextDay = true + } + if nextDay { + nextDayTime += szTime[order.DeskType] + } if curTime > costTime { - Smithy.OrderCostTime += int32(curTime - costTime) // 转时间戳 - eTimd := time.Now().Unix() + int64(curTime-costTime) - Smithy.Clang.DeskType = order.DeskType - Smithy.Clang.ETime = eTimd - Smithy.Clang.STime = time.Now().Unix() - int64(curTime-costTime) + smithy.Clang.DeskType = order.DeskType + smithy.Clang.ETime = time.Now().Unix() + int64(curTime-costTime) + smithy.Clang.STime = smithy.Clang.ETime - int64(szTime[order.DeskType]) bCooking = true // 记录下订单时间 - Smithy.Ctime = time.Now().Unix() - mapData["ctime"] = Smithy.Ctime + smithy.Ctime = time.Now().Unix() + mapData["ctime"] = smithy.Ctime break } - Smithy.OrderCostTime += curTime + smithy.Items = this.module.configure.GetMultipleDropReward(_smithycfg.Using, _smithycfg.Drop, smithy.Items) // 获取掉落奖励 } + if bCooking { // 分配了正在製作的食物 break } } - if !bCooking { // 经过计算没有烹饪食物的时候 - Smithy.Clang = nil - } - sz := make([]*pb.OrderClang, 0) - for _, v := range Smithy.Orders { - if v.Count != 0 { - sz = append(sz, v) + if nextDay { + smithy.OrderCostTime += nextDayTime + for _, order := range smithy.Orders { + if order.Count == 0 { + continue + } + smithy.OrderCostTime += szTime[order.DeskType] * order.Count } } - Smithy.Orders = sz + + if utils.GetZeroTime(smithy.Ctime) <= time.Now().Unix() { + smithy.OrderCostTime = 0 + } + + if smithy.Clang != nil && smithy.Clang.ETime <= time.Now().Unix() { // 当前时间超过正在做的时间 + desktype := smithy.Clang.DeskType + skillLv := smithy.Skill[desktype] // 获取技能等级 + _smithycfg := this.module.configure.GetSmithyConfigData(desktype, skillLv) + smithy.Items = this.module.configure.GetMultipleDropReward(_smithycfg.Using, _smithycfg.Drop, smithy.Items) + smithy.Clang = nil + } // 保存信息 - mapData["orders"] = Smithy.Orders - mapData["orderCostTime"] = Smithy.OrderCostTime - mapData["clang"] = Smithy.Clang // 正在做的 - this.module.ModifySmithyData(uid, mapData) + mapData["items"] = smithy.Items + mapData["orders"] = smithy.Orders + mapData["orderCostTime"] = smithy.OrderCostTime + mapData["clang"] = smithy.Clang // 正在做的 } -// 技能升级 重计算时间消耗 func (this *modelSmithy) CalculationDeskSkillLv(uid string, Smithy *pb.DBSmithy) { mapData := make(map[string]interface{}, 0) mapData["skill"] = Smithy.Skill + mapData["deskFloor"] = Smithy.DeskFloor this.module.ModifySmithyData(uid, mapData) } @@ -167,5 +198,6 @@ func (this *modelSmithy) CalculationStoveSkillLv(uid string, Smithy *pb.DBSmithy } } mapData["stoveLv"] = Smithy.StoveLv + mapData["deskFloor"] = Smithy.DeskFloor this.module.ModifySmithyData(uid, mapData) } diff --git a/modules/smithy/module.go b/modules/smithy/module.go index 4071e1ace..9944aaa94 100644 --- a/modules/smithy/module.go +++ b/modules/smithy/module.go @@ -48,3 +48,17 @@ func (this *Smithy) ModifySmithyData(uid string, data map[string]interface{}) (c } return } + +func (this *Smithy) SendRdTask(session comm.IUserSession, Items []*pb.UserAssets) { + var equip map[int32]int32 // key xingji value 数量 + equip = make(map[int32]int32, 0) + for _, v := range Items { + cfg, err := this.configure.GetEquipmentConfigureById(v.T) + if err == nil { + equip[cfg.Star]++ + } + } + for k, v := range equip { + this.ModuleRtask.SendToRtask(session, comm.Rtype51, v, k) + } +} diff --git a/modules/viking/api_challenge.go b/modules/viking/api_challenge.go index 5f6cd82df..72c46f67c 100644 --- a/modules/viking/api_challenge.go +++ b/modules/viking/api_challenge.go @@ -41,18 +41,20 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.VikingChalleng code = pb.ErrorCode_ConfigNoFound return } - if value, ok := viking.Boos[req.BossType]; !ok { // 类型校验 - code = pb.ErrorCode_VikingBoosType - return - } else { - if value < req.Difficulty { - if value+1 != req.Difficulty { - code = pb.ErrorCode_VikingLvErr - return + // 类型校验 + boosData := this.configure.GetVikingBossConfigData(req.BossType, req.Difficulty) + if boosData != nil { + if value, ok := viking.Boos[req.BossType]; !ok { // 类型校验 + viking.Boos[req.BossType] = 0 + if value < req.Difficulty { + if value+1 != req.Difficulty { + code = pb.ErrorCode_VikingLvErr + return + } + newChallenge = true + } else { // 挑战历史 + newChallenge = false } - newChallenge = true - } else { // 挑战历史 - newChallenge = false } } diff --git a/modules/viking/api_getlist.go b/modules/viking/api_getlist.go index a9d17f20f..426286715 100644 --- a/modules/viking/api_getlist.go +++ b/modules/viking/api_getlist.go @@ -6,7 +6,6 @@ import ( "go_dreamfactory/utils" "time" - "go.mongodb.org/mongo-driver/bson/primitive" "google.golang.org/protobuf/proto" ) @@ -22,21 +21,13 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.VikingGetListReq if code != pb.ErrorCode_Success { return // 参数校验失败直接返回 } + list, err := this.module.modelViking.getVikingList(session.GetUserId()) if err != nil { code = pb.ErrorCode_DBError return } - if list == nil { - list.Id = primitive.NewObjectID().Hex() - list.Uid = session.GetUserId() - list.Boos = make(map[int32]int32) - _mapType := this.configure.GetVikingBossTypeConfigData() - for k := range _mapType { - list.Boos[k] = 0 // 默认难度0 - } - this.module.modelViking.Add(session.GetUserId(), list) // 写缓存 - } + // 校验 是不是当天 if !utils.IsToday(list.CTime) { list.CTime = time.Now().Unix() diff --git a/modules/viking/model_viking.go b/modules/viking/model_viking.go index b59578a4d..f9f12ca4d 100644 --- a/modules/viking/model_viking.go +++ b/modules/viking/model_viking.go @@ -3,10 +3,11 @@ package viking import ( "go_dreamfactory/comm" "go_dreamfactory/lego/core" - "go_dreamfactory/lego/sys/redis" + "go_dreamfactory/lego/sys/mgo" "go_dreamfactory/modules" "go_dreamfactory/pb" + "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/x/bsonx" ) @@ -28,10 +29,19 @@ func (this *modelViking) Init(service core.IService, module core.IModule, comp c } func (this *modelViking) getVikingList(uid string) (result *pb.DBViking, err error) { - result = &pb.DBViking{} - if err = this.Get(uid, result); err != nil && redis.RedisNil != err { + result = &pb.DBViking{ + Id: primitive.NewObjectID().Hex(), + Uid: uid, + Boos: make(map[int32]int32), + ChallengeTime: make(map[int32]int32), + } + if err = this.Get(uid, result); err != nil && mgo.MongodbNil != err { + return } + if mgo.MongodbNil == err { + this.module.modelViking.Add(uid, result) + } err = nil return result, err } diff --git a/pb/smithy_db.pb.go b/pb/smithy_db.pb.go index b9999ee2a..0226168ca 100644 --- a/pb/smithy_db.pb.go +++ b/pb/smithy_db.pb.go @@ -161,7 +161,7 @@ type DBSmithy struct { StoveLv int32 `protobuf:"varint,7,opt,name=stoveLv,proto3" json:"stoveLv" bson:"stoveLv"` //炉子等级 OrderCostTime int32 `protobuf:"varint,8,opt,name=orderCostTime,proto3" json:"orderCostTime" bson:"orderCostTime"` //订单消耗的时常 Ctime int64 `protobuf:"varint,9,opt,name=ctime,proto3" json:"ctime"` // 订单创建时间 - DeskFloor int32 `protobuf:"varint,10,opt,name=deskFloor,proto3" json:"deskFloor"` //@go_tags(`bson:"deskFloor"`)台子保底 + DeskFloor map[int32]int32 `protobuf:"bytes,10,rep,name=deskFloor,proto3" json:"deskFloor" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` //@go_tags(`bson:"deskFloor"`)台子保底 StoveFloor int32 `protobuf:"varint,11,opt,name=stoveFloor,proto3" json:"stoveFloor" bson:"stoveFloor"` //炉子保底 } @@ -260,11 +260,11 @@ func (x *DBSmithy) GetCtime() int64 { return 0 } -func (x *DBSmithy) GetDeskFloor() int32 { +func (x *DBSmithy) GetDeskFloor() map[int32]int32 { if x != nil { return x.DeskFloor } - return 0 + return nil } func (x *DBSmithy) GetStoveFloor() int32 { @@ -290,7 +290,7 @@ var file_smithy_smithy_db_proto_rawDesc = []byte{ 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x65, 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x6e, 0x65, 0x65, 0x64, 0x54, 0x69, 0x6d, - 0x65, 0x22, 0x8c, 0x03, 0x0a, 0x08, 0x44, 0x42, 0x53, 0x6d, 0x69, 0x74, 0x68, 0x79, 0x12, 0x0e, + 0x65, 0x22, 0xe4, 0x03, 0x0a, 0x08, 0x44, 0x42, 0x53, 0x6d, 0x69, 0x74, 0x68, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x05, 0x63, 0x6c, 0x61, 0x6e, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, @@ -307,15 +307,21 @@ var file_smithy_smithy_db_proto_rawDesc = []byte{ 0x6f, 0x72, 0x64, 0x65, 0x72, 0x43, 0x6f, 0x73, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x43, 0x6f, 0x73, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x64, 0x65, 0x73, 0x6b, - 0x46, 0x6c, 0x6f, 0x6f, 0x72, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x64, 0x65, 0x73, - 0x6b, 0x46, 0x6c, 0x6f, 0x6f, 0x72, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x74, 0x6f, 0x76, 0x65, 0x46, - 0x6c, 0x6f, 0x6f, 0x72, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x6f, 0x76, - 0x65, 0x46, 0x6c, 0x6f, 0x6f, 0x72, 0x1a, 0x38, 0x0a, 0x0a, 0x53, 0x6b, 0x69, 0x6c, 0x6c, 0x45, - 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, - 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x03, 0x52, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x36, 0x0a, 0x09, 0x64, 0x65, 0x73, 0x6b, + 0x46, 0x6c, 0x6f, 0x6f, 0x72, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x44, 0x42, + 0x53, 0x6d, 0x69, 0x74, 0x68, 0x79, 0x2e, 0x44, 0x65, 0x73, 0x6b, 0x46, 0x6c, 0x6f, 0x6f, 0x72, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x64, 0x65, 0x73, 0x6b, 0x46, 0x6c, 0x6f, 0x6f, 0x72, + 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x74, 0x6f, 0x76, 0x65, 0x46, 0x6c, 0x6f, 0x6f, 0x72, 0x18, 0x0b, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x6f, 0x76, 0x65, 0x46, 0x6c, 0x6f, 0x6f, 0x72, + 0x1a, 0x38, 0x0a, 0x0a, 0x53, 0x6b, 0x69, 0x6c, 0x6c, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, + 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, + 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3c, 0x0a, 0x0e, 0x44, 0x65, + 0x73, 0x6b, 0x46, 0x6c, 0x6f, 0x6f, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, + 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, + 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -330,24 +336,26 @@ func file_smithy_smithy_db_proto_rawDescGZIP() []byte { return file_smithy_smithy_db_proto_rawDescData } -var file_smithy_smithy_db_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_smithy_smithy_db_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_smithy_smithy_db_proto_goTypes = []interface{}{ (*Clang)(nil), // 0: Clang (*OrderClang)(nil), // 1: OrderClang (*DBSmithy)(nil), // 2: DBSmithy nil, // 3: DBSmithy.SkillEntry - (*UserAssets)(nil), // 4: UserAssets + nil, // 4: DBSmithy.DeskFloorEntry + (*UserAssets)(nil), // 5: UserAssets } var file_smithy_smithy_db_proto_depIdxs = []int32{ 0, // 0: DBSmithy.clang:type_name -> Clang 1, // 1: DBSmithy.orders:type_name -> OrderClang - 4, // 2: DBSmithy.items:type_name -> UserAssets + 5, // 2: DBSmithy.items:type_name -> UserAssets 3, // 3: DBSmithy.skill:type_name -> DBSmithy.SkillEntry - 4, // [4:4] is the sub-list for method output_type - 4, // [4:4] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name + 4, // 4: DBSmithy.deskFloor:type_name -> DBSmithy.DeskFloorEntry + 5, // [5:5] is the sub-list for method output_type + 5, // [5:5] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name } func init() { file_smithy_smithy_db_proto_init() } @@ -400,7 +408,7 @@ func file_smithy_smithy_db_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_smithy_smithy_db_proto_rawDesc, NumEnums: 0, - NumMessages: 4, + NumMessages: 5, NumExtensions: 0, NumServices: 0, }, diff --git a/utils/time.go b/utils/time.go index 5c4a22562..05e69b2b5 100644 --- a/utils/time.go +++ b/utils/time.go @@ -1,6 +1,8 @@ package utils -import "time" +import ( + "time" +) // 判断时间点处于今天 func IsToday(d int64) bool { @@ -19,12 +21,10 @@ func IsAfterWeek(d int64) bool { return now.Sub(tt) >= time.Hour*24*7 } -// 获取0点时间戳 -func GetZeroTime() int64 { - - currentTime := time.Now() - +// 获取当前时间戳下一天0点时间戳 +func GetZeroTime(curTime int64) int64 { + currentTime := time.Unix(curTime, 0) startTime := time.Date(currentTime.Year(), currentTime.Month(), currentTime.Day(), 0, 0, 0, 0, currentTime.Location()) - return startTime.Unix() + return startTime.Unix() + 86400 //3600*24 }