private void RefreshAvailableDecks()
 {
     if (AvailableDecks.Count == 0)
     {
         for (var i = 1; i <= 9; i++)
         {
             var key   = i.ToString(CultureInfo.InvariantCulture);
             var model = new AvailableDecksModel
             {
                 Slot           = key,
                 AvailableDecks =
                     new BindableCollection <DeckModel>(Decks.Where(x => x.Key == key || String.IsNullOrEmpty(x.Key))),
                 SelectedDeck = Decks.FirstOrDefault(x => x.Key == key)
             };
             model.PropertyChanged += AvailableDecksModel_OnPropertyChanged;
             AvailableDecks.Add(model);
         }
         NotifyOfPropertyChange(() => AvailableDecks);
     }
     else
     {
         for (var i = 1; i <= 9; i++)
         {
             var key = i.ToString(CultureInfo.InvariantCulture);
             AvailableDecks[i - 1].AvailableDecks =
                 new BindableCollection <DeckModel>(Decks.Where(x => x.Key == key || String.IsNullOrEmpty(x.Key)));
             AvailableDecks[i - 1].PropertyChanged -= AvailableDecksModel_OnPropertyChanged;
             AvailableDecks[i - 1].SelectedDeck     = Decks.FirstOrDefault(x => x.Key == key);
             AvailableDecks[i - 1].PropertyChanged += AvailableDecksModel_OnPropertyChanged;
         }
         NotifyOfPropertyChange(() => AvailableDecks);
     }
 }
示例#2
0
 public bool UserOwnsFlashcard(string UserId, int FlashcardId)
 {
     //User owns Deck && Deck has Flashcard
     if (Decks.Where(d => Flashcards.FirstOrDefault(f => f.Id == FlashcardId).DeckId == d.Id && UserId == d.UserId).Count() > 0)
     {
         return(true);
     }
     return(false);
 }
示例#3
0
        internal async void StartGame()
        {
            List <string> decks = Decks.Where(c => c.IsSelected).Select(c => c.Text).ToList();

            settings.SavePreferredDecks(decks);
            var gid = await CardsAgainstHumility.Add(CardsAgainstHumility.NewId(), GameName, decks, MaxPlayers, MaxScore);

            await CardsAgainstHumility.JoinGame(gid);

            navService.Navigate(new Uri("/GamePage.xaml", UriKind.Relative));
        }
示例#4
0
        public double GetValue(SourceEnum?source = null)
        {
            int wildCount = source == null
                                ? Decks.Where(x => x.Key.DeckType != DeckType.Standard).GroupBy(x => x.Key.DuplicateIndicatior).Count()
                                : Decks.Count(x => x.Key.Source == source.Value && x.Key.DeckType != DeckType.Standard);

            double wildReduceFactor = 1 - wildCount / (GetInDecks(source) * 2.0);

            return(source == null
                       ? Card.ValuationFactor * (6 - GetTier()) * GetApperences() * wildReduceFactor
                       : GetInDecks(source) != 0 ? Card.ValuationFactor * (6 - GetTier(source)) * GetApperences(source) * wildReduceFactor : 0);
        }
示例#5
0
        public static void LoadCards()
        {
            foreach (CardDeck deck in Decks.Where(deck => deck.Include))
            {
                foreach (string value in deck.BlackCards)
                {
                    Cards.Add(new CardInfo(CardType.Black, value));
                }

                foreach (string value in deck.WhiteCards)
                {
                    Cards.Add(new CardInfo(CardType.White, value));
                }
            }
        }
示例#6
0
 public override bool Equals(Object obj)
 {
     //Check for null and compare run-time types.
     if ((obj == null) || !this.GetType().Equals(obj.GetType()))
     {
         return(false);
     }
     else
     {
         GameState other = (GameState)obj;
         if (IsAwaitingSubgameWinner != other.IsAwaitingSubgameWinner)
         {
             return(false);
         }
         if (Decks.Count != other.Decks.Count)
         {
             return(false);
         }
         var areEqual = !Decks.Where(deck => !other.Decks.Contains(deck)).Any();
         return(areEqual);
     }
 }
示例#7
0
 public double GetTier(SourceEnum?source = null)
 {
     return(source == null
                ? Decks.GroupBy(x => x.Key.DuplicateIndicatior).Sum(x => x.Average(y => y.Key.Tier)) / GetInDecks()
                : Decks.Where(x => x.Key.Source == source.Value).Sum(x => x.Key.Tier) / (double)GetInDecks(source));
 }
示例#8
0
 public double GetApperences(SourceEnum?source = null)
 {
     return(source == null
                ? Decks.GroupBy(x => x.Key.DuplicateIndicatior).Sum(x => x.Average(y => y.Value))
                : Decks.Where(x => x.Key.Source == source.Value).Sum(x => x.Value));
 }
示例#9
0
 public List <IDeckData> GetFractionDeck(string fraction) =>
 Decks.Where(x => x.Fraction == fraction).ToList();
示例#10
0
 public IEnumerable <Deck> GetDecksForUser(string UserId)
 {
     return(Decks.Where(d => d.UserId == UserId));
 }