门票消耗 从com移除,对应修改红点计算规则

This commit is contained in:
meixiongfeng 2023-01-12 15:40:49 +08:00
parent fc3ac03b99
commit cbaccff12a
9 changed files with 59 additions and 67 deletions

View File

@ -382,6 +382,7 @@ const (
Reddot30 ReddotType = 10030 //邮件-----未读邮件红点
Reddot31 ReddotType = 10031 //维京远征 有挑战次数
Reddot32 ReddotType = 10032 //狩猎 有挑战次数
Reddot33 ReddotType = 10033 //附魔副本 有挑战次数
)
type TaskType int32

View File

@ -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)

View File

@ -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

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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

View File

@ -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
}

View File

@ -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)