Пример #1
0
        private void Disband(Character disbander) => OnlyWithLeader(disbander.ID, ldr =>
        {
            _log.Debug($"Disbanding party {partyId} by character {disbander.ID}");

            ForAllMembers(m =>
            {
                m.SendPacket(PartyPacket.MemberLeft(m, ldr, this, true, false));
                var c = m.GetCharacter(false);

                if (c != null)
                {
                    c.PartyID = 0;
                }
                else
                {
                    _log.Debug($"Unable to set PartyID to 0 of {m.id}");
                }
            }, -1, false);

            for (var i = 0; i < Constants.MaxPartyMembers; i++)
            {
                members[i] = null;
            }

            leader = null;

            Parties.Remove(partyId);
            var discardedInvites = Invites.Where(x => x.Value.partyId == partyId).Select(x => x.Key).ToArray();
            discardedInvites.ForEach(x => Invites.Remove(x));

            SendPartyDisband();
        });
Пример #2
0
        public ViewInvitesViewModel(MainViewModel parent, IMobileServiceTable <Invite> invitesTable, Action dismiss)
        {
            _parent       = parent;
            _invitesTable = invitesTable;
            Invites       = parent.Invites;

            AcceptCommand = new DelegateCommand <Invite>(async invite =>
            {
                invite.Approved = true;
                await _invitesTable.UpdateAsync(invite);
                Invites.Remove(invite);
                _parent.LoadLists();
                _parent.ViewInvitesCommand.IsEnabled = Invites.Count > 0;
                if (Invites.Count == 0)
                {
                    dismiss();
                }
            });

            RejectCommand = new DelegateCommand <Invite>(async invite =>
            {
                await _invitesTable.UpdateAsync(invite);
                Invites.Remove(invite);
                _parent.ViewInvitesCommand.IsEnabled = Invites.Count > 0;
                if (Invites.Count == 0)
                {
                    dismiss();
                }
            });
        }
Пример #3
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);
        }
Пример #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);
     }
 }
Пример #5
0
        private async Task ProcessInvite(Invite invite)
        {
            await invitesTable.UpdateAsync(invite);

            Invites.Remove(invite);
            if (Invites.Count > 0)
            {
                parent.IsPendingInvitesButtonVisible = true;
                parent.ViewInvitesCommand.IsEnabled  = true;
            }
            else
            {
                flyoutProvider.HideViewInvitesFlyout();
                parent.IsPendingInvitesButtonVisible = false;
                parent.ViewInvitesCommand.IsEnabled  = false;
            }
        }
Пример #6
0
        private async void AcceptInvite(Wishlist item)
        {
            await wishListService.AcceptInvite(item.WishlistId);

            Invites.Remove(item);
        }
Пример #7
0
 public bool RemoveInvite(uint id)
 {
     return(Invites.Remove(id));
 }