113 lines
3.2 KiB
Go
113 lines
3.2 KiB
Go
package mainline
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
type Mainline struct {
|
|
modules.ModuleBase
|
|
modelMainline *ModelMainline
|
|
api *apiComp
|
|
configure *configureComp
|
|
}
|
|
|
|
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)
|
|
|
|
return
|
|
}
|
|
|
|
func (this *Mainline) OnInstallComp() {
|
|
this.ModuleBase.OnInstallComp()
|
|
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
|
this.modelMainline = this.RegisterComp(new(ModelMainline)).(*ModelMainline)
|
|
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
|
}
|
|
|
|
// 接口信息 给其他模块调用 用来修改主线关卡信息
|
|
func (this *Mainline) ModifyMainlineData(uid string, objId string, data map[string]interface{}) (code pb.ErrorCode) {
|
|
err := this.modelMainline.modifyMainlineData(uid, objId, data)
|
|
if err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
}
|
|
return
|
|
}
|
|
|
|
// 校验是否能挑战该关卡
|
|
func (this *Mainline) CheckChallengeChapter(storyObjId string, uid string, zhangjieID int32, Intensity string) (code pb.ErrorCode) {
|
|
|
|
// _szData, err := this.modelMainline.getMainlineList(uid)
|
|
// if err != nil {
|
|
// code = pb.ErrorCode_DBError
|
|
// return
|
|
// }
|
|
// sort.SliceStable(_szData, func(i, j int) bool { // 排序
|
|
// return _szData[i].ChapterId > _szData[j].ChapterId
|
|
// })
|
|
|
|
// 获取当前关卡数据
|
|
curChapter := this.modelMainline.getOneChapterInfo(uid, storyObjId)
|
|
if curChapter == nil {
|
|
code = pb.ErrorCode_MainlineNotFindChapter // 没有找到主线关卡信息
|
|
return
|
|
}
|
|
stroyId := curChapter.ChapterId
|
|
// 获取关卡难度用来取配置文件
|
|
if Intensity == comm.MailLineEasy {
|
|
configData := this.configure.GetMainlineEasyChapter(curChapter.MainlineId)
|
|
if configData != nil { // 校验章节
|
|
if configData.Chapter != zhangjieID {
|
|
code = pb.ErrorCode_ConfigNoFound
|
|
return
|
|
}
|
|
// 如果这一关是路线二的话
|
|
if configData.Route == 2 && curChapter.ChapterId > stroyId { // 当前的关卡ID 大于路线2的ID 即可
|
|
return
|
|
}
|
|
// 判断下一关是不是当前传入的值
|
|
if configData.Previoustage != stroyId {
|
|
code = pb.ErrorCode_MainlineIDFailed
|
|
return
|
|
}
|
|
}
|
|
} else if Intensity == comm.MailLineHard {
|
|
configData := this.configure.GetMainlineHardChapter(curChapter.MainlineId)
|
|
if configData != nil { // 校验章节
|
|
if configData.Chapter != zhangjieID {
|
|
code = pb.ErrorCode_ConfigNoFound
|
|
return
|
|
}
|
|
// 判断下一关是不是当前传入的值
|
|
if configData.Previoustage != stroyId {
|
|
code = pb.ErrorCode_MainlineIDFailed
|
|
return
|
|
}
|
|
}
|
|
} else {
|
|
configData := this.configure.GetMainlinePurgatoryChapter(curChapter.MainlineId)
|
|
if configData != nil { // 校验章节
|
|
if configData.Chapter != zhangjieID {
|
|
code = pb.ErrorCode_ConfigNoFound
|
|
return
|
|
}
|
|
// 判断下一关是不是当前传入的值
|
|
if configData.Previoustage != stroyId {
|
|
code = pb.ErrorCode_MainlineIDFailed
|
|
return
|
|
}
|
|
}
|
|
}
|
|
return
|
|
}
|