140 lines
3.5 KiB
Go
140 lines
3.5 KiB
Go
package mainline
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
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.ModuleMainline
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
// 跳转主线管卡
|
|
func (this *Mainline) BingoJumpLevel(session comm.IUserSession, level int32) (errdata *pb.ErrorData) {
|
|
var (
|
|
info *pb.DBMainline
|
|
confs []*cfg.GameMainStageData
|
|
err error
|
|
)
|
|
|
|
if confs, err = this.configure.GetMainStageConfs(); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
info, err = this.modelMline.getMainlineData(session.GetUserId())
|
|
if err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
info.Level = make(map[int32]int32)
|
|
info.Lastlevel = make(map[int32]int32)
|
|
info.Chapteraward = make(map[int32]*pb.DBMainlineAward)
|
|
info.Exploreaward = make(map[int32]*pb.DBMainlineAward)
|
|
info.Groupaward = make(map[int32]*pb.DBMainlineAward)
|
|
for _, v := range confs {
|
|
if v.Id <= level {
|
|
info.Level[v.Id] = 7
|
|
}
|
|
}
|
|
this.modelMline.updateprogress(info)
|
|
if err = this.modelMline.updateMainlineData(session.GetUserId(), info); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
return
|
|
}
|