上传代码规范化调整
This commit is contained in:
parent
8483f6b17d
commit
0310fe0676
@ -19,8 +19,26 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.AcademyChallen
|
||||
record *pb.DBBattleRecord
|
||||
err error
|
||||
)
|
||||
defer func() {
|
||||
if errdata == nil {
|
||||
if errdata = this.ChallengeCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
if level, err = this.module.configure.getGameTeaching(req.Level); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if errdata, record = this.module.battle.CreateEveBattle(session, &pb.BattleEVEReq{
|
||||
Ptype: pb.PlayType_academy,
|
||||
Format: nil,
|
||||
Sysformat: level.UsFormatList,
|
||||
Backupformat: nil,
|
||||
Buleformat: level.FormatList,
|
||||
}); errdata != nil {
|
||||
return
|
||||
}
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), "challenge", &pb.AcademyChallengeResp{Code: pb.ErrorCode_Success, Level: req.Level, Info: &pb.BattleInfo{
|
||||
Id: record.Id,
|
||||
Title: record.Title,
|
||||
@ -33,27 +51,5 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.AcademyChallen
|
||||
Buleflist: record.Buleflist,
|
||||
Tasks: level.Task,
|
||||
}})
|
||||
} else {
|
||||
session.SendMsg(string(this.module.GetType()), "challenge", &pb.AcademyChallengeResp{Code: errdata.Code, Info: nil})
|
||||
}
|
||||
}()
|
||||
if errdata = this.ChallengeCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if level, err = this.module.configure.getGameTeaching(req.Level); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
cd, record = this.module.battle.CreateEveBattle(session, &pb.BattleEVEReq{
|
||||
Ptype: pb.PlayType_academy,
|
||||
Format: nil,
|
||||
Sysformat: level.UsFormatList,
|
||||
Backupformat: nil,
|
||||
Buleformat: level.FormatList,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
@ -26,10 +26,7 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.AcademyInfoReq) (er
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), "info", &pb.AcademyInfoResp{Info: info})
|
||||
|
@ -24,7 +24,7 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.AcademyReceiveRe
|
||||
if errdata = this.ReceiveCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
if code, iswin = this.module.battle.CheckBattleReport(session, req.Report); errdata != nil {
|
||||
if errdata, iswin = this.module.battle.CheckBattleReport(session, req.Report); errdata != nil {
|
||||
return
|
||||
}
|
||||
if iswin {
|
||||
@ -34,10 +34,6 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.AcademyReceiveRe
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if level, err = this.module.configure.getGameTeaching(req.Level); err != nil {
|
||||
@ -46,14 +42,14 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.AcademyReceiveRe
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
if req.Report.Completetask == nil || len(req.Report.Completetask) != len(level.Task) {
|
||||
code = pb.ErrorCode_AcademyTaskNoCompleteTask
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_AcademyTaskNoCompleteTask,
|
||||
Title: pb.ErrorCode_AcademyTaskNoCompleteTask.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -66,10 +62,6 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.AcademyReceiveRe
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -18,11 +18,31 @@ func (this *apiComp) Teaching(session comm.IUserSession, req *pb.AcademyTeaching
|
||||
level *cfg.GameHeroStrategyData
|
||||
record *pb.DBBattleRecord
|
||||
err error
|
||||
cd pb.ErrorCode
|
||||
)
|
||||
defer func() {
|
||||
if cd == pb.ErrorCode_Success {
|
||||
session.SendMsg(string(this.module.GetType()), "teaching", &pb.AcademyTeachingResp{Code: cd, HeroId: req.HeroId, Info: &pb.BattleInfo{
|
||||
if errdata = this.TeachingCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if level, err = this.module.configure.getGameHeroTeaching(req.HeroId); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if errdata, record = this.module.battle.CreateEveBattle(session, &pb.BattleEVEReq{
|
||||
Ptype: pb.PlayType_heroteaching,
|
||||
Format: nil,
|
||||
Sysformat: level.UsFormatList,
|
||||
Backupformat: nil,
|
||||
Buleformat: level.FormatList,
|
||||
}); errdata != nil {
|
||||
return
|
||||
}
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), "teaching", &pb.AcademyTeachingResp{
|
||||
HeroId: req.HeroId, Info: &pb.BattleInfo{
|
||||
Id: record.Id,
|
||||
Title: record.Title,
|
||||
Rulesid: level.Battleready,
|
||||
@ -34,28 +54,5 @@ func (this *apiComp) Teaching(session comm.IUserSession, req *pb.AcademyTeaching
|
||||
Buleflist: record.Buleflist,
|
||||
Tasks: level.Task,
|
||||
}})
|
||||
} else {
|
||||
session.SendMsg(string(this.module.GetType()), "teaching", &pb.AcademyTeachingResp{Code: cd, Info: nil})
|
||||
}
|
||||
}()
|
||||
if cd = this.TeachingCheck(session, req); cd != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
|
||||
if level, err = this.module.configure.getGameHeroTeaching(req.HeroId); err != nil {
|
||||
cd = pb.ErrorCode_ConfigNoFound
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
cd, record = this.module.battle.CreateEveBattle(session, &pb.BattleEVEReq{
|
||||
Ptype: pb.PlayType_heroteaching,
|
||||
Format: nil,
|
||||
Sysformat: level.UsFormatList,
|
||||
Backupformat: nil,
|
||||
Buleformat: level.FormatList,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ func (this *apiComp) TeachingReceive(session comm.IUserSession, req *pb.AcademyT
|
||||
if errdata = this.TeachingReceiveCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
if code, iswin = this.module.battle.CheckBattleReport(session, req.Report); errdata != nil {
|
||||
if errdata, iswin = this.module.battle.CheckBattleReport(session, req.Report); errdata != nil {
|
||||
return
|
||||
}
|
||||
if iswin {
|
||||
@ -34,10 +34,6 @@ func (this *apiComp) TeachingReceive(session comm.IUserSession, req *pb.AcademyT
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if level, err = this.module.configure.getGameHeroTeaching(req.HeroId); err != nil {
|
||||
@ -46,16 +42,13 @@ func (this *apiComp) TeachingReceive(session comm.IUserSession, req *pb.AcademyT
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
if req.Report.Completetask == nil || len(req.Report.Completetask) != len(level.Task) {
|
||||
code = pb.ErrorCode_AcademyTaskNoCompleteTask
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_AcademyTaskNoCompleteTask,
|
||||
Title: pb.ErrorCode_AcademyTaskNoCompleteTask.ToString(),
|
||||
Message: fmt.Sprintf("目标任务:%v 完成任务:%v", level.Task, req.Report.Completetask),
|
||||
}
|
||||
return
|
||||
@ -69,10 +62,6 @@ func (this *apiComp) TeachingReceive(session comm.IUserSession, req *pb.AcademyT
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
this.module.DispenseRes(session, level.Award, true)
|
||||
|
@ -23,64 +23,57 @@ func (this *apiComp) Plot(session comm.IUserSession, req *pb.ArenaPlotReq) (errd
|
||||
index int32
|
||||
err error
|
||||
)
|
||||
if cd = this.PlotCheck(session, req); cd != pb.ErrorCode_Success {
|
||||
if errdata = this.PlotCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
if npc, err = this.module.configure.getChallengenpc(req.Pid); err != nil {
|
||||
cd = pb.ErrorCode_ConfigNoFound
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if info, err = this.module.modelArena.queryPlayerInfo(session.GetUserId()); err != nil {
|
||||
cd = pb.ErrorCode_DBError
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
this.module.modelArena.recoverTicket(session, info)
|
||||
if cd = this.module.ConsumeRes(session, []*cfg.Gameatn{this.module.ModuleTools.GetGlobalConf().ArenaTicketCos}, true); cd != pb.ErrorCode_Success {
|
||||
if errdata = this.module.ConsumeRes(session, []*cfg.Gameatn{this.module.ModuleTools.GetGlobalConf().ArenaTicketCos}, true); errdata != nil {
|
||||
return
|
||||
}
|
||||
// if info.Ticket > this.module.ModuleTools.GetGlobalConf().ArenaTicketCos {
|
||||
// info.Ticket -= this.module.ModuleTools.GetGlobalConf().ArenaTicketCos
|
||||
// } else {
|
||||
// code = pb.ErrorCode_ArenaTicketNotEnough
|
||||
// return
|
||||
// }
|
||||
|
||||
if info.Npc[req.Pid] != nil {
|
||||
ndata := info.Npc[req.Pid]
|
||||
if !configure.Now().After(time.Unix(ndata.Cd, 0)) { //已经过了cd时间
|
||||
code = pb.ErrorCode_ArenaTicketNpcInCd
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ArenaTicketNpcInCd,
|
||||
Title: pb.ErrorCode_ArenaTicketNpcInCd.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
index = ndata.Index
|
||||
}
|
||||
if cd, record = this.module.battle.CreatePveBattle(session, &pb.BattlePVEReq{
|
||||
if errdata, record = this.module.battle.CreatePveBattle(session, &pb.BattlePVEReq{
|
||||
Ptype: pb.PlayType_arena,
|
||||
Format: req.Battle,
|
||||
Mformat: []int32{npc.MonsterformatId[index]},
|
||||
}); cd == pb.ErrorCode_Success {
|
||||
}); errdata != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if err = this.module.modelArena.updateArenaUserInfo(info); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), "plot", &pb.ArenaPlotResp{
|
||||
Pid: req.Pid,
|
||||
Info: &pb.BattleInfo{
|
||||
|
@ -37,20 +37,15 @@ func (this *apiComp) PlotReward(session comm.IUserSession, req *pb.ArenaPlotRewa
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if code, iswin = this.module.battle.CheckBattleReport(session, req.Report); errdata != nil {
|
||||
if errdata, iswin = this.module.battle.CheckBattleReport(session, req.Report); errdata != nil {
|
||||
return
|
||||
}
|
||||
if !iswin {
|
||||
code = pb.ErrorCode_MoonfantasyBattleNoWin
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: "战斗校验失败",
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_MoonfantasyBattleNoWin,
|
||||
Title: pb.ErrorCode_MoonfantasyBattleNoWin.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -60,10 +55,6 @@ func (this *apiComp) PlotReward(session comm.IUserSession, req *pb.ArenaPlotRewa
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if info.Npc[req.Pid] == nil {
|
||||
@ -85,10 +76,6 @@ func (this *apiComp) PlotReward(session comm.IUserSession, req *pb.ArenaPlotRewa
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -30,10 +30,6 @@ func (this *apiComp) Rank(session comm.IUserSession, req *pb.ArenaRankReq) (errd
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if uids, err = this.module.modelRank.queryRankUser(); err != nil {
|
||||
@ -42,10 +38,6 @@ func (this *apiComp) Rank(session comm.IUserSession, req *pb.ArenaRankReq) (errd
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if ranks, err = this.module.modelArena.queryPlayers(uids); err != nil {
|
||||
@ -54,10 +46,6 @@ func (this *apiComp) Rank(session comm.IUserSession, req *pb.ArenaRankReq) (errd
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
players = make([]*pb.ArenaPlayer, len(ranks))
|
||||
|
@ -27,10 +27,7 @@ func (this *apiComp) SetAttFormt(session comm.IUserSession, req *pb.ArenaSetAttF
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
if heros, err = this.module.modelArena.queryUserHeros(session.GetUserId(), req.Formt); err != nil {
|
||||
@ -39,10 +36,6 @@ func (this *apiComp) SetAttFormt(session comm.IUserSession, req *pb.ArenaSetAttF
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
info.Attack = &pb.DBPlayerBattleFormt{
|
||||
@ -56,10 +49,6 @@ func (this *apiComp) SetAttFormt(session comm.IUserSession, req *pb.ArenaSetAttF
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), "setattformt", &pb.ArenaSetAttFormtResp{Issucc: true})
|
||||
|
@ -27,10 +27,7 @@ func (this *apiComp) SetDefFormt(session comm.IUserSession, req *pb.ArenaSetDefF
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@ -40,10 +37,7 @@ func (this *apiComp) SetDefFormt(session comm.IUserSession, req *pb.ArenaSetDefF
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
info.Defend = &pb.DBPlayerBattleFormt{
|
||||
@ -57,10 +51,7 @@ func (this *apiComp) SetDefFormt(session comm.IUserSession, req *pb.ArenaSetDefF
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
Message: err.Error(),
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), "setdefformt", &pb.ArenaSetDefFormtResp{Issucc: true})
|
||||
|
@ -404,11 +404,7 @@ func (this *modelArena) recoverTicket(session comm.IUserSession, info *pb.DBAren
|
||||
)
|
||||
|
||||
if ticketitem = this.module.ModuleTools.GetGlobalConf().ArenaTicketCos; ticketitem == nil {
|
||||
// errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
// code = pb.ErrorCode_ConfigNoFound
|
||||
// data = &pb.ErrorData{
|
||||
// Title: code.ToString(),
|
||||
// Message: comm.NewNotFoundConfErr(moduleName, "global.json", "ArenaTicketCos").Error(),
|
||||
@ -453,11 +449,7 @@ func (this *modelArena) reddot(session comm.IUserSession) bool {
|
||||
return false
|
||||
}
|
||||
if ticketitem = this.module.ModuleTools.GetGlobalConf().ArenaTicketCos; ticketitem == nil {
|
||||
// errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
// code = pb.ErrorCode_ConfigNoFound
|
||||
// data = &pb.ErrorData{
|
||||
// Title: code.ToString(),
|
||||
// Message: comm.NewNotFoundConfErr(moduleName, "global.json", "ArenaTicketCos").Error(),
|
||||
|
@ -130,7 +130,7 @@ func (this *Arena) GetMatcheBattleRoles(uid string) (captain int32, rules []*pb.
|
||||
info *pb.DBArenaUser
|
||||
players []*pb.ArenaPlayer
|
||||
ais []*pb.ArenaPlayer
|
||||
code pb.ErrorCode
|
||||
errdata *pb.ErrorData
|
||||
)
|
||||
global = this.ModuleTools.GetGlobalConf()
|
||||
if info, err = this.modelArena.queryPlayerInfo(uid); err != nil && err != mgo.MongodbNil {
|
||||
@ -151,8 +151,8 @@ func (this *Arena) GetMatcheBattleRoles(uid string) (captain int32, rules []*pb.
|
||||
}
|
||||
if len(players) > 0 {
|
||||
captain = players[0].Defend.Leadpos
|
||||
if rules, code = this.battle.CreateRolesByHeros(players[0].Defend.Formt); errdata != nil {
|
||||
err = fmt.Errorf("Player CreateRolesByHeros fail:%d", code)
|
||||
if rules, errdata = this.battle.CreateRolesByHeros(players[0].Defend.Formt); errdata != nil {
|
||||
err = fmt.Errorf("Player CreateRolesByHeros fail:%v", errdata)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
@ -161,8 +161,8 @@ func (this *Arena) GetMatcheBattleRoles(uid string) (captain int32, rules []*pb.
|
||||
}
|
||||
if len(ais) > 0 {
|
||||
captain = ais[0].Defend.Leadpos
|
||||
if rules, code = this.battle.CreateRolesByHeros(ais[0].Defend.Formt); errdata != nil {
|
||||
err = fmt.Errorf("AI CreateRolesByHeros fail:%d", code)
|
||||
if rules, errdata = this.battle.CreateRolesByHeros(ais[0].Defend.Formt); errdata != nil {
|
||||
err = fmt.Errorf("AI CreateRolesByHeros fail:%v", errdata)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
|
@ -78,11 +78,14 @@ func (this *modelBattleComp) createeve(session comm.IUserSession, conn *db.DBCon
|
||||
if v != "" {
|
||||
hero := &pb.DBHero{}
|
||||
if err := model.GetListObj(session.GetUserId(), v, hero); err != nil {
|
||||
code = pb.ErrorCode_HeroNoExist
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroNoExist,
|
||||
Title: pb.ErrorCode_HeroNoExist.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
tid := 100 + i
|
||||
if record.Redflist[0].Team[i], code = this.createBattleRole(hero, tid, i); errdata != nil {
|
||||
if record.Redflist[0].Team[i], errdata = this.createBattleRole(hero, tid, i); errdata != nil {
|
||||
return
|
||||
}
|
||||
if buff != nil {
|
||||
@ -107,7 +110,10 @@ func (this *modelBattleComp) createeve(session comm.IUserSession, conn *db.DBCon
|
||||
if this.module.IsCross() {
|
||||
if hero, err = this.module.friend.UseAssistHero(session.GetUserId(), v); err != nil {
|
||||
this.module.Errorln(err)
|
||||
code = pb.ErrorCode_HeroNoExist
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroNoExist,
|
||||
Title: pb.ErrorCode_HeroNoExist.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
} else { //获取跨服数据
|
||||
@ -123,7 +129,7 @@ func (this *modelBattleComp) createeve(session comm.IUserSession, conn *db.DBCon
|
||||
}
|
||||
}
|
||||
tid := 100 + i
|
||||
if record.Redflist[0].Team[i], code = this.createBattleRole(hero, tid, i); errdata != nil {
|
||||
if record.Redflist[0].Team[i], errdata = this.createBattleRole(hero, tid, i); errdata != nil {
|
||||
return
|
||||
}
|
||||
record.Redflist[0].Team[i].Ishelp = true
|
||||
@ -141,7 +147,7 @@ func (this *modelBattleComp) createeve(session comm.IUserSession, conn *db.DBCon
|
||||
if v == 0 {
|
||||
continue
|
||||
}
|
||||
if captain, masters, code = this.createMasterRoles(100, i, v); errdata != nil {
|
||||
if captain, masters, errdata = this.createMasterRoles(100, i, v); errdata != nil {
|
||||
return
|
||||
}
|
||||
record.Redflist[i].Systeam = masters
|
||||
@ -164,7 +170,7 @@ func (this *modelBattleComp) createeve(session comm.IUserSession, conn *db.DBCon
|
||||
if v == 0 {
|
||||
continue
|
||||
}
|
||||
if captain, masters, code = this.createMasterRoles(100, i, v); errdata != nil {
|
||||
if captain, masters, errdata = this.createMasterRoles(100, i, v); errdata != nil {
|
||||
return
|
||||
}
|
||||
record.Redflist[i].Backupteam = masters
|
||||
@ -182,7 +188,7 @@ func (this *modelBattleComp) createeve(session comm.IUserSession, conn *db.DBCon
|
||||
} else {
|
||||
record.Redflist = make([]*pb.DBBattleFormt, len(req.Sysformat))
|
||||
for i, v := range req.Sysformat {
|
||||
if captain, masters, code = this.createMasterRoles(100, i, v); errdata != nil {
|
||||
if captain, masters, errdata = this.createMasterRoles(100, i, v); errdata != nil {
|
||||
return
|
||||
}
|
||||
record.Redflist[i] = &pb.DBBattleFormt{
|
||||
@ -201,7 +207,7 @@ func (this *modelBattleComp) createeve(session comm.IUserSession, conn *db.DBCon
|
||||
}
|
||||
if req.Backupformat != nil && len(req.Backupformat) > 0 {
|
||||
for i, v := range req.Backupformat {
|
||||
if captain, masters, code = this.createMasterRoles(100, i, v); errdata != nil {
|
||||
if captain, masters, errdata = this.createMasterRoles(100, i, v); errdata != nil {
|
||||
return
|
||||
}
|
||||
record.Redflist[i].Backupteam = masters
|
||||
@ -219,7 +225,7 @@ func (this *modelBattleComp) createeve(session comm.IUserSession, conn *db.DBCon
|
||||
}
|
||||
|
||||
for i, v := range req.Buleformat {
|
||||
if captain, masters, code = this.createMasterRoles(200, i, v); errdata != nil {
|
||||
if captain, masters, errdata = this.createMasterRoles(200, i, v); errdata != nil {
|
||||
return
|
||||
}
|
||||
record.Buleflist[i] = &pb.DBBattleFormt{
|
||||
@ -258,11 +264,14 @@ func (this *modelBattleComp) createpve(session comm.IUserSession, conn *db.DBCon
|
||||
if v != "" {
|
||||
heros[i] = &pb.DBHero{}
|
||||
if err := model.GetListObj(session.GetUserId(), v, heros[i]); err != nil {
|
||||
code = pb.ErrorCode_HeroNoExist
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroNoExist,
|
||||
Title: pb.ErrorCode_HeroNoExist.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
tid := 100 + i
|
||||
if record.Redflist[0].Team[i], code = this.createBattleRole(heros[i], tid, i); errdata != nil {
|
||||
if record.Redflist[0].Team[i], errdata = this.createBattleRole(heros[i], tid, i); errdata != nil {
|
||||
return
|
||||
}
|
||||
if buff != nil {
|
||||
@ -286,7 +295,10 @@ func (this *modelBattleComp) createpve(session comm.IUserSession, conn *db.DBCon
|
||||
if this.module.IsCross() {
|
||||
if heros[i], err = this.module.friend.UseAssistHero(session.GetUserId(), v); err != nil {
|
||||
this.module.Errorln(err)
|
||||
code = pb.ErrorCode_HeroNoExist
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroNoExist,
|
||||
Title: pb.ErrorCode_HeroNoExist.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
} else { //获取跨服数据
|
||||
@ -302,7 +314,7 @@ func (this *modelBattleComp) createpve(session comm.IUserSession, conn *db.DBCon
|
||||
}
|
||||
}
|
||||
tid := 100 + i
|
||||
if record.Redflist[0].Team[i], code = this.createBattleRole(heros[i], tid, i); errdata != nil {
|
||||
if record.Redflist[0].Team[i], errdata = this.createBattleRole(heros[i], tid, i); errdata != nil {
|
||||
return
|
||||
}
|
||||
record.Redflist[0].Team[i].Ishelp = true
|
||||
@ -316,7 +328,10 @@ func (this *modelBattleComp) createpve(session comm.IUserSession, conn *db.DBCon
|
||||
}
|
||||
}
|
||||
if ok := this.checkBattlereadyCapskill(req.Format.Leadpos, heros); !ok {
|
||||
code = pb.ErrorCode_BattleCapskillCheckFailed
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_BattleCapskillCheckFailed,
|
||||
Title: pb.ErrorCode_BattleCapskillCheckFailed.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
var (
|
||||
@ -324,7 +339,7 @@ func (this *modelBattleComp) createpve(session comm.IUserSession, conn *db.DBCon
|
||||
masters []*pb.BattleRole
|
||||
)
|
||||
for i, v := range req.Mformat {
|
||||
if captain, masters, code = this.createMasterRoles(200, i, v); errdata != nil {
|
||||
if captain, masters, errdata = this.createMasterRoles(200, i, v); errdata != nil {
|
||||
return
|
||||
}
|
||||
record.Buleflist[i] = &pb.DBBattleFormt{
|
||||
@ -364,11 +379,14 @@ func (this *modelBattleComp) createpvb(session comm.IUserSession, conn *db.DBCon
|
||||
if v != "" {
|
||||
heros[i] = &pb.DBHero{}
|
||||
if err := model.GetListObj(session.GetUserId(), v, heros[i]); err != nil {
|
||||
code = pb.ErrorCode_HeroNoExist
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroNoExist,
|
||||
Title: pb.ErrorCode_HeroNoExist.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
tid := 100 + i
|
||||
if record.Redflist[ii].Team[i], code = this.createBattleRole(heros[i], tid, i); errdata != nil {
|
||||
if record.Redflist[ii].Team[i], errdata = this.createBattleRole(heros[i], tid, i); errdata != nil {
|
||||
return
|
||||
}
|
||||
if buff != nil {
|
||||
@ -392,7 +410,10 @@ func (this *modelBattleComp) createpvb(session comm.IUserSession, conn *db.DBCon
|
||||
if this.module.IsCross() {
|
||||
if heros[i], err = this.module.friend.UseAssistHero(session.GetUserId(), v); err != nil {
|
||||
this.module.Errorln(err)
|
||||
code = pb.ErrorCode_HeroNoExist
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroNoExist,
|
||||
Title: pb.ErrorCode_HeroNoExist.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
} else { //获取跨服数据
|
||||
@ -408,7 +429,7 @@ func (this *modelBattleComp) createpvb(session comm.IUserSession, conn *db.DBCon
|
||||
}
|
||||
}
|
||||
tid := 100 + i
|
||||
if record.Redflist[ii].Team[i], code = this.createBattleRole(heros[i], tid, i); errdata != nil {
|
||||
if record.Redflist[ii].Team[i], errdata = this.createBattleRole(heros[i], tid, i); errdata != nil {
|
||||
return
|
||||
}
|
||||
record.Redflist[ii].Team[i].Ishelp = true
|
||||
@ -422,7 +443,10 @@ func (this *modelBattleComp) createpvb(session comm.IUserSession, conn *db.DBCon
|
||||
}
|
||||
}
|
||||
if ok := this.checkBattlereadyCapskill(v.Leadpos, heros); !ok {
|
||||
code = pb.ErrorCode_BattleCapskillCheckFailed
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_BattleCapskillCheckFailed,
|
||||
Title: pb.ErrorCode_BattleCapskillCheckFailed.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -432,7 +456,7 @@ func (this *modelBattleComp) createpvb(session comm.IUserSession, conn *db.DBCon
|
||||
masters []*pb.BattleRole
|
||||
)
|
||||
for i, v := range req.Mformat {
|
||||
if captain, masters, code = this.createMasterRoles(200, i, v); errdata != nil {
|
||||
if captain, masters, errdata = this.createMasterRoles(200, i, v); errdata != nil {
|
||||
return
|
||||
}
|
||||
record.Buleflist[i] = &pb.DBBattleFormt{
|
||||
@ -464,7 +488,7 @@ func (this *modelBattleComp) createpvp(session comm.IUserSession, conn *db.DBCon
|
||||
for i, v := range req.Redformat.Format {
|
||||
if v != nil {
|
||||
tid := 100 + i
|
||||
if record.Redflist[0].Team[i], code = this.createBattleRole(v, tid, i); errdata != nil {
|
||||
if record.Redflist[0].Team[i], errdata = this.createBattleRole(v, tid, i); errdata != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
@ -472,7 +496,10 @@ func (this *modelBattleComp) createpvp(session comm.IUserSession, conn *db.DBCon
|
||||
}
|
||||
}
|
||||
if ok := this.checkBattlereadyCapskill(req.Redformat.Leadpos, req.Redformat.Format); !ok {
|
||||
code = pb.ErrorCode_BattleCapskillCheckFailed
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_BattleCapskillCheckFailed,
|
||||
Title: pb.ErrorCode_BattleCapskillCheckFailed.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -484,7 +511,7 @@ func (this *modelBattleComp) createpvp(session comm.IUserSession, conn *db.DBCon
|
||||
for i, v := range req.Buleformat.Format {
|
||||
if v != nil {
|
||||
tid := 200 + i
|
||||
if record.Buleflist[0].Team[i], code = this.createBattleRole(v, tid, i); errdata != nil {
|
||||
if record.Buleflist[0].Team[i], errdata = this.createBattleRole(v, tid, i); errdata != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
@ -492,7 +519,10 @@ func (this *modelBattleComp) createpvp(session comm.IUserSession, conn *db.DBCon
|
||||
}
|
||||
}
|
||||
if ok := this.checkBattlereadyCapskill(req.Buleformat.Leadpos, req.Buleformat.Format); !ok {
|
||||
code = pb.ErrorCode_BattleCapskillCheckFailed
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_BattleCapskillCheckFailed,
|
||||
Title: pb.ErrorCode_BattleCapskillCheckFailed.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
return
|
||||
@ -521,11 +551,14 @@ func (this *modelBattleComp) creatertpvp(redmodel, bluemodel *db.DBModel, btype
|
||||
if v != "" {
|
||||
heros[i] = &pb.DBHero{}
|
||||
if err := redmodel.GetListObj(req.RedCompId, v, heros[i]); err != nil {
|
||||
code = pb.ErrorCode_HeroNoExist
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroNoExist,
|
||||
Title: pb.ErrorCode_HeroNoExist.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
tid := 100 + i
|
||||
if record.Redflist[ii].Team[i], code = this.createBattleRole(heros[i], tid, i); errdata != nil {
|
||||
if record.Redflist[ii].Team[i], errdata = this.createBattleRole(heros[i], tid, i); errdata != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
@ -533,7 +566,10 @@ func (this *modelBattleComp) creatertpvp(redmodel, bluemodel *db.DBModel, btype
|
||||
}
|
||||
}
|
||||
if ok := this.checkBattlereadyCapskill(v.Leadpos, heros); !ok {
|
||||
code = pb.ErrorCode_BattleCapskillCheckFailed
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_BattleCapskillCheckFailed,
|
||||
Title: pb.ErrorCode_BattleCapskillCheckFailed.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -547,11 +583,14 @@ func (this *modelBattleComp) creatertpvp(redmodel, bluemodel *db.DBModel, btype
|
||||
if v != "" {
|
||||
heros[i] = &pb.DBHero{}
|
||||
if err := bluemodel.GetListObj(req.BlueCompId, v, heros[i]); err != nil {
|
||||
code = pb.ErrorCode_HeroNoExist
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroNoExist,
|
||||
Title: pb.ErrorCode_HeroNoExist.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
tid := 200 + i
|
||||
if record.Buleflist[ii].Team[i], code = this.createBattleRole(heros[i], tid, i); errdata != nil {
|
||||
if record.Buleflist[ii].Team[i], errdata = this.createBattleRole(heros[i], tid, i); errdata != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
@ -559,7 +598,10 @@ func (this *modelBattleComp) creatertpvp(redmodel, bluemodel *db.DBModel, btype
|
||||
}
|
||||
}
|
||||
if ok := this.checkBattlereadyCapskill(v.Leadpos, heros); !ok {
|
||||
code = pb.ErrorCode_BattleCapskillCheckFailed
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_BattleCapskillCheckFailed,
|
||||
Title: pb.ErrorCode_BattleCapskillCheckFailed.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -594,11 +636,14 @@ func (this *modelBattleComp) createlpve(session comm.IUserSession, conn *db.DBCo
|
||||
if v != "" {
|
||||
heros[i] = &pb.DBHero{}
|
||||
if err := model.GetListObj(session.GetUserId(), v, heros[i]); err != nil {
|
||||
code = pb.ErrorCode_HeroNoExist
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroNoExist,
|
||||
Title: pb.ErrorCode_HeroNoExist.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
tid := 100 + i
|
||||
if record.Redflist[0].Team[i], code = this.createBattleRole(heros[i], tid, i); errdata != nil {
|
||||
if record.Redflist[0].Team[i], errdata = this.createBattleRole(heros[i], tid, i); errdata != nil {
|
||||
return
|
||||
}
|
||||
if buff != nil {
|
||||
@ -622,7 +667,10 @@ func (this *modelBattleComp) createlpve(session comm.IUserSession, conn *db.DBCo
|
||||
if this.module.IsCross() {
|
||||
if heros[i], err = this.module.friend.UseAssistHero(session.GetUserId(), v); err != nil {
|
||||
this.module.Errorln(err)
|
||||
code = pb.ErrorCode_HeroNoExist
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroNoExist,
|
||||
Title: pb.ErrorCode_HeroNoExist.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
} else { //获取跨服数据
|
||||
@ -638,7 +686,7 @@ func (this *modelBattleComp) createlpve(session comm.IUserSession, conn *db.DBCo
|
||||
}
|
||||
}
|
||||
tid := 100 + i
|
||||
if record.Redflist[0].Team[i], code = this.createBattleRole(heros[i], tid, i); errdata != nil {
|
||||
if record.Redflist[0].Team[i], errdata = this.createBattleRole(heros[i], tid, i); errdata != nil {
|
||||
return
|
||||
}
|
||||
record.Redflist[0].Team[i].Ishelp = true
|
||||
@ -652,7 +700,10 @@ func (this *modelBattleComp) createlpve(session comm.IUserSession, conn *db.DBCo
|
||||
}
|
||||
}
|
||||
if ok := this.checkBattlereadyCapskill(req.Format.Leadpos, heros); !ok {
|
||||
code = pb.ErrorCode_BattleCapskillCheckFailed
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_BattleCapskillCheckFailed,
|
||||
Title: pb.ErrorCode_BattleCapskillCheckFailed.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
record.Buleflist[0] = &pb.DBBattleFormt{
|
||||
@ -753,7 +804,7 @@ func (this *modelBattleComp) createMasterRoles(comp, wheel int, fid int32) (capt
|
||||
captain = int32(i)
|
||||
}
|
||||
// if monst, err := this.module.configure.GetMonster(v.Monster); err != nil {
|
||||
// errdata = &pb.ErrorData{
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
|
@ -84,7 +84,10 @@ func (this *Battle) OnInstallComp() {
|
||||
func (this *Battle) QueryBattleRecord(oid string) (errdata *pb.ErrorData, record *pb.DBBattleRecord) {
|
||||
var err error
|
||||
if record, err = this.modelBattle.queryrecord(oid); err != nil {
|
||||
code = pb.ErrorCode_BattleNoFoundRecord
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_BattleNoFoundRecord,
|
||||
Title: pb.ErrorCode_BattleNoFoundRecord.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
return
|
||||
@ -111,7 +114,7 @@ func (this *Battle) CreateEveBattle(session comm.IUserSession, req *pb.BattleEVE
|
||||
return
|
||||
}
|
||||
|
||||
if record, code = this.modelBattle.createeve(session, conn, pb.BattleType_eve, req); errdata != nil {
|
||||
if record, errdata = this.modelBattle.createeve(session, conn, pb.BattleType_eve, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
@ -158,7 +161,7 @@ func (this *Battle) CreatePveBattle(session comm.IUserSession, req *pb.BattlePVE
|
||||
}
|
||||
}
|
||||
|
||||
if record, code = this.modelBattle.createpve(session, conn, pb.BattleType_pve, req); errdata != nil {
|
||||
if record, errdata = this.modelBattle.createpve(session, conn, pb.BattleType_pve, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
if req.Format.Friendformat != nil {
|
||||
@ -194,7 +197,7 @@ func (this *Battle) CreatePvbBattle(session comm.IUserSession, req *pb.BattlePVB
|
||||
}
|
||||
return
|
||||
}
|
||||
if record, code = this.modelBattle.createpvb(session, conn, pb.BattleType_pvb, req); errdata != nil {
|
||||
if record, errdata = this.modelBattle.createpvb(session, conn, pb.BattleType_pvb, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
@ -220,7 +223,7 @@ func (this *Battle) CreatePvpBattle(session comm.IUserSession, req *pb.BattlePVP
|
||||
this.Errorf("session:%v err:", session, err)
|
||||
return
|
||||
}
|
||||
if record, code = this.modelBattle.createpvp(session, conn, pb.BattleType_pvp, req); errdata != nil {
|
||||
if record, errdata = this.modelBattle.createpvp(session, conn, pb.BattleType_pvp, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
@ -234,7 +237,10 @@ func (this *Battle) CreateRtPvpBattle(req *pb.BattleRTPVPReq) (errdata *pb.Error
|
||||
err error
|
||||
)
|
||||
if !this.IsCross() {
|
||||
code = pb.ErrorCode_Exception
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_Exception,
|
||||
Title: pb.ErrorCode_Exception.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if redmodel, err = this.GetDBModelByUid(req.RedCompId, comm.TableHero); err != nil {
|
||||
@ -253,7 +259,7 @@ func (this *Battle) CreateRtPvpBattle(req *pb.BattleRTPVPReq) (errdata *pb.Error
|
||||
}
|
||||
return
|
||||
}
|
||||
if record, code = this.modelBattle.creatertpvp(redmodel, bluemodel, pb.BattleType_rtpvp, req); errdata != nil {
|
||||
if record, errdata = this.modelBattle.creatertpvp(redmodel, bluemodel, pb.BattleType_rtpvp, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
@ -300,7 +306,7 @@ func (this *Battle) CreateLPVEBattle(session comm.IUserSession, req *pb.BattleLP
|
||||
}
|
||||
}
|
||||
|
||||
if record, code = this.modelBattle.createlpve(session, conn, pb.BattleType_lpev, req); errdata != nil {
|
||||
if record, errdata = this.modelBattle.createlpve(session, conn, pb.BattleType_lpev, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
if req.Format.Friendformat != nil {
|
||||
@ -311,7 +317,7 @@ func (this *Battle) CreateLPVEBattle(session comm.IUserSession, req *pb.BattleLP
|
||||
|
||||
///创建角色列表 更具Format表格
|
||||
func (this *Battle) CreateRolesByFormat(fid int32) (captain int32, roles []*pb.BattleRole, errdata *pb.ErrorData) {
|
||||
captain, roles, code = this.modelBattle.createMasterRoles(2, 0, fid)
|
||||
captain, roles, errdata = this.modelBattle.createMasterRoles(2, 0, fid)
|
||||
return
|
||||
}
|
||||
|
||||
@ -320,7 +326,7 @@ func (this *Battle) CreateRolesByHeros(heros []*pb.DBHero) (roles []*pb.BattleRo
|
||||
roles = make([]*pb.BattleRole, len(heros))
|
||||
for i, v := range heros {
|
||||
if v != nil {
|
||||
if roles[i], code = this.modelBattle.createBattleRole(v, 200+i, i); errdata != nil {
|
||||
if roles[i], errdata = this.modelBattle.createBattleRole(v, 200+i, i); errdata != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -338,7 +344,10 @@ func (this *Battle) GetBattleInfo(req *pb.BattleGetInfoReq) (errdata *pb.ErrorDa
|
||||
ctx, _ = context.WithTimeout(context.Background(), time.Second*5)
|
||||
if resp, err = this.clientmgr.GetInfo(ctx, req); err != nil {
|
||||
this.Errorln(err)
|
||||
code = pb.ErrorCode_RpcFuncExecutionError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_RpcFuncExecutionError,
|
||||
Title: pb.ErrorCode_RpcFuncExecutionError.ToString(),
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -354,10 +363,16 @@ func (this *Battle) CreateBattleServer(req *pb.BattleInfo) (errdata *pb.ErrorDat
|
||||
ctx, _ = context.WithTimeout(context.Background(), time.Second*5)
|
||||
if resp, err = this.clientmgr.CreateBattle(ctx, &pb.BattleCreateServerReq{Info: req}); err != nil {
|
||||
this.Errorln(err)
|
||||
code = pb.ErrorCode_RpcFuncExecutionError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_RpcFuncExecutionError,
|
||||
Title: pb.ErrorCode_RpcFuncExecutionError.ToString(),
|
||||
}
|
||||
}
|
||||
if !resp.Issucc {
|
||||
code = pb.ErrorCode_BattleCreateFailed
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_BattleCreateFailed,
|
||||
Title: pb.ErrorCode_BattleCreateFailed.ToString(),
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -371,10 +386,16 @@ func (this *Battle) InCmdBattle(req *pb.BattleInCmdReq) (errdata *pb.ErrorData)
|
||||
ctx, _ = context.WithTimeout(context.Background(), time.Second*5)
|
||||
if resp, err = this.clientmgr.InCmdBattle(ctx, req); err != nil {
|
||||
this.Errorln(err)
|
||||
code = pb.ErrorCode_RpcFuncExecutionError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_RpcFuncExecutionError,
|
||||
Title: pb.ErrorCode_RpcFuncExecutionError.ToString(),
|
||||
}
|
||||
}
|
||||
if !resp.Issucc {
|
||||
code = pb.ErrorCode_BattleInCmdFailed
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_BattleInCmdFailed,
|
||||
Title: pb.ErrorCode_BattleInCmdFailed.ToString(),
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -387,10 +408,16 @@ func (this *Battle) ConcedeBattle(req *pb.BattleConcedeReq) (errdata *pb.ErrorDa
|
||||
)
|
||||
if resp, err = this.clientmgr.ConcedeBattle(context.Background(), req); err != nil {
|
||||
this.Errorln(err)
|
||||
code = pb.ErrorCode_RpcFuncExecutionError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_RpcFuncExecutionError,
|
||||
Title: pb.ErrorCode_RpcFuncExecutionError.ToString(),
|
||||
}
|
||||
}
|
||||
if !resp.Issucc {
|
||||
code = pb.ErrorCode_BattleInCmdFailed
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_BattleInCmdFailed,
|
||||
Title: pb.ErrorCode_BattleInCmdFailed.ToString(),
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -411,7 +438,10 @@ func (this *Battle) CheckBattleReport(session comm.IUserSession, report *pb.Batt
|
||||
stime := time.Now()
|
||||
ctx, _ = context.WithTimeout(context.Background(), time.Second*5)
|
||||
if reply, err = this.clientmgr.CheckBattle(ctx, report); err != nil || !reply.Ischeck {
|
||||
code = pb.ErrorCode_BattleValidationFailed
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_BattleValidationFailed,
|
||||
Title: pb.ErrorCode_BattleValidationFailed.ToString(),
|
||||
}
|
||||
this.Error("[Battle Check]",
|
||||
log.Field{Key: "t", Value: time.Since(stime).Milliseconds()},
|
||||
log.Field{Key: "reply", Value: reply.String()},
|
||||
@ -429,5 +459,5 @@ func (this *Battle) CheckBattleReport(session comm.IUserSession, report *pb.Batt
|
||||
// this.ModuleBuried.SendToRtask(session, comm.Rtype157, int32(report.Info.Ptype), v)
|
||||
go this.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.Rtype157, int32(report.Info.Ptype), v))
|
||||
}
|
||||
return pb.ErrorCode_Success, true
|
||||
return nil, true
|
||||
}
|
||||
|
@ -34,10 +34,6 @@ func (this *apiComp) InquireProgress(session comm.IUserSession, req *pb.BuriedIn
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -29,10 +29,6 @@ func (this *apiComp) ChanageChannel(session comm.IUserSession, req *pb.ChatChana
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if ok {
|
||||
@ -42,10 +38,6 @@ func (this *apiComp) ChanageChannel(session comm.IUserSession, req *pb.ChatChana
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
this.module.ModuleUser.ChangeUserExpand(session.GetUserId(), map[string]interface{}{
|
||||
|
@ -26,10 +26,6 @@ func (this *apiComp) CrossChannel(session comm.IUserSession, req *pb.ChatCrossCh
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
this.module.ModuleUser.ChangeUserExpand(session.GetUserId(), map[string]interface{}{
|
||||
|
@ -37,10 +37,6 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.ChatGetListReq)
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
break
|
||||
@ -51,10 +47,6 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.ChatGetListReq)
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
break
|
||||
@ -65,10 +57,6 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.ChatGetListReq)
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
break
|
||||
@ -80,19 +68,12 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.ChatGetListReq)
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if req.ChannelId != result.Chatchannel {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: fmt.Sprintf("req.ChannelId:%d != result.Chatchannel:%d", req.ChannelId, result.Chatchannel),
|
||||
}
|
||||
return
|
||||
@ -103,10 +84,6 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.ChatGetListReq)
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
break
|
||||
@ -117,10 +94,6 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.ChatGetListReq)
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
break
|
||||
@ -130,9 +103,6 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.ChatGetListReq)
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: fmt.Sprintf("不存在的聊天频道类型 channel:%d ", req.Channel),
|
||||
}
|
||||
return
|
||||
|
@ -57,10 +57,6 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (errda
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -80,7 +76,6 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (errda
|
||||
session.SendMsg(string(this.module.GetType()), "send", &pb.ChatSendResp{Issucc: true})
|
||||
return
|
||||
}
|
||||
code = pb.ErrorCode_Success
|
||||
}
|
||||
if msg.Ctype == pb.ChatType_Text { //过滤敏感词
|
||||
msg.Content = wordfilter.Replace(msg.Content, '*')
|
||||
@ -134,9 +129,6 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (errda
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: fmt.Sprintf("不存在的聊天频道类型 channel:%d ", req.Channel),
|
||||
}
|
||||
return
|
||||
|
@ -242,18 +242,18 @@ func (this *modelChatComp) saveUserMsg(msg *pb.DBChat) (err error) {
|
||||
// )
|
||||
// if max, err = this.module.configure.GetChannelRecordMax(); err != nil {
|
||||
// errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
// Code: pb.ErrorCode_ConfigNoFound,
|
||||
// Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
// Message: err.Error(),
|
||||
// }
|
||||
// return
|
||||
// }
|
||||
// if err = this.module.modelChat.addChatMsg(fmt.Sprintf("%s-%s", worldchatkey, msg.Stag), int64(max), msg); err != nil {
|
||||
// errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
// Code: pb.ErrorCode_DBError,
|
||||
// Title: pb.ErrorCode_DBError.ToString(),
|
||||
// Message: err.Error(),
|
||||
// }
|
||||
// return
|
||||
// }
|
||||
// data, _ := anypb.New(&pb.ChatMessagePush{Chat: msg})
|
||||
|
@ -163,7 +163,11 @@ func (this *Chat) SendWorldChat(msg *pb.DBChat) (errdata *pb.ErrorData) {
|
||||
msg,
|
||||
nil); err != nil {
|
||||
this.Errorln(err)
|
||||
code = pb.ErrorCode_RpcFuncExecutionError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_RpcFuncExecutionError,
|
||||
Title: pb.ErrorCode_RpcFuncExecutionError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
@ -198,7 +202,11 @@ func (this *Chat) SendUnionChat(msg *pb.DBChat) (errdata *pb.ErrorData) {
|
||||
msg,
|
||||
nil); err != nil {
|
||||
this.Errorln(err)
|
||||
code = pb.ErrorCode_RpcFuncExecutionError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_RpcFuncExecutionError,
|
||||
Title: pb.ErrorCode_RpcFuncExecutionError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
@ -218,7 +226,11 @@ func (this *Chat) SendUserChat(msg *pb.DBChat) (errdata *pb.ErrorData) {
|
||||
session.SendMsg(string(this.GetType()), "message", &pb.ChatMessagePush{Chat: msg})
|
||||
if err = session.Push(); err != nil {
|
||||
this.Errorf("err:%v", err)
|
||||
code = pb.ErrorCode_SystemError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SystemError,
|
||||
Title: pb.ErrorCode_SystemError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
} else {
|
||||
@ -284,7 +296,11 @@ func (this *Chat) SendSysChatToWorld(ctype comm.ChatSystemType, appenddata inter
|
||||
msg,
|
||||
nil); err != nil {
|
||||
this.Errorln(err)
|
||||
code = pb.ErrorCode_RpcFuncExecutionError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_RpcFuncExecutionError,
|
||||
Title: pb.ErrorCode_RpcFuncExecutionError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,10 +51,6 @@ func (this *apiComp) Ask(session comm.IUserSession, req *pb.CombatAskReq) (errda
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
this.module.Errorln(err)
|
||||
return
|
||||
}
|
||||
@ -70,9 +66,9 @@ func (this *apiComp) Ask(session comm.IUserSession, req *pb.CombatAskReq) (errda
|
||||
if level.Pass != 2 {
|
||||
level.Progress = 0
|
||||
if condis, err = this.module.ModuleBuried.CheckCondition(session.GetUserId(), lvconf.Maintask...); err != nil {
|
||||
code = pb.ErrorCode_ExternalModule
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ExternalModule,
|
||||
Title: pb.ErrorCode_ExternalModule.ToString(),
|
||||
Message: comm.NewExternalModuleErr("Buried", "CheckCondition", lvconf.Maintask).Error(),
|
||||
}
|
||||
return
|
||||
@ -105,9 +101,9 @@ func (this *apiComp) Ask(session comm.IUserSession, req *pb.CombatAskReq) (errda
|
||||
}
|
||||
|
||||
if condis, err = this.module.ModuleBuried.CheckCondition(session.GetUserId(), lvconf.Subtask...); err != nil {
|
||||
code = pb.ErrorCode_ExternalModule
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ExternalModule,
|
||||
Title: pb.ErrorCode_ExternalModule.ToString(),
|
||||
Message: comm.NewExternalModuleErr("Buried", "CheckCondition", lvconf.Subtask).Error(),
|
||||
}
|
||||
return
|
||||
|
@ -20,10 +20,6 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.CombatChalleng
|
||||
err error
|
||||
)
|
||||
if errdata = this.ChallengeCheck(session, req); errdata != nil {
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: req.String(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -33,21 +29,13 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.CombatChalleng
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if code, record = this.module.battle.CreatePveBattle(session, &pb.BattlePVEReq{
|
||||
if errdata, record = this.module.battle.CreatePveBattle(session, &pb.BattlePVEReq{
|
||||
Ptype: pb.PlayType_combat,
|
||||
Format: req.Battle,
|
||||
Mformat: manster.FormatList,
|
||||
}); errdata != nil {
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: req.String(),
|
||||
}
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), "challenge", &pb.CombatChallengeResp{Manster: req.Manster, Level: req.Level, Info: &pb.BattleInfo{
|
||||
|
@ -28,7 +28,7 @@ func (this *apiComp) ChallengeReceive(session comm.IUserSession, req *pb.CombatC
|
||||
if errdata = this.ChallengeReceiveCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
if code, iswin = this.module.battle.CheckBattleReport(session, req.Report); errdata != nil {
|
||||
if errdata, iswin = this.module.battle.CheckBattleReport(session, req.Report); errdata != nil {
|
||||
return
|
||||
}
|
||||
if iswin {
|
||||
@ -38,10 +38,7 @@ func (this *apiComp) ChallengeReceive(session comm.IUserSession, req *pb.CombatC
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
if lv, ok = info.Level[req.Level]; !ok {
|
||||
@ -51,10 +48,7 @@ func (this *apiComp) ChallengeReceive(session comm.IUserSession, req *pb.CombatC
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
if manster, err = this.module.configure.getGameCombatManster(req.Manster); err != nil {
|
||||
@ -63,10 +57,7 @@ func (this *apiComp) ChallengeReceive(session comm.IUserSession, req *pb.CombatC
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
for _, v := range lv.Passmanster {
|
||||
@ -75,10 +66,7 @@ func (this *apiComp) ChallengeReceive(session comm.IUserSession, req *pb.CombatC
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: fmt.Sprintf("req.Manster:%d 重复", code),
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -90,10 +78,7 @@ func (this *apiComp) ChallengeReceive(session comm.IUserSession, req *pb.CombatC
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@ -112,10 +97,6 @@ func (this *apiComp) ChallengeReceive(session comm.IUserSession, req *pb.CombatC
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,12 @@ func (this *apiComp) WatchHero(session comm.IUserSession, req *pb.ForumWatchHero
|
||||
return
|
||||
}
|
||||
if hero, err = this.module.modelForum.watchHero(req.Stag, req.Uid, req.HerocId); err != nil {
|
||||
code = pb.ErrorCode_HeroNoExist
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroNoExist,
|
||||
Title: pb.ErrorCode_HeroNoExist.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
equip = this.module.modelForum.watchHeroEquip(req.Stag, req.Uid, hero.EquipID...)
|
||||
session.SendMsg(string(this.module.GetType()), "watchhero", &pb.ForumWatchHeroResp{
|
||||
|
@ -93,9 +93,9 @@ locp:
|
||||
})
|
||||
continue
|
||||
}
|
||||
var code pb.ErrorCode
|
||||
code, err = this.secAuth(msg)
|
||||
if err == nil {
|
||||
var errdata *pb.ErrorData
|
||||
errdata = this.secAuth(msg)
|
||||
if errdata == nil {
|
||||
// this.gateway.Debugf("----------2 agent:%s uId:%s MainType:%s SubType:%s ", this.sessionId, this.uId, msg.MainType, msg.SubType)
|
||||
if err = this.messageDistribution(msg); err != nil {
|
||||
this.gateway.Errorf("messageDistribution err:%v", err)
|
||||
@ -123,8 +123,8 @@ locp:
|
||||
MsgId: msg.MsgId,
|
||||
ReqMainType: msg.MainType,
|
||||
ReqSubType: msg.SubType,
|
||||
Code: code,
|
||||
Err: &pb.ErrorData{Title: "用户消息验证失败!", Datastring: err.Error()},
|
||||
Code: errdata.Code,
|
||||
Err: errdata,
|
||||
})
|
||||
if err = this.WriteMsg(&pb.UserMessage{
|
||||
MsgId: msg.MsgId,
|
||||
@ -170,21 +170,30 @@ locp:
|
||||
}
|
||||
|
||||
// 安全认证 所有协议
|
||||
func (this *Agent) secAuth(msg *pb.UserMessage) (errdata *pb.ErrorData, err error) {
|
||||
func (this *Agent) secAuth(msg *pb.UserMessage) (errdata *pb.ErrorData) {
|
||||
if !utils.ValidSecretKey(msg.Sec) { //验证失败
|
||||
this.gateway.Errorf("%v", msg.Sec)
|
||||
return pb.ErrorCode_SignError, fmt.Errorf("key invalid")
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SignError,
|
||||
Title: pb.ErrorCode_SignError.ToString(),
|
||||
Message: "key invalid",
|
||||
}
|
||||
return
|
||||
}
|
||||
return this.decodeUserData(msg)
|
||||
}
|
||||
|
||||
// 解码
|
||||
func (this *Agent) decodeUserData(msg *pb.UserMessage) (errdata *pb.ErrorData, err error) {
|
||||
func (this *Agent) decodeUserData(msg *pb.UserMessage) (errdata *pb.ErrorData) {
|
||||
base64Str := msg.Sec
|
||||
dec, err := base64.StdEncoding.DecodeString(base64Str[35:])
|
||||
if err != nil {
|
||||
this.gateway.Errorf("base64 decode err %v", err)
|
||||
return pb.ErrorCode_DecodeError, nil
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DecodeError,
|
||||
Title: pb.ErrorCode_DecodeError.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
now := configure.Now().Unix()
|
||||
jsonRet := gjson.Parse(string(dec))
|
||||
@ -192,7 +201,12 @@ func (this *Agent) decodeUserData(msg *pb.UserMessage) (errdata *pb.ErrorData, e
|
||||
//秘钥30秒失效
|
||||
if now-time.Unix(timestamp, 0).Unix() > 30 {
|
||||
this.gateway.Errorf("now:%v last timestamp:%v more than 30s", now, timestamp)
|
||||
return pb.ErrorCode_TimestampTimeout, fmt.Errorf("sec key expire")
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_TimestampTimeout,
|
||||
Title: pb.ErrorCode_TimestampTimeout.ToString(),
|
||||
Message: "sec key expire",
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//只有login的时候才需要设置Data
|
||||
@ -206,21 +220,31 @@ func (this *Agent) decodeUserData(msg *pb.UserMessage) (errdata *pb.ErrorData, e
|
||||
ad, err := anypb.New(req)
|
||||
if err != nil {
|
||||
this.gateway.Errorf("decodeUserData pb err:%v", err)
|
||||
return pb.ErrorCode_PbError, err
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_PbError,
|
||||
Title: pb.ErrorCode_PbError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
msg.Data = ad
|
||||
} else {
|
||||
switch msg.MainType {
|
||||
case string(comm.ModuleNotify), string(comm.ModuleGate):
|
||||
return pb.ErrorCode_Success, nil
|
||||
return
|
||||
default:
|
||||
if this.UserId() == "" {
|
||||
this.gateway.Errorf("[%v.%v] Agent UId empty", msg.MainType, msg.SubType)
|
||||
return pb.ErrorCode_AgentUidEmpty, fmt.Errorf("no login")
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_AgentUidEmpty,
|
||||
Title: pb.ErrorCode_AgentUidEmpty.ToString(),
|
||||
Message: "no login",
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
return pb.ErrorCode_Success, nil
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Agent) SessionId() string {
|
||||
|
@ -18,37 +18,48 @@ func (this *apiComp) Ask(session comm.IUserSession, req *pb.MoonfantasyAskReq) (
|
||||
lock *redis.RedisMutex
|
||||
// umfantasy *pb.DBUserMFantasy
|
||||
user *pb.DBUser
|
||||
cd pb.ErrorCode
|
||||
isjson bool
|
||||
err error
|
||||
)
|
||||
defer func() {
|
||||
session.SendMsg(string(this.module.GetType()), "ask", &pb.MoonfantasyAskResp{Code: cd, Info: mdata})
|
||||
}()
|
||||
if cd = this.AskCheck(session, req); cd != pb.ErrorCode_Success {
|
||||
if errdata = this.AskCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
//月之秘境需要加分布式锁 防止多人同时操作
|
||||
if lock, err = this.module.modelDream.newDreamLock(req.Mid); err != nil {
|
||||
cd = pb.ErrorCode_DBError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
defer lock.Unlock()
|
||||
if err = lock.Lock(); err != nil {
|
||||
cd = pb.ErrorCode_DBError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
}
|
||||
this.module.Errorln(err)
|
||||
return
|
||||
}
|
||||
if mdata, err = this.module.modelDream.querymfantasy(req.Mid); err != nil {
|
||||
cd = pb.ErrorCode_DBError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if mdata == nil {
|
||||
cd = pb.ErrorCode_MoonfantasyHasExpired
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_MoonfantasyHasExpired,
|
||||
Title: pb.ErrorCode_MoonfantasyHasExpired.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if this.module.modelDream.checkMFantasyExpiration(mdata) { //已过期
|
||||
cd = pb.ErrorCode_MoonfantasyHasExpired
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_MoonfantasyHasExpired,
|
||||
Title: pb.ErrorCode_MoonfantasyHasExpired.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
for _, v := range mdata.Join {
|
||||
@ -60,7 +71,10 @@ func (this *apiComp) Ask(session comm.IUserSession, req *pb.MoonfantasyAskReq) (
|
||||
|
||||
if !isjson {
|
||||
if len(mdata.Join) >= int(mdata.Numup) {
|
||||
cd = pb.ErrorCode_MoonfantasyJoinUp
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_MoonfantasyJoinUp,
|
||||
Title: pb.ErrorCode_MoonfantasyJoinUp.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
// if umfantasy, err = this.module.modelUserMF.queryUsermfantasy(session.GetUserId()); err != nil {
|
||||
@ -85,5 +99,7 @@ func (this *apiComp) Ask(session comm.IUserSession, req *pb.MoonfantasyAskReq) (
|
||||
"join": mdata.Join,
|
||||
})
|
||||
}
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), "ask", &pb.MoonfantasyAskResp{Info: mdata})
|
||||
return
|
||||
}
|
||||
|
@ -15,24 +15,109 @@ func (this *apiComp) BattleCheck(session comm.IUserSession, req *pb.MoonfantasyB
|
||||
func (this *apiComp) Battle(session comm.IUserSession, req *pb.MoonfantasyBattleReq) (errdata *pb.ErrorData) {
|
||||
var (
|
||||
boss *cfg.GameDreamlandBoosData
|
||||
// umfantasy *pb.DBUserMFantasy
|
||||
mdata *pb.DBMoonFantasy
|
||||
record *pb.DBBattleRecord
|
||||
cd pb.ErrorCode
|
||||
isjoin bool
|
||||
err error
|
||||
)
|
||||
|
||||
defer func() {
|
||||
if cd == pb.ErrorCode_Success {
|
||||
// this.module.modelUserMF.Change(session.GetUserId(), map[string]interface{}{
|
||||
// "ticket": umfantasy.Ticket,
|
||||
// })
|
||||
if errdata = this.BattleCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
if mdata, err = this.module.modelDream.querymfantasy(req.Mid); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if mdata == nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_MoonfantasyHasExpired,
|
||||
Title: pb.ErrorCode_MoonfantasyHasExpired.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if this.module.modelDream.checkMFantasyExpiration(mdata) { //已过期
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_MoonfantasyHasExpired,
|
||||
Title: pb.ErrorCode_MoonfantasyHasExpired.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
for _, v := range mdata.Join {
|
||||
if v.Uid == session.GetUserId() {
|
||||
isjoin = true
|
||||
}
|
||||
}
|
||||
if !isjoin {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_MoonfantasyNoJoin,
|
||||
Title: pb.ErrorCode_MoonfantasyNoJoin.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if boss, err = this.module.configure.GetMonsterById(mdata.Monster); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if errdata = this.module.ModuleItems.RecoverTicket(session); errdata != nil {
|
||||
return
|
||||
}
|
||||
if errdata = this.module.CheckRes(session, boss.PsConsume); errdata != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if len(mdata.Join) >= int(mdata.Numup) {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_MoonfantasyJoinUp,
|
||||
Title: pb.ErrorCode_MoonfantasyJoinUp.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if this.module.modelDream.checkMFantasyExpiration(mdata) { //已过期
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_MoonfantasyHasExpired,
|
||||
Title: pb.ErrorCode_MoonfantasyHasExpired.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if v, ok := mdata.Record[session.GetUserId()]; ok {
|
||||
if v >= mdata.Unitmup {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_MoonfantasyDareUp,
|
||||
Title: pb.ErrorCode_MoonfantasyDareUp.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
} else {
|
||||
mdata.Record[session.GetUserId()]++
|
||||
}
|
||||
} else {
|
||||
mdata.Record[session.GetUserId()] = 1
|
||||
}
|
||||
|
||||
if errdata, record = this.module.battle.CreatePveBattle(session, &pb.BattlePVEReq{
|
||||
Ptype: pb.PlayType_moonfantasy,
|
||||
Format: req.Battle,
|
||||
Mformat: boss.Monsterformatid,
|
||||
}); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
this.module.modelDream.ChangeList("", mdata.Id, map[string]interface{}{
|
||||
"record": mdata.Record,
|
||||
})
|
||||
session.SendMsg(string(this.module.GetType()), "battle", &pb.MoonfantasyBattleResp{
|
||||
Code: cd,
|
||||
Mid: mdata.Monster,
|
||||
Info: &pb.BattleInfo{
|
||||
Id: record.Id,
|
||||
@ -46,81 +131,6 @@ func (this *apiComp) Battle(session comm.IUserSession, req *pb.MoonfantasyBattle
|
||||
Buleflist: record.Buleflist,
|
||||
},
|
||||
})
|
||||
// this.module.ModuleRtask.SendToRtask(session, comm.Rtype88, 1)
|
||||
go this.module.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.Rtype88, 1))
|
||||
} else {
|
||||
session.SendMsg(string(this.module.GetType()), "battle", &pb.MoonfantasyBattleResp{Code: cd})
|
||||
}
|
||||
|
||||
}()
|
||||
|
||||
if cd = this.BattleCheck(session, req); cd != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
if mdata, err = this.module.modelDream.querymfantasy(req.Mid); err != nil {
|
||||
cd = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
if mdata == nil {
|
||||
cd = pb.ErrorCode_MoonfantasyHasExpired
|
||||
return
|
||||
}
|
||||
if this.module.modelDream.checkMFantasyExpiration(mdata) { //已过期
|
||||
cd = pb.ErrorCode_MoonfantasyHasExpired
|
||||
return
|
||||
}
|
||||
for _, v := range mdata.Join {
|
||||
if v.Uid == session.GetUserId() {
|
||||
isjoin = true
|
||||
}
|
||||
}
|
||||
if !isjoin {
|
||||
cd = pb.ErrorCode_MoonfantasyNoJoin
|
||||
return
|
||||
}
|
||||
// if umfantasy, err = this.module.modelUserMF.queryUsermfantasy(session.GetUserId()); err != nil {
|
||||
// cd = pb.ErrorCode_CacheReadError
|
||||
// }
|
||||
|
||||
// if umfantasy.Ticket < this.module.ModuleTools.GetGlobalConf().DreamlandCos {
|
||||
// cd = pb.ErrorCode_MoonfantasyNotEnoughbattles
|
||||
// }
|
||||
// umfantasy.Ticket -= this.module.ModuleTools.GetGlobalConf().DreamlandCos
|
||||
if boss, err = this.module.configure.GetMonsterById(mdata.Monster); err != nil {
|
||||
cd = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
}
|
||||
if cd = this.module.ModuleItems.RecoverTicket(session); cd != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
if cd = this.module.CheckRes(session, boss.PsConsume); cd != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
|
||||
if len(mdata.Join) >= int(mdata.Numup) {
|
||||
cd = pb.ErrorCode_MoonfantasyJoinUp
|
||||
return
|
||||
}
|
||||
|
||||
if this.module.modelDream.checkMFantasyExpiration(mdata) { //已过期
|
||||
cd = pb.ErrorCode_MoonfantasyHasExpired
|
||||
return
|
||||
}
|
||||
if v, ok := mdata.Record[session.GetUserId()]; ok {
|
||||
if v >= mdata.Unitmup {
|
||||
cd = pb.ErrorCode_MoonfantasyDareUp
|
||||
return
|
||||
} else {
|
||||
mdata.Record[session.GetUserId()]++
|
||||
}
|
||||
} else {
|
||||
mdata.Record[session.GetUserId()] = 1
|
||||
}
|
||||
|
||||
cd, record = this.module.battle.CreatePveBattle(session, &pb.BattlePVEReq{
|
||||
Ptype: pb.PlayType_moonfantasy,
|
||||
Format: req.Battle,
|
||||
Mformat: boss.Monsterformatid,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
@ -38,15 +38,15 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.MoonfantasyBuyReq) (
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data = &pb.ErrorData{
|
||||
Title: code.ToString(),
|
||||
Message: comm.NewNotFoundConfErr(modelName, "global.json", "CopsBuyGet").Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if info, err = this.module.modelUserMF.queryUsermfantasy(session.GetUserId()); err != nil && err != mgo.MongodbNil {
|
||||
code = pb.ErrorCode_CacheReadError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_CacheReadError,
|
||||
Title: pb.ErrorCode_CacheReadError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
this.module.modelUserMF.recoverTicket(session, info)
|
||||
@ -64,7 +64,11 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.MoonfantasyBuyReq) (
|
||||
for i := int32(0); i < req.BuyNum; i++ {
|
||||
|
||||
if int(info.BuyNum+i+1) > maxbuy+vipbuy {
|
||||
code = pb.ErrorCode_ArenaTicketBuyUp
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ArenaTicketBuyUp,
|
||||
Title: pb.ErrorCode_ArenaTicketBuyUp.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if challengeD, err = this.module.configure.GetchallengeData(info.BuyNum + i + 1); err != nil || challengeD == nil {
|
||||
|
@ -20,16 +20,20 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.MoonfantasyGetLi
|
||||
mfantasys []*pb.DBMoonFantasy = make([]*pb.DBMoonFantasy, 0)
|
||||
)
|
||||
if info, err = this.module.modelUserMF.queryUsermfantasy(session.GetUserId()); err != nil && err != mgo.MongodbNil {
|
||||
code = pb.ErrorCode_CacheReadError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_CacheReadError,
|
||||
Title: pb.ErrorCode_CacheReadError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
// this.module.modelUserMF.recoverTicket(session, info)
|
||||
// if err = this.module.modelUserMF.updateUserInfo(info); err != nil {
|
||||
// errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
// Code: pb.ErrorCode_DBError,
|
||||
// Title: pb.ErrorCode_DBError.ToString(),
|
||||
// Message: err.Error(),
|
||||
// }
|
||||
// return
|
||||
// }
|
||||
this.module.ModuleItems.RecoverTicket(session)
|
||||
|
@ -36,7 +36,7 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.MoonfantasyRecei
|
||||
}
|
||||
return
|
||||
}
|
||||
if code, iswin = this.module.battle.CheckBattleReport(session, req.Report); errdata != nil {
|
||||
if errdata, iswin = this.module.battle.CheckBattleReport(session, req.Report); errdata != nil {
|
||||
return
|
||||
}
|
||||
if !iswin {
|
||||
|
@ -202,10 +202,10 @@ func (this *modelDreamComp) noticeuserfriend(session comm.IUserSession, mid stri
|
||||
)
|
||||
// if model, err = this.module.GetDBNodule(session, comm.TableFriend, 0); err != nil {
|
||||
// errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
// Code: pb.ErrorCode_DBError,
|
||||
// Title: pb.ErrorCode_DBError.ToString(),
|
||||
// Message: err.Error(),
|
||||
// }
|
||||
// this.module.Errorf("session:%v err:%v", session, err)
|
||||
// return
|
||||
// }
|
||||
|
@ -43,7 +43,11 @@ func (this *apiComp) Invite(session comm.IUserSession, req *pb.ParkourInviteReq)
|
||||
return
|
||||
}
|
||||
if info.Captainid != "" && info.Captainid != session.GetUserId() { //自己不是队长 无权邀请他人
|
||||
code = pb.ErrorCode_ParkourInviteNoPermissions
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ParkourInviteNoPermissions,
|
||||
Title: pb.ErrorCode_ParkourInviteNoPermissions.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if len(info.Member) > 3 {
|
||||
@ -54,7 +58,10 @@ func (this *apiComp) Invite(session comm.IUserSession, req *pb.ParkourInviteReq)
|
||||
return
|
||||
}
|
||||
if tuser = this.module.ModuleUser.GetUser(session.GetUserId()); tuser == nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SystemError,
|
||||
Title: pb.ErrorCode_SystemError.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if mount, err = this.module.configure.getGameBuzkashiMount(info.Dfmount); err != nil {
|
||||
@ -85,7 +92,10 @@ func (this *apiComp) Invite(session comm.IUserSession, req *pb.ParkourInviteReq)
|
||||
return
|
||||
}
|
||||
if tuser = this.module.ModuleUser.GetUser(req.Uid); tuser == nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SystemError,
|
||||
Title: pb.ErrorCode_SystemError.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if mount, err = this.module.configure.getGameBuzkashiMount(tinfo.Dfmount); err != nil {
|
||||
@ -112,7 +122,10 @@ func (this *apiComp) Invite(session comm.IUserSession, req *pb.ParkourInviteReq)
|
||||
&pb.ParkourTeamChanagePush{Team: info}, users...)
|
||||
} else {
|
||||
if tinfo.Captainid != "" {
|
||||
code = pb.ErrorCode_ParkourTargetTeamed
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ParkourTargetTeamed,
|
||||
Title: pb.ErrorCode_ParkourTargetTeamed.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
ok = false
|
||||
|
@ -47,7 +47,10 @@ func (this *apiComp) InviteHandle(session comm.IUserSession, req *pb.ParkourInvi
|
||||
return
|
||||
}
|
||||
if len(tean.Member) >= 3 {
|
||||
code = pb.ErrorCode_ParkourMemberFull
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ParkourMemberFull,
|
||||
Title: pb.ErrorCode_ParkourMemberFull.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if req.State == 3 {
|
||||
@ -60,7 +63,10 @@ func (this *apiComp) InviteHandle(session comm.IUserSession, req *pb.ParkourInvi
|
||||
}
|
||||
}
|
||||
if !ok {
|
||||
code = pb.ErrorCode_ParkourInviteOverdue
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ParkourInviteOverdue,
|
||||
Title: pb.ErrorCode_ParkourInviteOverdue.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
tean.Invite = append(tean.Invite[0:index], tean.Invite[index+1:]...)
|
||||
|
@ -42,12 +42,20 @@ func (this *apiComp) JoinTeam(session comm.IUserSession, req *pb.ParkourJoinTeam
|
||||
}
|
||||
// 状态校验
|
||||
if info.State != pb.RaceTeamState_resting { // 不是休息中不能参加
|
||||
code = pb.ErrorCode_StateInvalid
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_StateInvalid,
|
||||
Title: pb.ErrorCode_StateInvalid.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if len(info.Member) > 3 {
|
||||
code = pb.ErrorCode_ParkourMemberFull
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ParkourMemberFull,
|
||||
Title: pb.ErrorCode_ParkourMemberFull.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if tean, err = this.module.parkourComp.queryinfo(req.Uid); err != nil {
|
||||
@ -62,7 +70,12 @@ func (this *apiComp) JoinTeam(session comm.IUserSession, req *pb.ParkourJoinTeam
|
||||
users = make([]string, len(tean.Member))
|
||||
for i, v := range tean.Member {
|
||||
if v.Uid == session.GetUserId() {
|
||||
code = pb.ErrorCode_ParkourTargetTeamed // 自己已经在队伍中
|
||||
// 自己已经在队伍中
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ParkourTargetTeamed,
|
||||
Title: pb.ErrorCode_ParkourTargetTeamed.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
users[i] = v.Uid
|
||||
|
@ -48,7 +48,10 @@ func (this *apiComp) RaceMatch(session comm.IUserSession, req *pb.ParkourRaceMat
|
||||
team.Captainid = team.Uid
|
||||
team.State = pb.RaceTeamState_teaming
|
||||
if tuser = this.module.ModuleUser.GetUser(session.GetUserId()); tuser == nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SystemError,
|
||||
Title: pb.ErrorCode_SystemError.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if mount, err = this.module.configure.getGameBuzkashiMount(team.Dfmount); err != nil {
|
||||
|
@ -47,7 +47,11 @@ func (this *apiComp) DailyBuy(session comm.IUserSession, req *pb.PayDailyBuyReq)
|
||||
}
|
||||
if info.Items[conf.Id] != nil {
|
||||
if info.Items[conf.Id].Buyunm <= 0 {
|
||||
code = pb.ErrorCode_PayBuyNumNotEnough
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_PayBuyNumNotEnough,
|
||||
Title: pb.ErrorCode_PayBuyNumNotEnough.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -58,7 +62,7 @@ func (this *apiComp) DailyBuy(session comm.IUserSession, req *pb.PayDailyBuyReq)
|
||||
}
|
||||
}
|
||||
|
||||
if code, items = this.module.modelDaily.delivery(session, conf.Packagetype); errdata != nil {
|
||||
if errdata, items = this.module.modelDaily.delivery(session, conf.Packagetype); errdata != nil {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,6 @@ func (this *apiComp) Delivery(session comm.IUserSession, req *pb.PayDeliveryReq)
|
||||
this.module.Errorln(err)
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), "delivery", &pb.PayDeliveryResp{Code: code})
|
||||
session.SendMsg(string(this.module.GetType()), "delivery", &pb.PayDeliveryResp{})
|
||||
return
|
||||
}
|
||||
|
@ -77,6 +77,7 @@ func (this *Pay) Rpc_ModulePayDelivery(ctx context.Context, args *pb.PayDelivery
|
||||
res []*cfg.Gameatn
|
||||
items []*pb.UserAssets
|
||||
session comm.IUserSession
|
||||
errdata *pb.ErrorData
|
||||
online bool
|
||||
)
|
||||
|
||||
@ -98,12 +99,14 @@ func (this *Pay) Rpc_ModulePayDelivery(ctx context.Context, args *pb.PayDelivery
|
||||
this.PutUserSession(session)
|
||||
}()
|
||||
if session, online = this.GetUserSession(args.Uid); online {
|
||||
if reply.Code = this.DispenseRes(session, res, true); reply.Code != pb.ErrorCode_Success {
|
||||
if errdata = this.DispenseRes(session, res, true); errdata != nil {
|
||||
reply.Code = errdata.Code
|
||||
return
|
||||
}
|
||||
|
||||
} else {
|
||||
if reply.Code = this.DispenseRes(session, res, false); reply.Code != pb.ErrorCode_Success {
|
||||
if errdata = this.DispenseRes(session, res, false); errdata != nil {
|
||||
reply.Code = errdata.Code
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -122,10 +125,16 @@ func (this *Pay) Rpc_ModulePayDelivery(ctx context.Context, args *pb.PayDelivery
|
||||
case 1:
|
||||
break
|
||||
case 2:
|
||||
reply.Code, items = this.modelDaily.delivery(session, args.Productid)
|
||||
if errdata, items = this.modelDaily.delivery(session, args.Productid); errdata != nil {
|
||||
reply.Code = errdata.Code
|
||||
return
|
||||
}
|
||||
break
|
||||
case 3:
|
||||
reply.Code, items = this.privilege.Delivery(session, args.Productid)
|
||||
if errdata, items = this.privilege.Delivery(session, args.Productid); errdata != nil {
|
||||
reply.Code = errdata.Code
|
||||
return
|
||||
}
|
||||
break
|
||||
}
|
||||
for _, v := range res {
|
||||
@ -204,10 +213,14 @@ func (this *Pay) ModulePayDelivery(session comm.IUserSession, Productid string,
|
||||
case 1:
|
||||
break
|
||||
case 2:
|
||||
code, items = this.modelDaily.delivery(session, Productid)
|
||||
if errdata, items = this.modelDaily.delivery(session, Productid); errdata != nil {
|
||||
return
|
||||
}
|
||||
break
|
||||
case 3:
|
||||
code, items = this.privilege.Delivery(session, Productid)
|
||||
if errdata, items = this.privilege.Delivery(session, Productid); errdata != nil {
|
||||
return
|
||||
}
|
||||
break
|
||||
}
|
||||
for _, v := range res {
|
||||
|
@ -49,14 +49,20 @@ func (this *apiComp) Accept(session comm.IUserSession, req *pb.PracticeAcceptReq
|
||||
return
|
||||
}
|
||||
if redRecord.Status == 1 { //已经在战斗中了
|
||||
code = pb.ErrorCode_PracticeQiecuoing
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_PracticeQiecuoing,
|
||||
Title: pb.ErrorCode_PracticeQiecuoing.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
keep = false
|
||||
for _, v := range redRecord.Targets {
|
||||
if v.Uid == session.GetUserId() {
|
||||
if configure.Now().Sub(time.Unix(v.Timestamp, 0)).Seconds() > 10 {
|
||||
code = pb.ErrorCode_PracticeInviteTimeOut
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_PracticeInviteTimeOut,
|
||||
Title: pb.ErrorCode_PracticeInviteTimeOut.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
keep = true
|
||||
@ -73,22 +79,28 @@ func (this *apiComp) Accept(session comm.IUserSession, req *pb.PracticeAcceptReq
|
||||
//发起者 red
|
||||
red := this.module.ModuleUser.GetUser(req.Uid)
|
||||
if red == nil {
|
||||
code = pb.ErrorCode_UserNofound
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_UserNofound,
|
||||
Title: pb.ErrorCode_UserNofound.ToString(),
|
||||
}
|
||||
this.module.Error("未找到红方信息", log.Field{Key: "uid", Value: req.Uid})
|
||||
return
|
||||
}
|
||||
blue := this.module.ModuleUser.GetUser(session.GetUserId())
|
||||
if blue == nil {
|
||||
code = pb.ErrorCode_UserNofound
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_UserNofound,
|
||||
Title: pb.ErrorCode_UserNofound.ToString(),
|
||||
}
|
||||
this.module.Error("未找到蓝方信息", log.Field{Key: "uid", Value: session.GetUserId()})
|
||||
return
|
||||
}
|
||||
if redRecord.Battid, code = this.module.pvp.CreatePvp(
|
||||
if redRecord.Battid, errdata = this.module.pvp.CreatePvp(
|
||||
&pb.PvpUserInfo{Uid: red.Uid, Name: red.Name, Avatar: red.Avatar, Lv: red.Lv},
|
||||
&pb.PvpUserInfo{Uid: blue.Uid, Name: blue.Name, Avatar: blue.Avatar, Lv: blue.Lv},
|
||||
pb.PvpType_friends,
|
||||
); errdata != nil {
|
||||
this.module.Error("CreatePvp", log.Field{Key: "code", Value: code})
|
||||
this.module.Error("CreatePvp", log.Field{Key: "code", Value: errdata})
|
||||
return
|
||||
}
|
||||
redRecord.Status = 1
|
||||
@ -109,7 +121,11 @@ func (this *apiComp) Accept(session comm.IUserSession, req *pb.PracticeAcceptReq
|
||||
if err := session.SendMsg(string(this.module.GetType()), "accept", &pb.FriendAcceptResp{
|
||||
IsSucc: true,
|
||||
}); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SystemError,
|
||||
Title: pb.ErrorCode_SystemError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ func (this *apiComp) Expulsion(session comm.IUserSession, req *pb.PracticeExpuls
|
||||
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 hero, errdata := this.module.ModuleHero.GetHeroByObjID(session.GetUserId(), pillar.Hero); errdata == 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
|
||||
@ -196,7 +196,7 @@ func (this *apiComp) Expulsion(session comm.IUserSession, req *pb.PracticeExpuls
|
||||
}
|
||||
}
|
||||
_session, ok = this.module.GetUserSession(pillar.Uid)
|
||||
if _, code = this.module.ModuleHero.AddHeroExp(_session, pillar.Hero, exp); errdata != nil {
|
||||
if _, errdata = this.module.ModuleHero.AddHeroExp(_session, pillar.Hero, exp); errdata != nil {
|
||||
return
|
||||
}
|
||||
if errdata = this.module.ModuleHero.KungFuHero(_session, pillar.Hero, false, ""); errdata != nil {
|
||||
|
@ -67,7 +67,11 @@ func (this *apiComp) GymRefresh(session comm.IUserSession, req *pb.PracticeGymRe
|
||||
}
|
||||
}
|
||||
if len(confs) == 0 {
|
||||
code = pb.ErrorCode_ConfigurationException
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigurationException,
|
||||
Title: pb.ErrorCode_ConfigurationException.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
r := rand.New(rand.NewSource(configure.Now().Unix()))
|
||||
|
@ -27,7 +27,7 @@ func (this *apiComp) NPCBattkle(session comm.IUserSession, req *pb.PracticeNPCBa
|
||||
return
|
||||
}
|
||||
|
||||
if code, record = this.module.battle.CreateLPVEBattle(session, &pb.BattleLPVEReq{
|
||||
if errdata, record = this.module.battle.CreateLPVEBattle(session, &pb.BattleLPVEReq{
|
||||
Ptype: pb.PlayType_practicenpc,
|
||||
Format: req.Formation,
|
||||
Monsterleadpos: room.Captain,
|
||||
|
@ -36,7 +36,7 @@ func (this *apiComp) NPCBattkleFinish(session comm.IUserSession, req *pb.Practic
|
||||
return
|
||||
}
|
||||
|
||||
if code, _ = this.module.battle.CheckBattleReport(session, req.Report); errdata != nil {
|
||||
if errdata, _ = this.module.battle.CheckBattleReport(session, req.Report); errdata != nil {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -20,25 +20,25 @@ func (this *apiComp) NPCDialog(session comm.IUserSession, req *pb.PracticeNPCDia
|
||||
// )
|
||||
// if room, err = this.module.modelPandata.queryUserMartialhall(session.GetUserId()); err != nil {
|
||||
// errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
// Code: pb.ErrorCode_DBError,
|
||||
// Title: pb.ErrorCode_DBError.ToString(),
|
||||
// Message: err.Error(),
|
||||
// }
|
||||
// return
|
||||
// }
|
||||
// if room.Npcstate != 2 {
|
||||
// errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
}
|
||||
// Code: pb.ErrorCode_ReqParameterError,
|
||||
// Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
// }
|
||||
// return
|
||||
// }
|
||||
// // if conf, err = this.module.configure.getDispatchBattleData(room.Currnpc); err != nil {
|
||||
// // errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
// Code: pb.ErrorCode_ConfigNoFound,
|
||||
// Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
// Message: err.Error(),
|
||||
// }
|
||||
// // return
|
||||
// // }
|
||||
// // if errdata = this.module.DispenseRes(session, conf.StoryAward, true); errdata != nil {
|
||||
|
@ -54,27 +54,43 @@ func (this *apiComp) Qiecuo(session comm.IUserSession, req *pb.PracticeQiecuoReq
|
||||
if result.Battid == fresult.Battid { //两个人正在战斗中
|
||||
if battle, err = this.module.pvp.QueryBattle(result.Battid); err != nil {
|
||||
this.module.Error("查询pvp数据失败!", log.Field{Key: "id", Value: result.Battid}, log.Field{Key: "err", Value: err.Error()})
|
||||
code = pb.ErrorCode_SystemError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SystemError,
|
||||
Title: pb.ErrorCode_SystemError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if err = session.SendMsg(string(this.module.GetType()), "qiecuo", &pb.PracticeQiecuoResp{Fid: req.Fid, Isbattle: true, Battle: battle}); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SystemError,
|
||||
Title: pb.ErrorCode_SystemError.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
return
|
||||
} else {
|
||||
if result.Status == 1 {
|
||||
code = pb.ErrorCode_PracticeYouQiecuoing
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_PracticeYouQiecuoing,
|
||||
Title: pb.ErrorCode_PracticeYouQiecuoing.ToString(),
|
||||
}
|
||||
return
|
||||
} else {
|
||||
code = pb.ErrorCode_PracticeTargetQiecuoing
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_PracticeTargetQiecuoing,
|
||||
Title: pb.ErrorCode_PracticeTargetQiecuoing.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
//目标是否在线
|
||||
if !this.module.ModuleUser.IsOnline(req.Fid) {
|
||||
code = pb.ErrorCode_UserOffline
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_UserOffline,
|
||||
Title: pb.ErrorCode_UserOffline.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -94,7 +110,10 @@ func (this *apiComp) Qiecuo(session comm.IUserSession, req *pb.PracticeQiecuoReq
|
||||
if configure.Now().Sub(time.Unix(v.Timestamp, 0)).Seconds() > 10 {
|
||||
v.Timestamp = configure.Now().Unix()
|
||||
} else {
|
||||
code = pb.ErrorCode_PracticeSent
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_PracticeSent,
|
||||
Title: pb.ErrorCode_PracticeSent.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -110,7 +129,10 @@ func (this *apiComp) Qiecuo(session comm.IUserSession, req *pb.PracticeQiecuoReq
|
||||
})
|
||||
|
||||
if err = session.SendMsg(string(this.module.GetType()), "qiecuo", &pb.PracticeQiecuoResp{Fid: req.Fid}); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SystemError,
|
||||
Title: pb.ErrorCode_SystemError.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -235,7 +235,7 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.PracticeReceiveR
|
||||
}
|
||||
}
|
||||
this.module.Debug("最终经验加成", log.Field{Key: "exp", Value: exp}, log.Field{Key: "exp1", Value: exp1})
|
||||
if _, code = this.module.ModuleHero.AddHeroExp(session, pillar.Hero, exp1); errdata != nil {
|
||||
if _, errdata = this.module.ModuleHero.AddHeroExp(session, pillar.Hero, exp1); errdata != nil {
|
||||
return
|
||||
}
|
||||
if errdata = this.module.DispenseRes(session, append(ants1, ants2...), true); errdata != nil {
|
||||
|
@ -73,7 +73,11 @@ func (this *apiComp) Refuse(session comm.IUserSession, req *pb.PracticeRefuseReq
|
||||
if err := session.SendMsg(string(this.module.GetType()), "refuse", &pb.PracticeRefuseResp{
|
||||
IsSucc: true,
|
||||
}); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SystemError,
|
||||
Title: pb.ErrorCode_SystemError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,10 @@ func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.PracticeUpgradeR
|
||||
return
|
||||
}
|
||||
if pillarconfigure, err = this.module.configure.getGamePandamasMz(pillar.Lv); err != nil || len(pillarconfigure.UpLvConsume) == 0 {
|
||||
code = pb.ErrorCode_PracticePillarMaxLv
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_PracticePillarMaxLv,
|
||||
Title: pb.ErrorCode_PracticePillarMaxLv.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ func (this *modelPandata) refreshnpc(room *pb.DBPracticeRoom) (err error) {
|
||||
npcs []*cfg.GameDispatch_BattleData
|
||||
wigets []int32
|
||||
index int32
|
||||
code pb.ErrorCode
|
||||
errdata *pb.ErrorData
|
||||
)
|
||||
|
||||
if npcs, err = this.module.configure.getDispatchBattle(); err != nil {
|
||||
@ -134,8 +134,8 @@ func (this *modelPandata) refreshnpc(room *pb.DBPracticeRoom) (err error) {
|
||||
room.Currnpc = npcs[index].Id
|
||||
room.Npcstate = 0
|
||||
room.Battlenum = 0
|
||||
if room.Captain, room.Formation, code = this.module.battle.CreateRolesByFormat(npcs[index].MonsterformatId); errdata != nil {
|
||||
err = fmt.Errorf("CreateRolesByFormat fail:%d", code)
|
||||
if room.Captain, room.Formation, errdata = this.module.battle.CreateRolesByFormat(npcs[index].MonsterformatId); errdata != nil {
|
||||
err = fmt.Errorf("CreateRolesByFormat fail:%+v", errdata)
|
||||
return
|
||||
}
|
||||
return
|
||||
|
@ -51,7 +51,10 @@ func (this *apiComp) ActiveCancel(session comm.IUserSession, req *pb.PvpActiveCa
|
||||
}
|
||||
}
|
||||
} else {
|
||||
code = pb.ErrorCode_BattleInCmdFailed
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_BattleInCmdFailed,
|
||||
Title: pb.ErrorCode_BattleInCmdFailed.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -18,14 +18,9 @@ func (this *apiComp) InCmd(session comm.IUserSession, req *pb.PvpInCmdReq) (errd
|
||||
battle *BattleItem
|
||||
side int32
|
||||
ok bool
|
||||
cd pb.ErrorCode
|
||||
)
|
||||
|
||||
defer func() {
|
||||
session.SendMsg(string(this.module.GetType()), "incmd", &pb.PvpInCmdResp{Code: cd, Battleid: req.Battleid, Cmd: req.Cmd})
|
||||
}()
|
||||
|
||||
if cd = this.InCmdCheck(session, req); cd != pb.ErrorCode_Success {
|
||||
if errdata = this.InCmdCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
this.module.lock.RLock()
|
||||
@ -50,11 +45,11 @@ func (this *apiComp) InCmd(session comm.IUserSession, req *pb.PvpInCmdReq) (errd
|
||||
return
|
||||
}
|
||||
//技能释放指令
|
||||
if cd = this.module.battle.InCmdBattle(&pb.BattleInCmdReq{
|
||||
if errdata = this.module.battle.InCmdBattle(&pb.BattleInCmdReq{
|
||||
Battleid: req.Battleid,
|
||||
Side: side,
|
||||
In: req.Cmd,
|
||||
}); cd != pb.ErrorCode_Success {
|
||||
}); errdata != nil {
|
||||
return
|
||||
} else {
|
||||
if battle.operatetimer != nil {
|
||||
@ -62,9 +57,13 @@ func (this *apiComp) InCmd(session comm.IUserSession, req *pb.PvpInCmdReq) (errd
|
||||
}
|
||||
}
|
||||
} else {
|
||||
cd = pb.ErrorCode_BattleInCmdFailed
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_BattleInCmdFailed,
|
||||
Title: pb.ErrorCode_BattleInCmdFailed.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), "incmd", &pb.PvpInCmdResp{Battleid: req.Battleid, Cmd: req.Cmd})
|
||||
return
|
||||
}
|
||||
|
@ -15,7 +15,6 @@ func (this *apiComp) Into(session comm.IUserSession, req *pb.PvpIntoReq) (errdat
|
||||
var (
|
||||
battle *BattleItem
|
||||
resp *pb.BattleGetInfoResp = &pb.BattleGetInfoResp{}
|
||||
cd pb.ErrorCode
|
||||
ok bool
|
||||
)
|
||||
if errdata = this.IntoCheck(session, req); errdata != nil {
|
||||
@ -25,9 +24,12 @@ func (this *apiComp) Into(session comm.IUserSession, req *pb.PvpIntoReq) (errdat
|
||||
battle, ok = this.module.battles[req.Battleid]
|
||||
this.module.lock.RUnlock()
|
||||
if ok {
|
||||
if cd, resp = this.module.battle.GetBattleInfo(&pb.BattleGetInfoReq{
|
||||
if errdata, resp = this.module.battle.GetBattleInfo(&pb.BattleGetInfoReq{
|
||||
Battleid: req.Battleid,
|
||||
}); cd == pb.ErrorCode_Success {
|
||||
}); errdata != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
battle.lock.Lock()
|
||||
if session.GetUserId() == battle.Red.Uid {
|
||||
battle.RedOffline = false
|
||||
@ -37,11 +39,6 @@ func (this *apiComp) Into(session comm.IUserSession, req *pb.PvpIntoReq) (errdat
|
||||
battle.BlueSession.SetSession(session.GetIP(), session.GetSessionId(), session.GetServiecTag(), session.GetGatewayServiceId(), session.GetUserId())
|
||||
}
|
||||
battle.lock.Unlock()
|
||||
}
|
||||
} else {
|
||||
cd = pb.ErrorCode_BattleInCmdFailed
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), "into", &pb.PvpIntoResp{Code: cd, Battleid: req.Battleid, Info: resp.Info})
|
||||
session.SendMsg(string(this.module.GetType()), "into", &pb.PvpIntoResp{Battleid: req.Battleid, Info: resp.Info})
|
||||
return
|
||||
}
|
||||
|
@ -43,7 +43,10 @@ func (this *apiComp) LoadComplete(session comm.IUserSession, req *pb.PvpLoadComp
|
||||
}
|
||||
}
|
||||
} else {
|
||||
code = pb.ErrorCode_BattleNoKeep
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_BattleNoKeep,
|
||||
Title: pb.ErrorCode_BattleNoKeep.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), "into", &pb.PvpLoadCompleteResp{Battleid: req.Battleid, Issucc: true})
|
||||
|
@ -100,11 +100,17 @@ func (this *Pvp) CreatePvp(red, blue *pb.PvpUserInfo, ptype pb.PvpType) (battleI
|
||||
}
|
||||
|
||||
if battle.RedSession, ok = this.GetUserSession(red.Uid); !ok {
|
||||
code = pb.ErrorCode_BattleUserOff
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_BattleUserOff,
|
||||
Title: pb.ErrorCode_BattleUserOff.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if battle.BlueSession, ok = this.GetUserSession(blue.Uid); !ok {
|
||||
code = pb.ErrorCode_BattleUserOff
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_BattleUserOff,
|
||||
Title: pb.ErrorCode_BattleUserOff.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
this.lock.Lock()
|
||||
@ -118,7 +124,10 @@ func (this *Pvp) CreatePvp(red, blue *pb.PvpUserInfo, ptype pb.PvpType) (battleI
|
||||
Countdown: 60,
|
||||
}, battle.RedSession, battle.BlueSession); err != nil {
|
||||
this.Errorln(err)
|
||||
code = pb.ErrorCode_RpcFuncExecutionError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_RpcFuncExecutionError,
|
||||
Title: pb.ErrorCode_RpcFuncExecutionError.ToString(),
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -129,8 +138,8 @@ func (this *Pvp) PvpOutCmdPush(out *pb.PvpOutCmdPush) {
|
||||
var (
|
||||
battle *BattleItem
|
||||
ok bool
|
||||
errdata *pb.ErrorData
|
||||
data []byte
|
||||
code pb.ErrorCode
|
||||
err error
|
||||
)
|
||||
this.lock.RLock()
|
||||
@ -266,7 +275,7 @@ func (this *Pvp) operateTimeOut(task *timewheel.Task, args ...interface{}) {
|
||||
id string
|
||||
battle *BattleItem
|
||||
ok bool
|
||||
code pb.ErrorCode
|
||||
errdata *pb.ErrorData
|
||||
data []byte
|
||||
)
|
||||
id = args[0].(string)
|
||||
@ -296,10 +305,10 @@ func (this *Pvp) startBattle(battle *BattleItem) {
|
||||
var (
|
||||
record *pb.DBBattleRecord
|
||||
info *pb.BattleInfo
|
||||
code pb.ErrorCode
|
||||
errdata *pb.ErrorData
|
||||
err error
|
||||
)
|
||||
if code, record = this.battle.CreateRtPvpBattle(&pb.BattleRTPVPReq{
|
||||
if errdata, record = this.battle.CreateRtPvpBattle(&pb.BattleRTPVPReq{
|
||||
Ptype: pb.PlayType_friendsmeet,
|
||||
Title: "",
|
||||
RedCompId: battle.Red.Uid,
|
||||
@ -316,6 +325,7 @@ func (this *Pvp) startBattle(battle *BattleItem) {
|
||||
}, battle.RedSession, battle.BlueSession); err != nil {
|
||||
this.Errorln(err)
|
||||
}
|
||||
return
|
||||
} else {
|
||||
record.Id = battle.Id
|
||||
info = &pb.BattleInfo{
|
||||
@ -445,7 +455,7 @@ func (this *Pvp) trusteeship(ctx context.Context, req *pb.RPC_PVPTrusteeshipReq,
|
||||
ok bool
|
||||
side int32
|
||||
data []byte
|
||||
code pb.ErrorCode
|
||||
errdata *pb.ErrorData
|
||||
)
|
||||
for _, bid := range req.Battleid {
|
||||
this.lock.RLock()
|
||||
|
@ -36,7 +36,11 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.ShopBuyReq) (errdata
|
||||
}
|
||||
|
||||
if conf, err = this.module.configure.GetShopItemsConfigure(req.GoodsId); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SystemError,
|
||||
Title: pb.ErrorCode_SystemError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if shopData, err = this.module.modelShop.QueryUserShopData(session.GetUserId()); err != nil { //没有购买记录
|
||||
@ -107,7 +111,11 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.ShopBuyReq) (errdata
|
||||
}
|
||||
}
|
||||
if conf.Buyminnum-record.Buy[req.GoodsId] < req.BuyNum {
|
||||
code = pb.ErrorCode_ShopGoodsIsSoldOut
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ShopGoodsIsSoldOut,
|
||||
Title: pb.ErrorCode_ShopGoodsIsSoldOut.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
record.Buy[req.GoodsId] += req.BuyNum
|
||||
|
@ -55,7 +55,10 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq)
|
||||
return
|
||||
}
|
||||
if udata = this.module.ModuleUser.GetUser(session.GetUserId()); udata == nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SystemError,
|
||||
Title: pb.ErrorCode_SystemError.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -137,7 +140,10 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq)
|
||||
if !isrefresh {
|
||||
//剩余刷新次数为零
|
||||
if leftrefnum == 0 {
|
||||
code = pb.ErrorCode_ShopNoSurplusRefreshNum
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ShopNoSurplusRefreshNum,
|
||||
Title: pb.ErrorCode_ShopNoSurplusRefreshNum.ToString(),
|
||||
}
|
||||
return
|
||||
} else if leftrefnum > 0 {
|
||||
leftrefnum--
|
||||
@ -151,9 +157,9 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq)
|
||||
var _items []*cfg.GameShopitemData
|
||||
for _, v := range shopconf.Shopitem {
|
||||
if _items, err = this.module.configure.GetShopItemsConfigureByGroups(v, udata); err != nil || len(_items) == 0 {
|
||||
code = pb.ErrorCode_SystemError
|
||||
data = &pb.ErrorData{
|
||||
Title: pb.GetErrorCodeMsg(code),
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SystemError,
|
||||
Title: pb.ErrorCode_SystemError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
@ -169,7 +175,7 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq)
|
||||
for i, v := range items {
|
||||
sdata.Items[i] = v.Key
|
||||
if v.Preview { //是否预览
|
||||
if code, sdata.Preview[v.Key] = this.module.equip.NewEquipment(session.GetUserId(), v.Iteminfo[0].T); errdata != nil {
|
||||
if errdata, sdata.Preview[v.Key] = this.module.equip.NewEquipment(session.GetUserId(), v.Iteminfo[0].T); errdata != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -198,7 +204,11 @@ 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 {
|
||||
this.module.Error("no founf shopgroup", log.Field{Key: "gid", Value: v})
|
||||
code = pb.ErrorCode_SystemError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SystemError,
|
||||
Title: pb.ErrorCode_SystemError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
items = append(items, randomGoods(_items))
|
||||
@ -210,7 +220,7 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq)
|
||||
for i, v := range items {
|
||||
sdata.Items[i] = v.Key
|
||||
if v.Preview { //是否预览
|
||||
if code, sdata.Preview[v.Key] = this.module.equip.NewEquipment(session.GetUserId(), v.Iteminfo[0].T); errdata != nil {
|
||||
if errdata, sdata.Preview[v.Key] = this.module.equip.NewEquipment(session.GetUserId(), v.Iteminfo[0].T); errdata != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -221,7 +231,11 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq)
|
||||
go this.module.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.Rtype105, 1))
|
||||
} else { //返回以前的商品列表
|
||||
if items, err = this.module.configure.GetShopItemsConfigureByIds(sdata.Items...); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SystemError,
|
||||
Title: pb.ErrorCode_SystemError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
goods = transGoods(items, sdata)
|
||||
|
@ -18,17 +18,18 @@ func (this *Api_Comp) CreateNotify(c *engine.Context) {
|
||||
err := c.BindJSON(&req)
|
||||
this.module.Debugf("CreateNotify:%+v err:%v", req, err)
|
||||
var (
|
||||
code pb.ErrorCode
|
||||
msg string
|
||||
errdata *pb.ErrorData
|
||||
data interface{}
|
||||
)
|
||||
defer func() {
|
||||
c.JSON(http.StatusOK, &Respond{Code: code, Message: msg, Data: data})
|
||||
c.JSON(http.StatusOK, &Respond{Code: errdata.Code, Message: errdata.Message, Data: data})
|
||||
}()
|
||||
if sign := gin.ParamSign(this.options.Key, map[string]interface{}{"Title": req.Title, "Ctime": req.Ctime, "Rtime": req.Rtime}); sign != req.Sign {
|
||||
this.module.Errorf("LoginByCaptchaReq SignError sgin:%s", sign)
|
||||
code = pb.ErrorCode_SignError
|
||||
msg = pb.GetErrorCodeMsg(code)
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SignError,
|
||||
Title: pb.ErrorCode_SignError.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if len(req.Title) == 0 {
|
||||
@ -36,7 +37,6 @@ func (this *Api_Comp) CreateNotify(c *engine.Context) {
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
}
|
||||
msg = pb.GetErrorCodeMsg(code)
|
||||
return
|
||||
}
|
||||
if err = this.module.modelNotify.CreateSystemNotify(&req.DBSystemNotify); err != nil {
|
||||
@ -46,8 +46,10 @@ func (this *Api_Comp) CreateNotify(c *engine.Context) {
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
msg = pb.GetErrorCodeMsg(code)
|
||||
return
|
||||
}
|
||||
msg = pb.GetErrorCodeMsg(code)
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_Success,
|
||||
Title: pb.ErrorCode_Success.ToString(),
|
||||
}
|
||||
}
|
||||
|
@ -30,8 +30,7 @@ func (this *Api_Comp) CreateMail(c *engine.Context) {
|
||||
err := c.BindJSON(&req)
|
||||
this.module.Debugf("CrateMail:%+v err:%v", req, err)
|
||||
var (
|
||||
code pb.ErrorCode
|
||||
msg string
|
||||
errdata *pb.ErrorData
|
||||
data interface{}
|
||||
)
|
||||
if db.IsCross() { // 跨服服务器不能发邮件
|
||||
@ -39,10 +38,9 @@ func (this *Api_Comp) CreateMail(c *engine.Context) {
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
}
|
||||
msg = pb.GetErrorCodeMsg(code)
|
||||
return
|
||||
}
|
||||
defer c.JSON(http.StatusOK, &Respond{Code: code, Message: msg, Data: data})
|
||||
defer c.JSON(http.StatusOK, &Respond{Code: errdata.Code, Message: errdata.Message, Data: data})
|
||||
if sign := gin.ParamSign(this.options.Key, map[string]interface{}{
|
||||
"uid": req.Uid,
|
||||
"title": req.Title,
|
||||
@ -50,8 +48,10 @@ func (this *Api_Comp) CreateMail(c *engine.Context) {
|
||||
"cid": req.Cid,
|
||||
}); sign != req.Sign {
|
||||
this.module.Errorf("LoginByCaptchaReq SignError sgin:%s", sign)
|
||||
code = pb.ErrorCode_SignError
|
||||
msg = pb.GetErrorCodeMsg(code)
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SignError,
|
||||
Title: pb.ErrorCode_SignError.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -72,15 +72,20 @@ func (this *Api_Comp) CreateMail(c *engine.Context) {
|
||||
mail.Reward = true
|
||||
}
|
||||
|
||||
msg = pb.GetErrorCodeMsg(code)
|
||||
|
||||
if _, err = this.module.service.RpcGo(
|
||||
context.Background(),
|
||||
comm.Service_Worker,
|
||||
string(comm.Rpc_Mail),
|
||||
mail, nil); err != nil {
|
||||
this.module.Errorln(err)
|
||||
code = pb.ErrorCode_RpcFuncExecutionError
|
||||
msg = pb.GetErrorCodeMsg(code)
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_RpcFuncExecutionError,
|
||||
Title: pb.ErrorCode_RpcFuncExecutionError.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_Success,
|
||||
Title: pb.ErrorCode_Success.ToString(),
|
||||
}
|
||||
}
|
||||
|
@ -14,20 +14,18 @@ import (
|
||||
//上传配置文件
|
||||
func (this *Api_Comp) Upload(c *engine.Context) {
|
||||
var (
|
||||
code pb.ErrorCode
|
||||
msg string
|
||||
errdata *pb.ErrorData
|
||||
)
|
||||
defer func() {
|
||||
c.JSON(http.StatusOK, &Respond{
|
||||
Code: code,
|
||||
Message: msg,
|
||||
Code: errdata.Code,
|
||||
Message: errdata.Message,
|
||||
})
|
||||
}()
|
||||
filenum := c.PostForm("filenum")
|
||||
if filenum != "" {
|
||||
if n, err := strconv.Atoi(filenum); err != nil {
|
||||
this.module.Errorln(err)
|
||||
msg = err.Error()
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
@ -37,7 +35,6 @@ func (this *Api_Comp) Upload(c *engine.Context) {
|
||||
for i := 0; i < n; i++ {
|
||||
if fn, err := c.FormFile(fmt.Sprintf("file_%d", i)); err != nil {
|
||||
this.module.Errorln(err)
|
||||
msg = err.Error()
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
@ -46,7 +43,6 @@ func (this *Api_Comp) Upload(c *engine.Context) {
|
||||
} else {
|
||||
if err = c.SaveUploadedFile(fn, fmt.Sprintf("%s/%s", configure.ConfigurePath(), fn.Filename)); err != nil {
|
||||
this.module.Errorln(err)
|
||||
msg = err.Error()
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
@ -63,8 +59,10 @@ func (this *Api_Comp) Upload(c *engine.Context) {
|
||||
&pb.EmptyReq{},
|
||||
&pb.EmptyResp{}); err != nil {
|
||||
this.module.Errorln(err)
|
||||
msg = err.Error()
|
||||
code = pb.ErrorCode_RpcFuncExecutionError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_RpcFuncExecutionError,
|
||||
Title: pb.ErrorCode_RpcFuncExecutionError.ToString(),
|
||||
}
|
||||
}
|
||||
} else {
|
||||
errdata = &pb.ErrorData{
|
||||
@ -72,4 +70,8 @@ func (this *Api_Comp) Upload(c *engine.Context) {
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
}
|
||||
}
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_Success,
|
||||
Title: pb.ErrorCode_Success.ToString(),
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user