代码整理

This commit is contained in:
meixiongfeng 2023-05-31 18:17:21 +08:00
parent fa4b57748b
commit 732398c5ea
30 changed files with 232 additions and 122 deletions

View File

@ -85,7 +85,10 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.CaravanBuyOrSe
} }
} else { } else {
code = pb.ErrorCode_DataNotFound code = pb.ErrorCode_DataNotFound
data.Message = e.Error() data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
} }
} }
addScore += price * v // 卖出收益 addScore += price * v // 卖出收益

View File

@ -60,7 +60,10 @@ func (this *apiComp) GotoCity(session comm.IUserSession, req *pb.CaravanGotoCity
// } // }
} else { } else {
code = pb.ErrorCode_DataNotFound code = pb.ErrorCode_DataNotFound
data.Message = e.Error() data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: e.Error(),
}
} }
} }
if list.Curcity == req.City { if list.Curcity == req.City {

View File

@ -9,6 +9,8 @@ import (
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
) )
var moduleName = "caravan"
const ( const (
game_caravan = "game_caravancity.json" game_caravan = "game_caravancity.json"
game_caravan_lv = "game_caravanlv.json" game_caravan_lv = "game_caravanlv.json"
@ -62,13 +64,13 @@ func (this *configureComp) GetCaravanCity(cityId int32) (data *cfg.GameCaravanCi
if v, err = this.GetConfigure(game_caravan); err == nil { if v, err = this.GetConfigure(game_caravan); err == nil {
if configure, ok := v.(*cfg.GameCaravanCity); ok { if configure, ok := v.(*cfg.GameCaravanCity); ok {
if data = configure.Get(cityId); data == nil { if data = configure.Get(cityId); data == nil {
err = comm.NewNotFoundConfErr("caravan", game_caravan, cityId) err = comm.NewNotFoundConfErr(moduleName, game_caravan, cityId)
this.module.Errorln(err) this.module.Errorln(err)
} }
return return
} }
} }
err = comm.NewNotFoundConfErr("caravan", game_caravan, cityId) err = comm.NewNotFoundConfErr(moduleName, game_caravan, cityId)
return return
} }
@ -80,13 +82,13 @@ func (this *configureComp) GetCaravanLv(lv int32) (data *cfg.GameCaravanLvData,
if v, err = this.GetConfigure(game_caravan_lv); err == nil { if v, err = this.GetConfigure(game_caravan_lv); err == nil {
if configure, ok := v.(*cfg.GameCaravanLv); ok { if configure, ok := v.(*cfg.GameCaravanLv); ok {
if data = configure.Get(lv); data == nil { if data = configure.Get(lv); data == nil {
err = comm.NewNotFoundConfErr("caravan", game_caravan_lv, lv) err = comm.NewNotFoundConfErr(moduleName, game_caravan_lv, lv)
this.module.Errorln(err) this.module.Errorln(err)
} }
return return
} }
} }
err = comm.NewNotFoundConfErr("caravan", game_caravan_lv, lv) err = comm.NewNotFoundConfErr(moduleName, game_caravan_lv, lv)
return return
} }
@ -97,13 +99,13 @@ func (this *configureComp) GetCaravanGoods(itemId int32) (data *cfg.GameCaravanT
if v, err = this.GetConfigure(game_caravan_thing); err == nil { if v, err = this.GetConfigure(game_caravan_thing); err == nil {
if configure, ok := v.(*cfg.GameCaravanThing); ok { if configure, ok := v.(*cfg.GameCaravanThing); ok {
if data = configure.Get(itemId); data == nil { if data = configure.Get(itemId); data == nil {
err = comm.NewNotFoundConfErr("caravan", game_caravan_thing, itemId) err = comm.NewNotFoundConfErr(moduleName, game_caravan_thing, itemId)
this.module.Errorln(err) this.module.Errorln(err)
} }
return return
} }
} }
err = comm.NewNotFoundConfErr("caravan", game_caravan_thing, itemId) err = comm.NewNotFoundConfErr(moduleName, game_caravan_thing, itemId)
return return
} }
@ -144,13 +146,13 @@ func (this *configureComp) GetCaravanEventById(id int32) (data *cfg.GameCaravanE
if v, err = this.GetConfigure(game_caravan_event); err == nil { if v, err = this.GetConfigure(game_caravan_event); err == nil {
if configure, ok := v.(*cfg.GameCaravanEvent); ok { if configure, ok := v.(*cfg.GameCaravanEvent); ok {
if data = configure.Get(id); data == nil { if data = configure.Get(id); data == nil {
err = comm.NewNotFoundConfErr("caravan", game_caravan_event, id) err = comm.NewNotFoundConfErr(moduleName, game_caravan_event, id)
this.module.Errorln(err) this.module.Errorln(err)
} }
return return
} }
} }
err = comm.NewNotFoundConfErr("caravan", game_caravan_event, id) err = comm.NewNotFoundConfErr(moduleName, game_caravan_event, id)
return return
} }
@ -200,11 +202,11 @@ func (this *configureComp) GetCaravanRank(index int32) (reward *cfg.GameCaravanR
if v, err := this.GetConfigure(game_caravan_rank); err == nil { if v, err := this.GetConfigure(game_caravan_rank); err == nil {
if configure, ok := v.(*cfg.GameCaravanRank); ok { if configure, ok := v.(*cfg.GameCaravanRank); ok {
if reward = configure.Get(index); reward == nil { if reward = configure.Get(index); reward == nil {
err = comm.NewNotFoundConfErr("caravan", game_caravan_rank, index) err = comm.NewNotFoundConfErr(moduleName, game_caravan_rank, index)
this.module.Errorln(err) this.module.Errorln(err)
} }
} }
} }
err = comm.NewNotFoundConfErr("caravan", game_caravan_rank, index) err = comm.NewNotFoundConfErr(moduleName, game_caravan_rank, index)
return return
} }

