示例#1
0
        public decimal Evaluate(List <List <GameItemChanceOutOf100> > slotMatrix)
        {
            if (slotMatrix.Count < 3 || slotMatrix[0].Count < 3)
            {
                throw new ArgumentException("Slot matrix's dimentions should be atleast 3x3!");
            }
            var     wildCard   = GetEnumValuesCached().First();
            decimal addedCoefs = 0;

            for (int i = 0; i < slotMatrix.Count; i++)
            {
                bool rowJackpot = true;

                GameItemChanceOutOf100 rowUniqueItem = wildCard;
                for (int j = 0; j < slotMatrix[i].Count; j++)
                {
                    if (rowUniqueItem == wildCard && slotMatrix[i][j] != wildCard)
                    {
                        rowUniqueItem = slotMatrix[i][j];
                    }
                    if (slotMatrix[i][j] != rowUniqueItem && slotMatrix[i][j] != wildCard)
                    {
                        rowJackpot = false;
                        break;
                    }
                }
                if (rowJackpot)
                {
                    addedCoefs += CalculateJackpotRowCoeff(slotMatrix[i]);
                }
            }
            return(addedCoefs);
        }
示例#2
0
        private decimal GetCoefficient(GameItemChanceOutOf100 item)
        {
            var cacheChances = cache.GetOrCreate("GameRowWinCoefficients", entry =>
            {
                try
                {
                    var coeffsAsJson        = reader.ReadAllFrom(@"..\BedeSlots.Services\GameCoefficients.json");
                    entry.SlidingExpiration = TimeSpan.FromHours(1);
                    return(JsonConvert.DeserializeObject <Dictionary <string, decimal> >(coeffsAsJson));
                }
                catch (Exception)
                {
                    var defaultRates = new Dictionary <string, decimal>();
                    defaultRates[GameItemChanceOutOf100.Apple.ToString()]     = 0.4M;
                    defaultRates[GameItemChanceOutOf100.Pen.ToString()]       = 0.6M;
                    defaultRates[GameItemChanceOutOf100.Pineapple.ToString()] = 0.8M;
                    defaultRates[GameItemChanceOutOf100.PPAP.ToString()]      = 0.0M;
                    return(defaultRates);
                }
            });

            return(cacheChances[item.ToString()]);
        }