123 lines
2.9 KiB
Go
123 lines
2.9 KiB
Go
package horoscope
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/base"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
/*
|
|
模块名:星座图
|
|
描述:全局属性增幅器
|
|
开发:李伟
|
|
*/
|
|
|
|
var _ comm.IHoroscope = (*Horoscope)(nil)
|
|
|
|
func NewModule() core.IModule {
|
|
m := new(Horoscope)
|
|
return m
|
|
}
|
|
|
|
type Horoscope struct {
|
|
modules.ModuleBase
|
|
service base.IRPCXService //rpc服务对象 通过这个对象可以发布服务和调用其他服务的接口
|
|
options *Options
|
|
api_comp *apiComp
|
|
configure *configureComp
|
|
modelHoroscope *modelHoroscope
|
|
}
|
|
|
|
// 模块名
|
|
func (this *Horoscope) GetType() core.M_Modules {
|
|
return comm.ModuleHoroscope
|
|
}
|
|
|
|
// 模块初始化接口 注册用户创建角色事件
|
|
func (this *Horoscope) 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.(base.IRPCXService)
|
|
return
|
|
}
|
|
|
|
func (this *Horoscope) Start() (err error) {
|
|
if err = this.ModuleBase.Start(); err != nil {
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
// 装备组件
|
|
func (this *Horoscope) OnInstallComp() {
|
|
this.ModuleBase.OnInstallComp()
|
|
this.api_comp = this.RegisterComp(new(apiComp)).(*apiComp)
|
|
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
|
this.modelHoroscope = this.RegisterComp(new(modelHoroscope)).(*modelHoroscope)
|
|
}
|
|
|
|
// 计算英雄数值
|
|
func (this *Horoscope) ComputeHeroNumeric(uid string, hero ...*pb.DBHero) {
|
|
this.modelHoroscope.computeHeroNumeric(uid, hero...)
|
|
return
|
|
}
|
|
|
|
// 红点需求
|
|
func (this *Horoscope) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (result map[comm.ReddotType]*pb.ReddotItem) {
|
|
result = make(map[comm.ReddotType]*pb.ReddotItem)
|
|
for _, v := range rid {
|
|
switch v {
|
|
case comm.Reddot17:
|
|
result[comm.Reddot17] = &pb.ReddotItem{
|
|
Rid: int32(comm.Reddot17),
|
|
Activated: this.modelHoroscope.reddot(session),
|
|
}
|
|
break
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
// GM 满级星座图
|
|
func (this *Horoscope) GMFulllevel(session comm.IUserSession) (errdata *pb.ErrorData) {
|
|
var (
|
|
confs map[int32]*cfg.GameHoroscopeData
|
|
info *pb.DBHoroscope
|
|
err error
|
|
)
|
|
|
|
if confs, err = this.configure.getMaxHoroscopes(); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
if info, err = this.modelHoroscope.queryInfo(session.GetUserId()); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
for k, v := range confs {
|
|
info.Nodes[k] = v.Lv
|
|
}
|
|
if err = this.modelHoroscope.updateInfo(session, info); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
return
|
|
}
|