Пример #1
0
        private decimal TestCollapsingPayout(string strwheel, decimal betperline, Func <int, int, int[], Wheel> wheelEncoding)
        {
            var alchemyReelsModule = new AlchemyReelsModule(null);
            var maxWin             = 0m;
            var totalWin           = 0m;
            var maxIndexPosition   = new List <int>();
            var requestContext     = new RequestContext <SpinArgs>("", AlchemyReelsConfiguration.GameName, PlatformType.Web);
            var summData           = new SummaryData();

            AlchemyReelsCommon.CreateWheels(new List <int>()
            {
                3, 3, 3
            });

            Assert.That(strwheel, Is.Not.Null.Or.Empty);

            string[] arrstr = strwheel.Split(',');
            int[]    arr    = Array.ConvertAll(arrstr, int.Parse);

            var ugk = new UserGameKey()
            {
                UserId = -1,
                GameId = AlchemyReelsConfiguration.GameId,
                Level  = 1
            };

            var sb = new SpinBet(ugk, PlatformType.None)
            {
                LineBet    = 1,
                Credits    = 0,
                Lines      = AlchemyReelsConfiguration.BettingLines,
                Multiplier = 1
            };

            requestContext.Currency = new Currency()
            {
                Id = sb.CurrencyId
            };
            requestContext.Parameters = new SpinArgs()
            {
                LineBet = sb.LineBet, BettingLines = sb.Lines
            };
            requestContext.GameSetting = new GameSetting()
            {
                GameSettingGroupId = sb.GameSettingGroupId
            };

            var sr = new AlchemyReelsCollapsingSpinResult()
            {
                SpinBet = new SpinBet(ugk, PlatformType.None)
                {
                    Lines      = AlchemyReelsConfiguration.BettingLines,
                    Multiplier = 1,
                    LineBet    = betperline
                },

                Wheel = wheelEncoding(AlchemyReelsConfiguration.Width, AlchemyReelsConfiguration.Height, arr)
            };

            sr.TopIndices = new List <int>()
            {
                6, 6, 49
            };

            totalWin = AlchemyReelsCommon.CalculateWin(sr);

            Console.WriteLine();
            Console.WriteLine("--- POSITION TABLE ---");
            foreach (AlchemyReelTableWin tw in sr.TableWins)
            {
                Console.WriteLine(String.Format("[WIN:{0} SYM:{1} COUNT:{2}]", tw.Win, tw.Card, tw.Count));
            }

            if (sr.HasBonus)
            {
                var bonusCreated = alchemyReelsModule.CreateBonus(sr);

                var bonus = bonusCreated.Value;

                bonus.SpinTransactionId = sr.TransactionId;
                bonus.GameResult        = sr;

                var requestBonusContext = new RequestContext <BonusArgs>("", AlchemyReelsConfiguration.GameName, PlatformType.Web);

                requestBonusContext.Currency = new Currency()
                {
                    Id = sb.CurrencyId
                };
                requestBonusContext.Parameters = new BonusArgs()
                {
                    Bonus = "CollapsingSpin"
                };
                requestBonusContext.GameSetting = new GameSetting()
                {
                    GameSettingGroupId = sb.GameSettingGroupId
                };

                BonusResult bonusResult;
                int         step = bonus.CurrentStep;

                do
                {
                    var entity = new BonusEntity
                    {
                        UserId     = ugk.UserId,
                        GameId     = AlchemyReelsConfiguration.GameId,
                        Guid       = bonus.Guid.ToString("N"),
                        Data       = bonus.ToByteArray(),
                        BonusType  = bonus.GetType().Name,
                        Version    = 2,
                        IsOptional = bonus.IsOptional,
                        IsStarted  = bonus.IsStarted,
                        RoundId    = sr.RoundId
                    };

                    bonusResult = alchemyReelsModule.ExecuteBonus(AlchemyReelsConfiguration.LevelOne, entity, requestBonusContext).Value;
                    var alchemyFreeCollapsingSpinResult = bonusResult as AlchemyFreeCollapsingSpinResult;

                    var win = alchemyFreeCollapsingSpinResult.Win;

                    if (win > 0)
                    {
                        totalWin += win;
                    }

                    var maxTopIndices = alchemyFreeCollapsingSpinResult.SpinResult.TopIndices.ToList();

                    if (totalWin > maxWin)
                    {
                        maxWin = totalWin;

                        maxIndexPosition = maxTopIndices;
                    }

                    Console.WriteLine("--- POSITION TABLE ---");
                    foreach (AlchemyReelTableWin tw in alchemyFreeCollapsingSpinResult.SpinResult.TableWins)
                    {
                        Console.WriteLine(String.Format("[WIN:{0} SYM:{1} COUNT:{2}]", tw.Win, tw.Card, tw.Count));
                    }

                    bonus = bonusResult.Bonus;
                }while (!bonusResult.IsCompleted && bonusResult.Bonus != null);
            }

            Console.WriteLine($"Win            : {totalWin}");
            return(totalWin);
        }
