Ejemplo n.º 1
0
        public bool StartGame()
        {
            game = BuildGame();

            mainView     = BuildMain(RoundType.First);
            currentRound = RoundType.First;
            mainView.ShowDialog();

            if (!exit && !newGame)
            {
                mainView     = BuildMain(RoundType.Second);
                currentRound = RoundType.Second;
                mainView.ShowDialog();
            }
            if (!exit && !newGame)
            {
                if (game.Cash > 0)
                {
                    currentQ     = game.FinalQuestion;
                    mainView     = BuildFinal();
                    currentRound = RoundType.Final;
                    mainView.ShowDialog();
                }
                else
                {
                    didFinal = false;
                }
            }
            if (!exit && !newGame)
            {
                mainView = BuildFinished();
                mainView.ShowDialog();
            }
            return(exit);
        }
Ejemplo n.º 2
0
        //returns a random Final Jeopardy question
        public JeoQuestion GetFinal()
        {
            bool        found = false;
            JeoQuestion retQ  = new JeoQuestion();

            do
            {
                JeoCategory <JeoQuestion> checkCat = Categories[rando.Next(Categories.Count)];
                if (checkCat.HasFinal)
                {
                    found = true;
                    List <JeoQuestion> finalReg = new List <JeoQuestion>();

                    //register any questions with QType of final, and return a random one
                    foreach (JeoQuestion q in checkCat)
                    {
                        if (q.Type == QType.Final)
                        {
                            finalReg.Add(q);
                        }
                    }
                    retQ = finalReg[rando.Next(finalReg.Count)];
                }
            } while (!found);

            return(retQ);
        }
Ejemplo n.º 3
0
 public JeoButton(JeoQuestion q)
 {
     Question = q;
 }
Ejemplo n.º 4
0
        private void QChosen(object e, EventArgs args)
        {
            viewPanel.Hide();
            JeoButton btn = (JeoButton)e;

            btn.Text     = "";
            btn.Click   -= QChosen;
            btn.Answered = true;
            currentQ     = btn.Question;

            if (currentQ.Type == QType.Standard)
            {
                Form view = new Form();
                view.FormBorderStyle = FormBorderStyle.None;
                view.BackColor       = Color.LightGray;
                view.Size            = new Size(Screen.PrimaryScreen.WorkingArea.Width, (70 * 3));
                TableLayoutPanel parent = new TableLayoutPanel();
                parent.Dock        = DockStyle.Fill;
                parent.RowCount    = 3;
                parent.ColumnCount = 2;
                parent.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 140F));
                parent.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
                parent.RowStyles.Add(new RowStyle(SizeType.Absolute, 70));
                parent.RowStyles.Add(new RowStyle(SizeType.Absolute, 70));
                parent.RowStyles.Add(new RowStyle(SizeType.Absolute, 70));

                //create and add category heading button
                Button cat = new Button();
                FormatButton(ref cat);
                cat.Text = btn.Question.Category;
                parent.Controls.Add(cat);
                parent.SetColumnSpan(cat, 2);

                //create and add value display button
                Button val = new Button();
                FormatButton(ref val);
                val.Text = "$" + btn.Question.Value;
                parent.Controls.Add(val);

                //create and add clue display button. Set font to be smaller than default formatting
                Button clu = new Button();
                FormatButton(ref clu);
                clu.Font = new Font("Arial", 15, FontStyle.Bold);
                clu.Text = btn.Question.Clue;
                parent.Controls.Add(clu);

                //create and add submit button
                Button sub = new Button();
                FormatButton(ref sub);
                sub.Text   = "Submit";
                sub.Click += new EventHandler(QSubmited);
                parent.Controls.Add(sub);
                view.AcceptButton = sub;

                //create and add input text field
                input           = new TextBox();
                input.ForeColor = Color.Blue;
                input.BackColor = Color.Yellow;
                input.Font      = new Font("Arial", 20, FontStyle.Bold);
                input.Multiline = true;
                input.Dock      = DockStyle.Fill;
                input.TextAlign = HorizontalAlignment.Center;
                parent.Controls.Add(input);

                view.Controls.Add(parent);
                view.ActiveControl = input;
                view.ShowDialog();
            }
            else if (currentQ.Type == QType.Double)
            {
                Form view = new Form();
                view.Size            = new Size(Screen.PrimaryScreen.WorkingArea.Width, (70 * 4));
                view.BackColor       = Color.LightGray;
                view.FormBorderStyle = FormBorderStyle.None;
                TableLayoutPanel parent = new TableLayoutPanel();
                parent.Dock        = DockStyle.Fill;
                parent.RowCount    = 4;
                parent.ColumnCount = 2;
                parent.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 240F));
                parent.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
                parent.RowStyles.Add(new RowStyle(SizeType.Absolute, 70));
                parent.RowStyles.Add(new RowStyle(SizeType.Absolute, 70));
                parent.RowStyles.Add(new RowStyle(SizeType.Absolute, 70));
                parent.RowStyles.Add(new RowStyle(SizeType.Absolute, 70));

                //create and add category heading button
                Button cat = new Button();
                FormatButton(ref cat);
                cat.Text = btn.Question.Category;
                parent.Controls.Add(cat);
                parent.SetColumnSpan(cat, 2);

                //create and add value display button
                Button val = new Button();
                FormatButton(ref val);
                val.Text = "Daily Double!";
                parent.Controls.Add(val);

                //create and add clue display button. Set font to be smaller than default formatting
                Button clu = new Button();
                FormatButton(ref clu);
                clu.Font = new Font("Arial", 15, FontStyle.Bold);
                clu.Text = btn.Question.Clue;
                parent.Controls.Add(clu);

                //create and add bid button
                Button bidLabel = new Button();
                FormatButton(ref bidLabel);
                bidLabel.Font = new Font("Arial", 15, FontStyle.Bold);
                if (currentQ.Round == RoundType.First)
                {
                    ddMinMax = 1000;
                }
                if (currentQ.Round == RoundType.Second)
                {
                    ddMinMax = 2000;
                }
                bidLabel.Text = "Your Bid (Maximum $" + Math.Max(ddMinMax, game.Cash) + ")";
                parent.Controls.Add(bidLabel);

                //create and add bid text field
                bid           = new TextBox();
                bid.ForeColor = Color.Blue;
                bid.BackColor = Color.Yellow;
                bid.Font      = new Font("Arial", 20, FontStyle.Bold);
                bid.Multiline = true;
                bid.Dock      = DockStyle.Fill;
                bid.TextAlign = HorizontalAlignment.Center;
                parent.Controls.Add(bid);

                //create and add submit button
                Button sub = new Button();
                FormatButton(ref sub);
                sub.Text   = "Submit";
                sub.Click += new EventHandler(QSubmited);
                parent.Controls.Add(sub);
                view.AcceptButton = sub;

                //create and add input text field
                input           = new TextBox();
                input.ForeColor = Color.Blue;
                input.BackColor = Color.Yellow;
                input.Font      = new Font("Arial", 20, FontStyle.Bold);
                input.Multiline = true;
                input.Dock      = DockStyle.Fill;
                input.TextAlign = HorizontalAlignment.Center;
                parent.Controls.Add(input);

                view.Controls.Add(parent);
                view.ActiveControl = bid;
                view.ShowDialog();
            }
        }
