コード例 #1
0
        private void questionFormToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //TODO : Button Click for Roll -> Load method Roll();
            using (frmQuestion question = new frmQuestion(Game.Players[pTurn]))
            {
                DialogResult result = question.ShowDialog();
                while (result != DialogResult.OK)
                {
                    MessageBox.Show("Error! The form seems to have went missing...");
                    result = question.ShowDialog();
                }

                if (result == DialogResult.OK)
                {
                    bool allowedToRoll = false;

                    if (question.answeredQuestion == true)
                    {
                        Game.Players[pTurn].Score += 1;
                        question.answeredQuestion  = false;
                        allowedToRoll              = true;

                        if (allowedToRoll == true)
                        {
                            //Roll();
                            allowedToRoll = false;
                        }
                    }

                    updatePlayers();
                }
            }
        }
コード例 #2
0
        private void btnRoll_Click(object sender, EventArgs e)
        {
            using (frmQuestion question = new frmQuestion(Game.Players[pTurn]))
            {
                DialogResult questionFormResult = question.ShowDialog();
                while (questionFormResult != DialogResult.OK)
                {
                    MessageBox.Show("Well... that question just disappeared. Lets try that again.");
                    questionFormResult = question.ShowDialog();
                }

                if (questionFormResult == DialogResult.OK)
                {
                    if (question.answeredQuestion == true)
                    {
                        if (question.outOfQuestions && !noQuestions)
                        {
                            MessageBox.Show("Out of Questions.");
                            question.outOfQuestions = false;
                            noQuestions             = true;
                        }

                        if (Game.Players[pTurn].IsInJail)
                        {
                            Game.Players[pTurn].JailDuration = Game.Players[pTurn].JailDuration + 1;
                        }

                        Game.Players[pTurn].Score += 1;
                        question.answeredQuestion  = false;

                        if (!Game.Players[pTurn].IsInJail)
                        {
                            using (frmRollDice roll = new frmRollDice())
                            {
                                DialogResult result = roll.ShowDialog();
                                if (result == DialogResult.OK)
                                {
                                    mroll = roll.roll;
                                }
                            }

                            removePlayerToken();

                            Game.Players[pTurn].Position = Game.Players[pTurn].Position + mroll;

                            if (Game.Players[pTurn].Position >= 27)
                            {
                                if (Game.Players[pTurn].Position > 27)
                                {
                                    PlayerPassedGo();
                                }

                                Game.Players[pTurn].Position = Game.Players[pTurn].Position - 27;
                            }

                            setPlayerToken();

                            using (frmProperty property = new frmProperty(Game.Players[pTurn], boardProperties[Game.Players[pTurn].Position]))
                            {
                                DialogResult answerFormResult = property.ShowDialog();
                                while (answerFormResult != DialogResult.OK)
                                {
                                    MessageBox.Show("Well... Properties have to be bought, and Rents have to be paid.\nYou just can't \"x\" the problem away...");
                                    answerFormResult = property.ShowDialog();
                                }

                                if (answerFormResult == DialogResult.OK)
                                {
                                    if (property.isValidSelection == true)
                                    {
                                        property.isValidSelection = false;
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (Game.Players[pTurn].JailDuration >= 3)
                            {
                                Game.Players[pTurn].IsInJail     = false;
                                Game.Players[pTurn].JailDuration = 0;
                            }

                            if (Game.Players[pTurn].IsInJail)
                            {
                                using (frmProperty property = new frmProperty(Game.Players[pTurn], boardProperties[Game.Players[pTurn].Position]))
                                {
                                    DialogResult answerFormResult = property.ShowDialog();
                                    if (answerFormResult != DialogResult.OK)
                                    {
                                        MessageBox.Show("I guess you don't want to bail then..");
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (pTurn >= (Game.Players.Count - 1))
            {
                pTurn = 0;
                lblP1IsTurn.Visible = true;
                lblP2IsTurn.Visible = false;
            }
            else
            {
                pTurn++;
                lblP1IsTurn.Visible = false;
                lblP2IsTurn.Visible = true;
            }

            updatePlayers();
        }