Ejemplo n.º 1
0
        /// <summary>
        /// Method  that handles all activities for player 3 and resets configuration for player 1.
        /// </summary>
        private void Player3_Turn()
        {
            try
            {
                if (game.IsActive)
                {
                    timeLeft = 25;

                    game.Turn        = player3;
                    picP2.BackColor  = Color.FromArgb(0, 128, 55);
                    picP3.BackColor  = Color.FromArgb(255, 255, 128);
                    lblTurnName.Text = $"{player3.Name}'s";

                    //Pauses the turn for the player between 1-5 seconds,otherwise it will turns will almost
                    //become instantenous
                    PauseForMilliSeconds(r.Next(1000, 5000));
                    player3.Turn(aDeck, dumpCards, PanelDump);
                    UpdateStockCount();

                    // Handles dump card for player 3
                    PauseForMilliSeconds(r.Next(5000, 7000));
                    DumpCard(player3);

                    player3.PlayHand.Sort();
                    Hand.ShowHandBack(player3.CardsPanel, player3.PlayHand);
                    player3.ScoreUpdate();

                    //Checkgame status
                    CheckGameStatus();

                    //reset to P1's Turn
                    picP3.BackColor     = Color.FromArgb(0, 128, 55);
                    picP1.BackColor     = Color.FromArgb(255, 255, 128);
                    PanelHandP1.Enabled = false;
                    lblTurnName.Text    = $"{player1.Name}'s";
                    timeLeft            = 25;
                    game.Turn           = player1;
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Method  that handles all activities for player 2.
        /// </summary>
        private void Player2_Turn()
        {
            try
            {
                if (game.IsActive)
                {
                    //Reset timer info
                    timeLeft = 25;
                    timerP1.Start();

                    game.Turn        = player2;
                    picP1.BackColor  = Color.FromArgb(0, 128, 55);
                    picP2.BackColor  = Color.FromArgb(255, 255, 128);
                    lblTurnName.Text = $"{player2.Name}'s";

                    //Pauses the turn for the player between 1-5 seconds,otherwise it will turns will almost
                    //become instantenous
                    PauseForMilliSeconds(r.Next(1000, 5000));
                    player2.Turn(aDeck, dumpCards, PanelDump);

                    UpdateStockCount();

                    //Pauses the turn for the player between 5-15 seconds,otherwise it will turns will almost
                    //become instantenous
                    PauseForMilliSeconds(r.Next(5000, 7000));
                    // Handles dump card for player 2
                    DumpCard(player2);

                    player2.PlayHand.Sort();
                    Hand.ShowHandBack(player2.CardsPanel, player2.PlayHand);

                    //Check game status
                    CheckGameStatus();

                    //Calls for Player 3's turn
                    Player3_Turn();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);;
            }
        }