Ejemplo n.º 1
0
        public void TryJoin(Character chr)
        {
            if (!Invites.ContainsKey(chr.ID))
            {
                Program.MainForm.LogAppend("Trying to join party while no invite. CharacterID: {0}, party ID {1}",
                                           chr.ID, partyId);
                chr.SendPacket(PartyPacket.PartyError(PartyFunction.UNABLE_TO_FIND_PLAYER));
                return;
            }

            Invites.Remove(chr.ID);
            if (IsFull())
            {
                _log.Warn($"Invite accepted to party {partyId} by {chr.ID}, but its already full.");
                chr.SendPacket(PartyPacket.PartyError(PartyFunction.JOIN_ALREADY_FULL));
                return;
            }

            if (chr.PartyID != 0)
            {
                _log.Warn($"Invite accepted to party {partyId} by {chr.ID}, the person is already in a party");
                chr.SendPacket(PartyPacket.PartyError(PartyFunction.JOIN_ALREADY_JOINED));
                return;
            }

            if (leader.GetMap() != chr.MapID)
            {
                _log.Warn($"Invite accepted to party {partyId} by {chr.ID}, but is not in the same map.");
                chr.SendPacket(PartyPacket.PartyError(PartyFunction.UNABLE_TO_FIND_PLAYER));
                return;
            }

            Join(chr);
        }
Ejemplo n.º 2
0
 public void Invite(int invitor, int invitee) => OnlyWithLeader(invitor, ldr =>
 {
     var toInvite = CenterServer.Instance.FindCharacter(invitee);
     if (toInvite == null)
     {
         ldr.SendPacket(PartyPacket.PartyError(PartyFunction.UNABLE_TO_FIND_PLAYER));
     }
     else if (Invites.ContainsKey(toInvite.ID))
     {
         ldr.SendPacket(PartyPacket.PartyErrorWithName(PartyFunction.INVITE_USER_ALREADY_HAS_INVITE, toInvite.Name));
     }
     else if (toInvite.PartyID != 0)
     {
         ldr.SendPacket(PartyPacket.PartyError(PartyFunction.JOIN_ALREADY_JOINED));
     }
     else if (IsFull())
     {
         ldr.SendPacket(PartyPacket.PartyError(PartyFunction.JOIN_ALREADY_FULL));
     }
     else
     {
         _log.Debug($"Sending invite from party {partyId} from character {invitor} to {invitee}");
         toInvite.SendPacket(PartyPacket.PartyInvite(this));
         Invites.Add(toInvite.ID, this);
         //TODO do invites expire?
     }
 });
Ejemplo n.º 3
0
 public bool IsInvited(uint id)
 {
     if (id == Owner)
     {
         return(true);
     }
     return(Invites.ContainsKey(id));
 }
Ejemplo n.º 4
0
 public void DeclineInvite(Character decliner)
 {
     if (Invites.ContainsKey(decliner.ID))
     {
         _log.Debug($"Invite to party {partyId} has been declined by {decliner.ID}");
         Invites.Remove(decliner.ID);
         leader.SendPacket(PartyPacket.PartyErrorWithName(PartyFunction.INVITE_REJECTED, decliner.Name));
     }
     else
     {
         Program.MainForm.LogAppend("Trying to decline party invite while no invite exists. CharacterID: {0}, party ID {1}", decliner.ID, partyId);
     }
 }
Ejemplo n.º 5
0
        public void InvitePlayer(Player invitor, Player invitedPlayer)
        {
            if (Invites.ContainsKey(invitedPlayer.CharacterId))
            {
                return;
            }

            Invites[invitedPlayer.CharacterId] = invitedPlayer;

            invitedPlayer.SendTextMessage(MessageTypes.InfoDescription, string.Format("{0} invites you to {1} private chat channel.", invitor.CharacterName, GenderStringifier.Stringify(invitor)));

            invitor.SendTextMessage(MessageTypes.InfoDescription, string.Format("{0} has been invited.", invitedPlayer.CharacterName));

            foreach (Player user in Users.Values)
            {
                user.SendChannelEvent(Id, invitedPlayer.CharacterName, ChatChannelEvents.Invite);
            }
        }