Esempio n. 1
0
        /*Create the Answers list of AnswerCards, which the listview binds to. Generates four AnswerCards, with a Card and Correct properties, indicating if
         * this is the right answer. Each loop checks if the random card from the full list of cards of the deck is the correct choice, from the randomly
         * chosen card in the hand shown in the carousel view (The GetHand method is generalized so each game can use it, making it a little harder to
         * then also generate AnswerCards). Then that card is removed from Cards so there are no duplicates (This means we have to call the DB for a full
         * list of cards each time..). Then finally, checks to see if the actual answer has been one of the randomly selected, if not it adds it in a random
         * Position. Maybe it would be better to add the actual answer first, but it needs to be in a random position, so the Answers list needs to be populated
         * before that.*/
        private void Setup()
        {
            Answers.Clear();
            RandomNumber = Random.Next(0, Cards.Count);
            Cards        = CardDatabase.GetCards();
            var NotYet = true;

            for (var i = 0; i < 4; i++)
            {
                RandomNumber = Random.Next(0, Cards.Count);
                var Card = Cards[RandomNumber];
                if (!Card.Answer.Equals(Hand[index].Answer))
                {
                    Answers.Add(new AnswerCard(Card, false));
                    Cards.Remove(Card);
                }
                else
                {
                    Answers.Add(new AnswerCard(Card, true));
                    Cards.Remove(Card);
                    NotYet = false;
                }
            }

            if (NotYet)
            {
                RandomNumber          = Random.Next(0, Answers.Count);
                Answers[RandomNumber] = new AnswerCard(Hand[index], true);
            }
        }
Esempio n. 2
0
 public MultiChoiceViewModel(Deck Deck)
 {
     this.Deck    = Deck;
     CardDatabase = new CardDB(Deck);
     Cards        = CardDatabase.GetCards();
     GetHand();
     Answers  = new ObservableCollection <AnswerCard>();
     Pick     = new Command(Picked);
     Position = 0;
     index    = 0;
     Setup();
 }
Esempio n. 3
0
        public EditCardsViewModel(Deck deck)
        {
            this.Deck    = deck;
            CardDatabase = new CardDB(deck);

            Add  = new Command(AddCard);
            Done = new Command(DoneEdit);
            PageDisappearingCommand = new Command(PageDisappearing);

            Cards = CardDatabase.GetCards();
            if (Cards.Count == 0)
            {
                EmptyDeck();
            }
        }
Esempio n. 4
0
        public void GetCards()
        {
            ScheduledScore = DeckDatabase.GetScheduled(Deck);
            Cards          = CardDatabase.GetCardsWithScore(0);
            if (Cards.Count < 5)
            {
                Cards = new ObservableCollection <Card>(Cards.Concat(CardDatabase.GetCardsWithScore(ScheduledScore)));
            }
            if (Cards.Count >= 5)
            {
                Cards = new ObservableCollection <Card>(Cards.Take(5));
            }

            var x = CardDatabase.GetCards();

            if (Cards.Count < HandSize)
            {
                FillDeck();
            }
        }