Ejemplo n.º 5
0
        public JeoModel()
        {
            bool oldCat = false;

            using (StreamReader sr = new StreamReader(DBPATH))
            {
                string  json = sr.ReadToEnd();
                JObject db   = JObject.Parse(json);

                //iterate through each category
                int totalCount = 0;
                foreach (JProperty category in db.Properties())
                {
                    JeoCategory <JeoQuestion> catList = new JeoCategory <JeoQuestion>();
                    catList.CatName = category.Name.ToString().ToUpper();
                    oldCat          = false;
                    //iterate through each question within each category
                    foreach (JToken question in category)
                    {
                        //keeps track of how many questions in the category will fit into a standard round
                        int qCount = 0;

                        //create a JeoQuestion based on the entries in each quesiton
                        foreach (JToken entry in question.Children())
                        {
                            ++totalCount;
                            string clue   = entry["clue"].ToString();
                            string answer = entry["answer"].ToString();
                            string cat    = category.Name.ToString().ToUpper();

                            //check if the value has a dollar amount, else determine what kind of question it is
                            QType  type  = QType.Standard;
                            string value = entry["value"].ToString();
                            if (int.TryParse(value, out int val))
                            {
                                ;
                            }
                            else
                            {
                                if (value.Contains("Final"))
                                {
                                    type = QType.Final;
                                }
                                else if (value.Contains("Double"))
                                {
                                    type = QType.Double;
                                }
                                else
                                {
                                    type = QType.Special;
                                }
                            }

                            //determine and assign which round the question is from
                            string    roundStr = entry["round"].ToString();
                            RoundType round    = RoundType.Special;
                            if (int.TryParse(roundStr, out int roun))
                            {
                                if (roun == 1)
                                {
                                    round            = RoundType.First;
                                    catList.HasFirst = true;
                                }
                                if (roun == 2)
                                {
                                    round             = RoundType.Second;
                                    catList.HasSecond = true;
                                }
                            }
                            else
                            {
                                round = RoundType.Final;
                            }

                            //create the JeoQuestion object and check for special flags
                            JeoQuestion addQ = new JeoQuestion(cat, clue, answer, val, round, type);
                            if (clue.ToUpper().Contains("AUDIO DAILY DOUBLE"))
                            {
                                addQ.IsAudio = true;
                            }
                            if (clue.ToUpper().Contains("VIDEO DAILY DOUBLE"))
                            {
                                addQ.IsVideo = true;
                            }
                            if (clue.ToUpper().Contains("A HREF"))
                            {
                                addQ.HasLink = true;
                            }

                            //update category based on flags
                            if (addQ.IsAudio || addQ.IsVideo || addQ.HasLink)
                            {
                                catList.HasAVL = true;
                            }
                            if (addQ.Type == QType.Double)
                            {
                                catList.HasDouble = true;
                            }
                            if (addQ.Type == QType.Final)
                            {
                                catList.HasFinal = true;
                            }
                            if (addQ.Type == QType.Standard || addQ.Type == QType.Double)
                            {
                                ++qCount;
                            }

                            //jeopardy questions used to be worth half as much; for consistency, update older values to newer standard
                            if ((addQ.Round == RoundType.First) && ((addQ.Value % 200F) != 0) && (addQ.Value > 0))
                            {
                                oldCat = true;
                            }
                            if ((addQ.Round == RoundType.Second) && ((addQ.Value % 400F) != 0) && (addQ.Value > 0))
                            {
                                oldCat = true;
                            }
                            if (oldCat)
                            {
                                addQ.Value = addQ.Value * 2;
                            }
                            catList.Add(addQ);
                        }

                        if (qCount > 4)
                        {
                            catList.IsFull = true;
                        }
                        Categories.Add(catList);
                    }
                }
                sr.Dispose();
            }
        }
Ejemplo n.º 6
0
 public JeoGame(List <JeoCategory <JeoQuestion> > first, List <JeoCategory <JeoQuestion> > second, JeoQuestion final)
 {
     FirstRound = first; SecondRound = second; FinalQuestion = final;
 }