예제 #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);
        }
예제 #2
0
        public JeoCategory <JeoQuestion> RandomCat(RoundType type, bool hasDouble, bool hasAVL)
        {
            JeoCategory <JeoQuestion> retCat = new JeoCategory <JeoQuestion>();

            if (!hasAVL)
            {
                //loop the find category logic until a category with an audio/visual/link quesiton is found
                do
                {
                    retCat = new JeoCategory <JeoQuestion>();
                    retCat = Categories[rando.Next(Categories.Count)];
                    //find new random category until parameters (correct round and/or presence of audio/visual/link questions) are met
                    //also verify if category has enough questions to fill a standard round (IsFull property)
                    if (type == RoundType.First)
                    {
                        if (hasDouble)
                        {
                            while (!retCat.HasDouble || !retCat.HasFirst || !retCat.IsFull)
                            {
                                retCat = new JeoCategory <JeoQuestion>();
                                retCat = Categories[rando.Next(Categories.Count)];
                            }
                        }
                        else
                        {
                            while (retCat.HasDouble || !retCat.HasFirst || !retCat.IsFull)
                            {
                                retCat = new JeoCategory <JeoQuestion>();
                                retCat = Categories[rando.Next(Categories.Count)];
                            }
                        }
                    }
                    else if (type == RoundType.Second)
                    {
                        if (hasDouble)
                        {
                            while (!retCat.HasDouble || !retCat.HasSecond || !retCat.IsFull)
                            {
                                retCat = new JeoCategory <JeoQuestion>();
                                retCat = Categories[rando.Next(Categories.Count)];
                            }
                        }
                        else
                        {
                            while (retCat.HasDouble || !retCat.HasSecond || !retCat.IsFull)
                            {
                                retCat = new JeoCategory <JeoQuestion>();
                                retCat = Categories[rando.Next(Categories.Count)];
                            }
                        }
                    }
                    else if (type == RoundType.Final)
                    {
                        {
                            if (hasDouble)
                            {
                                while (!retCat.HasDouble || !retCat.HasFinal || !retCat.IsFull)
                                {
                                    retCat = new JeoCategory <JeoQuestion>();
                                    retCat = Categories[rando.Next(Categories.Count)];
                                }
                            }
                            else
                            {
                                while (retCat.HasDouble || !retCat.HasFinal || !retCat.IsFull)
                                {
                                    retCat = new JeoCategory <JeoQuestion>();
                                    retCat = Categories[rando.Next(Categories.Count)];
                                }
                            }
                        }
                    }
                } while (retCat.HasAVL);
            }
            else
            {
                //find new random category until parameters (correct round and/or presence of audio/visual/link questions) are met
                //also verify if category has enough questions to fill a standard round (IsFull property)
                if (type == RoundType.First)
                {
                    if (hasDouble)
                    {
                        while (!retCat.HasDouble || !retCat.HasFirst || !retCat.IsFull)
                        {
                            retCat = new JeoCategory <JeoQuestion>();
                            retCat = Categories[rando.Next(Categories.Count)];
                        }
                    }
                    else
                    {
                        while (retCat.HasDouble || !retCat.HasFirst || !retCat.IsFull)
                        {
                            retCat = new JeoCategory <JeoQuestion>();
                            retCat = Categories[rando.Next(Categories.Count)];
                        }
                    }
                }
                else if (type == RoundType.Second)
                {
                    if (hasDouble)
                    {
                        while (!retCat.HasDouble || !retCat.HasSecond || !retCat.IsFull)
                        {
                            retCat = new JeoCategory <JeoQuestion>();
                            retCat = Categories[rando.Next(Categories.Count)];
                        }
                    }
                    else
                    {
                        while (retCat.HasDouble || !retCat.HasSecond || !retCat.IsFull)
                        {
                            retCat = new JeoCategory <JeoQuestion>();
                            retCat = Categories[rando.Next(Categories.Count)];
                        }
                    }
                }
                else if (type == RoundType.Final)
                {
                    if (hasDouble)
                    {
                        while (!retCat.HasDouble || !retCat.HasFinal || !retCat.IsFull)
                        {
                            retCat = new JeoCategory <JeoQuestion>();
                            retCat = Categories[rando.Next(Categories.Count)];
                        }
                    }
                    else
                    {
                        while (retCat.HasDouble || !retCat.HasFinal || !retCat.IsFull)
                        {
                            retCat = new JeoCategory <JeoQuestion>();
                            retCat = Categories[rando.Next(Categories.Count)];
                        }
                    }
                }
            }

            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);
        }