87 lines
1.9 KiB
Go
87 lines
1.9 KiB
Go
package island
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/base"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
/*
|
|
模块名:Pack
|
|
描述:背包系统模块
|
|
开发:李伟
|
|
*/
|
|
func NewModule() core.IModule {
|
|
m := new(IsLand)
|
|
return m
|
|
}
|
|
|
|
type IsLand struct {
|
|
modules.ModuleBase
|
|
service base.IRPCXService
|
|
hero comm.IHero
|
|
battle comm.IBattle
|
|
api *apiComp
|
|
model *modelComp
|
|
modelhero *modelHeroComp
|
|
configure *ConfigureComp
|
|
}
|
|
|
|
func (this *IsLand) GetType() core.M_Modules {
|
|
return comm.ModuleIsLand
|
|
}
|
|
|
|
func (this *IsLand) 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.(comm.IService)
|
|
return
|
|
}
|
|
|
|
func (this *IsLand) OnInstallComp() {
|
|
this.ModuleBase.OnInstallComp()
|
|
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
|
this.model = this.RegisterComp(new(modelComp)).(*modelComp)
|
|
this.modelhero = this.RegisterComp(new(modelHeroComp)).(*modelHeroComp)
|
|
this.configure = this.RegisterComp(new(ConfigureComp)).(*ConfigureComp)
|
|
}
|
|
|
|
func (this *IsLand) Start() (err error) {
|
|
if err = this.ModuleBase.Start(); err != nil {
|
|
return
|
|
}
|
|
var module core.IModule
|
|
if module, err = this.service.GetModule(comm.ModuleHero); err != nil {
|
|
return
|
|
}
|
|
this.hero = module.(comm.IHero)
|
|
if module, err = this.service.GetModule(comm.ModuleBattle); err != nil {
|
|
return
|
|
}
|
|
this.battle = module.(comm.IBattle)
|
|
return
|
|
}
|
|
|
|
func (this *IsLand) Delivery(session comm.IUserSession, pId int32) (errdata *pb.ErrorData, items []*pb.UserAtno) {
|
|
var (
|
|
info *pb.DBIsland
|
|
err error
|
|
)
|
|
|
|
if info, err = this.model.getmodel(session.GetUserId()); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
info.Vip = true
|
|
this.model.Change(session.GetUserId(), map[string]interface{}{
|
|
"vip": info.Vip,
|
|
})
|
|
return
|
|
}
|