Merge branch 'meixiongfeng' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev

This commit is contained in:
meixiongfeng 2022-09-02 17:24:23 +08:00
commit 882a382298
21 changed files with 375 additions and 246 deletions

View File

@ -71,9 +71,9 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet)
costTime int32 costTime int32
curTime int32 curTime int32
szTime map[int32]int32 szTime map[int32]int32
zTime int64 zeroTime int64 // 订单开始的时间对应第二天0点时间
nextDay bool nextDay bool // 是否跨天了
nextDayTime int32 nextDayTime int32 // 跨天累计时间
) )
mapData := make(map[string]interface{}, 0) mapData := make(map[string]interface{}, 0)
szTime = make(map[int32]int32, 0) szTime = make(map[int32]int32, 0)
@ -92,12 +92,8 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet)
} }
szTime[k] = _time szTime[k] = _time
} }
if !utils.IsToday(gourmet.Ctime) {
gourmet.Ctime = time.Now().Unix()
zTime = utils.GetZeroTime()
}
if gourmet.CookingFood != nil && gourmet.CookingFood.ETime > 0 { if gourmet.CookingFood != nil && gourmet.CookingFood.ETime > 0 {
zeroTime = utils.GetZeroTime(gourmet.CookingFood.STime) // 获取订单开始时间当天的0点
costTime = int32(time.Now().Unix() - gourmet.CookingFood.ETime) // 当前过去的时间 costTime = int32(time.Now().Unix() - gourmet.CookingFood.ETime) // 当前过去的时间
if costTime < 0 { // 没有完成 不做处理 if costTime < 0 { // 没有完成 不做处理
return return
@ -121,14 +117,21 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet)
} }
order.CookTime = order.FoodCount * szTime[order.FoodType] order.CookTime = order.FoodCount * szTime[order.FoodType]
if gourmet.CookingFood == nil { if gourmet.CookingFood == nil {
if zeroTime == 0 {
zeroTime = utils.GetZeroTime(time.Now().Unix())
}
gourmet.CookingFood = &pb.Cooking{} gourmet.CookingFood = &pb.Cooking{}
gourmet.CookingFood.STime = time.Now().Unix() 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.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 gourmet.OrderCostTime = 0
nextDay = true nextDay = true
} }
@ -163,6 +166,11 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet)
gourmet.OrderCostTime += szTime[order.FoodType] * order.FoodCount 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() { // 当前时间超过正在做的时间 if gourmet.CookingFood != nil && gourmet.CookingFood.ETime <= time.Now().Unix() { // 当前时间超过正在做的时间
foodtype := gourmet.CookingFood.FoodType foodtype := gourmet.CookingFood.FoodType
skillLv := gourmet.Skill[foodtype] // 获取技能等级 skillLv := gourmet.Skill[foodtype] // 获取技能等级

View File

@ -37,18 +37,13 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
return return
} }
AwakenConfig, err1 := this.module.configure.GetHeroAwakenConfig() awakenData = this.module.configure.GetHeroAwakenConfig(_hero.HeroID, _hero.JuexingLv)
if err1 != nil { if awakenData == nil {
code = pb.ErrorCode_ConfigNoFound code = pb.ErrorCode_ConfigNoFound
return return
} }
for _, v := range AwakenConfig.GetDataMap() { nextAwaken := this.module.configure.GetHeroAwakenConfig(_hero.HeroID, _hero.JuexingLv+1)
if v.Hid == _hero.HeroID && v.Phase == _hero.JuexingLv+1 { if nextAwaken == nil {
awakenData = v
break
}
}
if awakenData == nil {
code = pb.ErrorCode_HeroMaxAwaken // 达到最大觉醒等级 code = pb.ErrorCode_HeroMaxAwaken // 达到最大觉醒等级
return return
} }
@ -87,10 +82,10 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
"isOverlying": false, "isOverlying": false,
} }
// 保存数据 // 保存数据
err1 = this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap) err := this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap)
if err1 != nil { if err != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
this.module.Errorf("update hero skill failed:%v", err1) this.module.Errorf("update hero skill failed:%v", err)
return return
} }
} else { // 加属性 } else { // 加属性
@ -107,10 +102,10 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
"isOverlying": false, "isOverlying": false,
} }
// 保存数据 // 保存数据
err1 = this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap) err = this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap)
if err1 != nil { if err != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
this.module.Errorf("update hero skill failed:%v", err1) this.module.Errorf("update hero skill failed:%v", err)
return return
} }
} }
@ -126,6 +121,14 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
cfg := this.module.configure.GetHero(_hero.HeroID) cfg := this.module.configure.GetHero(_hero.HeroID)
if cfg != nil { if cfg != nil {
this.module.ModuleRtask.SendToRtask(session, comm.Rtype36, 1, cfg.Color, cfg.Job, cfg.Race, _hero.JuexingLv) 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 return
} }

