Ejemplo n.º 1
0
        public void RemoveInvite(PartyInvite invite)
        {
            InformAboutRemoveInvite(invite);

            partyInviteRepository.Remove(invite);
            partyInviteRepository.SaveChanges();
        }
Ejemplo n.º 2
0
        // [Command("invite-r")]
        // public async Task RefreshInvite(int id)
        // {
        //  var invite = await _db.PartyInvites.FindAsync(id);
        //  if (invite == null) return;
        //
        //  var message = await Context.Channel.GetMessageAsync(invite.MessageId) as IUserMessage;
        //  if (message?.Embeds.Any() != true) return;
        //
        //  var jobs = _db.CharacterJobs.ToList();
        //  var emotes = Context.Guild.Emotes.Where(x => jobs.Select(y => y.ShortcutName).Contains(x.Name)).ToList();
        //
        //  var entries = invite.PartyInviteEntries.ToList();
        //
        //  var users = new List<(IUser user, GuildEmote emote)>();
        //  foreach (var emote in emotes)
        //  {
        //      await foreach (var user in message.GetReactionUsersAsync(emote, 20))
        //      {
        //          users.AddRange(user.Select(x => (x, emote)));
        //      }
        //  }
        //
        //  using (var transaction = await _db.Database.BeginTransactionAsync())
        //  {
        //      try
        //      {
        //          foreach (var entry in entries)
        //          {
        //              if (!users.Any(x => x.user.Id == entry.User.DiscordId))
        //              {
        //                  _db.Remove(entry);
        //                  await _db.SaveChangesAsync();
        //                  continue;
        //              }
        //
        //              var jobUser = users.FirstOrDefault(x => x.user.Id == entry.User.DiscordId);
        //              var job = jobs.First(x => x.ShortcutName == jobUser.emote.Name);
        //              if (entry.JobId != job.JobId)
        //              {
        //                  entry.JobId = job.JobId;
        //                  // entry.ReactionName = jobUser.emote.Name;
        //
        //                  _db.Update(entry);
        //                  await _db.SaveChangesAsync();
        //                  continue;
        //              }
        //
        //              var entity = new PartyInviteEntry
        //              {
        //                  PartyInviteId = invite.PartyInviteId,
        //                  // ReactionName = jobUser.emote.Name,
        //                  // UserId = jobUser.user.Id,
        //                  // CharacterJobId = job.JobId
        //              };
        //
        //              await _db.PartyInviteEntries.AddAsync(entry);
        //              await _db.SaveChangesAsync();
        //          }
        //
        //          await transaction.CommitAsync();
        //      }
        //      catch (Exception)
        //      {
        //          transaction.Rollback();
        //          return;
        //      }
        //  }
        //
        //  var inviter = await Context.Channel.GetUserAsync(1);
        //
        //  await message.ModifyAsync(properties => { properties.Embed = CreateEmbed(message, invite, inviter); });
        // }

        private Embed CreateEmbed(IUserMessage message, PartyInvite invite, IUser user)
        {
            var template    = invite.ContentTemplate;
            var contentName = !string.IsNullOrEmpty(template.QuestUrl)
                                ? $"[{template.ContentName}]({template.QuestUrl})"
                                : template.ContentName;

            return(new EmbedBuilder
            {
                Title = "パーティ募集",
                Description = $"#{invite.PartyInviteId}"
            }
                   .AddField(builder =>
            {
                builder.Name = "高難易度コンテンツ";
                builder.Value = contentName;
            })
                   .AddField("目的", invite.Purpose.DisplayName(), true)
                   .AddField("開始日時", invite.StartDate.ToString("yyyy/MM/dd HH:mm"), true)
                   .AddField("参加人数", $"{invite.PartyInviteEntries.Count}/8 人", true)
                   .WithAuthor(user)
                   .WithColor(Color.Purple)
                   .WithCurrentTimestamp()
                   .Build());
        }
        public async Task ProcessInviteToParty(ConnectedUser usr, InviteToParty msg)
        {
            ConnectedUser target;
            if (server.ConnectedUsers.TryGetValue(msg.UserName, out target))
            {
                if (target.Ignores.Contains(usr.Name)) return;
                var myParty = GetParty(usr.Name);
                var targetParty = GetParty(target.Name);
                if ((myParty != null) && (myParty == targetParty)) return;

                RemoveOldInvites();
                var partyInvite = partyInvites.FirstOrDefault(x => (x.Inviter == usr.Name) && (x.Invitee == target.Name));

                if (partyInvite == null)
                {
                    partyInvite = new PartyInvite()
                    {
                        PartyID = myParty?.PartyID ?? Interlocked.Increment(ref partyCounter),
                        Inviter = usr.Name,
                        Invitee = target.Name
                    };
                    partyInvites.Add(partyInvite);
                }

                await
                    target.SendCommand(new OnPartyInvite()
                    {
                        PartyID = partyInvite.PartyID,
                        UserNames = myParty?.UserNames?.ToList() ?? new List<string>() { usr.Name },
                        TimeoutSeconds = inviteTimeoutSeconds
                    });
            }
        }
