141 lines
3.5 KiB
Go
141 lines
3.5 KiB
Go
package hunting
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
type Hunting struct {
|
|
modules.ModuleBase
|
|
modelHunting *modelHunting
|
|
api *apiComp
|
|
configure *configureComp
|
|
modulerank *ModelRank
|
|
battle comm.IBattle
|
|
service core.IService
|
|
battlerecord comm.IBattleRecord // 战报模块
|
|
}
|
|
|
|
func NewModule() core.IModule {
|
|
return &Hunting{}
|
|
}
|
|
|
|
func (this *Hunting) GetType() core.M_Modules {
|
|
return comm.ModuleHunting
|
|
}
|
|
|
|
func (this *Hunting) 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 *Hunting) Start() (err error) {
|
|
if err = this.ModuleBase.Start(); err != nil {
|
|
return
|
|
}
|
|
var module core.IModule
|
|
if module, err = this.service.GetModule(comm.ModuleBattle); err != nil {
|
|
return
|
|
}
|
|
|
|
this.battle = module.(comm.IBattle)
|
|
if module, err = this.service.GetModule(comm.ModuleBattleRecord); err != nil {
|
|
return
|
|
}
|
|
this.battlerecord = module.(comm.IBattleRecord)
|
|
return
|
|
}
|
|
|
|
func (this *Hunting) OnInstallComp() {
|
|
this.ModuleBase.OnInstallComp()
|
|
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
|
this.modelHunting = this.RegisterComp(new(modelHunting)).(*modelHunting)
|
|
this.modulerank = this.RegisterComp(new(ModelRank)).(*ModelRank)
|
|
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
|
}
|
|
|
|
// 接口信息
|
|
func (this *Hunting) ModifyHuntingData(uid string, data map[string]interface{}) (errdata *pb.ErrorData) {
|
|
err := this.modelHunting.modifyHuntingDataByObjId(uid, data)
|
|
if err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *Hunting) CheckUserBaseHuntingInfo(uid string) (data []*pb.DBHuntingRank) {
|
|
|
|
if d := this.modulerank.getHuntingRank(uid); d.Id != "" {
|
|
for k, v := range d.Data {
|
|
data = append(data, &pb.DBHuntingRank{
|
|
Uinfo: d.Uinfo,
|
|
Line: v.Line[v.Maxnandu],
|
|
Difficulty: v.Maxnandu,
|
|
Bosstype: k,
|
|
Costtime: v.Costime[v.Maxnandu],
|
|
})
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
//红点查询
|
|
func (this *Hunting) Reddot(session comm.IUserSession, rid map[comm.ReddotType]struct{}) (items map[comm.ReddotType]*pb.ReddotItem) {
|
|
var (
|
|
selfrid []comm.ReddotType = []comm.ReddotType{comm.Reddot17}
|
|
ok bool
|
|
)
|
|
items = make(map[comm.ReddotType]*pb.ReddotItem)
|
|
for _, v := range selfrid {
|
|
if _, ok = rid[v]; ok {
|
|
break
|
|
}
|
|
}
|
|
if ok {
|
|
return
|
|
}
|
|
for _, v := range selfrid {
|
|
if _, ok = rid[v]; ok {
|
|
switch v {
|
|
case comm.Reddot14102:
|
|
items[comm.Reddot14102] = &pb.ReddotItem{
|
|
Rid: int32(comm.Reddot14102),
|
|
Activated: this.modelHunting.checkReddot32(session),
|
|
}
|
|
break
|
|
}
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
// 解锁远征所有难度
|
|
func (this *Hunting) CompleteAllLevel(session comm.IUserSession) (errdata *pb.ErrorData) {
|
|
list, _ := this.modelHunting.getHuntingList(session.GetUserId())
|
|
|
|
list.Boss = make(map[int32]int32)
|
|
list.BossTime = make(map[string]int32)
|
|
|
|
conf := this.configure.GetHuntingBossAllData()
|
|
for k, v := range conf {
|
|
list.Boss[k] = v
|
|
}
|
|
mapData := make(map[string]interface{}, 0)
|
|
|
|
mapData["boss"] = list.Boss
|
|
mapData["bossTime"] = list.BossTime
|
|
errdata = this.ModifyHuntingData(session.GetUserId(), mapData)
|
|
|
|
session.SendMsg(string(this.GetType()), HuntingGetListResp, &pb.HuntingGetListResp{Data: list})
|
|
return
|
|
}
|