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