Beispiel #1
0
        public JeoCategory <JeoQuestion> TestCat(RoundType type, bool hasDouble, bool hasAVL)
        {
            JeoCategory <JeoQuestion> retCat = new JeoCategory <JeoQuestion>();

            retCat = CatByName("HOUSES OF THE HOLY");

            if (retCat.Count > 5 && type == RoundType.First)
            {
                JeoCategory <JeoQuestion> newCat = new JeoCategory <JeoQuestion>();
                newCat.CatName   = retCat.CatName;
                newCat.HasFirst  = retCat.HasFirst;
                newCat.HasDouble = retCat.HasDouble;
                newCat.HasFinal  = retCat.HasFinal;
                newCat.HasAVL    = retCat.HasAVL;
                newCat.IsFull    = retCat.IsFull;
                newCat.Clear();

                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 200 && x.Round == RoundType.First));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 400 && x.Round == RoundType.First));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 600 && x.Round == RoundType.First));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 800 && x.Round == RoundType.First));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 1000 && x.Round == RoundType.First));

                //if method call has a daily double, randomly replace one of the questions with it
                //todo: replace the value that the daily double was originally at. not possible?
                if (hasDouble)
                {
                    newCat[rando.Next(4)] = retCat.Find(x => x.Type == QType.Double);
                }

                retCat = newCat;
            }
            if (retCat.Count > 5 && type == RoundType.Second)
            {
                JeoCategory <JeoQuestion> newCat = new JeoCategory <JeoQuestion>();
                newCat.CatName   = retCat.CatName;
                newCat.HasFirst  = retCat.HasFirst;
                newCat.HasDouble = retCat.HasDouble;
                newCat.HasFinal  = retCat.HasFinal;
                newCat.HasAVL    = retCat.HasAVL;
                newCat.IsFull    = retCat.IsFull;
                newCat.Clear();

                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 400 && x.Round == RoundType.Second));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 800 && x.Round == RoundType.Second));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 1200 && x.Round == RoundType.Second));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 1600 && x.Round == RoundType.Second));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 2000 && x.Round == RoundType.Second));

                //if method call has a daily double, randomly replace one of the questions with it
                //todo: replace the value that the daily double was originally at. not possible?
                if (hasDouble)
                {
                    newCat[rando.Next(4)] = retCat.Find(x => x.Type == QType.Double);
                }

                retCat = newCat;
            }

            return(retCat);
        }
Beispiel #2
0
        //return random category of specified RoundType. Alternate definition allows preference for Audio/Visual/Link quesitons
        //and/or daily doubles
        //todo: add a definition that respects AVL, but does not check hasDouble. How to do without duplicate method signatures?
        public JeoCategory <JeoQuestion> RandomCat(RoundType type)
        {
            JeoCategory <JeoQuestion> retCat = new JeoCategory <JeoQuestion>();

            retCat = Categories[rando.Next(Categories.Count)];

            //find new random category until parameters correct round type is found
            //also verify if category has enough questions to fill a standard round (IsFull property)
            if (type == RoundType.First)
            {
                while (!retCat.HasFirst || !retCat.IsFull)
                {
                    retCat = Categories[rando.Next(Categories.Count)];
                }
            }
            else if (type == RoundType.Second)
            {
                while (!retCat.HasSecond || !retCat.IsFull)
                {
                    retCat = Categories[rando.Next(Categories.Count)];
                }
            }
            else if (type == RoundType.Final)
            {
                while (!retCat.HasFinal || !retCat.IsFull)
                {
                    retCat = Categories[rando.Next(Categories.Count)];
                }
            }

            //if there are more than 5 questions in a category, randomly select one each of the correct value
            if (retCat.Count > 5 && type == RoundType.First)
            {
                JeoCategory <JeoQuestion> newCat = new JeoCategory <JeoQuestion>();

                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 200 && x.Round == RoundType.First));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 400 && x.Round == RoundType.First));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 600 && x.Round == RoundType.First));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 800 && x.Round == RoundType.First));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 1000 && x.Round == RoundType.First));

                retCat = newCat;
            }
            if (retCat.Count > 5 && type == RoundType.Second)
            {
                JeoCategory <JeoQuestion> newCat = new JeoCategory <JeoQuestion>();

                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 400 && x.Round == RoundType.Second));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 800 && x.Round == RoundType.Second));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 1200 && x.Round == RoundType.Second));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 1600 && x.Round == RoundType.Second));
                retCat.OrderBy(x => rando.Next()).FirstOrDefault();
                newCat.Add(retCat.Find(x => x.Value == 2000 && x.Round == RoundType.Second));

                retCat = newCat;
            }

            return(retCat);
        }