附魔boss 字段修改
This commit is contained in:
parent
5aedd33442
commit
08dfb99e03
@ -75,6 +75,7 @@ const (
|
|||||||
ModuleWorldtask core.M_Modules = "worldtask" //世界任务
|
ModuleWorldtask core.M_Modules = "worldtask" //世界任务
|
||||||
ModuleReddot core.M_Modules = "reddot" //红点
|
ModuleReddot core.M_Modules = "reddot" //红点
|
||||||
ModuleCombat core.M_Modules = "combat" //关卡编辑
|
ModuleCombat core.M_Modules = "combat" //关卡编辑
|
||||||
|
ModuleEnchant core.M_Modules = "enchant" //附魔
|
||||||
)
|
)
|
||||||
|
|
||||||
//数据表名定义处
|
//数据表名定义处
|
||||||
@ -203,6 +204,9 @@ const (
|
|||||||
TableCombat = "combat"
|
TableCombat = "combat"
|
||||||
/// vip
|
/// vip
|
||||||
TableVip = "vip"
|
TableVip = "vip"
|
||||||
|
|
||||||
|
TableEnchantRank = "enchantRank"
|
||||||
|
TableEnchant = "enchant"
|
||||||
)
|
)
|
||||||
|
|
||||||
//RPC服务接口定义处
|
//RPC服务接口定义处
|
||||||
|
@ -20,7 +20,7 @@ type apiComp struct {
|
|||||||
modules.MCompGate
|
modules.MCompGate
|
||||||
service core.IService
|
service core.IService
|
||||||
configure *configureComp
|
configure *configureComp
|
||||||
module *Hunting
|
module *Enchant
|
||||||
friend comm.IFriend
|
friend comm.IFriend
|
||||||
chat comm.IChat
|
chat comm.IChat
|
||||||
}
|
}
|
||||||
@ -28,7 +28,7 @@ type apiComp struct {
|
|||||||
//组件初始化接口
|
//组件初始化接口
|
||||||
func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
err = this.MCompGate.Init(service, module, comp, options)
|
err = this.MCompGate.Init(service, module, comp, options)
|
||||||
this.module = module.(*Hunting)
|
this.module = module.(*Enchant)
|
||||||
|
|
||||||
this.service = service
|
this.service = service
|
||||||
return
|
return
|
||||||
|
@ -33,7 +33,7 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.HuntingBuyReq) (code
|
|||||||
if code != pb.ErrorCode_Success {
|
if code != pb.ErrorCode_Success {
|
||||||
return // 参数校验失败直接返回
|
return // 参数校验失败直接返回
|
||||||
}
|
}
|
||||||
list, err := this.module.modelHunting.getHuntingList(session.GetUserId())
|
list, err := this.module.modelEnchant.getEnchantList(session.GetUserId())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
return
|
return
|
||||||
@ -130,7 +130,7 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.HuntingBuyReq) (code
|
|||||||
}
|
}
|
||||||
list.BuyCount = curByCount
|
list.BuyCount = curByCount
|
||||||
mapData["buyCount"] = curByCount
|
mapData["buyCount"] = curByCount
|
||||||
code = this.module.ModifyHuntingData(session.GetUserId(), mapData)
|
code = this.module.ModifyEnchantData(session.GetUserId(), mapData)
|
||||||
|
|
||||||
session.SendMsg(string(this.module.GetType()), HuntingBuyResp, &pb.HuntingBuyResp{Data: list})
|
session.SendMsg(string(this.module.GetType()), HuntingBuyResp, &pb.HuntingBuyResp{Data: list})
|
||||||
return
|
return
|
||||||
|
@ -25,7 +25,7 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.HuntingChallen
|
|||||||
return // 参数校验失败直接返回
|
return // 参数校验失败直接返回
|
||||||
}
|
}
|
||||||
|
|
||||||
hunting, err := this.module.modelHunting.getHuntingList(session.GetUserId())
|
hunting, err := this.module.modelEnchant.getEnchantList(session.GetUserId())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
code = pb.ErrorCode_PagodaNotFound
|
code = pb.ErrorCode_PagodaNotFound
|
||||||
return
|
return
|
||||||
@ -44,11 +44,8 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.HuntingChallen
|
|||||||
code = pb.ErrorCode_HuntingNoChallengeCount
|
code = pb.ErrorCode_HuntingNoChallengeCount
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// if hunting.ChallengeCount > this.module.configure.GetGlobalConf().HuntingNum+hunting.BuyCount {
|
|
||||||
// code = pb.ErrorCode_HuntingMaxChallengeCount
|
cfgData := this.module.configure.GetEnchantBossConfigData(req.BossType)
|
||||||
// return
|
|
||||||
// }
|
|
||||||
cfgData := this.module.configure.GetHuntingBossConfigData(req.BossType, req.Difficulty)
|
|
||||||
if cfgData == nil {
|
if cfgData == nil {
|
||||||
code = pb.ErrorCode_ConfigNoFound
|
code = pb.ErrorCode_ConfigNoFound
|
||||||
return
|
return
|
||||||
@ -71,7 +68,7 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.HuntingChallen
|
|||||||
Leadpos: req.Leadpos,
|
Leadpos: req.Leadpos,
|
||||||
Format: req.Teamids,
|
Format: req.Teamids,
|
||||||
},
|
},
|
||||||
Mformat: cfgData.Boss,
|
//Mformat: cfgData.Boss,
|
||||||
})
|
})
|
||||||
if code != pb.ErrorCode_Success {
|
if code != pb.ErrorCode_Success {
|
||||||
return
|
return
|
||||||
|
@ -21,19 +21,19 @@ func (this *apiComp) ChallengeOverCheck(session comm.IUserSession, req *pb.Hunti
|
|||||||
///挑战主线关卡
|
///挑战主线关卡
|
||||||
func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.HuntingChallengeOverReq) (code pb.ErrorCode, data proto.Message) {
|
func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.HuntingChallengeOverReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
var (
|
var (
|
||||||
mapData map[string]interface{}
|
mapData map[string]interface{}
|
||||||
newChallenge bool // 新的关卡
|
// newChallenge bool // 新的关卡
|
||||||
reward []*cfg.Gameatn
|
// reward []*cfg.Gameatn
|
||||||
bWin bool // 战斗是否胜利
|
bWin bool // 战斗是否胜利
|
||||||
)
|
)
|
||||||
mapData = make(map[string]interface{}, 0)
|
mapData = make(map[string]interface{}, 0)
|
||||||
reward = make([]*cfg.Gameatn, 0)
|
// reward = make([]*cfg.Gameatn, 0)
|
||||||
code = this.ChallengeOverCheck(session, req)
|
code = this.ChallengeOverCheck(session, req)
|
||||||
if code != pb.ErrorCode_Success {
|
if code != pb.ErrorCode_Success {
|
||||||
return // 参数校验失败直接返回
|
return // 参数校验失败直接返回
|
||||||
}
|
}
|
||||||
|
|
||||||
hunting, err := this.module.modelHunting.getHuntingList(session.GetUserId())
|
hunting, err := this.module.modelEnchant.getEnchantList(session.GetUserId())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
code = pb.ErrorCode_PagodaNotFound
|
code = pb.ErrorCode_PagodaNotFound
|
||||||
return
|
return
|
||||||
@ -54,7 +54,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.HuntingCha
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
cfgHunting := this.module.configure.GetHuntingBossConfigData(req.BossType, req.Difficulty)
|
cfgHunting := this.module.configure.GetEnchantBossConfigData(req.BossType)
|
||||||
if cfgHunting == nil {
|
if cfgHunting == nil {
|
||||||
code = pb.ErrorCode_ConfigNoFound
|
code = pb.ErrorCode_ConfigNoFound
|
||||||
return
|
return
|
||||||
@ -68,7 +68,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.HuntingCha
|
|||||||
code = pb.ErrorCode_HuntingLvErr
|
code = pb.ErrorCode_HuntingLvErr
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
newChallenge = true
|
//newChallenge = true
|
||||||
}
|
}
|
||||||
// 校验门票数量够不够
|
// 校验门票数量够不够
|
||||||
if code = this.module.ConsumeRes(session, []*cfg.Gameatn{costRes}, true); code != pb.ErrorCode_Success {
|
if code = this.module.ConsumeRes(session, []*cfg.Gameatn{costRes}, true); code != pb.ErrorCode_Success {
|
||||||
@ -92,28 +92,22 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.HuntingCha
|
|||||||
// 耗时校验 当前战斗胜利时间消耗小于之前刷新数据
|
// 耗时校验 当前战斗胜利时间消耗小于之前刷新数据
|
||||||
|
|
||||||
// 发放通关随机奖励
|
// 发放通关随机奖励
|
||||||
reward = this.module.configure.GetDropReward(cfgHunting.Drop) // 获取掉落奖励
|
// reward = this.module.configure.GetDropReward(cfgHunting.) // 获取掉落奖励
|
||||||
if code = this.module.DispenseRes(session, reward, true); code != pb.ErrorCode_Success {
|
// if code = this.module.DispenseRes(session, reward, true); code != pb.ErrorCode_Success {
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
if newChallenge && bWin { // 新关卡挑战通过 发放首通奖励
|
// if newChallenge && bWin { // 新关卡挑战通过 发放首通奖励
|
||||||
if code = this.module.DispenseRes(session, cfgHunting.Firstprize, true); code != pb.ErrorCode_Success {
|
// if code = this.module.DispenseRes(session, cfgHunting.Firstprize, true); code != pb.ErrorCode_Success {
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
hunting.Boss[req.BossType] += 1
|
// hunting.Boss[req.BossType] += 1
|
||||||
mapData["boss"] = hunting.Boss
|
// mapData["boss"] = hunting.Boss
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
|
||||||
for k := range hunting.Boss {
|
|
||||||
hunting.Boss[k] += 1
|
|
||||||
}
|
|
||||||
mapData["challengeTime"] = hunting.BossTime
|
mapData["challengeTime"] = hunting.BossTime
|
||||||
code = this.module.ModifyHuntingData(session.GetUserId(), mapData)
|
code = this.module.ModifyEnchantData(session.GetUserId(), mapData)
|
||||||
session.SendMsg(string(this.module.GetType()), HuntingChallengeOverResp, &pb.HuntingChallengeOverResp{Data: hunting})
|
session.SendMsg(string(this.module.GetType()), HuntingChallengeOverResp, &pb.HuntingChallengeOverResp{Data: hunting})
|
||||||
|
|
||||||
// 随机任务统计
|
|
||||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype81, req.Difficulty, req.BossType)
|
|
||||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype82, req.BossType)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.HuntingGetListRe
|
|||||||
return // 参数校验失败直接返回
|
return // 参数校验失败直接返回
|
||||||
}
|
}
|
||||||
|
|
||||||
list, err := this.module.modelHunting.getHuntingList(session.GetUserId())
|
list, err := this.module.modelEnchant.getEnchantList(session.GetUserId())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
return
|
return
|
||||||
@ -85,7 +85,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.HuntingGetListRe
|
|||||||
list.RecoveryTime = 0
|
list.RecoveryTime = 0
|
||||||
}
|
}
|
||||||
mapData["recoveryTime"] = list.RecoveryTime
|
mapData["recoveryTime"] = list.RecoveryTime
|
||||||
code = this.module.ModifyHuntingData(session.GetUserId(), mapData) //修改内存信息
|
code = this.module.ModifyEnchantData(session.GetUserId(), mapData) //修改内存信息
|
||||||
// 发送难度
|
// 发送难度
|
||||||
for k := range list.Boss {
|
for k := range list.Boss {
|
||||||
list.Boss[k] += 1
|
list.Boss[k] += 1
|
||||||
|
@ -28,7 +28,7 @@ func (this *apiComp) RankList(session comm.IUserSession, req *pb.HuntingRankList
|
|||||||
}
|
}
|
||||||
if !req.Friend {
|
if !req.Friend {
|
||||||
var (
|
var (
|
||||||
pipe *pipe.RedisPipe = this.module.modelHunting.Redis.RedisPipe(context.TODO())
|
pipe *pipe.RedisPipe = this.module.modelEnchant.Redis.RedisPipe(context.TODO())
|
||||||
)
|
)
|
||||||
rd = pipe.ZRange("huntingRank"+strconv.Itoa(int(req.BoosType)), 0, -1)
|
rd = pipe.ZRange("huntingRank"+strconv.Itoa(int(req.BoosType)), 0, -1)
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ func (this *apiComp) RankList(session comm.IUserSession, req *pb.HuntingRankList
|
|||||||
} else {
|
} else {
|
||||||
uids := this.friend.GetFriendList(session.GetUserId())
|
uids := this.friend.GetFriendList(session.GetUserId())
|
||||||
for _, id := range uids {
|
for _, id := range uids {
|
||||||
rankData := this.module.modulerank.getHuntingRankListByBossType(id, req.BoosType)
|
rankData := this.module.modulerank.getEnchantRankListByBossType(id, req.BoosType)
|
||||||
if rankData != nil {
|
if rankData != nil {
|
||||||
szRank = append(szRank, rankData)
|
szRank = append(szRank, rankData)
|
||||||
}
|
}
|
||||||
|
@ -10,45 +10,45 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
game_huntingboss = "game_huntingboss.json"
|
game_enchantboss = "game_enchantboss.json"
|
||||||
game_challenge = "game_huntingchallenge.json"
|
game_enchantshop = "game_enchantshop.json"
|
||||||
)
|
)
|
||||||
|
|
||||||
///配置管理基础组件
|
///配置管理基础组件
|
||||||
type configureComp struct {
|
type configureComp struct {
|
||||||
hlock sync.RWMutex
|
hlock sync.RWMutex
|
||||||
modules.MCompConfigure
|
modules.MCompConfigure
|
||||||
_huntingMap map[int64]*cfg.GameHuntingBossData
|
_enchantMap map[int32][]*cfg.GameEnchantBossData
|
||||||
}
|
}
|
||||||
|
|
||||||
//组件初始化接口
|
//组件初始化接口
|
||||||
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
err = this.MCompConfigure.Init(service, module, comp, options)
|
err = this.MCompConfigure.Init(service, module, comp, options)
|
||||||
|
|
||||||
this._huntingMap = make(map[int64]*cfg.GameHuntingBossData, 0)
|
this._enchantMap = make(map[int32][]*cfg.GameEnchantBossData, 0)
|
||||||
configure.RegisterConfigure(game_huntingboss, cfg.NewGameHuntingBoss, func() {
|
configure.RegisterConfigure(game_enchantboss, cfg.NewGameEnchantBoss, func() {
|
||||||
if v, err := this.GetConfigure(game_huntingboss); err == nil {
|
if v, err := this.GetConfigure(game_enchantboss); err == nil {
|
||||||
if configure, ok := v.(*cfg.GameHuntingBoss); ok {
|
if configure, ok := v.(*cfg.GameEnchantBoss); ok {
|
||||||
this.hlock.Lock()
|
this.hlock.Lock()
|
||||||
defer this.hlock.Unlock()
|
defer this.hlock.Unlock()
|
||||||
for _, value := range configure.GetDataList() {
|
for _, value := range configure.GetDataList() {
|
||||||
this._huntingMap[int64(value.Type<<16)+int64(value.Difficulty)] = value
|
this._enchantMap[value.Bossid] = append(this._enchantMap[value.Bossid], value)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Errorf("get game_huntingboss conf err:%v", err)
|
log.Errorf("get game_enchantboss conf err:%v", err)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
err = this.LoadConfigure(game_challenge, cfg.NewGameHuntingChallenge)
|
err = this.LoadConfigure(game_enchantshop, cfg.NewGameEnchantShop)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 参数: boss类型 难度
|
// 参数: boss类型 难度
|
||||||
func (this *configureComp) GetHuntingBossConfigData(bossType int32, difficulty int32) (data *cfg.GameHuntingBossData) {
|
func (this *configureComp) GetEnchantBossConfigData(bossId int32) (data []*cfg.GameEnchantBossData) {
|
||||||
|
|
||||||
return this._huntingMap[int64(bossType<<16)+int64(difficulty)]
|
return this._enchantMap[bossId]
|
||||||
}
|
}
|
||||||
|
|
||||||
//加载多个配置文件
|
//加载多个配置文件
|
||||||
@ -69,16 +69,16 @@ func (this *configureComp) GetConfigure(name string) (v interface{}, err error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get boss Type
|
// get boss Type
|
||||||
func (this *configureComp) GetHuntingBossTypeConfigData() (mapType map[int32]struct{}) {
|
func (this *configureComp) GetEnchantBossTypeConfigData() (mapType map[int32]struct{}) {
|
||||||
|
|
||||||
mapType = make(map[int32]struct{}, 0)
|
mapType = make(map[int32]struct{}, 0)
|
||||||
if v, err := this.GetConfigure(game_huntingboss); err == nil {
|
if v, err := this.GetConfigure(game_enchantboss); err == nil {
|
||||||
if configure, ok := v.(*cfg.GameHuntingBoss); ok {
|
if configure, ok := v.(*cfg.GameEnchantBoss); ok {
|
||||||
this.hlock.Lock()
|
this.hlock.Lock()
|
||||||
defer this.hlock.Unlock()
|
defer this.hlock.Unlock()
|
||||||
for _, value := range configure.GetDataList() {
|
for _, value := range configure.GetDataList() {
|
||||||
if _, ok := mapType[value.Type]; !ok {
|
if _, ok := mapType[value.Bossid]; !ok {
|
||||||
mapType[value.Type] = struct{}{}
|
mapType[value.Bossid] = struct{}{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,9 +87,9 @@ func (this *configureComp) GetHuntingBossTypeConfigData() (mapType map[int32]str
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *configureComp) GetBuyChallengeCount(index int32) (data *cfg.GameHuntingChallengeData) {
|
func (this *configureComp) GetBuyChallengeCount(index int32) (data *cfg.GameEnchantShopData) {
|
||||||
if v, err := this.GetConfigure(game_challenge); err == nil {
|
if v, err := this.GetConfigure(game_enchantshop); err == nil {
|
||||||
if configure, ok := v.(*cfg.GameHuntingChallenge); ok {
|
if configure, ok := v.(*cfg.GameEnchantShop); ok {
|
||||||
data = configure.Get(index)
|
data = configure.Get(index)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -100,8 +100,8 @@ func (this *configureComp) GetBuyChallengeCount(index int32) (data *cfg.GameHunt
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
func (this *configureComp) GetMaxBuyChallengeCount() int32 {
|
func (this *configureComp) GetMaxBuyChallengeCount() int32 {
|
||||||
if v, err := this.GetConfigure(game_challenge); err == nil {
|
if v, err := this.GetConfigure(game_enchantshop); err == nil {
|
||||||
if configure, ok := v.(*cfg.GameHuntingChallenge); ok {
|
if configure, ok := v.(*cfg.GameEnchantShop); ok {
|
||||||
return int32(len(configure.GetDataList()))
|
return int32(len(configure.GetDataList()))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -13,15 +13,15 @@ import (
|
|||||||
"go.mongodb.org/mongo-driver/x/bsonx"
|
"go.mongodb.org/mongo-driver/x/bsonx"
|
||||||
)
|
)
|
||||||
|
|
||||||
type modelHunting struct {
|
type modelEnchant struct {
|
||||||
modules.MCompModel
|
modules.MCompModel
|
||||||
module *Hunting
|
module *Enchant
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *modelHunting) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
func (this *modelEnchant) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
this.TableName = string(comm.TableHunting)
|
this.TableName = string(comm.TableHunting)
|
||||||
err = this.MCompModel.Init(service, module, comp, options)
|
err = this.MCompModel.Init(service, module, comp, options)
|
||||||
this.module = module.(*Hunting)
|
this.module = module.(*Enchant)
|
||||||
// uid 创建索引
|
// uid 创建索引
|
||||||
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
||||||
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
|
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
|
||||||
@ -29,12 +29,12 @@ func (this *modelHunting) Init(service core.IService, module core.IModule, comp
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *modelHunting) modifyHuntingDataByObjId(uid string, data map[string]interface{}) error {
|
func (this *modelEnchant) modifyEnchantDataByObjId(uid string, data map[string]interface{}) error {
|
||||||
return this.Change(uid, data)
|
return this.Change(uid, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取列表信息
|
// 获取列表信息
|
||||||
func (this *modelHunting) getHuntingList(uid string) (result *pb.DBHunting, err error) {
|
func (this *modelEnchant) getEnchantList(uid string) (result *pb.DBHunting, err error) {
|
||||||
result = &pb.DBHunting{
|
result = &pb.DBHunting{
|
||||||
Id: primitive.NewObjectID().Hex(),
|
Id: primitive.NewObjectID().Hex(),
|
||||||
Uid: uid,
|
Uid: uid,
|
||||||
@ -47,7 +47,7 @@ func (this *modelHunting) getHuntingList(uid string) (result *pb.DBHunting, err
|
|||||||
}
|
}
|
||||||
if mgo.MongodbNil == err {
|
if mgo.MongodbNil == err {
|
||||||
if len(result.Boss) == 0 {
|
if len(result.Boss) == 0 {
|
||||||
_cfg := this.module.configure.GetHuntingBossTypeConfigData()
|
_cfg := this.module.configure.GetEnchantBossTypeConfigData()
|
||||||
for k := range _cfg {
|
for k := range _cfg {
|
||||||
result.Boss[k] = 0
|
result.Boss[k] = 0
|
||||||
str := strconv.Itoa(int(k)) + "_1"
|
str := strconv.Itoa(int(k)) + "_1"
|
||||||
@ -61,7 +61,7 @@ func (this *modelHunting) getHuntingList(uid string) (result *pb.DBHunting, err
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 红点检测
|
// 红点检测
|
||||||
func (this *modelHunting) checkReddot32(uid string) bool {
|
func (this *modelEnchant) checkReddot32(uid string) bool {
|
||||||
|
|
||||||
conf := this.module.configure.GetGlobalConf()
|
conf := this.module.configure.GetGlobalConf()
|
||||||
if conf == nil {
|
if conf == nil {
|
@ -14,13 +14,13 @@ import (
|
|||||||
|
|
||||||
type ModelRank struct {
|
type ModelRank struct {
|
||||||
modules.MCompModel
|
modules.MCompModel
|
||||||
moduleHunting *Hunting
|
moduleHunting *Enchant
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ModelRank) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
func (this *ModelRank) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
this.TableName = comm.TableHuntingRecord // 挑战记录
|
this.TableName = comm.TableHuntingRecord // 挑战记录
|
||||||
err = this.MCompModel.Init(service, module, comp, options)
|
err = this.MCompModel.Init(service, module, comp, options)
|
||||||
this.moduleHunting = module.(*Hunting)
|
this.moduleHunting = module.(*Enchant)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ func (this *ModelRank) AddRankList(uId string, objId string, data *pb.DBHuntingR
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ModelRank) getHuntingRankList(uid string) []*pb.DBHuntingRank {
|
func (this *ModelRank) getEnchantRankList(uid string) []*pb.DBHuntingRank {
|
||||||
ranks := make([]*pb.DBHuntingRank, 0)
|
ranks := make([]*pb.DBHuntingRank, 0)
|
||||||
err := this.GetList(uid, &ranks)
|
err := this.GetList(uid, &ranks)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -41,7 +41,7 @@ func (this *ModelRank) getHuntingRankList(uid string) []*pb.DBHuntingRank {
|
|||||||
return ranks
|
return ranks
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ModelRank) getHuntingRankListByBossType(uid string, bossType int32) *pb.DBHuntingRank {
|
func (this *ModelRank) getEnchantRankListByBossType(uid string, bossType int32) *pb.DBHuntingRank {
|
||||||
ranks := make([]*pb.DBHuntingRank, 0)
|
ranks := make([]*pb.DBHuntingRank, 0)
|
||||||
err := this.GetList(uid, &ranks)
|
err := this.GetList(uid, &ranks)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -12,9 +12,9 @@ import (
|
|||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Hunting struct {
|
type Enchant struct {
|
||||||
modules.ModuleBase
|
modules.ModuleBase
|
||||||
modelHunting *modelHunting
|
modelEnchant *modelEnchant
|
||||||
api *apiComp
|
api *apiComp
|
||||||
configure *configureComp
|
configure *configureComp
|
||||||
modulerank *ModelRank
|
modulerank *ModelRank
|
||||||
@ -23,20 +23,20 @@ type Hunting struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewModule() core.IModule {
|
func NewModule() core.IModule {
|
||||||
return &Hunting{}
|
return &Enchant{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Hunting) GetType() core.M_Modules {
|
func (this *Enchant) GetType() core.M_Modules {
|
||||||
return comm.ModuleHunting
|
return comm.ModuleEnchant
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Hunting) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
func (this *Enchant) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
||||||
err = this.ModuleBase.Init(service, module, options)
|
err = this.ModuleBase.Init(service, module, options)
|
||||||
this.service = service
|
this.service = service
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Hunting) Start() (err error) {
|
func (this *Enchant) Start() (err error) {
|
||||||
err = this.ModuleBase.Start()
|
err = this.ModuleBase.Start()
|
||||||
var module core.IModule
|
var module core.IModule
|
||||||
if module, err = this.service.GetModule(comm.ModuleBattle); err != nil {
|
if module, err = this.service.GetModule(comm.ModuleBattle); err != nil {
|
||||||
@ -47,28 +47,28 @@ func (this *Hunting) Start() (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Hunting) OnInstallComp() {
|
func (this *Enchant) OnInstallComp() {
|
||||||
this.ModuleBase.OnInstallComp()
|
this.ModuleBase.OnInstallComp()
|
||||||
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
||||||
this.modelHunting = this.RegisterComp(new(modelHunting)).(*modelHunting)
|
this.modelEnchant = this.RegisterComp(new(modelEnchant)).(*modelEnchant)
|
||||||
this.modulerank = this.RegisterComp(new(ModelRank)).(*ModelRank)
|
this.modulerank = this.RegisterComp(new(ModelRank)).(*ModelRank)
|
||||||
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 接口信息
|
// 接口信息
|
||||||
func (this *Hunting) ModifyHuntingData(uid string, data map[string]interface{}) (code pb.ErrorCode) {
|
func (this *Enchant) ModifyEnchantData(uid string, data map[string]interface{}) (code pb.ErrorCode) {
|
||||||
err := this.modelHunting.modifyHuntingDataByObjId(uid, data)
|
err := this.modelEnchant.modifyEnchantDataByObjId(uid, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Hunting) CheckUserBaseHuntingInfo(uid string) (data []*pb.DBHuntingRank) {
|
func (this *Enchant) CheckUserBaseEnchantInfo(uid string) (data []*pb.DBHuntingRank) {
|
||||||
list, err := this.modelHunting.getHuntingList(uid)
|
list, err := this.modelEnchant.getEnchantList(uid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
for k := range list.Boss {
|
for k := range list.Boss {
|
||||||
_d := this.modulerank.getHuntingRankListByBossType(uid, k)
|
_d := this.modulerank.getEnchantRankListByBossType(uid, k)
|
||||||
if _d != nil {
|
if _d != nil {
|
||||||
data = append(data, _d)
|
data = append(data, _d)
|
||||||
}
|
}
|
||||||
@ -76,12 +76,12 @@ func (this *Hunting) CheckUserBaseHuntingInfo(uid string) (data []*pb.DBHuntingR
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
func (this *Hunting) CheckRank(uid string, boosID int32, difficulty int32, hunting *pb.DBHunting, report *pb.BattleReport) {
|
func (this *Enchant) CheckRank(uid string, boosID int32, difficulty int32, Enchant *pb.DBHunting, report *pb.BattleReport) {
|
||||||
costTime := report.Costtime
|
costTime := report.Costtime
|
||||||
key := strconv.Itoa(int(boosID)) + "_" + strconv.Itoa(int(difficulty))
|
key := strconv.Itoa(int(boosID)) + "_" + strconv.Itoa(int(difficulty))
|
||||||
|
|
||||||
if hunting.BossTime[key] > costTime || hunting.BossTime[key] == 0 && difficulty >= hunting.Boss[boosID] { // 刷新记录
|
if Enchant.BossTime[key] > costTime || Enchant.BossTime[key] == 0 && difficulty >= Enchant.Boss[boosID] { // 刷新记录
|
||||||
hunting.BossTime[key] = costTime
|
Enchant.BossTime[key] = costTime
|
||||||
szLine := make([]*pb.LineUp, 5)
|
szLine := make([]*pb.LineUp, 5)
|
||||||
Leadpos := 0
|
Leadpos := 0
|
||||||
if report != nil && report.Info != nil && len(report.Info.Redflist) > 0 {
|
if report != nil && report.Info != nil && len(report.Info.Redflist) > 0 {
|
||||||
@ -100,7 +100,7 @@ func (this *Hunting) CheckRank(uid string, boosID int32, difficulty int32, hunti
|
|||||||
// 写入排行榜
|
// 写入排行榜
|
||||||
objID := ""
|
objID := ""
|
||||||
bFind := false
|
bFind := false
|
||||||
ranks := this.modulerank.getHuntingRankList(uid)
|
ranks := this.modulerank.getEnchantRankList(uid)
|
||||||
for _, v := range ranks {
|
for _, v := range ranks {
|
||||||
if v.Bosstype == boosID {
|
if v.Bosstype == boosID {
|
||||||
mapRankData := make(map[string]interface{}, 0)
|
mapRankData := make(map[string]interface{}, 0)
|
||||||
@ -110,7 +110,7 @@ func (this *Hunting) CheckRank(uid string, boosID int32, difficulty int32, hunti
|
|||||||
mapRankData["line"] = szLine
|
mapRankData["line"] = szLine
|
||||||
mapRankData["costTime"] = costTime
|
mapRankData["costTime"] = costTime
|
||||||
conn_, _ := db.Cross()
|
conn_, _ := db.Cross()
|
||||||
dbModel := db.NewDBModel(comm.TableHuntingRank, time.Hour, conn_)
|
dbModel := db.NewDBModel(comm.TableEnchantRank, time.Hour, conn_)
|
||||||
dbModel.ChangeList(uid, v.Id, mapRankData)
|
dbModel.ChangeList(uid, v.Id, mapRankData)
|
||||||
objID = v.Id
|
objID = v.Id
|
||||||
bFind = true
|
bFind = true
|
||||||
@ -133,49 +133,23 @@ func (this *Hunting) CheckRank(uid string, boosID int32, difficulty int32, hunti
|
|||||||
}
|
}
|
||||||
objID = new.Id
|
objID = new.Id
|
||||||
conn_, _ := db.Cross()
|
conn_, _ := db.Cross()
|
||||||
dbModel := db.NewDBModel(comm.TableHuntingRank, time.Hour, conn_)
|
dbModel := db.NewDBModel(comm.TableEnchantRank, time.Hour, conn_)
|
||||||
dbModel.AddList(uid, new.Id, new)
|
dbModel.AddList(uid, new.Id, new)
|
||||||
}
|
}
|
||||||
this.modulerank.SetRankListData("huntingRank"+strconv.Itoa(int(boosID)), difficulty<<16+costTime, objID)
|
this.modulerank.SetRankListData("EnchantRank"+strconv.Itoa(int(boosID)), difficulty<<16+costTime, objID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//红点查询
|
//红点查询
|
||||||
func (this *Hunting) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (reddot map[comm.ReddotType]bool) {
|
func (this *Enchant) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (reddot map[comm.ReddotType]bool) {
|
||||||
reddot = make(map[comm.ReddotType]bool)
|
reddot = make(map[comm.ReddotType]bool)
|
||||||
for _, v := range rid {
|
for _, v := range rid {
|
||||||
switch v {
|
switch v {
|
||||||
case comm.Reddot32:
|
case comm.Reddot32:
|
||||||
reddot[comm.Reddot32] = this.modelHunting.checkReddot32(session.GetUserId())
|
reddot[comm.Reddot32] = this.modelEnchant.checkReddot32(session.GetUserId())
|
||||||
break
|
break
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解锁远征所有难度
|
|
||||||
func (this *Hunting) CompleteAllLevel(session comm.IUserSession) (code pb.ErrorCode) {
|
|
||||||
list, err := this.modelHunting.getHuntingList(session.GetUserId())
|
|
||||||
if err != nil {
|
|
||||||
code = pb.ErrorCode_DBError
|
|
||||||
return
|
|
||||||
}
|
|
||||||
mapData := make(map[string]interface{}, 0)
|
|
||||||
// 查配置获取每个Boss的最大难度
|
|
||||||
for k := range list.Boss {
|
|
||||||
for i := 1; ; i++ {
|
|
||||||
conf := this.configure.GetHuntingBossConfigData(k, int32(i))
|
|
||||||
if conf == nil {
|
|
||||||
list.Boss[k] = int32(i - 1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mapData["boss"] = list.Boss
|
|
||||||
code = this.ModifyHuntingData(session.GetUserId(), mapData)
|
|
||||||
for k := range list.Boss {
|
|
||||||
list.Boss[k] += 1
|
|
||||||
}
|
|
||||||
session.SendMsg(string(this.GetType()), HuntingGetListResp, &pb.HuntingGetListResp{Data: list})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user