Пример #2
0
        public void TestAlchemyReels(int gameId, int level, string currencyCode, int numusers, int numItrPerUser, decimal bet, int lines, int mp)
        {
            var sdt = DateTime.Now;

            var serviceProvider = new ServiceCollection()
                                  .AddLogging()
                                  .BuildServiceProvider();
            var logFactory = serviceProvider.GetService <ILoggerFactory>();
            var logger     = logFactory.CreateLogger <AlchemyReelsModule>();

            var alchemyReelsModule = new AlchemyReelsModule(logger);
            var maxWin             = 0m;

            AlchemyReelsCommon.CreateWheels(new List <int>()
            {
                3, 3, 3
            });

            var summData = new SummaryData();
            var users    = GenerateUsers(gameId, numusers, level);
            var sbs      = GenerateUserBets(users, bet, lines, mp);

            var requestContext = new RequestContext <SpinArgs>("", AlchemyReelsConfiguration.GameName, PlatformType.Web);

            var requestBonusContext = new RequestContext <BonusArgs>("", AlchemyReelsConfiguration.GameName, PlatformType.Web);

            Parallel.ForEach(users,
                             () => new SummaryData(),
                             (key, state, sdata) =>
            {
                var sb = sbs[key.UserId];
                requestContext.Currency = new Currency()
                {
                    Id = sb.CurrencyId
                };
                requestContext.Parameters = new SpinArgs()
                {
                    LineBet = sb.LineBet, BettingLines = sb.Lines
                };
                requestContext.GameSetting = new GameSetting()
                {
                    GameSettingGroupId = sb.GameSettingGroupId
                };

                for (var i = 0; i < numItrPerUser; ++i)
                {
                    var sr = alchemyReelsModule.ExecuteSpin(level, new UserGameSpinData(), requestContext).Value as AlchemyReelsCollapsingSpinResult;

                    if (sr.Win > maxWin)
                    {
                        maxWin = sr.Win;
                    }

                    UpdateSummaryData(sdata, sr);
                    UpdateAlchemyReelsSummaryData(sdata, sr);

                    if (sr.HasBonus)
                    {
                        var bonusCreated = alchemyReelsModule.CreateBonus(sr);

                        var bonus = bonusCreated.Value;

                        bonus.SpinTransactionId = sr.TransactionId;
                        bonus.GameResult        = sr;

                        requestBonusContext.Currency = new Currency()
                        {
                            Id = sb.CurrencyId
                        };
                        requestBonusContext.Parameters = new BonusArgs()
                        {
                            Bonus = "CollapsingSpin"
                        };
                        requestBonusContext.GameSetting = new GameSetting()
                        {
                            GameSettingGroupId = sb.GameSettingGroupId
                        };

                        BonusResult bonusResult;
                        var step = bonus.CurrentStep;

                        do
                        {
                            var entity = new BonusEntity
                            {
                                UserId     = key.UserId,
                                GameId     = AlchemyReelsConfiguration.GameId,
                                Guid       = bonus.Guid.ToString("N"),
                                Data       = bonus.ToByteArray(),
                                BonusType  = bonus.GetType().Name,
                                Version    = 2,
                                IsOptional = bonus.IsOptional,
                                IsStarted  = bonus.IsStarted,
                                RoundId    = sr.RoundId
                            };

                            bonusResult = alchemyReelsModule.ExecuteBonus(level, entity, requestBonusContext).Value;
                            var alchemyFreeCollapsingSpinResult = bonusResult as AlchemyFreeCollapsingSpinResult;

                            UpdateSummaryDataCollapsing(sdata, alchemyFreeCollapsingSpinResult.SpinResult);
                            UpdateAlchemyReelsSummaryData(sdata, alchemyFreeCollapsingSpinResult.SpinResult);

                            bonus = bonusResult.Bonus;
                        }while (!bonusResult.IsCompleted && bonusResult.Bonus != null);
                    }
                }

                return(sdata);
            },
                             sdata =>
            {
                lock (summData)
                {
                    summData.Sum(sdata);
                }
            });

            DisplayAlchemyReelsSummaryData(level, bet, lines, summData, sdt, maxWin, null);
        }
