From cbaccff12a45a42bfd2ae28b2b1ca5cb56e02878 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Thu, 12 Jan 2023 15:40:49 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=A8=E7=A5=A8=E6=B6=88=E8=80=97=20?= =?UTF-8?q?=E4=BB=8Ecom=E7=A7=BB=E9=99=A4=EF=BC=8C=E5=AF=B9=E5=BA=94?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BA=A2=E7=82=B9=E8=AE=A1=E7=AE=97=E8=A7=84?= =?UTF-8?q?=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/const.go | 1 + comm/imodule.go | 2 +- modules/autoBattle/api_autochallenge.go | 2 +- modules/enchant/model_enchant.go | 19 ++++------- modules/enchant/module.go | 12 +++++++ modules/hunting/model_hunting.go | 22 +++++-------- modules/hunting/module.go | 3 +- modules/viking/model_viking.go | 21 +++++------- modules/viking/module.go | 44 +++++++++++-------------- 9 files changed, 59 insertions(+), 67 deletions(-) diff --git a/comm/const.go b/comm/const.go index 7c3aff126..0a5bb88b8 100644 --- a/comm/const.go +++ b/comm/const.go @@ -382,6 +382,7 @@ const ( Reddot30 ReddotType = 10030 //邮件-----未读邮件红点 Reddot31 ReddotType = 10031 //维京远征 有挑战次数 Reddot32 ReddotType = 10032 //狩猎 有挑战次数 + Reddot33 ReddotType = 10033 //附魔副本 有挑战次数 ) type TaskType int32 diff --git a/comm/imodule.go b/comm/imodule.go index 178b79eeb..8a6b89724 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -268,7 +268,7 @@ type ( CheckUserBaseVikingInfo(uid string) (data []*pb.DBVikingRank) // 查询玩家最佳通关记录 IReddot // 自动购买门票 - AutoBuyTicket(session IUserSession) (code pb.ErrorCode) + AutoBuyTicket(session IUserSession, bossId, difficulty int32) (code pb.ErrorCode) // 自动战斗 战斗信息 AutoBattleInfo(session IUserSession, battle *pb.BattleFormation, bossId, difficulty int32) (code pb.ErrorCode, battleInfo *pb.BattleInfo) AutoBattleOver(session IUserSession, Report *pb.BattleReport, autoBattle *pb.DBAutoBattle) (code pb.ErrorCode, atno []*pb.UserAtno) diff --git a/modules/autoBattle/api_autochallenge.go b/modules/autoBattle/api_autochallenge.go index 49b821bf9..320f1e1b7 100644 --- a/modules/autoBattle/api_autochallenge.go +++ b/modules/autoBattle/api_autochallenge.go @@ -58,7 +58,7 @@ func (this *apiComp) AutoChallenge(session comm.IUserSession, req *pb.AutoBattle // 优先判断门票够不够 if req.Ptype == pb.PlayType_viking { if req.AutoBuy { - this.viking.AutoBuyTicket(session) + this.viking.AutoBuyTicket(session, req.BossId, req.Difficulty) code = this.viking.CheckBattelParameter(session, req.Battle, req.BossId, req.Difficulty) // 参数校验 if code != pb.ErrorCode_Success { return diff --git a/modules/enchant/model_enchant.go b/modules/enchant/model_enchant.go index 5530710ac..f80c669a3 100644 --- a/modules/enchant/model_enchant.go +++ b/modules/enchant/model_enchant.go @@ -48,19 +48,12 @@ func (this *modelEnchant) getEnchantList(uid string) (result *pb.DBEnchant, err } // 红点检测 -func (this *modelEnchant) checkReddot32(uid string) bool { - - conf := this.module.configure.GetGlobalConf() - if conf == nil { - return false - } - costRes := conf.EnchantbossCos - if costRes == nil { - return false - } - amount := int32(this.module.ModuleItems.QueryItemAmount(uid, costRes.T)) // 获取当前数量 - if amount > 0 { - return true +func (this *modelEnchant) checkReddot33(session comm.IUserSession) bool { + conf := this.module.configure.GetEnchantBossConfigData(1) + if len(conf) > 0 { + if code := this.module.CheckRes(session, conf[0].PsConsume); code == pb.ErrorCode_Success { + return true + } } return false } diff --git a/modules/enchant/module.go b/modules/enchant/module.go index cd2894d93..c0ec5d9e8 100644 --- a/modules/enchant/module.go +++ b/modules/enchant/module.go @@ -155,3 +155,15 @@ func (this *Enchant) CheckRank(uid string, boosID int32, report *pb.BattleReport return } } + +func (this *Enchant) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (reddot map[comm.ReddotType]bool) { + reddot = make(map[comm.ReddotType]bool) + for _, v := range rid { + switch v { + case comm.Reddot33: + reddot[comm.Reddot33] = this.modelEnchant.checkReddot33(session) + break + } + } + return +} diff --git a/modules/hunting/model_hunting.go b/modules/hunting/model_hunting.go index f610a87ed..3927e51b7 100644 --- a/modules/hunting/model_hunting.go +++ b/modules/hunting/model_hunting.go @@ -42,19 +42,15 @@ func (this *modelHunting) getHuntingList(uid string) (result *pb.DBHunting, err } // 红点检测 -func (this *modelHunting) checkReddot32(uid string) bool { +func (this *modelHunting) checkReddot32(session comm.IUserSession) bool { + if list, err := this.module.modelHunting.getHuntingList(session.GetUserId()); err == nil { + if _, ok := list.Boss[1]; ok { + conf := this.module.configure.GetHuntingBossConfigData(1, 1) + if code := this.module.CheckRes(session, conf.PsConsume); code == pb.ErrorCode_Success { + return true + } + } + } - conf := this.module.configure.GetGlobalConf() - if conf == nil { - return false - } - costRes := conf.HuntingCos - if costRes == nil { - return false - } - amount := int32(this.module.ModuleItems.QueryItemAmount(uid, costRes.T)) // 获取当前数量 - if amount > 0 { - return true - } return false } diff --git a/modules/hunting/module.go b/modules/hunting/module.go index 11bb3da41..0ecbbef81 100644 --- a/modules/hunting/module.go +++ b/modules/hunting/module.go @@ -169,9 +169,8 @@ func (this *Hunting) Reddot(session comm.IUserSession, rid ...comm.ReddotType) ( for _, v := range rid { switch v { case comm.Reddot32: - reddot[comm.Reddot32] = this.modelHunting.checkReddot32(session.GetUserId()) + reddot[comm.Reddot32] = this.modelHunting.checkReddot32(session) break - } } return diff --git a/modules/viking/model_viking.go b/modules/viking/model_viking.go index e3b96968d..a1ddc52d9 100644 --- a/modules/viking/model_viking.go +++ b/modules/viking/model_viking.go @@ -48,19 +48,16 @@ func (this *modelViking) modifyVikingDataByObjId(uid string, data map[string]int } // 红点检测 -func (this *modelViking) checkReddot31(uid string) bool { +func (this *modelViking) checkReddot31(session comm.IUserSession) bool { - conf := this.module.configure.GetGlobalConf() - if conf == nil { - return false - } - costRes := conf.VikingExpeditionCos - if costRes == nil { - return false - } - amount := int32(this.module.ModuleItems.QueryItemAmount(uid, costRes.T)) // 获取当前数量 - if amount > 0 { - return true + if list, err := this.module.modelViking.getVikingList(session.GetUserId()); err == nil { + if _, ok := list.Boss[1]; ok { + conf := this.module.configure.GetVikingBossConfigData(1, 1) + if code := this.module.CheckRes(session, conf.PsConsume); code == pb.ErrorCode_Success { + return true + } + } } + return false } diff --git a/modules/viking/module.go b/modules/viking/module.go index fc0e29dd5..c5d3ec679 100644 --- a/modules/viking/module.go +++ b/modules/viking/module.go @@ -12,7 +12,6 @@ import ( "go_dreamfactory/lego/sys/redis/pipe" "go_dreamfactory/modules" "go_dreamfactory/pb" - cfg "go_dreamfactory/sys/configure/structs" "go_dreamfactory/sys/db" "math" "strconv" @@ -175,7 +174,7 @@ func (this *Viking) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (r for _, v := range rid { switch v { case comm.Reddot31: - reddot[comm.Reddot31] = this.modelViking.checkReddot31(session.GetUserId()) + reddot[comm.Reddot31] = this.modelViking.checkReddot31(session) break } @@ -207,23 +206,17 @@ func (this *Viking) CompleteAllLevel(session comm.IUserSession) (code pb.ErrorCo return } -func (this *Viking) AutoBuyTicket(session comm.IUserSession) (code pb.ErrorCode) { - conf := this.configure.GetGlobalConf() - if conf == nil { - code = pb.ErrorCode_ConfigNoFound - return - } - costRes := conf.VikingExpeditionCos - if costRes == nil { - code = pb.ErrorCode_ConfigNoFound - return - } - amount := int32(this.ModuleItems.QueryItemAmount(session.GetUserId(), costRes.T)) // 获取当前数量 - if amount == 0 { // 数量不足直接购买 - code, _ = this.api.Buy(session, &pb.VikingBuyReq{ - Count: 1, - }) +func (this *Viking) AutoBuyTicket(session comm.IUserSession, bossId, difficulty int32) (code pb.ErrorCode) { + conf := this.configure.GetVikingBossConfigData(bossId, difficulty) + if code := this.CheckRes(session, conf.PsConsume); code != pb.ErrorCode_Success { + amount := int32(this.ModuleItems.QueryItemAmount(session.GetUserId(), conf.PsConsume[0].T)) // 获取当前数量 + if amount < conf.PsConsume[0].N { // 数量不足直接购买 + code, _ = this.api.Buy(session, &pb.VikingBuyReq{ + Count: conf.PsConsume[0].N - amount, + }) + } } + return } @@ -252,12 +245,13 @@ func (this *Viking) AutoBattleOver(session comm.IUserSession, Report *pb.BattleR bossId := autoBattle.BossId difficulty := autoBattle.Difficulty atno = make([]*pb.UserAtno, 0) - costRes := this.configure.GetGlobalConf().VikingExpeditionCos - if costRes == nil { - code = pb.ErrorCode_ConfigNoFound - return - } - if code = this.ConsumeRes(session, []*cfg.Gameatn{costRes}, true); code != pb.ErrorCode_Success { + conf := this.configure.GetVikingBossConfigData(bossId, difficulty) + // costRes := this.configure.GetGlobalConf().VikingExpeditionCos + // if costRes == nil { + // code = pb.ErrorCode_ConfigNoFound + // return + // } + if code = this.ConsumeRes(session, conf.PsConsume, true); code != pb.ErrorCode_Success { return } viking, err := this.modelViking.getVikingList(session.GetUserId()) @@ -273,7 +267,7 @@ func (this *Viking) AutoBattleOver(session comm.IUserSession, Report *pb.BattleR } if autoBattle != nil { if autoBattle.AutoBuy { - code = this.AutoBuyTicket(session) + code = this.AutoBuyTicket(session, bossId, difficulty) } } mapData := make(map[string]interface{}, 0)