Пример #1
0
        private void SpinBtn_Click(object sender, EventArgs e)
        {
            this.bet = betNumericUpDown.Value;

            this.credits = Convert.ToDecimal(CreditsVal.Text);

            if (bet <= this.credits && bet > 0)
            {
                RemoveBetFromCredits(this.credits, this.bet);

                var slotMachineItems      = this.slotMachineItemsProvider.GetSlotMachineItems();
                var SlotMachineItemsArray = SlotMachineHelper.Shuffle(slotMachineItems);

                var slotMachineItemsMatrix = this.matrixProvider.GenerateMatrix(SlotMachineItemsArray, MatrixSizeConstants.Rows, MatrixSizeConstants.Cols);
                var pictureBoxes           = Controls.OfType <PictureBox>();

                var picBoxMatrix = matrixProvider.GetPictureBoxMatrix(pictureBoxes, MatrixSizeConstants.Rows, MatrixSizeConstants.Cols);
                FillSlotMachinePictireBoxesWithSlotMAchineItemsImages(slotMachineItemsMatrix, picBoxMatrix);

                var winCoef = GetTotalWinningRowsCoefficient(slotMachineItemsMatrix);
                if (winCoef > 0)
                {
                    var winAmount = AddCreditsToCreditsAmount(this.bet, winCoef);

                    SetSpinResultText(SpinResultText.Win, winAmount);
                }
                else
                {
                    SetSpinResultText(SpinResultText.Loss, bet);
                }
            }
            else if (this.credits <= 0)
            {
                decimal dialogResult = Prompt.ShowEnterCreditsDialog("You don't have enough credits. Please add more to continue playing", "Not enough credits");

                SetCreditsAmount(dialogResult);
            }
            else if (this.bet > this.credits)
            {
                Prompt.ShowInformationDialog("You're bet is bigger than your credits. Please lower your bet to continue playing", "Bet bigger than credits");
            }
        }