/* 模块名:Gourmet 描述:美食家模块 开发:梅雄风 */ package gourmet import ( "crypto/rand" "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/modules" cfg "go_dreamfactory/sys/configure/structs" "math/big" ) type Gourmet struct { modules.ModuleBase api *apiComp configure *configureComp modelAtlas *modelAtlas } 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.configure = this.RegisterComp(new(configureComp)).(*configureComp) this.modelAtlas = this.RegisterComp(new(modelAtlas)).(*modelAtlas) } //红点查询 func (this *Gourmet) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (reddot map[comm.ReddotType]bool) { return } // 获取做菜成功率 返回菜单的ID func (this *Gourmet) GetSuccessRate(m map[string]int32, conf *cfg.GameBreakingbadData) (cid string) { if conf == nil { return } var ( rate int32 ) for _, v := range conf.Recipe { if v1, ok := m[v.A]; ok { rate += v.N * v1 } } n, _ := rand.Int(rand.Reader, big.NewInt(100)) if n.Int64() < int64(rate) { return conf.Delicacies } else { cid = this.configure.GetNormalGourmetFood() } return }