View File

@ -44,8 +44,8 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR
} }
// 共鸣次数判断 // 共鸣次数判断
resonConfig, errr := this.module.configure.GetHeroResonanceConfig(_hero.HeroID) resonConfig := this.module.configure.GetHeroResonanceConfig(_hero.HeroID, _hero.Star)
if errr != nil { if resonConfig == nil {
code = pb.ErrorCode_ConfigNoFound code = pb.ErrorCode_ConfigNoFound
return return
} }
@ -84,12 +84,6 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR
ChangeList = append(ChangeList, _costMaphero[k]) 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) code = this.module.ConsumeRes(session, resonConfig.Need, true)
if code != pb.ErrorCode_Success { if code != pb.ErrorCode_Success {
return return
@ -108,9 +102,9 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR
"isOverlying": false, "isOverlying": false,
"sameCount": 1, "sameCount": 1,
} }
err1 = this.module.modelHero.ChangeList(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息 err := this.module.modelHero.ChangeList(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
if err1 != nil { if err != nil {
this.module.Errorf("update hero skill failed:%v", err1) this.module.Errorf("update hero skill failed:%v", err)
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return 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)
this.module.ModuleRtask.SendToRtask(session, comm.Rtype39, 1, 1) this.module.ModuleRtask.SendToRtask(session, comm.Rtype40, 1, 1)
return return
} }

View File

@ -39,8 +39,8 @@ func (this *apiComp) ResonanceReset(session comm.IUserSession, req *pb.HeroReson
} }
// 共鸣次数判断 // 共鸣次数判断
resonConfig, errr := this.module.configure.GetHeroResonanceConfig(_hero.HeroID) resonConfig := this.module.configure.GetHeroResonanceConfig(_hero.HeroID, _hero.Star)
if errr != nil { if resonConfig == nil {
code = pb.ErrorCode_ConfigNoFound code = pb.ErrorCode_ConfigNoFound
return return
} }

View File

