代码整理

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 {
code = pb.ErrorCode_DataNotFound
data.Message = e.Error()
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
}
}
addScore += price * v // 卖出收益

View File

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

View File

@ -9,6 +9,8 @@ import (
cfg "go_dreamfactory/sys/configure/structs"
)
var moduleName = "caravan"
const (
game_caravan = "game_caravancity.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 configure, ok := v.(*cfg.GameCaravanCity); ok {
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)
}
return
}
}
err = comm.NewNotFoundConfErr("caravan", game_caravan, cityId)
err = comm.NewNotFoundConfErr(moduleName, game_caravan, cityId)
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 configure, ok := v.(*cfg.GameCaravanLv); ok {
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)
}
return
}
}
err = comm.NewNotFoundConfErr("caravan", game_caravan_lv, lv)
err = comm.NewNotFoundConfErr(moduleName, game_caravan_lv, lv)
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 configure, ok := v.(*cfg.GameCaravanThing); ok {
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)
}
return
}
}
err = comm.NewNotFoundConfErr("caravan", game_caravan_thing, itemId)
err = comm.NewNotFoundConfErr(moduleName, game_caravan_thing, itemId)
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 configure, ok := v.(*cfg.GameCaravanEvent); ok {
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)
}
return
}
}
err = comm.NewNotFoundConfErr("caravan", game_caravan_event, id)
err = comm.NewNotFoundConfErr(moduleName, game_caravan_event, id)
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 configure, ok := v.(*cfg.GameCaravanRank); ok {
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)
}
}
}
err = comm.NewNotFoundConfErr("caravan", game_caravan_rank, index)
err = comm.NewNotFoundConfErr(moduleName, game_caravan_rank, index)
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 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)
}
return

View File

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

View File