View File

@ -291,7 +291,7 @@ func (this *configureComp) GetHeroFucionConfig(cid string) (data *cfg.GameHerofu
) )
if v, err = this.GetConfigure(hero_fusion); err == nil { if v, err = this.GetConfigure(hero_fusion); err == nil {
if configure, ok := v.(*cfg.GameHerofusion); ok { if configure, ok := v.(*cfg.GameHerofusion); ok {
if data = configure.Get(cid); data != nil { if data = configure.Get(cid); data == nil {
err = comm.NewNotFoundConfErr("hero", hero_fusion, cid) err = comm.NewNotFoundConfErr("hero", hero_fusion, cid)
} }
return return

View File

@ -30,8 +30,8 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.HuntingChallen
code = pb.ErrorCode_PagodaNotFound code = pb.ErrorCode_PagodaNotFound
return return
} }
cfgData := this.module.configure.GetHuntingBossConfigData(req.BossType, req.Difficulty) cfgData, err := this.module.configure.GetHuntingBossConfigData(req.BossType, req.Difficulty)
if cfgData == nil { if err != nil {
code = pb.ErrorCode_ConfigNoFound code = pb.ErrorCode_ConfigNoFound
return return
} }

View File

@ -1,7 +1,6 @@
package hunting package hunting
import ( import (
"fmt"
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/pb" "go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
@ -41,10 +40,13 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.HuntingCha
code = pb.ErrorCode_PagodaNotFound code = pb.ErrorCode_PagodaNotFound
return return
} }
cfgHunting := this.module.configure.GetHuntingBossConfigData(req.BossType, req.Difficulty) cfgHunting, err := this.module.configure.GetHuntingBossConfigData(req.BossType, req.Difficulty)
if cfgHunting == nil { if err != nil {
code = pb.ErrorCode_ConfigNoFound code = pb.ErrorCode_ConfigNoFound
data.Message = fmt.Sprintf("GetHuntingBossConfig No't Found:BossType = %d,Difficulty = %d", req.BossType, req.Difficulty) data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return return
} }

View File

@ -1,6 +1,8 @@
package hunting package hunting
import ( import (
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log" "go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules" "go_dreamfactory/modules"
@ -9,6 +11,8 @@ import (
"sync" "sync"
) )
var moduleName = "hunting"
const ( const (
game_huntingboss = "game_huntingboss.json" game_huntingboss = "game_huntingboss.json"
// game_challenge = "game_huntingchallenge.json" // game_challenge = "game_huntingchallenge.json"
@ -49,9 +53,12 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
} }
// 参数: boss类型 难度 // 参数: boss类型 难度
func (this *configureComp) GetHuntingBossConfigData(bossType int32, difficulty int32) (data *cfg.GameHuntingBossData) { func (this *configureComp) GetHuntingBossConfigData(bossType int32, difficulty int32) (data *cfg.GameHuntingBossData, err error) {
data = this._huntingMap[int64(bossType<<16)+int64(difficulty)]
return this._huntingMap[int64(bossType<<16)+int64(difficulty)] if data == nil {
err = comm.NewNotFoundConfErr(moduleName, game_huntingboss, fmt.Errorf("bossId:%d,difficulty:%d", bossType, difficulty))
}
return
} }
//加载多个配置文件 //加载多个配置文件

View File

@ -59,7 +59,7 @@ func (this *modelHunting) getHuntingList(uid string) (result *pb.DBHunting, err
func (this *modelHunting) checkReddot32(session comm.IUserSession) bool { func (this *modelHunting) checkReddot32(session comm.IUserSession) bool {
if list, err := this.module.modelHunting.getHuntingList(session.GetUserId()); err == nil { if list, err := this.module.modelHunting.getHuntingList(session.GetUserId()); err == nil {
if _, ok := list.Boss[1]; ok { if _, ok := list.Boss[1]; ok {
conf := this.module.configure.GetHuntingBossConfigData(1, 1) conf, _ := this.module.configure.GetHuntingBossConfigData(1, 1)
if code := this.module.CheckRes(session, conf.PsConsume); code == pb.ErrorCode_Success { if code := this.module.CheckRes(session, conf.PsConsume); code == pb.ErrorCode_Success {
return true return true
} }

View File

@ -187,7 +187,7 @@ func (this *Hunting) CompleteAllLevel(session comm.IUserSession) (code pb.ErrorC
// 查配置获取每个Boss的最大难度 // 查配置获取每个Boss的最大难度
for k := range list.Boss { for k := range list.Boss {
for i := 1; ; i++ { for i := 1; ; i++ {
conf := this.configure.GetHuntingBossConfigData(k, int32(i)) conf, _ := this.configure.GetHuntingBossConfigData(k, int32(i))
if conf == nil { if conf == nil {
list.Boss[k] = int32(i - 1) list.Boss[k] = int32(i - 1)
} }

View File

@ -41,7 +41,10 @@ func (this *apiComp) FetterLvUp(session comm.IUserSession, req *pb.LibraryFetter
conf, e := this.module.configure.GetFriendData(fetter.Fid, fetter.Fidlv) conf, e := this.module.configure.GetFriendData(fetter.Fid, fetter.Fidlv)
if e != nil || len(conf) == 0 { if e != nil || len(conf) == 0 {
code = pb.ErrorCode_ConfigNoFound code = pb.ErrorCode_ConfigNoFound
data.Message = e.Error() data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: e.Error(),
}
return return
} }

View File

@ -1,7 +1,7 @@
package privilege package privilege
import ( import (
"fmt" "go_dreamfactory/comm"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log" "go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules" "go_dreamfactory/modules"
@ -10,6 +10,8 @@ import (
"sync" "sync"
) )
var moduleName = "privilege"
const ( const (
game_privilegecard = "game_privilegecard.json" game_privilegecard = "game_privilegecard.json"
game_privilege = "game_privilege.json" game_privilege = "game_privilege.json"
@ -52,21 +54,18 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
return return
} }
func (this *configureComp) GetPrivilegeCard(id string) (configure *cfg.GamePrivilegeCardData, err error) { func (this *configureComp) GetPrivilegeCard(id string) (data *cfg.GamePrivilegeCardData, err error) {
var ( var (
v interface{} v interface{}
ok bool
) )
if v, err = this.GetConfigure(game_privilegecard); err != nil { if v, err = this.GetConfigure(game_privilegecard); err == nil {
this.module.Errorf("err:%v", err) if configure, ok := v.(*cfg.GamePrivilegeCard); !ok {
return if data = configure.Get(id); data != nil {
} else { return
if configure, ok = v.(*cfg.GamePrivilegeCard).GetDataMap()[id]; !ok { }
err = fmt.Errorf("GamePrivilegeCardData not found:%s ", id)
this.module.Errorf("err:%v", err)
return
} }
} }
err = comm.NewNotFoundConfErr(moduleName, game_privilegecard, id)
return return
} }

View File

@ -138,7 +138,10 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq)
for _, v := range shopconf.Shopitem { for _, v := range shopconf.Shopitem {
if _items, err = this.module.configure.GetShopItemsConfigureByGroups(v, udata); err != nil || len(_items) == 0 { if _items, err = this.module.configure.GetShopItemsConfigureByGroups(v, udata); err != nil || len(_items) == 0 {
code = pb.ErrorCode_SystemError code = pb.ErrorCode_SystemError
data.Message = err.Error() data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return return
} }
items = append(items, randomGoods(_items)) items = append(items, randomGoods(_items))

View File

@ -28,9 +28,13 @@ func (this *apiComp) AtlasActivate(session comm.IUserSession, req *pb.SmithyAtla
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return return
} }
conf := this.module.configure.GetSmithyAtlasConf(req.Id) conf, err := this.module.configure.GetSmithyAtlasConf(req.Id)
if conf == nil { if err != nil {
code = pb.ErrorCode_SmithyNoFoundAtlas code = pb.ErrorCode_SmithyNoFoundAtlas
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return return
} }
if conf.TypeId == 1 { if conf.TypeId == 1 {

View File

@ -28,8 +28,8 @@ func (this *apiComp) AtlasAward(session comm.IUserSession, req *pb.SmithyAtlasAw
return return
} }
for { for {
conf := this.module.configure.GetSmithyAtlasLvConf(atlas.Award + 1) conf, err := this.module.configure.GetSmithyAtlasLvConf(atlas.Award + 1)
if conf == nil { if err != nil {
break break
} }
if atlas.Score < conf.AtlasScore { // 校验积分够不够 if atlas.Score < conf.AtlasScore { // 校验积分够不够

View File

@ -46,8 +46,8 @@ func (this *apiComp) ForgeEquip(session comm.IUserSession, req *pb.SmithyForgeEq
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return return
} }
reelcfg := this.module.configure.GetSmithyReelConfigData(req.ReelId) reelcfg, err := this.module.configure.GetSmithyReelConfigData(req.ReelId)
if reelcfg == nil { if err != nil {
code = pb.ErrorCode_ReqParameterError // 没有找到该类型的图纸信息 code = pb.ErrorCode_ReqParameterError // 没有找到该类型的图纸信息
return return
} }
@ -149,10 +149,14 @@ func (this *apiComp) ForgeEquip(session comm.IUserSession, req *pb.SmithyForgeEq
hitLen int32 hitLen int32
) )
for k, v := range req.Hit { for k, v := range req.Hit {
confMake := this.module.configure.GetSmithyMake(k) confMake, err := this.module.configure.GetSmithyMake(k)
if confMake == nil { if err != nil {
code = pb.ErrorCode_ConfigNoFound code = pb.ErrorCode_ConfigNoFound
this.module.Errorf("GetSmithyMake配置没找到:%d", k) this.module.Errorf("GetSmithyMake配置没找到:%d", k)
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return return
} }
hitLen += v hitLen += v
@ -170,8 +174,8 @@ func (this *apiComp) ForgeEquip(session comm.IUserSession, req *pb.SmithyForgeEq
if stove.Hit[k] != v { if stove.Hit[k] != v {
var curProbability int32 var curProbability int32
for k, v := range stove.Hit { for k, v := range stove.Hit {
confMake := this.module.configure.GetSmithyMake(k) confMake, err := this.module.configure.GetSmithyMake(k)
if confMake == nil { if err != nil {
break break
} }
curProbability += v * confMake.Probability curProbability += v * confMake.Probability
@ -226,7 +230,7 @@ func (this *apiComp) ForgeEquip(session comm.IUserSession, req *pb.SmithyForgeEq
} }
if stoveLvConf := this.module.configure.GetSmithyStoveConf(stove.Lv); stoveLvConf != nil { if stoveLvConf, err := this.module.configure.GetSmithyStoveConf(stove.Lv); err == nil {
maxT = stoveLvConf.MaxTemperature maxT = stoveLvConf.MaxTemperature
} }
if stove.RecoveTime == 0 && stove.Temperature <= maxT { if stove.RecoveTime == 0 && stove.Temperature <= maxT {

View File

@ -31,8 +31,12 @@ func (this *apiComp) TaskAward(session comm.IUserSession, req *pb.SmithyTaskAwar
resp := &pb.SmithyTaskAwardResp{ resp := &pb.SmithyTaskAwardResp{
TaskId: req.TaskId, TaskId: req.TaskId,
} }
if conf := this.module.configure.GetSmithyTask(req.TaskId); conf == nil { if conf, err := this.module.configure.GetSmithyTask(req.TaskId); err != nil {
code = pb.ErrorCode_ConfigNoFound code = pb.ErrorCode_ConfigNoFound
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return return
} else { } else {
if code = this.module.DispenseRes(session, conf.Reword, true); code != pb.ErrorCode_Success { if code = this.module.DispenseRes(session, conf.Reword, true); code != pb.ErrorCode_Success {

View File

@ -29,7 +29,7 @@ func (this *apiComp) Rise(session comm.IUserSession, req *pb.SmithyRiseReq) (cod
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return return
} }
if conf := this.module.configure.GetSmithyStoveConf(stove.Lv); conf != nil { if conf, err := this.module.configure.GetSmithyStoveConf(stove.Lv); err == nil {
if stove.Temperature >= conf.MaxTemperature { // 已经达到最大的温度值了 if stove.Temperature >= conf.MaxTemperature { // 已经达到最大的温度值了
code = pb.ErrorCode_SmithyMaxTemperature code = pb.ErrorCode_SmithyMaxTemperature
return return

View File

@ -23,14 +23,22 @@ func (this *apiComp) StoveUp(session comm.IUserSession, req *pb.SmithyStoveUpReq
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return return
} }
conf := this.module.configure.GetSmithyStoveConf(stove.Lv) conf, err := this.module.configure.GetSmithyStoveConf(stove.Lv)
if conf == nil { if err != nil {
code = pb.ErrorCode_ConfigNoFound code = pb.ErrorCode_ConfigNoFound
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return return
} }
nexConf := this.module.configure.GetSmithyStoveConf(stove.Lv + 1) _, err = this.module.configure.GetSmithyStoveConf(stove.Lv + 1)
if nexConf == nil { if err != nil {
code = pb.ErrorCode_SmithyStoveMaxLv code = pb.ErrorCode_SmithyStoveMaxLv
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return return
} }
if code = this.module.ConsumeRes(session, conf.UpMaterial, true); code != pb.ErrorCode_Success { if code = this.module.ConsumeRes(session, conf.UpMaterial, true); code != pb.ErrorCode_Success {

View File

@ -25,9 +25,13 @@ func (this *apiComp) ToolsUp(session comm.IUserSession, req *pb.SmithyToolsUpReq
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return return
} }
conf := this.module.configure.GetSmithyToolsData(req.Id) conf, err := this.module.configure.GetSmithyToolsData(req.Id)
if conf == nil { if err != nil {
code = pb.ErrorCode_ReqParameterError code = pb.ErrorCode_ReqParameterError
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return return
} }
// 校验前置条件 // 校验前置条件
@ -35,9 +39,13 @@ func (this *apiComp) ToolsUp(session comm.IUserSession, req *pb.SmithyToolsUpReq
if stove.Skill[conf.SkillType]+1 == conf.SkillLv { // 必须是一级一级的升级(即当前等级的下一级) if stove.Skill[conf.SkillType]+1 == conf.SkillLv { // 必须是一级一级的升级(即当前等级的下一级)
// 判断前置条件 // 判断前置条件
if conf.Preconditions != 0 { if conf.Preconditions != 0 {
poreConf := this.module.configure.GetSmithyToolsData(conf.Preconditions) poreConf, err := this.module.configure.GetSmithyToolsData(conf.Preconditions)
if poreConf == nil { // 配置没找到 if err != nil { // 配置没找到
code = pb.ErrorCode_ConfigNoFound code = pb.ErrorCode_ConfigNoFound
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return return
} }
if _, ok := stove.Skill[poreConf.SkillType]; !ok { if _, ok := stove.Skill[poreConf.SkillType]; !ok {

View File

@ -36,9 +36,13 @@ func (this *apiComp) Sell(session comm.IUserSession, req *pb.SmithySellReq) (cod
return return
} }
conf := this.module.configure.GetSmithyCustomerConf(req.CustomerId) conf, err := this.module.configure.GetSmithyCustomerConf(req.CustomerId)
if conf == nil { if err != nil {
code = pb.ErrorCode_ConfigNoFound code = pb.ErrorCode_ConfigNoFound
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return return
} }

View File

@ -1,6 +1,7 @@
package smithy package smithy
import ( import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log" "go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules" "go_dreamfactory/modules"
@ -9,6 +10,8 @@ import (
"sync" "sync"
) )
var moduleName = "smithy"
const ( const (
//game_smithy = "game_smithy.json" //game_smithy = "game_smithy.json"
//game_smithystoveold = "game_smithystove.json" //game_smithystoveold = "game_smithystove.json"
@ -80,13 +83,19 @@ func (this *configureComp) GetConfigure(name string) (v interface{}, err error)
} }
// 获取图纸信息 // 获取图纸信息
func (this *configureComp) GetSmithyReelConfigData(id int32) (data *cfg.GameNewSmithyData) { func (this *configureComp) GetSmithyReelConfigData(id int32) (data *cfg.GameNewSmithyData, err error) {
if v, err := this.GetConfigure(game_smithyreel); err == nil { var (
v interface{}
)
if v, err = this.GetConfigure(game_smithyreel); err == nil {
if configure, ok := v.(*cfg.GameNewSmithy); ok { if configure, ok := v.(*cfg.GameNewSmithy); ok {
data = configure.Get(int32(id)) if data = configure.Get(int32(id)); data == nil {
err = comm.NewNotFoundConfErr(moduleName, game_smithyreel, id)
}
return return
} }
} }
err = comm.NewNotFoundConfErr(moduleName, game_smithyreel, id)
return return
} }
@ -172,59 +181,86 @@ func (this *configureComp) GetSmithyCustomerConfList() (data []*cfg.GameSmithyCu
return return
} }
func (this *configureComp) GetSmithyCustomerConf(id int32) *cfg.GameSmithyCustomerData { func (this *configureComp) GetSmithyCustomerConf(id int32) (data *cfg.GameSmithyCustomerData, err error) {
if v, err := this.GetConfigure(game_smithycustomer); err == nil { var (
v interface{}
)
if v, err = this.GetConfigure(game_smithycustomer); err == nil {
if configure, ok := v.(*cfg.GameSmithyCustomer); ok { if configure, ok := v.(*cfg.GameSmithyCustomer); ok {
return configure.GetDataMap()[id] if data = configure.Get(id); data == nil {
err = comm.NewNotFoundConfErr(moduleName, game_smithycustomer, id)
}
return
} }
} }
return nil err = comm.NewNotFoundConfErr(moduleName, game_smithycustomer, id)
return
} }
// 获取铁匠铺工作台信息 // 获取铁匠铺工作台信息
func (this *configureComp) GetSmithyToolsData(id int32) (data *cfg.GameSmithyToolData) { func (this *configureComp) GetSmithyToolsData(id int32) (data *cfg.GameSmithyToolData, err error) {
if v, err := this.GetConfigure(game_smithytools); err == nil { var (
v interface{}
)
if v, err = this.GetConfigure(game_smithytools); err == nil {
if configure, ok := v.(*cfg.GameSmithyTool); ok { if configure, ok := v.(*cfg.GameSmithyTool); ok {
data = configure.Get(int(id)) if data = configure.Get(int(id)); data == nil {
err = comm.NewNotFoundConfErr(moduleName, game_smithytools, id)
}
return return
} }
} }
this.module.Errorf("GetSmithyToolsData notfound id:%d", id) err = comm.NewNotFoundConfErr(moduleName, game_smithytools, id)
return nil return
} }
func (this *configureComp) GetSmithyStoveConf(level int32) (data *cfg.GameSmithyStoveV1Data) { func (this *configureComp) GetSmithyStoveConf(level int32) (data *cfg.GameSmithyStoveV1Data, err error) {
if v, err := this.GetConfigure(game_smithystove); err == nil { var (
v interface{}
)
if v, err = this.GetConfigure(game_smithystove); err == nil {
if configure, ok := v.(*cfg.GameSmithyStoveV1); ok { if configure, ok := v.(*cfg.GameSmithyStoveV1); ok {
data = configure.Get(int32(level)) if data = configure.Get(int32(level)); data == nil {
err = comm.NewNotFoundConfErr(moduleName, game_smithystove, level)
}
return return
} }
} }
this.module.Errorf("GetSmithyStoveConf notfound level:%d", level) err = comm.NewNotFoundConfErr(moduleName, game_smithystove, level)
return return
} }
// 获取图鉴信息 // 获取图鉴信息
func (this *configureComp) GetSmithyAtlasConf(id string) (data *cfg.GameSmithyAtlasData) { func (this *configureComp) GetSmithyAtlasConf(id string) (data *cfg.GameSmithyAtlasData, err error) {
if v, err := this.GetConfigure(game_smithyatlas); err == nil { var (
v interface{}
)
if v, err = this.GetConfigure(game_smithyatlas); err == nil {
if configure, ok := v.(*cfg.GameSmithyAtlas); ok { if configure, ok := v.(*cfg.GameSmithyAtlas); ok {
data = configure.Get(id) if data = configure.Get(id); data == nil {
err = comm.NewNotFoundConfErr(moduleName, game_smithyatlas, id)
}
return return
} }
} }
this.module.Errorf("GetSmithyAtlasConf notfound id:%d", id) err = comm.NewNotFoundConfErr(moduleName, game_smithyatlas, id)
return return
} }
func (this *configureComp) GetSmithyAtlasLvConf(lv int32) (data *cfg.GameSmithyAtlasLvData) { func (this *configureComp) GetSmithyAtlasLvConf(lv int32) (data *cfg.GameSmithyAtlasLvData, err error) {
if v, err := this.GetConfigure(game_smithyatlaslv); err == nil { var (
v interface{}
)
if v, err = this.GetConfigure(game_smithyatlaslv); err == nil {
if configure, ok := v.(*cfg.GameSmithyAtlasLv); ok { if configure, ok := v.(*cfg.GameSmithyAtlasLv); ok {
data = configure.Get(lv) if data = configure.Get(lv); data == nil {
err = comm.NewNotFoundConfErr(moduleName, game_smithyatlaslv, lv)
}
return return
} }
} }
this.module.Errorf("GetSmithyAtlasLvConf notfound lv:%d", lv) err = comm.NewNotFoundConfErr(moduleName, game_smithyatlaslv, lv)
return return
} }
@ -250,24 +286,34 @@ func (this *configureComp) LoadSmithyAtlasScoreConf() {
} }
// 获取图鉴任务配置 // 获取图鉴任务配置
func (this *configureComp) GetSmithyTask(taskId int32) (data *cfg.GameSmithyTaskData) { func (this *configureComp) GetSmithyTask(taskId int32) (data *cfg.GameSmithyTaskData, err error) {
if v, err := this.GetConfigure(game_smithytask); err == nil { var (
v interface{}
)
if v, err = this.GetConfigure(game_smithytask); err == nil {
if configure, ok := v.(*cfg.GameSmithyTask); ok { if configure, ok := v.(*cfg.GameSmithyTask); ok {
data = configure.Get(taskId) if data = configure.Get(taskId); data == nil {
err = comm.NewNotFoundConfErr(moduleName, game_smithytask, taskId)
}
return return
} }
} }
this.module.Errorf("GetSmithyTask notfound taskId:%d", taskId) err = comm.NewNotFoundConfErr(moduleName, game_smithytask, taskId)
return return
} }
func (this *configureComp) GetSmithyMake(cid int32) (data *cfg.GameSmithyMakeData) { func (this *configureComp) GetSmithyMake(cid int32) (data *cfg.GameSmithyMakeData, err error) {
if v, err := this.GetConfigure(game_smithymake); err == nil { var (
v interface{}
)
if v, err = this.GetConfigure(game_smithymake); err == nil {
if configure, ok := v.(*cfg.GameSmithyMake); ok { if configure, ok := v.(*cfg.GameSmithyMake); ok {
data = configure.Get(cid) if data = configure.Get(cid); data == nil {
err = comm.NewNotFoundConfErr(moduleName, game_smithymake, cid)
}
return return
} }
} }
this.module.Errorf("GetSmithyMake notfound taskId:%d", cid) err = comm.NewNotFoundConfErr(moduleName, game_smithymake, cid)
return return
} }

View File

@ -64,7 +64,7 @@ func (this *modelAtlas) CheckActivateAtlas(uid string, id string, lv int32, qual
list *pb.DBAtlas list *pb.DBAtlas
err error err error
) )
if atlasConf = this.module.configure.GetSmithyAtlasConf(id); atlasConf == nil { if atlasConf, err = this.module.configure.GetSmithyAtlasConf(id); err != nil {
return false return false
} }
if list, err = this.module.modelAtlas.getSmithyAtlasList(uid); err != nil { if list, err = this.module.modelAtlas.getSmithyAtlasList(uid); err != nil {

View File

@ -48,7 +48,7 @@ func (this *modelStove) getSmithyStoveList(uid string) (result *pb.DBStove, err
result.Lv = 1 result.Lv = 1
result.RecoveTime = 0 result.RecoveTime = 0
if conf := this.module.configure.GetSmithyStoveConf(result.Lv); conf != nil { // 获取1级炉子温度配置 if conf, _ := this.module.configure.GetSmithyStoveConf(result.Lv); conf != nil { // 获取1级炉子温度配置
result.Temperature = conf.MaxTemperature result.Temperature = conf.MaxTemperature
} }
if err = this.Add(uid, result); err != nil { if err = this.Add(uid, result); err != nil {
@ -135,7 +135,7 @@ func (this *modelStove) CheckForgeConsume(reelId int32, lv int32) (atn []*cfg.Ga
// 计算恢复进度 // 计算恢复进度
func (this *modelStove) calculationRecoveryT(uid string, stove *pb.DBStove) { func (this *modelStove) calculationRecoveryT(uid string, stove *pb.DBStove) {
if conf := this.module.configure.GetSmithyStoveConf(stove.Lv); conf != nil { if conf, _ := this.module.configure.GetSmithyStoveConf(stove.Lv); conf != nil {
if stove.Temperature < conf.MaxTemperature { if stove.Temperature < conf.MaxTemperature {
// 小于最高温度就开始恢复 // 小于最高温度就开始恢复
if addT := (configure.Now().Unix() - stove.RecoveTime) / int64(conf.TemperatureRecovery); addT > 0 { if addT := (configure.Now().Unix() - stove.RecoveTime) / int64(conf.TemperatureRecovery); addT > 0 {

View File

@ -76,7 +76,7 @@ func (this *modelTask) updateTaskRecord(uid string, taskId int32) error {
// 检查任务状态 // 检查任务状态
func (this *modelTask) checkTaskStatus(uid string, taskId int32) bool { func (this *modelTask) checkTaskStatus(uid string, taskId int32) bool {
conf := this.module.configure.GetSmithyTask(taskId) conf, _ := this.module.configure.GetSmithyTask(taskId)
if conf == nil { if conf == nil {
return false return false
} }

View File

@ -51,8 +51,8 @@ func (this *Smithy) OnInstallComp() {
} }
func (this *Smithy) CheckActivateAtlasCollect(uid string, id string) { func (this *Smithy) CheckActivateAtlasCollect(uid string, id string) {
atlasConf := this.configure.GetSmithyAtlasConf(id) atlasConf, err := this.configure.GetSmithyAtlasConf(id)
if atlasConf == nil || atlasConf.TypeId != 2 { if err != nil || atlasConf.TypeId != 2 {
return return
} }

View File

@ -24,22 +24,20 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.VikingChalleng
if code != pb.ErrorCode_Success { if code != pb.ErrorCode_Success {
return // 参数校验失败直接返回 return // 参数校验失败直接返回
} }
viking, err := this.module.modelViking.getVikingList(session.GetUserId()) viking, _ := this.module.modelViking.getVikingList(session.GetUserId())
if err != nil {
code = pb.ErrorCode_VikingBoosType
return
}
cfgData := this.module.configure.GetVikingBossConfigData(req.BossId, req.Difficulty) cfgData, err := this.module.configure.GetVikingBossConfigData(req.BossId, req.Difficulty)
if cfgData == nil { if err != nil {
code = pb.ErrorCode_ConfigNoFound code = pb.ErrorCode_ConfigNoFound
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return return
} }
if v1, ok := viking.Ps[req.BossId]; ok && v1 == 0 { if v1, ok := viking.Ps[req.BossId]; ok && v1 == 0 {
if code = this.module.ConsumeRes(session, cfgData.PsMg, true); code != pb.ErrorCode_Success { // 扣1点 if code = this.module.ConsumeRes(session, cfgData.PsMg, true); code != pb.ErrorCode_Success { // 扣1点
return return
} }
} else { } else {

View File

@ -42,9 +42,14 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
return return
} }
vikingCfg := this.module.configure.GetVikingBossConfigData(req.BossId, req.Difficulty) vikingCfg, err := this.module.configure.GetVikingBossConfigData(req.BossId, req.Difficulty)
if vikingCfg == nil { if err != nil {
code = pb.ErrorCode_ConfigNoFound code = pb.ErrorCode_ConfigNoFound
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return return
} }

View File

@ -1,6 +1,8 @@
package viking package viking
import ( import (
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log" "go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules" "go_dreamfactory/modules"
@ -9,6 +11,8 @@ import (
"sync" "sync"
) )
var moduleName = "viking"
const ( const (
game_vikingboss = "game_vikingboss.json" game_vikingboss = "game_vikingboss.json"
// game_challenge = "game_vikingchallenge.json" // game_challenge = "game_vikingchallenge.json"
@ -51,9 +55,11 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
} }
// 参数: boss类型 难度 // 参数: boss类型 难度
func (this *configureComp) GetVikingBossConfigData(bossId int32, difficulty int32) (data *cfg.GameVikingBossData) { func (this *configureComp) GetVikingBossConfigData(bossId int32, difficulty int32) (data *cfg.GameVikingBossData, err error) {
if data = this._vikingMap[int64(bossId<<16)+int64(difficulty)]; data == nil {
return this._vikingMap[int64(bossId<<16)+int64(difficulty)] err = comm.NewNotFoundConfErr(moduleName, game_vikingboss, fmt.Errorf("bossId:%d,difficulty:%d", bossId, difficulty))
}
return
} }
//加载多个配置文件 //加载多个配置文件

View File

@ -57,9 +57,10 @@ func (this *modelViking) checkReddot31(session comm.IUserSession) bool {
if list, err := this.module.modelViking.getVikingList(session.GetUserId()); err == nil { if list, err := this.module.modelViking.getVikingList(session.GetUserId()); err == nil {
if _, ok := list.Boss[1]; ok { if _, ok := list.Boss[1]; ok {
conf := this.module.configure.GetVikingBossConfigData(1, 1) if conf, _ := this.module.configure.GetVikingBossConfigData(1, 1); conf != nil {
if code := this.module.CheckRes(session, conf.PsConsume); code == pb.ErrorCode_Success { if code := this.module.CheckRes(session, conf.PsConsume); code == pb.ErrorCode_Success {
return true return true
}
} }
} }
} }

View File

@ -193,7 +193,7 @@ func (this *Viking) CompleteAllLevel(session comm.IUserSession) (code pb.ErrorCo
// 查配置获取每个Boss的最大难度 // 查配置获取每个Boss的最大难度
for k := range list.Boss { for k := range list.Boss {
for i := 1; ; i++ { for i := 1; ; i++ {
conf := this.configure.GetVikingBossConfigData(k, int32(i)) conf, _ := this.configure.GetVikingBossConfigData(k, int32(i))
if conf == nil { if conf == nil {
list.Boss[k] = int32(i - 1) list.Boss[k] = int32(i - 1)
} }
@ -207,7 +207,7 @@ func (this *Viking) CompleteAllLevel(session comm.IUserSession) (code pb.ErrorCo
} }
func (this *Viking) AutoBuyTicket(session comm.IUserSession, bossId, difficulty int32) (code pb.ErrorCode) { func (this *Viking) AutoBuyTicket(session comm.IUserSession, bossId, difficulty int32) (code pb.ErrorCode) {
conf := this.configure.GetVikingBossConfigData(bossId, difficulty) conf, _ := this.configure.GetVikingBossConfigData(bossId, difficulty)
if code := this.CheckRes(session, conf.PsConsume); code != pb.ErrorCode_Success { if code := this.CheckRes(session, conf.PsConsume); code != pb.ErrorCode_Success {
amount := int32(this.ModuleItems.QueryItemAmount(session.GetUserId(), conf.PsConsume[0].T)) // 获取当前数量 amount := int32(this.ModuleItems.QueryItemAmount(session.GetUserId(), conf.PsConsume[0].T)) // 获取当前数量
if amount < conf.PsConsume[0].N { // 数量不足直接购买 if amount < conf.PsConsume[0].N { // 数量不足直接购买
@ -222,7 +222,7 @@ func (this *Viking) AutoBuyTicket(session comm.IUserSession, bossId, difficulty
func (this *Viking) AutoBattleInfo(session comm.IUserSession, battle *pb.BattleFormation, bossId, difficulty int32) (code pb.ErrorCode, battleInfo *pb.BattleInfo) { func (this *Viking) AutoBattleInfo(session comm.IUserSession, battle *pb.BattleFormation, bossId, difficulty int32) (code pb.ErrorCode, battleInfo *pb.BattleInfo) {
cfgData := this.configure.GetVikingBossConfigData(bossId, difficulty) cfgData, _ := this.configure.GetVikingBossConfigData(bossId, difficulty)
if cfgData == nil { if cfgData == nil {
code = pb.ErrorCode_ConfigNoFound code = pb.ErrorCode_ConfigNoFound
return return
@ -254,7 +254,7 @@ func (this *Viking) AutoBattleOver(session comm.IUserSession, Report *pb.BattleR
bossId := autoBattle.BossId bossId := autoBattle.BossId
difficulty := autoBattle.Difficulty difficulty := autoBattle.Difficulty
atno = make([]*pb.UserAtno, 0) atno = make([]*pb.UserAtno, 0)
conf := this.configure.GetVikingBossConfigData(bossId, difficulty) conf, _ := this.configure.GetVikingBossConfigData(bossId, difficulty)
tasks := make([]*pb.BuriedParam, 0) tasks := make([]*pb.BuriedParam, 0)
// costRes := this.ModuleTools.GetGlobalConf().VikingExpeditionCos // costRes := this.ModuleTools.GetGlobalConf().VikingExpeditionCos
// if costRes == nil { // if costRes == nil {
@ -281,7 +281,7 @@ func (this *Viking) AutoBattleOver(session comm.IUserSession, Report *pb.BattleR
} }
} }
mapData := make(map[string]interface{}, 0) mapData := make(map[string]interface{}, 0)
vikingCfg := this.configure.GetVikingBossConfigData(bossId, difficulty) vikingCfg, _ := this.configure.GetVikingBossConfigData(bossId, difficulty)
if vikingCfg == nil { if vikingCfg == nil {
code = pb.ErrorCode_ConfigNoFound code = pb.ErrorCode_ConfigNoFound
return return