Example #1
0
        /// <summary>
        /// Enables the current player's turn
        /// </summary>
        private void GetCurrentPlayer()
        {
            Player p = wheel.GetCurrentPlayer();

            foreach (var label in playerLabels)
            {
                if (label.Text == p.Name)
                {
                    label.ForeColor = Color.Red;
                }
                else
                {
                    label.ForeColor = Color.Black;
                }
            }

            if (p.Name == user.Name)
            {
                isUsersTurn            = true;
                isSpinning             = true;
                prizeWheel             = new PrizeWheel(wheel);
                prizeWheel.FormClosed += (_, _) => prizeWheel = null;
                Hide();
                prizeWheel.ShowDialog(this);
                lbl_CurrentPrize.Text = wheel.CurrentPrize().ToString("C0");
                Show();

                isSpinning = false;
            }
            else
            {
                isUsersTurn = false;
            }
        }
Example #2
0
        public EndGameDialog(IWheel wheel)
        {
            InitializeComponent();
            lbl_Outcome.Text =
                $@"{wheel.GetCurrentPlayer()} successfully solved the phrase:""{wheel.GetCurrentPhrase()}""";

            var sortedPlayers = wheel.GetAllPlayers().ToList().OrderByDescending(p => p.Score).ToList();

            for (int i = 1; i <= sortedPlayers.Count; i++)
            {
                switch (i)
                {
                case 1:
                    lbl_Player1.Text    = $@"Winner: {sortedPlayers[i-1]} - {sortedPlayers[i-1].Score:C0}";
                    lbl_Player1.Visible = true;
                    break;

                case 2:
                    lbl_Player2.Text    = $@"2nd Place: {sortedPlayers[i-1]} - {sortedPlayers[i-1].Score:C0}";
                    lbl_Player2.Visible = true;
                    break;

                case 3:
                    lbl_Player3.Text    = $@"3rd Place: {sortedPlayers[i-1]} - {sortedPlayers[i-1].Score:C0}";
                    lbl_Player3.Visible = true;
                    break;

                case 4:
                    lbl_Player4.Text    = $@"4th Place: {sortedPlayers[i-1]} - {sortedPlayers[i-1].Score:C0}";
                    lbl_Player4.Visible = true;
                    break;
                }
            }
        }