diff --git a/comm/const.go b/comm/const.go index ca6adca4f..ffb4c143a 100644 --- a/comm/const.go +++ b/comm/const.go @@ -129,8 +129,7 @@ const ( TablePagoda = "pagoda" ///武馆数据表 TableMartialhall = "martialhall" - // 美食馆 - TableGourmet = "gourmet" + // 随机任务 TableRtask = "rtask" // 随机任务触发记录 diff --git a/modules/gourmet/api_createorder.go b/modules/gourmet/api_createorder.go deleted file mode 100644 index ff54ee241..000000000 --- a/modules/gourmet/api_createorder.go +++ /dev/null @@ -1,149 +0,0 @@ -package gourmet - -import ( - "go_dreamfactory/comm" - "go_dreamfactory/pb" - "go_dreamfactory/sys/configure" - cfg "go_dreamfactory/sys/configure/structs" - - "google.golang.org/protobuf/proto" -) - -//参数校验 -func (this *apiComp) CreateOrderCheck(session comm.IUserSession, req *pb.GourmetCreateOrderReq) (code pb.ErrorCode) { - if len(req.Order) == 0 { - code = pb.ErrorCode_ReqParameterError - return - } - return -} - -///美食城创建订单 -func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.GourmetCreateOrderReq) (code pb.ErrorCode, data proto.Message) { - var ( - res []*cfg.Gameatn // 订单消耗 - costTime int32 // 当前订单的总耗时 - szTime map[int32]int32 // 记录每个类型的订单耗时 key 是技能组type value 订单耗时 - privilegeAddItme int32 // 特权额外增加的时间 - ) - szTime = make(map[int32]int32, 0) - code = this.CreateOrderCheck(session, req) - if code != pb.ErrorCode_Success { - return // 参数校验失败直接返回 - } - _gourmet, err := this.module.modelGourmet.getGourmetList(session.GetUserId()) - if err != nil { - code = pb.ErrorCode_DBError - return - } - // 记录每个食材耗时 - for k, v := range _gourmet.Skill { - _skillCfg := this.module.configure.GetGourmetConfigData(k, v) - szTime[k] += _skillCfg.Needtime - // 高效制作技能 - for k1, v1 := range _gourmet.SpecialSkill { - specalSkill := this.module.configure.GetGourmetConfigData(k1, v1) - szTime[k] += specalSkill.Needtime - } - } - - // if !utils.IsToday(_gourmet.Ctime) { // 跨天了 - // _gourmet.Ctime = configure.Now().Unix() - // _gourmet.OrderCostTime = 0 - // } - // 计算消耗 - for _, order := range req.Order { - if order.FoodCount == 0 { - continue - } - if v, ok := szTime[order.FoodType]; ok { - costTime += v * order.FoodCount - } - if v, ok := _gourmet.Skill[order.FoodType]; ok { - conf := this.module.configure.GetGourmetConfigData(order.FoodType, v) - res = append(res, conf.DeliciousConsume...) - } - } - - // 校验时间 - cfgCom := this.module.configure.GetGlobalConf() // 获取总的下单时长 - if cfgCom == nil { - return - } - privilegeAddItme = this.module.ModulePrivilege.GetCountByPrivilegeId(session.GetUserId(), comm.PrivilegeType8) - _gourmet.OrderCostTime += costTime - if cfgCom.Gourmet+privilegeAddItme < _gourmet.OrderCostTime { // 大于总时长是不允许的 - code = pb.ErrorCode_GourmetMoreOrderTime - return - } - - if _gourmet.Foods == nil { // 队列数据为nil 直接将订单数据给ta - _gourmet.Foods = req.Order - } else { - for _, v := range req.Order { - bFound := false - for _, v1 := range _gourmet.Foods { - if v.FoodType == v1.FoodType { - v1.FoodCount += v.FoodCount // 加对应的数量 - bFound = true - break - } - } - if !bFound { - _gourmet.Foods = append(_gourmet.Foods, v) - } - } - } - // 重新计算时间 - for _, v := range _gourmet.Foods { - if v1, ok := szTime[v.FoodType]; ok { - v.CookTime = v1 * v.FoodCount - } - } - if _gourmet.CookingFood != nil && _gourmet.CookingFood.ETime == 0 { - _gourmet.CookingFood = nil - } - if _gourmet.CookingFood == nil { - for _, v := range _gourmet.Foods { - if v.FoodCount > 0 { - v.FoodCount-- - v.CookTime = v.FoodCount * szTime[v.FoodType] - // 获取生产时间 - _gourmet.CookingFood = &pb.Cooking{ - FoodType: v.FoodType, - ETime: configure.Now().Unix() + int64(szTime[v.FoodType]), - STime: configure.Now().Unix(), - } - if v.FoodCount == 0 { - v.CookTime = 0 - } - if _gourmet.Ctime == 0 { - _gourmet.Ctime = configure.Now().Unix() - } - break - } - } - } - - if code = this.module.ConsumeRes(session, res, true); code != pb.ErrorCode_Success { // 消耗校验 - return - } - - // 校验通过 写数据 - mapData := make(map[string]interface{}, 0) - mapData["foods"] = _gourmet.Foods - mapData["orderCostTime"] = _gourmet.OrderCostTime - mapData["cookingFood"] = _gourmet.CookingFood // 正在做的 - mapData["ctime"] = _gourmet.Ctime - code = this.module.ModifyGourmetData(session.GetUserId(), mapData) - - session.SendMsg(string(this.module.GetType()), GourmetCreateOrderResp, &pb.GourmetCreateOrderResp{Data: _gourmet}) - - iTotal := 0 - for _, v := range req.Order { - iTotal += int(v.FoodCount) - } - // this.module.ModuleRtask.SendToRtask(session, comm.Rtype150, int32(iTotal)) - go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype150, int32(iTotal))) - return -} diff --git a/modules/gourmet/api_foodskilllv.go b/modules/gourmet/api_foodskilllv.go deleted file mode 100644 index aacd31ed9..000000000 --- a/modules/gourmet/api_foodskilllv.go +++ /dev/null @@ -1,70 +0,0 @@ -package gourmet - -import ( - "crypto/rand" - "go_dreamfactory/comm" - "go_dreamfactory/pb" - "math/big" - - "google.golang.org/protobuf/proto" -) - -//参数校验 -func (this *apiComp) SkillLVCheck(session comm.IUserSession, req *pb.GourmetSkillLvReq) (code pb.ErrorCode) { - if req.SkillType == 0 { - code = pb.ErrorCode_ReqParameterError - } - return -} - -///美食城厨师技能升级 -func (this *apiComp) SkillLV(session comm.IUserSession, req *pb.GourmetSkillLvReq) (code pb.ErrorCode, dat proto.Message) { - var ( - bSpecial bool // 是不是特殊技能 - ) - code = this.SkillLVCheck(session, req) - if code != pb.ErrorCode_Success { - return // 参数校验失败直接返回 - } - _gourmet, err := this.module.modelGourmet.getGourmetList(session.GetUserId()) - if err != nil { - code = pb.ErrorCode_DBError - return - } - - skilllv, ok := _gourmet.Skill[req.SkillType] - if !ok { // 校验技能存不存在 - skilllv, ok = _gourmet.SpecialSkill[req.SkillType] - if !ok { - code = pb.ErrorCode_ReqParameterError - return - } - bSpecial = true - } - - if this.module.configure.GetGourmetConfigData(req.SkillType, skilllv+1) == nil { // 下一级是否存在 - code = pb.ErrorCode_GourmetSkillMaxLv - return - } - _skillCfg := this.module.configure.GetGourmetConfigData(req.SkillType, skilllv) // 获取技能配置 - - code = this.module.ConsumeRes(session, _skillCfg.SkillConsume, true) // 消耗检测 - if code != pb.ErrorCode_Success { - return - } - // 概率升级 - n, _ := rand.Int(rand.Reader, big.NewInt(1000)) - - if n.Int64() < int64(_skillCfg.Probability) { // 可以升级 - // 技能升级成功 - if bSpecial { // 通用技能升级 - _gourmet.SpecialSkill[req.SkillType] += 1 - this.module.modelGourmet.CalculationSpecialSkillLv(session.GetUserId(), _gourmet, req.SkillType, _gourmet.SpecialSkill[req.SkillType]) - } else { // 某一类型技能升级 - _gourmet.Skill[req.SkillType] += 1 - this.module.modelGourmet.CalculationGourmetbySkiiLv(session.GetUserId(), _gourmet, req.SkillType, _gourmet.Skill[req.SkillType]) - } - } - session.SendMsg(string(this.module.GetType()), GourmetSkillLvResp, &pb.GourmetSkillLvResp{Data: _gourmet}) - return -} diff --git a/modules/gourmet/api_getReward.go b/modules/gourmet/api_getReward.go deleted file mode 100644 index 86d1e2b6a..000000000 --- a/modules/gourmet/api_getReward.go +++ /dev/null @@ -1,42 +0,0 @@ -package gourmet - -import ( - "go_dreamfactory/comm" - "go_dreamfactory/pb" - cfg "go_dreamfactory/sys/configure/structs" - - "google.golang.org/protobuf/proto" -) - -//参数校验 -func (this *apiComp) GetRewardCheck(session comm.IUserSession, req *pb.GourmetGetRewardReq) (code pb.ErrorCode) { - - return -} - -///美食城领取奖励 -func (this *apiComp) GetReward(session comm.IUserSession, req *pb.GourmetGetRewardReq) (code pb.ErrorCode, data proto.Message) { - code = this.GetRewardCheck(session, req) - _gourmet, err := this.module.modelGourmet.getGourmetList(session.GetUserId()) - if err != nil { - code = pb.ErrorCode_DBError - return - } - if len(_gourmet.Items) > 0 { - res := make([]*cfg.Gameatn, 0) - for _, v := range _gourmet.Items { - res = append(res, &cfg.Gameatn{ - A: v.A, - T: v.T, - N: v.N, - }) - } - code = this.module.DispenseRes(session, res, true) - _gourmet.Items = nil - mapData := make(map[string]interface{}, 0) - mapData["items"] = nil - code = this.module.ModifyGourmetData(session.GetUserId(), mapData) - } - session.SendMsg(string(this.module.GetType()), GourmetGetRewardResp, &pb.GourmetGetRewardResp{Data: _gourmet}) - return -} diff --git a/modules/gourmet/api_getlist.go b/modules/gourmet/api_getlist.go deleted file mode 100644 index c791c1fb6..000000000 --- a/modules/gourmet/api_getlist.go +++ /dev/null @@ -1,37 +0,0 @@ -package gourmet - -import ( - "go_dreamfactory/comm" - "go_dreamfactory/pb" - - "google.golang.org/protobuf/proto" -) - -//参数校验 -func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.GourmetGetListReq) (code pb.ErrorCode) { - - return -} - -///获取美食城基本信息 -func (this *apiComp) GetList(session comm.IUserSession, req *pb.GourmetGetListReq) (code pb.ErrorCode, data proto.Message) { - - code = this.GetListCheck(session, req) - if code != pb.ErrorCode_Success { - return // 参数校验失败直接返回 - } - _gourmet, err := this.module.modelGourmet.getGourmetList(session.GetUserId()) - if err != nil { - code = pb.ErrorCode_DBError - return - } - - // 计算订单信息 - this.module.modelGourmet.CalculationGourmet(session.GetUserId(), _gourmet) - session.SendMsg(string(this.module.GetType()), GourmetGetListResp, &pb.GourmetGetListResp{Data: _gourmet}) - - // 任务统计 - // this.module.ModuleRtask.SendToRtask(session, comm.Rtype136, _gourmet.TotalTime) - go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype136, _gourmet.TotalTime)) - return -} diff --git a/modules/gourmet/comp_configure.go b/modules/gourmet/comp_configure.go index f982649a2..e9f437445 100644 --- a/modules/gourmet/comp_configure.go +++ b/modules/gourmet/comp_configure.go @@ -6,21 +6,18 @@ import ( "go_dreamfactory/modules" "go_dreamfactory/sys/configure" cfg "go_dreamfactory/sys/configure/structs" - "sync" ) const ( - game_gourmet = "game_gourmet.json" - game_food = "game_breakingbad.json" + //game_gourmet = "game_gourmet.json" + game_food = "game_breakingbad.json" ) ///配置管理基础组件 type configureComp struct { - hlock sync.RWMutex modules.MCompConfigure - _gourmetMap map[int64]*cfg.GameGourmetData - module *Gourmet - normal string + module *Gourmet + normal string } //组件初始化接口 @@ -30,33 +27,12 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp err = this.LoadMultiConfigure(map[string]interface{}{ game_food: cfg.NewGameBreakingbad, }) - this._gourmetMap = make(map[int64]*cfg.GameGourmetData, 0) - configure.RegisterConfigure(game_gourmet, cfg.NewGameGourmet, func() { - if v, err := this.GetConfigure(game_gourmet); err == nil { - if configure, ok := v.(*cfg.GameGourmet); ok { - this.hlock.Lock() - defer this.hlock.Unlock() - for _, value := range configure.GetDataList() { - this._gourmetMap[int64(value.Type<<16)+int64(value.Level)] = value - } - return - } - } - log.Errorf("get game_pagoda conf err:%v", err) - return - }) configure.RegisterConfigure(game_food, cfg.NewGameBreakingbad, this.SetGrormetCookBookConf) return } -// 获取美食馆配置数据 -func (this *configureComp) GetGourmetConfigData(gourmetType int32, level int32) (data *cfg.GameGourmetData) { - - return this._gourmetMap[int64(gourmetType<<16)+int64(level)] -} - //加载多个配置文件 func (this *configureComp) LoadMultiConfigure(confs map[string]interface{}) (err error) { for k, v := range confs { @@ -73,22 +49,6 @@ 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) GetGourmetSkillConfigBySkillType(skillType int32) (data []int32) { - data = make([]int32, 0) - if v, err := this.GetConfigure(game_gourmet); err == nil { - if configure, ok := v.(*cfg.GameGourmet); ok { - this.hlock.Lock() - defer this.hlock.Unlock() - for _, value := range configure.GetDataList() { - if value.SkillType == skillType && value.Initial == 1 { - data = append(data, value.Type) - } - } - return - } - } - return -} func (this *configureComp) SetGrormetCookBookConf() { diff --git a/modules/gourmet/model_gourmet.go b/modules/gourmet/model_gourmet.go deleted file mode 100644 index 06dce9310..000000000 --- a/modules/gourmet/model_gourmet.go +++ /dev/null @@ -1,202 +0,0 @@ -package gourmet - -import ( - "go_dreamfactory/comm" - "go_dreamfactory/lego/core" - "go_dreamfactory/lego/sys/redis" - "go_dreamfactory/modules" - "go_dreamfactory/pb" - "go_dreamfactory/sys/configure" - "go_dreamfactory/utils" - - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/x/bsonx" -) - -type modelGourmet struct { - modules.MCompModel - module *Gourmet -} - -func (this *modelGourmet) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { - this.TableName = string(comm.TableGourmet) - err = this.MCompModel.Init(service, module, comp, options) - this.module = module.(*Gourmet) - // uid 创建索引 - this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ - Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, - }) - return -} - -func (this *modelGourmet) getGourmetList(uid string) (result *pb.DBGourmet, err error) { - result = &pb.DBGourmet{} - if err = this.Get(uid, result); err != nil { - if redis.RedisNil != err { // 没有数据直接创建新的数据 - - result.Id = primitive.NewObjectID().Hex() - result.Uid = uid - result.Skill = make(map[int32]int32, 0) - szSkill := this.module.configure.GetGourmetSkillConfigBySkillType(1) // 查表获取初始技能 - for _, v := range szSkill { - result.Skill[v] = 1 - } - - szSpecailSkill := this.module.configure.GetGourmetSkillConfigBySkillType(2) // 高效制作 等通用技能 - result.SpecialSkill = make(map[int32]int32, 0) - for _, v := range szSpecailSkill { - result.SpecialSkill[v] = 1 - } - result.SpecialSkill[1005] = 1 // 通用技能 - if err = this.Add(uid, result); err != nil { - this.module.Errorf("err:%v", err) - err = nil - return - } - } - return - } - err = nil - return result, err -} -func (this *modelGourmet) modifyGourmetDataByObjId(uid string, data map[string]interface{}) error { - return this.Change(uid, data) -} - -// 计算订单信息 -func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet) { - var ( - szTime map[int32]int32 // 食材耗时 - zeroTime int64 // 当前时间对应的0点时间戳,用来判断是否跨天了 - ) - mapData := make(map[string]interface{}, 0) - szTime = make(map[int32]int32, 0) - - // 记录每个食材耗时 - for k, v := range gourmet.Skill { - // 计算出需要的时间 - _skillCfg := this.module.configure.GetGourmetConfigData(k, v) - szTime[k] += _skillCfg.Needtime - // 高效制作技能 - for k1, v1 := range gourmet.SpecialSkill { - specalSkill := this.module.configure.GetGourmetConfigData(k1, v1) - szTime[k] += specalSkill.Needtime - } - } - - // 有订单在做 - zeroTime = utils.GetTodayZeroTime(configure.Now().Unix()) - - if (gourmet.CookingFood != nil && gourmet.CookingFood.ETime >= configure.Now().Unix()) || gourmet.CookingFood == nil { - for _, order := range gourmet.Foods { - _gourmetcfg := this.module.configure.GetGourmetConfigData(order.FoodType, gourmet.Skill[order.FoodType]) // 美食家配置表 - if order.FoodCount > 0 { - if gourmet.CookingFood.ETime > configure.Now().Unix() { - break - } - order.FoodCount-- - if order.FoodCount == 0 { - order.CookTime = 0 - } - order.CookTime = order.FoodCount * szTime[order.FoodType] - if gourmet.CookingFood == nil { - gourmet.CookingFood = &pb.Cooking{} - gourmet.CookingFood.STime = configure.Now().Unix() - gourmet.CookingFood.ETime = configure.Now().Unix() + int64(szTime[order.FoodType]) - // 如果此时跨天了 清除订单时常 - if gourmet.CookingFood.STime < zeroTime && zeroTime <= gourmet.CookingFood.ETime { // 跨天清空订单耗时 - gourmet.OrderCostTime = 0 - for _, order := range gourmet.Foods { // 重新计算订单时常 - gourmet.OrderCostTime += order.FoodCount * szTime[order.FoodType] - } - } - } else { - gourmet.CookingFood.STime += int64(szTime[order.FoodType]) - oldTime := gourmet.CookingFood.ETime - gourmet.CookingFood.ETime += int64(szTime[order.FoodType]) - // 如果此时跨天了 清除订单时常 - if oldTime < zeroTime && zeroTime <= gourmet.CookingFood.ETime { // 跨天清空订单耗时 - gourmet.OrderCostTime = 0 - for _, order := range gourmet.Foods { // 重新计算订单时常 - gourmet.OrderCostTime += order.FoodCount * szTime[order.FoodType] - } - } - } - gourmet.CookingFood.FoodType = order.FoodType - // 设置掉落组 - gourmet.Items = this.module.configure.GetMultipleDropReward(_gourmetcfg.Using, _gourmetcfg.Propsgroup, gourmet.Items) // 获取掉落奖励 - // 记录下订单时间 - gourmet.Ctime = gourmet.CookingFood.ETime - gourmet.TotalTime += szTime[order.FoodType] - } - } - - if gourmet.CookingFood != nil && gourmet.CookingFood.ETime <= configure.Now().Unix() { - _gourmetcfg := this.module.configure.GetGourmetConfigData(gourmet.CookingFood.FoodType, gourmet.Skill[gourmet.CookingFood.FoodType]) - gourmet.Items = this.module.configure.GetMultipleDropReward(_gourmetcfg.Using, _gourmetcfg.Propsgroup, gourmet.Items) - gourmet.CookingFood = nil - } - } - - // 保存信息 - mapData["items"] = gourmet.Items - mapData["foods"] = gourmet.Foods - mapData["orderCostTime"] = gourmet.OrderCostTime - mapData["cookingFood"] = gourmet.CookingFood // 正在做的 - mapData["totalTime"] = gourmet.TotalTime - mapData["ctime"] = gourmet.Ctime - this.module.ModifyGourmetData(uid, mapData) // 同步数据 -} - -// 技能等级提高了 重新计算订单时间(只对订单中数据有影响) -func (this *modelGourmet) CalculationGourmetbySkiiLv(uid string, gourmet *pb.DBGourmet, skillType int32, skilllv int32) { - mapData := make(map[string]interface{}, 0) - var totalTime int32 - for _, v := range gourmet.Foods { - if v.FoodCount > 0 && v.FoodType == skillType { - _skillCfg := this.module.configure.GetGourmetConfigData(skillType, skilllv) - if _skillCfg != nil { - totalTime += _skillCfg.Needtime * v.FoodCount - v.CookTime += totalTime - mapData["foods"] = gourmet.Foods - } - break - } - } - // 总时间也减少了 - gourmet.OrderCostTime += totalTime - mapData["orderCostTime"] = gourmet.OrderCostTime - mapData["skill"] = gourmet.Skill - this.module.ModifyGourmetData(uid, mapData) -} - -// 升级高效制作技能重计算时间消耗 -func (this *modelGourmet) CalculationSpecialSkillLv(uid string, gourmet *pb.DBGourmet, skillType int32, skilllv int32) { - mapData := make(map[string]interface{}, 0) - var totalTime int32 - for _, v := range gourmet.Foods { - if v.FoodCount > 0 { - preScaleTime := 0 - preSkillConf := this.module.configure.GetGourmetConfigData(skillType, skilllv-1) - if preSkillConf != nil { - preScaleTime = int(preSkillConf.Needtime) - } - _skillCfg := this.module.configure.GetGourmetConfigData(skillType, skilllv) - if _skillCfg != nil { - scaleTime := (_skillCfg.Needtime - int32(preScaleTime)) * v.FoodCount - totalTime += scaleTime - v.CookTime += scaleTime - if v.CookTime < 0 { // 担心配置错误 为负数情况 所以这里做下判断 - v.CookTime = 0 - } - } - } - } - // 总时间也减少了 - mapData["foods"] = gourmet.Foods - gourmet.OrderCostTime += totalTime - mapData["orderCostTime"] = gourmet.OrderCostTime - mapData["specialSkill"] = gourmet.SpecialSkill - this.module.ModifyGourmetData(uid, mapData) -} diff --git a/modules/gourmet/module.go b/modules/gourmet/module.go index 219ae351c..e75058532 100644 --- a/modules/gourmet/module.go +++ b/modules/gourmet/module.go @@ -10,17 +10,15 @@ import ( "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/modules" - "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" "math/big" ) type Gourmet struct { modules.ModuleBase - modelGourmet *modelGourmet - api *apiComp - configure *configureComp - modelAtlas *modelAtlas + api *apiComp + configure *configureComp + modelAtlas *modelAtlas } func NewModule() core.IModule { @@ -40,115 +38,15 @@ func (this *Gourmet) Init(service core.IService, module core.IModule, options co func (this *Gourmet) OnInstallComp() { this.ModuleBase.OnInstallComp() this.api = this.RegisterComp(new(apiComp)).(*apiComp) - this.modelGourmet = this.RegisterComp(new(modelGourmet)).(*modelGourmet) this.configure = this.RegisterComp(new(configureComp)).(*configureComp) this.modelAtlas = this.RegisterComp(new(modelAtlas)).(*modelAtlas) } -// 接口信息 -func (this *Gourmet) ModifyGourmetData(uid string, data map[string]interface{}) (code pb.ErrorCode) { - err := this.modelGourmet.modifyGourmetDataByObjId(uid, data) - if err != nil { - code = pb.ErrorCode_DBError - } - return -} - //红点查询 func (this *Gourmet) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (reddot map[comm.ReddotType]bool) { - reddot = make(map[comm.ReddotType]bool) - for _, v := range rid { - switch v { - case comm.Reddot20: - reddot[comm.Reddot20] = this.CheckPoint20(session.GetUserId()) - break - case comm.Reddot21: - reddot[comm.Reddot21] = this.CheckPoint21(session.GetUserId()) - break - case comm.Reddot22: - reddot[comm.Reddot22] = this.CheckPoint22(session.GetUserId()) - break - } - } return } -func (this *Gourmet) CheckPoint20(uid string) bool { - - _gourmet, err := this.modelGourmet.getGourmetList(uid) - if err != nil { - return false - } - if _gourmet.OrderCostTime > 0 { - return false - } - return true -} - -func (this *Gourmet) CheckPoint21(uid string) bool { - - _gourmet, err := this.modelGourmet.getGourmetList(uid) - if err != nil { - - return false - } - for skillType := range _gourmet.Skill { - skilllv, _ := _gourmet.Skill[skillType] - if this.configure.GetGourmetConfigData(skillType, skillType+1) == nil { // 下一级是否存在 - - return false - } - _skillCfg := this.configure.GetGourmetConfigData(skillType, skilllv) // 获取技能配置 - for _, v := range _skillCfg.SkillConsume { - if v.A == comm.AttrType { //用户属性资源 - if amount := this.ModuleUser.QueryAttributeValue(uid, v.T); amount < int64(v.N) { - - return false - } - } else if v.A == comm.ItemType { //道具资源 - if amount := this.ModuleItems.QueryItemAmount(uid, v.T); amount < uint32(v.N) { - - return false - } - } - } - } - // 特殊技能判断 - for skillType := range _gourmet.SpecialSkill { - skilllv, _ := _gourmet.Skill[skillType] - if this.configure.GetGourmetConfigData(skillType, skillType+1) == nil { // 下一级是否存在 - - return false - } - _skillCfg := this.configure.GetGourmetConfigData(skillType, skilllv) // 获取技能配置 - for _, v := range _skillCfg.SkillConsume { - if v.A == comm.AttrType { //用户属性资源 - if amount := this.ModuleUser.QueryAttributeValue(uid, v.T); amount < int64(v.N) { - - return false - } - } else if v.A == comm.ItemType { //道具资源 - if amount := this.ModuleItems.QueryItemAmount(uid, v.T); amount < uint32(v.N) { - - return false - } - } - } - } - return true -} - -func (this *Gourmet) CheckPoint22(uid string) bool { - _gourmet, err := this.modelGourmet.getGourmetList(uid) - if err != nil { - - return false - } - if len(_gourmet.Items) > 0 { // 有可领取的 直接返回 - return true - } - return false -} // 获取做菜成功率 返回菜单的ID func (this *Gourmet) GetSuccessRate(m map[string]int32, conf *cfg.GameBreakingbadData) (cid string) {