コード例 #1
0
        public static List <ISlotMachineItem> Shuffle(List <ISlotMachineItem> list)
        {
            int n = list.Count;

            while (n > 1)
            {
                n--;
                int k = random.Next(n + 1);
                ISlotMachineItem value = list[k];
                list[k] = list[n];
                list[n] = value;
            }
            return(list);
        }
コード例 #2
0
        public ISlotMachineItem[,] GenerateMatrix(IList <ISlotMachineItem> items, int rows, int cols)
        {
            var randomNumberProvider = new RandomNumberProvider();
            var slotMachiteItems     = items;

            var matrix = new ISlotMachineItem[rows, cols];

            for (int row = 0; row < rows; row++)
            {
                for (int col = 0; col < cols; col++)
                {
                    var randomNumber = randomNumberProvider.GetRandomNumber(0, 100);

                    matrix[row, col] = slotMachiteItems[randomNumber];
                }
            }

            return(matrix);
        }
コード例 #3
0
        private decimal GetTotalWinningRowsCoefficient(ISlotMachineItem[,] matrix)
        {
            decimal totalCoefficient = 0;

            for (int row = 0; row < matrix.GetLength(0); row++)
            {
                decimal          rowCoefficient = 0;
                bool             isWinningRow   = true;
                ISlotMachineItem prevItem       = null;

                for (int col = 0; col < matrix.GetLength(1); col++)
                {
                    var currentItem = matrix[row, col];

                    if (currentItem.IsWildCard)
                    {
                        continue;
                    }

                    if (prevItem != null && prevItem != currentItem)
                    {
                        isWinningRow = false;

                        break;
                    }

                    rowCoefficient += currentItem.Coefficient;
                    prevItem        = currentItem;
                }
                if (isWinningRow)
                {
                    totalCoefficient += rowCoefficient;
                }
            }
            return(totalCoefficient);
        }