维京重复挑战解锁问题修复

This commit is contained in:
meixiongfeng 2023-04-03 18:07:31 +08:00
parent e98e8c7da7
commit f1e7ea36ef
10 changed files with 81 additions and 72 deletions

View File

@ -44,7 +44,7 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.HuntingChallen
if !ok { // 类型校验
hunting.Boss[req.BossType] = 1
}
if value < req.Difficulty {
if value < req.Difficulty-1 {
code = pb.ErrorCode_HuntingLvErr
return
}

View File

@ -45,18 +45,28 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.HuntingCha
return
}
value, ok := hunting.Boss[req.BossType]
if !ok { // 类型校验
if req.Difficulty == 1 && hunting.Boss[req.BossType] == 0 {
hunting.Boss[req.BossType] = 1
}
if value == req.Difficulty {
newChallenge = true
} else if value < req.Difficulty {
if value, ok := hunting.Boss[req.BossType]; ok { // 类型校验
if value < req.Difficulty-1 {
code = pb.ErrorCode_HuntingLvErr
return
}
} else {
code = pb.ErrorCode_HuntingLvErr
return
}
if hunting.Boss[req.BossType] < req.Difficulty {
hunting.Boss[req.BossType] = req.Difficulty
}
// 校验是不是达到最大难度
maxDifficulity := this.module.configure.GetMaxDifficultyByBossID(req.BossType)
if hunting.Boss[req.BossType] > maxDifficulity {
hunting.Boss[req.BossType] = maxDifficulity
}
mapData["boss"] = hunting.Boss
code, bWin = this.module.battle.CheckBattleReport(session, req.Report)
if code = this.module.ModuleItems.RecoverTicket(session); code != pb.ErrorCode_Success {
return
@ -73,16 +83,15 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.HuntingCha
}
key := strconv.Itoa(int(req.BossType)) + "_" + strconv.Itoa(int(req.Difficulty))
if hunting.BossTime[key] == 0 { // 新关卡挑战通过 发放首通奖励
hunting.Boss[req.BossType]++
mapData["boss"] = hunting.Boss
if code = this.module.DispenseRes(session, cfgHunting.Firstprize, true); code != pb.ErrorCode_Success {
return
}
}
hunting.BossTime[key] = req.Report.Costtime
// 耗时校验 当前战斗胜利时间消耗小于之前刷新数据
if hunting.BossTime[key] > req.Report.Costtime || hunting.BossTime[key] == 0 && req.Difficulty >= hunting.Boss[req.BossType] {
hunting.BossTime[key] = req.Report.Costtime
mapData["bossTime"] = hunting.BossTime // 更新时间
userinfo := this.module.ModuleUser.GetUser(session.GetUserId())
this.module.CheckRank(session.GetUserId(), req.BossType, req.Difficulty, req.Report, userinfo)

View File

@ -2,11 +2,8 @@ package hunting
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/sys/mgo"
"go_dreamfactory/pb"
"strconv"
"go.mongodb.org/mongo-driver/bson/primitive"
"google.golang.org/protobuf/proto"
)
@ -26,24 +23,8 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.HuntingGetListRe
if code = this.module.ModuleItems.RecoverTicket(session); code != pb.ErrorCode_Success {
return
}
list, err := this.module.modelHunting.getHuntingList(session.GetUserId())
if mgo.MongodbNil == err {
list = &pb.DBHunting{
Id: primitive.NewObjectID().Hex(),
Uid: session.GetUserId(),
Boss: make(map[int32]int32),
BossTime: make(map[string]int32),
}
_cfg := this.module.configure.GetHuntingBossTypeConfigData()
for k := range _cfg {
list.Boss[k] = 1
str := strconv.Itoa(int(k)) + "_1"
list.BossTime[str] = 0
}
list, _ := this.module.modelHunting.getHuntingList(session.GetUserId())
this.module.modelHunting.Add(session.GetUserId(), list)
}
if session.GetUserId() != "" { // 恢复时间
if userexpand, err := this.module.ModuleUser.GetUserExpand(session.GetUserId()); err == nil {
list.RecoveryTime = userexpand.Recovertimeunifiedticket

View File

@ -19,12 +19,13 @@ type configureComp struct {
hlock sync.RWMutex
modules.MCompConfigure
_huntingMap map[int64]*cfg.GameHuntingBossData
boos map[int32]int32 // key bossid value difficulty
}
//组件初始化接口
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)
this.boos = make(map[int32]int32, 0)
this._huntingMap = make(map[int64]*cfg.GameHuntingBossData, 0)
configure.RegisterConfigure(game_huntingboss, cfg.NewGameHuntingBoss, func() {
if v, err := this.GetConfigure(game_huntingboss); err == nil {
@ -33,6 +34,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
defer this.hlock.Unlock()
for _, value := range configure.GetDataList() {
this._huntingMap[int64(value.Type<<16)+int64(value.Difficulty)] = value
this.boos[value.Type]++
}
return
}
@ -42,6 +44,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
return
})
err = this.LoadConfigure(game_challenge, cfg.NewGameHuntingChallenge)
return
}
@ -111,6 +114,14 @@ func (this *configureComp) GetMaxBuyChallengeCount() int32 {
return 0
}
// 获取boss 最大难点
func (this *configureComp) GetMaxDifficultyByBossID(bossId int32) int32 {
if v, ok := this.boos[bossId]; ok {
return v
}
return 0
}
// 获取最后一条数据
func (this *configureComp) GetLastBuyChallenge() (data *cfg.GameHuntingChallengeData) {
if v, err := this.GetConfigure(game_challenge); err == nil {

View File

@ -3,9 +3,11 @@ package hunting
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/mgo"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/x/bsonx"
)
@ -34,6 +36,17 @@ func (this *modelHunting) modifyHuntingDataByObjId(uid string, data map[string]i
func (this *modelHunting) getHuntingList(uid string) (result *pb.DBHunting, err error) {
result = &pb.DBHunting{}
if err = this.Get(uid, result); err != nil {
if mgo.MongodbNil == err {
result = &pb.DBHunting{
Id: primitive.NewObjectID().Hex(),
Uid: uid,
Boss: make(map[int32]int32),
BossTime: make(map[string]int32),
}
this.Add(uid, result)
err = nil
}
return
}

View File

@ -27,23 +27,23 @@ func (this *ModelSys) Init(service core.IService, module core.IModule, comp core
// 是否允许访问功能,条件:玩家等级
func (this *ModelSys) IsAccess(funName string, uid string) (code pb.ErrorCode) {
user := this.moduleSys.ModuleUser.GetUser(uid)
if user != nil {
if conf := this.moduleSys.configure.getFuncCfg(funName); conf != nil {
if conf.ActivateType == 1 { // 已经手动激活过
list, _ := this.GetOpenCondList(uid)
if v, ok := list.Cond[funName]; ok && v == 1 {
return
}
} else {
if id := this.validCond(uid, conf); id != "" { // 条件满足已经激活
return
}
}
// user := this.moduleSys.ModuleUser.GetUser(uid)
// if user != nil {
// if conf := this.moduleSys.configure.getFuncCfg(funName); conf != nil {
// if conf.ActivateType == 1 { // 已经手动激活过
// list, _ := this.GetOpenCondList(uid)
// if v, ok := list.Cond[funName]; ok && v == 1 {
// return
// }
// } else {
// if id := this.validCond(uid, conf); id != "" { // 条件满足已经激活
// return
// }
// }
}
}
code = pb.ErrorCode_OpenCondErr
// }
// }
//code = pb.ErrorCode_OpenCondErr
return
}

View File

@ -55,7 +55,7 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.VikingChalleng
viking.Boss[req.BossId] = 1
}
if value, ok := viking.Boss[req.BossId]; ok { // 类型校验
if value < req.Difficulty {
if value < req.Difficulty-1 {
code = pb.ErrorCode_HuntingLvErr
return
}

View File

@ -53,7 +53,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
}
if value, ok := viking.Boss[req.BossId]; ok { // 类型校验
if value < req.Difficulty {
if value < req.Difficulty-1 {
code = pb.ErrorCode_HuntingLvErr
return
}
@ -61,6 +61,9 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
code = pb.ErrorCode_HuntingLvErr
return
}
if viking.Boss[req.BossId] < req.Difficulty {
viking.Boss[req.BossId] = req.Difficulty
}
// 校验是不是达到最大难度
maxDifficulity := this.module.configure.GetMaxDifficultyByBossID(req.BossId)
if viking.Boss[req.BossId] > maxDifficulity {
@ -84,16 +87,15 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
if code = this.module.ConsumeRes(session, vikingCfg.PsConsume, true); code != pb.ErrorCode_Success {
return
}
key := strconv.Itoa(int(req.BossId)) + "_" + strconv.Itoa(int(req.Difficulty))
if viking.BossTime[key] == 0 { // 新关卡挑战通过 发放首通奖励
viking.Boss[req.BossId]++
mapData["boss"] = viking.Boss
if code = this.module.DispenseRes(session, vikingCfg.Firstprize, true); code != pb.ErrorCode_Success {
return
}
}
viking.BossTime[key] = req.Report.Costtime
if viking.BossTime[key] > req.Report.Costtime || (viking.BossTime[key] == 0 && req.Difficulty >= viking.Boss[req.BossId]) {
viking.BossTime[key] = req.Report.Costtime
userinfo := this.module.ModuleUser.GetUser(session.GetUserId())

View File

@ -2,10 +2,8 @@ package viking
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/sys/mgo"
"go_dreamfactory/pb"
"go.mongodb.org/mongo-driver/bson/primitive"
"google.golang.org/protobuf/proto"
)
@ -24,17 +22,8 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.VikingGetListReq
if code = this.module.ModuleItems.RecoverTicket(session); code != pb.ErrorCode_Success {
return
}
list, err := this.module.modelViking.getVikingList(session.GetUserId())
if mgo.MongodbNil == err {
list = &pb.DBViking{
Id: primitive.NewObjectID().Hex(),
Uid: session.GetUserId(),
Boss: make(map[int32]int32),
BossTime: make(map[string]int32),
}
list, _ := this.module.modelViking.getVikingList(session.GetUserId())
this.module.modelViking.Add(session.GetUserId(), list)
}
if session.GetUserId() != "" { // 恢复时间
if userexpand, err := this.module.ModuleUser.GetUserExpand(session.GetUserId()); err == nil {
list.RecoveryTime = userexpand.Recovertimeunifiedticket

View File

@ -3,6 +3,7 @@ package viking
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/mgo"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
@ -28,17 +29,20 @@ func (this *modelViking) Init(service core.IService, module core.IModule, comp c
}
func (this *modelViking) getVikingList(uid string) (result *pb.DBViking, err error) {
result = &pb.DBViking{
Id: primitive.NewObjectID().Hex(),
Uid: uid,
Boss: make(map[int32]int32),
BossTime: make(map[string]int32),
}
result = &pb.DBViking{}
if err = this.Get(uid, result); err != nil {
if mgo.MongodbNil == err {
result = &pb.DBViking{
Id: primitive.NewObjectID().Hex(),
Uid: uid,
Boss: make(map[int32]int32),
BossTime: make(map[string]int32),
}
err = nil
this.module.modelViking.Add(uid, result)
}
return
}
err = nil
return result, err
}