go_dreamfactory/modules/mainline/module.go
2023-07-25 16:14:29 +08:00

92 lines
2.2 KiB
Go

package mainline
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
)
type Mainline struct {
modules.ModuleBase
modelMline *ModelMline
service core.IService
api *apiComp
configure *configureComp
battle comm.IBattle
}
func NewModule() core.IModule {
return &Mainline{}
}
func (this *Mainline) GetType() core.M_Modules {
return comm.ModuleMline
}
func (this *Mainline) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
err = this.ModuleBase.Init(service, module, options)
this.service = service
return
}
func (this *Mainline) OnInstallComp() {
this.ModuleBase.OnInstallComp()
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
this.modelMline = this.RegisterComp(new(ModelMline)).(*ModelMline)
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
}
func (this *Mainline) Start() (err error) {
err = this.ModuleBase.Start()
var module core.IModule
if module, err = this.service.GetModule(comm.ModuleBattle); err != nil {
return
}
this.battle = module.(comm.IBattle)
return
}
// 红点查询
func (this *Mainline) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (reddot map[comm.ReddotType]*pb.ReddotItem) {
reddot = make(map[comm.ReddotType]*pb.ReddotItem)
for _, v := range rid {
if v == comm.Reddot24101 {
reddot[comm.Reddot24101] = &pb.ReddotItem{
Rid: int32(comm.Reddot24101),
Activated: this.CheckPoint(session.GetUserId()),
}
break
}
}
return
}
// 红点检测
func (this *Mainline) CheckPoint(uid string) bool {
// info, err := this.modelMline.getMainlineData(uid)
// if err != nil {
// return false
// }
// for _, v := range list {
// mLineConf := this.configure.GetMainChapterConf(v.ChapterId)
// if mLineConf == nil {
// return false
// }
// var maxstar int32
// for _, v1 := range v.Star {
// maxstar += v1
// }
// awardConf := this.configure.GetMainStarRewardConf(mLineConf.Starreward)
// for _, v1 := range awardConf {
// if v1.Starnum > maxstar {
// break
// }
// if _, ok := v.Award[v1.Starnum]; !ok { // 找到没有领奖的数据
// return true
// }
// }
// }
return false
}