优化
This commit is contained in:
parent
695e862bff
commit
e8744d1b76
@ -23,14 +23,14 @@ func (this *apiComp) ChallengeOverCheck(session comm.IUserSession, req *pb.Hunti
|
||||
///挑战主线关卡
|
||||
func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.HuntingChallengeOverReq) (errdata *pb.ErrorData) {
|
||||
var (
|
||||
mapData map[string]interface{}
|
||||
newChallenge bool // 新的关卡
|
||||
reward []*cfg.Gameatn
|
||||
bWin bool // 战斗是否胜利
|
||||
tasks []*pb.BuriedParam = make([]*pb.BuriedParam, 0)
|
||||
del []string // 自动出售的装备
|
||||
atno []*pb.UserAtno // atno 类型
|
||||
res []*cfg.Gameatn // 最后获得的资源
|
||||
mapData map[string]interface{}
|
||||
|
||||
reward []*cfg.Gameatn
|
||||
bWin bool // 战斗是否胜利
|
||||
tasks []*pb.BuriedParam = make([]*pb.BuriedParam, 0)
|
||||
del []string // 自动出售的装备
|
||||
atno []*pb.UserAtno // atno 类型
|
||||
res []*cfg.Gameatn // 最后获得的资源
|
||||
)
|
||||
mapData = make(map[string]interface{}, 0)
|
||||
reward = make([]*cfg.Gameatn, 0)
|
||||
@ -58,6 +58,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.HuntingCha
|
||||
|
||||
if req.Difficulty == 1 && hunting.Boss[req.BossType] == 0 {
|
||||
hunting.Boss[req.BossType] = 1
|
||||
mapData["boss"] = hunting.Boss
|
||||
}
|
||||
|
||||
if value, ok := hunting.Boss[req.BossType]; ok { // 类型校验
|
||||
@ -76,15 +77,12 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.HuntingCha
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if hunting.Boss[req.BossType] < req.Difficulty {
|
||||
hunting.Boss[req.BossType] = req.Difficulty
|
||||
mapData["boss"] = hunting.Boss
|
||||
}
|
||||
// 校验是不是达到最大难度
|
||||
maxDifficulity := this.module.configure.GetMaxDifficultyByBossID(req.BossType)
|
||||
if hunting.Boss[req.BossType] > maxDifficulity {
|
||||
hunting.Boss[req.BossType] = maxDifficulity
|
||||
}
|
||||
mapData["boss"] = hunting.Boss
|
||||
|
||||
errdata, bWin = this.module.battle.CheckBattleReport(session, req.Report)
|
||||
if v, ok := hunting.Ps[req.BossType]; !ok || v == 0 {
|
||||
errdata = &pb.ErrorData{
|
||||
@ -108,18 +106,25 @@ 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 { // 新关卡挑战通过 发放首通奖励
|
||||
mapData["boss"] = hunting.Boss
|
||||
|
||||
hunting.BossTime[key] = req.Report.Costtime
|
||||
mapData["bossTime"] = hunting.BossTime
|
||||
if errdata = this.module.DispenseRes(session, cfgHunting.Firstprize, true); errdata != nil {
|
||||
return
|
||||
}
|
||||
for _, v := range cfgHunting.Firstprize {
|
||||
if _conf, err := this.module.configure.GetItemConfigureData(v.T); err == nil {
|
||||
if _conf.Usetype == comm.UseType8 {
|
||||
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype154, v.N))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
hunting.BossTime[key] = req.Report.Costtime
|
||||
// 耗时校验 当前战斗胜利时间消耗小于之前刷新数据
|
||||
if (hunting.BossTime[key] > req.Report.Costtime || hunting.BossTime[key] == 0) && req.Difficulty >= hunting.Boss[req.BossType] {
|
||||
|
||||
if hunting.BossTime[key] > req.Report.Costtime {
|
||||
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)
|
||||
this.module.CheckRank(session.GetUserId(), req.BossType, req.Difficulty, req.Report)
|
||||
}
|
||||
// 发放通关随机奖励
|
||||
//reward = this.module.configure.GetDropReward(cfgHunting.Drop) // 获取掉落奖励
|
||||
@ -147,15 +152,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.HuntingCha
|
||||
if errdata, atno = this.module.DispenseAtno(session, res, true); errdata != nil {
|
||||
return
|
||||
}
|
||||
if newChallenge && bWin { // 新关卡挑战通过 发放首通奖励
|
||||
if errdata = this.module.DispenseRes(session, cfgHunting.Firstprize, true); errdata != nil {
|
||||
return
|
||||
}
|
||||
hunting.Boss[req.BossType] += 1
|
||||
mapData["boss"] = hunting.Boss
|
||||
}
|
||||
|
||||
mapData["bossTime"] = hunting.BossTime
|
||||
errdata = this.module.ModifyHuntingData(session.GetUserId(), mapData)
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), HuntingChallengeOverResp, &pb.HuntingChallengeOverResp{
|
||||
@ -178,16 +175,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.HuntingCha
|
||||
}
|
||||
}
|
||||
}
|
||||
if newChallenge && bWin {
|
||||
for _, v := range cfgHunting.Firstprize {
|
||||
if _conf, err := this.module.configure.GetItemConfigureData(v.T); err == nil {
|
||||
if _conf.Usetype == comm.UseType8 {
|
||||
// this.module.ModuleRtask.SendToRtask(session, comm.Rtype154, v.N)
|
||||
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype154, v.N))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if req.Auto {
|
||||
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype172, 1))
|
||||
}
|
||||
|
@ -23,13 +23,12 @@ 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 {
|
||||
@ -38,7 +37,6 @@ 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
|
||||
}
|
||||
@ -96,25 +94,3 @@ func (this *configureComp) GetHuntingBossTypeConfigData() (mapType map[int32]str
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 获取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 {
|
||||
// if configure, ok := v.(*cfg.GameHuntingChallenge); ok && len(configure.GetDataList()) > 0 {
|
||||
// data = configure.GetDataList()[len(configure.GetDataList())-1]
|
||||
// return
|
||||
// }
|
||||
// } else {
|
||||
// log.Errorf("get game_challenge conf err:%v", err)
|
||||
// }
|
||||
|
||||
// return
|
||||
// }
|
||||
|
@ -84,9 +84,9 @@ func (this *Hunting) CheckUserBaseHuntingInfo(uid string) (data []*pb.DBHuntingR
|
||||
}
|
||||
return
|
||||
}
|
||||
func (this *Hunting) CheckRank(uid string, boosID int32, difficulty int32, report *pb.BattleReport, userinfo *pb.DBUser) {
|
||||
func (this *Hunting) CheckRank(uid string, boosID int32, difficulty int32, report *pb.BattleReport) {
|
||||
conn_, _ := db.Cross() // 获取跨服数据库对象
|
||||
|
||||
userinfo := this.ModuleUser.GetUser(uid)
|
||||
model := db.NewDBModel(comm.TableHuntingRank, time.Hour, conn_)
|
||||
|
||||
costTime := report.Costtime
|
||||
|
@ -60,6 +60,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
|
||||
|
||||
if req.Difficulty == 1 && viking.Boss[req.BossId] == 0 {
|
||||
viking.Boss[req.BossId] = 1
|
||||
mapData["boss"] = viking.Boss
|
||||
}
|
||||
|
||||
if value, ok := viking.Boss[req.BossId]; ok { // 类型校验
|
||||
@ -79,13 +80,8 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
|
||||
}
|
||||
if viking.Boss[req.BossId] < req.Difficulty {
|
||||
viking.Boss[req.BossId] = req.Difficulty
|
||||
mapData["boss"] = viking.Boss
|
||||
}
|
||||
// 校验是不是达到最大难度
|
||||
maxDifficulity := this.module.configure.GetMaxDifficultyByBossID(req.BossId)
|
||||
if viking.Boss[req.BossId] > maxDifficulity {
|
||||
viking.Boss[req.BossId] = maxDifficulity
|
||||
}
|
||||
mapData["boss"] = viking.Boss
|
||||
|
||||
errdata, bWin = this.module.battle.CheckBattleReport(session, req.Report)
|
||||
if v, ok := viking.Ps[req.BossId]; ok && v > 0 {
|
||||
@ -111,19 +107,18 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
|
||||
|
||||
key := strconv.Itoa(int(req.BossId)) + "_" + strconv.Itoa(int(req.Difficulty))
|
||||
if viking.BossTime[key] == 0 { // 新关卡挑战通过 发放首通奖励
|
||||
|
||||
mapData["boss"] = viking.Boss
|
||||
viking.BossTime[key] = req.Report.Costtime
|
||||
mapData["bossTime"] = viking.BossTime // 更新时间
|
||||
if errdata = this.module.DispenseRes(session, vikingCfg.Firstprize, true); errdata != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (viking.BossTime[key] > req.Report.Costtime || viking.BossTime[key] == 0) && req.Difficulty >= viking.Boss[req.BossId] {
|
||||
if viking.BossTime[key] > req.Report.Costtime {
|
||||
viking.BossTime[key] = req.Report.Costtime
|
||||
userinfo := this.module.ModuleUser.GetUser(session.GetUserId())
|
||||
this.module.CheckRank(session.GetUserId(), req.BossId, req.Difficulty, req.Report, userinfo)
|
||||
mapData["bossTime"] = viking.BossTime // 更新时间
|
||||
this.module.CheckRank(session.GetUserId(), req.BossId, req.Difficulty, req.Report)
|
||||
}
|
||||
mapData["bossTime"] = viking.BossTime // 更新时间
|
||||
|
||||
reward = this.module.configure.GetDropReward(vikingCfg.Drop) // 获取掉落奖励
|
||||
// 星级校验
|
||||
|
@ -23,7 +23,6 @@ type configureComp struct {
|
||||
hlock sync.RWMutex
|
||||
modules.MCompConfigure
|
||||
_vikingMap map[int64]*cfg.GameVikingBossData
|
||||
boos map[int32]int32 // key bossid value difficulty
|
||||
}
|
||||
|
||||
//组件初始化接口
|
||||
@ -31,7 +30,6 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
|
||||
err = this.MCompConfigure.Init(service, module, comp, options)
|
||||
|
||||
this._vikingMap = make(map[int64]*cfg.GameVikingBossData, 0)
|
||||
this.boos = make(map[int32]int32, 0)
|
||||
configure.RegisterConfigure(game_vikingboss, cfg.NewGameVikingBoss, func() {
|
||||
if v, err := this.GetConfigure(game_vikingboss); err == nil {
|
||||
if configure, ok := v.(*cfg.GameVikingBoss); ok {
|
||||
@ -39,7 +37,6 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
|
||||
defer this.hlock.Unlock()
|
||||
for _, value := range configure.GetDataList() {
|
||||
this._vikingMap[int64(value.Bossid<<16)+int64(value.Difficulty)] = value
|
||||
this.boos[value.Bossid]++
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -93,11 +90,3 @@ func (this *configureComp) GetVikingBossTypeConfigData() map[int32]struct{} {
|
||||
}
|
||||
return mapType
|
||||
}
|
||||
|
||||
// 获取boss 最大难点
|
||||
func (this *configureComp) GetMaxDifficultyByBossID(bossId int32) int32 {
|
||||
if v, ok := this.boos[bossId]; ok {
|
||||
return v
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
@ -89,9 +89,12 @@ func (this *Viking) CheckUserBaseVikingInfo(uid string) (data []*pb.DBVikingRank
|
||||
}
|
||||
|
||||
// 记录数据存在跨服
|
||||
func (this *Viking) CheckRank(uid string, boosID int32, difficulty int32, report *pb.BattleReport, userinfo *pb.DBUser) {
|
||||
conn_, _ := db.Cross() // 获取跨服数据库对象
|
||||
|
||||
func (this *Viking) CheckRank(uid string, boosID int32, difficulty int32, report *pb.BattleReport) {
|
||||
conn_, err := db.Cross() // 获取跨服数据库对象
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
userinfo := this.ModuleUser.GetUser(uid)
|
||||
model := db.NewDBModel(comm.TableVikingRank, 0, conn_)
|
||||
|
||||
costTime := report.Costtime
|
||||
@ -316,8 +319,7 @@ func (this *Viking) AutoBattleOver(session comm.IUserSession, Report *pb.BattleR
|
||||
return
|
||||
}
|
||||
}
|
||||
userinfo := this.ModuleUser.GetUser(session.GetUserId())
|
||||
this.CheckRank(session.GetUserId(), bossId, difficulty, Report, userinfo)
|
||||
this.CheckRank(session.GetUserId(), bossId, difficulty, Report)
|
||||
reward := this.configure.GetDropReward(vikingCfg.Drop) // 获取掉落奖励
|
||||
if c, res1 := this.DispenseAtno(session, reward, true); c == nil {
|
||||
atno = append(atno, res1...)
|
||||
|
Loading…
Reference in New Issue
Block a user