Beispiel #1
0
        private void OnUnSelectAttackRoute(UserParty party)
        {
            var target    = AttackParties.SingleOrDefault(x => x.Id == party.Id);
            var userParty = UserParties.SingleOrDefault(x => x.Party.Value.Id == party.Id);

            //凸ルート編成後にユーザーパーティを消す場合があるので必ずチェックする
            if (userParty != null)
            {
                userParty.IsSelectedRoute.Value = false;
            }
            if (userParty == null)
            {
                var result = MessageBox.Show("マイパーティ一覧から既にこの編成が消えています。\nこの編成をマイパーティに追加して凸ルートから削除しますか?", "警告",
                                             MessageBoxButton.YesNoCancel);
                if (result == MessageBoxResult.Yes)
                {
                    var newParty = new UserParty(party.UserUnits, party.Comment, party.EstimateDamage);
                    Database.I.AddParty(newParty);
                }
                else if (result == MessageBoxResult.Cancel)
                {
                    return;
                }
            }
            AttackParties.Remove(target);
            CheckDoubling();
        }
Beispiel #2
0
        private void OnAddUserParty(UserParty party)
        {
            UserParties.Add(new PartyListElementViewModel(party, OnSelectAttackRoute));
            var parties = UserParties.ToArray();

            UserParties.Clear();
            UserParties.AddRange(parties.OrderByDescending(x => x.Party.Value.CreateTime));
        }
Beispiel #3
0
        private void OnRemoveUserParty(UserParty party)
        {
            var userPartyIndex = UserParties.ToList().FindIndex(x => x.Id == party.Id);

            if (userPartyIndex >= 0)
            {
                UserParties.RemoveAt(userPartyIndex);
            }
        }
Beispiel #4
0
        protected override bool ExecuteRemoveParty(Party partyToRemove, bool isUser)
        {
            if (isUser)
            {
                return(UserParties.Remove(partyToRemove));
            }

            return(BotParties.Remove(partyToRemove));
        }
Beispiel #5
0
        public override void DeleteAll()
        {
            base.DeleteAll();

            AggregationParties.Clear();
            UserParties.Clear();
            BotParties.Clear();
            PendingRequests.Clear();
            ConnectedParties.Clear();
        }
Beispiel #6
0
        public virtual void DeleteAll()
        {
            AggregationParties.Clear();
            UserParties.Clear();
            BotParties.Clear();
            PendingRequests.Clear();
            ConnectedParties.Clear();
#if DEBUG
            LastMessageRouterResults.Clear();
#endif
        }
Beispiel #7
0
        protected override bool ExecuteAddParty(Party partyToAdd, bool isUser)
        {
            if (isUser)
            {
                UserParties.Add(partyToAdd);
            }
            else
            {
                BotParties.Add(partyToAdd);
            }

            return(true);
        }
 public void SaveParty(UserParty party)
 {
     if (UserParties.Contains(party))
     {
         var index = UserParties.FindIndex(x => x.Id == party.Id);
         UserParties[index] = party;
         OnChangeUserParty?.Invoke(party);
         FileManager.I.SaveJson(UserParties.ToArray());
     }
     else
     {
         AddParty(party);
     }
 }
Beispiel #9
0
        public virtual Party FindPartyByChannelAccountIdAndConversationId(string channelAccountId, string conversationId)
        {
            Party userParty = null;

            try
            {
                userParty = UserParties.Single(party =>
                                               (party.ChannelAccount.Id.Equals(channelAccountId) &&
                                                party.ConversationAccount.Id.Equals(conversationId)));
            }
            catch (InvalidOperationException)
            {
            }

            return(userParty);
        }
Beispiel #10
0
        public virtual Party FindExistingUserParty(Party partyToFind)
        {
            Party foundParty = null;

            try
            {
                foundParty = UserParties.First(party => partyToFind.Equals(party));
            }
            catch (ArgumentNullException)
            {
            }
            catch (InvalidOperationException)
            {
            }

            return(foundParty);
        }
Beispiel #11
0
        private void OnChangeUserParty(UserParty party)
        {
            var userPartyIndex = UserParties.ToList().FindIndex(x => x.Id == party.Id);

            if (userPartyIndex >= 0)
            {
                UserParties[userPartyIndex].UpdateParty(party);;
                var parties = UserParties.ToArray();
                UserParties.Clear();
                UserParties.AddRange(parties.OrderByDescending(x => x.Party.Value.CreateTime));
            }

            var attackRouteIndex = AttackParties.ToList().FindIndex(x => x.Id == party.Id);

            if (attackRouteIndex >= 0)
            {
                AttackParties[attackRouteIndex].UpdateParty(party);
                CheckDoubling();
            }
        }
Beispiel #12
0
        public virtual IList <Party> FindPartiesWithMatchingChannelAccount(Party partyToFind, IList <Party> parties)
        {
            IList <Party>       matchingParties = null;
            IEnumerable <Party> foundParties    = null;

            try
            {
                foundParties = UserParties.Where(party => party.HasMatchingChannelInformation(partyToFind));
            }
            catch (ArgumentNullException)
            {
            }
            catch (InvalidOperationException)
            {
            }

            if (foundParties != null)
            {
                matchingParties = foundParties.ToArray();
            }

            return(matchingParties);
        }
Beispiel #13
0
        public virtual bool AddParty(Party newParty, bool isUser = true)
        {
            if (newParty == null || (isUser ? UserParties.Contains(newParty) : BotParties.Contains(newParty)))
            {
                return(false);
            }

            if (isUser)
            {
                UserParties.Add(newParty);
            }
            else
            {
                if (newParty.ChannelAccount == null)
                {
                    throw new NullReferenceException($"Channel account of a bot party ({nameof(newParty.ChannelAccount)}) cannot be null");
                }

                BotParties.Add(newParty);
            }

            return(true);
        }
 public virtual void DeleteAll()
 {
     UserParties.Clear();
     BotParties.Clear();
 }
Beispiel #15
0
 public void RemoveParty(UserParty party)
 {
     UserParties.Remove(party);
     OnRemoveUserParty?.Invoke(party);
     FileManager.I.SaveJson(UserParties.ToArray());
 }
Beispiel #16
0
 public void AddParty(UserParty party)
 {
     UserParties.Add(party);
     OnAddUserParty?.Invoke(party);
     FileManager.I.SaveJson(UserParties.ToArray());
 }