This commit is contained in:
meixiongfeng 2023-06-06 14:58:24 +08:00
commit c3b4c4c12a
114 changed files with 1964 additions and 1663 deletions

View File

@ -19,8 +19,26 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.AcademyChallen
record *pb.DBBattleRecord
err error
)
defer func() {
if errdata == nil {
if errdata = this.ChallengeCheck(session, req); errdata != nil {
return
}
if level, err = this.module.configure.getGameTeaching(req.Level); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Title: pb.ErrorCode_ConfigNoFound.ToString(),
}
return
}
if errdata, record = this.module.battle.CreateEveBattle(session, &pb.BattleEVEReq{
Ptype: pb.PlayType_academy,
Format: nil,
Sysformat: level.UsFormatList,
Backupformat: nil,
Buleformat: level.FormatList,
}); errdata != nil {
return
}
session.SendMsg(string(this.module.GetType()), "challenge", &pb.AcademyChallengeResp{Code: pb.ErrorCode_Success, Level: req.Level, Info: &pb.BattleInfo{
Id: record.Id,
Title: record.Title,
@ -33,27 +51,5 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.AcademyChallen
Buleflist: record.Buleflist,
Tasks: level.Task,
}})
} else {
session.SendMsg(string(this.module.GetType()), "challenge", &pb.AcademyChallengeResp{Code: errdata.Code, Info: nil})
}
}()
if errdata = this.ChallengeCheck(session, req); errdata != nil {
return
}
if level, err = this.module.configure.getGameTeaching(req.Level); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Title: pb.ErrorCode_ConfigNoFound.ToString(),
}
return
}
cd, record = this.module.battle.CreateEveBattle(session, &pb.BattleEVEReq{
Ptype: pb.PlayType_academy,
Format: nil,
Sysformat: level.UsFormatList,
Backupformat: nil,
Buleformat: level.FormatList,
})
return
}

View File

@ -26,10 +26,7 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.AcademyInfoReq) (er
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return
}
session.SendMsg(string(this.module.GetType()), "info", &pb.AcademyInfoResp{Info: info})

View File

@ -24,7 +24,7 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.AcademyReceiveRe
if errdata = this.ReceiveCheck(session, req); errdata != nil {
return
}
if code, iswin = this.module.battle.CheckBattleReport(session, req.Report); errdata != nil {
if errdata, iswin = this.module.battle.CheckBattleReport(session, req.Report); errdata != nil {
return
}
if iswin {
@ -34,10 +34,6 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.AcademyReceiveRe
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return
}
if level, err = this.module.configure.getGameTeaching(req.Level); err != nil {
@ -46,14 +42,14 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.AcademyReceiveRe
Title: pb.ErrorCode_ConfigNoFound.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return
}
if req.Report.Completetask == nil || len(req.Report.Completetask) != len(level.Task) {
code = pb.ErrorCode_AcademyTaskNoCompleteTask
errdata = &pb.ErrorData{
Code: pb.ErrorCode_AcademyTaskNoCompleteTask,
Title: pb.ErrorCode_AcademyTaskNoCompleteTask.ToString(),
}
return
}
@ -66,10 +62,6 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.AcademyReceiveRe
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return
}

View File