Пример #3
0
        private decimal TestPayout(string strwheel, decimal betperline, Func <int, int, int[], Wheel> wheelEncoding)
        {
            var alchemyReelsModule = new AlchemyReelsModule(null);
            var requestContext     = new RequestContext <SpinArgs>("", AlchemyReelsConfiguration.GameName, PlatformType.Web);

            AlchemyReelsCommon.CreateWheels(new List <int>()
            {
                5, 5, 5
            });

            Assert.That(strwheel, Is.Not.Null.Or.Empty);

            var arrstr = strwheel.Split(',');
            var arr    = Array.ConvertAll(arrstr, int.Parse);

            var ugk = new UserGameKey()
            {
                UserId = -1,
                GameId = AlchemyReelsConfiguration.GameId,
                Level  = 1
            };

            var sb = new SpinBet(ugk, PlatformType.None)
            {
                LineBet    = 1,
                Credits    = 0,
                Lines      = AlchemyReelsConfiguration.BettingLines,
                Multiplier = 1
            };

            requestContext.Currency = new Currency()
            {
                Id = sb.CurrencyId
            };
            requestContext.Parameters = new SpinArgs()
            {
                LineBet = sb.LineBet, BettingLines = sb.Lines
            };
            requestContext.GameSetting = new GameSetting()
            {
                GameSettingGroupId = sb.GameSettingGroupId
            };

            var sr = new AlchemyReelsCollapsingSpinResult()
            {
                SpinBet = new SpinBet(ugk, PlatformType.None)
                {
                    Lines      = AlchemyReelsConfiguration.BettingLines,
                    Multiplier = 1,
                    LineBet    = betperline
                },

                Wheel = wheelEncoding(AlchemyReelsConfiguration.Width, AlchemyReelsConfiguration.Height, arr)
            };

            var win = AlchemyReelsCommon.CalculateWin(sr);

            Console.WriteLine("--- WIN POSITION ---");
            foreach (AlcheryReelsWinPosition wp in sr.WinPositions)
            {
                Console.WriteLine(String.Format("[LINE:{0} MUL:{1} WIN:{2}]", wp.Line, wp.Multiplier, wp.Win));
            }

            Console.WriteLine();
            Console.WriteLine("--- WIN TABLE ---");
            foreach (AlchemyReelTableWin tw in sr.TableWins)
            {
                Console.WriteLine(String.Format("[CARD:{0} COUNT:{1} WILD:{2}]", tw.Card, tw.Count, tw.Wild));
            }

            return(win);
        }
