113 lines
2.4 KiB
Go
113 lines
2.4 KiB
Go
package jielong
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
type Jielong struct {
|
|
modules.ModuleBase
|
|
service core.IService
|
|
api *apiComp
|
|
configure *configureComp
|
|
|
|
modelJielong *ModelJielong
|
|
}
|
|
|
|
func NewModule() core.IModule {
|
|
return &Jielong{}
|
|
}
|
|
|
|
func (this *Jielong) GetType() core.M_Modules {
|
|
return comm.ModuleJielong
|
|
}
|
|
|
|
func (this *Jielong) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
|
if err = this.ModuleBase.Init(service, module, options); err != nil {
|
|
return
|
|
}
|
|
this.service = service
|
|
return
|
|
}
|
|
|
|
func (this *Jielong) Start() (err error) {
|
|
if err = this.ModuleBase.Start(); err != nil {
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
func (this *Jielong) OnInstallComp() {
|
|
this.ModuleBase.OnInstallComp()
|
|
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
|
this.modelJielong = this.RegisterComp(new(ModelJielong)).(*ModelJielong)
|
|
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
|
}
|
|
|
|
// 红点需求
|
|
func (this *Jielong) Reddot(session comm.IUserSession, rid map[comm.ReddotType]struct{}) (items map[comm.ReddotType]*pb.ReddotItem) {
|
|
var (
|
|
selfrid []comm.ReddotType = []comm.ReddotType{comm.Reddot38106}
|
|
info *pb.DBJielongData
|
|
err error
|
|
ok bool
|
|
)
|
|
items = make(map[comm.ReddotType]*pb.ReddotItem)
|
|
for _, v := range selfrid {
|
|
if _, ok = rid[v]; ok {
|
|
break
|
|
}
|
|
}
|
|
|
|
if !ok {
|
|
return
|
|
}
|
|
|
|
if info, err = this.modelJielong.getUserJielongData(session.GetUserId()); err != nil {
|
|
return
|
|
}
|
|
|
|
for _, v := range selfrid {
|
|
if _, ok = rid[v]; ok {
|
|
switch v {
|
|
case comm.Reddot38106:
|
|
if c, e := this.configure.getGameFastDataByType(1); e != nil {
|
|
break
|
|
} else {
|
|
for _, v := range c {
|
|
if info.Weekmax >= v.Condition {
|
|
if _, ok := info.Reward[v.Key]; !ok {
|
|
items[comm.Reddot38106] = &pb.ReddotItem{
|
|
Rid: int32(comm.Reddot38106),
|
|
Activated: true,
|
|
}
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if c, e := this.configure.getGameFastDataByType(2); e != nil {
|
|
break
|
|
} else {
|
|
for _, v := range c {
|
|
if info.Hisotry >= v.Condition {
|
|
if _, ok := info.Gotarr[v.Key]; !ok {
|
|
items[comm.Reddot38106] = &pb.ReddotItem{
|
|
Rid: int32(comm.Reddot38106),
|
|
Activated: true,
|
|
}
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break
|
|
}
|
|
}
|
|
}
|
|
return
|
|
}
|