Example #1
0
 /// <summary>
 /// Cancels duel.
 /// </summary>
 /// <param name="cancelReason">player is too far away; player was attacked etc.</param>
 private void SendDuelCancel(IWorldClient client, DuelCancelReason cancelReason, int playerId)
 {
     using var packet = new Packet(PacketType.DUEL_CANCEL);
     packet.Write((byte)cancelReason);
     packet.Write(playerId);
     client.SendPacket(packet);
 }
Example #2
0
        private void Sender_OnDuelFinish(DuelCancelReason reason)
        {
            switch (reason)
            {
            case DuelCancelReason.Lose:
                FinishTradeSuccessful(Sender.DuelOpponent, Sender);
                SendDuelFinish(Sender.Client, false);
                SendDuelFinish(Sender.DuelOpponent.Client, true);
                break;

            case DuelCancelReason.TooFarAway:
                SendDuelCancel(Sender.Client, DuelCancelReason.TooFarAway, Sender.Id);
                SendDuelCancel(Sender.DuelOpponent.Client, DuelCancelReason.TooFarAway, Sender.Id);
                break;

            case DuelCancelReason.OpponentDisconnected:
                SendDuelCancel(Sender.DuelOpponent.Client, DuelCancelReason.OpponentDisconnected, Sender.Id);
                break;

            case DuelCancelReason.AdmitDefeat:
                SendDuelCancel(Sender.Client, DuelCancelReason.AdmitDefeat, Sender.Id);
                SendDuelCancel(Sender.DuelOpponent.Client, DuelCancelReason.AdmitDefeat, Sender.Id);
                break;

                // TODO: implement MobAttack.
            }

            StopDuel();
        }
 private void SendDuelCancel(int senderId, DuelCancelReason reason)
 {
     if (reason != DuelCancelReason.Other)
     {
         _packetFactory.SendDuelCancel(GameSession.Client, reason, senderId);
     }
 }