错误码整合

This commit is contained in:
meixiongfeng 2023-05-29 17:23:53 +08:00
parent 0ae9600577
commit a4d0f967df
24 changed files with 187 additions and 205 deletions

View File

@ -86,7 +86,7 @@ func (this *modelBattleComp) createeve(session comm.IUserSession, conn *db.DBCon
return
}
if buff != nil {
if conf := this.module.configure.GetHeroConfig(hero.HeroID); conf != nil {
if conf, err := this.module.configure.GetHeroConfig(hero.HeroID); err == nil {
if buff.CampRestriction == conf.Race && buff.OccupationalRestrictions == conf.Job && conf.Star >= buff.StarLimit {
record.Redflist[0].Team[i].PandaBuff = buff.Buffid
}
@ -128,7 +128,7 @@ func (this *modelBattleComp) createeve(session comm.IUserSession, conn *db.DBCon
}
record.Redflist[0].Team[i].Ishelp = true
if buff != nil {
if conf := this.module.configure.GetHeroConfig(hero.HeroID); conf != nil {
if conf, err := this.module.configure.GetHeroConfig(hero.HeroID); err == nil {
if buff.CampRestriction == conf.Race && buff.OccupationalRestrictions == conf.Job && conf.Star >= buff.StarLimit {
record.Redflist[0].Team[i].PandaBuff = buff.Buffid
}
@ -150,7 +150,7 @@ func (this *modelBattleComp) createeve(session comm.IUserSession, conn *db.DBCon
}
if buff != nil {
for _, v := range masters {
if conf := this.module.configure.GetHeroConfig(v.HeroID); conf != nil {
if conf, err := this.module.configure.GetHeroConfig(v.HeroID); err == nil {
if buff.CampRestriction == conf.Race && buff.OccupationalRestrictions == conf.Job && conf.Star >= buff.StarLimit {
v.PandaBuff = buff.Buffid
}
@ -170,7 +170,7 @@ func (this *modelBattleComp) createeve(session comm.IUserSession, conn *db.DBCon
record.Redflist[i].Backupteam = masters
if buff != nil {
for _, v := range masters {
if conf := this.module.configure.GetHeroConfig(v.HeroID); conf != nil {
if conf, err := this.module.configure.GetHeroConfig(v.HeroID); err == nil {
if buff.CampRestriction == conf.Race && buff.OccupationalRestrictions == conf.Job && conf.Star >= buff.StarLimit {
v.PandaBuff = buff.Buffid
}
@ -191,7 +191,7 @@ func (this *modelBattleComp) createeve(session comm.IUserSession, conn *db.DBCon
}
if buff != nil {
for _, v := range masters {
if conf := this.module.configure.GetHeroConfig(v.HeroID); conf != nil {
if conf, err := this.module.configure.GetHeroConfig(v.HeroID); err == nil {
if buff.CampRestriction == conf.Race && buff.OccupationalRestrictions == conf.Job && conf.Star >= buff.StarLimit {
v.PandaBuff = buff.Buffid
}
@ -207,7 +207,7 @@ func (this *modelBattleComp) createeve(session comm.IUserSession, conn *db.DBCon
record.Redflist[i].Backupteam = masters
if buff != nil {
for _, v := range masters {
if conf := this.module.configure.GetHeroConfig(v.HeroID); conf != nil {
if conf, err := this.module.configure.GetHeroConfig(v.HeroID); err == nil {
if buff.CampRestriction == conf.Race && buff.OccupationalRestrictions == conf.Job && conf.Star >= buff.StarLimit {
v.PandaBuff = buff.Buffid
}
@ -266,7 +266,7 @@ func (this *modelBattleComp) createpve(session comm.IUserSession, conn *db.DBCon
return
}
if buff != nil {
if conf := this.module.configure.GetHeroConfig(heros[i].HeroID); conf != nil {
if conf, err := this.module.configure.GetHeroConfig(heros[i].HeroID); err == nil {
if buff.CampRestriction == conf.Race && buff.OccupationalRestrictions == conf.Job && conf.Star >= buff.StarLimit {
record.Redflist[0].Team[i].PandaBuff = buff.Buffid
}
@ -307,7 +307,7 @@ func (this *modelBattleComp) createpve(session comm.IUserSession, conn *db.DBCon
}
record.Redflist[0].Team[i].Ishelp = true
if buff != nil {
if conf := this.module.configure.GetHeroConfig(heros[i].HeroID); conf != nil {
if conf, err := this.module.configure.GetHeroConfig(heros[i].HeroID); err == nil {
if buff.CampRestriction == conf.Race && buff.OccupationalRestrictions == conf.Job && conf.Star >= buff.StarLimit {
record.Redflist[0].Team[i].PandaBuff = buff.Buffid
}
@ -372,7 +372,7 @@ func (this *modelBattleComp) createpvb(session comm.IUserSession, conn *db.DBCon
return
}
if buff != nil {
if conf := this.module.configure.GetHeroConfig(heros[i].HeroID); conf != nil {
if conf, err := this.module.configure.GetHeroConfig(heros[i].HeroID); err == nil {
if buff.CampRestriction == conf.Race && buff.OccupationalRestrictions == conf.Job && conf.Star >= buff.StarLimit {
record.Redflist[ii].Team[i].PandaBuff = buff.Buffid
}
@ -413,7 +413,7 @@ func (this *modelBattleComp) createpvb(session comm.IUserSession, conn *db.DBCon
}
record.Redflist[ii].Team[i].Ishelp = true
if buff != nil {
if conf := this.module.configure.GetHeroConfig(heros[i].HeroID); conf != nil {
if conf, err := this.module.configure.GetHeroConfig(heros[i].HeroID); err == nil {
if buff.CampRestriction == conf.Race && buff.OccupationalRestrictions == conf.Job && conf.Star >= buff.StarLimit {
record.Redflist[ii].Team[i].PandaBuff = buff.Buffid
}
@ -602,7 +602,7 @@ func (this *modelBattleComp) createlpve(session comm.IUserSession, conn *db.DBCo
return
}
if buff != nil {
if conf := this.module.configure.GetHeroConfig(heros[i].HeroID); conf != nil {
if conf, err := this.module.configure.GetHeroConfig(heros[i].HeroID); err == nil {
if buff.CampRestriction == conf.Race && buff.OccupationalRestrictions == conf.Job && conf.Star >= buff.StarLimit {
record.Redflist[0].Team[i].PandaBuff = buff.Buffid
}
@ -643,7 +643,7 @@ func (this *modelBattleComp) createlpve(session comm.IUserSession, conn *db.DBCo
}
record.Redflist[0].Team[i].Ishelp = true
if buff != nil {
if conf := this.module.configure.GetHeroConfig(heros[i].HeroID); conf != nil {
if conf, err := this.module.configure.GetHeroConfig(heros[i].HeroID); err == nil {
if buff.CampRestriction == conf.Race && buff.OccupationalRestrictions == conf.Job && conf.Star >= buff.StarLimit {
record.Redflist[0].Team[i].PandaBuff = buff.Buffid
}
@ -831,7 +831,7 @@ func (this *modelBattleComp) checkBattlereadyCapskill(leadpos int32, heros []*pb
conf = make([]*cfg.GameHeroData, len(heros))
for i, v := range heros {
if v != nil {
conf[i] = this.module.configure.GetHeroConfig(v.HeroID)
conf[i], _ = this.module.configure.GetHeroConfig(v.HeroID)
}
}
if caprule, err = this.module.configure.GetBattlereadyCapskill(conf[leadpos].Capskillrule); err != nil {

View File

@ -177,31 +177,21 @@ func (this *MCompConfigure) GetDropReward(dropId int32) (result []*cfg.Gameatn)
return
}
// func (this *MCompConfigure) GetColor(id int32) (item *cfg.GameGameColorData, err error) {
// var (
// v interface{}
// ok bool
// )
// if v, err = this.GetConfigure(game_gamecolor); err == nil {
// return
// } else {
// if item, ok = v.(*cfg.GameGameColor).GetDataMap()[id]; !ok {
// err = fmt.Errorf("on found color:%d", id)
// }
// }
// return
// }
// 获取英雄原始星级
func (this *MCompConfigure) GetHeroConfig(heroCfgId string) *cfg.GameHeroData {
if v, err := this.GetConfigure(new_hero); err == nil {
func (this *MCompConfigure) GetHeroConfig(heroCfgId string) (conf *cfg.GameHeroData, err error) {
var (
v interface{}
)
if v, err = this.GetConfigure(new_hero); err == nil {
if configure, ok := v.(*cfg.GameHero); ok {
if v, ok := configure.GetDataMap()[heroCfgId]; ok {
return v
if conf, ok = configure.GetDataMap()[heroCfgId]; !ok {
err = comm.NewNotFoundConfErr("gourmet", new_hero, heroCfgId)
}
return
}
}
return nil
err = comm.NewNotFoundConfErr("gourmet", new_hero, heroCfgId)
return
}
// 获取英雄原始星级

View File

@ -29,9 +29,10 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.EnchantChallen
return
}
cfgData := this.module.configure.GetEnchantBossConfigData(req.BossType)
if cfgData == nil {
cfgData, err := this.module.configure.GetEnchantBossConfigData(req.BossType)
if err != nil {
code = pb.ErrorCode_ConfigNoFound
data.Message = err.Error()
return
}
if len(cfgData) <= 0 {

View File

@ -34,9 +34,10 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.EnchantCha
return
}
cfgEnchant := this.module.configure.GetEnchantBossConfigData(req.BossType)
if cfgEnchant == nil {
cfgEnchant, err := this.module.configure.GetEnchantBossConfigData(req.BossType)
if err != nil {
code = pb.ErrorCode_ConfigNoFound
data.Message = err.Error()
return
}

View File

@ -1,6 +1,7 @@
package enchant
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules"
@ -46,9 +47,15 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
}
// 参数: boss类型 难度
func (this *configureComp) GetEnchantBossConfigData(bossId int32) (data []*cfg.GameEnchantBossData) {
return this._enchantMap[bossId]
func (this *configureComp) GetEnchantBossConfigData(bossId int32) (data []*cfg.GameEnchantBossData, err error) {
var (
ok bool
)
if data, ok = this._enchantMap[bossId]; !ok {
err = comm.NewNotFoundConfErr("enchant", game_enchantboss, bossId)
return
}
return
}
//加载多个配置文件
@ -68,18 +75,23 @@ func (this *configureComp) GetConfigure(name string) (v interface{}, err error)
return configure.GetConfigure(name)
}
func (this *configureComp) GetBuyChallengeCount(index int32) (data *cfg.GameEnchantShopData) {
if v, err := this.GetConfigure(game_enchantshop); err == nil {
func (this *configureComp) GetBuyChallengeCount(index int32) (data *cfg.GameEnchantShopData, err error) {
var (
v interface{}
)
if v, err = this.GetConfigure(game_enchantshop); err == nil {
if configure, ok := v.(*cfg.GameEnchantShop); ok {
data = configure.Get(index)
if data == nil {
err = comm.NewNotFoundConfErr("enchant", game_enchantshop, index)
}
return
}
} else {
log.Errorf("get game_challenge conf err:%v", err)
}
err = comm.NewNotFoundConfErr("enchant", game_enchantshop, index)
return
}
func (this *configureComp) GetMaxBuyChallengeCount() int32 {
if v, err := this.GetConfigure(game_enchantshop); err == nil {
if configure, ok := v.(*cfg.GameEnchantShop); ok {

View File

@ -49,7 +49,7 @@ func (this *modelEnchant) getEnchantList(uid string) (result *pb.DBEnchant, err
// 红点检测
func (this *modelEnchant) checkReddot33(session comm.IUserSession) bool {
conf := this.module.configure.GetEnchantBossConfigData(1)
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

View File

@ -21,9 +21,10 @@ func (this *apiComp) ActivateAtlas(session comm.IUserSession, req *pb.GourmetAct
if code != pb.ErrorCode_Success {
return // 参数校验失败直接返回
}
conf := this.configure.GetGrormetCookBookConf(req.Cid)
if conf == nil { // 配置校验
conf, err := this.configure.GetGrormetCookBookConf(req.Cid)
if err != nil { // 配置校验
code = pb.ErrorCode_ConfigNoFound
data.Message = err.Error()
return
}
_gourmet, err := this.module.modelAtlas.getGourmetAtlasList(session.GetUserId())

View File

@ -25,9 +25,10 @@ func (this *apiComp) CreateFood(session comm.IUserSession, req *pb.GourmetCreate
if code != pb.ErrorCode_Success {
return // 参数校验失败直接返回
}
conf := this.configure.GetGrormetCookBookConf(req.Cid)
if conf == nil { // 配置校验
conf, err := this.configure.GetGrormetCookBookConf(req.Cid)
if err != nil { // 配置校验
code = pb.ErrorCode_ConfigNoFound
data.Message = err.Error()
return
}

View File

@ -1,6 +1,7 @@
package gourmet
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules"
@ -9,7 +10,6 @@ import (
)
const (
//game_gourmet = "game_gourmet.json"
game_food = "game_breakingbad.json"
)
@ -17,7 +17,7 @@ const (
type configureComp struct {
modules.MCompConfigure
module *Gourmet
normal string
normal string // 普通菜
}
//组件初始化接口
@ -65,14 +65,20 @@ func (this *configureComp) SetGrormetCookBookConf() {
return
}
func (this *configureComp) GetGrormetCookBookConf(id string) (configure *cfg.GameBreakingbadData) {
if v, err := this.GetConfigure(game_food); err == nil {
func (this *configureComp) GetGrormetCookBookConf(id string) (configure *cfg.GameBreakingbadData, err error) {
var (
v interface{}
)
if v, err = this.GetConfigure(game_food); err == nil {
if conf, ok := v.(*cfg.GameBreakingbad); ok {
return conf.Get(id)
configure = conf.Get(id)
if configure == nil {
err = comm.NewNotFoundConfErr("gourmet", game_food, id)
}
return
}
}
this.module.Errorf("can't found GameBreakingbadData:%d", id)
err = comm.NewNotFoundConfErr("gourmet", game_food, id)
return
}

View File

@ -25,6 +25,7 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
_hero *pb.DBHero
chanegCard []*pb.DBHero // change
_heroMap map[string]interface{}
err error
)
_heroMap = make(map[string]interface{}, 0)
chanegCard = make([]*pb.DBHero, 0)
@ -37,9 +38,10 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
return
}
awakenData = this.module.configure.GetHeroAwakenConfig(_hero.HeroID, _hero.JuexingLv+1)
if awakenData == nil {
awakenData, err = this.module.configure.GetHeroAwakenConfig(_hero.HeroID, _hero.JuexingLv+1)
if err != nil {
code = pb.ErrorCode_ConfigNoFound
data.Message = err.Error()
return
}
if len(awakenData.Phasebonus) < 2 { // 配置校验
@ -82,7 +84,7 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
_heroMap["juexingLv"] = _hero.JuexingLv
_heroMap["juexProperty"] = _hero.JuexProperty
// 保存数据
err := this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap)
err = this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap)
if err != nil {
code = pb.ErrorCode_DBError
this.module.Errorf("update hero skill failed:%v", err)
@ -106,13 +108,13 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
szTask = append(szTask, comm.GettaskParam(comm.Rtype118, _hero.Lv, _hero.JuexingLv))
szTask = append(szTask, comm.GettaskParam(comm.Rtype120, 1))
szTask = append(szTask, comm.GettaskParam(comm.Rtype122, _hero.JuexingLv, _hero.Star))
cfg := this.module.configure.GetHeroConfig(_hero.HeroID)
if cfg != nil {
cfg, err := this.module.configure.GetHeroConfig(_hero.HeroID)
if err == nil {
szTask = append(szTask, comm.GettaskParam(comm.Rtype121, 1, cfg.Race))
//xx英雄满级、共鸣、觉醒至最高状态
nextAwaken := this.module.configure.GetHeroAwakenConfig(_hero.HeroID, _hero.JuexingLv+1)
if nextAwaken == nil { // 达到满级觉醒
_, err := this.module.configure.GetHeroAwakenConfig(_hero.HeroID, _hero.JuexingLv+1)
if err != nil { // 达到满级觉醒
if _hero.Lv == this.module.configure.GetHeroMaxLv(_hero.Star) {
// 校验共鸣满级
var _l int32
@ -133,6 +135,10 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
}
}
} else {
code = pb.ErrorCode_ConfigNoFound
data.Message = err.Error()
return
}
go this.module.ModuleRtask.TriggerTask(session.GetUserId(), szTask...)
return

View File

@ -28,9 +28,10 @@ func (this *apiComp) Fusion(session comm.IUserSession, req *pb.HeroFusionReq) (c
if code = this.FusionCheck(session, req); code != pb.ErrorCode_Success {
return
}
conf := this.module.configure.GetHeroFucionConfig(req.HeroId)
if conf == nil {
conf, err := this.module.configure.GetHeroFucionConfig(req.HeroId)
if err != nil {
code = pb.ErrorCode_ConfigNoFound // 配置没找到
data.Message = err.Error()
return
}
for _, v := range req.Heros {

View File

@ -35,9 +35,10 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt
return
}
// 查询配置表 找出原始品质
heroCfg := this.module.configure.GetHeroConfig(_hero.HeroID)
if heroCfg == nil {
code = pb.ErrorCode_HeroNoExist
heroCfg, err := this.module.configure.GetHeroConfig(_hero.HeroID)
if err != nil {
code = pb.ErrorCode_ConfigNoFound
data.Message = err.Error()
return
}
for _, v1 := range req.Item {
@ -134,7 +135,7 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt
szTask = append(szTask, comm.GettaskParam(comm.Rtype57, 1))
szTask = append(szTask, comm.GettaskParam(comm.Rtype174, 1, _hero.Star))
}
if cfg := this.module.configure.GetHeroConfig(_hero.HeroID); cfg != nil {
if cfg, err := this.module.configure.GetHeroConfig(_hero.HeroID); err == nil {
szTask = append(szTask, comm.GettaskParam(comm.Rtype55, 1, cfg.Color))
szTask = append(szTask, comm.GettaskParam(comm.Rtype56, 1, 1, cfg.Job))
szTask = append(szTask, comm.GettaskParam(comm.Rtype116, lvUpCount, cfg.Race))

View File

@ -21,6 +21,7 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, req *pb.HeroStr
var (
starConf *cfg.GameHeroStarupData // 配置表目标升星英雄信息
_hero *pb.DBHero // 目标英雄
err error
)
code = this.StrengthenUpStarCheck(session, req) // check
@ -33,13 +34,19 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, req *pb.HeroStr
}
// 校验指定英雄
starConf = this.module.configure.GetHeroStarupConfig(_hero.HeroID, _hero.Star)
if starConf == nil {
code = pb.ErrorCode_ReqParameterError
starConf, err = this.module.configure.GetHeroStarupConfig(_hero.HeroID, _hero.Star)
if err != nil {
code = pb.ErrorCode_ConfigNoFound
data.Message = err.Error()
return
}
heroConf := this.module.configure.GetHeroConfig(_hero.HeroID)
nextHeroConfig := this.module.configure.GetHeroStarupConfig(_hero.HeroID, _hero.Star+1)
heroConf, err := this.module.configure.GetHeroConfig(_hero.HeroID)
if err != nil {
code = pb.ErrorCode_ConfigNoFound
data.Message = err.Error()
return
}
nextHeroConfig, _ := this.module.configure.GetHeroStarupConfig(_hero.HeroID, _hero.Star+1)
if nextHeroConfig == nil && heroConf.Type != comm.CardTypeStar {
code = pb.ErrorCode_HeroMaxStarLv
return
@ -67,7 +74,7 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, req *pb.HeroStr
}
// 保存数据
err := this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap)
err = this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap)
if err != nil {
code = pb.ErrorCode_DBError
this.module.Errorf("update hero star failed:%v", err)

View File

@ -44,9 +44,13 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStren
N: v,
})
// 查询 本次消耗会获得多少经验
if expConf := this.module.configure.GetHeroExp(k); expConf != nil {
if expConf, err := this.module.configure.GetHeroExp(k); err == nil {
addExp += expConf.Exp * v
costGold += expConf.Needgold * v
} else {
code = pb.ErrorCode_ConfigNoFound
data.Message = err.Error()
return
}
}
cost = append(cost, &cfg.Gameatn{

View File

@ -141,14 +141,14 @@ func (this *apiComp) TalentLearn(session comm.IUserSession, req *pb.HeroTalentLe
szTask = append(szTask, comm.GettaskParam(comm.Rtype123, 1, int32(len(talent.Talent)), heroObj.Star))
szTask = append(szTask, comm.GettaskParam(comm.Rtype124, 1))
szTask = append(szTask, comm.GettaskParam(comm.Rtype125, 1, utils.ToInt32(heroObj.HeroID)))
cfg := this.module.configure.GetHeroConfig(heroObj.HeroID)
if cfg != nil {
cfg, err := this.module.configure.GetHeroConfig(heroObj.HeroID)
if err != nil {
szTask = append(szTask, comm.GettaskParam(comm.Rtype126, 1, cfg.Race))
}
szTask = append(szTask, comm.GettaskParam(comm.Rtype127, 1, heroObj.Star))
szTask = append(szTask, comm.GettaskParam(comm.Rtype40, 1, int32(len(talent.Talent))))
nextAwaken := this.module.configure.GetHeroAwakenConfig(heroObj.HeroID, heroObj.JuexingLv+1)
if nextAwaken == nil { // 达到满级觉醒
_, err = this.module.configure.GetHeroAwakenConfig(heroObj.HeroID, heroObj.JuexingLv+1)
if err != nil { // 达到满级觉醒
if heroObj.Lv == this.module.configure.GetHeroMaxLv(heroObj.Star) {
if this.module.configure.GetHeroTalentMaxLv(heroObj.HeroID) == int32(len(talent.Talent)) {

View File

@ -2,6 +2,7 @@ package hero
import (
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
@ -106,8 +107,16 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
}
// 获取英雄升星相关配置数据
func (this *configureComp) GetHeroStarupConfig(hid string, star int32) *cfg.GameHeroStarupData {
return this.starMap[utils.ToInt64(hid)+int64(star)<<31]
func (this *configureComp) GetHeroStarupConfig(hid string, star int32) (conf *cfg.GameHeroStarupData, err error) {
var (
ok bool
par interface{}
)
if conf, ok = this.starMap[utils.ToInt64(hid)+int64(star)<<31]; !ok {
par = fmt.Errorf("hid:%s,phase:%d", hid, star)
err = comm.NewNotFoundConfErr("hero", hero_starup, par)
}
return
}
// 获取当前英雄最高星级
@ -123,8 +132,16 @@ func (this *configureComp) GetHeroMaxStar(hid string, curStar int32) int32 {
}
// 获取觉醒配置
func (this *configureComp) GetHeroAwakenConfig(hid string, phase int32) *cfg.GameHeroAwakenData {
return this.awakenMap[utils.ToInt64(hid)+int64(phase)<<31]
func (this *configureComp) GetHeroAwakenConfig(hid string, phase int32) (cfg *cfg.GameHeroAwakenData, err error) {
var (
ok bool
par interface{}
)
if cfg, ok = this.awakenMap[utils.ToInt64(hid)+int64(phase)<<31]; !ok {
par = fmt.Errorf("hid:%s,phase:%d", hid, phase)
err = comm.NewNotFoundConfErr("hero", hero_awaken, par)
}
return
}
// 抽卡配置表
@ -159,48 +176,38 @@ func (this *configureComp) GetPollByType(poosType string) map[int32][]*cfg.GameD
return this.drawCardCfg[poosType]
}
func (this *configureComp) GetHeroExpConfig() (configure *cfg.GameHeroExp, err error) {
func (this *configureComp) GetHeroExp(hid string) (conf *cfg.GameHeroExpData, err error) {
var (
v interface{}
ok bool
v interface{}
)
if v, err = this.GetConfigure(hero_exp); err == nil {
if configure, ok = v.(*cfg.GameHeroExp); !ok {
err = fmt.Errorf("%T no is *cfg.GameHeroExp", v)
return
if c, ok := v.(*cfg.GameHeroExp); ok {
if conf = c.Get(hid); conf == nil {
err = comm.NewNotFoundConfErr("hero", hero_exp, hid)
return
}
}
} else {
err = fmt.Errorf("%T no is *cfg.GameHeroExp", v)
return
}
err = comm.NewNotFoundConfErr("hero", hero_exp, hid)
return
}
func (this *configureComp) GetHeroExp(hid string) *cfg.GameHeroExpData {
if v, err := this.GetConfigure(hero_exp); err == nil {
if configure, ok := v.(*cfg.GameHeroExp); !ok {
err = fmt.Errorf("%T no is *cfg.GameHeroExp", v)
return nil
} else {
return configure.Get(hid)
}
} else {
err = fmt.Errorf("%T no is *cfg.GameHeroExp", v)
}
return nil
}
//获取英雄配置
func (this *configureComp) GetHeroConfig(heroCfgId string) *cfg.GameHeroData {
if v, err := this.GetConfigure(new_hero); err == nil {
func (this *configureComp) GetHeroConfig(heroCfgId string) (conf *cfg.GameHeroData, err error) {
var (
v interface{}
)
if v, err = this.GetConfigure(new_hero); err == nil {
if configure, ok := v.(*cfg.GameHero); ok {
if v, ok := configure.GetDataMap()[heroCfgId]; ok {
return v
if conf, ok = configure.GetDataMap()[heroCfgId]; !ok {
err = comm.NewNotFoundConfErr("hero", new_hero, heroCfgId)
}
return
}
}
this.module.Errorf("config no is *cfg.GameHero heroid :%s", heroCfgId)
return nil
err = comm.NewNotFoundConfErr("hero", new_hero, heroCfgId)
return
}
//获取英雄星级配置
@ -270,15 +277,19 @@ func (this *configureComp) GetHeroSkillMaxLvConfig(skillId uint32) int32 {
}
// 获取卡牌合成配置
func (this *configureComp) GetHeroFucionConfig(cid string) (data *cfg.GameHerofusionData) {
if v, err := this.GetConfigure(hero_fusion); err == nil {
func (this *configureComp) GetHeroFucionConfig(cid string) (data *cfg.GameHerofusionData, err error) {
var (
v interface{}
)
if v, err = this.GetConfigure(hero_fusion); err == nil {
if configure, ok := v.(*cfg.GameHerofusion); ok {
data = configure.Get(cid)
if data = configure.Get(cid); data != nil {
err = comm.NewNotFoundConfErr("hero", hero_fusion, cid)
}
return
}
}
this.module.Errorf("cfg.GameHerofusionData GetHeroFucionConfig:id = %s", cid)
err = comm.NewNotFoundConfErr("hero", hero_fusion, cid)
return
}

View File

@ -38,7 +38,7 @@ func (this *ModelHero) Init(service core.IService, module core.IModule, comp cor
//初始化英雄
func (this *ModelHero) InitHero(uid string, heroCfgId string) *pb.DBHero {
heroCfg := this.moduleHero.configure.GetHeroConfig(heroCfgId)
heroCfg, _ := this.moduleHero.configure.GetHeroConfig(heroCfgId)
if heroCfg == nil {
this.moduleHero.Errorf("%v hero not found from config %v", heroCfgId)
return nil
@ -69,7 +69,7 @@ func (this *ModelHero) InitHero(uid string, heroCfgId string) *pb.DBHero {
//初始化英雄技能
func (this *ModelHero) initHeroSkill(hero *pb.DBHero) []*pb.SkillData {
heroCfg := this.moduleHero.configure.GetHeroConfig(hero.HeroID)
heroCfg, _ := this.moduleHero.configure.GetHeroConfig(hero.HeroID)
if heroCfg != nil {
if heroCfg.Skill != 0 {
hero.CaptainSkill = heroCfg.Skill
@ -211,8 +211,8 @@ func (this *ModelHero) getHeroList(uid string) []*pb.DBHero {
func (this *ModelHero) resetJuexingProperty(hero *pb.DBHero) {
hero.JuexProperty = make(map[string]int32)
for i := 1; i <= int(hero.JuexingLv); i++ {
awakenData := this.moduleHero.configure.GetHeroAwakenConfig(hero.HeroID, int32(i))
if awakenData != nil {
awakenData, err := this.moduleHero.configure.GetHeroAwakenConfig(hero.HeroID, int32(i))
if err == nil {
if len(awakenData.Phasebonus) != 2 {
continue
}
@ -433,7 +433,7 @@ func (this *ModelHero) StarHpAddition(star int32) (addValue float32) {
//英雄基础属性 + 英雄等级基础属性 * 英雄成长系数 + 英雄星级对应等级属性 * 英雄品质系数
func (this *ModelHero) PropertyCompute(hero *pb.DBHero) {
growCfg := this.moduleHero.configure.GetHeroLvgrow(hero.HeroID)
heroCfg := this.moduleHero.configure.GetHeroConfig(hero.HeroID)
heroCfg, _ := this.moduleHero.configure.GetHeroConfig(hero.HeroID)
lvCfg := this.moduleHero.configure.GetHeroLv(hero.Lv)
starCfg := this.moduleHero.configure.GetHeroStar(hero.Star)
starLvfg := this.moduleHero.configure.GetHeroLv(starCfg.Level)
@ -590,12 +590,12 @@ func (this *ModelHero) AddCardExp(session comm.IUserSession, hero *pb.DBHero, ex
szTask = append(szTask, comm.GettaskParam(comm.Rtype24, 1))
// szTask = append(szTask, comm.GettaskParam(comm.Rtype29, 1, hero.Lv, utils.ToInt32(hero.HeroID)))
if cfg := this.moduleHero.configure.GetHeroConfig(hero.HeroID); cfg != nil {
if cfg, _ := this.moduleHero.configure.GetHeroConfig(hero.HeroID); cfg != nil {
szTask = append(szTask, comm.GettaskParam(comm.Rtype32, 1, cfg.Color, hero.Lv))
//xx英雄满级、共鸣、觉醒至最高状态
nextAwaken := this.moduleHero.configure.GetHeroAwakenConfig(hero.HeroID, hero.JuexingLv+1)
if nextAwaken == nil { // 达到满级觉醒
_, err := this.moduleHero.configure.GetHeroAwakenConfig(hero.HeroID, hero.JuexingLv+1)
if err != nil { // 达到满级觉醒
if hero.Lv == this.moduleHero.configure.GetHeroMaxLv(hero.Star) {
var _l int32
talent, err := this.moduleHero.modelTalent.GetHerotalent(session.GetUserId())
@ -698,7 +698,7 @@ func (this *ModelHero) GetRandHeroIdBypool(sz []int32) int32 {
// 初始化怪物属性
func (this *ModelHero) InitMonsterHero(heroCfgId string, star, lv int32) *pb.DBHero {
heroCfg := this.moduleHero.configure.GetHeroConfig(heroCfgId)
heroCfg, _ := this.moduleHero.configure.GetHeroConfig(heroCfgId)
if heroCfg == nil {
this.moduleHero.Errorf("%v hero not found from config %v", heroCfgId)
return nil
@ -857,7 +857,7 @@ func (this *ModelHero) resetTalentProperty(hero *pb.DBHero) {
func (this *ModelHero) createHero(session comm.IUserSession, heroCfgId string, count int32) (hero *pb.DBHero, bFirst bool, atno []*pb.UserAtno, err error) {
heros := make([]*pb.DBHero, 0)
uid := session.GetUserId()
heroCfg := this.moduleHero.configure.GetHeroConfig(heroCfgId)
heroCfg, _ := this.moduleHero.configure.GetHeroConfig(heroCfgId)
if heroCfg == nil {
err = errors.New("not found hero configID")
this.moduleHero.Errorf("not found hero configID:%s", heroCfgId)

View File

@ -94,7 +94,7 @@ func (this *Hero) createRepeatHero(session comm.IUserSession, heroCfgId string,
// 统计任务
// 查品质
cfg := this.configure.GetHeroConfig(heroCfgId)
cfg, _ := this.configure.GetHeroConfig(heroCfgId)
if cfg != nil {
var szTask []*comm.TaskParam
szTask = append(szTask, comm.GettaskParam(comm.Rtype1, 1, utils.ToInt32(heroCfgId)))
@ -213,14 +213,14 @@ func (this *Hero) GetSpecifiedHero(session comm.IUserSession, heroConfId string,
return pb.ErrorCode_ReqParameterError
}
// 等级校验
conf := this.configure.GetHeroConfig(heroConfId)
conf, _ := this.configure.GetHeroConfig(heroConfId)
if conf == nil {
code = pb.ErrorCode_ReqParameterError
return
}
cid := heroConfId
maxStar := conf.Star
starConf := this.configure.GetHeroStarupConfig(cid, conf.Star)
starConf, _ := this.configure.GetHeroStarupConfig(cid, conf.Star)
if starConf == nil {
code = pb.ErrorCode_ReqParameterError
return
@ -655,7 +655,7 @@ func (this *Hero) GetAllMaxHero(session comm.IUserSession) (code pb.ErrorCode) {
if v.Handbook != -1 {
cid := v.Hid
maxStar := v.Star
starConf := this.configure.GetHeroStarupConfig(cid, v.Star)
starConf, _ := this.configure.GetHeroStarupConfig(cid, v.Star)
if starConf == nil {
continue // 走到这里说明配置表没有配置数据
}
@ -666,8 +666,8 @@ func (this *Hero) GetAllMaxHero(session comm.IUserSession) (code pb.ErrorCode) {
maxJux := 1 // 最大觉醒等级
for i := 1; ; i++ {
data := this.configure.GetHeroAwakenConfig(cid, int32(i))
if data == nil {
_, err := this.configure.GetHeroAwakenConfig(cid, int32(i))
if err != nil {
maxJux = i - 1
break
}
@ -919,7 +919,7 @@ func (this *Hero) DrawCardContinuousRestrictionCamp(cardId string, race map[int3
}
iMaxCount := cfgDraw.DrawCardContinuousRestrictionCamp
// 获取阵营
if heroConf := this.configure.GetHeroConfig(cardId); heroConf != nil {
if heroConf, _ := this.configure.GetHeroConfig(cardId); heroConf != nil {
if v1, ok := race[heroConf.Race]; ok && v1 > iMaxCount { // 满足条件 再随机获取一个英雄
for i := 0; i < int(iMaxCount); i++ { // 最多循环次数
randomIndex := this.modelHero.GetRandW(sz)

View File

@ -90,30 +90,6 @@ func (this *configureComp) GetHuntingBossTypeConfigData() (mapType map[int32]str
return
}
// func (this *configureComp) GetBuyChallengeCount(index int32) (data *cfg.GameHuntingChallengeData) {
// if v, err := this.GetConfigure(game_challenge); err == nil {
// if configure, ok := v.(*cfg.GameHuntingChallenge); ok {
// data = configure.Get(index)
// return
// }
// } else {
// log.Errorf("get game_challenge conf err:%v", err)
// }
// return
// }
// func (this *configureComp) GetMaxBuyChallengeCount() int32 {
// if v, err := this.GetConfigure(game_challenge); err == nil {
// if configure, ok := v.(*cfg.GameHuntingChallenge); ok {
// return int32(len(configure.GetDataList()))
// }
// } else {
// log.Errorf("get game_challenge conf err:%v", err)
// }
// return 0
// }
// 获取boss 最大难点
func (this *configureComp) GetMaxDifficultyByBossID(bossId int32) int32 {
if v, ok := this.boos[bossId]; ok {

View File

@ -150,11 +150,15 @@ func (this *apiComp) UseGift(session comm.IUserSession, req *pb.LibraryUseGiftRe
//library := this.module.modelLibrary.getLibraryList(session.GetUserId())
this.module.Errorf("英雄好感度等级提升,英雄ID:%s,增加经验:%s,提升的等级:%d", _heroObj.Heroid, addExp, upLv)
if rst, err := this.module.ModuleUser.GetUserExpand(session.GetUserId()); err == nil { // 修改阵营累计好感度
if heroCfg := this.module.configure.GetHeroConfig(_heroObj.Heroid); heroCfg != nil {
if heroCfg, err := this.module.configure.GetHeroConfig(_heroObj.Heroid); err == nil {
rst.Race[heroCfg.Race] += upLv
this.module.ModuleUser.ChangeUserExpand(session.GetUserId(), map[string]interface{}{
"race": rst.Race,
})
} else {
code = pb.ErrorCode_ConfigNoFound
data.Message = err.Error()
return
}
}
var szTask []*comm.TaskParam

View File

@ -73,14 +73,14 @@ func (this *apiComp) Expulsion(session comm.IUserSession, req *pb.PracticeExpuls
}
exp1 += exp
//满级英雄加
//满级英雄加
for k, v := range froom.Full {
if v > 0 {
if conf, err := this.module.configure.getGamePandamasYxjx(k); err != nil {
this.module.Errorln(err)
} else if v/conf.Register > 0 {
if hero, code := this.module.ModuleHero.GetHeroByObjID(session.GetUserId(), pillar.Hero); code == pb.ErrorCode_Success {
if heroconf := this.module.configure.GetHeroConfig(hero.HeroID); heroconf != nil {
if heroconf, _ := this.module.configure.GetHeroConfig(hero.HeroID); heroconf != nil {
if (conf.Camp == 0 || (conf.Camp != 0 && heroconf.Race == conf.Camp)) && (conf.Occupation == 0 || (conf.Occupation != 0 && heroconf.Job == conf.Occupation)) {
exp1 += minutes * int32(math.Floor(float64(v/conf.Register)*float64(conf.ExpBonus))) * exp
}

View File

@ -101,14 +101,14 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.PracticeReceiveR
}
exp1 += exp
this.module.Debug("基础经验加成", log.Field{Key: "minutes", Value: minutes}, log.Field{Key: "minExp", Value: pillarconfigure.MinExp}, log.Field{Key: "exp1", Value: exp1})
//满级英雄加
//满级英雄加
for k, v := range room.Full {
if v > 0 {
if conf, err := this.module.configure.getGamePandamasYxjx(k); err != nil {
this.module.Errorln(err)
} else if v/conf.Register > 0 {
if hero, err := this.module.ModuleHero.QueryCrossHeroinfo(pillar.Hero); err == nil {
if heroconf := this.module.configure.GetHeroConfig(hero.HeroID); heroconf != nil {
if heroconf, _ := this.module.configure.GetHeroConfig(hero.HeroID); heroconf != nil {
if (conf.Camp == 0 || (conf.Camp != 0 && heroconf.Race == conf.Camp)) && (conf.Occupation == 0 || (conf.Occupation != 0 && heroconf.Job == conf.Occupation)) {
// exp1 += int32(math.Floor(float64(v/conf.Register) * float64(conf.ExpBonus) / float64(100) * float64(exp)))
exp1 += minutes * int32(math.Floor(float64(v/conf.Register)*float64(conf.ExpBonus)))

View File

@ -431,21 +431,6 @@ func (this *MCompConfigure) GetDropReward(dropId int32) (result []*cfg.Gameatn)
return
}
// func (this *MCompConfigure) GetColor(id int32) (item *cfg.GameGameColorData, err error) {
// var (
// v interface{}
// ok bool
// )
// if v, err = this.GetConfigure(game_gamecolor); err == nil {
// return
// } else {
// if item, ok = v.(*cfg.GameGameColor).GetDataMap()[id]; !ok {
// err = fmt.Errorf("on found color:%d", id)
// }
// }
// return
// }
// 获取英雄原始星级
func (this *MCompConfigure) GetHeroConfig(heroCfgId string) *cfg.GameHeroData {
if v, err := this.GetConfigure(new_hero); err == nil {

View File

@ -92,31 +92,6 @@ func (this *configureComp) GetVikingBossTypeConfigData() map[int32]struct{} {
return mapType
}
// func (this *configureComp) GetBuyChallengeCount(index int32) (data *cfg.GameVikingChallengeData) {
// if v, err := this.GetConfigure(game_challenge); err == nil {
// if configure, ok := v.(*cfg.GameVikingChallenge); ok {
// data = configure.Get(index)
// return
// }
// } else {
// log.Errorf("get game_challenge conf err:%v", err)
// }
// return
// }
// func (this *configureComp) GetMaxBuyChallengeCount() int32 {
// if v, err := this.GetConfigure(game_challenge); err == nil {
// if configure, ok := v.(*cfg.GameVikingChallenge); ok {
// return int32(len(configure.GetDataList()))
// }
// } else {
// log.Errorf("get game_challenge conf err:%v", err)
// }
// return 0
// }
// 获取boss 最大难点
func (this *configureComp) GetMaxDifficultyByBossID(bossId int32) int32 {
if v, ok := this.boos[bossId]; ok {