go_dreamfactory/modules/gourmet/module.go
2023-06-05 16:14:34 +08:00

71 lines
1.4 KiB
Go

/*
模块名:Gourmet
描述:美食家模块
开发:梅雄风
*/
package gourmet
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
cfg "go_dreamfactory/sys/configure/structs"
"math/rand"
)
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
}
}
if rand.Int31n(100) < rate {
return conf.Delicacies
} else {
cid = this.configure.GetNormalGourmetFood()
}
return
}