/* 模块名:Gourmet 描述:美食家模块 开发:梅雄风 */ package gourmet import ( "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/modules" "go_dreamfactory/pb" ) type Gourmet struct { modules.ModuleBase modelGourmet *modelGourmet api *apiComp configure *configureComp } func NewModule() core.IModule { return &Gourmet{} } func (this *Gourmet) GetType() core.M_Modules { return comm.ModuleGourmet } func (this *Gourmet) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { err = this.ModuleBase.Init(service, module, options) return } 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) } // 接口信息 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 }