示例#1
0
        private void win()
        {
            int    s1, s2, s3, s4;
            Player winner = p1;
            bool   tie    = false;

            s1 = p1.getScore();
            s2 = p2.getScore();
            s3 = p3.getScore();
            s4 = p4.getScore();

            if (s1 > s2 && s1 > s3 && s1 > s4)
            {
                winner = p1;
            }
            else if (s2 > s1 && s2 > s3 && s2 > s4)
            {
                winner = p2;
            }
            else if (s3 > s1 && s3 > s2 && s3 > s4)
            {
                winner = p3;
            }
            else if (s4 > s1 && s4 > s2 && s4 > s3)
            {
                winner = p4;
            }
            else
            {
                tie = true;
            }

            if (!tie)
            {
                active_player_label.Text = winner.getName() + " is the winner!";
            }
            else
            {
                active_player_label.Text = "Tie game!";
            }

            bool replay = false;

            using (Form3 f3 = new Form3())
            {
                f3.ShowDialog();
                replay = f3.replay;
            }

            if (replay)
            {
                setUp();
                plus_score_label.Visible = false;
                this.Invalidate();
            }
            else
            {
                this.Close();
            }
        }
示例#2
0
        private void givePoints()
        {
            int poss = activePlayer.getPoss();

            if (poss % 3 == 0)
            {
                activePlayer.setScore(activePlayer.getScore() + 3);
                plus_score_label.ForeColor = activePlayer.getColor();
                plus_score_label.Text      = "+3";
                plus_score_label.Visible   = true;
            }
            if (poss % 5 == 0)
            {
                activePlayer.setScore(activePlayer.getScore() + 5);
                plus_score_label.ForeColor = activePlayer.getColor();
                plus_score_label.Text      = "+5";
                plus_score_label.Visible   = true;
            }

            if
            (activePlayer.getPlayerNum() == 1)
            {
                p1_score.Text = activePlayer.getScore() + "";
            }
            else if (activePlayer.getPlayerNum() == 2)
            {
                p2_score.Text = activePlayer.getScore() + "";
            }
            else if (activePlayer.getPlayerNum() == 3)
            {
                p3_score.Text = activePlayer.getScore() + "";
            }
            else if (activePlayer.getPlayerNum() == 4)
            {
                p4_score.Text = activePlayer.getScore() + "";
            }
        }