@ -1,7 +1,6 @@
package hunting
import (
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
@ -41,10 +40,13 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.HuntingCha
code = pb.ErrorCode_PagodaNotFound
return
}
cfgHunting := this.module.configure.GetHuntingBossConfigData(req.BossType, req.Difficulty)
if cfgHunting == nil {
cfgHunting, err := this.module.configure.GetHuntingBossConfigData(req.BossType, req.Difficulty)
if err != nil {
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
}

View File

@ -1,6 +1,8 @@
package hunting
import (
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules"
@ -9,6 +11,8 @@ import (
"sync"
)
var moduleName = "hunting"
const (
game_huntingboss = "game_huntingboss.json"
// game_challenge = "game_huntingchallenge.json"
@ -49,9 +53,12 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
}
// 参数: boss类型 难度
func (this *configureComp) GetHuntingBossConfigData(bossType int32, difficulty int32) (data *cfg.GameHuntingBossData) {
return this._huntingMap[int64(bossType<<16)+int64(difficulty)]
func (this *configureComp) GetHuntingBossConfigData(bossType int32, difficulty int32) (data *cfg.GameHuntingBossData, err error) {
data = 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 {
if list, err := this.module.modelHunting.getHuntingList(session.GetUserId()); err == nil {
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 {
return true
}

View File

@ -187,7 +187,7 @@ func (this *Hunting) CompleteAllLevel(session comm.IUserSession) (code pb.ErrorC
// 查配置获取每个Boss的最大难度
for k := range list.Boss {
for i := 1; ; i++ {
conf := this.configure.GetHuntingBossConfigData(k, int32(i))
conf, _ := this.configure.GetHuntingBossConfigData(k, int32(i))
if conf == nil {
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)
if e != nil || len(conf) == 0 {
code = pb.ErrorCode_ConfigNoFound
data.Message = e.Error()
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: e.Error(),
}
return
}

View File

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

View File

@ -138,7 +138,10 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq)
for _, v := range shopconf.Shopitem {
if _items, err = this.module.configure.GetShopItemsConfigureByGroups(v, udata); err != nil || len(_items) == 0 {
code = pb.ErrorCode_SystemError
data.Message = err.Error()
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return
}
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
return
}
conf := this.module.configure.GetSmithyAtlasConf(req.Id)
if conf == nil {
conf, err := this.module.configure.GetSmithyAtlasConf(req.Id)
if err != nil {
code = pb.ErrorCode_SmithyNoFoundAtlas
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return
}
if conf.TypeId == 1 {

View File

@ -28,8 +28,8 @@ func (this *apiComp) AtlasAward(session comm.IUserSession, req *pb.SmithyAtlasAw
return
}
for {
conf := this.module.configure.GetSmithyAtlasLvConf(atlas.Award + 1)
if conf == nil {
conf, err := this.module.configure.GetSmithyAtlasLvConf(atlas.Award + 1)
if err != nil {
break
}
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
return
}
reelcfg := this.module.configure.GetSmithyReelConfigData(req.ReelId)
if reelcfg == nil {
reelcfg, err := this.module.configure.GetSmithyReelConfigData(req.ReelId)
if err != nil {
code = pb.ErrorCode_ReqParameterError // 没有找到该类型的图纸信息
return
}
@ -149,10 +149,14 @@ func (this *apiComp) ForgeEquip(session comm.IUserSession, req *pb.SmithyForgeEq
hitLen int32
)
for k, v := range req.Hit {
confMake := this.module.configure.GetSmithyMake(k)
if confMake == nil {
confMake, err := this.module.configure.GetSmithyMake(k)
if err != nil {
code = pb.ErrorCode_ConfigNoFound
this.module.Errorf("GetSmithyMake配置没找到:%d", k)
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return
}
hitLen += v
@ -170,8 +174,8 @@ func (this *apiComp) ForgeEquip(session comm.IUserSession, req *pb.SmithyForgeEq
if stove.Hit[k] != v {
var curProbability int32
for k, v := range stove.Hit {
confMake := this.module.configure.GetSmithyMake(k)
if confMake == nil {
confMake, err := this.module.configure.GetSmithyMake(k)
if err != nil {
break
}
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
}
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{
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
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return
} else {
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
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 { // 已经达到最大的温度值了
code = pb.ErrorCode_SmithyMaxTemperature
return

View File

@ -23,14 +23,22 @@ func (this *apiComp) StoveUp(session comm.IUserSession, req *pb.SmithyStoveUpReq
code = pb.ErrorCode_DBError
return
}
conf := this.module.configure.GetSmithyStoveConf(stove.Lv)
if conf == nil {
conf, err := this.module.configure.GetSmithyStoveConf(stove.Lv)
if err != nil {
code = pb.ErrorCode_ConfigNoFound
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return
}
nexConf := this.module.configure.GetSmithyStoveConf(stove.Lv + 1)
if nexConf == nil {
_, err = this.module.configure.GetSmithyStoveConf(stove.Lv + 1)
if err != nil {
code = pb.ErrorCode_SmithyStoveMaxLv
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return
}
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
return
}
conf := this.module.configure.GetSmithyToolsData(req.Id)
if conf == nil {
conf, err := this.module.configure.GetSmithyToolsData(req.Id)
if err != nil {
code = pb.ErrorCode_ReqParameterError
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return
}
// 校验前置条件
@ -35,9 +39,13 @@ func (this *apiComp) ToolsUp(session comm.IUserSession, req *pb.SmithyToolsUpReq
if stove.Skill[conf.SkillType]+1 == conf.SkillLv { // 必须是一级一级的升级(即当前等级的下一级)
// 判断前置条件
if conf.Preconditions != 0 {
poreConf := this.module.configure.GetSmithyToolsData(conf.Preconditions)
if poreConf == nil { // 配置没找到
poreConf, err := this.module.configure.GetSmithyToolsData(conf.Preconditions)
if err != nil { // 配置没找到
code = pb.ErrorCode_ConfigNoFound
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return
}
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
}
conf := this.module.configure.GetSmithyCustomerConf(req.CustomerId)
if conf == nil {
conf, err := this.module.configure.GetSmithyCustomerConf(req.CustomerId)
if err != nil {
code = pb.ErrorCode_ConfigNoFound
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return
}

View File

@ -1,6 +1,7 @@
package smithy
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules"
@ -9,6 +10,8 @@ import (
"sync"
)
var moduleName = "smithy"
const (
//game_smithy = "game_smithy.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) {
if v, err := this.GetConfigure(game_smithyreel); err == nil {
func (this *configureComp) GetSmithyReelConfigData(id int32) (data *cfg.GameNewSmithyData, err error) {
var (
v interface{}
)
if v, err = this.GetConfigure(game_smithyreel); err == nil {
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
}
}
err = comm.NewNotFoundConfErr(moduleName, game_smithyreel, id)
return
}
@ -172,59 +181,86 @@ func (this *configureComp) GetSmithyCustomerConfList() (data []*cfg.GameSmithyCu
return
}
func (this *configureComp) GetSmithyCustomerConf(id int32) *cfg.GameSmithyCustomerData {
if v, err := this.GetConfigure(game_smithycustomer); err == nil {
func (this *configureComp) GetSmithyCustomerConf(id int32) (data *cfg.GameSmithyCustomerData, err error) {
var (
v interface{}
)
if v, err = this.GetConfigure(game_smithycustomer); err == nil {
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) {
if v, err := this.GetConfigure(game_smithytools); err == nil {
func (this *configureComp) GetSmithyToolsData(id int32) (data *cfg.GameSmithyToolData, err error) {
var (
v interface{}
)
if v, err = this.GetConfigure(game_smithytools); err == nil {
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
}
}
this.module.Errorf("GetSmithyToolsData notfound id:%d", id)
return nil
err = comm.NewNotFoundConfErr(moduleName, game_smithytools, id)
return
}
func (this *configureComp) GetSmithyStoveConf(level int32) (data *cfg.GameSmithyStoveV1Data) {
if v, err := this.GetConfigure(game_smithystove); err == nil {
func (this *configureComp) GetSmithyStoveConf(level int32) (data *cfg.GameSmithyStoveV1Data, err error) {
var (
v interface{}
)
if v, err = this.GetConfigure(game_smithystove); err == nil {
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
}
}
this.module.Errorf("GetSmithyStoveConf notfound level:%d", level)
err = comm.NewNotFoundConfErr(moduleName, game_smithystove, level)
return
}
// 获取图鉴信息
func (this *configureComp) GetSmithyAtlasConf(id string) (data *cfg.GameSmithyAtlasData) {
if v, err := this.GetConfigure(game_smithyatlas); err == nil {
func (this *configureComp) GetSmithyAtlasConf(id string) (data *cfg.GameSmithyAtlasData, err error) {
var (
v interface{}
)
if v, err = this.GetConfigure(game_smithyatlas); err == nil {
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
}
}
this.module.Errorf("GetSmithyAtlasConf notfound id:%d", id)
err = comm.NewNotFoundConfErr(moduleName, game_smithyatlas, id)
return
}
func (this *configureComp) GetSmithyAtlasLvConf(lv int32) (data *cfg.GameSmithyAtlasLvData) {
if v, err := this.GetConfigure(game_smithyatlaslv); err == nil {
func (this *configureComp) GetSmithyAtlasLvConf(lv int32) (data *cfg.GameSmithyAtlasLvData, err error) {
var (
v interface{}
)
if v, err = this.GetConfigure(game_smithyatlaslv); err == nil {
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
}
}
this.module.Errorf("GetSmithyAtlasLvConf notfound lv:%d", lv)
err = comm.NewNotFoundConfErr(moduleName, game_smithyatlaslv, lv)
return
}
@ -250,24 +286,34 @@ func (this *configureComp) LoadSmithyAtlasScoreConf() {
}
// 获取图鉴任务配置
func (this *configureComp) GetSmithyTask(taskId int32) (data *cfg.GameSmithyTaskData) {
if v, err := this.GetConfigure(game_smithytask); err == nil {
func (this *configureComp) GetSmithyTask(taskId int32) (data *cfg.GameSmithyTaskData, err error) {
var (
v interface{}
)
if v, err = this.GetConfigure(game_smithytask); err == nil {
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
}
}
this.module.Errorf("GetSmithyTask notfound taskId:%d", taskId)
err = comm.NewNotFoundConfErr(moduleName, game_smithytask, taskId)
return
}
func (this *configureComp) GetSmithyMake(cid int32) (data *cfg.GameSmithyMakeData) {
if v, err := this.GetConfigure(game_smithymake); err == nil {
func (this *configureComp) GetSmithyMake(cid int32) (data *cfg.GameSmithyMakeData, err error) {
var (
v interface{}
)
if v, err = this.GetConfigure(game_smithymake); err == nil {
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
}
}
this.module.Errorf("GetSmithyMake notfound taskId:%d", cid)
err = comm.NewNotFoundConfErr(moduleName, game_smithymake, cid)
return
}

View File

@ -64,7 +64,7 @@ func (this *modelAtlas) CheckActivateAtlas(uid string, id string, lv int32, qual
list *pb.DBAtlas
err error
)
if atlasConf = this.module.configure.GetSmithyAtlasConf(id); atlasConf == nil {
if atlasConf, err = this.module.configure.GetSmithyAtlasConf(id); err != nil {
return false
}
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.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
}
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) {
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 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 {
conf := this.module.configure.GetSmithyTask(taskId)
conf, _ := this.module.configure.GetSmithyTask(taskId)
if conf == nil {
return false
}

View File

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

View File

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

View File

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

View File

@ -1,6 +1,8 @@
package viking
import (
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules"
@ -9,6 +11,8 @@ import (
"sync"
)
var moduleName = "viking"
const (
game_vikingboss = "game_vikingboss.json"
// game_challenge = "game_vikingchallenge.json"
@ -51,9 +55,11 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
}
// 参数: boss类型 难度
func (this *configureComp) GetVikingBossConfigData(bossId int32, difficulty int32) (data *cfg.GameVikingBossData) {
return this._vikingMap[int64(bossId<<16)+int64(difficulty)]
func (this *configureComp) GetVikingBossConfigData(bossId int32, difficulty int32) (data *cfg.GameVikingBossData, err error) {
if data = this._vikingMap[int64(bossId<<16)+int64(difficulty)]; data == nil {
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 _, ok := list.Boss[1]; ok {
conf := this.module.configure.GetVikingBossConfigData(1, 1)
if code := this.module.CheckRes(session, conf.PsConsume); code == pb.ErrorCode_Success {
return true
if conf, _ := this.module.configure.GetVikingBossConfigData(1, 1); conf != nil {
if code := this.module.CheckRes(session, conf.PsConsume); code == pb.ErrorCode_Success {
return true
}
}
}
}

View File

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