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); } }
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); }
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)); }
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); }
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)); } } }
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); } }
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)); }
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)); }
public List <IDeckData> GetFractionDeck(string fraction) => Decks.Where(x => x.Fraction == fraction).ToList();
public IEnumerable <Deck> GetDecksForUser(string UserId) { return(Decks.Where(d => d.UserId == UserId)); }