Exemplo n.º 1
0
 public override void run()
 {
     try
     {
         Account player = this._client._player;
         Room    room   = player == null ? (Room)null : player._room;
         SLOT    slot1;
         if (room == null || room._state < RoomState.Loading || (!room.getSlot(player._slotId,out slot1) || slot1.state < SLOT_STATE.LOAD))
         {
             return;
         }
         bool isBotMode = room.isBotMode();
         this.FreepassEffect(player,slot1,room,isBotMode);
         if (room.vote.Timer != null && room.votekick != null && room.votekick.victimIdx == slot1._id)
         {
             room.vote.Timer = (Timer)null;
             room.votekick   = (VoteKick)null;
             using (VOTEKICK_CANCEL_VOTE_PAK votekickCancelVotePak = new VOTEKICK_CANCEL_VOTE_PAK())
                 room.SendPacketToPlayers((SendPacket)votekickCancelVotePak,SLOT_STATE.BATTLE,0,slot1._id);
         }
         AllUtils.ResetSlotInfo(room,slot1,true);
         int red13  = 0;
         int blue13 = 0;
         int num1   = 0;
         int num2   = 0;
         for (int index = 0; index < 16; ++index)
         {
             SLOT slot2 = room._slots[index];
             if (slot2.state >= SLOT_STATE.LOAD)
             {
                 if (slot2._team == 0)
                 {
                     ++num1;
                 }
                 else
                 {
                     ++num2;
                 }
                 if (slot2.state == SLOT_STATE.BATTLE)
                 {
                     if (slot2._team == 0)
                     {
                         ++red13;
                     }
                     else
                     {
                         ++blue13;
                     }
                 }
             }
         }
         if (slot1._id == room._leader)
         {
             if (isBotMode)
             {
                 if (red13 > 0 || blue13 > 0)
                 {
                     this.LeaveHostBOT_GiveBattle(room,player);
                 }
                 else
                 {
                     this.LeaveHostBOT_EndBattle(room,player);
                 }
             }
             else if (room._state == RoomState.Battle && (red13 == 0 || blue13 == 0) || room._state <= RoomState.PreBattle && (num1 == 0 || num2 == 0))
             {
                 this.LeaveHostNoBOT_EndBattle(room,player,red13,blue13);
             }
             else
             {
                 this.LeaveHostNoBOT_GiveBattle(room,player);
             }
         }
         else if (!isBotMode)
         {
             if (room._state == RoomState.Battle && (red13 == 0 || blue13 == 0) || room._state <= RoomState.PreBattle && (num1 == 0 || num2 == 0))
             {
                 this.LeavePlayerNoBOT_EndBattle(room,player,red13,blue13);
             }
             else
             {
                 this.LeavePlayer_QuitBattle(room,player);
             }
         }
         else
         {
             this.LeavePlayer_QuitBattle(room,player);
         }
         this._client.SendPacket((SendPacket) new BATTLE_LEAVEP2PSERVER_PAK(player,0));
         if (this.isFinished || room._state != RoomState.Battle)
         {
             return;
         }
         AllUtils.BattleEndRoundPlayersCount(room);
     }
     catch (Exception ex)
     {
         Logger.warning("[BATTLE_PLAYER_LEAVE_REC] " + ex.ToString());
     }
 }
 public override void run()
 {
     try
     {
         Account p    = _client._player;
         Room    room = p == null ? null : p._room;
         SLOT    slot;
         if (room != null && (int)room._state >= 2 && room.getSlot(p._slotId,out slot) && (int)slot.state >= 9)
         {
             bool isBotMode = room.isBotMode();
             FreepassEffect(p,slot,room,isBotMode);
             if (room.vote.Timer != null && room.votekick != null && room.votekick.victimIdx == slot._id)
             {
                 room.vote.Timer = null;
                 room.votekick   = null;
                 using (VOTEKICK_CANCEL_VOTE_PAK packet = new VOTEKICK_CANCEL_VOTE_PAK())
                     room.SendPacketToPlayers(packet,SLOT_STATE.BATTLE,0,slot._id);
             }
             AllUtils.ResetSlotInfo(room,slot,true);
             int red13 = 0,blue13 = 0,red9 = 0,blue9 = 0;
             for (int i = 0; i < 16; i++)
             {
                 SLOT slotR = room._slots[i];
                 if ((int)slotR.state >= 9)
                 {
                     if (slotR._team == 0)
                     {
                         red9++;
                     }
                     else
                     {
                         blue9++;
                     }
                     if (slotR.state == SLOT_STATE.BATTLE)
                     {
                         if (slotR._team == 0)
                         {
                             red13++;
                         }
                         else
                         {
                             blue13++;
                         }
                     }
                 }
             }
             if (slot._id == room._leader)
             {
                 if (isBotMode)
                 {
                     if (red13 > 0 || blue13 > 0)
                     {
                         LeaveHostBOT_GiveBattle(room,p);
                     }
                     else
                     {
                         LeaveHostBOT_EndBattle(room,p);
                     }
                 }
                 else if ((int)room._state == 5 && (red13 == 0 || blue13 == 0) || (int)room._state <= 4 && (red9 == 0 || blue9 == 0))
                 {
                     LeaveHostNoBOT_EndBattle(room,p,red13,blue13);
                 }
                 else
                 {
                     LeaveHostNoBOT_GiveBattle(room,p);
                 }
             }
             else if (!isBotMode)
             {
                 if ((int)room._state == 5 && (red13 == 0 || blue13 == 0) || (int)room._state <= 4 && (red9 == 0 || blue9 == 0))
                 {
                     LeavePlayerNoBOT_EndBattle(room,p,red13,blue13);
                 }
                 else
                 {
                     LeavePlayer_QuitBattle(room,p);
                 }
             }
             else
             {
                 LeavePlayer_QuitBattle(room,p);
             }
             _client.SendPacket(new BATTLE_LEAVEP2PSERVER_PAK(p,0));
             if (!isFinished && room._state == RoomState.Battle)
             {
                 AllUtils.BattleEndRoundPlayersCount(room);
             }
         }
     }
     catch (Exception ex)
     {
         SaveLog.fatal(ex.ToString());
         Printf.b_danger("[BATTLE_PLAYER_LEAVE_REC.run] Erro fatal!");
     }
 }