Example #1
0
        /// <summary>
        /// set the text of the socre label
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            sessionCheck();
            Gameboard gb = (Gameboard)Session["Gameboard"];

            lblScore.Text = Session["name"].ToString() + ": $" + gb.currentScore;
        }
Example #2
0
        /// <summary>
        /// Setup the gameboard for the next round and redirect to the appropriate page to begin the next round.
        /// May redirect to EndGame.aspx if the player does not qualify to play final jeopardy
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnContinue_Click(object sender, EventArgs e)
        {
            Gameboard gb     = (Gameboard)Session["Gameboard"];
            bool      result = gb.SetupNextRound();

            Session["Gameboard"] = gb;
            if (result)
            {
                if (gb.currentRound == 2)
                {
                    Response.Redirect("GameBoardUI.aspx");
                }
                else if (gb.currentRound == 3 && gb.currentScore > 0)
                {
                    Response.Redirect("Wager.aspx");
                }
                else
                {
                    Response.Redirect("EndGame.aspx");
                }
            }
            else
            {
                Response.Redirect("Error.aspx");
            }
        }
Example #3
0
        /// <summary>
        /// stop the timer, check the answer, update the score, and show the correct answer and continue button
        /// </summary>
        /// <param name="buttonNum">number of the answer button that was clicked</param>
        private void processAnswerChoice(int buttonNum)
        {
            Timer1.Enabled = false;
            int value = (int)Session["value"];

            Session["value"] = null;

            int correctButtonNum = (int)Session["Correct"];

            Session["Correct"] = null;

            Gameboard gb = (Gameboard)Session["Gameboard"];

            if (buttonNum == correctButtonNum)
            {
                gb.increaseScore(value);
            }
            else
            {
                gb.decreaseScore(value);
            }
            Session["Gameboard"] = gb;
            showCorrect(correctButtonNum);
            btnContinue.Visible = true;
        }
Example #4
0
        private void Cell_Click(object sender, EventArgs e)
        {
            JeopardyButton btn = (JeopardyButton)sender;
            Gameboard      gb  = (Gameboard)Session["Gameboard"];

            gb.getQuestion(btn.category, btn.dollarValue).display = false;
            updateGameboard(gb);
            Session["Gameboard"] = gb;
        }
Example #5
0
        protected void Page_Init(object sender, EventArgs e)
        {
            Gameboard gb;

            if (!IsPostBack)
            {
                gb = new Gameboard();
                Session["Gameboard"] = gb;
            }
            else
            {
                gb = (Gameboard)Session["Gameboard"];
            }
            drawGameboard(gb);
        }
Example #6
0
        /// <summary>
        /// create the ui for the gameboard and initialize the round timer
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Init(object sender, EventArgs e)
        {
            sessionCheck();
            Gameboard gb = (Gameboard)Session["Gameboard"];

            drawGameboard(gb);
            updateGameboard(gb);

            if (Session["RoundEnd"] == null)
            {
                DateTime now = DateTime.Now;
                Session["RoundEnd"] = now.AddMinutes(15);
            }
            updateRoundInfo();
        }
Example #7
0
        private void updateGameboard(Gameboard gb)
        {
            List <JeopardyButton> buttons = (List <JeopardyButton>)Session["GameBoardButtons"];

            foreach (JeopardyButton b in buttons)
            {
                if (gb.getQuestion(b.category, b.dollarValue).display)
                {
                    b.Visible = true;
                }
                else
                {
                    b.Visible = false;
                }
            }
            Session["GameBoardButtons"] = buttons;
        }
Example #8
0
        /// <summary>
        /// update the time remaining in the round and end the round if time has expired
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Timer1_Tick(object sender, EventArgs e)
        {
            Gameboard gb  = (Gameboard)Session["Gameboard"];
            DateTime  end = (DateTime)Session["RoundEnd"];

            if (end.CompareTo(DateTime.Now) > 0)
            {
                //time is remaining
                updateRoundInfo();
            }
            else
            {
                Session["RoundTimeout"] = "";
                Session["RoundEnd"]     = null;
                Response.Redirect("EndOfRound.aspx");
            }
        }
Example #9
0
 /// <summary>
 /// Update high scores with the result of this game, display the high scores, clear session
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         sessionCheck();
         Random        r   = new Random();
         Gameboard     gb  = (Gameboard)Session["Gameboard"];
         HighScoreData hsd = new HighScoreData(gb.currentScore, Session["name"].ToString(), r.Next(100000));
         updateHighScores(hsd);
         List <object> scores = getHighScores();
         if (scores == null)
         {
             Response.Redirect("Error.aspx");
         }
         displayHighScores(scores);
         lblScore.Text = "Your Score: $" + gb.currentScore;
         Session.RemoveAll();
     }
 }