@ -51,31 +51,17 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, req *pb.HeroStr
} }
// 校验指定英雄 // 校验指定英雄
tagHeroConfig, err1 := this.module.configure.GetHeroStarupConfig() tagHeroConfig := this.module.configure.GetHeroStarupConfig(_hero.HeroID, _hero.Star)
if err1 != nil { if tagHeroConfig == nil {
code = pb.ErrorCode_ReqParameterError code = pb.ErrorCode_ReqParameterError
return return
} }
nextHeroConfig := this.module.configure.GetHeroStarupConfig(_hero.HeroID, _hero.Star+1)
for _, value := range tagHeroConfig.GetDataList() { if nextHeroConfig == nil {
if _hero.HeroID == value.Id && _hero.Star == value.Star { code = pb.ErrorCode_HeroMaxStarLv
// 校验等级
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 //升星条件不满足
return return
} }
// 优先校验数量对不对 // 优先校验数量对不对
if target.Needheronum != costNeedHeroCount || target.Needracenum != costRaceHeroCount { if target.Needheronum != costNeedHeroCount || target.Needracenum != costRaceHeroCount {
code = pb.ErrorCode_ReqParameterError 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}) this.module.ModuleTask.SendToTask(session, comm.TaskTypeUpHeroStar, &pb.TaskParam{First: _hero.Star})
// 保存数据 // 保存数据
err1 = this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap) err := this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap)
if err1 != nil { if err != nil {
code = pb.ErrorCode_DBError 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) // 重新计算属性 this.module.modelHero.ChangeHeroProperty(session, _hero) // 重新计算属性

View File

@ -7,6 +7,7 @@ import (
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/utils"
) )
const ( const (
@ -31,6 +32,9 @@ type configureComp struct {
modules.MCompConfigure modules.MCompConfigure
drawCardCfg map[string]map[int32][]*cfg.GameDrawCardData // 第一个key 卡池id 第二个key 星级 drawCardCfg map[string]map[int32][]*cfg.GameDrawCardData // 第一个key 卡池id 第二个key 星级
//map["base_pool1"]map[3]*cfg.Game_drawCardData //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, new_hero: cfg.NewGameHero,
hero_stargrow: cfg.NewGameHeroStargrow, hero_stargrow: cfg.NewGameHeroStargrow,
hero_levelgrow: cfg.NewGameHeroLevelgrow, hero_levelgrow: cfg.NewGameHeroLevelgrow,
hero_starup: cfg.NewGameHeroStarup,
hero_levelup: cfg.NewGameHeroLevelup, hero_levelup: cfg.NewGameHeroLevelup,
hero_exp: cfg.NewGameHeroExp, hero_exp: cfg.NewGameHeroExp,
hero_skillup: cfg.NewGameHeroSkillLevel, hero_skillup: cfg.NewGameHeroSkillLevel,
game_skillatk: cfg.NewGameSkillAtk, game_skillatk: cfg.NewGameSkillAtk,
hero_resonance: cfg.NewGameHeroResonance,
hero_comatn: cfg.NewGameComAtn, hero_comatn: cfg.NewGameComAtn,
hero_awaken: cfg.NewGameHeroAwaken,
hero_drawcard: cfg.NewGameDrawCard, hero_drawcard: cfg.NewGameDrawCard,
}) })
this.drawCardCfg = make(map[string]map[int32][]*cfg.GameDrawCardData, 0) this.drawCardCfg = make(map[string]map[int32][]*cfg.GameDrawCardData, 0)
configure.RegisterConfigure(hero_drawcard, cfg.NewGameDrawCard, func() { configure.RegisterConfigure(hero_drawcard, cfg.NewGameDrawCard, this.SetHeroDrawConfig)
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 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 ( var (
v interface{} v interface{}
err error
) )
if v, err = this.GetConfigure(hero_drawcard); err == nil { if v, err = this.GetConfigure(hero_drawcard); err == nil {
if _configure, ok := v.(*cfg.GameDrawCard); !ok { if _configure, ok := v.(*cfg.GameDrawCard); !ok {
@ -140,23 +199,6 @@ func (this *configureComp) GetHeroLevelgrowConfig() (configure *cfg.GameHeroLeve
return 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) { func (this *configureComp) GetHeroLevelUpConfig() (configure *cfg.GameHeroLevelup, err error) {
var ( var (
@ -334,25 +376,6 @@ func (this *configureComp) GetHeroSkillMaxLvConfig(skillId uint32) int32 {
return 0 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) { func (this *configureComp) GetHeroResonanceRestConfig() (data *cfg.GameComAtnData, err error) {
var ( var (
v interface{} v interface{}
@ -370,19 +393,3 @@ func (this *configureComp) GetHeroResonanceRestConfig() (data *cfg.GameComAtnDat
return 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
}

View File

@ -56,11 +56,10 @@ func (this *TestService) InitSys() {
} }
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
hero := &pb.DBHero{} currentTime := time.Unix(1637420154, 0)
hero.Block = false startTime := time.Date(currentTime.Year(), currentTime.Month(), currentTime.Day(), 0, 0, 0, 0, currentTime.Location())
hero.Lv = 12 fmt.Print(startTime.Unix())
new := CloneNewHero(hero)
fmt.Printf("%v", new)
service = newService( service = newService(
rpcx.SetConfPath("../../bin/conf/worker_1.yaml"), rpcx.SetConfPath("../../bin/conf/worker_1.yaml"),
) )

View File

@ -253,8 +253,8 @@ func (this *ModelHero) getHeroList(uid string) []*pb.DBHero {
// 设置共鸣能量点数属性 // 设置共鸣能量点数属性
func (this *ModelHero) setEnergyProperty(hero *pb.DBHero) { func (this *ModelHero) setEnergyProperty(hero *pb.DBHero) {
resonConfig, err := this.moduleHero.configure.GetHeroResonanceConfig(hero.HeroID) resonConfig := this.moduleHero.configure.GetHeroResonanceConfig(hero.HeroID, hero.Star)
if err != nil { if resonConfig == nil {
return return
} }
EnergyProperty := make(map[string]int32) //副属性 EnergyProperty := make(map[string]int32) //副属性

View File

@ -126,10 +126,39 @@ func (this *Hero) UpdateEquipment(session comm.IUserSession, hero *pb.DBHero, eq
this.modelHero.setEquipProperty(hero, equip) this.modelHero.setEquipProperty(hero, equip)
session.SendMsg("hero", "change", &pb.HeroChangePush{List: list}) session.SendMsg("hero", "change", &pb.HeroChangePush{List: list})
// 随机任务统计
if hero.SuiteId != 0 || hero.SuiteExtId != 0 {
this.SendRdTask(session)
}
return 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 { func (this *Hero) GetHeroList(uid string) []*pb.DBHero {
return this.modelHero.getHeroList(uid) return this.modelHero.getHeroList(uid)

View File

@ -119,7 +119,10 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.PagodaChalleng
pagoda.Reward = seasonPagoda.Reward pagoda.Reward = seasonPagoda.Reward
session.SendMsg(string(this.module.GetType()), PagodaChallengeResp, &pb.PagodaChallengeResp{Data: pagoda}) 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 return
} }

View File

@ -56,8 +56,17 @@ func (this *apiComp) DeskSkillLv(session comm.IUserSession, req *pb.SmithyDeskSk
if n.Int64() < int64(curSkillCfg.Probability) { // 可以升级 if n.Int64() < int64(curSkillCfg.Probability) { // 可以升级
// 技能升级成功 // 技能升级成功
_smithy.Skill[req.DeskType] += 1 _smithy.Skill[req.DeskType] += 1
_smithy.DeskFloor[req.DeskType] = 0
this.module.modelSmithy.CalculationDeskSkillLv(session.GetUserId(), _smithy) 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 { } else {
code = pb.ErrorCode_GourmetSkillMaxLv code = pb.ErrorCode_GourmetSkillMaxLv

View File

@ -35,11 +35,15 @@ func (this *apiComp) GetReward(session comm.IUserSession, req *pb.SmithyGetRewar
if code != pb.ErrorCode_Success { if code != pb.ErrorCode_Success {
return return
} }
// 随机任务
this.module.SendRdTask(session, _gourmet.Items)
_gourmet.Items = nil _gourmet.Items = nil
mapData := make(map[string]interface{}, 0) mapData := make(map[string]interface{}, 0)
mapData["items"] = nil mapData["items"] = nil
code = this.module.ModifySmithyData(session.GetUserId(), mapData) code = this.module.ModifySmithyData(session.GetUserId(), mapData)
} }
session.SendMsg(string(this.module.GetType()), SmithyGetRewardResp, &pb.SmithyGetRewardResp{Data: _gourmet}) session.SendMsg(string(this.module.GetType()), SmithyGetRewardResp, &pb.SmithyGetRewardResp{Data: _gourmet})
return return
} }

View File

@ -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) { func (this *apiComp) StoveSkillLv(session comm.IUserSession, req *pb.SmithyStoveSkillLvReq) (code pb.ErrorCode, dat proto.Message) {
var bLevelUp bool
code = this.StoveSkillLvCheck(session, req) code = this.StoveSkillLvCheck(session, req)
if code != pb.ErrorCode_Success { if code != pb.ErrorCode_Success {
return // 参数校验失败直接返回 return // 参数校验失败直接返回
@ -46,11 +46,18 @@ func (this *apiComp) StoveSkillLv(session comm.IUserSession, req *pb.SmithyStove
n, _ := rand.Int(rand.Reader, big.NewInt(100)) n, _ := rand.Int(rand.Reader, big.NewInt(100))
if n.Int64() < int64(curLvData.Probability) { // 可以升级 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 _smithy.StoveLv += 1
this.module.modelSmithy.CalculationStoveSkillLv(session.GetUserId(), _smithy, _smithy.StoveLv) this.module.modelSmithy.CalculationStoveSkillLv(session.GetUserId(), _smithy, _smithy.StoveLv)
} }
session.SendMsg(string(this.module.GetType()), SmithyDeskSkillLvResp, &pb.SmithyDeskSkillLvResp{Data: _smithy}) session.SendMsg(string(this.module.GetType()), SmithyDeskSkillLvResp, &pb.SmithyDeskSkillLvResp{Data: _smithy})
return return
} }

View File

@ -1,6 +1,7 @@
package smithy package smithy
import ( import (
"fmt"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log" "go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules" "go_dreamfactory/modules"
@ -12,11 +13,13 @@ import (
const ( const (
game_smithy = "game_smithy.json" game_smithy = "game_smithy.json"
game_smithystove = "game_smithystove.json" game_smithystove = "game_smithystove.json"
game_equip = "game_equip.json" //装备信息表
) )
///配置管理基础组件 ///配置管理基础组件
type configureComp struct { type configureComp struct {
modules.MCompConfigure modules.MCompConfigure
module *Smithy
hlock sync.RWMutex hlock sync.RWMutex
_smithyMap map[int64]*cfg.GameSmithyData _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) { 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) err = this.MCompConfigure.Init(service, module, comp, options)
this._smithyMap = make(map[int64]*cfg.GameSmithyData, 0) this._smithyMap = make(map[int64]*cfg.GameSmithyData, 0)
this.module = module.(*Smithy)
configure.RegisterConfigure(game_smithy, cfg.NewGameSmithy, func() { configure.RegisterConfigure(game_smithy, cfg.NewGameSmithy, func() {
if v, err := this.GetConfigure(game_smithy); err == nil { if v, err := this.GetConfigure(game_smithy); err == nil {
if configure, ok := v.(*cfg.GameSmithy); ok { if configure, ok := v.(*cfg.GameSmithy); ok {
@ -40,6 +44,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
return return
}) })
err = this.LoadConfigure(game_smithystove, cfg.NewGameSmithyStove) err = this.LoadConfigure(game_smithystove, cfg.NewGameSmithyStove)
err = this.LoadConfigure(game_equip, cfg.NewGameEquip)
return return
} }
@ -90,3 +95,21 @@ func (this *configureComp) LoadMultiConfigure(confs map[string]interface{}) (err
func (this *configureComp) GetConfigure(name string) (v interface{}, err error) { func (this *configureComp) GetConfigure(name string) (v interface{}, err error) {
return configure.GetConfigure(name) 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
}

View File

@ -39,10 +39,12 @@ func (this *modelSmithy) getSmithyList(uid string) (result *pb.DBSmithy, err err
result.Id = primitive.NewObjectID().Hex() result.Id = primitive.NewObjectID().Hex()
result.Uid = uid result.Uid = uid
result.Skill = make(map[int32]int32, 0) 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() // 找类型 mapType := this.module.configure.GetSmithyTypeConfigData() // 找类型
for key := range mapType { for key := range mapType {
result.Skill[key] = 1 result.Skill[key] = 1
result.DeskFloor[key] = 0
} }
if err = this.Add(uid, result); err != nil { 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 { func (this *modelSmithy) modifySmithyDataByObjId(uid string, data map[string]interface{}) error {
return this.Change(uid, data) return this.Change(uid, data)
} }
func (this *modelSmithy) CalculationSmithy(uid string, smithy *pb.DBSmithy) {
// 计算订单信息
func (this *modelSmithy) CalculationSmithy(uid string, Smithy *pb.DBSmithy) {
var ( var (
bCooking bool bCooking bool
costTime int32 costTime int32
curTime int32 curTime int32
szTime map[int32]int32 // k 台子类型 v订单耗时
zeroTime int64 // 订单开始的时间对应第二天0点时间
nextDay bool // 是否跨天了
nextDayTime int32 // 跨天累计时间
) )
mapData := make(map[string]interface{}, 0) mapData := make(map[string]interface{}, 0)
if Smithy.Clang != nil && Smithy.Clang.ETime > 0 { szTime = make(map[int32]int32, 0)
costTime = int32(time.Now().Unix() - Smithy.Clang.ETime) // 当前过去的时间 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 { // 没有完成 不做处理 if costTime < 0 { // 没有完成 不做处理
return return
} }
} }
if Smithy.Clang == nil {
Smithy.Clang = &pb.Clang{} for _, order := range smithy.Orders {
}
for _, order := range Smithy.Orders {
if order.Count == 0 { if order.Count == 0 {
continue continue
} }
foodtype := order.DeskType desktype := order.DeskType
// 获取技能等级 skillLv := smithy.Skill[desktype] // 获取技能等级
skillLv := Smithy.Skill[foodtype]
// 计算出需要的时间 // 计算出需要的时间
_skillCfg := this.module.configure.GetSmithyStoveConfigData(skillLv) // 技能配置表
_Smithycfg := this.module.configure.GetSmithyConfigData(foodtype, skillLv) // 美食家配置表 _smithycfg := this.module.configure.GetSmithyConfigData(desktype, skillLv) // 美食家配置表
for i := 0; i < int(order.Count); i++ { iCount := int(order.Count)
curTime += _skillCfg.Time for i := 0; i < iCount; i++ {
// 判断是不是第二天 curTime += szTime[order.DeskType]
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 // 清空当天的订单时长
}
order.Count-- 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) // 获取掉落奖励 // 判断订单是否跨天
if smithy.Clang.ETime >= zeroTime && !nextDay {
mapData["items"] = Smithy.Items smithy.Ctime = zeroTime // 设置
smithy.OrderCostTime = 0
nextDay = true
}
if nextDay {
nextDayTime += szTime[order.DeskType]
}
if curTime > costTime { if curTime > costTime {
Smithy.OrderCostTime += int32(curTime - costTime)
// 转时间戳 // 转时间戳
eTimd := time.Now().Unix() + int64(curTime-costTime) smithy.Clang.DeskType = order.DeskType
Smithy.Clang.DeskType = order.DeskType smithy.Clang.ETime = time.Now().Unix() + int64(curTime-costTime)
Smithy.Clang.ETime = eTimd smithy.Clang.STime = smithy.Clang.ETime - int64(szTime[order.DeskType])
Smithy.Clang.STime = time.Now().Unix() - int64(curTime-costTime)
bCooking = true bCooking = true
// 记录下订单时间 // 记录下订单时间
Smithy.Ctime = time.Now().Unix() smithy.Ctime = time.Now().Unix()
mapData["ctime"] = Smithy.Ctime mapData["ctime"] = smithy.Ctime
break break
} }
Smithy.OrderCostTime += curTime smithy.Items = this.module.configure.GetMultipleDropReward(_smithycfg.Using, _smithycfg.Drop, smithy.Items) // 获取掉落奖励
} }
if bCooking { // 分配了正在製作的食物 if bCooking { // 分配了正在製作的食物
break break
} }
} }
if !bCooking { // 经过计算没有烹饪食物的时候 if nextDay {
Smithy.Clang = nil smithy.OrderCostTime += nextDayTime
} for _, order := range smithy.Orders {
sz := make([]*pb.OrderClang, 0) if order.Count == 0 {
for _, v := range Smithy.Orders { continue
if v.Count != 0 { }
sz = append(sz, v) 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["items"] = smithy.Items
mapData["orderCostTime"] = Smithy.OrderCostTime mapData["orders"] = smithy.Orders
mapData["clang"] = Smithy.Clang // 正在做的 mapData["orderCostTime"] = smithy.OrderCostTime
this.module.ModifySmithyData(uid, mapData) mapData["clang"] = smithy.Clang // 正在做的
} }
// 技能升级 重计算时间消耗
func (this *modelSmithy) CalculationDeskSkillLv(uid string, Smithy *pb.DBSmithy) { func (this *modelSmithy) CalculationDeskSkillLv(uid string, Smithy *pb.DBSmithy) {
mapData := make(map[string]interface{}, 0) mapData := make(map[string]interface{}, 0)
mapData["skill"] = Smithy.Skill mapData["skill"] = Smithy.Skill
mapData["deskFloor"] = Smithy.DeskFloor
this.module.ModifySmithyData(uid, mapData) this.module.ModifySmithyData(uid, mapData)
} }
@ -167,5 +198,6 @@ func (this *modelSmithy) CalculationStoveSkillLv(uid string, Smithy *pb.DBSmithy
} }
} }
mapData["stoveLv"] = Smithy.StoveLv mapData["stoveLv"] = Smithy.StoveLv
mapData["deskFloor"] = Smithy.DeskFloor
this.module.ModifySmithyData(uid, mapData) this.module.ModifySmithyData(uid, mapData)
} }

View File

@ -48,3 +48,17 @@ func (this *Smithy) ModifySmithyData(uid string, data map[string]interface{}) (c
} }
return 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)
}
}

View File

@ -41,18 +41,20 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.VikingChalleng
code = pb.ErrorCode_ConfigNoFound code = pb.ErrorCode_ConfigNoFound
return return
} }
if value, ok := viking.Boos[req.BossType]; !ok { // 类型校验 // 类型校验
code = pb.ErrorCode_VikingBoosType boosData := this.configure.GetVikingBossConfigData(req.BossType, req.Difficulty)
return if boosData != nil {
} else { if value, ok := viking.Boos[req.BossType]; !ok { // 类型校验
if value < req.Difficulty { viking.Boos[req.BossType] = 0
if value+1 != req.Difficulty { if value < req.Difficulty {
code = pb.ErrorCode_VikingLvErr if value+1 != req.Difficulty {
return code = pb.ErrorCode_VikingLvErr
return
}
newChallenge = true
} else { // 挑战历史
newChallenge = false
} }
newChallenge = true
} else { // 挑战历史
newChallenge = false
} }
} }

View File

@ -6,7 +6,6 @@ import (
"go_dreamfactory/utils" "go_dreamfactory/utils"
"time" "time"
"go.mongodb.org/mongo-driver/bson/primitive"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@ -22,21 +21,13 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.VikingGetListReq
if code != pb.ErrorCode_Success { if code != pb.ErrorCode_Success {
return // 参数校验失败直接返回 return // 参数校验失败直接返回
} }
list, err := this.module.modelViking.getVikingList(session.GetUserId()) list, err := this.module.modelViking.getVikingList(session.GetUserId())
if err != nil { if err != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return 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) { if !utils.IsToday(list.CTime) {
list.CTime = time.Now().Unix() list.CTime = time.Now().Unix()

View File

@ -3,10 +3,11 @@ package viking
import ( import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/redis" "go_dreamfactory/lego/sys/mgo"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go.mongodb.org/mongo-driver/bson/primitive"
"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"
) )
@ -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) { func (this *modelViking) getVikingList(uid string) (result *pb.DBViking, err error) {
result = &pb.DBViking{} result = &pb.DBViking{
if err = this.Get(uid, result); err != nil && redis.RedisNil != err { 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 return
} }
if mgo.MongodbNil == err {
this.module.modelViking.Add(uid, result)
}
err = nil err = nil
return result, err return result, err
} }

View File

@ -161,7 +161,7 @@ type DBSmithy struct {
StoveLv int32 `protobuf:"varint,7,opt,name=stoveLv,proto3" json:"stoveLv" bson:"stoveLv"` //炉子等级 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"` //订单消耗的时常 OrderCostTime int32 `protobuf:"varint,8,opt,name=orderCostTime,proto3" json:"orderCostTime" bson:"orderCostTime"` //订单消耗的时常
Ctime int64 `protobuf:"varint,9,opt,name=ctime,proto3" json:"ctime"` // 订单创建时间 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"` //炉子保底 StoveFloor int32 `protobuf:"varint,11,opt,name=stoveFloor,proto3" json:"stoveFloor" bson:"stoveFloor"` //炉子保底
} }
@ -260,11 +260,11 @@ func (x *DBSmithy) GetCtime() int64 {
return 0 return 0
} }
func (x *DBSmithy) GetDeskFloor() int32 { func (x *DBSmithy) GetDeskFloor() map[int32]int32 {
if x != nil { if x != nil {
return x.DeskFloor return x.DeskFloor
} }
return 0 return nil
} }
func (x *DBSmithy) GetStoveFloor() int32 { 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 0x03, 0x52, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x36, 0x0a, 0x09, 0x64, 0x65, 0x73, 0x6b,
0x46, 0x6c, 0x6f, 0x6f, 0x72, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x64, 0x65, 0x73, 0x46, 0x6c, 0x6f, 0x6f, 0x72, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x44, 0x42,
0x6b, 0x46, 0x6c, 0x6f, 0x6f, 0x72, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x74, 0x6f, 0x76, 0x65, 0x46, 0x53, 0x6d, 0x69, 0x74, 0x68, 0x79, 0x2e, 0x44, 0x65, 0x73, 0x6b, 0x46, 0x6c, 0x6f, 0x6f, 0x72,
0x6c, 0x6f, 0x6f, 0x72, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x6f, 0x76, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x64, 0x65, 0x73, 0x6b, 0x46, 0x6c, 0x6f, 0x6f, 0x72,
0x65, 0x46, 0x6c, 0x6f, 0x6f, 0x72, 0x1a, 0x38, 0x0a, 0x0a, 0x53, 0x6b, 0x69, 0x6c, 0x6c, 0x45, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x74, 0x6f, 0x76, 0x65, 0x46, 0x6c, 0x6f, 0x6f, 0x72, 0x18, 0x0b,
0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x6f, 0x76, 0x65, 0x46, 0x6c, 0x6f, 0x6f, 0x72,
0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x1a, 0x38, 0x0a, 0x0a, 0x53, 0x6b, 0x69, 0x6c, 0x6c, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10,
0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79,
0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 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 ( var (
@ -330,24 +336,26 @@ func file_smithy_smithy_db_proto_rawDescGZIP() []byte {
return file_smithy_smithy_db_proto_rawDescData 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{}{ var file_smithy_smithy_db_proto_goTypes = []interface{}{
(*Clang)(nil), // 0: Clang (*Clang)(nil), // 0: Clang
(*OrderClang)(nil), // 1: OrderClang (*OrderClang)(nil), // 1: OrderClang
(*DBSmithy)(nil), // 2: DBSmithy (*DBSmithy)(nil), // 2: DBSmithy
nil, // 3: DBSmithy.SkillEntry nil, // 3: DBSmithy.SkillEntry
(*UserAssets)(nil), // 4: UserAssets nil, // 4: DBSmithy.DeskFloorEntry
(*UserAssets)(nil), // 5: UserAssets
} }
var file_smithy_smithy_db_proto_depIdxs = []int32{ var file_smithy_smithy_db_proto_depIdxs = []int32{
0, // 0: DBSmithy.clang:type_name -> Clang 0, // 0: DBSmithy.clang:type_name -> Clang
1, // 1: DBSmithy.orders:type_name -> OrderClang 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 3, // 3: DBSmithy.skill:type_name -> DBSmithy.SkillEntry
4, // [4:4] is the sub-list for method output_type 4, // 4: DBSmithy.deskFloor:type_name -> DBSmithy.DeskFloorEntry
4, // [4:4] is the sub-list for method input_type 5, // [5:5] is the sub-list for method output_type
4, // [4:4] is the sub-list for extension type_name 5, // [5:5] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension extendee 5, // [5:5] is the sub-list for extension type_name
0, // [0:4] is the sub-list for field 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() } func init() { file_smithy_smithy_db_proto_init() }
@ -400,7 +408,7 @@ func file_smithy_smithy_db_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_smithy_smithy_db_proto_rawDesc, RawDescriptor: file_smithy_smithy_db_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 4, NumMessages: 5,
NumExtensions: 0, NumExtensions: 0,
NumServices: 0, NumServices: 0,
}, },

View File

@ -1,6 +1,8 @@
package utils package utils
import "time" import (
"time"
)
// 判断时间点处于今天 // 判断时间点处于今天
func IsToday(d int64) bool { func IsToday(d int64) bool {
@ -19,12 +21,10 @@ func IsAfterWeek(d int64) bool {
return now.Sub(tt) >= time.Hour*24*7 return now.Sub(tt) >= time.Hour*24*7
} }
// 获取0点时间戳 // 获取当前时间戳下一天0点时间戳
func GetZeroTime() int64 { func GetZeroTime(curTime int64) int64 {
currentTime := time.Unix(curTime, 0)
currentTime := time.Now()
startTime := time.Date(currentTime.Year(), currentTime.Month(), currentTime.Day(), 0, 0, 0, 0, currentTime.Location()) startTime := time.Date(currentTime.Year(), currentTime.Month(), currentTime.Day(), 0, 0, 0, 0, currentTime.Location())
return startTime.Unix() return startTime.Unix() + 86400 //3600*24
} }