/* 模块名:Smithy 描述:美食家模块 开发:梅雄风 */ package smithy import ( "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/modules" "go_dreamfactory/pb" "go_dreamfactory/sys/configure" ) type Smithy struct { modules.ModuleBase modelTrade *modelTrade api *apiComp configure *configureComp modelStove *modelStove modelAtlas *modelAtlas modelTask *modelTask } func NewModule() core.IModule { return &Smithy{} } func (this *Smithy) GetType() core.M_Modules { return comm.ModuleSmithy } func (this *Smithy) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { err = this.ModuleBase.Init(service, module, options) return } func (this *Smithy) OnInstallComp() { this.ModuleBase.OnInstallComp() this.api = this.RegisterComp(new(apiComp)).(*apiComp) this.configure = this.RegisterComp(new(configureComp)).(*configureComp) this.modelTrade = this.RegisterComp(new(modelTrade)).(*modelTrade) this.modelStove = this.RegisterComp(new(modelStove)).(*modelStove) this.modelAtlas = this.RegisterComp(new(modelAtlas)).(*modelAtlas) this.modelTask = this.RegisterComp(new(modelTask)).(*modelTask) } func (this *Smithy) CheckActivateAtlasCollect(uid string, id string) (code pb.ErrorCode) { atlasConf := this.configure.GetSmithyAtlasConf(id) if atlasConf != nil && atlasConf.TypeId == 2 { //类型为2表示特殊类型图鉴 if list, err := this.modelAtlas.getSmithyAtlasList(uid); err == nil { if _, ok := list.Collect[id]; !ok { list.Collect[id] = &pb.CollectData{ Id: id, Score: atlasConf.AtlasScore, Time: configure.Now().Unix(), Activate: false, } //list.Score += atlasConf.AtlasScore update := make(map[string]interface{}, 0) update["collect"] = list.Collect //update["score"] = list.Score this.modelAtlas.modifySmithyAtlasList(uid, update) // 更新信息 return } } } code = pb.ErrorCode_SmithyNoFoundAtlas return } func (this *Smithy) SendRdTask(session comm.IUserSession, Items []*pb.UserAssets) { var equip map[int32]int32 // key xingji value 数量 equip = make(map[int32]int32, 0) tasks := make([]*comm.TaskParam, 0) for _, v := range Items { if cfg := this.configure.GetEquipmentConfigureById(v.T); cfg == nil { equip[cfg.Star]++ } } for k, v := range equip { tasks = append(tasks, comm.GettaskParam(comm.Rtype51, v, k)) // this.ModuleRtask.SendToRtask(session, comm.Rtype51, v, k) } go this.ModuleRtask.TriggerTask(session.GetUserId(), tasks...) }