65 lines
1.5 KiB
Go
65 lines
1.5 KiB
Go
/*
|
|
模块名:viking
|
|
描述:维京远征
|
|
开发:梅雄风
|
|
*/
|
|
package viking
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
type Viking struct {
|
|
modules.ModuleBase
|
|
modelViking *modelViking
|
|
api *apiComp
|
|
configure *configureComp
|
|
}
|
|
|
|
func NewModule() core.IModule {
|
|
return &Viking{}
|
|
}
|
|
|
|
func (this *Viking) GetType() core.M_Modules {
|
|
return comm.ModuleViking
|
|
}
|
|
|
|
func (this *Viking) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
|
err = this.ModuleBase.Init(service, module, options)
|
|
|
|
return
|
|
}
|
|
|
|
func (this *Viking) OnInstallComp() {
|
|
this.ModuleBase.OnInstallComp()
|
|
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
|
this.modelViking = this.RegisterComp(new(modelViking)).(*modelViking)
|
|
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
|
}
|
|
|
|
// 接口信息
|
|
func (this *Viking) ModifyVikingData(uid string, data map[string]interface{}) (code pb.ErrorCode) {
|
|
err := this.modelViking.modifyVikingDataByObjId(uid, data)
|
|
if err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
}
|
|
return
|
|
}
|
|
func (this *Viking) GetDropReward(dropId int32, Items []*cfg.Gameatn) {
|
|
Items = make([]*cfg.Gameatn, 0)
|
|
|
|
data := this.configure.GetDropData(dropId)
|
|
szW := make([]int32, 0)
|
|
for _, value := range data {
|
|
szW = append(szW, value.P)
|
|
}
|
|
index := comm.GetRandW(szW)
|
|
Items = append(Items, data[index].Prize...)
|
|
|
|
return
|
|
}
|