private DeckState GetDeckState()
        {
            var createdCardsInDeck =
                Deck.Where(x => x.HasCardId && (x.Info.Created || x.Info.Stolen) && !x.Info.Hidden)
                .GroupBy(ce => new { ce.CardId, Created = (ce.Info.Created || ce.Info.Stolen), ce.Info.Discarded })
                .Select(g =>
            {
                var card             = Database.GetCardFromId(g.Key.CardId);
                card.Count           = g.Count();
                card.IsCreated       = g.Key.Created;
                card.HighlightInHand = Hand.Any(ce => ce.CardId == g.Key.CardId);
                return(card);
            });
            var originalCardsInDeck = DeckList.Instance.ActiveDeckVersion.Cards
                                      .Where(x => x.Count > 0)
                                      .Select(x => Enumerable.Repeat(x.Id, x.Count))
                                      .SelectMany(x => x).ToList();
            var revealedNotInDeck = RevealedEntities.Where(x => (!x.Info.Created || x.Info.OriginalEntityWasCreated == false) &&
                                                           x.IsPlayableCard &&
                                                           (!x.IsInDeck || x.Info.Stolen) &&
                                                           x.Info.OriginalController == Id &&
                                                           !(x.Info.Hidden && (x.IsInDeck || x.IsInHand))).ToList();
            var removedFromDeck = new List <string>();

            foreach (var e in revealedNotInDeck)
            {
                originalCardsInDeck.Remove(e.CardId);
                if (!e.Info.Stolen || e.Info.OriginalController == Id)
                {
                    removedFromDeck.Add(e.CardId);
                }
            }
            return(new DeckState(createdCardsInDeck.Concat(originalCardsInDeck.GroupBy(x => x).Select(x =>
            {
                var card = Database.GetCardFromId(x.Key);
                card.Count = x.Count();
                if (Hand.Any(e => e.CardId == x.Key))
                {
                    card.HighlightInHand = true;
                }
                return card;
            })), removedFromDeck.GroupBy(x => x).Select(c =>
            {
                var card = Database.GetCardFromId(c.Key);
                card.Count = 0;
                if (Hand.Any(e => e.CardId == c.Key))
                {
                    card.HighlightInHand = true;
                }
                return card;
            })));
        }
Beispiel #2
0
 public void JoustReveal(Entity entity, int turn)
 {
     if (Deck.Where(ce => ce.InDeck).All(ce => ce.CardId != entity.CardId))
     {
         RevealDeckCard(entity.CardId, turn);
         var ce = new CardEntity(entity.CardId, null)
         {
             Turn = turn
         };
         RevealedCards.Add(ce);
         Log("JoustReveal", ce);
     }
 }