Ejemplo n.º 4
0
        public async Task CreateInviteAsync(string?shortcutName = null, int purpose = 1, DateTime?startDate = null,
                                            DateTime?endDate    = null)
        {
            await using var transaction = await _db.Database.BeginTransactionAsync();

            var template = _db.ContentTemplates.FirstOrDefault(x => x.ShortcutName == shortcutName);

            if (template == null)
            {
                return;
            }

            var user = await _db.Users.FirstOrDefaultAsync(x => x.DiscordId == Context.User.Id);

            if (user == null)
            {
                await ReplyAsync("You are not registered.");

                return;
            }

            var invite = new PartyInvite
            {
                UserId            = user.UserId,
                ContentTemplateId = template.ContentTemplateId,
                Purpose           = (Purpose)purpose,
                StartDate         = startDate ?? DateTime.Now,
                EndDate           = endDate
            };

            await _db.PartyInvites.AddAsync(invite);

            await _db.SaveChangesAsync();

            var inviteEmbed = new InviteEmbedWrapper
            {
                InviteId    = invite.PartyInviteId,
                ContentType = invite.ContentTemplate.ContentType.TypeName,
                ContentName = invite.ContentTemplate.GetQuestName(),
                Purpose     = invite.Purpose.DisplayName(),
                MaxPlayer   = invite.ContentTemplate.MaxPlayer,
                StartDate   = startDate,
                EndDate     = endDate,
                Inviter     = Context.User,
            };

            var inviteMessage = await ReplyAsync(embed : inviteEmbed.ToEmbed());

            var memberMessage = await ReplyAsync("参加者 \uD83D\uDCCC");

            invite.MessageId           = inviteMessage.Id;
            invite.MemberListMessageId = memberMessage.Id;
            _db.PartyInvites.Update(invite);
            await _db.SaveChangesAsync();

            await Context.Message.DeleteAsync();

            await transaction.CommitAsync();
        }
 public PartyInviteListItemViewModel(PartyInvite invite)
 {
     InviteID    = invite.ID;
     PartyID     = invite.PartyID;
     PartyName   = invite.Party.Entity.Name;
     PartyAvatar = new SmallEntityAvatarViewModel(invite.Party.Entity)
                   .DisableNameInclude();
 }
Ejemplo n.º 6
0
        private void InformAboutRemoveInvite(PartyInvite invite)
        {
            var    partyLink = EntityLinkCreator.Create(invite.Party.Entity).ToHtmlString();
            string message   = $"You are no longer invited to {partyLink}.";

            using (NoSaveChanges)
                warningService.AddWarning(invite.CitizenID, message);
        }
Ejemplo n.º 7
0
        public void DeclineInvite(PartyInvite invite)
        {
            var message = $"{invite.Citizen.Entity.Name} declined party invite.";

            using (NoSaveChanges)
                warningService.AddWarning(invite.PartyID, message);

            partyInviteRepository.Remove(invite);
            ConditionalSaveChanges(partyInviteRepository);
        }
Ejemplo n.º 8
0
        private void InitializeInvites()
        {
            IEnumerable <PartyInvite> invites = PartyInvite.GetAll(ActiveParty.Id);

            foreach (PartyInvite invite in invites)
            {
                FormattedListBoxItem item = new FormattedListBoxItem(invite.Id, invite.GuestName, true);
                item.SetHeight(35);
                listBoxGuests.Items.Add(item);
            }
        }
