go_dreamfactory/modules/moonlv/module.go
2024-01-10 17:55:41 +08:00

119 lines
3.0 KiB
Go

package moonlv
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
)
type Moonlv struct {
modules.ModuleBase
api *apiComp
configure *configureComp
modelMoonlv *modelMoonlv
service core.IService
}
func NewModule() core.IModule {
return &Moonlv{}
}
func (this *Moonlv) GetType() core.M_Modules {
return comm.ModuleMoonlv
}
func (this *Moonlv) 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 *Moonlv) OnInstallComp() {
this.ModuleBase.OnInstallComp()
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
this.modelMoonlv = this.RegisterComp(new(modelMoonlv)).(*modelMoonlv)
}
func (this *Moonlv) BuriedsNotify(session comm.IUserSession, conds []*pb.ConIProgress) {
// var groupID int32
// this.Debug("护月任务通知", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "conds", Value: conds})
// dt, err := this.modelMoonlv.getMoonlvList(session)
// if c, e := this.configure.GetMoonLvConf(dt.Lv); e == nil {
// groupID = c.TaskGroupId
// }
// confList, err := this.configure.GetMoonLvTaskConf(groupID)
// if err != nil {
// this.Error(err.Error())
// return
// }
// condMap := make(map[int32]*pb.ConIProgress)
// for _, conf := range confList {
// for _, cond := range conds {
// if cond.Conid == conf.TaskId {
// condMap[conf.TaskId] = cond
// }
// }
// }
// update := make(map[string]interface{})
// if dt.Tasks == nil {
// for k, v := range condMap {
// tt := &pb.MoonTask{
// TaskId: k,
// }
// if v.State == pb.BuriedItemFinishState_buried_finish {
// tt.Received = 1
// }
// dt.Tasks = append(dt.Tasks, tt)
// }
// update["tasks"] = dt.Tasks
// if err := this.modelMoonlv.modifyMoonlvList(session.GetUserId(), update); err != nil {
// this.Error(err.Error())
// return
// }
// return
// }
// var newTask []*pb.MoonTask
// existTaskMap := make(map[int32]*pb.MoonTask)
// for _, task := range dt.Tasks {
// existTaskMap[task.TaskId] = task
// }
// for k, v := range condMap {
// if task, ok := existTaskMap[k]; ok {
// if v.State == pb.BuriedItemFinishState_buried_finish {
// task.Received = 1
// }
// } else {
// nt := &pb.MoonTask{
// TaskId: k,
// }
// if v.State == pb.BuriedItemFinishState_buried_finish {
// nt.Received = 1
// }
// newTask = append(newTask, nt)
// }
// }
// dt.Tasks = append(dt.Tasks, newTask...)
// update["tasks"] = dt.Tasks
// if len(update) > 0 {
// if err := this.modelMoonlv.modifyMoonlvList(session.GetUserId(), update); err != nil {
// this.Error(err.Error())
// return
// }
// }
}
func (this *Moonlv) GMCreateMoonlv(session comm.IUserSession, lv int32) {
if lv <= 0 {
return
}
this.modelMoonlv.modifyMoonlvList(session.GetUserId(), map[string]interface{}{"lv": lv})
}