Example #10
0
        /// <summary>
        /// retrieve the question for the clicked cell and redirect to wager or questionui
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Cell_Click(object sender, EventArgs e)
        {
            JeopardyButton btn = (JeopardyButton)sender;
            Gameboard      gb  = (Gameboard)Session["Gameboard"];

            gb.getQuestion(btn.category, btn.dollarValue).display = false;
            Session["Gameboard"] = gb;
            Question q = gb.getQuestion(btn.category, btn.dollarValue);

            Session["Question"] = q;
            if (q.wagerActive)
            {
                Response.Redirect("Wager.aspx");
            }
            else
            {
                Response.Redirect("QuestionUI.aspx");
            }
        }
Example #11
0
        /// <summary>
        /// create and initialize elements of the gameboard display
        /// </summary>
        /// <param name="gb">current gameboard</param>
        private void drawGameboard(Gameboard gb)
        {
            List <JeopardyButton> buttons = new List <JeopardyButton>();
            TableRow Header = new TableRow();

            tblGameboard.Rows.Add(Header);
            foreach (string category in gb.roundCategories)
            {
                TableCell cell = new TableCell();
                cell.ForeColor       = System.Drawing.Color.White;
                cell.HorizontalAlign = HorizontalAlign.Center;
                cell.VerticalAlign   = VerticalAlign.Middle;
                cell.Text            = category;
                cell.CssClass        = "boardHead";
                Header.Cells.Add(cell);
            }
            foreach (int value in gb.values)
            {
                TableRow row = new TableRow();
                tblGameboard.Rows.Add(row);
                foreach (string category in gb.roundCategories)
                {
                    Question  q    = gb.getQuestion(category, value);
                    TableCell cell = new TableCell();

                    cell.CssClass        = "boardCell";
                    cell.HorizontalAlign = HorizontalAlign.Center;
                    cell.VerticalAlign   = VerticalAlign.Middle;
                    JeopardyButton b = new JeopardyButton();
                    b.category    = category;
                    b.dollarValue = value;
                    b.Text        = "$" + value.ToString();
                    cell.Controls.Add(b);
                    b.Click += Cell_Click;
                    buttons.Add(b);
                    b.CssClass = "GameBoardCell";

                    row.Cells.Add(cell);
                }
            }
            Session["GameBoardButtons"] = buttons;
            updateGameInfo();
        }
Example #12
0
        /// <summary>
        /// update the label showing the remaining time and current round
        /// </summary>
        private void updateRoundInfo()
        {
            Gameboard gb        = (Gameboard)Session["Gameboard"];
            DateTime  end       = (DateTime)Session["RoundEnd"];
            TimeSpan  remaining = end.Subtract(DateTime.Now);
            string    dispSeconds;

            if (remaining.Minutes < 0 || remaining.Seconds < 0)
            {
                remaining = new TimeSpan(0, 0, 0);//don't display negative
            }
            if (remaining.Seconds > 9)
            {
                dispSeconds = remaining.Seconds.ToString();
            }
            else
            {
                dispSeconds = "0" + remaining.Seconds.ToString();
            }
            lblRoundInfo.Text = "Round: " + gb.currentRound + "&nbsp;&nbsp;&nbsp;&nbsp;" + "Remaining: " + remaining.Minutes + ":" + dispSeconds;
        }
Example #13
0
        /// <summary>
        /// ubdate the visibility of the buttons in the gameboard to match question states and end the round if all questions have been answered
        /// </summary>
        /// <param name="gb">current gameboard</param>
        private void updateGameboard(Gameboard gb)
        {
            bool visibleQuestions         = false;
            List <JeopardyButton> buttons = (List <JeopardyButton>)Session["GameBoardButtons"];

            foreach (JeopardyButton b in buttons)
            {
                if (gb.getQuestion(b.category, b.dollarValue).display)
                {
                    b.Visible        = true;
                    visibleQuestions = true;
                }
                else
                {
                    b.Visible = false;
                }
            }
            Session["GameBoardButtons"] = buttons;
            if (!visibleQuestions)
            {
                Response.Redirect("EndOfRound.aspx");
            }
            updateGameInfo();
        }
Example #14
0
        //update the label containing the player's name and score
        private void updateGameInfo()
        {
            Gameboard gb = (Gameboard)Session["Gameboard"];

            lblGameInfo.Text = "Player: " + Session["name"] + "&nbsp;&nbsp;&nbsp;&nbsp;" + "Score: $" + gb.currentScore;
        }