Ejemplo n.º 9
0
        public void InviteCitizen(Citizen citizen, Party party)
        {
            var invitiation = new PartyInvite()
            {
                CitizenID = citizen.ID,
                PartyID   = party.ID
            };

            partyInviteRepository.Add(invitiation);
            ConditionalSaveChanges(partyInviteRepository);
        }
Ejemplo n.º 10
0
        public void CreatePartyInvite(PartyInvite invite)
        {
            DateTime now = DateTime.Now;

            invite.Id      = Guid.NewGuid();
            invite.Created = now;
            invite.Updated = now;

            mConnection.Execute("INSERT INTO PartiesInvites(id,created,updated,partyid,playerid)" +
                                "value(@id,@created,@updated,@partyid,@playerid)", invite);
        }
Ejemplo n.º 11
0
        public MethodResult CanDeclineInvite(PartyInvite invite, Citizen citizen)
        {
            if (invite == null)
            {
                return(new MethodResult("Invite does not exist!"));
            }
            if (invite.CitizenID != citizen.ID)
            {
                return(new MethodResult("This is not your invite!"));
            }

            return(MethodResult.Success);
        }
Ejemplo n.º 12
0
        private void DeleteInvite()
        {
            if (listBoxGuests.SelectedItem == null)
            {
                return;
            }
            FormattedListBoxItem item =
                (FormattedListBoxItem)listBoxGuests.SelectedItem;

            PartyInvite.Delete(item.Id);
            listBoxGuests.Items.Remove(item);
            textBoxGuestName.Text  = "";
            buttonDelete.IsEnabled = false;
        }
Ejemplo n.º 13
0
        public async Task ProcessInviteToParty(ConnectedUser usr, InviteToParty msg)
        {
            ConnectedUser target;

            if (server.ConnectedUsers.TryGetValue(msg.UserName, out target))
            {
                if (target.Ignores.Contains(usr.Name))
                {
                    return;
                }
                var myParty     = GetParty(usr.Name);
                var targetParty = GetParty(target.Name);
                if ((myParty != null) && (myParty == targetParty))
                {
                    return;
                }

                // if i dont have battle but target has, join him
                if (myParty == null && usr.MyBattle == null && target.MyBattle != null && !target.MyBattle.IsPassworded)
                {
                    await server.ForceJoinBattle(usr.Name, target.MyBattle);
                }

                RemoveOldInvites();
                var partyInvite = partyInvites.FirstOrDefault(x => (x.Inviter == usr.Name) && (x.Invitee == target.Name));

                if (partyInvite == null)
                {
                    partyInvite = new PartyInvite()
                    {
                        PartyID = myParty?.PartyID ?? Interlocked.Increment(ref partyCounter),
                        Inviter = usr.Name,
                        Invitee = target.Name
                    };
                    partyInvites.Add(partyInvite);
                }

                await
                target.SendCommand(new OnPartyInvite()
                {
                    PartyID   = partyInvite.PartyID,
                    UserNames = myParty?.UserNames?.ToList() ?? new List <string>()
                    {
                        usr.Name
                    },
                    TimeoutSeconds = inviteTimeoutSeconds
                });
            }
        }
Ejemplo n.º 14
0
        private void textBoxGuestName_TextChanged(object sender, RoutedEventArgs e)
        {
            FormattedListBoxItem selectedItem = (FormattedListBoxItem)listBoxGuests.SelectedItem;

            if (selectedItem != null)
            {
                selectedItem.Text = textBoxGuestName.Text;
                PartyInvite invite = PartyInvite.Get(selectedItem.Id);
                if (invite != null)
                {
                    invite.SetGuestName(textBoxGuestName.Text);
                    invite.Update();
                }
            }
        }
Ejemplo n.º 15
0
    public static string GetInviterBestName(PartyInvite invite)
    {
        if ((invite != null) && !string.IsNullOrEmpty(invite.InviterName))
        {
            return(invite.InviterName);
        }
        BnetPlayer player = (invite != null) ? GetPlayer(invite.InviterId) : null;
        string     str    = (player != null) ? player.GetBestName() : null;

        if (string.IsNullOrEmpty(str))
        {
            str = GameStrings.Get("GLOBAL_PLAYER_PLAYER");
        }
        return(str);
    }