Пример #4
0
        public void TestAlchemyReelsFullCycle(int level, List <int> rows)
        {
            var sdt             = DateTime.Now;
            var serviceProvider = new ServiceCollection()
                                  .AddLogging()
                                  .BuildServiceProvider();
            var logFactory = serviceProvider.GetService <ILoggerFactory>();
            var logger     = logFactory.CreateLogger <AlchemyReelsModule>();

            var alchemyReelsModule = new AlchemyReelsModule(logger);
            var maxWin             = 0m;
            var profile            = new Dictionary <decimal, int>();
            var maxIndexPosition   = new List <int>();

            AlchemyReelsCommon.CreateWheels(rows);

            var summData = new SummaryData();

            for (var reel0 = 0; reel0 < AlchemyReelsConfiguration.Wheels[level].Reels[0].Count; reel0++)
            {
                for (var reel1 = 0; reel1 < AlchemyReelsConfiguration.Wheels[level].Reels[1].Count; reel1++)
                {
                    for (var reel2 = 0; reel2 < AlchemyReelsConfiguration.Wheels[level].Reels[2].Count; reel2++)
                    {
                        var totalWin = (decimal)0;

                        var ugk = new UserGameKey()
                        {
                            UserId = -1,
                            GameId = AlchemyReelsConfiguration.GameId,
                            Level  = 1
                        };

                        var sb = new SpinBet(ugk, PlatformType.None)
                        {
                            LineBet    = 1,
                            Credits    = 0,
                            Lines      = AlchemyReelsConfiguration.BettingLines,
                            Multiplier = 1
                        };

                        var requestContext      = new RequestContext <SpinArgs>("", AlchemyReelsConfiguration.GameName, PlatformType.Web);
                        var requestBonusContext = new RequestContext <BonusArgs>("", AlchemyReelsConfiguration.GameName, PlatformType.Web);
                        requestContext.Currency = new Currency()
                        {
                            Id = sb.CurrencyId
                        };
                        requestContext.Parameters = new SpinArgs()
                        {
                            LineBet = sb.LineBet, BettingLines = sb.Lines
                        };
                        requestContext.GameSetting = new GameSetting()
                        {
                            GameSettingGroupId = sb.GameSettingGroupId
                        };

                        var wheel = new Wheel(rows);
                        wheel.Reels[0] = GetRange(AlchemyReelsConfiguration.Wheels[level].Reels[0], reel0, wheel.Rows[0]);
                        wheel.Reels[1] = GetRange(AlchemyReelsConfiguration.Wheels[level].Reels[1], reel1, wheel.Rows[1]);
                        wheel.Reels[2] = GetRange(AlchemyReelsConfiguration.Wheels[level].Reels[2], reel2, wheel.Rows[2]);

                        var sr = new AlchemyReelsCollapsingSpinResult()
                        {
                            SpinBet = new SpinBet(ugk, PlatformType.None)
                            {
                                Lines      = AlchemyReelsConfiguration.BettingLines,
                                Multiplier = 1,
                                LineBet    = 1m
                            },

                            Wheel = wheel
                        };

                        sr.Wheel      = wheel;
                        sr.TopIndices = new List <int>()
                        {
                            reel0, reel1, reel2
                        };

                        AlchemyReelsCommon.CalculateWin(sr);

                        totalWin = sr.Win;

                        UpdateSummaryData(summData, sr);
                        UpdateAlchemyReelsSummaryData(summData, sr);

                        if (sr.HasBonus)
                        {
                            var bonusCreated = alchemyReelsModule.CreateBonus(sr);

                            var bonus = bonusCreated.Value;

                            bonus.SpinTransactionId = sr.TransactionId;
                            bonus.GameResult        = sr;

                            requestBonusContext.Currency = new Currency()
                            {
                                Id = sb.CurrencyId
                            };
                            requestBonusContext.Parameters = new BonusArgs()
                            {
                                Bonus = "CollapsingSpin"
                            };
                            requestBonusContext.GameSetting = new GameSetting()
                            {
                                GameSettingGroupId = sb.GameSettingGroupId
                            };

                            BonusResult bonusResult;
                            var         step = bonus.CurrentStep;

                            do
                            {
                                var entity = new BonusEntity
                                {
                                    UserId     = ugk.UserId,
                                    GameId     = AlchemyReelsConfiguration.GameId,
                                    Guid       = bonus.Guid.ToString("N"),
                                    Data       = bonus.ToByteArray(),
                                    BonusType  = bonus.GetType().Name,
                                    Version    = 2,
                                    IsOptional = bonus.IsOptional,
                                    IsStarted  = bonus.IsStarted,
                                    RoundId    = sr.RoundId
                                };

                                bonusResult = alchemyReelsModule.ExecuteBonus(level, entity, requestBonusContext).Value;
                                var alchemyFreeCollapsingSpinResult = bonusResult as AlchemyFreeCollapsingSpinResult;

                                var win = alchemyFreeCollapsingSpinResult.Win;

                                if (win > 0)
                                {
                                    totalWin += win;
                                }

                                var maxTopIndices = alchemyFreeCollapsingSpinResult.SpinResult.TopIndices.ToList();

                                if (totalWin > maxWin)
                                {
                                    maxWin = totalWin;

                                    maxIndexPosition = maxTopIndices;
                                }

                                UpdateSummaryDataCollapsing(summData, alchemyFreeCollapsingSpinResult.SpinResult);
                                UpdateAlchemyReelsSummaryData(summData, alchemyFreeCollapsingSpinResult.SpinResult);

                                bonus = bonusResult.Bonus;
                            }while (!bonusResult.IsCompleted && bonusResult.Bonus != null);
                        }

                        if (!profile.ContainsKey(totalWin))
                        {
                            profile.Add(totalWin, 1);
                        }
                        else
                        {
                            profile.TryGetValue(totalWin, out int count);
                            profile.Remove(totalWin);
                            profile.Add(totalWin, count + 1);
                        }
                    }
                }
            }

            DisplayAlchemyReelsSummaryData(level, 1, 10, summData, sdt, maxWin, maxIndexPosition);
            if (profile != null)
            {
                foreach (var item in profile.OrderByDescending(p => p.Key))
                {
                    Console.WriteLine($"Win            : {item.Key}; {item.Value}");
                }
            }
        }