示例#1
0
 /// <summary>
 /// Starts a game of durak
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BtPlay_Click(object sender, EventArgs e)
 {
     if (IsDeckSizeSelected())
     {
         durakPage = new DurakPage(GetHumanPlayer(), GetEnemyPlayer(), GetPlayerSelectedDeck(), rdNewbieMode.Checked);
         this.Parent.Controls.Add(durakPage);
         PlayDurak.SetScreenVisible(this.Parent.Controls, durakPage);
     }
     else
     {
         MessageBox.Show("Error! Deck size must be selected");
     }
 }
示例#2
0
        /// <summary>
        /// Checks if the game should be ended and who is the winner
        /// </summary>
        public void DetermineGameEnd()
        {
            Win result = new Win();

            if (drawDeckViewer.Controls.Count == 0)
            {
                if (playerDeckViewer.Controls.Count == 0 && enemyDeckViewer.Controls.Count == 0)
                {
                    //It's a tie!
                    this.Parent.Controls.Add(result);
                    result.LabelText = "Tie Game";

                    if (this.Parent is PlayDurak)
                    {
                        PlayDurak.SetScreenVisible(this.Parent.Controls, result);
                    }
                }
                else if (playerDeckViewer.Controls.Count == 0)
                {
                    //The human player wins!
                    this.Parent.Controls.Add(result);
                    result.LabelText = "You Win !!";

                    if (this.Parent is PlayDurak)
                    {
                        PlayDurak.SetScreenVisible(this.Parent.Controls, result);
                    }
                }
                else
                {
                    //The AI wins!
                    this.Parent.Controls.Add(result);
                    result.LabelText = "You are the Durak!";
                    if (this.Parent is PlayDurak)
                    {
                        PlayDurak.SetScreenVisible(this.Parent.Controls, result);
                    }
                }
            }
        }