Ejemplo n.º 16
0
        private void AddInvite(string inviteName)
        {
            PartyInvite invite = PartyInvite.Add(ActiveParty.Id, inviteName);

            foreach (FormattedListBoxItem existingItem in listBoxGuests.Items)
            {
                existingItem.IsSelected = false;
            }
            FormattedListBoxItem item = new FormattedListBoxItem(invite.Id, inviteName, true);

            item.SetHeight(35);
            listBoxGuests.Items.Add(item);
            listBoxGuests.SelectedItem = item;
            listBoxGuests.ScrollIntoView(item);
            buttonDelete.IsEnabled = true;
        }
Ejemplo n.º 17
0
        public bool AddInvitation(ushort inviter, ushort invited)
        {
            if (GetInvite(invited) != null)
            {
                return(false);
            }

            var inviteTemplate = new PartyInvite
            {
                ConInviter = inviter,
                ConInvited = invited,
                Time       = DateTime.UtcNow.AddMinutes(5)
            };

            _partyInvites.Add(invited, inviteTemplate);
            return(true);
        }
Ejemplo n.º 18
0
        public MethodResult CanRemoveInvite(PartyInvite invite, Citizen citizen)
        {
            if (invite == null)
            {
                return(new MethodResult("Invite does not exist!"));
            }

            if (IsPartyMember(citizen, invite.Party).IsError)
            {
                return(new MethodResult("You cannot do that!"));
            }

            if (GetPartyRole(citizen, invite.Party) == PartyRoleEnum.Member)
            {
                return(new MethodResult("You cannot do that!"));
            }

            return(MethodResult.Success);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Joins the party of the provided <see cref="PartyInvite"/>.
        /// </summary>
        /// <param name="xmppClient">The <see cref="XMPPClient"/> to join the party from.</param>
        /// <param name="invite">The <see cref="PartyInvite"/> to accept.</param>
        internal static async Task JoinParty(XMPPClient xmppClient, PartyInvite invite)
        {
            // We're using a using statement so that the initialised client is disposed of when the code block is exited.
            using var client = new WebClient
                  {
                      Headers =
                      {
                          // This is so Epic Games' API knows what kind of data we're providing.
                          [HttpRequestHeader.ContentType] = "application/json",
                          // Set the Authorization header to the access token from the provided OAuthSession.
                          [HttpRequestHeader.Authorization] = $"bearer {xmppClient.AuthSession.AccessToken}"
                      }
                  };

start:
            try
            {
                // Use our request helper to make a POST request.
                var response = await client.PostDataAsync <PartyJoined>(Endpoints.Party.Join(invite.PartyId, xmppClient.AuthSession.AccountId),
                                                                        new PartyJoinInfo(xmppClient).ToString()).ConfigureAwait(false);

                // Set the XMPP clients current party to the party we just joined, then join the party chat.
                xmppClient.CurrentParty = await GetParty(xmppClient.AuthSession, response.PartyId);

                await xmppClient.JoinPartyChat();
            }
            catch (EpicException ex)
            {
                // If the error code DOESN'T indicate we're already in a party, throw the exception.
                if (ex.ErrorCode != "errors.com.epicgames.social.party.user_has_party")
                {
                    await InitParty(xmppClient);

                    throw;
                }

                // Else, restart the process.
                await InitParty(xmppClient);

                goto start;
            }
        }
Ejemplo n.º 20
0
        public override bool PartyInvite(string name, PartyType partyType)
        {
            if (data.PartyMembers.Count > 0 && data.PartyLeaderObjectId != data.MainHero.ObjectId)
            {
                return(false);
            }

            var action = new PartyInvite(name, partyType);

            action.Send(data, tcpClient);

            int timeout = 0;

            data.PendingInvite = null;
            while (data.PendingInvite == null && timeout < 10)
            {
                timeout++;
                Thread.Sleep(100);
            }

            return(data.PendingInvite ?? false);
        }
Ejemplo n.º 21
0
 private static void ResetTransactionalTables()
 {
     SettingManager.SetStoreSetting("DailyIdOffset", 0);
     DayOfOperation.Reset(typeof(DayOfOperation));
     EmployeeTimesheet.Reset(typeof(EmployeeTimesheet));
     EmployeeTimesheetChangeLog.Reset(typeof(EmployeeTimesheetChangeLog));
     Lock.Reset(typeof(Lock));
     Party.Reset(typeof(Party));
     PartyInvite.Reset(typeof(PartyInvite));
     RegisterDeposit.Reset(typeof(RegisterDeposit));
     RegisterDrawer.Reset(typeof(RegisterDrawer));
     RegisterDrop.Reset(typeof(RegisterDrop));
     RegisterNoSale.Reset(typeof(RegisterNoSale));
     RegisterPayout.Reset(typeof(RegisterPayout));
     Ticket.Reset(typeof(Ticket));
     TicketCoupon.Reset(typeof(TicketCoupon));
     TicketDiscount.Reset(typeof(TicketDiscount));
     TicketItem.Reset(typeof(TicketItem));
     TicketItemOption.Reset(typeof(TicketItemOption));
     TicketItemReturn.Reset(typeof(TicketItemReturn));
     TicketPayment.Reset(typeof(TicketPayment));
     TicketRefund.Reset(typeof(TicketRefund));
     TicketVoid.Reset(typeof(TicketVoid));
 }
Ejemplo n.º 22
0
        void HandlePartyInvite(PartyInviteClient packet)
        {
            Player invitingPlayer = GetPlayer();
            Player invitedPlayer  = Global.ObjAccessor.FindPlayerByName(packet.TargetName);

            // no player
            if (invitedPlayer == null)
            {
                SendPartyResult(PartyOperation.Invite, packet.TargetName, PartyResult.BadPlayerNameS);
                return;
            }

            // player trying to invite himself (most likely cheating)
            if (invitedPlayer == invitingPlayer)
            {
                SendPartyResult(PartyOperation.Invite, invitedPlayer.GetName(), PartyResult.BadPlayerNameS);
                return;
            }

            // restrict invite to GMs
            if (!WorldConfig.GetBoolValue(WorldCfg.AllowGmGroup) && !invitingPlayer.IsGameMaster() && invitedPlayer.IsGameMaster())
            {
                SendPartyResult(PartyOperation.Invite, invitedPlayer.GetName(), PartyResult.BadPlayerNameS);
                return;
            }

            // can't group with
            if (!invitingPlayer.IsGameMaster() && !WorldConfig.GetBoolValue(WorldCfg.AllowTwoSideInteractionGroup) && invitingPlayer.GetTeam() != invitedPlayer.GetTeam())
            {
                SendPartyResult(PartyOperation.Invite, invitedPlayer.GetName(), PartyResult.PlayerWrongFaction);
                return;
            }
            if (invitingPlayer.GetInstanceId() != 0 && invitedPlayer.GetInstanceId() != 0 && invitingPlayer.GetInstanceId() != invitedPlayer.GetInstanceId() && invitingPlayer.GetMapId() == invitedPlayer.GetMapId())
            {
                SendPartyResult(PartyOperation.Invite, invitedPlayer.GetName(), PartyResult.TargetNotInInstanceS);
                return;
            }
            // just ignore us
            if (invitedPlayer.GetInstanceId() != 0 && invitedPlayer.GetDungeonDifficultyID() != invitingPlayer.GetDungeonDifficultyID())
            {
                SendPartyResult(PartyOperation.Invite, invitedPlayer.GetName(), PartyResult.IgnoringYouS);
                return;
            }

            if (invitedPlayer.GetSocial().HasIgnore(invitingPlayer.GetGUID(), invitingPlayer.GetSession().GetAccountGUID()))
            {
                SendPartyResult(PartyOperation.Invite, invitedPlayer.GetName(), PartyResult.IgnoringYouS);
                return;
            }

            if (!invitedPlayer.GetSocial().HasFriend(invitingPlayer.GetGUID()) && invitingPlayer.GetLevel() < WorldConfig.GetIntValue(WorldCfg.PartyLevelReq))
            {
                SendPartyResult(PartyOperation.Invite, invitedPlayer.GetName(), PartyResult.InviteRestricted);
                return;
            }

            Group group = invitingPlayer.GetGroup();

            if (group != null && group.IsBGGroup())
            {
                group = invitingPlayer.GetOriginalGroup();
            }

            if (group == null)
            {
                group = invitingPlayer.GetGroupInvite();
            }

            Group group2 = invitedPlayer.GetGroup();

            if (group2 != null && group2.IsBGGroup())
            {
                group2 = invitedPlayer.GetOriginalGroup();
            }

            PartyInvite partyInvite;

            // player already in another group or invited
            if (group2 || invitedPlayer.GetGroupInvite())
            {
                SendPartyResult(PartyOperation.Invite, invitedPlayer.GetName(), PartyResult.AlreadyInGroupS);

                if (group2)
                {
                    // tell the player that they were invited but it failed as they were already in a group
                    partyInvite = new PartyInvite();
                    partyInvite.Initialize(invitingPlayer, packet.ProposedRoles, false);
                    invitedPlayer.SendPacket(partyInvite);
                }

                return;
            }

            if (group)
            {
                // not have permissions for invite
                if (!group.IsLeader(invitingPlayer.GetGUID()) && !group.IsAssistant(invitingPlayer.GetGUID()))
                {
                    if (group.IsCreated())
                    {
                        SendPartyResult(PartyOperation.Invite, "", PartyResult.NotLeader);
                    }
                    return;
                }
                // not have place
                if (group.IsFull())
                {
                    SendPartyResult(PartyOperation.Invite, "", PartyResult.GroupFull);
                    return;
                }
            }

            // ok, but group not exist, start a new group
            // but don't create and save the group to the DB until
            // at least one person joins
            if (group == null)
            {
                group = new Group();
                // new group: if can't add then delete
                if (!group.AddLeaderInvite(invitingPlayer))
                {
                    return;
                }

                if (!group.AddInvite(invitedPlayer))
                {
                    group.RemoveAllInvites();
                    return;
                }
            }
            else
            {
                // already existed group: if can't add then just leave
                if (!group.AddInvite(invitedPlayer))
                {
                    return;
                }
            }

            partyInvite = new PartyInvite();
            partyInvite.Initialize(invitingPlayer, packet.ProposedRoles, true);
            invitedPlayer.SendPacket(partyInvite);

            SendPartyResult(PartyOperation.Invite, invitedPlayer.GetName(), PartyResult.Ok);
        }
Ejemplo n.º 23
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="Statistics" /> class.
        /// </summary>
        public Statistics()
        {
            _startTime = Environment.TickCount;

            WoWEventHandler.Instance.OnXpGain += (sender, args) =>
            {
                XpGained += args.Xp;
                OnPropertyChanged(nameof(XpGained));
                OnPropertyChanged(nameof(XpHour));
            };

            WoWEventHandler.Instance.LevelUp += (sender, args) =>
            {
                LevelUps++;
                OnPropertyChanged(nameof(LevelUps));
            };

            WoWEventHandler.Instance.OnDeath += (sender, args) =>
            {
                Deaths++;
                OnPropertyChanged(nameof(Deaths));
            };

            WoWEventHandler.Instance.OnDisconnect += (sender, args) =>
            {
                Disconnects++;
                OnPropertyChanged(nameof(Disconnects));
            };

            WoWEventHandler.Instance.OnDuelRequest += (sender, args) =>
            {
                var req = new DuelRequest(args.Player);
                _duelRequests.Add(req);
                OnPropertyChanged(nameof(DuelRequests));
                OnPropertyChanged(nameof(DuelRequestsCount));
            };

            WoWEventHandler.Instance.OnGuildInvite += (sender, args) =>
            {
                var invite = new GuildInvite(args.Player, args.Guild);
                _guildInvites.Add(invite);
                OnPropertyChanged(nameof(GuildInvites));
                OnPropertyChanged(nameof(GuildInvitesCount));
            };

            WoWEventHandler.Instance.OnUnitKilled += (sender, args) =>
            {
                UnitsKilled++;
                OnPropertyChanged(nameof(UnitsKilled));
            };

            WoWEventHandler.Instance.OnLoot += (sender, args) =>
            {
                var loot = new Loot(args.ItemName, args.ItemId, args.Count);
                _lootList.Add(loot);
                OnPropertyChanged(nameof(LootList));
                OnPropertyChanged(nameof(LootListCount));
            };

            WoWEventHandler.Instance.OnPartyInvite += (sender, args) =>
            {
                var party = new PartyInvite(args.Player);
                _partyInvites.Add(party);
                OnPropertyChanged(nameof(PartyInvites));
                OnPropertyChanged(nameof(PartyInvitesCount));
            };

            _runningTimer = new Timer(1000 * 5)
            {
                AutoReset = true
            };
            _runningTimer.Elapsed += (sender, args) =>
            {
                OnPropertyChanged(nameof(RunningSince));
                var player = ObjectManager.Instance.Player;
                if (player == null)
                {
                    return;
                }
                ToonName = player.Name;
                var money = player.Money;
                if (_startCopperCount == null)
                {
                    _startCopperCount = money;
                }
                CopperGained = money - _startCopperCount.Value;
            };
            _runningTimer.Start();

            WoWEventHandler.Instance.OnTradeShow += (sender, args) =>
            {
                TradeRequests++;
                OnPropertyChanged(nameof(TradeRequests));
            };
        }
Ejemplo n.º 24
0
        private void RestoreToSingleTicket()
        {
            // Need to check for locks on any of the settings in the source list
            if (listboxSourceTicket.Items.Cast <FormattedListBoxItem>()
                .Where(item => item.Id != OriginalTicket.PrimaryKey.Id)
                .Any(item => PosHelper.IsLocked(TableName.Ticket, item.Id)))
            {
                PosDialogWindow.ShowDialog(
                    Types.Strings.OneOrMoreOfTheTicketsInThisPartyIsCurrentlyBeingModifiedSomewhereElseCanNotChangeToSingleTicket, Types.Strings.TicketLocked);
                return;
            }

            // Move TicketItems
            IEnumerable <Ticket> tickets = TicketManager.GetPartyTickets(ParentTicket.PartyId);

            foreach (Ticket ticket in tickets)
            {
                if (ticket.PrimaryKey.Equals(ParentTicket.PrimaryKey) ||
                    ticket.IsClosed || ticket.IsCanceled)
                {
                    continue;
                }
                // Move all ticket items that are not on the ParentTicket, back to
                // the ParentTicket
#if DEMO
                int ticketItemCount = ParentTicket.GetNumberOfTicketItems() +
                                      ticket.GetNumberOfTicketItems();
                if (ticketItemCount > 3)
                {
                    PosDialogWindow.ShowDialog(Window.GetWindow(this),
                                               Types.Strings.YouCanNotAddMoreThan3TicketItemsToASingleTicketInTheDemoVersionAdditionalTicketItemsWillBeRemoved,
                                               Types.Strings.DemoRestriction);
                }
#endif
                IEnumerable <TicketItem> ticketItems = TicketItem.GetAll(ticket.PrimaryKey);
                foreach (TicketItem ticketItem in ticketItems)
                {
#if DEMO
                    if (ParentTicket.GetNumberOfTicketItems() >= 3)
                    {
                        ticketItem.Delete();
                        continue;
                    }
#endif
                    ticketItem.SetTicketId(ParentTicket.PrimaryKey.Id);
                    ticketItem.UpdateTicketId();
                }

                // Delete the child ticket
                TicketManager.Delete(ticket.PrimaryKey);
            }

            // Delete Party Invites
            IEnumerable <PartyInvite> invites = PartyInvite.GetAll(ParentTicket.PartyId);
            foreach (PartyInvite invite in invites)
            {
                PartyInvite.Delete(invite.Id);
            }

            // Delete the party
            Party.Delete(ParentTicket.PartyId);
            ParentTicket.SetPartyId(0);
            ParentTicket.Update();
            CurrentTicket = OriginalTicket = ParentTicket;

            // Done, Close the parent window
            Window.GetWindow(this).Close();
        }
Ejemplo n.º 25
0
 public void RegisterPartyInviteHandler()
 {
     _partyInviteHandler = new PartyInvite(_steamGameCoordinator);
     _dotaManager.AddCacheHandler(CacheSubscritionTypes.Partyinvite, _partyInviteHandler.HandleInvite);
 }
 public PartyInviteNotificationMessage(PartyInvite partyInvite) : base(MessageType.PartyInviteNotification)
 {
     PartyInvite = partyInvite;
 }
Ejemplo n.º 27
0
 public void AcceptInvite(PartyInvite invite)
 {
     JoinParty(invite.Citizen, invite.Party);
     partyRepository.SaveChanges();
 }