@ -18,11 +18,31 @@ func (this *apiComp) Teaching(session comm.IUserSession, req *pb.AcademyTeaching
level *cfg.GameHeroStrategyData
record *pb.DBBattleRecord
err error
cd pb.ErrorCode
)
defer func() {
if cd == pb.ErrorCode_Success {
session.SendMsg(string(this.module.GetType()), "teaching", &pb.AcademyTeachingResp{Code: cd, HeroId: req.HeroId, Info: &pb.BattleInfo{
if errdata = this.TeachingCheck(session, req); errdata != nil {
return
}
if level, err = this.module.configure.getGameHeroTeaching(req.HeroId); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Title: pb.ErrorCode_ConfigNoFound.ToString(),
Message: err.Error(),
}
return
}
if errdata, record = this.module.battle.CreateEveBattle(session, &pb.BattleEVEReq{
Ptype: pb.PlayType_heroteaching,
Format: nil,
Sysformat: level.UsFormatList,
Backupformat: nil,
Buleformat: level.FormatList,
}); errdata != nil {
return
}
session.SendMsg(string(this.module.GetType()), "teaching", &pb.AcademyTeachingResp{
HeroId: req.HeroId, Info: &pb.BattleInfo{
Id: record.Id,
Title: record.Title,
Rulesid: level.Battleready,
@ -34,28 +54,5 @@ func (this *apiComp) Teaching(session comm.IUserSession, req *pb.AcademyTeaching
Buleflist: record.Buleflist,
Tasks: level.Task,
}})
} else {
session.SendMsg(string(this.module.GetType()), "teaching", &pb.AcademyTeachingResp{Code: cd, Info: nil})
}
}()
if cd = this.TeachingCheck(session, req); cd != pb.ErrorCode_Success {
return
}
if level, err = this.module.configure.getGameHeroTeaching(req.HeroId); err != nil {
cd = pb.ErrorCode_ConfigNoFound
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return
}
cd, record = this.module.battle.CreateEveBattle(session, &pb.BattleEVEReq{
Ptype: pb.PlayType_heroteaching,
Format: nil,
Sysformat: level.UsFormatList,
Backupformat: nil,
Buleformat: level.FormatList,
})
return
}

View File

@ -24,7 +24,7 @@ func (this *apiComp) TeachingReceive(session comm.IUserSession, req *pb.AcademyT
if errdata = this.TeachingReceiveCheck(session, req); errdata != nil {
return
}
if code, iswin = this.module.battle.CheckBattleReport(session, req.Report); errdata != nil {
if errdata, iswin = this.module.battle.CheckBattleReport(session, req.Report); errdata != nil {
return
}
if iswin {
@ -34,10 +34,6 @@ func (this *apiComp) TeachingReceive(session comm.IUserSession, req *pb.AcademyT
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return
}
if level, err = this.module.configure.getGameHeroTeaching(req.HeroId); err != nil {
@ -46,16 +42,13 @@ func (this *apiComp) TeachingReceive(session comm.IUserSession, req *pb.AcademyT
Title: pb.ErrorCode_ConfigNoFound.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return
}
if req.Report.Completetask == nil || len(req.Report.Completetask) != len(level.Task) {
code = pb.ErrorCode_AcademyTaskNoCompleteTask
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
errdata = &pb.ErrorData{
Code: pb.ErrorCode_AcademyTaskNoCompleteTask,
Title: pb.ErrorCode_AcademyTaskNoCompleteTask.ToString(),
Message: fmt.Sprintf("目标任务:%v 完成任务:%v", level.Task, req.Report.Completetask),
}
return
@ -69,10 +62,6 @@ func (this *apiComp) TeachingReceive(session comm.IUserSession, req *pb.AcademyT
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return
}
this.module.DispenseRes(session, level.Award, true)

View File

@ -23,64 +23,57 @@ func (this *apiComp) Plot(session comm.IUserSession, req *pb.ArenaPlotReq) (errd
index int32
err error
)
if cd = this.PlotCheck(session, req); cd != pb.ErrorCode_Success {
if errdata = this.PlotCheck(session, req); errdata != nil {
return
}
if npc, err = this.module.configure.getChallengenpc(req.Pid); err != nil {
cd = pb.ErrorCode_ConfigNoFound
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Title: pb.ErrorCode_ConfigNoFound.ToString(),
Message: err.Error(),
}
return
}
if info, err = this.module.modelArena.queryPlayerInfo(session.GetUserId()); err != nil {
cd = pb.ErrorCode_DBError
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
return
}
this.module.modelArena.recoverTicket(session, info)
if cd = this.module.ConsumeRes(session, []*cfg.Gameatn{this.module.ModuleTools.GetGlobalConf().ArenaTicketCos}, true); cd != pb.ErrorCode_Success {
if errdata = this.module.ConsumeRes(session, []*cfg.Gameatn{this.module.ModuleTools.GetGlobalConf().ArenaTicketCos}, true); errdata != nil {
return
}
// if info.Ticket > this.module.ModuleTools.GetGlobalConf().ArenaTicketCos {
// info.Ticket -= this.module.ModuleTools.GetGlobalConf().ArenaTicketCos
// } else {
// code = pb.ErrorCode_ArenaTicketNotEnough
// return
// }
if info.Npc[req.Pid] != nil {
ndata := info.Npc[req.Pid]
if !configure.Now().After(time.Unix(ndata.Cd, 0)) { //已经过了cd时间
code = pb.ErrorCode_ArenaTicketNpcInCd
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ArenaTicketNpcInCd,
Title: pb.ErrorCode_ArenaTicketNpcInCd.ToString(),
}
return
}
index = ndata.Index
}
if cd, record = this.module.battle.CreatePveBattle(session, &pb.BattlePVEReq{
if errdata, record = this.module.battle.CreatePveBattle(session, &pb.BattlePVEReq{
Ptype: pb.PlayType_arena,
Format: req.Battle,
Mformat: []int32{npc.MonsterformatId[index]},
}); cd == pb.ErrorCode_Success {
}); errdata != nil {
return
}
if err = this.module.modelArena.updateArenaUserInfo(info); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
}
return
}
}
session.SendMsg(string(this.module.GetType()), "plot", &pb.ArenaPlotResp{
Pid: req.Pid,
Info: &pb.BattleInfo{

View File

@ -37,20 +37,15 @@ func (this *apiComp) PlotReward(session comm.IUserSession, req *pb.ArenaPlotRewa
Title: pb.ErrorCode_ConfigNoFound.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return
}
if code, iswin = this.module.battle.CheckBattleReport(session, req.Report); errdata != nil {
if errdata, iswin = this.module.battle.CheckBattleReport(session, req.Report); errdata != nil {
return
}
if !iswin {
code = pb.ErrorCode_MoonfantasyBattleNoWin
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: "战斗校验失败",
errdata = &pb.ErrorData{
Code: pb.ErrorCode_MoonfantasyBattleNoWin,
Title: pb.ErrorCode_MoonfantasyBattleNoWin.ToString(),
}
return
}
@ -60,10 +55,6 @@ func (this *apiComp) PlotReward(session comm.IUserSession, req *pb.ArenaPlotRewa
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return
}
if info.Npc[req.Pid] == nil {
@ -85,10 +76,6 @@ func (this *apiComp) PlotReward(session comm.IUserSession, req *pb.ArenaPlotRewa
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return
}

View File

@ -30,10 +30,6 @@ func (this *apiComp) Rank(session comm.IUserSession, req *pb.ArenaRankReq) (errd
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return
}
if uids, err = this.module.modelRank.queryRankUser(); err != nil {
@ -42,10 +38,6 @@ func (this *apiComp) Rank(session comm.IUserSession, req *pb.ArenaRankReq) (errd
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return
}
if ranks, err = this.module.modelArena.queryPlayers(uids); err != nil {
@ -54,10 +46,6 @@ func (this *apiComp) Rank(session comm.IUserSession, req *pb.ArenaRankReq) (errd
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return
}
players = make([]*pb.ArenaPlayer, len(ranks))

View File

@ -27,10 +27,7 @@ func (this *apiComp) SetAttFormt(session comm.IUserSession, req *pb.ArenaSetAttF
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return
}
if heros, err = this.module.modelArena.queryUserHeros(session.GetUserId(), req.Formt); err != nil {
@ -39,10 +36,6 @@ func (this *apiComp) SetAttFormt(session comm.IUserSession, req *pb.ArenaSetAttF
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return
}
info.Attack = &pb.DBPlayerBattleFormt{
@ -56,10 +49,6 @@ func (this *apiComp) SetAttFormt(session comm.IUserSession, req *pb.ArenaSetAttF
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return
}
session.SendMsg(string(this.module.GetType()), "setattformt", &pb.ArenaSetAttFormtResp{Issucc: true})

View File

@ -27,10 +27,7 @@ func (this *apiComp) SetDefFormt(session comm.IUserSession, req *pb.ArenaSetDefF
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return
}
@ -40,10 +37,7 @@ func (this *apiComp) SetDefFormt(session comm.IUserSession, req *pb.ArenaSetDefF
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return
}
info.Defend = &pb.DBPlayerBattleFormt{
@ -57,10 +51,7 @@ func (this *apiComp) SetDefFormt(session comm.IUserSession, req *pb.ArenaSetDefF
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
Message: err.Error(),
}
return
}
session.SendMsg(string(this.module.GetType()), "setdefformt", &pb.ArenaSetDefFormtResp{Issucc: true})

View File

@ -404,11 +404,7 @@ func (this *modelArena) recoverTicket(session comm.IUserSession, info *pb.DBAren
)
if ticketitem = this.module.ModuleTools.GetGlobalConf().ArenaTicketCos; ticketitem == nil {
// errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Title: pb.ErrorCode_ConfigNoFound.ToString(),
Message: err.Error(),
}
// code = pb.ErrorCode_ConfigNoFound
// data = &pb.ErrorData{
// Title: code.ToString(),
// Message: comm.NewNotFoundConfErr(moduleName, "global.json", "ArenaTicketCos").Error(),
@ -453,11 +449,7 @@ func (this *modelArena) reddot(session comm.IUserSession) bool {
return false
}
if ticketitem = this.module.ModuleTools.GetGlobalConf().ArenaTicketCos; ticketitem == nil {
// errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Title: pb.ErrorCode_ConfigNoFound.ToString(),
Message: err.Error(),
}
// code = pb.ErrorCode_ConfigNoFound
// data = &pb.ErrorData{
// Title: code.ToString(),
// Message: comm.NewNotFoundConfErr(moduleName, "global.json", "ArenaTicketCos").Error(),

View File

@ -130,7 +130,7 @@ func (this *Arena) GetMatcheBattleRoles(uid string) (captain int32, rules []*pb.
info *pb.DBArenaUser
players []*pb.ArenaPlayer
ais []*pb.ArenaPlayer
code pb.ErrorCode
errdata *pb.ErrorData
)
global = this.ModuleTools.GetGlobalConf()
if info, err = this.modelArena.queryPlayerInfo(uid); err != nil && err != mgo.MongodbNil {
@ -151,8 +151,8 @@ func (this *Arena) GetMatcheBattleRoles(uid string) (captain int32, rules []*pb.
}
if len(players) > 0 {
captain = players[0].Defend.Leadpos
if rules, code = this.battle.CreateRolesByHeros(players[0].Defend.Formt); errdata != nil {
err = fmt.Errorf("Player CreateRolesByHeros fail:%d", code)
if rules, errdata = this.battle.CreateRolesByHeros(players[0].Defend.Formt); errdata != nil {
err = fmt.Errorf("Player CreateRolesByHeros fail:%v", errdata)
return
}
} else {
@ -161,8 +161,8 @@ func (this *Arena) GetMatcheBattleRoles(uid string) (captain int32, rules []*pb.
}
if len(ais) > 0 {
captain = ais[0].Defend.Leadpos
if rules, code = this.battle.CreateRolesByHeros(ais[0].Defend.Formt); errdata != nil {
err = fmt.Errorf("AI CreateRolesByHeros fail:%d", code)
if rules, errdata = this.battle.CreateRolesByHeros(ais[0].Defend.Formt); errdata != nil {
err = fmt.Errorf("AI CreateRolesByHeros fail:%v", errdata)
return
}
} else {

View File

@ -78,11 +78,14 @@ func (this *modelBattleComp) createeve(session comm.IUserSession, conn *db.DBCon
if v != "" {
hero := &pb.DBHero{}
if err := model.GetListObj(session.GetUserId(), v, hero); err != nil {
code = pb.ErrorCode_HeroNoExist
errdata = &pb.ErrorData{
Code: pb.ErrorCode_HeroNoExist,
Title: pb.ErrorCode_HeroNoExist.ToString(),
}
return
}
tid := 100 + i
if record.Redflist[0].Team[i], code = this.createBattleRole(hero, tid, i); errdata != nil {
if record.Redflist[0].Team[i], errdata = this.createBattleRole(hero, tid, i); errdata != nil {
return
}
if buff != nil {
@ -107,7 +110,10 @@ func (this *modelBattleComp) createeve(session comm.IUserSession, conn *db.DBCon
if this.module.IsCross() {
if hero, err = this.module.friend.UseAssistHero(session.GetUserId(), v); err != nil {
this.module.Errorln(err)
code = pb.ErrorCode_HeroNoExist
errdata = &pb.ErrorData{
Code: pb.ErrorCode_HeroNoExist,
Title: pb.ErrorCode_HeroNoExist.ToString(),
}
return
}
} else { //获取跨服数据
@ -123,7 +129,7 @@ func (this *modelBattleComp) createeve(session comm.IUserSession, conn *db.DBCon
}
}
tid := 100 + i
if record.Redflist[0].Team[i], code = this.createBattleRole(hero, tid, i); errdata != nil {
if record.Redflist[0].Team[i], errdata = this.createBattleRole(hero, tid, i); errdata != nil {
return
}
record.Redflist[0].Team[i].Ishelp = true
@ -141,7 +147,7 @@ func (this *modelBattleComp) createeve(session comm.IUserSession, conn *db.DBCon
if v == 0 {
continue
}
if captain, masters, code = this.createMasterRoles(100, i, v); errdata != nil {
if captain, masters, errdata = this.createMasterRoles(100, i, v); errdata != nil {
return
}
record.Redflist[i].Systeam = masters
@ -164,7 +170,7 @@ func (this *modelBattleComp) createeve(session comm.IUserSession, conn *db.DBCon
if v == 0 {
continue
}
if captain, masters, code = this.createMasterRoles(100, i, v); errdata != nil {
if captain, masters, errdata = this.createMasterRoles(100, i, v); errdata != nil {
return
}
record.Redflist[i].Backupteam = masters
@ -182,7 +188,7 @@ func (this *modelBattleComp) createeve(session comm.IUserSession, conn *db.DBCon
} else {
record.Redflist = make([]*pb.DBBattleFormt, len(req.Sysformat))
for i, v := range req.Sysformat {
if captain, masters, code = this.createMasterRoles(100, i, v); errdata != nil {
if captain, masters, errdata = this.createMasterRoles(100, i, v); errdata != nil {
return
}
record.Redflist[i] = &pb.DBBattleFormt{
@ -201,7 +207,7 @@ func (this *modelBattleComp) createeve(session comm.IUserSession, conn *db.DBCon
}
if req.Backupformat != nil && len(req.Backupformat) > 0 {
for i, v := range req.Backupformat {
if captain, masters, code = this.createMasterRoles(100, i, v); errdata != nil {
if captain, masters, errdata = this.createMasterRoles(100, i, v); errdata != nil {
return
}
record.Redflist[i].Backupteam = masters
@ -219,7 +225,7 @@ func (this *modelBattleComp) createeve(session comm.IUserSession, conn *db.DBCon
}
for i, v := range req.Buleformat {
if captain, masters, code = this.createMasterRoles(200, i, v); errdata != nil {
if captain, masters, errdata = this.createMasterRoles(200, i, v); errdata != nil {
return
}
record.Buleflist[i] = &pb.DBBattleFormt{
@ -258,11 +264,14 @@ func (this *modelBattleComp) createpve(session comm.IUserSession, conn *db.DBCon
if v != "" {
heros[i] = &pb.DBHero{}
if err := model.GetListObj(session.GetUserId(), v, heros[i]); err != nil {
code = pb.ErrorCode_HeroNoExist
errdata = &pb.ErrorData{
Code: pb.ErrorCode_HeroNoExist,
Title: pb.ErrorCode_HeroNoExist.ToString(),
}
return
}
tid := 100 + i
if record.Redflist[0].Team[i], code = this.createBattleRole(heros[i], tid, i); errdata != nil {
if record.Redflist[0].Team[i], errdata = this.createBattleRole(heros[i], tid, i); errdata != nil {
return
}
if buff != nil {
@ -286,7 +295,10 @@ func (this *modelBattleComp) createpve(session comm.IUserSession, conn *db.DBCon
if this.module.IsCross() {
if heros[i], err = this.module.friend.UseAssistHero(session.GetUserId(), v); err != nil {
this.module.Errorln(err)
code = pb.ErrorCode_HeroNoExist
errdata = &pb.ErrorData{
Code: pb.ErrorCode_HeroNoExist,
Title: pb.ErrorCode_HeroNoExist.ToString(),
}
return
}
} else { //获取跨服数据
@ -302,7 +314,7 @@ func (this *modelBattleComp) createpve(session comm.IUserSession, conn *db.DBCon
}
}
tid := 100 + i
if record.Redflist[0].Team[i], code = this.createBattleRole(heros[i], tid, i); errdata != nil {
if record.Redflist[0].Team[i], errdata = this.createBattleRole(heros[i], tid, i); errdata != nil {
return
}
record.Redflist[0].Team[i].Ishelp = true
@ -316,7 +328,10 @@ func (this *modelBattleComp) createpve(session comm.IUserSession, conn *db.DBCon
}
}
if ok := this.checkBattlereadyCapskill(req.Format.Leadpos, heros); !ok {
code = pb.ErrorCode_BattleCapskillCheckFailed
errdata = &pb.ErrorData{
Code: pb.ErrorCode_BattleCapskillCheckFailed,
Title: pb.ErrorCode_BattleCapskillCheckFailed.ToString(),
}
return
}
var (
@ -324,7 +339,7 @@ func (this *modelBattleComp) createpve(session comm.IUserSession, conn *db.DBCon
masters []*pb.BattleRole
)
for i, v := range req.Mformat {
if captain, masters, code = this.createMasterRoles(200, i, v); errdata != nil {
if captain, masters, errdata = this.createMasterRoles(200, i, v); errdata != nil {
return
}
record.Buleflist[i] = &pb.DBBattleFormt{
@ -364,11 +379,14 @@ func (this *modelBattleComp) createpvb(session comm.IUserSession, conn *db.DBCon
if v != "" {
heros[i] = &pb.DBHero{}
if err := model.GetListObj(session.GetUserId(), v, heros[i]); err != nil {
code = pb.ErrorCode_HeroNoExist
errdata = &pb.ErrorData{
Code: pb.ErrorCode_HeroNoExist,
Title: pb.ErrorCode_HeroNoExist.ToString(),
}
return
}
tid := 100 + i
if record.Redflist[ii].Team[i], code = this.createBattleRole(heros[i], tid, i); errdata != nil {
if record.Redflist[ii].Team[i], errdata = this.createBattleRole(heros[i], tid, i); errdata != nil {
return
}
if buff != nil {
@ -392,7 +410,10 @@ func (this *modelBattleComp) createpvb(session comm.IUserSession, conn *db.DBCon
if this.module.IsCross() {
if heros[i], err = this.module.friend.UseAssistHero(session.GetUserId(), v); err != nil {
this.module.Errorln(err)
code = pb.ErrorCode_HeroNoExist
errdata = &pb.ErrorData{
Code: pb.ErrorCode_HeroNoExist,
Title: pb.ErrorCode_HeroNoExist.ToString(),
}
return
}
} else { //获取跨服数据
@ -408,7 +429,7 @@ func (this *modelBattleComp) createpvb(session comm.IUserSession, conn *db.DBCon
}
}
tid := 100 + i
if record.Redflist[ii].Team[i], code = this.createBattleRole(heros[i], tid, i); errdata != nil {
if record.Redflist[ii].Team[i], errdata = this.createBattleRole(heros[i], tid, i); errdata != nil {
return
}
record.Redflist[ii].Team[i].Ishelp = true
@ -422,7 +443,10 @@ func (this *modelBattleComp) createpvb(session comm.IUserSession, conn *db.DBCon
}
}
if ok := this.checkBattlereadyCapskill(v.Leadpos, heros); !ok {
code = pb.ErrorCode_BattleCapskillCheckFailed
errdata = &pb.ErrorData{
Code: pb.ErrorCode_BattleCapskillCheckFailed,
Title: pb.ErrorCode_BattleCapskillCheckFailed.ToString(),
}
return
}
}
@ -432,7 +456,7 @@ func (this *modelBattleComp) createpvb(session comm.IUserSession, conn *db.DBCon
masters []*pb.BattleRole
)
for i, v := range req.Mformat {
if captain, masters, code = this.createMasterRoles(200, i, v); errdata != nil {
if captain, masters, errdata = this.createMasterRoles(200, i, v); errdata != nil {
return
}
record.Buleflist[i] = &pb.DBBattleFormt{
@ -464,7 +488,7 @@ func (this *modelBattleComp) createpvp(session comm.IUserSession, conn *db.DBCon
for i, v := range req.Redformat.Format {
if v != nil {
tid := 100 + i
if record.Redflist[0].Team[i], code = this.createBattleRole(v, tid, i); errdata != nil {
if record.Redflist[0].Team[i], errdata = this.createBattleRole(v, tid, i); errdata != nil {
return
}
} else {
@ -472,7 +496,10 @@ func (this *modelBattleComp) createpvp(session comm.IUserSession, conn *db.DBCon
}
}
if ok := this.checkBattlereadyCapskill(req.Redformat.Leadpos, req.Redformat.Format); !ok {
code = pb.ErrorCode_BattleCapskillCheckFailed
errdata = &pb.ErrorData{
Code: pb.ErrorCode_BattleCapskillCheckFailed,
Title: pb.ErrorCode_BattleCapskillCheckFailed.ToString(),
}
return
}
@ -484,7 +511,7 @@ func (this *modelBattleComp) createpvp(session comm.IUserSession, conn *db.DBCon
for i, v := range req.Buleformat.Format {
if v != nil {
tid := 200 + i
if record.Buleflist[0].Team[i], code = this.createBattleRole(v, tid, i); errdata != nil {
if record.Buleflist[0].Team[i], errdata = this.createBattleRole(v, tid, i); errdata != nil {
return
}
} else {
@ -492,7 +519,10 @@ func (this *modelBattleComp) createpvp(session comm.IUserSession, conn *db.DBCon
}
}
if ok := this.checkBattlereadyCapskill(req.Buleformat.Leadpos, req.Buleformat.Format); !ok {
code = pb.ErrorCode_BattleCapskillCheckFailed
errdata = &pb.ErrorData{
Code: pb.ErrorCode_BattleCapskillCheckFailed,
Title: pb.ErrorCode_BattleCapskillCheckFailed.ToString(),
}
return
}
return
@ -521,11 +551,14 @@ func (this *modelBattleComp) creatertpvp(redmodel, bluemodel *db.DBModel, btype
if v != "" {
heros[i] = &pb.DBHero{}
if err := redmodel.GetListObj(req.RedCompId, v, heros[i]); err != nil {
code = pb.ErrorCode_HeroNoExist
errdata = &pb.ErrorData{
Code: pb.ErrorCode_HeroNoExist,
Title: pb.ErrorCode_HeroNoExist.ToString(),
}
return
}
tid := 100 + i
if record.Redflist[ii].Team[i], code = this.createBattleRole(heros[i], tid, i); errdata != nil {
if record.Redflist[ii].Team[i], errdata = this.createBattleRole(heros[i], tid, i); errdata != nil {
return
}
} else {
@ -533,7 +566,10 @@ func (this *modelBattleComp) creatertpvp(redmodel, bluemodel *db.DBModel, btype
}
}
if ok := this.checkBattlereadyCapskill(v.Leadpos, heros); !ok {
code = pb.ErrorCode_BattleCapskillCheckFailed
errdata = &pb.ErrorData{
Code: pb.ErrorCode_BattleCapskillCheckFailed,
Title: pb.ErrorCode_BattleCapskillCheckFailed.ToString(),
}
return
}
}
@ -547,11 +583,14 @@ func (this *modelBattleComp) creatertpvp(redmodel, bluemodel *db.DBModel, btype
if v != "" {
heros[i] = &pb.DBHero{}
if err := bluemodel.GetListObj(req.BlueCompId, v, heros[i]); err != nil {
code = pb.ErrorCode_HeroNoExist
errdata = &pb.ErrorData{
Code: pb.ErrorCode_HeroNoExist,
Title: pb.ErrorCode_HeroNoExist.ToString(),
}
return
}
tid := 200 + i
if record.Buleflist[ii].Team[i], code = this.createBattleRole(heros[i], tid, i); errdata != nil {
if record.Buleflist[ii].Team[i], errdata = this.createBattleRole(heros[i], tid, i); errdata != nil {
return
}
} else {
@ -559,7 +598,10 @@ func (this *modelBattleComp) creatertpvp(redmodel, bluemodel *db.DBModel, btype
}
}
if ok := this.checkBattlereadyCapskill(v.Leadpos, heros); !ok {
code = pb.ErrorCode_BattleCapskillCheckFailed
errdata = &pb.ErrorData{
Code: pb.ErrorCode_BattleCapskillCheckFailed,
Title: pb.ErrorCode_BattleCapskillCheckFailed.ToString(),
}
return
}
}
@ -594,11 +636,14 @@ func (this *modelBattleComp) createlpve(session comm.IUserSession, conn *db.DBCo
if v != "" {
heros[i] = &pb.DBHero{}
if err := model.GetListObj(session.GetUserId(), v, heros[i]); err != nil {
code = pb.ErrorCode_HeroNoExist
errdata = &pb.ErrorData{
Code: pb.ErrorCode_HeroNoExist,
Title: pb.ErrorCode_HeroNoExist.ToString(),
}
return
}
tid := 100 + i
if record.Redflist[0].Team[i], code = this.createBattleRole(heros[i], tid, i); errdata != nil {
if record.Redflist[0].Team[i], errdata = this.createBattleRole(heros[i], tid, i); errdata != nil {
return
}
if buff != nil {
@ -622,7 +667,10 @@ func (this *modelBattleComp) createlpve(session comm.IUserSession, conn *db.DBCo
if this.module.IsCross() {
if heros[i], err = this.module.friend.UseAssistHero(session.GetUserId(), v); err != nil {
this.module.Errorln(err)
code = pb.ErrorCode_HeroNoExist
errdata = &pb.ErrorData{
Code: pb.ErrorCode_HeroNoExist,
Title: pb.ErrorCode_HeroNoExist.ToString(),
}
return
}
} else { //获取跨服数据
@ -638,7 +686,7 @@ func (this *modelBattleComp) createlpve(session comm.IUserSession, conn *db.DBCo
}
}
tid := 100 + i
if record.Redflist[0].Team[i], code = this.createBattleRole(heros[i], tid, i); errdata != nil {
if record.Redflist[0].Team[i], errdata = this.createBattleRole(heros[i], tid, i); errdata != nil {
return
}
record.Redflist[0].Team[i].Ishelp = true
@ -652,7 +700,10 @@ func (this *modelBattleComp) createlpve(session comm.IUserSession, conn *db.DBCo
}
}
if ok := this.checkBattlereadyCapskill(req.Format.Leadpos, heros); !ok {
code = pb.ErrorCode_BattleCapskillCheckFailed
errdata = &pb.ErrorData{
Code: pb.ErrorCode_BattleCapskillCheckFailed,
Title: pb.ErrorCode_BattleCapskillCheckFailed.ToString(),
}
return
}
record.Buleflist[0] = &pb.DBBattleFormt{
@ -753,7 +804,7 @@ func (this *modelBattleComp) createMasterRoles(comp, wheel int, fid int32) (capt
captain = int32(i)
}
// if monst, err := this.module.configure.GetMonster(v.Monster); err != nil {
// errdata = &pb.ErrorData{
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Title: pb.ErrorCode_ConfigNoFound.ToString(),
Message: err.Error(),

View File

@ -84,7 +84,10 @@ func (this *Battle) OnInstallComp() {
func (this *Battle) QueryBattleRecord(oid string) (errdata *pb.ErrorData, record *pb.DBBattleRecord) {
var err error
if record, err = this.modelBattle.queryrecord(oid); err != nil {
code = pb.ErrorCode_BattleNoFoundRecord
errdata = &pb.ErrorData{
Code: pb.ErrorCode_BattleNoFoundRecord,
Title: pb.ErrorCode_BattleNoFoundRecord.ToString(),
}
return
}
return
@ -111,7 +114,7 @@ func (this *Battle) CreateEveBattle(session comm.IUserSession, req *pb.BattleEVE
return
}
if record, code = this.modelBattle.createeve(session, conn, pb.BattleType_eve, req); errdata != nil {
if record, errdata = this.modelBattle.createeve(session, conn, pb.BattleType_eve, req); errdata != nil {
return
}
return
@ -158,7 +161,7 @@ func (this *Battle) CreatePveBattle(session comm.IUserSession, req *pb.BattlePVE
}
}
if record, code = this.modelBattle.createpve(session, conn, pb.BattleType_pve, req); errdata != nil {
if record, errdata = this.modelBattle.createpve(session, conn, pb.BattleType_pve, req); errdata != nil {
return
}
if req.Format.Friendformat != nil {
@ -194,7 +197,7 @@ func (this *Battle) CreatePvbBattle(session comm.IUserSession, req *pb.BattlePVB
}
return
}
if record, code = this.modelBattle.createpvb(session, conn, pb.BattleType_pvb, req); errdata != nil {
if record, errdata = this.modelBattle.createpvb(session, conn, pb.BattleType_pvb, req); errdata != nil {
return
}
return
@ -220,7 +223,7 @@ func (this *Battle) CreatePvpBattle(session comm.IUserSession, req *pb.BattlePVP
this.Errorf("session:%v err:", session, err)
return
}
if record, code = this.modelBattle.createpvp(session, conn, pb.BattleType_pvp, req); errdata != nil {
if record, errdata = this.modelBattle.createpvp(session, conn, pb.BattleType_pvp, req); errdata != nil {
return
}
return
@ -234,7 +237,10 @@ func (this *Battle) CreateRtPvpBattle(req *pb.BattleRTPVPReq) (errdata *pb.Error
err error
)
if !this.IsCross() {
code = pb.ErrorCode_Exception
errdata = &pb.ErrorData{
Code: pb.ErrorCode_Exception,
Title: pb.ErrorCode_Exception.ToString(),
}
return
}
if redmodel, err = this.GetDBModelByUid(req.RedCompId, comm.TableHero); err != nil {
@ -253,7 +259,7 @@ func (this *Battle) CreateRtPvpBattle(req *pb.BattleRTPVPReq) (errdata *pb.Error
}
return
}
if record, code = this.modelBattle.creatertpvp(redmodel, bluemodel, pb.BattleType_rtpvp, req); errdata != nil {
if record, errdata = this.modelBattle.creatertpvp(redmodel, bluemodel, pb.BattleType_rtpvp, req); errdata != nil {
return
}
return
@ -300,7 +306,7 @@ func (this *Battle) CreateLPVEBattle(session comm.IUserSession, req *pb.BattleLP
}
}
if record, code = this.modelBattle.createlpve(session, conn, pb.BattleType_lpev, req); errdata != nil {
if record, errdata = this.modelBattle.createlpve(session, conn, pb.BattleType_lpev, req); errdata != nil {
return
}
if req.Format.Friendformat != nil {
@ -311,7 +317,7 @@ func (this *Battle) CreateLPVEBattle(session comm.IUserSession, req *pb.BattleLP
///创建角色列表 更具Format表格
func (this *Battle) CreateRolesByFormat(fid int32) (captain int32, roles []*pb.BattleRole, errdata *pb.ErrorData) {
captain, roles, code = this.modelBattle.createMasterRoles(2, 0, fid)
captain, roles, errdata = this.modelBattle.createMasterRoles(2, 0, fid)
return
}
@ -320,7 +326,7 @@ func (this *Battle) CreateRolesByHeros(heros []*pb.DBHero) (roles []*pb.BattleRo
roles = make([]*pb.BattleRole, len(heros))
for i, v := range heros {
if v != nil {
if roles[i], code = this.modelBattle.createBattleRole(v, 200+i, i); errdata != nil {
if roles[i], errdata = this.modelBattle.createBattleRole(v, 200+i, i); errdata != nil {
return
}
}
@ -338,7 +344,10 @@ func (this *Battle) GetBattleInfo(req *pb.BattleGetInfoReq) (errdata *pb.ErrorDa
ctx, _ = context.WithTimeout(context.Background(), time.Second*5)
if resp, err = this.clientmgr.GetInfo(ctx, req); err != nil {
this.Errorln(err)
code = pb.ErrorCode_RpcFuncExecutionError
errdata = &pb.ErrorData{
Code: pb.ErrorCode_RpcFuncExecutionError,
Title: pb.ErrorCode_RpcFuncExecutionError.ToString(),
}
}
return
}
@ -354,10 +363,16 @@ func (this *Battle) CreateBattleServer(req *pb.BattleInfo) (errdata *pb.ErrorDat
ctx, _ = context.WithTimeout(context.Background(), time.Second*5)
if resp, err = this.clientmgr.CreateBattle(ctx, &pb.BattleCreateServerReq{Info: req}); err != nil {
this.Errorln(err)
code = pb.ErrorCode_RpcFuncExecutionError
errdata = &pb.ErrorData{
Code: pb.ErrorCode_RpcFuncExecutionError,
Title: pb.ErrorCode_RpcFuncExecutionError.ToString(),
}
}
if !resp.Issucc {
code = pb.ErrorCode_BattleCreateFailed
errdata = &pb.ErrorData{
Code: pb.ErrorCode_BattleCreateFailed,
Title: pb.ErrorCode_BattleCreateFailed.ToString(),
}
}
return
}
@ -371,10 +386,16 @@ func (this *Battle) InCmdBattle(req *pb.BattleInCmdReq) (errdata *pb.ErrorData)
ctx, _ = context.WithTimeout(context.Background(), time.Second*5)
if resp, err = this.clientmgr.InCmdBattle(ctx, req); err != nil {
this.Errorln(err)
code = pb.ErrorCode_RpcFuncExecutionError
errdata = &pb.ErrorData{
Code: pb.ErrorCode_RpcFuncExecutionError,
Title: pb.ErrorCode_RpcFuncExecutionError.ToString(),
}
}
if !resp.Issucc {
code = pb.ErrorCode_BattleInCmdFailed
errdata = &pb.ErrorData{
Code: pb.ErrorCode_BattleInCmdFailed,
Title: pb.ErrorCode_BattleInCmdFailed.ToString(),
}
}
return
}
@ -387,10 +408,16 @@ func (this *Battle) ConcedeBattle(req *pb.BattleConcedeReq) (errdata *pb.ErrorDa
)
if resp, err = this.clientmgr.ConcedeBattle(context.Background(), req); err != nil {
this.Errorln(err)
code = pb.ErrorCode_RpcFuncExecutionError
errdata = &pb.ErrorData{
Code: pb.ErrorCode_RpcFuncExecutionError,
Title: pb.ErrorCode_RpcFuncExecutionError.ToString(),
}
}
if !resp.Issucc {
code = pb.ErrorCode_BattleInCmdFailed
errdata = &pb.ErrorData{
Code: pb.ErrorCode_BattleInCmdFailed,
Title: pb.ErrorCode_BattleInCmdFailed.ToString(),
}
}
return
}
@ -411,7 +438,10 @@ func (this *Battle) CheckBattleReport(session comm.IUserSession, report *pb.Batt
stime := time.Now()
ctx, _ = context.WithTimeout(context.Background(), time.Second*5)
if reply, err = this.clientmgr.CheckBattle(ctx, report); err != nil || !reply.Ischeck {
code = pb.ErrorCode_BattleValidationFailed
errdata = &pb.ErrorData{
Code: pb.ErrorCode_BattleValidationFailed,
Title: pb.ErrorCode_BattleValidationFailed.ToString(),
}
this.Error("[Battle Check]",
log.Field{Key: "t", Value: time.Since(stime).Milliseconds()},
log.Field{Key: "reply", Value: reply.String()},
@ -429,5 +459,5 @@ func (this *Battle) CheckBattleReport(session comm.IUserSession, report *pb.Batt
// this.ModuleBuried.SendToRtask(session, comm.Rtype157, int32(report.Info.Ptype), v)
go this.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.Rtype157, int32(report.Info.Ptype), v))
}
return pb.ErrorCode_Success, true
return nil, true
}

View File

@ -34,10 +34,6 @@ func (this *apiComp) InquireProgress(session comm.IUserSession, req *pb.BuriedIn
Title: pb.ErrorCode_ConfigNoFound.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: code.ToString(),
Message: err.Error(),
}
return
}

View File

@ -29,10 +29,6 @@ func (this *apiComp) ChanageChannel(session comm.IUserSession, req *pb.ChatChana
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: code.ToString(),
Message: err.Error(),
}
return
}
if ok {
@ -42,10 +38,6 @@ func (this *apiComp) ChanageChannel(session comm.IUserSession, req *pb.ChatChana
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: code.ToString(),
Message: err.Error(),
}
return
}
this.module.ModuleUser.ChangeUserExpand(session.GetUserId(), map[string]interface{}{

View File

@ -26,10 +26,6 @@ func (this *apiComp) CrossChannel(session comm.IUserSession, req *pb.ChatCrossCh
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: code.ToString(),
Message: err.Error(),
}
return
}
this.module.ModuleUser.ChangeUserExpand(session.GetUserId(), map[string]interface{}{

View File

@ -37,10 +37,6 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.ChatGetListReq)
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: code.ToString(),
Message: err.Error(),
}
return
}
break
@ -51,10 +47,6 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.ChatGetListReq)
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: code.ToString(),
Message: err.Error(),
}
return
}
break
@ -65,10 +57,6 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.ChatGetListReq)
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: code.ToString(),
Message: err.Error(),
}
return
}
break
@ -80,19 +68,12 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.ChatGetListReq)
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: code.ToString(),
Message: err.Error(),
}
return
}
if req.ChannelId != result.Chatchannel {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ReqParameterError,
Title: pb.ErrorCode_ReqParameterError.ToString(),
}
data = &pb.ErrorData{
Title: code.ToString(),
Message: fmt.Sprintf("req.ChannelId:%d != result.Chatchannel:%d", req.ChannelId, result.Chatchannel),
}
return
@ -103,10 +84,6 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.ChatGetListReq)
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: code.ToString(),
Message: err.Error(),
}
return
}
break
@ -117,10 +94,6 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.ChatGetListReq)
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: code.ToString(),
Message: err.Error(),
}
return
}
break
@ -130,9 +103,6 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.ChatGetListReq)
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ReqParameterError,
Title: pb.ErrorCode_ReqParameterError.ToString(),
}
data = &pb.ErrorData{
Title: code.ToString(),
Message: fmt.Sprintf("不存在的聊天频道类型 channel:%d ", req.Channel),
}
return

View File

@ -57,10 +57,6 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (errda
Title: pb.ErrorCode_ConfigNoFound.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: code.ToString(),
Message: err.Error(),
}
return
}
@ -80,7 +76,6 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (errda
session.SendMsg(string(this.module.GetType()), "send", &pb.ChatSendResp{Issucc: true})
return
}
code = pb.ErrorCode_Success
}
if msg.Ctype == pb.ChatType_Text { //过滤敏感词
msg.Content = wordfilter.Replace(msg.Content, '*')
@ -134,9 +129,6 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (errda
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ReqParameterError,
Title: pb.ErrorCode_ReqParameterError.ToString(),
}
data = &pb.ErrorData{
Title: code.ToString(),
Message: fmt.Sprintf("不存在的聊天频道类型 channel:%d ", req.Channel),
}
return

View File

@ -242,18 +242,18 @@ func (this *modelChatComp) saveUserMsg(msg *pb.DBChat) (err error) {
// )
// if max, err = this.module.configure.GetChannelRecordMax(); err != nil {
// errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Title: pb.ErrorCode_ConfigNoFound.ToString(),
Message: err.Error(),
}
// Code: pb.ErrorCode_ConfigNoFound,
// Title: pb.ErrorCode_ConfigNoFound.ToString(),
// Message: err.Error(),
// }
// return
// }
// if err = this.module.modelChat.addChatMsg(fmt.Sprintf("%s-%s", worldchatkey, msg.Stag), int64(max), msg); err != nil {
// errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
// Code: pb.ErrorCode_DBError,
// Title: pb.ErrorCode_DBError.ToString(),
// Message: err.Error(),
// }
// return
// }
// data, _ := anypb.New(&pb.ChatMessagePush{Chat: msg})

View File

@ -163,7 +163,11 @@ func (this *Chat) SendWorldChat(msg *pb.DBChat) (errdata *pb.ErrorData) {
msg,
nil); err != nil {
this.Errorln(err)
code = pb.ErrorCode_RpcFuncExecutionError
errdata = &pb.ErrorData{
Code: pb.ErrorCode_RpcFuncExecutionError,
Title: pb.ErrorCode_RpcFuncExecutionError.ToString(),
Message: err.Error(),
}
}
}
return
@ -198,7 +202,11 @@ func (this *Chat) SendUnionChat(msg *pb.DBChat) (errdata *pb.ErrorData) {
msg,
nil); err != nil {
this.Errorln(err)
code = pb.ErrorCode_RpcFuncExecutionError
errdata = &pb.ErrorData{
Code: pb.ErrorCode_RpcFuncExecutionError,
Title: pb.ErrorCode_RpcFuncExecutionError.ToString(),
Message: err.Error(),
}
}
}
return
@ -218,7 +226,11 @@ func (this *Chat) SendUserChat(msg *pb.DBChat) (errdata *pb.ErrorData) {
session.SendMsg(string(this.GetType()), "message", &pb.ChatMessagePush{Chat: msg})
if err = session.Push(); err != nil {
this.Errorf("err:%v", err)
code = pb.ErrorCode_SystemError
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SystemError,
Title: pb.ErrorCode_SystemError.ToString(),
Message: err.Error(),
}
return
}
} else {
@ -284,7 +296,11 @@ func (this *Chat) SendSysChatToWorld(ctype comm.ChatSystemType, appenddata inter
msg,
nil); err != nil {
this.Errorln(err)
code = pb.ErrorCode_RpcFuncExecutionError
errdata = &pb.ErrorData{
Code: pb.ErrorCode_RpcFuncExecutionError,
Title: pb.ErrorCode_RpcFuncExecutionError.ToString(),
Message: err.Error(),
}
}
}
}

View File

@ -51,10 +51,6 @@ func (this *apiComp) Ask(session comm.IUserSession, req *pb.CombatAskReq) (errda
Code: pb.ErrorCode_ReqParameterError,
Title: pb.ErrorCode_ReqParameterError.ToString(),
}
data = &pb.ErrorData{
Title: code.ToString(),
Message: err.Error(),
}
this.module.Errorln(err)
return
}
@ -70,9 +66,9 @@ func (this *apiComp) Ask(session comm.IUserSession, req *pb.CombatAskReq) (errda
if level.Pass != 2 {
level.Progress = 0
if condis, err = this.module.ModuleBuried.CheckCondition(session.GetUserId(), lvconf.Maintask...); err != nil {
code = pb.ErrorCode_ExternalModule
data = &pb.ErrorData{
Title: code.ToString(),
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ExternalModule,
Title: pb.ErrorCode_ExternalModule.ToString(),
Message: comm.NewExternalModuleErr("Buried", "CheckCondition", lvconf.Maintask).Error(),
}
return
@ -105,9 +101,9 @@ func (this *apiComp) Ask(session comm.IUserSession, req *pb.CombatAskReq) (errda
}
if condis, err = this.module.ModuleBuried.CheckCondition(session.GetUserId(), lvconf.Subtask...); err != nil {
code = pb.ErrorCode_ExternalModule
data = &pb.ErrorData{
Title: code.ToString(),
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ExternalModule,
Title: pb.ErrorCode_ExternalModule.ToString(),
Message: comm.NewExternalModuleErr("Buried", "CheckCondition", lvconf.Subtask).Error(),
}
return

View File

@ -20,10 +20,6 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.CombatChalleng
err error
)
if errdata = this.ChallengeCheck(session, req); errdata != nil {
data = &pb.ErrorData{
Title: code.ToString(),
Message: req.String(),
}
return
}
@ -33,21 +29,13 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.CombatChalleng
Title: pb.ErrorCode_ConfigNoFound.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: code.ToString(),
Message: err.Error(),
}
return
}
if code, record = this.module.battle.CreatePveBattle(session, &pb.BattlePVEReq{
if errdata, record = this.module.battle.CreatePveBattle(session, &pb.BattlePVEReq{
Ptype: pb.PlayType_combat,
Format: req.Battle,
Mformat: manster.FormatList,
}); errdata != nil {
data = &pb.ErrorData{
Title: code.ToString(),
Message: req.String(),
}
return
}
session.SendMsg(string(this.module.GetType()), "challenge", &pb.CombatChallengeResp{Manster: req.Manster, Level: req.Level, Info: &pb.BattleInfo{

View File

@ -28,7 +28,7 @@ func (this *apiComp) ChallengeReceive(session comm.IUserSession, req *pb.CombatC
if errdata = this.ChallengeReceiveCheck(session, req); errdata != nil {
return
}
if code, iswin = this.module.battle.CheckBattleReport(session, req.Report); errdata != nil {
if errdata, iswin = this.module.battle.CheckBattleReport(session, req.Report); errdata != nil {
return
}
if iswin {
@ -38,10 +38,7 @@ func (this *apiComp) ChallengeReceive(session comm.IUserSession, req *pb.CombatC
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: code.ToString(),
Message: err.Error(),
}
return
}
if lv, ok = info.Level[req.Level]; !ok {
@ -51,10 +48,7 @@ func (this *apiComp) ChallengeReceive(session comm.IUserSession, req *pb.CombatC
Code: pb.ErrorCode_ReqParameterError,
Title: pb.ErrorCode_ReqParameterError.ToString(),
}
data = &pb.ErrorData{
Title: code.ToString(),
Message: err.Error(),
}
return
}
if manster, err = this.module.configure.getGameCombatManster(req.Manster); err != nil {
@ -63,10 +57,7 @@ func (this *apiComp) ChallengeReceive(session comm.IUserSession, req *pb.CombatC
Title: pb.ErrorCode_ConfigNoFound.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: code.ToString(),
Message: err.Error(),
}
return
}
for _, v := range lv.Passmanster {
@ -75,10 +66,7 @@ func (this *apiComp) ChallengeReceive(session comm.IUserSession, req *pb.CombatC
Code: pb.ErrorCode_ReqParameterError,
Title: pb.ErrorCode_ReqParameterError.ToString(),
}
data = &pb.ErrorData{
Title: code.ToString(),
Message: fmt.Sprintf("req.Manster:%d 重复", code),
}
return
}
}
@ -90,10 +78,7 @@ func (this *apiComp) ChallengeReceive(session comm.IUserSession, req *pb.CombatC
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: code.ToString(),
Message: err.Error(),
}
return
}
@ -112,10 +97,6 @@ func (this *apiComp) ChallengeReceive(session comm.IUserSession, req *pb.CombatC
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: code.ToString(),
Message: err.Error(),
}
return
}
}

View File

@ -14,7 +14,10 @@ func (a *apiComp) Autoreceive(session comm.IUserSession, req *pb.DispatchAutoRec
rsp := &pb.DispatchAutoReceiveResp{}
d := a.module.modelDispatch.getDBDispatch(session.GetUserId())
if d == nil {
code = pb.ErrorCode_DataNotFound
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DataNotFound,
Title: pb.ErrorCode_DataNotFound.ToString(),
}
return
}
// var flag bool

View File

@ -38,7 +38,11 @@ func (this *apiComp) Do(session comm.IUserSession, req *pb.DispatchDoReq) (errda
dConf, err := this.module.configure.getDispatchTaskConf(req.TaskId)
if err != nil {
code = pb.ErrorCode_SystemError
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Title: pb.ErrorCode_ConfigNoFound.ToString(),
Message: err.Error(),
}
return
}
@ -53,20 +57,32 @@ func (this *apiComp) Do(session comm.IUserSession, req *pb.DispatchDoReq) (errda
if len(req.HeroIds) < int(dConf.Taskneed) {
this.module.Error("英雄派遣:", log.Field{Key: "HeroIds len", Value: len(req.HeroIds)}, log.Field{Key: "Taskneed", Value: dConf.Taskneed})
code = pb.ErrorCode_DispatchHeroNoEnough
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DispatchHeroNoEnough,
Title: pb.ErrorCode_DispatchHeroNoEnough.ToString(),
Message: err.Error(),
}
return
}
d := this.module.modelDispatch.getDBDispatch(session.GetUserId())
if d == nil && d.Nb == nil {
code = pb.ErrorCode_DataNotFound
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DataNotFound,
Title: pb.ErrorCode_DataNotFound.ToString(),
Message: err.Error(),
}
return
}
//校验门票
ticketAtn := this.module.ModuleTools.GetGlobalConf().DispatchNumtools
if errdata = this.module.CheckRes(session, []*cfg.Gameatn{ticketAtn}); errdata != nil {
code = pb.ErrorCode_DispatchTicketNoEnough
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DispatchTicketNoEnough,
Title: pb.ErrorCode_DispatchTicketNoEnough.ToString(),
Message: err.Error(),
}
return
}
@ -74,6 +90,7 @@ func (this *apiComp) Do(session comm.IUserSession, req *pb.DispatchDoReq) (errda
if err := this.module.modelDispatch.dispatch(session.GetUserId(), req.TaskId, req.HeroIds, d); err != nil {
var errCustom = new(comm.CustomError)
var code pb.ErrorCode
if errors.As(err, &errCustom) {
code = errCustom.Code
} else {
@ -82,6 +99,12 @@ func (this *apiComp) Do(session comm.IUserSession, req *pb.DispatchDoReq) (errda
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
return
}
errdata = &pb.ErrorData{
Code: code,
Title: code.ToString(),
Message: err.Error(),
}
return
}

View File

@ -17,7 +17,10 @@ func (a *apiComp) NoticeCheck(session comm.IUserSession, req *pb.DispatchNoticeR
func (a *apiComp) Notice(session comm.IUserSession, req *pb.DispatchNoticeReq) (errdata *pb.ErrorData) {
d := a.module.modelDispatch.getDBDispatch(session.GetUserId())
if d == nil {
code = pb.ErrorCode_DataNotFound
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DataNotFound,
Title: pb.ErrorCode_DataNotFound.ToString(),
}
return
}
uid := session.GetUserId()

View File

@ -24,7 +24,10 @@ func (a *apiComp) Receive(session comm.IUserSession, req *pb.DispatchReceiveReq)
}
d := a.module.modelDispatch.getDBDispatch(session.GetUserId())
if d == nil {
code = pb.ErrorCode_DataNotFound
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DataNotFound,
Title: pb.ErrorCode_DataNotFound.ToString(),
}
return
}
@ -39,7 +42,10 @@ func (a *apiComp) Receive(session comm.IUserSession, req *pb.DispatchReceiveReq)
}
if !flag {
code = pb.ErrorCode_DispatchNoFinished
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DispatchNoFinished,
Title: pb.ErrorCode_DispatchNoFinished.ToString(),
}
return
}

View File

@ -17,7 +17,10 @@ func (a *apiComp) Refresh(session comm.IUserSession, req *pb.DispatchRefreshReq)
d := a.module.modelDispatch.getDBDispatch(session.GetUserId())
if d == nil {
code = pb.ErrorCode_DataNotFound
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DataNotFound,
Title: pb.ErrorCode_DataNotFound.ToString(),
}
return
}
@ -26,8 +29,14 @@ func (a *apiComp) Refresh(session comm.IUserSession, req *pb.DispatchRefreshReq)
//更新刷新次数
if err := a.module.modelDispatch.updateFreeCount(session.GetUserId(), d.Nb); err != nil {
var customer = new(comm.CustomError)
var code pb.ErrorCode
if errors.As(err, &customer) {
code = customer.Code
errdata = &pb.ErrorData{
Code: code,
Title: code.ToString(),
Message: err.Error(),
}
} else {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
@ -40,7 +49,10 @@ func (a *apiComp) Refresh(session comm.IUserSession, req *pb.DispatchRefreshReq)
} else {
refreshCount := a.module.ModuleTools.GetGlobalConf().DispatchRefreshtimes
if d.Nb.RefreshCount >= refreshCount {
code = pb.ErrorCode_DispatchRefreshMax
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DispatchRefreshMax,
Title: pb.ErrorCode_DispatchRefreshMax.ToString(),
}
return
}
//消耗金币

View File

@ -23,7 +23,10 @@ func (a *apiComp) Weekrecive(session comm.IUserSession, req *pb.DispatchWeekReci
d := a.module.modelDispatch.getDBDispatch(session.GetUserId())
if d == nil {
code = pb.ErrorCode_DataNotFound
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DataNotFound,
Title: pb.ErrorCode_DataNotFound.ToString(),
}
return
}

View File

@ -253,7 +253,7 @@ func (this *modelDispatch) validHeroCond(uid string, taskId int32, heroId string
//获取英雄信息
hero, code := this.module.ModuleHero.GetHeroByObjID(uid, heroId)
if code == pb.ErrorCode_Success && hero != nil {
if code == nil && hero != nil {
for _, v := range gd.Taskreq {
switch v.Key {
case 1: //校验英雄的基础条件

View File

@ -27,7 +27,12 @@ func (this *apiComp) WatchHero(session comm.IUserSession, req *pb.ForumWatchHero
return
}
if hero, err = this.module.modelForum.watchHero(req.Stag, req.Uid, req.HerocId); err != nil {
code = pb.ErrorCode_HeroNoExist
errdata = &pb.ErrorData{
Code: pb.ErrorCode_HeroNoExist,
Title: pb.ErrorCode_HeroNoExist.ToString(),
Message: err.Error(),
}
return
}
equip = this.module.modelForum.watchHeroEquip(req.Stag, req.Uid, hero.EquipID...)
session.SendMsg(string(this.module.GetType()), "watchhero", &pb.ForumWatchHeroResp{

View File

@ -93,9 +93,9 @@ locp:
})
continue
}
var code pb.ErrorCode
code, err = this.secAuth(msg)
if err == nil {
var errdata *pb.ErrorData
errdata = this.secAuth(msg)
if errdata == nil {
// this.gateway.Debugf("----------2 agent:%s uId:%s MainType:%s SubType:%s ", this.sessionId, this.uId, msg.MainType, msg.SubType)
if err = this.messageDistribution(msg); err != nil {
this.gateway.Errorf("messageDistribution err:%v", err)
@ -123,8 +123,8 @@ locp:
MsgId: msg.MsgId,
ReqMainType: msg.MainType,
ReqSubType: msg.SubType,
Code: code,
Err: &pb.ErrorData{Title: "用户消息验证失败!", Datastring: err.Error()},
Code: errdata.Code,
Err: errdata,
})
if err = this.WriteMsg(&pb.UserMessage{
MsgId: msg.MsgId,
@ -170,21 +170,30 @@ locp:
}
// 安全认证 所有协议
func (this *Agent) secAuth(msg *pb.UserMessage) (errdata *pb.ErrorData, err error) {
func (this *Agent) secAuth(msg *pb.UserMessage) (errdata *pb.ErrorData) {
if !utils.ValidSecretKey(msg.Sec) { //验证失败
this.gateway.Errorf("%v", msg.Sec)
return pb.ErrorCode_SignError, fmt.Errorf("key invalid")
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SignError,
Title: pb.ErrorCode_SignError.ToString(),
Message: "key invalid",
}
return
}
return this.decodeUserData(msg)
}
// 解码
func (this *Agent) decodeUserData(msg *pb.UserMessage) (errdata *pb.ErrorData, err error) {
func (this *Agent) decodeUserData(msg *pb.UserMessage) (errdata *pb.ErrorData) {
base64Str := msg.Sec
dec, err := base64.StdEncoding.DecodeString(base64Str[35:])
if err != nil {
this.gateway.Errorf("base64 decode err %v", err)
return pb.ErrorCode_DecodeError, nil
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DecodeError,
Title: pb.ErrorCode_DecodeError.ToString(),
}
return
}
now := configure.Now().Unix()
jsonRet := gjson.Parse(string(dec))
@ -192,7 +201,12 @@ func (this *Agent) decodeUserData(msg *pb.UserMessage) (errdata *pb.ErrorData, e
//秘钥30秒失效
if now-time.Unix(timestamp, 0).Unix() > 30 {
this.gateway.Errorf("now:%v last timestamp:%v more than 30s", now, timestamp)
return pb.ErrorCode_TimestampTimeout, fmt.Errorf("sec key expire")
errdata = &pb.ErrorData{
Code: pb.ErrorCode_TimestampTimeout,
Title: pb.ErrorCode_TimestampTimeout.ToString(),
Message: "sec key expire",
}
return
}
//只有login的时候才需要设置Data
@ -206,21 +220,31 @@ func (this *Agent) decodeUserData(msg *pb.UserMessage) (errdata *pb.ErrorData, e
ad, err := anypb.New(req)
if err != nil {
this.gateway.Errorf("decodeUserData pb err:%v", err)
return pb.ErrorCode_PbError, err
errdata = &pb.ErrorData{
Code: pb.ErrorCode_PbError,
Title: pb.ErrorCode_PbError.ToString(),
Message: err.Error(),
}
return
}
msg.Data = ad
} else {
switch msg.MainType {
case string(comm.ModuleNotify), string(comm.ModuleGate):
return pb.ErrorCode_Success, nil
return
default:
if this.UserId() == "" {
this.gateway.Errorf("[%v.%v] Agent UId empty", msg.MainType, msg.SubType)
return pb.ErrorCode_AgentUidEmpty, fmt.Errorf("no login")
errdata = &pb.ErrorData{
Code: pb.ErrorCode_AgentUidEmpty,
Title: pb.ErrorCode_AgentUidEmpty.ToString(),
Message: "no login",
}
return
}
}
}
return pb.ErrorCode_Success, nil
return
}
func (this *Agent) SessionId() string {

View File

@ -35,7 +35,10 @@ func (this *apiComp) Reset(session comm.IUserSession, req *pb.HoroscopeResetReq)
conf = this.module.ModuleTools.GetGlobalConf()
if info.Lastrest > 0 {
if configure.Now().Sub(time.Unix(info.Lastrest, 0)).Seconds() < float64(conf.HoroscopeResetCd) {
code = pb.ErrorCode_HoroscopeRestCDNoEnd
errdata = &pb.ErrorData{
Code: pb.ErrorCode_HoroscopeRestCDNoEnd,
Title: pb.ErrorCode_HoroscopeRestCDNoEnd.ToString(),
}
return
}
}

View File

@ -51,7 +51,10 @@ func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.HoroscopeUpgrade
return
}
if v, ok := info.Nodes[front.NodeId]; !ok || v < front.Lv {
code = pb.ErrorCode_HoroscopeNotTurnedOn
errdata = &pb.ErrorData{
Code: pb.ErrorCode_HoroscopeNotTurnedOn,
Title: pb.ErrorCode_HoroscopeNotTurnedOn.ToString(),
}
return
}
}

View File

@ -143,7 +143,7 @@ func (this *modelHoroscope) reddot(session comm.IUserSession) bool {
var (
info *pb.DBHoroscope
horoscope *cfg.GameHoroscope
code pb.ErrorCode
errdata *pb.ErrorData
err error
)
if info, err = this.queryInfo(session.GetUserId()); err != nil {
@ -155,7 +155,7 @@ func (this *modelHoroscope) reddot(session comm.IUserSession) bool {
for _, v := range horoscope.GetDataList() {
if lv, ok := info.Nodes[v.NodeId]; !ok && v.Lv > lv {
if errdata = this.module.CheckRes(session, v.CostItem); code == pb.ErrorCode_Success {
if errdata = this.module.CheckRes(session, v.CostItem); errdata == nil {
return true
}
}

View File

@ -328,6 +328,7 @@ func (this *ModuleBase) CheckRes(session comm.IUserSession, res []*cfg.Gameatn)
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ResNoEnough,
Title: pb.ErrorCode_ResNoEnough.ToString(),
Atn: &pb.UserAssets{A: comm.AttrType, T: k, N: v},
Message: fmt.Sprintf("资源%v的数量:%v 小于 %v", k, amount, v),
}
// this.Warn("资源不足", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "T", Value: k}, log.Field{Key: "N", Value: v})
@ -340,6 +341,7 @@ func (this *ModuleBase) CheckRes(session comm.IUserSession, res []*cfg.Gameatn)
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ResNoEnough,
Title: pb.ErrorCode_ResNoEnough.ToString(),
Atn: &pb.UserAssets{A: comm.ItemType, T: k, N: v},
Message: fmt.Sprintf("道具%v的数量:%v 小于 %v", k, amount, v),
}
// this.Warn("道具不足", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "T", Value: k}, log.Field{Key: "N", Value: v})
@ -372,22 +374,34 @@ func (this *ModuleBase) ConsumeRes(session comm.IUserSession, res []*cfg.Gameatn
}
// 校验数量
for k, v := range attrs {
if this.ModuleUser.QueryAttributeValue(session.GetUserId(), k) < -int64(v) { // -v 负负得正
code = pb.ErrorCode_ResNoEnough
amount := this.ModuleUser.QueryAttributeValue(session.GetUserId(), k)
if amount < -int64(v) { // -v 负负得正
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ResNoEnough,
Title: pb.ErrorCode_ResNoEnough.ToString(),
Atn: &pb.UserAssets{A: comm.AttrType, T: k, N: v},
Message: fmt.Sprintf("资源%v的数量:%v 小于 %v", k, amount, v),
}
this.Warn("资源不足", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "T", Value: k}, log.Field{Key: "N", Value: v})
return
}
}
for k, v := range items {
if int32(this.ModuleItems.QueryItemAmount(session.GetUserId(), k)) < -v {
code = pb.ErrorCode_ResNoEnough
amount := this.ModuleItems.QueryItemAmount(session.GetUserId(), k)
if int32(amount) < -v {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ResNoEnough,
Title: pb.ErrorCode_ResNoEnough.ToString(),
Atn: &pb.UserAssets{A: comm.ItemType, T: k, N: v},
Message: fmt.Sprintf("道具%v的数量:%v 小于 %v", k, amount, v),
}
this.Warn("道具不足", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "T", Value: k}, log.Field{Key: "N", Value: v})
return
}
}
// 真正消耗
if len(attrs) > 0 {
code = this.ModuleUser.AddAttributeValues(session, attrs, bPush)
errdata = this.ModuleUser.AddAttributeValues(session, attrs, bPush)
if errdata != nil {
return
}
@ -398,7 +412,7 @@ func (this *ModuleBase) ConsumeRes(session comm.IUserSession, res []*cfg.Gameatn
}
}
if len(items) > 0 {
_, code = this.ModuleItems.AddItems(session, items, bPush)
_, errdata = this.ModuleItems.AddItems(session, items, bPush)
if errdata != nil {
return
}
@ -459,44 +473,44 @@ func (this *ModuleBase) DispenseRes(session comm.IUserSession, res []*cfg.Gameat
}
if len(attrs) > 0 { //用户属性资源
code = this.ModuleUser.AddAttributeValues(session, attrs, bPush)
this.Debugf("发放用户资源: %v code : [%v]", attrs, code)
errdata = this.ModuleUser.AddAttributeValues(session, attrs, bPush)
this.Debugf("发放用户资源: %v errdata: %v", attrs, errdata)
}
if len(items) > 0 { //道具资源
_, code = this.ModuleItems.AddItems(session, items, bPush)
this.Debugf("发放道具资源: %v code : [%v]", items, code)
_, errdata = this.ModuleItems.AddItems(session, items, bPush)
this.Debugf("发放道具资源: %v errdata: %v", items, errdata)
}
if len(heros) > 0 { //卡片资源
_, _, code = this.ModuleHero.CreateRepeatHeros(session, heros, bPush)
this.Debugf("发放英雄资源: %v code : [%v]", heros, code)
_, _, errdata = this.ModuleHero.CreateRepeatHeros(session, heros, bPush)
this.Debugf("发放英雄资源: %v errdata: %v", heros, errdata)
}
if len(equips) > 0 {
_, code = this.ModuleEquipment.AddNewEquipments(session, equips, bPush)
this.Debugf("发放装备资源: %v code : [%v]", equips, code)
_, errdata = this.ModuleEquipment.AddNewEquipments(session, equips, bPush)
this.Debugf("发放装备资源: %v errdata: %v", equips, errdata)
}
if len(vip) > 0 { //卡片资源
for k := range vip {
code, _ = this.ModulePrivilege.Delivery(session, k)
this.Debugf("发放月卡资源: %v code : [%v]", k, code)
errdata, _ = this.ModulePrivilege.Delivery(session, k)
this.Debugf("发放月卡资源: %v errdata: %v", k, errdata)
}
}
if len(atlas) > 0 {
for k := range atlas {
this.ModuleSmithy.CheckActivateAtlasCollect(session.GetUserId(), k)
this.Debugf("发放图鉴资源: %v code : [%v]", k, code)
this.Debugf("发放图鉴资源: %v errdata: %v", k, errdata)
}
}
if len(panda) > 0 {
code = this.ModulePractice.AddItems(session, panda, bPush)
this.Debugf("发放武馆资源: %v code : [%v]", panda, code)
errdata = this.ModulePractice.AddItems(session, panda, bPush)
this.Debugf("发放武馆资源: %v errdata: %v", panda, errdata)
}
if len(mts) > 0 {
code = this.ModuleParkour.AddMounts(session, mts, bPush)
this.Debugf("发放捕羊大赛资源: %v code : [%v]", mts, code)
errdata = this.ModuleParkour.AddMounts(session, mts, bPush)
this.Debugf("发放捕羊大赛资源: %v errdata: %v", mts, errdata)
}
if len(per) > 0 {
code = this.ModuleUser.AddPer(session, per, bPush)
this.Debugf("发放用户皮肤资源资源: %v code : [%v]", mts, code)
errdata = this.ModuleUser.AddPer(session, per, bPush)
this.Debugf("发放用户皮肤资源资源: %v errdata: %v", mts, errdata)
}
return
}
@ -659,8 +673,8 @@ func (this *ModuleBase) DispenseAtno(session comm.IUserSession, res []*cfg.Gamea
}
if len(attrs) > 0 { //用户属性资源
code = this.ModuleUser.AddAttributeValues(session, attrs, bPush)
this.Debugf("发放用户资源: %v [%v]", attrs, code)
errdata = this.ModuleUser.AddAttributeValues(session, attrs, bPush)
this.Debugf("发放用户资源: %v [%v]", attrs, errdata)
for k, v := range attrs {
atno = append(atno, &pb.UserAtno{
A: "attr",
@ -701,8 +715,8 @@ func (this *ModuleBase) DispenseAtno(session comm.IUserSession, res []*cfg.Gamea
}
if len(vip) > 0 { //卡片资源
for k := range vip {
code, _ = this.ModulePrivilege.Delivery(session, k)
this.Debugf("发放月卡资源: %v [%v]", k, code)
errdata, _ = this.ModulePrivilege.Delivery(session, k)
this.Debugf("发放月卡资源: %v [%v]", k, errdata)
}
}

View File

@ -18,37 +18,48 @@ func (this *apiComp) Ask(session comm.IUserSession, req *pb.MoonfantasyAskReq) (
lock *redis.RedisMutex
// umfantasy *pb.DBUserMFantasy
user *pb.DBUser
cd pb.ErrorCode
isjson bool
err error
)
defer func() {
session.SendMsg(string(this.module.GetType()), "ask", &pb.MoonfantasyAskResp{Code: cd, Info: mdata})
}()
if cd = this.AskCheck(session, req); cd != pb.ErrorCode_Success {
if errdata = this.AskCheck(session, req); errdata != nil {
return
}
//月之秘境需要加分布式锁 防止多人同时操作
if lock, err = this.module.modelDream.newDreamLock(req.Mid); err != nil {
cd = pb.ErrorCode_DBError
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.ToString(),
}
return
}
defer lock.Unlock()
if err = lock.Lock(); err != nil {
cd = pb.ErrorCode_DBError
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.ToString(),
}
this.module.Errorln(err)
return
}
if mdata, err = this.module.modelDream.querymfantasy(req.Mid); err != nil {
cd = pb.ErrorCode_DBError
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.ToString(),
}
return
}
if mdata == nil {
cd = pb.ErrorCode_MoonfantasyHasExpired
errdata = &pb.ErrorData{
Code: pb.ErrorCode_MoonfantasyHasExpired,
Title: pb.ErrorCode_MoonfantasyHasExpired.ToString(),
}
return
}
if this.module.modelDream.checkMFantasyExpiration(mdata) { //已过期
cd = pb.ErrorCode_MoonfantasyHasExpired
errdata = &pb.ErrorData{
Code: pb.ErrorCode_MoonfantasyHasExpired,
Title: pb.ErrorCode_MoonfantasyHasExpired.ToString(),
}
return
}
for _, v := range mdata.Join {
@ -60,7 +71,10 @@ func (this *apiComp) Ask(session comm.IUserSession, req *pb.MoonfantasyAskReq) (
if !isjson {
if len(mdata.Join) >= int(mdata.Numup) {
cd = pb.ErrorCode_MoonfantasyJoinUp
errdata = &pb.ErrorData{
Code: pb.ErrorCode_MoonfantasyJoinUp,
Title: pb.ErrorCode_MoonfantasyJoinUp.ToString(),
}
return
}
// if umfantasy, err = this.module.modelUserMF.queryUsermfantasy(session.GetUserId()); err != nil {
@ -85,5 +99,7 @@ func (this *apiComp) Ask(session comm.IUserSession, req *pb.MoonfantasyAskReq) (
"join": mdata.Join,
})
}
session.SendMsg(string(this.module.GetType()), "ask", &pb.MoonfantasyAskResp{Info: mdata})
return
}

View File

@ -15,24 +15,109 @@ func (this *apiComp) BattleCheck(session comm.IUserSession, req *pb.MoonfantasyB
func (this *apiComp) Battle(session comm.IUserSession, req *pb.MoonfantasyBattleReq) (errdata *pb.ErrorData) {
var (
boss *cfg.GameDreamlandBoosData
// umfantasy *pb.DBUserMFantasy
mdata *pb.DBMoonFantasy
record *pb.DBBattleRecord
cd pb.ErrorCode
isjoin bool
err error
)
defer func() {
if cd == pb.ErrorCode_Success {
// this.module.modelUserMF.Change(session.GetUserId(), map[string]interface{}{
// "ticket": umfantasy.Ticket,
// })
if errdata = this.BattleCheck(session, req); errdata != nil {
return
}
if mdata, err = this.module.modelDream.querymfantasy(req.Mid); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
return
}
if mdata == nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_MoonfantasyHasExpired,
Title: pb.ErrorCode_MoonfantasyHasExpired.ToString(),
}
return
}
if this.module.modelDream.checkMFantasyExpiration(mdata) { //已过期
errdata = &pb.ErrorData{
Code: pb.ErrorCode_MoonfantasyHasExpired,
Title: pb.ErrorCode_MoonfantasyHasExpired.ToString(),
}
return
}
for _, v := range mdata.Join {
if v.Uid == session.GetUserId() {
isjoin = true
}
}
if !isjoin {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_MoonfantasyNoJoin,
Title: pb.ErrorCode_MoonfantasyNoJoin.ToString(),
}
return
}
if boss, err = this.module.configure.GetMonsterById(mdata.Monster); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Title: pb.ErrorCode_ConfigNoFound.ToString(),
Message: err.Error(),
}
return
}
if errdata = this.module.ModuleItems.RecoverTicket(session); errdata != nil {
return
}
if errdata = this.module.CheckRes(session, boss.PsConsume); errdata != nil {
return
}
if len(mdata.Join) >= int(mdata.Numup) {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_MoonfantasyJoinUp,
Title: pb.ErrorCode_MoonfantasyJoinUp.ToString(),
Message: err.Error(),
}
return
}
if this.module.modelDream.checkMFantasyExpiration(mdata) { //已过期
errdata = &pb.ErrorData{
Code: pb.ErrorCode_MoonfantasyHasExpired,
Title: pb.ErrorCode_MoonfantasyHasExpired.ToString(),
Message: err.Error(),
}
return
}
if v, ok := mdata.Record[session.GetUserId()]; ok {
if v >= mdata.Unitmup {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_MoonfantasyDareUp,
Title: pb.ErrorCode_MoonfantasyDareUp.ToString(),
Message: err.Error(),
}
return
} else {
mdata.Record[session.GetUserId()]++
}
} else {
mdata.Record[session.GetUserId()] = 1
}
if errdata, record = this.module.battle.CreatePveBattle(session, &pb.BattlePVEReq{
Ptype: pb.PlayType_moonfantasy,
Format: req.Battle,
Mformat: boss.Monsterformatid,
}); err != nil {
return
}
this.module.modelDream.ChangeList("", mdata.Id, map[string]interface{}{
"record": mdata.Record,
})
session.SendMsg(string(this.module.GetType()), "battle", &pb.MoonfantasyBattleResp{
Code: cd,
Mid: mdata.Monster,
Info: &pb.BattleInfo{
Id: record.Id,
@ -46,81 +131,6 @@ func (this *apiComp) Battle(session comm.IUserSession, req *pb.MoonfantasyBattle
Buleflist: record.Buleflist,
},
})
// this.module.ModuleRtask.SendToRtask(session, comm.Rtype88, 1)
go this.module.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.Rtype88, 1))
} else {
session.SendMsg(string(this.module.GetType()), "battle", &pb.MoonfantasyBattleResp{Code: cd})
}
}()
if cd = this.BattleCheck(session, req); cd != pb.ErrorCode_Success {
return
}
if mdata, err = this.module.modelDream.querymfantasy(req.Mid); err != nil {
cd = pb.ErrorCode_DBError
return
}
if mdata == nil {
cd = pb.ErrorCode_MoonfantasyHasExpired
return
}
if this.module.modelDream.checkMFantasyExpiration(mdata) { //已过期
cd = pb.ErrorCode_MoonfantasyHasExpired
return
}
for _, v := range mdata.Join {
if v.Uid == session.GetUserId() {
isjoin = true
}
}
if !isjoin {
cd = pb.ErrorCode_MoonfantasyNoJoin
return
}
// if umfantasy, err = this.module.modelUserMF.queryUsermfantasy(session.GetUserId()); err != nil {
// cd = pb.ErrorCode_CacheReadError
// }
// if umfantasy.Ticket < this.module.ModuleTools.GetGlobalConf().DreamlandCos {
// cd = pb.ErrorCode_MoonfantasyNotEnoughbattles
// }
// umfantasy.Ticket -= this.module.ModuleTools.GetGlobalConf().DreamlandCos
if boss, err = this.module.configure.GetMonsterById(mdata.Monster); err != nil {
cd = pb.ErrorCode_ConfigNoFound
return
}
if cd = this.module.ModuleItems.RecoverTicket(session); cd != pb.ErrorCode_Success {
return
}
if cd = this.module.CheckRes(session, boss.PsConsume); cd != pb.ErrorCode_Success {
return
}
if len(mdata.Join) >= int(mdata.Numup) {
cd = pb.ErrorCode_MoonfantasyJoinUp
return
}
if this.module.modelDream.checkMFantasyExpiration(mdata) { //已过期
cd = pb.ErrorCode_MoonfantasyHasExpired
return
}
if v, ok := mdata.Record[session.GetUserId()]; ok {
if v >= mdata.Unitmup {
cd = pb.ErrorCode_MoonfantasyDareUp
return
} else {
mdata.Record[session.GetUserId()]++
}
} else {
mdata.Record[session.GetUserId()] = 1
}
cd, record = this.module.battle.CreatePveBattle(session, &pb.BattlePVEReq{
Ptype: pb.PlayType_moonfantasy,
Format: req.Battle,
Mformat: boss.Monsterformatid,
})
return
}

View File

@ -38,15 +38,15 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.MoonfantasyBuyReq) (
Title: pb.ErrorCode_ConfigNoFound.ToString(),
Message: err.Error(),
}
data = &pb.ErrorData{
Title: code.ToString(),
Message: comm.NewNotFoundConfErr(modelName, "global.json", "CopsBuyGet").Error(),
}
return
}
if info, err = this.module.modelUserMF.queryUsermfantasy(session.GetUserId()); err != nil && err != mgo.MongodbNil {
code = pb.ErrorCode_CacheReadError
errdata = &pb.ErrorData{
Code: pb.ErrorCode_CacheReadError,
Title: pb.ErrorCode_CacheReadError.ToString(),
Message: err.Error(),
}
return
}
this.module.modelUserMF.recoverTicket(session, info)
@ -64,7 +64,11 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.MoonfantasyBuyReq) (
for i := int32(0); i < req.BuyNum; i++ {
if int(info.BuyNum+i+1) > maxbuy+vipbuy {
code = pb.ErrorCode_ArenaTicketBuyUp
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ArenaTicketBuyUp,
Title: pb.ErrorCode_ArenaTicketBuyUp.ToString(),
Message: err.Error(),
}
return
}
if challengeD, err = this.module.configure.GetchallengeData(info.BuyNum + i + 1); err != nil || challengeD == nil {

View File

@ -20,16 +20,20 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.MoonfantasyGetLi
mfantasys []*pb.DBMoonFantasy = make([]*pb.DBMoonFantasy, 0)
)
if info, err = this.module.modelUserMF.queryUsermfantasy(session.GetUserId()); err != nil && err != mgo.MongodbNil {
code = pb.ErrorCode_CacheReadError
errdata = &pb.ErrorData{
Code: pb.ErrorCode_CacheReadError,
Title: pb.ErrorCode_CacheReadError.ToString(),
Message: err.Error(),
}
return
}
// this.module.modelUserMF.recoverTicket(session, info)
// if err = this.module.modelUserMF.updateUserInfo(info); err != nil {
// errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
// Code: pb.ErrorCode_DBError,
// Title: pb.ErrorCode_DBError.ToString(),
// Message: err.Error(),
// }
// return
// }
this.module.ModuleItems.RecoverTicket(session)

View File

@ -36,7 +36,7 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.MoonfantasyRecei
}
return
}
if code, iswin = this.module.battle.CheckBattleReport(session, req.Report); errdata != nil {
if errdata, iswin = this.module.battle.CheckBattleReport(session, req.Report); errdata != nil {
return
}
if !iswin {

View File

@ -202,10 +202,10 @@ func (this *modelDreamComp) noticeuserfriend(session comm.IUserSession, mid stri
)
// if model, err = this.module.GetDBNodule(session, comm.TableFriend, 0); err != nil {
// errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
// Code: pb.ErrorCode_DBError,
// Title: pb.ErrorCode_DBError.ToString(),
// Message: err.Error(),
// }
// this.module.Errorf("session:%v err:%v", session, err)
// return
// }

View File

@ -27,10 +27,16 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.OldtimesReceiveR
for _, v := range ot.Chapters {
if v.Cid == req.ChapterId {
if v.Received == 1 {
code = pb.ErrorCode_OldtimesReceived
errdata = &pb.ErrorData{
Code: pb.ErrorCode_OldtimesReceived,
Title: pb.ErrorCode_OldtimesReceived.ToString(),
}
return
} else if v.Status != int32(finish) {
code = pb.ErrorCode_OldtimesNoAllFinished
errdata = &pb.ErrorData{
Code: pb.ErrorCode_OldtimesNoAllFinished,
Title: pb.ErrorCode_OldtimesNoAllFinished.ToString(),
}
return
} else {
v.Received = 1

View File

@ -43,7 +43,11 @@ func (this *apiComp) Invite(session comm.IUserSession, req *pb.ParkourInviteReq)
return
}
if info.Captainid != "" && info.Captainid != session.GetUserId() { //自己不是队长 无权邀请他人
code = pb.ErrorCode_ParkourInviteNoPermissions
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ParkourInviteNoPermissions,
Title: pb.ErrorCode_ParkourInviteNoPermissions.ToString(),
Message: err.Error(),
}
return
}
if len(info.Member) > 3 {
@ -54,7 +58,10 @@ func (this *apiComp) Invite(session comm.IUserSession, req *pb.ParkourInviteReq)
return
}
if tuser = this.module.ModuleUser.GetUser(session.GetUserId()); tuser == nil {
code = pb.ErrorCode_SystemError
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SystemError,
Title: pb.ErrorCode_SystemError.ToString(),
}
return
}
if mount, err = this.module.configure.getGameBuzkashiMount(info.Dfmount); err != nil {
@ -85,7 +92,10 @@ func (this *apiComp) Invite(session comm.IUserSession, req *pb.ParkourInviteReq)
return
}
if tuser = this.module.ModuleUser.GetUser(req.Uid); tuser == nil {
code = pb.ErrorCode_SystemError
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SystemError,
Title: pb.ErrorCode_SystemError.ToString(),
}
return
}
if mount, err = this.module.configure.getGameBuzkashiMount(tinfo.Dfmount); err != nil {
@ -112,7 +122,10 @@ func (this *apiComp) Invite(session comm.IUserSession, req *pb.ParkourInviteReq)
&pb.ParkourTeamChanagePush{Team: info}, users...)
} else {
if tinfo.Captainid != "" {
code = pb.ErrorCode_ParkourTargetTeamed
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ParkourTargetTeamed,
Title: pb.ErrorCode_ParkourTargetTeamed.ToString(),
}
return
}
ok = false

View File

@ -47,7 +47,10 @@ func (this *apiComp) InviteHandle(session comm.IUserSession, req *pb.ParkourInvi
return
}
if len(tean.Member) >= 3 {
code = pb.ErrorCode_ParkourMemberFull
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ParkourMemberFull,
Title: pb.ErrorCode_ParkourMemberFull.ToString(),
}
return
}
if req.State == 3 {
@ -60,7 +63,10 @@ func (this *apiComp) InviteHandle(session comm.IUserSession, req *pb.ParkourInvi
}
}
if !ok {
code = pb.ErrorCode_ParkourInviteOverdue
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ParkourInviteOverdue,
Title: pb.ErrorCode_ParkourInviteOverdue.ToString(),
}
return
}
tean.Invite = append(tean.Invite[0:index], tean.Invite[index+1:]...)

View File

@ -42,12 +42,20 @@ func (this *apiComp) JoinTeam(session comm.IUserSession, req *pb.ParkourJoinTeam
}
// 状态校验
if info.State != pb.RaceTeamState_resting { // 不是休息中不能参加
code = pb.ErrorCode_StateInvalid
errdata = &pb.ErrorData{
Code: pb.ErrorCode_StateInvalid,
Title: pb.ErrorCode_StateInvalid.ToString(),
Message: err.Error(),
}
return
}
if len(info.Member) > 3 {
code = pb.ErrorCode_ParkourMemberFull
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ParkourMemberFull,
Title: pb.ErrorCode_ParkourMemberFull.ToString(),
Message: err.Error(),
}
return
}
if tean, err = this.module.parkourComp.queryinfo(req.Uid); err != nil {
@ -62,7 +70,12 @@ func (this *apiComp) JoinTeam(session comm.IUserSession, req *pb.ParkourJoinTeam
users = make([]string, len(tean.Member))
for i, v := range tean.Member {
if v.Uid == session.GetUserId() {
code = pb.ErrorCode_ParkourTargetTeamed // 自己已经在队伍中
// 自己已经在队伍中
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ParkourTargetTeamed,
Title: pb.ErrorCode_ParkourTargetTeamed.ToString(),
Message: err.Error(),
}
return
}
users[i] = v.Uid

View File

@ -48,7 +48,10 @@ func (this *apiComp) RaceMatch(session comm.IUserSession, req *pb.ParkourRaceMat
team.Captainid = team.Uid
team.State = pb.RaceTeamState_teaming
if tuser = this.module.ModuleUser.GetUser(session.GetUserId()); tuser == nil {
code = pb.ErrorCode_SystemError
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SystemError,
Title: pb.ErrorCode_SystemError.ToString(),
}
return
}
if mount, err = this.module.configure.getGameBuzkashiMount(team.Dfmount); err != nil {

View File

@ -47,7 +47,11 @@ func (this *apiComp) DailyBuy(session comm.IUserSession, req *pb.PayDailyBuyReq)
}
if info.Items[conf.Id] != nil {
if info.Items[conf.Id].Buyunm <= 0 {
code = pb.ErrorCode_PayBuyNumNotEnough
errdata = &pb.ErrorData{
Code: pb.ErrorCode_PayBuyNumNotEnough,
Title: pb.ErrorCode_PayBuyNumNotEnough.ToString(),
Message: err.Error(),
}
return
}
}
@ -58,7 +62,7 @@ func (this *apiComp) DailyBuy(session comm.IUserSession, req *pb.PayDailyBuyReq)
}
}
if code, items = this.module.modelDaily.delivery(session, conf.Packagetype); errdata != nil {
if errdata, items = this.module.modelDaily.delivery(session, conf.Packagetype); errdata != nil {
return
}

View File

@ -28,6 +28,6 @@ func (this *apiComp) Delivery(session comm.IUserSession, req *pb.PayDeliveryReq)
this.module.Errorln(err)
return
}
session.SendMsg(string(this.module.GetType()), "delivery", &pb.PayDeliveryResp{Code: code})
session.SendMsg(string(this.module.GetType()), "delivery", &pb.PayDeliveryResp{})
return
}

View File

@ -77,6 +77,7 @@ func (this *Pay) Rpc_ModulePayDelivery(ctx context.Context, args *pb.PayDelivery
res []*cfg.Gameatn
items []*pb.UserAssets
session comm.IUserSession
errdata *pb.ErrorData
online bool
)
@ -98,12 +99,14 @@ func (this *Pay) Rpc_ModulePayDelivery(ctx context.Context, args *pb.PayDelivery
this.PutUserSession(session)
}()
if session, online = this.GetUserSession(args.Uid); online {
if reply.Code = this.DispenseRes(session, res, true); reply.Code != pb.ErrorCode_Success {
if errdata = this.DispenseRes(session, res, true); errdata != nil {
reply.Code = errdata.Code
return
}
} else {
if reply.Code = this.DispenseRes(session, res, false); reply.Code != pb.ErrorCode_Success {
if errdata = this.DispenseRes(session, res, false); errdata != nil {
reply.Code = errdata.Code
return
}
}
@ -122,10 +125,16 @@ func (this *Pay) Rpc_ModulePayDelivery(ctx context.Context, args *pb.PayDelivery
case 1:
break
case 2:
reply.Code, items = this.modelDaily.delivery(session, args.Productid)
if errdata, items = this.modelDaily.delivery(session, args.Productid); errdata != nil {
reply.Code = errdata.Code
return
}
break
case 3:
reply.Code, items = this.privilege.Delivery(session, args.Productid)
if errdata, items = this.privilege.Delivery(session, args.Productid); errdata != nil {
reply.Code = errdata.Code
return
}
break
}
for _, v := range res {
@ -204,10 +213,14 @@ func (this *Pay) ModulePayDelivery(session comm.IUserSession, Productid string,
case 1:
break
case 2:
code, items = this.modelDaily.delivery(session, Productid)
if errdata, items = this.modelDaily.delivery(session, Productid); errdata != nil {
return
}
break
case 3:
code, items = this.privilege.Delivery(session, Productid)
if errdata, items = this.privilege.Delivery(session, Productid); errdata != nil {
return
}
break
}
for _, v := range res {

View File

@ -49,14 +49,20 @@ func (this *apiComp) Accept(session comm.IUserSession, req *pb.PracticeAcceptReq
return
}
if redRecord.Status == 1 { //已经在战斗中了
code = pb.ErrorCode_PracticeQiecuoing
errdata = &pb.ErrorData{
Code: pb.ErrorCode_PracticeQiecuoing,
Title: pb.ErrorCode_PracticeQiecuoing.ToString(),
}
return
}
keep = false
for _, v := range redRecord.Targets {
if v.Uid == session.GetUserId() {
if configure.Now().Sub(time.Unix(v.Timestamp, 0)).Seconds() > 10 {
code = pb.ErrorCode_PracticeInviteTimeOut
errdata = &pb.ErrorData{
Code: pb.ErrorCode_PracticeInviteTimeOut,
Title: pb.ErrorCode_PracticeInviteTimeOut.ToString(),
}
return
}
keep = true
@ -73,22 +79,28 @@ func (this *apiComp) Accept(session comm.IUserSession, req *pb.PracticeAcceptReq
//发起者 red
red := this.module.ModuleUser.GetUser(req.Uid)
if red == nil {
code = pb.ErrorCode_UserNofound
errdata = &pb.ErrorData{
Code: pb.ErrorCode_UserNofound,
Title: pb.ErrorCode_UserNofound.ToString(),
}
this.module.Error("未找到红方信息", log.Field{Key: "uid", Value: req.Uid})
return
}
blue := this.module.ModuleUser.GetUser(session.GetUserId())
if blue == nil {
code = pb.ErrorCode_UserNofound
errdata = &pb.ErrorData{
Code: pb.ErrorCode_UserNofound,
Title: pb.ErrorCode_UserNofound.ToString(),
}
this.module.Error("未找到蓝方信息", log.Field{Key: "uid", Value: session.GetUserId()})
return
}
if redRecord.Battid, code = this.module.pvp.CreatePvp(
if redRecord.Battid, errdata = this.module.pvp.CreatePvp(
&pb.PvpUserInfo{Uid: red.Uid, Name: red.Name, Avatar: red.Avatar, Lv: red.Lv},
&pb.PvpUserInfo{Uid: blue.Uid, Name: blue.Name, Avatar: blue.Avatar, Lv: blue.Lv},
pb.PvpType_friends,
); errdata != nil {
this.module.Error("CreatePvp", log.Field{Key: "code", Value: code})
this.module.Error("CreatePvp", log.Field{Key: "code", Value: errdata})
return
}
redRecord.Status = 1
@ -109,7 +121,11 @@ func (this *apiComp) Accept(session comm.IUserSession, req *pb.PracticeAcceptReq
if err := session.SendMsg(string(this.module.GetType()), "accept", &pb.FriendAcceptResp{
IsSucc: true,
}); err != nil {
code = pb.ErrorCode_SystemError
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SystemError,
Title: pb.ErrorCode_SystemError.ToString(),
Message: err.Error(),
}
return
}

View File

@ -99,7 +99,7 @@ func (this *apiComp) Expulsion(session comm.IUserSession, req *pb.PracticeExpuls
if conf, err := this.module.configure.getGamePandamasYxjx(k); err != nil {
this.module.Errorln(err)
} else if v/conf.Register > 0 {
if hero, code := this.module.ModuleHero.GetHeroByObjID(session.GetUserId(), pillar.Hero); code == pb.ErrorCode_Success {
if hero, errdata := this.module.ModuleHero.GetHeroByObjID(session.GetUserId(), pillar.Hero); errdata == nil {
if heroconf, _ := this.module.configure.GetHeroConfig(hero.HeroID); heroconf != nil {
if (conf.Camp == 0 || (conf.Camp != 0 && heroconf.Race == conf.Camp)) && (conf.Occupation == 0 || (conf.Occupation != 0 && heroconf.Job == conf.Occupation)) {
exp1 += minutes * int32(math.Floor(float64(v/conf.Register)*float64(conf.ExpBonus))) * exp
@ -196,7 +196,7 @@ func (this *apiComp) Expulsion(session comm.IUserSession, req *pb.PracticeExpuls
}
}
_session, ok = this.module.GetUserSession(pillar.Uid)
if _, code = this.module.ModuleHero.AddHeroExp(_session, pillar.Hero, exp); errdata != nil {
if _, errdata = this.module.ModuleHero.AddHeroExp(_session, pillar.Hero, exp); errdata != nil {
return
}
if errdata = this.module.ModuleHero.KungFuHero(_session, pillar.Hero, false, ""); errdata != nil {

View File

@ -67,7 +67,11 @@ func (this *apiComp) GymRefresh(session comm.IUserSession, req *pb.PracticeGymRe
}
}
if len(confs) == 0 {
code = pb.ErrorCode_ConfigurationException
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigurationException,
Title: pb.ErrorCode_ConfigurationException.ToString(),
Message: err.Error(),
}
return
}
r := rand.New(rand.NewSource(configure.Now().Unix()))

View File

@ -27,7 +27,7 @@ func (this *apiComp) NPCBattkle(session comm.IUserSession, req *pb.PracticeNPCBa
return
}
if code, record = this.module.battle.CreateLPVEBattle(session, &pb.BattleLPVEReq{
if errdata, record = this.module.battle.CreateLPVEBattle(session, &pb.BattleLPVEReq{
Ptype: pb.PlayType_practicenpc,
Format: req.Formation,
Monsterleadpos: room.Captain,

View File

@ -36,7 +36,7 @@ func (this *apiComp) NPCBattkleFinish(session comm.IUserSession, req *pb.Practic
return
}
if code, _ = this.module.battle.CheckBattleReport(session, req.Report); errdata != nil {
if errdata, _ = this.module.battle.CheckBattleReport(session, req.Report); errdata != nil {
return
}

View File

@ -20,25 +20,25 @@ func (this *apiComp) NPCDialog(session comm.IUserSession, req *pb.PracticeNPCDia
// )
// if room, err = this.module.modelPandata.queryUserMartialhall(session.GetUserId()); err != nil {
// errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
// Code: pb.ErrorCode_DBError,
// Title: pb.ErrorCode_DBError.ToString(),
// Message: err.Error(),
// }
// return
// }
// if room.Npcstate != 2 {
// errdata = &pb.ErrorData{
Code: pb.ErrorCode_ReqParameterError,
Title: pb.ErrorCode_ReqParameterError.ToString(),
}
// Code: pb.ErrorCode_ReqParameterError,
// Title: pb.ErrorCode_ReqParameterError.ToString(),
// }
// return
// }
// // if conf, err = this.module.configure.getDispatchBattleData(room.Currnpc); err != nil {
// // errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Title: pb.ErrorCode_ConfigNoFound.ToString(),
Message: err.Error(),
}
// Code: pb.ErrorCode_ConfigNoFound,
// Title: pb.ErrorCode_ConfigNoFound.ToString(),
// Message: err.Error(),
// }
// // return
// // }
// // if errdata = this.module.DispenseRes(session, conf.StoryAward, true); errdata != nil {

View File

@ -54,27 +54,43 @@ func (this *apiComp) Qiecuo(session comm.IUserSession, req *pb.PracticeQiecuoReq
if result.Battid == fresult.Battid { //两个人正在战斗中
if battle, err = this.module.pvp.QueryBattle(result.Battid); err != nil {
this.module.Error("查询pvp数据失败!", log.Field{Key: "id", Value: result.Battid}, log.Field{Key: "err", Value: err.Error()})
code = pb.ErrorCode_SystemError
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SystemError,
Title: pb.ErrorCode_SystemError.ToString(),
Message: err.Error(),
}
return
}
if err = session.SendMsg(string(this.module.GetType()), "qiecuo", &pb.PracticeQiecuoResp{Fid: req.Fid, Isbattle: true, Battle: battle}); err != nil {
code = pb.ErrorCode_SystemError
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SystemError,
Title: pb.ErrorCode_SystemError.ToString(),
}
return
}
return
} else {
if result.Status == 1 {
code = pb.ErrorCode_PracticeYouQiecuoing
errdata = &pb.ErrorData{
Code: pb.ErrorCode_PracticeYouQiecuoing,
Title: pb.ErrorCode_PracticeYouQiecuoing.ToString(),
}
return
} else {
code = pb.ErrorCode_PracticeTargetQiecuoing
errdata = &pb.ErrorData{
Code: pb.ErrorCode_PracticeTargetQiecuoing,
Title: pb.ErrorCode_PracticeTargetQiecuoing.ToString(),
}
return
}
}
}
//目标是否在线
if !this.module.ModuleUser.IsOnline(req.Fid) {
code = pb.ErrorCode_UserOffline
errdata = &pb.ErrorData{
Code: pb.ErrorCode_UserOffline,
Title: pb.ErrorCode_UserOffline.ToString(),
}
return
}
@ -94,7 +110,10 @@ func (this *apiComp) Qiecuo(session comm.IUserSession, req *pb.PracticeQiecuoReq
if configure.Now().Sub(time.Unix(v.Timestamp, 0)).Seconds() > 10 {
v.Timestamp = configure.Now().Unix()
} else {
code = pb.ErrorCode_PracticeSent
errdata = &pb.ErrorData{
Code: pb.ErrorCode_PracticeSent,
Title: pb.ErrorCode_PracticeSent.ToString(),
}
return
}
}
@ -110,7 +129,10 @@ func (this *apiComp) Qiecuo(session comm.IUserSession, req *pb.PracticeQiecuoReq
})
if err = session.SendMsg(string(this.module.GetType()), "qiecuo", &pb.PracticeQiecuoResp{Fid: req.Fid}); err != nil {
code = pb.ErrorCode_SystemError
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SystemError,
Title: pb.ErrorCode_SystemError.ToString(),
}
return
}

View File

@ -235,7 +235,7 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.PracticeReceiveR
}
}
this.module.Debug("最终经验加成", log.Field{Key: "exp", Value: exp}, log.Field{Key: "exp1", Value: exp1})
if _, code = this.module.ModuleHero.AddHeroExp(session, pillar.Hero, exp1); errdata != nil {
if _, errdata = this.module.ModuleHero.AddHeroExp(session, pillar.Hero, exp1); errdata != nil {
return
}
if errdata = this.module.DispenseRes(session, append(ants1, ants2...), true); errdata != nil {

View File

@ -73,7 +73,11 @@ func (this *apiComp) Refuse(session comm.IUserSession, req *pb.PracticeRefuseReq
if err := session.SendMsg(string(this.module.GetType()), "refuse", &pb.PracticeRefuseResp{
IsSucc: true,
}); err != nil {
code = pb.ErrorCode_SystemError
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SystemError,
Title: pb.ErrorCode_SystemError.ToString(),
Message: err.Error(),
}
return
}

View File

@ -55,7 +55,10 @@ func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.PracticeUpgradeR
return
}
if pillarconfigure, err = this.module.configure.getGamePandamasMz(pillar.Lv); err != nil || len(pillarconfigure.UpLvConsume) == 0 {
code = pb.ErrorCode_PracticePillarMaxLv
errdata = &pb.ErrorData{
Code: pb.ErrorCode_PracticePillarMaxLv,
Title: pb.ErrorCode_PracticePillarMaxLv.ToString(),
}
return
}

View File

@ -119,7 +119,7 @@ func (this *modelPandata) refreshnpc(room *pb.DBPracticeRoom) (err error) {
npcs []*cfg.GameDispatch_BattleData
wigets []int32
index int32
code pb.ErrorCode
errdata *pb.ErrorData
)
if npcs, err = this.module.configure.getDispatchBattle(); err != nil {
@ -134,8 +134,8 @@ func (this *modelPandata) refreshnpc(room *pb.DBPracticeRoom) (err error) {
room.Currnpc = npcs[index].Id
room.Npcstate = 0
room.Battlenum = 0
if room.Captain, room.Formation, code = this.module.battle.CreateRolesByFormat(npcs[index].MonsterformatId); errdata != nil {
err = fmt.Errorf("CreateRolesByFormat fail:%d", code)
if room.Captain, room.Formation, errdata = this.module.battle.CreateRolesByFormat(npcs[index].MonsterformatId); errdata != nil {
err = fmt.Errorf("CreateRolesByFormat fail:%+v", errdata)
return
}
return

View File

@ -51,7 +51,10 @@ func (this *apiComp) ActiveCancel(session comm.IUserSession, req *pb.PvpActiveCa
}
}
} else {
code = pb.ErrorCode_BattleInCmdFailed
errdata = &pb.ErrorData{
Code: pb.ErrorCode_BattleInCmdFailed,
Title: pb.ErrorCode_BattleInCmdFailed.ToString(),
}
return
}

View File

@ -18,14 +18,9 @@ func (this *apiComp) InCmd(session comm.IUserSession, req *pb.PvpInCmdReq) (errd
battle *BattleItem
side int32
ok bool
cd pb.ErrorCode
)
defer func() {
session.SendMsg(string(this.module.GetType()), "incmd", &pb.PvpInCmdResp{Code: cd, Battleid: req.Battleid, Cmd: req.Cmd})
}()
if cd = this.InCmdCheck(session, req); cd != pb.ErrorCode_Success {
if errdata = this.InCmdCheck(session, req); errdata != nil {
return
}
this.module.lock.RLock()
@ -50,11 +45,11 @@ func (this *apiComp) InCmd(session comm.IUserSession, req *pb.PvpInCmdReq) (errd
return
}
//技能释放指令
if cd = this.module.battle.InCmdBattle(&pb.BattleInCmdReq{
if errdata = this.module.battle.InCmdBattle(&pb.BattleInCmdReq{
Battleid: req.Battleid,
Side: side,
In: req.Cmd,
}); cd != pb.ErrorCode_Success {
}); errdata != nil {
return
} else {
if battle.operatetimer != nil {
@ -62,9 +57,13 @@ func (this *apiComp) InCmd(session comm.IUserSession, req *pb.PvpInCmdReq) (errd
}
}
} else {
cd = pb.ErrorCode_BattleInCmdFailed
errdata = &pb.ErrorData{
Code: pb.ErrorCode_BattleInCmdFailed,
Title: pb.ErrorCode_BattleInCmdFailed.ToString(),
}
return
}
session.SendMsg(string(this.module.GetType()), "incmd", &pb.PvpInCmdResp{Battleid: req.Battleid, Cmd: req.Cmd})
return
}

View File

@ -15,7 +15,6 @@ func (this *apiComp) Into(session comm.IUserSession, req *pb.PvpIntoReq) (errdat
var (
battle *BattleItem
resp *pb.BattleGetInfoResp = &pb.BattleGetInfoResp{}
cd pb.ErrorCode
ok bool
)
if errdata = this.IntoCheck(session, req); errdata != nil {
@ -25,9 +24,12 @@ func (this *apiComp) Into(session comm.IUserSession, req *pb.PvpIntoReq) (errdat
battle, ok = this.module.battles[req.Battleid]
this.module.lock.RUnlock()
if ok {
if cd, resp = this.module.battle.GetBattleInfo(&pb.BattleGetInfoReq{
if errdata, resp = this.module.battle.GetBattleInfo(&pb.BattleGetInfoReq{
Battleid: req.Battleid,
}); cd == pb.ErrorCode_Success {
}); errdata != nil {
return
}
}
battle.lock.Lock()
if session.GetUserId() == battle.Red.Uid {
battle.RedOffline = false
@ -37,11 +39,6 @@ func (this *apiComp) Into(session comm.IUserSession, req *pb.PvpIntoReq) (errdat
battle.BlueSession.SetSession(session.GetIP(), session.GetSessionId(), session.GetServiecTag(), session.GetGatewayServiceId(), session.GetUserId())
}
battle.lock.Unlock()
}
} else {
cd = pb.ErrorCode_BattleInCmdFailed
return
}
session.SendMsg(string(this.module.GetType()), "into", &pb.PvpIntoResp{Code: cd, Battleid: req.Battleid, Info: resp.Info})
session.SendMsg(string(this.module.GetType()), "into", &pb.PvpIntoResp{Battleid: req.Battleid, Info: resp.Info})
return
}

View File

@ -43,7 +43,10 @@ func (this *apiComp) LoadComplete(session comm.IUserSession, req *pb.PvpLoadComp
}
}
} else {
code = pb.ErrorCode_BattleNoKeep
errdata = &pb.ErrorData{
Code: pb.ErrorCode_BattleNoKeep,
Title: pb.ErrorCode_BattleNoKeep.ToString(),
}
return
}
session.SendMsg(string(this.module.GetType()), "into", &pb.PvpLoadCompleteResp{Battleid: req.Battleid, Issucc: true})

View File

@ -100,11 +100,17 @@ func (this *Pvp) CreatePvp(red, blue *pb.PvpUserInfo, ptype pb.PvpType) (battleI
}
if battle.RedSession, ok = this.GetUserSession(red.Uid); !ok {
code = pb.ErrorCode_BattleUserOff
errdata = &pb.ErrorData{
Code: pb.ErrorCode_BattleUserOff,
Title: pb.ErrorCode_BattleUserOff.ToString(),
}
return
}
if battle.BlueSession, ok = this.GetUserSession(blue.Uid); !ok {
code = pb.ErrorCode_BattleUserOff
errdata = &pb.ErrorData{
Code: pb.ErrorCode_BattleUserOff,
Title: pb.ErrorCode_BattleUserOff.ToString(),
}
return
}
this.lock.Lock()
@ -118,7 +124,10 @@ func (this *Pvp) CreatePvp(red, blue *pb.PvpUserInfo, ptype pb.PvpType) (battleI
Countdown: 60,
}, battle.RedSession, battle.BlueSession); err != nil {
this.Errorln(err)
code = pb.ErrorCode_RpcFuncExecutionError
errdata = &pb.ErrorData{
Code: pb.ErrorCode_RpcFuncExecutionError,
Title: pb.ErrorCode_RpcFuncExecutionError.ToString(),
}
}
return
}
@ -129,8 +138,8 @@ func (this *Pvp) PvpOutCmdPush(out *pb.PvpOutCmdPush) {
var (
battle *BattleItem
ok bool
errdata *pb.ErrorData
data []byte
code pb.ErrorCode
err error
)
this.lock.RLock()
@ -266,7 +275,7 @@ func (this *Pvp) operateTimeOut(task *timewheel.Task, args ...interface{}) {
id string
battle *BattleItem
ok bool
code pb.ErrorCode
errdata *pb.ErrorData
data []byte
)
id = args[0].(string)
@ -296,10 +305,10 @@ func (this *Pvp) startBattle(battle *BattleItem) {
var (
record *pb.DBBattleRecord
info *pb.BattleInfo
code pb.ErrorCode
errdata *pb.ErrorData
err error
)
if code, record = this.battle.CreateRtPvpBattle(&pb.BattleRTPVPReq{
if errdata, record = this.battle.CreateRtPvpBattle(&pb.BattleRTPVPReq{
Ptype: pb.PlayType_friendsmeet,
Title: "",
RedCompId: battle.Red.Uid,
@ -316,6 +325,7 @@ func (this *Pvp) startBattle(battle *BattleItem) {
}, battle.RedSession, battle.BlueSession); err != nil {
this.Errorln(err)
}
return
} else {
record.Id = battle.Id
info = &pb.BattleInfo{
@ -445,7 +455,7 @@ func (this *Pvp) trusteeship(ctx context.Context, req *pb.RPC_PVPTrusteeshipReq,
ok bool
side int32
data []byte
code pb.ErrorCode
errdata *pb.ErrorData
)
for _, bid := range req.Battleid {
this.lock.RLock()

View File

@ -36,7 +36,11 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.ShopBuyReq) (errdata
}
if conf, err = this.module.configure.GetShopItemsConfigure(req.GoodsId); err != nil {
code = pb.ErrorCode_SystemError
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SystemError,
Title: pb.ErrorCode_SystemError.ToString(),
Message: err.Error(),
}
return
}
if shopData, err = this.module.modelShop.QueryUserShopData(session.GetUserId()); err != nil { //没有购买记录
@ -107,7 +111,11 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.ShopBuyReq) (errdata
}
}
if conf.Buyminnum-record.Buy[req.GoodsId] < req.BuyNum {
code = pb.ErrorCode_ShopGoodsIsSoldOut
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ShopGoodsIsSoldOut,
Title: pb.ErrorCode_ShopGoodsIsSoldOut.ToString(),
Message: err.Error(),
}
return
}
record.Buy[req.GoodsId] += req.BuyNum

View File

@ -55,7 +55,10 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq)
return
}
if udata = this.module.ModuleUser.GetUser(session.GetUserId()); udata == nil {
code = pb.ErrorCode_SystemError
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SystemError,
Title: pb.ErrorCode_SystemError.ToString(),
}
return
}
@ -137,7 +140,10 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq)
if !isrefresh {
//剩余刷新次数为零
if leftrefnum == 0 {
code = pb.ErrorCode_ShopNoSurplusRefreshNum
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ShopNoSurplusRefreshNum,
Title: pb.ErrorCode_ShopNoSurplusRefreshNum.ToString(),
}
return
} else if leftrefnum > 0 {
leftrefnum--
@ -151,9 +157,9 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq)
var _items []*cfg.GameShopitemData
for _, v := range shopconf.Shopitem {
if _items, err = this.module.configure.GetShopItemsConfigureByGroups(v, udata); err != nil || len(_items) == 0 {
code = pb.ErrorCode_SystemError
data = &pb.ErrorData{
Title: pb.GetErrorCodeMsg(code),
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SystemError,
Title: pb.ErrorCode_SystemError.ToString(),
Message: err.Error(),
}
return
@ -169,7 +175,7 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq)
for i, v := range items {
sdata.Items[i] = v.Key
if v.Preview { //是否预览
if code, sdata.Preview[v.Key] = this.module.equip.NewEquipment(session.GetUserId(), v.Iteminfo[0].T); errdata != nil {
if errdata, sdata.Preview[v.Key] = this.module.equip.NewEquipment(session.GetUserId(), v.Iteminfo[0].T); errdata != nil {
return
}
}
@ -198,7 +204,11 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq)
for _, v := range shopconf.Shopitem {
if _items, err = this.module.configure.GetShopItemsConfigureByGroups(v, udata); err != nil || len(_items) == 0 {
this.module.Error("no founf shopgroup", log.Field{Key: "gid", Value: v})
code = pb.ErrorCode_SystemError
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SystemError,
Title: pb.ErrorCode_SystemError.ToString(),
Message: err.Error(),
}
return
}
items = append(items, randomGoods(_items))
@ -210,7 +220,7 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq)
for i, v := range items {
sdata.Items[i] = v.Key
if v.Preview { //是否预览
if code, sdata.Preview[v.Key] = this.module.equip.NewEquipment(session.GetUserId(), v.Iteminfo[0].T); errdata != nil {
if errdata, sdata.Preview[v.Key] = this.module.equip.NewEquipment(session.GetUserId(), v.Iteminfo[0].T); errdata != nil {
return
}
}
@ -221,7 +231,11 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq)
go this.module.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.Rtype105, 1))
} else { //返回以前的商品列表
if items, err = this.module.configure.GetShopItemsConfigureByIds(sdata.Items...); err != nil {
code = pb.ErrorCode_SystemError
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SystemError,
Title: pb.ErrorCode_SystemError.ToString(),
Message: err.Error(),
}
return
}
goods = transGoods(items, sdata)

View File

@ -15,14 +15,13 @@ func (this *apiComp) Formation(session comm.IUserSession, req *pb.SociatyBFormat
if errdata = this.FormationCheck(session, req); errdata != nil {
return
}
data = &pb.ErrorData{}
uid := session.GetUserId()
user := this.module.ModuleUser.GetUser(uid)
if user == nil {
this.module.Error("GetRemoteUser",
log.Field{Key: "uid", Value: uid},
)
code = pb.ErrorCode_UserSessionNobeing
return
}
@ -31,30 +30,37 @@ func (this *apiComp) Formation(session comm.IUserSession, req *pb.SociatyBFormat
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Title: pb.ErrorCode_ConfigNoFound.ToString(),
Message: err.Error(),
}
data.Title = code.ToString()
return
}
//检验第二队或第三队是否达到解锁条件
if _, ok := req.Teams[2]; ok {
if user.Lv < ggd.GuildBossTroop2 {
code = pb.ErrorCode_SociatyTeamUnlock
data.Title = code.ToString()
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyTeamUnlock,
Title: pb.ErrorCode_SociatyTeamUnlock.ToString(),
}
return
}
}
if _, ok := req.Teams[3]; ok {
if user.Lv < ggd.GuildBossTroop3 {
code = pb.ErrorCode_SociatyTeamUnlock
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyTeamUnlock,
Title: pb.ErrorCode_SociatyTeamUnlock.ToString(),
}
return
}
}
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty == nil {
code = pb.ErrorCode_SociatyNoFound
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyNoFound,
Title: pb.ErrorCode_SociatyNoFound.ToString(),
}
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}
@ -73,8 +79,6 @@ func (this *apiComp) Formation(session comm.IUserSession, req *pb.SociatyBFormat
SociatyId: sociaty.Id,
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeFormation, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
session.SendMsg(string(this.module.GetType()), SociatySubTypeFormation, rsp)
return
}

View File

@ -17,13 +17,15 @@ func (this *apiComp) Accuse(session comm.IUserSession, req *pb.SociatyAccuseReq)
if errdata = this.AccuseCheck(session, req); errdata != nil {
return
}
data = &pb.ErrorData{}
uid := session.GetUserId()
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty == nil {
code = pb.ErrorCode_SociatyNoFound
data.Datastring = uid
data.Message = SociatyNoFound
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyNoFound,
Title: pb.ErrorCode_SociatyNoFound.ToString(),
}
return
}
@ -32,14 +34,17 @@ func (this *apiComp) Accuse(session comm.IUserSession, req *pb.SociatyAccuseReq)
pb.SociatyJob_VICEPRESIDENT,
pb.SociatyJob_ADMIN,
pb.SociatyJob_MEMBER) {
code = pb.ErrorCode_SociatyNoRight
data.Message = SociatyNoRight
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyNoRight,
Title: pb.ErrorCode_SociatyNoRight.ToString(),
}
return
}
// 弹劾
if err := this.module.modelSociaty.accuse(sociaty); err != nil {
var customErr = new(comm.CustomError)
var code pb.ErrorCode
if errors.As(err, &customErr) {
code = customErr.Code
} else {
@ -49,7 +54,12 @@ func (this *apiComp) Accuse(session comm.IUserSession, req *pb.SociatyAccuseReq)
Message: err.Error(),
}
}
data.Datastring = sociaty.Id
errdata = &pb.ErrorData{
Code: code,
Title: code.ToString(),
Datastring: sociaty.Id,
}
this.module.Error("弹劾",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
@ -62,8 +72,6 @@ func (this *apiComp) Accuse(session comm.IUserSession, req *pb.SociatyAccuseReq)
SociatyId: sociaty.Id,
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeAccuse, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
session.SendMsg(string(this.module.GetType()), SociatySubTypeAccuse, rsp)
return
}

View File

@ -12,13 +12,14 @@ func (this *apiComp) ActivitylistCheck(session comm.IUserSession, req *pb.Sociat
}
func (this *apiComp) Activitylist(session comm.IUserSession, req *pb.SociatyActivityListReq) (errdata *pb.ErrorData) {
data = &pb.ErrorData{}
uid := session.GetUserId()
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty == nil {
code = pb.ErrorCode_SociatyNoFound
data.Datastring = uid
data.Message = SociatyNoFound
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyNoFound,
Title: pb.ErrorCode_SociatyNoFound.ToString(),
}
return
}
@ -37,9 +38,7 @@ func (this *apiComp) Activitylist(session comm.IUserSession, req *pb.SociatyActi
rsp.List = activityList
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeActivityList, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
session.SendMsg(string(this.module.GetType()), SociatySubTypeActivityList, rsp)
return
}

View File

@ -23,12 +23,15 @@ func (this *apiComp) Activityreceive(session comm.IUserSession, req *pb.SociatyA
if errdata = this.ActivityreceiveCheck(session, req); errdata != nil {
return
}
data = &pb.ErrorData{}
uid := session.GetUserId()
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty == nil {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyNoFound,
Title: pb.ErrorCode_SociatyNoFound.ToString(),
}
return
}
@ -37,7 +40,10 @@ func (this *apiComp) Activityreceive(session comm.IUserSession, req *pb.SociatyA
for _, v := range sociatyTask.ActivityList {
if v.Id == req.Id {
if v.Status == 1 {
code = pb.ErrorCode_SociatyRewardReceived
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyRewardReceived,
Title: pb.ErrorCode_SociatyRewardReceived.ToString(),
}
return
}
break
@ -49,16 +55,17 @@ func (this *apiComp) Activityreceive(session comm.IUserSession, req *pb.SociatyA
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Title: pb.ErrorCode_ConfigNoFound.ToString(),
Message: err.Error(),
}
return
}
//是否满足领取条件
if sociaty.Activity < conf.Activity {
code = pb.ErrorCode_SociatyActivityNoEnough
data.Datastring = uid
data.Message = fmt.Sprintf("活跃度不足 实际:%d 期望:%d", sociaty.Activity, conf.Activity)
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyActivityNoEnough,
Title: pb.ErrorCode_SociatyActivityNoEnough.ToString(),
Message: fmt.Sprintf("活跃度不足 实际:%d 期望:%d", sociaty.Activity, conf.Activity),
}
return
}
@ -78,8 +85,6 @@ func (this *apiComp) Activityreceive(session comm.IUserSession, req *pb.SociatyA
SociatyId: sociaty.Id,
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeActivityReceive, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
session.SendMsg(string(this.module.GetType()), SociatySubTypeActivityReceive, rsp)
return
}

View File

@ -24,14 +24,14 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.SociatyAgreeReq) (
if errdata = this.AgreeCheck(session, req); errdata != nil {
return
}
data = &pb.ErrorData{}
uid := session.GetUserId()
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty == nil {
code = pb.ErrorCode_SociatyNoFound
data.Title = code.ToString()
data.Datastring = uid
data.Message = SociatyNoFound
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyNoFound,
Title: pb.ErrorCode_SociatyNoFound.ToString(),
}
return
}
@ -40,14 +40,16 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.SociatyAgreeReq) (
pb.SociatyJob_PRESIDENT,
pb.SociatyJob_VICEPRESIDENT,
pb.SociatyJob_ADMIN) {
code = pb.ErrorCode_SociatyNoRight
data.Title = code.ToString()
data.Message = SociatyNoRight
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyNoRight,
Title: pb.ErrorCode_SociatyNoRight.ToString(),
}
return
}
if err := this.module.modelSociaty.agree(req.Uid, sociaty); err != nil {
var customError = new(comm.CustomError)
var code pb.ErrorCode
if errors.As(err, &customError) {
code = customError.Code
} else {
@ -57,8 +59,11 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.SociatyAgreeReq) (
Message: err.Error(),
}
}
data.Title = code.ToString()
data.Message = err.Error()
errdata = &pb.ErrorData{
Code: code,
Title: code.ToString(),
Message: err.Error(),
}
this.module.Error("公会审核-同意",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "申请人", Value: req.Uid},
@ -84,10 +89,7 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.SociatyAgreeReq) (
SociatyId: sociaty.Id,
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeAgree, rsp); err != nil {
code = pb.ErrorCode_SystemError
return
}
session.SendMsg(string(this.module.GetType()), SociatySubTypeAgree, rsp)
//审核通过推送给申请人
if err := this.module.SendMsgToUser(string(this.module.GetType()), "pagree", &pb.SociatyPAgreePush{

View File

@ -27,15 +27,14 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.SociatyApplyReq) (
return
}
data = &pb.ErrorData{}
uid := session.GetUserId()
sociaty := this.module.modelSociaty.getSociaty(req.SociatyId)
if sociaty == nil {
code = pb.ErrorCode_SociatyNoFound
data.Title = code.ToString()
data.Datastring = req.SociatyId
this.module.Error("公会未找到", log.Field{Key: "uid", Value: uid}, log.Field{Key: "sociatyId", Value: req.SociatyId})
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyNoFound,
Title: pb.ErrorCode_SociatyNoFound.ToString(),
}
return
}
@ -43,58 +42,69 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.SociatyApplyReq) (
userEx, err := this.module.ModuleUser.GetUserExpand(uid)
if err != nil {
this.module.Error("GetRemoteUserExpand", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err.Error()})
code = pb.ErrorCode_UserNofound
data.Title = code.ToString()
data.Datastring = uid
data.Message = err.Error()
errdata = &pb.ErrorData{
Code: pb.ErrorCode_UserNofound,
Title: pb.ErrorCode_UserNofound.ToString(),
}
return
}
if utils.IsInCDHour(userEx.SociatyCd) {
code = pb.ErrorCode_SociatyCDLimit
data.Title = code.ToString()
data.Message = fmt.Sprintf("CD内[%v]不允许申请", userEx.SociatyCd)
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyCDLimit,
Title: pb.ErrorCode_SociatyCDLimit.ToString(),
Message: fmt.Sprintf("CD内[%v]不允许申请", userEx.SociatyCd),
}
return
}
// 是否公会成员
if this.module.modelSociaty.isMember(uid, sociaty) {
code = pb.ErrorCode_SociatyBelongTo
data.Title = code.ToString()
data.Datastring = sociaty.Id
data.Message = fmt.Sprintf("[%v]已经是公会[%v]成员", uid, sociaty.Name)
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyBelongTo,
Title: pb.ErrorCode_SociatyBelongTo.ToString(),
Message: fmt.Sprintf("[%v]已经是公会[%v]成员", uid, sociaty.Name),
}
return
}
user := this.module.ModuleUser.GetUser(uid)
if user == nil {
code = pb.ErrorCode_UserNofound
data.Title = code.ToString()
data.Datastring = uid
errdata = &pb.ErrorData{
Code: pb.ErrorCode_UserNofound,
Title: pb.ErrorCode_UserNofound.ToString(),
Datastring: uid,
}
return
}
// 是否达到入会等级
if user.Lv < sociaty.ApplyLv {
code = pb.ErrorCode_SociatyAppyLvNoEnough
data.Title = code.ToString()
data.Message = fmt.Sprintf("实际等级:%v 期望等级:%v", user.Lv, sociaty.ApplyLv)
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyAppyLvNoEnough,
Title: pb.ErrorCode_SociatyAppyLvNoEnough.ToString(),
Message: fmt.Sprintf("实际等级:%v 期望等级:%v", user.Lv, sociaty.ApplyLv),
}
return
}
// 是否已申请
if this.module.modelSociaty.isApplied(uid, sociaty) {
code = pb.ErrorCode_SociatyApplied
data.Title = code.ToString()
data.Message = fmt.Sprintf("[%v]已申请", sociaty.Name)
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyApplied,
Title: pb.ErrorCode_SociatyApplied.ToString(),
Message: fmt.Sprintf("[%v]已申请", sociaty.Name),
}
return
}
//判断申请人数是否超出最大允许申请数
if len(sociaty.ApplyRecord) >= int(this.module.globalConf.GuildAcceptApplyMax) {
code = pb.ErrorCode_SociatyApplyMax
data.Title = code.ToString()
data.Message = fmt.Sprintf("实际人数:%d 期望人数:%d", len(sociaty.ApplyRecord), int(this.module.globalConf.GuildAcceptApplyMax))
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyApplyMax,
Title: pb.ErrorCode_SociatyApplyMax.ToString(),
Message: fmt.Sprintf("实际人数:%d 期望人数:%d", len(sociaty.ApplyRecord), int(this.module.globalConf.GuildAcceptApplyMax)),
}
return
}
@ -102,6 +112,7 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.SociatyApplyReq) (
isCheck, err := this.module.modelSociaty.apply(uid, sociaty)
if err != nil {
var customError = new(comm.CustomError)
var code pb.ErrorCode
if errors.As(err, &customError) {
code = customError.Code
} else {
@ -111,8 +122,11 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.SociatyApplyReq) (
Message: err.Error(),
}
}
data.Title = code.ToString()
data.Message = err.Error()
errdata = &pb.ErrorData{
Code: code,
Title: code.ToString(),
Message: err.Error(),
}
this.module.Error("公会申请",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: req.SociatyId},
@ -130,8 +144,6 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.SociatyApplyReq) (
Uid: uid,
ScoiatyId: req.SociatyId,
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeApply, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
session.SendMsg(string(this.module.GetType()), SociatySubTypeApply, rsp)
return
}

View File

@ -23,14 +23,15 @@ func (this *apiComp) ApplyCancel(session comm.IUserSession, req *pb.SociatyApply
if errdata = this.ApplyCancelCheck(session, req); errdata != nil {
return
}
data = &pb.ErrorData{}
uid := session.GetUserId()
sociaty := this.module.modelSociaty.getSociaty(req.SociatyId)
if sociaty != nil && sociaty.Id == "" {
code = pb.ErrorCode_SociatyNoFound
data.Title = code.ToString()
this.module.Error("公会未找到", log.Field{Key: "uid", Value: uid}, log.Field{Key: "sociatyId", Value: req.SociatyId})
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyNoFound,
Title: pb.ErrorCode_SociatyNoFound.ToString(),
}
return
}
@ -52,8 +53,6 @@ func (this *apiComp) ApplyCancel(session comm.IUserSession, req *pb.SociatyApply
Uid: uid,
ScoiatyId: req.SociatyId,
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeApplyCanel, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
session.SendMsg(string(this.module.GetType()), SociatySubTypeApplyCanel, rsp)
return
}

View File

@ -23,15 +23,14 @@ func (this *apiComp) ApplyList(session comm.IUserSession, req *pb.SociatyApplyLi
if errdata = this.ApplyListCheck(session, req); errdata != nil {
return
}
data = &pb.ErrorData{}
uid := session.GetUserId()
sociaty := this.module.modelSociaty.getSociaty(req.SociatyId)
if sociaty == nil {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("公会未找到",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: req.SociatyId},
)
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyNoFound,
Title: pb.ErrorCode_SociatyNoFound.ToString(),
}
return
}
@ -40,7 +39,10 @@ func (this *apiComp) ApplyList(session comm.IUserSession, req *pb.SociatyApplyLi
pb.SociatyJob_PRESIDENT,
pb.SociatyJob_VICEPRESIDENT,
pb.SociatyJob_ADMIN) {
code = pb.ErrorCode_SociatyNoRight
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyNoRight,
Title: pb.ErrorCode_SociatyNoRight.ToString(),
}
return
}
@ -48,8 +50,6 @@ func (this *apiComp) ApplyList(session comm.IUserSession, req *pb.SociatyApplyLi
rsp := &pb.SociatyApplyListResp{
List: list,
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeApplyList, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
session.SendMsg(string(this.module.GetType()), SociatySubTypeApplyList, rsp)
return
}

View File

@ -23,7 +23,7 @@ func (this *apiComp) Assign(session comm.IUserSession, req *pb.SociatyAssignReq)
if errdata = this.AssignCheck(session, req); errdata != nil {
return
}
data = &pb.ErrorData{}
uid := session.GetUserId()
if uid == req.TargetId {
errdata = &pb.ErrorData{
@ -36,20 +36,28 @@ func (this *apiComp) Assign(session comm.IUserSession, req *pb.SociatyAssignReq)
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty == nil {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyNoFound,
Title: pb.ErrorCode_SociatyNoFound.ToString(),
}
return
}
// 校验权限
if !this.module.modelSociaty.isRight(uid, sociaty, pb.SociatyJob_PRESIDENT) {
code = pb.ErrorCode_SociatyNoRight
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyNoRight,
Title: pb.ErrorCode_SociatyNoRight.ToString(),
}
return
}
// 校验目标是否公会成员
if !this.module.modelSociaty.isMember(req.TargetId, sociaty) {
code = pb.ErrorCode_SociatyNoMember
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyNoMember,
Title: pb.ErrorCode_SociatyNoMember.ToString(),
}
return
}
@ -73,6 +81,7 @@ func (this *apiComp) Assign(session comm.IUserSession, req *pb.SociatyAssignReq)
if err := this.module.modelSociatyLog.addLog(Log_Job, sociaty.Id,
uid, req.TargetId, pb.SociatyJob_PRESIDENT.String()); err != nil {
var customErr = new(comm.CustomError)
var code pb.ErrorCode
if errors.As(err, &customErr) {
code = customErr.Code
} else {
@ -82,6 +91,11 @@ func (this *apiComp) Assign(session comm.IUserSession, req *pb.SociatyAssignReq)
Message: err.Error(),
}
}
errdata = &pb.ErrorData{
Code: code,
Title: code.ToString(),
Message: err.Error(),
}
this.module.Error("公会转让日志",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
@ -96,8 +110,6 @@ func (this *apiComp) Assign(session comm.IUserSession, req *pb.SociatyAssignReq)
SociatyId: sociaty.Id,
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeAssign, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
session.SendMsg(string(this.module.GetType()), SociatySubTypeAssign, rsp)
return
}

View File

@ -15,13 +15,12 @@ func (this *apiComp) BossmainCheck(session comm.IUserSession, req *pb.SociatyBMa
func (this *apiComp) Bossmain(session comm.IUserSession, req *pb.SociatyBMainReq) (errdata *pb.ErrorData) {
uid := session.GetUserId()
data = &pb.ErrorData{}
ggd := this.module.ModuleTools.GetGlobalConf()
if ggd == nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Title: pb.ErrorCode_ConfigNoFound.ToString(),
Message: err.Error(),
}
return
}
@ -31,7 +30,10 @@ func (this *apiComp) Bossmain(session comm.IUserSession, req *pb.SociatyBMainReq
log.Field{Key: "uid", Value: uid},
log.Field{Key: "err", Value: err.Error()},
)
code = pb.ErrorCode_UserSessionNobeing
errdata = &pb.ErrorData{
Code: pb.ErrorCode_UserSessionNobeing,
Title: pb.ErrorCode_UserSessionNobeing.ToString(),
}
return
}
@ -58,8 +60,11 @@ func (this *apiComp) Bossmain(session comm.IUserSession, req *pb.SociatyBMainReq
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty == nil {
code = pb.ErrorCode_SociatyNoFound
data.Title = code.ToString()
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyNoFound,
Title: pb.ErrorCode_SociatyNoFound.ToString(),
}
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}
@ -67,7 +72,10 @@ func (this *apiComp) Bossmain(session comm.IUserSession, req *pb.SociatyBMainReq
// 赛季信息
dbs := this.module.modelSociatyBoss.getSociatyBossSports()
if dbs == nil {
code = pb.ErrorCode_SociatySportsNoinit
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatySportsNoinit,
Title: pb.ErrorCode_SociatySportsNoinit.ToString(),
}
return
}
rsp.EndTime = dbs.EndTime
@ -92,8 +100,6 @@ func (this *apiComp) Bossmain(session comm.IUserSession, req *pb.SociatyBMainReq
rsp.Teams = sm.Teams
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeBossmain, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
session.SendMsg(string(this.module.GetType()), SociatySubTypeBossmain, rsp)
return
}

View File

@ -22,12 +22,15 @@ func (this *apiComp) Brank(session comm.IUserSession, req *pb.SociatyBRankReq) (
if errdata = this.BrankCheck(session, req); errdata != nil {
return
}
data = &pb.ErrorData{}
uid := session.GetUserId()
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty == nil {
code = pb.ErrorCode_SociatyNoFound
data.Title = code.ToString()
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyNoFound,
Title: pb.ErrorCode_SociatyNoFound.ToString(),
}
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}
@ -38,8 +41,6 @@ func (this *apiComp) Brank(session comm.IUserSession, req *pb.SociatyBRankReq) (
Rank: sri,
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeBrank, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
session.SendMsg(string(this.module.GetType()), SociatySubTypeBrank, rsp)
return
}

View File

@ -22,12 +22,14 @@ func (this *apiComp) Breceive(session comm.IUserSession, req *pb.SociatyBReceive
if errdata = this.BreceiveCheck(session, req); errdata != nil {
return
}
data = &pb.ErrorData{}
uid := session.GetUserId()
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty == nil {
code = pb.ErrorCode_SociatyNoFound
data.Title = code.ToString()
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyNoFound,
Title: pb.ErrorCode_SociatyNoFound.ToString(),
}
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}
@ -37,7 +39,6 @@ func (this *apiComp) Breceive(session comm.IUserSession, req *pb.SociatyBReceive
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Title: pb.ErrorCode_ConfigNoFound.ToString(),
Message: err.Error(),
}
return
}
@ -48,10 +49,16 @@ func (this *apiComp) Breceive(session comm.IUserSession, req *pb.SociatyBReceive
if task.TaskId == req.TaskId {
taskId = task.TaskId
if task.Status == 2 { //已领取
code = pb.ErrorCode_SociatyTaskReceived
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyTaskReceived,
Title: pb.ErrorCode_SociatyTaskReceived.ToString(),
}
return
} else if taskId == 0 { //未完成
code = pb.ErrorCode_SociatyTaskNoFinished
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyTaskNoFinished,
Title: pb.ErrorCode_SociatyTaskNoFinished.ToString(),
}
return
} else if taskId == 1 { //可领取
task.Status = 2
@ -74,7 +81,7 @@ func (this *apiComp) Breceive(session comm.IUserSession, req *pb.SociatyBReceive
}
// 奖励
if code := this.module.DispenseRes(session, taskConf.Reward, true); errdata != nil {
if errdata := this.module.DispenseRes(session, taskConf.Reward, true); errdata != nil {
this.module.Error("积分任务奖励领取",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "taskId", Value: taskId},
@ -85,8 +92,6 @@ func (this *apiComp) Breceive(session comm.IUserSession, req *pb.SociatyBReceive
SociatyId: sociaty.Id,
TaskId: req.TaskId,
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeBreceive, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
session.SendMsg(string(this.module.GetType()), SociatySubTypeBreceive, rsp)
return
}

View File

@ -21,21 +21,22 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.SociatyBuyReq) (errd
if errdata = this.BuyCheck(session, req); errdata != nil {
return
}
data = &pb.ErrorData{}
ggd := this.module.ModuleTools.GetGlobalConf()
if ggd == nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Title: pb.ErrorCode_ConfigNoFound.ToString(),
Message: err.Error(),
}
return
}
uid := session.GetUserId()
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty == nil {
code = pb.ErrorCode_SociatyNoFound
data.Title = code.ToString()
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Title: pb.ErrorCode_ConfigNoFound.ToString(),
}
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}
@ -43,13 +44,16 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.SociatyBuyReq) (errd
//校验钻石
imodule, err := this.module.service.GetModule(comm.ModuleUser)
if err != nil {
code = pb.ErrorCode_SystemError
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ExternalModule,
Title: pb.ErrorCode_ExternalModule.ToString(),
Message: comm.NewExternalModuleErr("user", "").Error(),
}
return
}
iuser, ok := imodule.(comm.IUser)
if !ok {
code = pb.ErrorCode_SystemError
return
}
@ -64,9 +68,11 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.SociatyBuyReq) (errd
ex, err := iuser.GetUserExpand(uid)
if err != nil {
code = pb.ErrorCode_UserSessionNobeing
data.Title = code.ToString()
data.Message = err.Error()
errdata = &pb.ErrorData{
Code: pb.ErrorCode_UserSessionNobeing,
Title: pb.ErrorCode_UserSessionNobeing.ToString(),
Message: err.Error(),
}
return
}
@ -84,7 +90,6 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.SociatyBuyReq) (errd
//扣除资源
if errdata = this.module.DispenseRes(session, atn, true); errdata != nil {
data.Title = code.ToString()
return
}
@ -92,8 +97,6 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.SociatyBuyReq) (errd
Uid: uid,
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeBuy, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
session.SendMsg(string(this.module.GetType()), SociatySubTypeBuy, rsp)
return
}

View File

@ -15,11 +15,14 @@ func (this *apiComp) Challengefinish(session comm.IUserSession, req *pb.SociatyB
if errdata = this.ChallengefinishCheck(session, req); errdata != nil {
return
}
data = &pb.ErrorData{}
uid := session.GetUserId()
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty == nil {
code = pb.ErrorCode_SociatyNoFound
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyNoFound,
Title: pb.ErrorCode_SociatyNoFound.ToString(),
}
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}
@ -30,7 +33,7 @@ func (this *apiComp) Challengefinish(session comm.IUserSession, req *pb.SociatyB
log.Field{Key: "uid", Value: uid},
log.Field{Key: "err", Value: err.Error()},
)
code = pb.ErrorCode_UserSessionNobeing
return
}
@ -51,8 +54,6 @@ func (this *apiComp) Challengefinish(session comm.IUserSession, req *pb.SociatyB
Integral: this.module.modelSociatyBoss.transIntegral(req.Report.Harm),
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeChallengefinish, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
session.SendMsg(string(this.module.GetType()), SociatySubTypeChallengefinish, rsp)
return
}

View File

@ -16,11 +16,15 @@ func (this *apiComp) Challengestart(session comm.IUserSession, req *pb.SociatyBC
if errdata = this.ChallengestartCheck(session, req); errdata != nil {
return
}
data = &pb.ErrorData{}
uid := session.GetUserId()
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty == nil {
code = pb.ErrorCode_SociatyNoFound
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyNoFound,
Title: pb.ErrorCode_SociatyNoFound.ToString(),
}
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}
@ -31,19 +35,22 @@ func (this *apiComp) Challengestart(session comm.IUserSession, req *pb.SociatyBC
log.Field{Key: "uid", Value: uid},
log.Field{Key: "err", Value: err.Error()},
)
code = pb.ErrorCode_UserSessionNobeing
data.Title = code.ToString()
data.Message = err.Error()
return
}
if userEx.SociatyTicket <= 0 {
code = pb.ErrorCode_SociatyTicketsNoEnough
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyTicketsNoEnough,
Title: pb.ErrorCode_SociatyTicketsNoEnough.ToString(),
}
return
}
//校验赛季时间
if this.module.modelSociatyBoss.sportsIsFinished() {
code = pb.ErrorCode_SociatySportsEnd
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatySportsEnd,
Title: pb.ErrorCode_SociatySportsEnd.ToString(),
}
return
}
@ -51,10 +58,11 @@ func (this *apiComp) Challengestart(session comm.IUserSession, req *pb.SociatyBC
if err := this.module.modelSociatyBoss.challengestart(session, sociaty); err != nil {
var customErr = new(comm.CustomError)
if errors.As(err, &customErr) {
code = customErr.Code
// if code == pb.ErrorCode_SociatyNoFormation {
// return
// }
code := customErr.Code
errdata = &pb.ErrorData{
Code: code,
Title: code.ToString(),
}
return
}
}
@ -64,8 +72,6 @@ func (this *apiComp) Challengestart(session comm.IUserSession, req *pb.SociatyBC
Uid: uid,
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeChallengestart, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
session.SendMsg(string(this.module.GetType()), SociatySubTypeChallengestart, rsp)
return
}

View File

@ -29,12 +29,11 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq)
if errdata = this.CreateCheck(session, req); errdata != nil {
return
}
data = &pb.ErrorData{}
uid := session.GetUserId()
user := this.module.ModuleUser.GetUser(uid)
if user == nil {
this.module.Error("GetRmoteUser not found", log.Field{Key: "uid", Value: uid})
code = pb.ErrorCode_UserSessionNobeing
return
}
@ -45,20 +44,25 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq)
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data.Title = code.ToString()
return
}
// CD校验
if utils.IsInCDHour(userExpand.SociatyCd) {
code = pb.ErrorCode_SociatyCDLimit
data.Title = code.ToString()
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyCDLimit,
Title: pb.ErrorCode_SociatyCDLimit.ToString(),
}
return
}
//检查是否已加入公会
if userExpand.SociatyId != "" {
code = pb.ErrorCode_SociatyAdded
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyAdded,
Title: pb.ErrorCode_SociatyAdded.ToString(),
}
return
}
@ -66,7 +70,12 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq)
if err := this.module.modelSociaty.isNameExist(req.Name); err != nil {
var customErr = new(comm.CustomError)
if errors.As(err, &customErr) {
code = customErr.Code
code := customErr.Code
errdata = &pb.ErrorData{
Code: code,
Title: code.ToString(),
Message: err.Error(),
}
return
}
errdata = &pb.ErrorData{
@ -97,7 +106,11 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq)
}
if req.ApplyLv > maxLv {
code = pb.ErrorCode_SociatyApplyLvLimit
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyApplyLvLimit,
Title: pb.ErrorCode_SociatyApplyLvLimit.ToString(),
Message: err.Error(),
}
return
}
@ -119,9 +132,9 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq)
})
if err := this.module.modelSociaty.create(sociaty); err != nil {
var customError = new(comm.CustomError)
var code pb.ErrorCode
if errors.As(err, &customError) {
if customError.Code == pb.ErrorCode_SociatyNoFound {
code = pb.ErrorCode_SociatyNoFound
code = customError.Code
} else {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
@ -129,6 +142,10 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq)
Message: err.Error(),
}
}
errdata = &pb.ErrorData{
Code: code,
Title: code.ToString(),
Message: err.Error(),
}
this.module.Error("创建公会",
log.Field{Key: "uid", Value: uid},
@ -168,12 +185,9 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq)
}
}()
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeCreate, &pb.SociatyCreateResp{
session.SendMsg(string(this.module.GetType()), SociatySubTypeCreate, &pb.SociatyCreateResp{
Id: sociaty.Id,
Uid: uid,
}); err != nil {
code = pb.ErrorCode_SystemError
return
}
})
return
}

View File

@ -24,11 +24,14 @@ func (this *apiComp) Discharge(session comm.IUserSession, req *pb.SociatyDischar
if errdata = this.DischargeCheck(session, req); errdata != nil {
return
}
data = &pb.ErrorData{}
uid := session.GetUserId()
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty == nil {
code = pb.ErrorCode_SociatyNoFound
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyNoFound,
Title: pb.ErrorCode_SociatyNoFound.ToString(),
}
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}
@ -37,13 +40,17 @@ func (this *apiComp) Discharge(session comm.IUserSession, req *pb.SociatyDischar
if !this.module.modelSociaty.isRight(uid, sociaty,
pb.SociatyJob_PRESIDENT,
pb.SociatyJob_VICEPRESIDENT) {
code = pb.ErrorCode_SociatyNoRight
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyNoRight,
Title: pb.ErrorCode_SociatyNoRight.ToString(),
}
return
}
// 踢人
if err := this.module.modelSociaty.discharge(req.TargetId, sociaty); err != nil {
var customError = new(comm.CustomError)
var code pb.ErrorCode
if errors.As(err, &customError) {
code = customError.Code
} else {
@ -53,8 +60,10 @@ func (this *apiComp) Discharge(session comm.IUserSession, req *pb.SociatyDischar
Message: err.Error(),
}
}
data.Title = code.ToString()
data.Message = err.Error()
errdata = &pb.ErrorData{
Code: code,
Title: code.ToString(),
}
this.module.Error("踢出公会",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
@ -109,8 +118,6 @@ func (this *apiComp) Discharge(session comm.IUserSession, req *pb.SociatyDischar
SociatyId: sociaty.Id,
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeDischarge, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
session.SendMsg(string(this.module.GetType()), SociatySubTypeDischarge, rsp)
return
}

View File

@ -25,11 +25,14 @@ func (this *apiComp) Dismiss(session comm.IUserSession, req *pb.SociatyDismissRe
return
}
data = &pb.ErrorData{}
uid := session.GetUserId()
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty == nil {
code = pb.ErrorCode_SociatyNoFound
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyNoFound,
Title: pb.ErrorCode_SociatyNoFound.ToString(),
}
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}
@ -42,7 +45,10 @@ func (this *apiComp) Dismiss(session comm.IUserSession, req *pb.SociatyDismissRe
// 校验权限
if !this.module.modelSociaty.isRight(uid, sociaty,
pb.SociatyJob_PRESIDENT) {
code = pb.ErrorCode_SociatyNoRight
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyNoRight,
Title: pb.ErrorCode_SociatyNoRight.ToString(),
}
return
}
@ -53,7 +59,10 @@ func (this *apiComp) Dismiss(session comm.IUserSession, req *pb.SociatyDismissRe
if sociaty.DismissTime == 0 {
if sociaty.DismissCD != 0 {
if utils.IsInCDHour(int64(sociaty.DismissCD)) {
code = pb.ErrorCode_SociatyCDLimit
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyCDLimit,
Title: pb.ErrorCode_SociatyCDLimit.ToString(),
}
return
} else {
update["dismissCD"] = 0
@ -68,7 +77,10 @@ func (this *apiComp) Dismiss(session comm.IUserSession, req *pb.SociatyDismissRe
update["dismissCD"] = utils.AddHour(int(globalCnf.GuildDissolutionCd)).Unix()
} else {
if utils.IsInCDHour(int64(sociaty.DismissCD)) {
code = pb.ErrorCode_SociatyCDLimit
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyCDLimit,
Title: pb.ErrorCode_SociatyCDLimit.ToString(),
}
return
}
}
@ -89,8 +101,6 @@ func (this *apiComp) Dismiss(session comm.IUserSession, req *pb.SociatyDismissRe
}
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeDismiss, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
session.SendMsg(string(this.module.GetType()), SociatySubTypeDismiss, rsp)
return
}

View File

@ -37,8 +37,6 @@ func (this *apiComp) List(session comm.IUserSession, req *pb.SociatyListReq) (er
rsp.List = append(rsp.List, info)
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeList, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
session.SendMsg(string(this.module.GetType()), SociatySubTypeList, rsp)
return
}

View File

@ -16,7 +16,6 @@ func (this *apiComp) Log(session comm.IUserSession, req *pb.SociatyLogReq) (errd
uid := session.GetUserId()
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty == nil {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}
@ -31,8 +30,6 @@ func (this *apiComp) Log(session comm.IUserSession, req *pb.SociatyLogReq) (errd
},
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeLog, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
session.SendMsg(string(this.module.GetType()), SociatySubTypeLog, rsp)
return
}

View File

@ -16,7 +16,6 @@ func (this *apiComp) Members(session comm.IUserSession, req *pb.SociatyMembersRe
uid := session.GetUserId()
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty == nil {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}
@ -27,8 +26,6 @@ func (this *apiComp) Members(session comm.IUserSession, req *pb.SociatyMembersRe
List: members,
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeMembers, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
session.SendMsg(string(this.module.GetType()), SociatySubTypeMembers, rsp)
return
}

View File

@ -14,7 +14,7 @@ func (this *apiComp) MineCheck(session comm.IUserSession, req *pb.SociatyMineReq
}
func (this *apiComp) Mine(session comm.IUserSession, req *pb.SociatyMineReq) (errdata *pb.ErrorData) {
data = &pb.ErrorData{}
uid := session.GetUserId()
userEx, err := this.module.ModuleUser.GetUserExpand(uid)
if err != nil {
@ -22,7 +22,6 @@ func (this *apiComp) Mine(session comm.IUserSession, req *pb.SociatyMineReq) (er
log.Field{Key: "uid", Value: uid},
log.Field{Key: "err", Value: err.Error()},
)
code = pb.ErrorCode_UserSessionNobeing
return
}
@ -30,22 +29,28 @@ func (this *apiComp) Mine(session comm.IUserSession, req *pb.SociatyMineReq) (er
// 未加入公会
if userEx.SociatyId == "" {
code = pb.ErrorCode_SociatyNoAdded
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyNoAdded,
Title: pb.ErrorCode_SociatyNoAdded.ToString(),
Message: err.Error(),
}
return
}
// 获取公会
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty == nil {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}
//判断公会是否解散(公会解散非立即执行)
if this.module.modelSociaty.isDismiss(sociaty) {
code = pb.ErrorCode_SociatyDismissed
data.Title = code.ToString()
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyDismissed,
Title: pb.ErrorCode_SociatyDismissed.ToString(),
Message: err.Error(),
}
return
}
@ -83,8 +88,7 @@ func (this *apiComp) Mine(session comm.IUserSession, req *pb.SociatyMineReq) (er
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data.Title = code.ToString()
data.Message = err.Error()
this.module.Error("会长弹劾",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
@ -97,8 +101,6 @@ func (this *apiComp) Mine(session comm.IUserSession, req *pb.SociatyMineReq) (er
rsp.Sociaty = sociaty
rsp.Master = master
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeMine, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
session.SendMsg(string(this.module.GetType()), SociatySubTypeMine, rsp)
return
}

View File

@ -14,11 +14,10 @@ func (this *apiComp) QuitCheck(session comm.IUserSession, req *pb.SociatyQuitReq
}
func (this *apiComp) Quit(session comm.IUserSession, req *pb.SociatyQuitReq) (errdata *pb.ErrorData) {
data = &pb.ErrorData{}
uid := session.GetUserId()
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty == nil {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}
@ -26,13 +25,19 @@ func (this *apiComp) Quit(session comm.IUserSession, req *pb.SociatyQuitReq) (er
// 会长不允许退公会
if this.module.modelSociaty.isRight(uid, sociaty,
pb.SociatyJob_PRESIDENT) {
code = pb.ErrorCode_SociatyQuitNoAllowed
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyQuitNoAllowed,
Title: pb.ErrorCode_SociatyQuitNoAllowed.ToString(),
}
return
}
// 退出公会
if err := this.module.modelSociaty.quit(uid, sociaty); err != nil {
code = pb.ErrorCode_SociatyQuit
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyQuit,
Title: pb.ErrorCode_SociatyQuit.ToString(),
}
this.module.Errorf("退出公会", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "err": err.Error()})
return
}
@ -49,8 +54,7 @@ func (this *apiComp) Quit(session comm.IUserSession, req *pb.SociatyQuitReq) (er
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
data.Title = code.ToString()
data.Message = err.Error()
this.module.Error("退出公会,更新玩家公会ID",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
@ -73,8 +77,6 @@ func (this *apiComp) Quit(session comm.IUserSession, req *pb.SociatyQuitReq) (er
Uid: uid,
SociatyId: sociaty.Id,
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeQuit, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
session.SendMsg(string(this.module.GetType()), SociatySubTypeQuit, rsp)
return
}

View File

@ -18,8 +18,6 @@ func (this *apiComp) Rank(session comm.IUserSession, req *pb.SociatyRankReq) (er
Rank: list,
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeRank, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
session.SendMsg(string(this.module.GetType()), SociatySubTypeRank, rsp)
return
}

View File

@ -26,7 +26,6 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.SociatyReceiveRe
uid := session.GetUserId()
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty == nil {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}
@ -35,11 +34,17 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.SociatyReceiveRe
for _, v := range sociatyTask.TaskList {
if v.TaskId == req.TaskId {
if v.Status != 1 {
code = pb.ErrorCode_SociatyTaskValidation
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyTaskValidation,
Title: pb.ErrorCode_SociatyTaskValidation.ToString(),
}
return
}
if v.Received == 1 { //已领取
code = pb.ErrorCode_SociatyRewardReceived
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyRewardReceived,
Title: pb.ErrorCode_SociatyRewardReceived.ToString(),
}
return
}
break
@ -48,7 +53,11 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.SociatyReceiveRe
// 奖励领取
if err := this.module.modelSociatyTask.receive(req.TaskId, sociaty.Id, uid); err != nil {
code = pb.ErrorCode_SociatyRewardReceive
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyRewardReceived,
Title: pb.ErrorCode_SociatyRewardReceived.ToString(),
}
this.module.Error("领取公会任务奖励",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
@ -67,7 +76,6 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.SociatyReceiveRe
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
log.Field{Key: "taskId", Value: req.TaskId},
log.Field{Key: "code", Value: code},
)
}
}
@ -99,8 +107,6 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.SociatyReceiveRe
TaskId: req.TaskId,
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeReceive, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
session.SendMsg(string(this.module.GetType()), SociatySubTypeReceive, rsp)
return
}

View File

@ -23,8 +23,6 @@ func (this *apiComp) Recommend(session comm.IUserSession, req *pb.SociatyRecomme
rsp := &pb.SociatyRecommendResp{}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeRecommend, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
session.SendMsg(string(this.module.GetType()), SociatySubTypeRecommend, rsp)
return
}

View File

@ -24,11 +24,10 @@ func (this *apiComp) Refuse(session comm.IUserSession, req *pb.SociatyRefuseReq)
return
}
data = &pb.ErrorData{}
uid := session.GetUserId()
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty == nil {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}
@ -38,22 +37,28 @@ func (this *apiComp) Refuse(session comm.IUserSession, req *pb.SociatyRefuseReq)
pb.SociatyJob_PRESIDENT,
pb.SociatyJob_VICEPRESIDENT,
pb.SociatyJob_ADMIN) {
code = pb.ErrorCode_SociatyNoRight
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyNoRight,
Title: pb.ErrorCode_SociatyNoRight.ToString(),
}
return
}
// 已是公会成员
if this.module.modelSociaty.isMember(uid, sociaty) {
code = pb.ErrorCode_SociatyAdded
data.Title = code.ToString()
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyAdded,
Title: pb.ErrorCode_SociatyAdded.ToString(),
}
return
}
// 拒绝公会申请
if err := this.module.modelSociaty.refuse(req.Uid, sociaty); err != nil {
code = pb.ErrorCode_SociatyRefuse
data.Title = code.ToString()
data.Message = err.Error()
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyRefuse,
Title: pb.ErrorCode_SociatyRefuse.ToString(),
}
this.module.Error("申请拒绝",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "拒绝目标人", Value: req.Uid},
@ -66,8 +71,6 @@ func (this *apiComp) Refuse(session comm.IUserSession, req *pb.SociatyRefuseReq)
Uid: req.Uid,
SociatyId: sociaty.Id,
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeRefuse, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
session.SendMsg(string(this.module.GetType()), SociatySubTypeRefuse, rsp)
return
}

View File

@ -22,15 +22,13 @@ func (this *apiComp) Search(session comm.IUserSession, req *pb.SociatySearchReq)
if errdata = this.SearchCheck(session, req); errdata != nil {
return
}
data = &pb.ErrorData{}
rsp := &pb.SociatySearchResp{}
sociaty := this.module.modelSociaty.findByName(req.Name)
if sociaty != nil && sociaty.Id != "" {
rsp.List = append(rsp.List, sociaty)
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeSearch, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
session.SendMsg(string(this.module.GetType()), SociatySubTypeSearch, rsp)
return
}

View File

@ -23,11 +23,10 @@ func (this *apiComp) Setting(session comm.IUserSession, req *pb.SociatySettingRe
if errdata = this.SettingCheck(session, req); errdata != nil {
return
}
data = &pb.ErrorData{}
uid := session.GetUserId()
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty == nil {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}
@ -35,7 +34,10 @@ func (this *apiComp) Setting(session comm.IUserSession, req *pb.SociatySettingRe
// 校验权限
if !this.module.modelSociaty.isRight(uid, sociaty,
pb.SociatyJob_PRESIDENT, pb.SociatyJob_VICEPRESIDENT) {
code = pb.ErrorCode_SociatyNoRight
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyNoRight,
Title: pb.ErrorCode_SociatyNoRight.ToString(),
}
return
}
@ -46,9 +48,10 @@ func (this *apiComp) Setting(session comm.IUserSession, req *pb.SociatySettingRe
// 更新设置
if err := this.module.modelSociaty.setting(sociaty); err != nil {
code = pb.ErrorCode_SociatySetting
data.Title = code.ToString()
data.Message = err.Error()
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatySetting,
Title: pb.ErrorCode_SociatySetting.ToString(),
}
this.module.Error("公会修改",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
@ -62,8 +65,6 @@ func (this *apiComp) Setting(session comm.IUserSession, req *pb.SociatySettingRe
SociatyId: sociaty.Id,
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeSetting, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
session.SendMsg(string(this.module.GetType()), SociatySubTypeSetting, rsp)
return
}

View File

@ -22,11 +22,10 @@ func (this *apiComp) SettingJob(session comm.IUserSession, req *pb.SociatySettin
if errdata = this.SettingJobCheck(session, req); errdata != nil {
return
}
data = &pb.ErrorData{}
uid := session.GetUserId()
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty == nil {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}
@ -34,13 +33,19 @@ func (this *apiComp) SettingJob(session comm.IUserSession, req *pb.SociatySettin
// 权限校验
if !this.module.modelSociaty.isRight(uid, sociaty,
pb.SociatyJob_PRESIDENT) {
code = pb.ErrorCode_SociatyNoRight
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyNoRight,
Title: pb.ErrorCode_SociatyNoRight.ToString(),
}
return
}
// 不能设置自己
if uid == req.TargetId {
code = pb.ErrorCode_SociatySelfSetting
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatySelfSetting,
Title: pb.ErrorCode_SociatySelfSetting.ToString(),
}
return
}
@ -49,13 +54,19 @@ func (this *apiComp) SettingJob(session comm.IUserSession, req *pb.SociatySettin
jobCount := this.module.modelSociaty.getJobCount(req.Job, sociaty)
if req.Job == pb.SociatyJob_VICEPRESIDENT && jobCount >= int(globalConf.GuildViceAllianceLeaderMaxNum) ||
req.Job == pb.SociatyJob_ADMIN && jobCount >= int(globalConf.GuildAdministratorsMaxNum) {
code = pb.ErrorCode_SociatyMemberCountLimit
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyMemberCountLimit,
Title: pb.ErrorCode_SociatyMemberCountLimit.ToString(),
}
return
}
// 设置职位
if err := this.module.modelSociaty.settingJob(req.TargetId, req.Job, sociaty); err != nil {
code = pb.ErrorCode_SociatySettingJob
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatySettingJob,
Title: pb.ErrorCode_SociatySettingJob.ToString(),
}
this.module.Errorf("设置公会职位", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "params": req, "err": err.Error()})
return
}
@ -66,8 +77,6 @@ func (this *apiComp) SettingJob(session comm.IUserSession, req *pb.SociatySettin
Job: req.Job,
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeSettingJob, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
session.SendMsg(string(this.module.GetType()), SociatySubTypeSettingJob, rsp)
return
}

View File

@ -16,31 +16,36 @@ func (this *apiComp) Sign(session comm.IUserSession, req *pb.SociatySignReq) (er
return
}
uid := session.GetUserId()
data = &pb.ErrorData{}
sociaty := this.module.modelSociaty.getUserSociaty(uid)
if sociaty == nil {
code = pb.ErrorCode_SociatyNoFound
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
return
}
// 不是该公会成员
if !this.module.modelSociaty.isMember(uid, sociaty) {
code = pb.ErrorCode_SociatyNoAdded
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyNoAdded,
Title: pb.ErrorCode_SociatyNoAdded.ToString(),
}
return
}
// 判断是否已签到
if this.module.modelSociaty.IsSign(uid, sociaty) {
code = pb.ErrorCode_SociatySigned
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatySigned,
Title: pb.ErrorCode_SociatySigned.ToString(),
}
return
}
// 签到
if err := this.module.modelSociaty.sign(uid, sociaty); err != nil {
code = pb.ErrorCode_SociatySign
data.Title = code.ToString()
data.Message = err.Error()
errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatySign,
Title: pb.ErrorCode_SociatySign.ToString(),
}
this.module.Error("签到失败", log.Field{Key: "uid", Value: uid}, log.Field{Key: "sociatyId", Value: sociaty.Id}, log.Field{Key: "err", Value: err.Error()})
return
}
@ -51,13 +56,12 @@ func (this *apiComp) Sign(session comm.IUserSession, req *pb.SociatySignReq) (er
for _, v := range this.module.sociatySignConf.GetDataList() {
if lastSignCount >= v.Down && lastSignCount <= v.Up {
// 发放签到奖励
if errdata = this.module.DispenseRes(session, v.Reward, true); code == pb.ErrorCode_Success {
if errdata = this.module.DispenseRes(session, v.Reward, true); errdata == nil {
signCfgId = v.Id
} else {
log.Error("发放签到奖励失败",
log.Field{Key: "uid", Value: uid},
log.Field{Key: "sociatyId", Value: sociaty.Id},
log.Field{Key: "code", Value: code},
)
}
break
@ -91,8 +95,6 @@ func (this *apiComp) Sign(session comm.IUserSession, req *pb.SociatySignReq) (er
SociatyId: sociaty.Id,
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeSign, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
session.SendMsg(string(this.module.GetType()), SociatySubTypeSign, rsp)
return
}

Some files were not shown because too many files have changed in this diff Show More