战斗中主动退出处理
This commit is contained in:
parent
be9aead903
commit
5a44eaffdb
@ -18,6 +18,7 @@ func (this *apiComp) ActiveCancel(session comm.IUserSession, req *pb.PvpActiveCa
|
||||
var (
|
||||
battle *BattleItem
|
||||
ok bool
|
||||
faiside int32
|
||||
winside int32
|
||||
)
|
||||
if code = this.ActiveCancelCheck(session, req); code != pb.ErrorCode_Success {
|
||||
@ -28,19 +29,28 @@ func (this *apiComp) ActiveCancel(session comm.IUserSession, req *pb.PvpActiveCa
|
||||
this.module.lock.RUnlock()
|
||||
if ok {
|
||||
if battle.Red.Uid == session.GetUserId() {
|
||||
faiside = 1
|
||||
winside = 2
|
||||
} else {
|
||||
faiside = 2
|
||||
winside = 1
|
||||
}
|
||||
this.module.PvpFinishPush(&pb.BattleFinishPush{
|
||||
Battleid: req.Battleid,
|
||||
WinSide: winside,
|
||||
})
|
||||
if err := this.module.SendMsgToSession(string(comm.ModulePvp), "cancel", &pb.PvpCancelPush{
|
||||
ServicePath: fmt.Sprintf("%s/%s", this.service.GetType(), this.service.GetId()),
|
||||
Battleid: battle.Id,
|
||||
}, battle.RedSession, battle.BlueSession); err != nil {
|
||||
this.module.Errorln(err)
|
||||
if battle.State == pb.PvpState_battle {
|
||||
this.module.battle.ConcedeBattle(&pb.BattleConcedeReq{
|
||||
Battleid: req.Battleid,
|
||||
Side: faiside,
|
||||
})
|
||||
} else {
|
||||
this.module.PvpFinishPush(&pb.BattleFinishPush{
|
||||
Battleid: req.Battleid,
|
||||
WinSide: winside,
|
||||
})
|
||||
if err := this.module.SendMsgToSession(string(comm.ModulePvp), "cancel", &pb.PvpCancelPush{
|
||||
ServicePath: fmt.Sprintf("%s/%s", this.service.GetType(), this.service.GetId()),
|
||||
Battleid: battle.Id,
|
||||
}, battle.RedSession, battle.BlueSession); err != nil {
|
||||
this.module.Errorln(err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
code = pb.ErrorCode_BattleInCmdFailed
|
||||
|
Loading…
Reference in New Issue
Block a user